var div_box_hide=false;                                        
var div_box_current=null;     
function div_box_checkout(div_box_show)
{
	div_box_hide=true;                                        
	window.setTimeout("div_box_time()",500);                                        
	div_box_current=div_box_show;  
}
function div_box_show(div_box_show,div_box_main)
{
	//An div_box hien tai neu co
	if(div_box_current)
	{
		if(div_box_current.style)
		{
			div_box_current.style.visibility="hidden";    
		}
		div_box_current=null;
	}
	var parent,top,left;
	top=0;left=0;
	parent=div_box_main.offsetParent;
	top_parent=div_box_main.offsetTop;
	while(parent)
	{
		top_parent+=parent.offsetTop;
		parent=parent.offsetParent;
	}

	parent=div_box_main.offsetParent;
	left_parent=div_box_main.offsetLeft;
	
	while(parent)
	{
		left_parent+=parent.offsetLeft;
		parent=parent.offsetParent;
	}

	top=div_box_main.offsetHeight+top_parent;
	left=left_parent;
	if(left>document.width/2)
		left=div_box_main.offsetWidth+left-div_box_show.offsetWidth;

	div_box_show.style.top=top;
	div_box_show.style.left=left;
	div_box_show.style.position="absolute";
	div_box_show.style.visibility="visible";  
	div_box_current=div_box_show;	
	div_box_hide=false;                                        
}
function div_box_time()
{
	if (div_box_hide)                                        
	{                                        
		if (div_box_current)    
		{    
			if(div_box_current.style)
				div_box_current.style.visibility="hidden";    
		}    
		div_box_hide=false;
		window.clearTimeout();    
	}        

}

function change_table_row_bgcolor(row,bgcolor)
{
	row.style.backgroundColor=bgcolor;
}
loadstatustext = 'Loading...';
function ajaxLoad(url,id)
{
        if (document.getElementById) 
        {
            var x = (window.ActiveXObject) ? new ActiveXObject("Microsoft.XMLHTTP") : new XMLHttpRequest();
        }
        if (x)
        {
            x.onreadystatechange = function()
            {
                el = id;
                el.innerHTML = loadstatustext;
          		if (x.readyState == 4 && x.status == 200)
                {
          			//el.style.width=330;
          			el.innerHTML = x.responseText;
                }
             }
             x.open("GET", url, true);
             x.send(null);
        }
}
	function processStateChange() 
	{
		if (req.readyState == 4) 
		{ // Complete
			if (req.status == 200) 
			{ // OK response
				document.getElementById("theTable").innerHTML = req.responseText;
			} 
			else 
			{
				alert("Problem: " + req.statusText);
			}
		}
	}

	function getURL(url,dataExtra,functionHandler) 
	{
		if (window.XMLHttpRequest) 
		{ // Non-IE browsers
			req = new XMLHttpRequest();
			req.onreadystatechange = functionHandler;
			req.dataExtra=dataExtra;
			try 
			{
				req.open("GET", url, true);
			} 
			catch (e) 
			{
				alert(e);
			}
			req.send(null);
		} 
		else if (window.ActiveXObject) 
		{ // IE
			req = new ActiveXObject("Microsoft.XMLHTTP");
			if (req) 
			{
				req.dataExtra=dataExtra;
				req.onreadystatechange = functionHandler;
				req.open("GET", url, true);
				req.send();
			}
		}
	}
/*TIEN ICH KIEM TRA DU LIEU VAO*/
function checkemail(email,lang)
{ 
	lang="VN";
	if ((email.length<6)||(email.indexOf("@")<1)||(email.indexOf(".")<1)) 
	{
		if(lang=="VN")
			alert("Dia chi email khong hop le!");
		else
			alert("Please input a valid email address")
		return false;
	}   
	if ((email.indexOf("@")==email.length-1)||(email.indexOf("@")!=email.lastIndexOf("@")))
	{
		if(lang=="VN")
			alert("Dia chi email khong hop le!");
		else
			alert("Please input a valid email address")
		return false;
	}
	if ((email.indexOf(".")==0)||(email.indexOf(".")==email.length))
	{
		if(lang=="VN")
			alert("Dia chi email khong hop le!");
		else
			alert("Please input a valid email address")
		return false;
	}

	if (email.indexOf(" ")>=0)
	{
		if(lang=="VN")
			alert("Dia chi email khong duoc chua khoang trang!");
		else
			alert("Please input a valid email address without any white space character!");
		return false;
	}
	return true;
}
	