// JavaScript Document
function ktra_Users()
{
	if (!isEmpty(document.formDK.User.value))
	{
		  alert("Vui long nhap ten dang nhap.");
		  document.formDK.User.focus();
		  return false;
	}

	if (!isEmpty(document.formDK.Password.value))
	{
		  alert("Vui long nhap vao mat khau.");
		  document.formDK.Password.focus();
		  return false;
	}
	if (!isEmpty(document.formDK.Retype.value))
	{
		  alert("Vui long go lai mat khau.");
		  document.formDK.Retype.focus();
		  return false;
	}

	if (document.formDK.Password.value != document.formDK.Retype.value)
	{
		  alert("Mat khau moi khong trung khop voi nhau.\nVui long go lai mat khau moi.");
		  document.formDK.Retype.focus();
		  return false;
	}

	if (!isEmpty(document.formDK.Fullname.value))
	{
		  alert("Vui long nhap ho ten.");
		  document.formDK.Fullname.focus();
		  return false;
	}

	if (isEmpty(document.formDK.Email.value))
	{
		if (!isEmail(document.formDK.Email.value))
		{
			  alert("Du lieu khong hop le.\nVui long nhap lai dia chi Email.");
			  document.formDK.Email.focus();
			  return false;
		}
	}
	document.formDK.submit();
}

function ktra_ProDis()
{
	if (!isEmpty(document.formDK.Title.value))
	{
		  alert("Vui long nhap vao noi dung.");
		  document.formDK.Title.focus();
		  return false;
	}
	document.formDK.submit();
}
function ktra_dangtin()
{
	if (!isEmpty(document.formDK.group_job.value))
	{
		  alert("Vui long chon nganh nghe.");
		  document.formDK.Title.focus();
		  return false;
	}
	if (!isEmpty(document.formDK.Title.value))
	{
		  alert("Vui long nhap vao noi dung.");
		  document.formDK.Title.focus();
		  return false;
	}
	document.formDK.submit();
}
function submit_form(a)
{
	document.frmList.action = a;
	document.frmList.submit();
}

function ktfind()
{
	if(!isNumber(document.formDK.price_from.value))
	{
		alert("Vui long nhap so vao.");
		document.formDK.price_from.focus();
		return false;
	}
	
	if(!isNumber(document.formDK.price_to.value))
	{
		alert("Vui long nhap so vao.");
		document.formDK.price_to.focus();
		return false;
	}
	if((document.formDK.price_to.value!="" || document.formDK.price_from.value!="") && document.formDK.cboDVT.value=="")
	{
		alert("Vui long chon don vi tinh.");
		document.formDK.cboDVT.focus();
		return false;	
	}
	
	if(!isNumber(document.formDK.area_from.value))
	{
		alert("Vui long nhap so vao.");
		document.formDK.area_from.focus();
		return false;
	}
	if(!isNumber(document.formDK.area_to.value))
	{
		alert("Vui long nhap so vao.");
		document.formDK.area_to.focus();
		return false;
	}
	return true;
}

function ktdoitien()
{	
	if (document.change.currency.value==0)
	{
		alert("Vui long chon loai tien.");
		document.change.currency.focus();
		return false;
	}

	if (document.change.amo.value=="")
	{
		alert("Vui long nhap vao so tien can doi.");
		document.change.amo.focus();
		return false;
	}
	
	if(!isNumber(document.change.amo.value))
	{
		alert("Vui long nhap so vao.");
		document.change.amo.focus();
		return false;
	}
	var tigiaTemp = document.change.currency.value;
	for(var i=0; i < document.change.cboCurrency.length; i++){
		if(tigiaTemp == document.change.cboCurrency.options[i].value){
			tigia = document.change.cboCurrency.options[i].text;
			sotien = document.change.amo.value;
			document.change.tongtien.value=tigia*sotien;
			break;
		}
	}
	return false;
}

function ktdoivang()
{	
	if (document.changev.gold.value==0)
	{
		alert("Vui long chon loai vang.");
		document.changev.gold.focus();
		return false;
	}

	if (document.changev.amo.value=="")
	{
		alert("Vui long nhap vao so vang.");
		document.changev.amo.focus();
		return false;
	}
	
	if (!isNumber(document.changev.amo.value))
	{
		alert("Vui long nhap so vao.");
		document.changev.amo.focus();
		return false;
	}
	//document.changev.submit();
	var type = document.getElementById("gold").value;
	var sizeCbo = document.getElementById("cboGold").length;
	for(var i=0; i< sizeCbo; i++){
		if(type == document.getElementById("cboGold").options[i].value){
			var tigia = document.getElementById("cboGold").options[i].text;
			var giatri = document.changev.amo.value;
			document.changev.tongtien.value = tigia*giatri;
			break;
		}
	}
	return false;
}
function ktdoidt()
{	
	if (document.change_area.length.value==0)
	{
		alert("Vui long nhap vao chieu dai.");
		document.change_area.length.focus();
		return false;
	}

	if (!isNumber(document.change_area.length.value))
	{
		alert("Vui long nhap so vao.");
		document.change_area.length.focus();
		return false;
	}
	
	if (document.change_area.width.value=="")
	{
		alert("Vui long nhap vao chieu rong.");
		document.change_area.width.focus();
		return false;
	}
	
	if (!isNumber(document.change_area.width.value))
	{
		alert("Vui long nhap so vao.");
		document.change_area.width.focus();
		return false;
	}
	var chieurong = document.change_area.width.value;
	var chieudai = document.change_area.length.value;
	document.change_area.result.value = chieudai*chieurong;
	return false;
}
function frm_Submit(link){
	var check = true;
	if(link == 'regis.php'){
		
		if(document.getElementById('username').value.length == 0){
			alert("Vui nhap vao truong ten dang nhap");
			document.getElementById('username').focus();
			check = false;
			return false;
		}
		if(document.getElementById('pass').value.length == 0){
			alert("Vui nhap vao truong mat khau");
			document.getElementById('pass').focus();
			check = false;
			return false;
		}if(document.getElementById('pass1').value != document.getElementById('pass').value){
			alert("mat khau xac nhan ko dung ");
			document.getElementById('pass').focus();
			check = false;
			return false;
		}
		if(document.getElementById('name').value.length == 0){
			alert("Vui nhap vao truong Ho Ten");
			document.getElementById('name').focus();
			check = false;
			return false;
		}
		if(document.getElementById('address').value.length == 0){
			alert("Vui nhap vao truong Dia Chi");
			document.getElementById('address').focus();
			check = false;return false;
		}
		if(document.getElementById('city').value.length == 0){
			alert("Vui nhap vao truong tinh/tp");
			document.getElementById('city').focus();
			check = false;
			return false;
		}
		if(!isNumber(document.getElementById('phone').value)){
			alert("Vui nhap vao truong So Dien Thoai,hoac so dt ko hop le ");
			document.getElementById('phone').focus();
			check = false;return false;
		}
		if(!isNumber(document.getElementById('fax').value)){
			alert("Vui nhap vao truong So Dien Thoai,hoac so dt ko hop le ");
			document.getElementById('fax').focus();
			check = false;return false;
		}
		if(!isEmail(document.getElementById('email').value)){
			alert("Vui nhap vao Email hop le");
			document.getElementById('email').focus();
			check = false;return false;
		}
	}
	if(check == true)
    document.frm_regis.action = link ;
    document.frm_regis.submit();
	
    return true;
}