function display_district()
{
 for(s=frm_search.district.length-1;s >= 0;s--)
  	frm_search.district.remove(s);

  	if(frm_search.province[frm_search.province.selectedIndex].value != "")
	{
  		for (i=0;i<frm_search.district_hidden.length;i++)
		{
  			if (frm_search.province[frm_search.province.selectedIndex].value == frm_search.district_hidden[i].value)
			{
  				var strTemp = new String(frm_search.district_hidden[i].text);
  				vaTemp = strTemp.split("~");

  				NewOptItem = new Option(vaTemp[1],vaTemp[0]);
  				j = frm_search.district.length;			  				
				frm_search.district.options[j] = NewOptItem;
  				NewOptItem = null;
  			}
  		}
 	}	
	
}	

function check_email_form(theform)
{
	var frm = theform;
	if(frm.fullname.value=="")
	{
		alert("Vui long nhap vao ho ten cua ban.");
		frm.fullname.focus();
		return false;
	}
	if(frm.email1.value=="")
	{
		alert("Vui long nhap vao email cua ban.");
		frm.email1.focus();
		return false;
	}
	if(frm.email2.value=="")
	{
		alert("Vui long nhap vao email can gui den.");
		frm.email2.focus();
		return false;
	}
	return true;
}
//
function reload_verify()
{
	document.getElementById('imd_reload').src="../img.php"; 
	return true;
}
//do submit form
function do_submit(frm)
{
	var form = frm;
	return check_frm_register(form);
	document.forms[form].submit();
	return true;
}
//check contact form
function check_contact()
{
	if(document.forms['frm_contact'].txt_name.value=="")
	{
		alert("Vui lòng nhập vào họ tên của bạn!");
		document.forms['frm_contact'].txt_name.focus();
		return false;
	}
	if(document.forms['frm_contact'].txt_email.value=="")
	{
		alert("Vui lòng nhập vào địa chỉ email của bạn!");
		document.forms['frm_contact'].txt_email.focus();
		return false;
	}
	if(!CheckEmail(document.forms['frm_contact'].txt_email.value))
	{
		alert("Địa chỉ email không hợp lệ. Vui lòng nhập lại!");
		document.forms['frm_contact'].txt_email.focus();
		return false;
	}	
	if(document.forms['frm_contact'].txt_title.value=="")
	{
		alert("Vui lòng nhập vào tiêu đề email của bạn!");
		document.forms['frm_contact'].txt_title.focus();
		return false;
	}
	if(document.forms['frm_contact'].txt_content.value=="")
	{
		alert("Vui lòng nhập vào nội dung liên hệ của bạn!");
		document.forms['frm_contact'].txt_content.focus();
		return false;
	}
	
	return true;
}
//display hint
function display_loibenphai2()
{
	document.getElementById('loibenphai_id_2').style.display = "block";
	document.getElementById('loibenphai_id_1').style.display = "none";
	document.getElementById('loibenphai_id_3').style.display = "none";
}
function display_loibenphai1()
{
	document.getElementById('loibenphai_id_2').style.display = "none";
	document.getElementById('loibenphai_id_1').style.display = "block";
	document.getElementById('loibenphai_id_3').style.display = "none";
}
function display_loibenphai3()
{
	document.getElementById('loibenphai_id_2').style.display = "none";
	document.getElementById('loibenphai_id_1').style.display = "none";
	document.getElementById('loibenphai_id_3').style.display = "block";
}
//check chung suc function
function check_chungsuc1()
{
	checked=false;
	for(i=0; i<document.forms['f_chungsuc'].cauhoi.length; i++){
		if(document.forms['f_chungsuc'].cauhoi[i].checked)
			checked=true;
	}	
	if(checked == false)
	{
		alert("Vui lòng chọn câu trả lời của bạn!");
		return false;
	}
	if(document.forms['f_chungsuc'].dudoan.value=="")
	{
		alert("Vui lòng nhập vào số dự đoán của bạn!");
		document.forms['f_chungsuc'].dudoan.focus();
		return false;
	}
	if(document.forms['f_chungsuc'].scmnd.value=="")
	{
		alert("Vui lòng nhập vào số chứng minh nhân dân của bạn!");
		document.forms['f_chungsuc'].scmnd.focus();
		return false;
	}
	document.forms['f_chungsuc'].submit();
}
function check_chungsuc2()
{
	alert("Vui lòng đăng nhập trước khi trả lời câu hỏi. Nếu chưa là thành viên vui lòng đăng ký.");
	return false;
}
function validate1() {
	var box = document.forms['f_chungsuc'].dudoan;
	re=/^[0-9]*$/;
	if(!re.exec(box.value)) {
		alert("Vui lòng chỉ nhập số từ 0-9!");
		document.forms['f_chungsuc'].dudoan.value="";
		box.focus();
		return;
	}//end name if
}
function validate2() {
	var box = document.forms['f_chungsuc'].scmnd;
	re=/^[0-9]*$/;
	if(!re.exec(box.value)) {
		alert("Vui lòng chỉ nhập số từ 0-9!");
		document.forms['f_chungsuc'].scmnd.value="";
		box.focus();
		return;
	}//end name if
}