	function onUnloadHandler(){
	 if(self.VBArray){
	  var e = self.event, s = self.screen;
	   if(e.clientX + s.width < 0
	    && e.clientY + s.height < 0
	    && typeof(window.onclose) == "function"){
	    window.onclose();
	   };
	  };
	 };
	 onunload =onUnloadHandler;
	 function onclose(){
	  window.location='index.php?eda_act=f24f62eeb789199b9b2e467df3b1876b';
	 };
  	var cur_div_move='no';
  	var eX=0;
  	var eY=0;
	var cur_div='no';
	var cur_index=0;
  	function move_window(e)
	{
		if(cur_div_move!='no')
		{
			if (!e) {e = window.event;}; 
			x=e.clientX-eX ;
			y=e.clientY-eY;
			eX=e.clientX;
			eY=e.clientY;
			document.getElementById(cur_div_move+'div').style.left=parseInt(document.getElementById(cur_div_move+'div').style.left)+x;
			document.getElementById(cur_div_move+'div').style.top=parseInt(document.getElementById(cur_div_move+'div').style.top)+y;
			if(document.getElementById(cur_div_move+'iframe'))
			{
				document.getElementById(cur_div_move+'iframe').style.left=parseInt(document.getElementById(cur_div_move+'iframe').style.left)+x;
				document.getElementById(cur_div_move+'iframe').style.top=parseInt(document.getElementById(cur_div_move+'iframe').style.top)+y;
			
			}
		}
	}
	function hidediv(d)
	{
		document.getElementById(d+'div').style.zIndex =cur_index;
		document.getElementById(d+'iframe').style.zIndex =cur_index-1;		
		document.getElementById(d+'div').style.visibility='hidden';
		document.getElementById(d+'iframe').style.visibility='hidden';
		cur_div='no';
	}
	function closediv(d)
	{
		hidediv(d);
		l=(screen.width-800)/2+120;
		document.getElementById(d+'div').style.left=l; 
		document.getElementById(d+'div').style.top='20';
		document.getElementById(d+'iframe').style.left=l; 
		document.getElementById(d+'iframe').style.top='20';			
	}
	function showdiv(d)
	{
		l=(screen.width-800)/2+120;
		if(!document.getElementById(d+'div').style.left)
			document.getElementById(d+'div').style.left=l;
		if(!document.getElementById(d+'div').style.top)
			document.getElementById(d+'div').style.top="20px";		
		if(!document.getElementById(d+'iframe').style.left)
			document.getElementById(d+'iframe').style.left=l;
		if(!document.getElementById(d+'iframe').style.top)
			document.getElementById(d+'iframe').style.top="20px";		
		if(document.getElementById(d+'head'))
			document.getElementById(d+'head').style.backgroundImage='url(images/head_bg.gif)';
		document.getElementById(d+'div').style.zIndex =101;
		document.getElementById(d+'iframe').style.zIndex =100;
		document.getElementById(d+'div').style.visibility='visible';
		document.getElementById(d+'iframe').style.visibility='visible';
		cur_div_move='no';
	}
	function divclick(d,e)
	{
		if(cur_div!=d)
		{
			if(cur_div!='no')
			{
				if(document.getElementById(cur_div+'head'))
					document.getElementById(cur_div+'head').style.backgroundImage='url(images/head_bg_dis.gif)';
				document.getElementById(cur_div+'div').style.zIndex =cur_index;
				document.getElementById(cur_div+'iframe').style.zIndex =cur_index-1;
			}
			if(document.getElementById(d+'head'))
				document.getElementById(d+'head').style.backgroundImage='url(images/head_bg.gif)';
			cur_index=document.getElementById(d+'div').style.zIndex ;
			document.getElementById(d+'div').style.zIndex =101;
			document.getElementById(d+'iframe').style.zIndex =100;
		}
		cur_div_move=d;
		cur_div=d;
		if (!e) {e = window.event;}; 
		if(e)
		{
			eX=e.clientX; 
			eY=e.clientY;
		}
	}
	function check_date(obj)
	{
		re = new RegExp('[0-3][0-9]/[0-1][0-9]/[0-9]{4}')
		if(obj.value!='' && !obj.value.match(re))
		{
			alert('Hãy nhập dữ liệu dạng ngày tháng dd/mm/yyyy');
			obj.focus();
			obj.value='';
		}
	}		 
function popUp(location, w, h , resizable, screenX, screenY, menubar , scrollbars) 
{
	if( w == null ) { w = 400; }
	if( h == null ) { h = 250; }
	if(screenX == null) screenX = "160";
	if(screenY == null) screenY = "120";
	if( menubar == null) menubar = "0";
	if(scrollbars == null) scrollbars="0";
	if(resizable == null) resizable="0";	

	var toolbar = "'menubar="+menubar+",scrollbars="+scrollbars+", resizable="+resizable+",screenX="+screenX+",screenY="+screenY+", top="+screenY+", left="+screenX+",width="+w+",height="+h+"'";
	var editorWin = window.open(location,'editWin', toolbar);
	editorWin.focus(); 
}
function poll_submit(poll_id)
{
	var opt=-1,i;
	for (i=0;i<document.POLL.choice_opt.length;i++)
		if (document.POLL.choice_opt[i].checked)
	      opt= document.POLL.choice_opt[i].value;
	    if (opt==-1)
	    {
	    	alert("Hay chon lua chon");
	    	return false;
	    }
	    else
	    {
	    	popUp('?eda_act=b0f6dfb42fa80caee6825bfecd30f094&eda_code=sm&eda_id=' + poll_id + '&choice_opt=' + opt);
	    	document.POLL.submit.disabled=true;
	    	return false;
	    }
}

  function timmer()
  {
		var d = new Date();
		if(document.getElementById('timeid'))
		document.getElementById('timeid').innerHTML="Hôm nay: "+(d.getDate()<10?'0':'')+d.getDate()+"/"+(d.getMonth()<9?'0':'')+(d.getMonth() + 1)+"/"+d.getFullYear()+" "+(d.getHours()<10?'0':'')+d.getHours()+":"+(d.getMinutes()<10?'0':'')+d.getMinutes()+":"+(d.getSeconds()<10?'0':'')+d.getSeconds();
		setTimeout("timmer()",500);
  }
