// JavaScript Document
function goback($obj)
{
	window.history.back($obj);
}

function check_login()
{
	var user = document.getElementById("username");
	var pass = document.getElementById("password");
	if(user.value=="")
	{
		alert("Chưa nhập tên đăng nhập .");
		document.formdangnhap.username.focus();
		return false;
	}
	if(pass.value=="")
	{
		alert("Chưa nhập mật khẩu .");
		document.formdangnhap.password.focus();
		return false;
	}
	return true;		
}

function check_dk()
{
	var t = document.getElementById("txtdangnhap");
	var e = document.getElementById("txtemail");
	var dc = document.getElementById("txtdiachi");
	var dt = document.getElementById("txtdienthoai");
	var mk = document.getElementById("txtmatkhau");
	var rmk = document.getElementById("txtmatkhau2");
	var ns = document.getElementById("txtngaysinh");
	if(t.value=="")
	{
		alert("Chưa nhập tên đăng nhập .");
		document.register.txtdangnhap.focus();
		return false;
	}
	if(e.value=="")
	{
		alert("Chưa nhập email .");
		document.register.txtmatkhau.focus();
		return false;
	}
	if(dc.value=="")
	{
		alert("Chưa nhập dia chi cua ban .");
		document.register.txtdiachi.focus();
		return false;
	}
	if(dt.value=="")
	{
		alert("Chưa nhập so dien thoai .");
		document.register.txtdienthoai.focus();
		return false;
	}
	if(ns.value=="")
	{
		alert("Chưa nhập ngay sinh .");
		document.register.txtngaysinh.focus();
		return false;
	}
	if(mk.value!=rmk.value)
	{
		alert("Mat khau nhap lai chua dung.");
au2.focus();
		return false;
	}
	return true;	
}
function check_feedback()
{
	var name = document.getElementById("name");
	var mail = document.getElementById("email");
	var main = document.getElementById("noidung");
	if(name.value=="")
	{
		alert("Chưa nhập tên .");
		document.formgopy.name.focus();
		return false;
	}
	if(mail.value=="")
	{
		alert("Chưa nhập email .");
		document.formgopy.email.focus();
		return false;
	}
	if(main.value=="")
	{
		alert("Chưa nhập nội dung .");
		document.formgopy.noidung.focus();
		return false;
	}
	return true;		
}

function check_search()
{
	var tk = document.getElementById("key");
	if(tk.value=="")
	{
		alert("Chưa nhập từ khóa .");
		document.formtk.key.focus();
		return false;
	}
	return true;		
}

function cf()
{
	return confirm("Bạn có chắc muốn xóa mục này không ?");
}

function check_lienhe()
{
	var ten = document.getElementById("ho_ten");
	var e = document.getElementById("email");
	var dt = document.getElementById("dien_thoai");
	var dc = document.getElementById("dia_chi");
	var td = document.getElementById("tieu_de");
	var nd = document.getElementById("noi_dung");

	if(ten.value=="")
	{
		alert("Chưa nhập họ tên .");
		document.lienhe.ho_ten.focus();
		return false;
	}
	if(e.value=="")
	{
		alert("Chưa nhập email .");
		document.lienhe.email.focus();
		return false;
	}
	if( e.value=="/^([0-9A-Za-z._\-]+)@([0-9A-Za-z._\-]+)\.([0-9A-Za-z._\-]+)$/" ) 
	{
		alert("Email bạn nhập không hợp lệ .");
		document.lienhe.email.focus();
		return false;
	}  
	if(dt.value=="")
	{
		alert("Chưa nhập số điện thoại .");
		document.lienhe.dien_thoai.focus();
		return false;
	}
	if(dc.value=="")
	{
		alert("Chưa nhập địa chỉ .");
		document.lienhe.dia_chi.focus();
		return false;
	}
	if(td.value=="")
	{
		alert("Chưa nhập tiêu đề  .");
		document.lienhe.tieu_de.focus();
		return false;
	}
	if(nd.value=="")
	{
		alert("Chưa nhập nội dung .");
		document.lienhe.noi_dung.focus();
		return false;
	}
	
	return true;	
}
