// JavaScript Document
var sAjaxSource = window.location + "&formtype=table";

function confirm_check(url,mess)
{
	anser=confirm(mess)
	
	if(anser==true)
		window.location = url
}
function linkto(url)
{
	window.location = url
}
function createInput(type,name,value,stype)
{
	return '<input type="'+type+'" name="'+name+'" value="'+value+'" "'+stype+'">';
}
function searchMatrix(matrix,col,need)
{
	for(i=0;i < matrix.length ;i++)
		if(matrix[i][col]==need)
			return i
	return -1
}
function getPosOfNode(idparent,eid)
{
	var e = document.getElementById(idparent);
	i=0
	chi=e.childNodes[i]
	while(chi)
	{
		if(chi.id == eid)
			return i
		
		i++
		chi=e.childNodes[i]
	}
	return -1
}

function setCKEditorType(strID, intType)
{
	switch (intType)
	{
		case 0: // giao dien full
		CKEDITOR.replace( strID,
				{
					toolbar : [ ['Source','-','Save','NewPage','Preview','-','Templates'],['Cut','Copy','Paste','PasteText','PasteFromWord','-','Print','SpellChecker','Scayt'],['Undo','Redo','-','Find','Replace','-','SelectAll','RemoveFormat'],['Form','Checkbox','Radio','TextField','Textarea','Select','Button','ImageButton','HiddenField'],'/',['Bold','Italic','Underline','Strike','-','Subscript','Superscript'],['NumberedList','BulletedList','-','Outdent','Indent','Blockquote'],['JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock'],['Link','Unlink','Anchor'],['Image','Flash','Table','HorizontalRule','Smiley','SpecialChar','PageBreak'],'/',['Styles','Format','Font','FontSize'],['TextColor','BGColor'],['Maximize','ShowBlocks','-','About'] ]
				});
		break;
		
		case 1: //Giao dien simply nhat
		CKEDITOR.replace( strID,
				{
					toolbar : [ ['Bold','Italic','Underline'],['Font','FontSize','TextColor','BGColor'],['Smiley'],['Link','Unlink'],['NumberedList','BulletedList'],['Outdent','Indent'],['JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock'],['RemoveFormat'],['Maximize'] ]
				});
		break;
		
		case 2: //giao dien edit content
		CKEDITOR.replace( strID,
				{
					toolbar : [ ['Bold','Italic','Underline'],['Font','FontSize','TextColor','BGColor'],['Smiley'],['Link','Unlink'],['NumberedList','BulletedList'],['Outdent','Indent'],['JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock'],['RemoveFormat'],['Maximize'],['PasteText','PasteFromWord'],['Flash','Table','HorizontalRule','Smiley','SpecialChar'] ]
				});
		break;
		
		case 3:
		CKEDITOR.replace( strID,
				{
					toolbar : [ ['Source','-','Save','NewPage','Preview','-','Templates'],['Cut','Copy','Paste','PasteText','PasteFromWord','-','Print','SpellChecker','Scayt'],['Undo','Redo','-','Find','Replace','-','SelectAll','RemoveFormat'],['Form','Checkbox','Radio','TextField','Textarea','Select','Button','ImageButton','HiddenField'],'/',['Bold','Italic','Underline','Strike','-','Subscript','Superscript'],['NumberedList','BulletedList','-','Outdent','Indent','Blockquote'],['JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock'],['Link','Unlink','Anchor'],['Image','Flash','Table','HorizontalRule','Smiley','SpecialChar','PageBreak'],'/',['Styles','Format','Font','FontSize'],['TextColor','BGColor'],['Maximize','ShowBlocks','-','About'] ]
				});
		break;
	}
	
	CKEDITOR.config.contentsCss = ['../view/skin1/css/content.css'];
}


function importJavaScript(jsFile) {
	
	var scriptElt = document.createElement('script');
	
	scriptElt.type = 'text/javascript';
	
	scriptElt.src = jsFile;
	
	document.getElementsByTagName('head')[0].appendChild(scriptElt);

}

function loadPopup(id)
{
	$("#popupbody").load("index.php?route=core/fileadjust&id="+id);
	
	$.blockUI(
	{ 
		message: $('#popup'),
		css: { 
			top:  ($(window).height() - 500) /2 + 'px', 
			left: ($(window).width() - 600) /2 + 'px', 
			width: '700px',
			height: '500px'
			}
	});
}