<!--
function LTrim(iStr)
{
	while (iStr.charCodeAt(0) <= 32)
	{
		iStr=iStr.substr(1);
	}
	return iStr;
}

function RTrim(iStr)
{
	while (iStr.charCodeAt(iStr.length - 1) <= 32)
	{
		iStr=iStr.substr(0, iStr.length - 1);
	}
	return iStr;
}

function Trim(iStr)
{
	while (iStr.charCodeAt(0) <= 32)
	{
		iStr=iStr.substr(1);
	}

	while (iStr.charCodeAt(iStr.length - 1) <= 32)
	{
		iStr=iStr.substr(0, iStr.length - 1);
	}

	return iStr;
}

function CheckEmailAddress(Email)
{
	Email = Trim(Email);

	while (Email != '')
	{
		c = Email.charAt(0);	
		if (c==' ' || c=='<' || c==39 || c==':' || c=='.')
		{
			Email = Email.substr(1);
		}
		else
		{
			break;
		}
	}

	i = Email.indexOf('>');
	if (i==-1)
	{
		while (Email != '')
		{
			c = Email.charAt(Email.length - 1);
			if (c==' ' || c==39 || c=='.')
			{
				Email = Email.substr(0, Email.length - 1);
			}
			else
			{
				break;
			}
		}
	}
	else
	{
		Email = Email.substr(0, i);
	}

	if (Email.length > 96)
		return '';

	i = Email.lastIndexOf('@');
	j = Email.lastIndexOf('.');
	if (i < j)
		i = j;

	switch (Email.length - i - 1)
	{
	case 2:
		break;
	case 3:
		switch (Email.substr(i))
		{
		case '.com':
		case '.net':
		case '.org':
		case '.edu':
		case '.mil':
		case '.gov':
		case '.biz':
		case '.pro':
		case '.int':
			break;
		default:
			return '';
		}
		break;
	default:
		switch (Email.substr(i))
		{
		case '.name':
		case '.info':
			break;
		default:
			return '';
		}
		break;
	}

	Email = Email.toLowerCase();

	if (Email == '')
		return '';

	if (Email.indexOf(' ') != -1)
		return '';

	if (Email.indexOf('..') != -1)
		return '';

	if (Email.indexOf('.@') != -1)
		return '';

	if (Email.indexOf('@.') != -1)
		return '';

	if (Email.indexOf(':') != -1)
		return '';

	for (i=0; i < Email.length; i++)
	{
		c = Email.charAt(i);

		if (c >= '0' && c <= '9')
			continue;
		
		if (c >= 'a' && c <= 'z')
			continue;
		
		if ('`~!#$%^&*-_+=?/\\|@.'.indexOf(c) != -1)
			continue;

		return '';
	}

	if ((i=Email.indexOf('@'))==-1)
		return '';

	if (Email.substr(i + 1).indexOf('@')!=-1)
		return '';

	if (Email.charAt(0)=='.' || Email.charAt(Email.length - 1)=='.')
		return '';

	return Email;
}
function PrintNews(gid,id){
	popUpContent("print.html", 788, 600);
}
function Block(block){
	document.getElementById(block).style.display = "block"
}
function resize() {
	if ( typeof( self.sizeToContent ) == 'function' ) {
	
        self.sizeToContent();

			return;
    
	}
	if (document.getElementById && typeof(document.getElementById('querywindowcontainer')) != 'undefined' ) {
		var newWidth  = document.getElementById('querywindowcontainer').offsetWidth;
		var newHeight = document.getElementById('querywindowcontainer').offsetHeight;
		self.resizeTo( newWidth + 45, newHeight + 75 );

	}
}
function popUpImage(theURL,width, height)
{
	width = width-0+17;
	height=height;
	if (width > screen.width) width=screen.width;
	if (height > screen.height) height=screen.height-60;
	popUpWin = window.open(theURL,'ViewFullImage',"toolbar=no,width="+ width+",height="+ height+ ",directories=no,status=no,scrollbars=yes,resizable=yes, menubar=no");
	popUpWin.moveTo(200,10);
	if (!popUpWin.opener) popUpWin.opener = self;
	with (popUpWin.document) {
		write('<HTML><HEAD><TITLE>View Full Image</TITLE>');
		write('</head>');
		write('<BODY bgcolor="#FFFFFF" topmargin="0" leftmargin="0" marginheight="0" marginwidth="0">');
		write('<IMG SRC="' + theURL + '" alt="Click on image to close window" onclick="window.close()">');
		write('</BODY></HTML>');
		close();
	}
}
function popUpContent(url, x, y) {
	if (!x){x=800;}
	if (!y){y=600;}
	if (x>400 && y>300){
		var popUpWin = window.open(url,'','height='+y+',width='+x+', location=no, scrollbars=yes, menubars=no,toolbars=no,resizable=yes');
	}else{
		var popUpWin = window.open(url,'','height='+y+',width='+x+', location=no, scrollbars=no, menubars=no,toolbars=no,resizable=yes');
	}
	if (!popUpWin.opener) 
	popUpWin.opener = self;
}
function confSlideShow(sURL, id){
	var popUpWin = window.showModalDialog(sURL, id, "dialogWidth:220px;dialogHeight:150px;status:no;help:no");
}
function Close(){
	window.close();
}
function roll(img_name, img_src)
   {
   document[img_name].src = img_src;
   }
function btnBack(){
	history.go(-1);

}
function deleteConfirm(str) {
  if (confirm(str)){	
    return true;
  }	
  else{
    return false;
  }	
}
function GoBack(){
	history.go(-1);
}
function SubmitForm(formname){
	document.formname.submit();

}
function Print()
{
	printMain.window.focus();
	printMain.window.print();
}


function Close()
{
	window.close();
}

function window.onload()
{
	focus();
}
function BacktoList(url){
	window.location=url;
}
function CheckDelete(){
	notok=true;
	fiel = document.frmCheckAll.elements['id[]'];
			if(fiel.checked==true){
				notok=false;
			}
			for (i = 0; i < fiel.length; i++)
				if(fiel[i].checked == true){
					notok=false;
				}
		  if(notok ){
					alert(" Hay chon ban ghi can xoa ! ");
		  }else{
			 if (confirm("Ban co chac chan muon xoa khong? ")){	
				document.frmCheckAll.submit();
			  }else{
				return false;
			  }
		  }
}

function roll(img_name, img_src)
   {
   document[img_name].src = img_src;
   }

function LTrim(iStr)
{
	while (iStr.charCodeAt(0) <= 32)
	{
		iStr=iStr.substr(1);
	}
	return iStr;
}

function RTrim(iStr)
{
	while (iStr.charCodeAt(iStr.length - 1) <= 32)
	{
		iStr=iStr.substr(0, iStr.length - 1);
	}
	return iStr;
}

function Trim(iStr)
{
	while (iStr.charCodeAt(0) <= 32)
	{
		iStr=iStr.substr(1);
	}

	while (iStr.charCodeAt(iStr.length - 1) <= 32)
	{
		iStr=iStr.substr(0, iStr.length - 1);
	}

	return iStr;
}

function CheckEmailAddress(Email)
{
	Email = Trim(Email);

	while (Email != '')
	{
		c = Email.charAt(0);	
		if (c==' ' || c=='<' || c==39 || c==':' || c=='.')
		{
			Email = Email.substr(1);
		}
		else
		{
			break;
		}
	}

	i = Email.indexOf('>');
	if (i==-1)
	{
		while (Email != '')
		{
			c = Email.charAt(Email.length - 1);
			if (c==' ' || c==39 || c=='.')
			{
				Email = Email.substr(0, Email.length - 1);
			}
			else
			{
				break;
			}
		}
	}
	else
	{
		Email = Email.substr(0, i);
	}

	if (Email.length > 96)
		return '';

	i = Email.lastIndexOf('@');
	j = Email.lastIndexOf('.');
	if (i < j)
		i = j;

	switch (Email.length - i - 1)
	{
	case 2:
		break;
	case 3:
		switch (Email.substr(i))
		{
		case '.com':
		case '.net':
		case '.org':
		case '.edu':
		case '.mil':
		case '.gov':
		case '.biz':
		case '.pro':
		case '.int':
			break;
		default:
			return '';
		}
		break;
	default:
		switch (Email.substr(i))
		{
		case '.name':
		case '.info':
			break;
		default:
			return '';
		}
		break;
	}

	Email = Email.toLowerCase();

	if (Email == '')
		return '';

	if (Email.indexOf(' ') != -1)
		return '';

	if (Email.indexOf('..') != -1)
		return '';

	if (Email.indexOf('.@') != -1)
		return '';

	if (Email.indexOf('@.') != -1)
		return '';

	if (Email.indexOf(':') != -1)
		return '';

	for (i=0; i < Email.length; i++)
	{
		c = Email.charAt(i);

		if (c >= '0' && c <= '9')
			continue;
		
		if (c >= 'a' && c <= 'z')
			continue;
		
		if ('`~!#$%^&*-_+=?/\\|@.'.indexOf(c) != -1)
			continue;

		return '';
	}

	if ((i=Email.indexOf('@'))==-1)
		return '';

	if (Email.substr(i + 1).indexOf('@')!=-1)
		return '';

	if (Email.charAt(0)=='.' || Email.charAt(Email.length - 1)=='.')
		return '';

	return Email;
}
//-->
	var current_row=null;
	function Datmau(tr, color, bgcolor){
		if(current_row!=null){
			current_row.style.background = '#EDEADE';
			current_row.style.color = '#3300CC';
			current_row.style.fontStyle = 'italic';
		}
		tr.style.background = bgcolor;
		tr.style.color = color;
		tr.style.fontStyle = 'italic';
		current_row=tr;

	}

				function CheckBoxSelected(theId,theForm){
						fid = document.Form4.elements['const_checks[]'];
						fid[theId].checked = true ;
						document.getElementById(theId).style.background='#84C1DF';
				}
				function SelectRow(box,theId){
					if(document.getElementById) {
						var cell = document.getElementById(theId);
						if(box.checked) {
							cell.style.backgroundColor='#84C1DF';
						}
						else {
							cell.style.backgroundColor='#FBFCFE';
						}
					}
					
				}
//-->
function addRow(tableID) 
{ 
var tbody = document.getElementById(tableID).getElementsByTagName("tbody")[0]; 
var row = document.createElement("TR"); 
var cell1 = document.createElement("TD"); 
var inp1 =  document.createElement("INPUT"); 
inp1.setAttribute("type","text"); 
inp1.setAttribute("name","eng[]"); 

cell1.appendChild(inp1); 

row.appendChild(cell1); 

tbody.appendChild(row); 
//alert(row.innerHTML); 
} 