//Kiem tra tim kiem
function onSubmit_Search(StrLang)
 {
   var keyword=document.getElementById("txtKeyWord");
   if (StrLang=='EN') 
    {
      if ((keyword.value=='') || (keyword.value=='-- Input keyword --'))	   
       {	    
	      alert('You have to enter key!');
		  keyword.focus();	  
		  return false;
	   }	 
	}
   else
    {
	  if ((keyword.value=='') || (keyword.value=='-- Nhập từ cần tìm --'))	   
       {	    
	      alert("Ban chua nhap tu khoa!");
		  keyword.focus();	  
		  return false;
	   }      
	}
  var frm=document.forms['frmSearch'];
  	  frm.submit();
 }
//Dung cho tim kiem
function Timkiem(StrLang)
 {
	var obj = document.frmSearch.txtKeyWord;
	if (StrLang=="EN")
	 {
	   if (obj.value == "-- Input keyword --")
	    {
		  obj.value = "";
	    }
	}
   else
    {
	   if (obj.value == "-- Nhập từ cần tìm --")
	    {
		  obj.value = "";
	    }		  
	}
 }
//Dung cho tim kiem
function outTimkiem(StrLang)
 {
	var obj = document.frmSearch.txtKeyWord;	
	if (StrLang=="EN")
	 {
	   if (obj.value =="")
	    {		
			obj.value = "-- Input keyword --";
		}	
	 }
	else
	 {
	   if (obj.value =="")
	    {		
			obj.value = "-- Nhập từ cần tìm --";
		}			   
	}
 }	
//Hien thi ngay gio
function dateTime(StrLang)
 {		
	 if (StrLang=='EN')
		 {
		  ngay = new Array(	"Sunday",
							"Monday",
							"Tuesday",
							"Wednesday",
							"Thursday",
							"Friday",
							"Staturday"
						);
		  stoday = "Today, "				
		 }
		else
		{
		 ngay = new Array(	"Ch&#7911; nh&#7853;t",
							"Th&#7913; hai",
							"Th&#7913; ba",
							"Th&#7913; t&#432;",
							"Th&#7913; n&#259;m",
							"Th&#7913; sáu",
							"Th&#7913; b&#7843;y"
						);
		stoday = "Hôm nay, ";				
		} 						
	d  = new Date();	
	document.write("<span class='datetime'>"+stoday+ngay[d.getDay()] + ", " +
						(d.getDate()<10?"0" + d.getDate():d.getDate()) + "-" +
						(d.getMonth()+1<10?"0" + (d.getMonth()+1):d.getMonth()+1) + "-" +
						d.getFullYear()+"</span>");
 }	
//Dung cho lien ket
function goNow()
 {
	var str;
	str = document.getElementById("fastLink").value;
	window.open(str);
 }
//Download
function Download(s)
 {
	window.open(s,'','width=10,height=10,resizable=1');	
 }
//In du lieu
function Inan(s)
 {
	window.open("/news/inan.asp?newsid=" + s,"Tin_tin","menubar=no,toolbar=no,scrollbars=yes");
 }
/*********************************************************************
 ***********************HAM KIEM TRA EMAIL****************************/
function checkMail(txt)
 {
	var x = document.all(txt).value;
	var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/; 
	if (filter.test(x))  
		return true;
	else 
		return false;
 }
/********************************************************************/
function XemKetQua(s,id,StrLang)
	{
		width=0;
			height=400;
			if(window.screen.availWidth>800)
				width=700;
			else
				width=600;	
		//----------------------------------------------------
		url = "/kq_binh_bau.asp?chid=" + id;		
		if(s==0)
		{
			v="";	
			opt = document.frmTrungCau.PollVote;		
			for(i=0;i<opt.length;i++)
				{				
					if(opt[i].checked)
					{
						v=	opt[i].value;	
						i=opt.length;
					}
				}
			if(v=="")	
				{
				  if (StrLang=='EN')
				  	alert("You don't select any projects!");
				  else
				    alert("Ban chua chon phuong an tra loi!");	
				  return false;
				}   
			else
			{
				url += "&paid=" +  v;					
				//----------------------------------
				document.getElementById("btPoll").disabled=true;
				document.getElementById("btView").disabled=false;			
			}
		}
		window.open(url,"","scrollbars=yes,status=yes,resizable=no,toolbar=no,width=500,height=400,top="
									+ (window.screen.availHeight/2 - height/2) +",left=" + (window.screen.availWidth/2 - width/2));
  }
 //------Mo cua so dang 800x600
 function Open_win(s,l)
  {
	width=0;
	height=500;
	if(window.screen.availWidth>800)
		width=800;
	else
		width=700;			
	Url = "chitiet_diemthi.asp?IDHocsinh=" + s + "&IDLop=" + l;
	//----------------------------------
	window.open(Url,"","scrollbars=yes,status=yes,resizable=no,toolbar=no,width=" + width + ",height=" + height + ",top="
							+ (window.screen.availHeight/2 - height/2 + 50) +",left=" + (window.screen.availWidth/2 - width/2 +50));
  }  
/***********************************************************************************************************
********************************** CAC HAM KIEM TRA DU LIEU*************************************************/
function check_contact(StrLang)
 {
   hoten=document.getElementById("txtHoten");
   diachi=document.getElementById("txtDiachi");
   hopthu=document.getElementById("txtEmail");
   tieude=document.getElementById("txtTieude");
   noidung=document.getElementById("txtNoidung");
   //Hoten
   if (hoten.value=='')
     {
	   if (StrLang=='EN')
	   	   alert("Please, enter your name!");	    
	   else
	   	   alert("Xin moi cho biet ten ban!");	    
	   hoten.focus();
	   return false;
	 }
   //Dia chi
   if (diachi.value=='')
    {
	   if (StrLang=='EN')
	   	  alert('Please, enter your address!');
	   else
	   	  alert('Xin moi cho biet dia chi cua ban!');
	   diachi.focus();
	   return false;
	}
   //Hop thu
   if (!checkMail("txtEmail"))
    {
	   if (StrLang=='EN')
	   	 alert("Invalid email, please enter its again!");
	   else
	   	 alert("Email khong hop le, moi nhap lai!");
	   hopthu.focus();
	   return false;
	}
   //Tieu de
   if (tieude.value=='')
    {
	  if (StrLang=='EN')		
	     alert('Please enter heading!');
	  else
	  	 alert('Xin moi cho biet tieu de lien he!');
	  tieude.focus();
	  return false;
	}
   //Noi dung
   if (noidung.value=='')
    {
	   if (StrLang=='EN')
	   	  alert('Please enter your content!');
	   else
	   	  alert('Xin moi cho biet noi dung lien he!');
	   noidung.focus();
	   return false;
	}
   return true;	 
 }
//Kiem tra hoi dap
function check_hoidap(StrLang)
 {
   hoten=document.getElementById("txtHoten");
   diachi=document.getElementById("txtDiachi");
   hopthu=document.getElementById("txtEmail");
   noidung=document.getElementById("txtNoidung");
   //Hoten
   if (hoten.value=='')
     {
	   if (StrLang=='EN')
	   	   alert("Please, enter your name!");	    
	   else
	   	   alert("Xin moi cho biet ten ban!");	    
	   hoten.focus();
	   return false;
	 }
   //Dia chi
   if (diachi.value=='')
    {
	   if (StrLang=='EN')
	   	  alert('Please, enter your address!');
	   else
	   	  alert('Xin moi cho biet dia chi cua ban!');
	   diachi.focus();
	   return false;
	}
   //Hop thu
   if (!checkMail("txtEmail"))
    {
	   if (StrLang=='EN')
	   	 alert("Invalid email, please enter its again!");
	   else
	   	 alert("Email khong hop le, moi nhap lai!");
	   hopthu.focus();
	   return false;
	}
   //Noi dung
   if (noidung.value=='')
    {
	   if (StrLang=='EN')
	   	  alert('Please enter your question!');
	   else
	   	  alert('Xin moi cho biet noi dung cau hoi!');
	   noidung.focus();
	   return false;
	}
   return true;	 
 } 
//Kiem tra diem tuyen sinh
function check_tuyen_sinh(StrLang)
 {
   hoten=document.getElementById("txtTenban");
   sbd=document.getElementById("txtSBD");
   ngaysinh=document.getElementById("txtNgaysinh");
   if ((hoten.value=='') & (sbd.value=='') & (ngaysinh.value==''))
    {
	   if (StrLang=='En')	  
	     alert('Please enter your condition to seek!');
	   else
	   	 alert('Xin moi nhap dieu kien tim kiem!');
	   hoten.focus();
	   return false;
	}
   return true;	   
 }
//Kiem tra diem hoc phan
function check_hoc_phan(StrLang)
 {
   lop=document.getElementById("CmbLophoc");
   hoten=document.getElementById("txtHoten");   
   ngaysinh=document.getElementById("txtNgaysinhhp");
   if (lop.value==0)
    {
	   if (StrLang=='En')	  
	     alert('Please select any class!');
	   else
	     alert('Xin moi chon lop cua ban!');
	   lop.focus();
	   return false;
	}
   else if ((hoten.value=='') & (ngaysinh.value==''))
    {
	   if (StrLang=='En')	  
	     alert('Please enter your condition to seek!');
	   else
	   	 alert('Xin moi nhap dieu kien tim kiem!');
	   hoten.focus();
	   return false;
	}
   return true;	   
 }
//Kiem tra dang nhap
function check_dang_nhap(StrLang)
 {
	username=document.getElementById("txtUsername");
	password=document.getElementById("txtPassword");
	//ten dang nhap
	if (username.value=='')
	 {
	    if (StrLang=='EN')	 	
			alert('Please enter username!');
		else
			alert('Xin moi nhap ten dang nhap!');
		username.focus();
		return false;
	 }
	//Mat khau
	if (password.value=='')
	 {
	    if (StrLang=='EN')	 	
			alert('Please enter password!');
		else
			alert('Xin moi nhap mat khau!');
		password.focus();
		return false;
	 }
  return true;	 
 }

