//**************************************************
//**************************************************
function validFrmSurvey(){
	
	var hiddenName = "survey_detail_id_" + id;
	var value =	document.getElementById(hiddenName).value;
	
	if(value==0){
		alert("Bạn chưa chọn câu trả lời.");
    	return false;
	}
	return true;
}

//**************************************************
//**************************************************
function onChangeSurvey(id,value){
	var hiddenName = "survey_detail_id_" + id;
	document.getElementById(hiddenName).value = value;
	var akaa = document.getElementById(hiddenName).value;
	alert(hiddenName + " " +akaa);
}

//**************************************************
//**************************************************
function validFrmContact(){
	var theForm = document.frmContactUs;

	if(trim(theForm.contact_name.value)==""){
		alert("Bạn chưa nhập tên liên hệ.");
		theForm.contact_name.focus();
		return false;
	}
	
	//mail
	if(theForm.contact_mail.value.length > 0){
		if (!isEmail(theForm.contact_mail.value)){
			alert("Email không đúng định dạng.");
			theForm.contact_mail.focus();
			theForm.contact_mail.select()
			return false;
		}
	}else{
		alert("Bạn chưa nhập email liên hệ.");
		theForm.contact_mail.focus();
		return false;
	}
	
	if(theForm.contact_message.value.length==0){
		alert("Bạn chưa nhập nội dung liên hệ.");
		theForm.contact_message.focus();
		return false;
	}else{
		if(theForm.contact_message.value.length<50){
		alert("Nội dung liên hệ phải nhiều hơn 50 ký tự.");
		theForm.contact_message.focus();
		return false;
		}
	}
	return true;
}

//****************************************************
//****************************************************
function validFrmRegister(){
	if(document.getElementById('check_user').value=="no"){
		alert("Xin nhập tên đăng nhập!");
		document.getElementById('txt_user').focus();
		return false;
	}
		
	if(document.getElementById('txt_password').value.length==0){
		alert("Xin nhập mật khẩu!");
		document.getElementById('txt_password').focus();
		return false;
	}

	if(document.getElementById('txt_password').value.length<6){
		alert("Mật khẩu phải nhiều hơn 6 ký tự.");
		document.getElementById('txt_password').focus();
		return false;
	}
	
	if(document.getElementById('txt_repassword').value.length==0){
		alert("Xin nhập xác nhận mật khẩu!");
		document.getElementById('txt_repassword').focus();
		return false;
	}
	
	if(document.getElementById('txt_repassword').value!=document.getElementById('txt_password').value){
		alert("Mật khẩu và xác nhận mật khẩu không giống nhau.");
		document.getElementById('txt_repassword').focus();
		return false;	
	}

	if(document.getElementById('txt_email').value.length>0){
		if (!isEmail(document.getElementById('txt_email').value)){
			alert("Email không đúng định dạng.");
			document.getElementById('txt_email').focus();
			return false;
		}
	}else{
		alert("Xin nhập địa chỉ email!");
		document.getElementById('txt_email').focus();
		return false;
	}
	
	if(document.getElementById('check_email').value=="no"){
		alert("Xin nhập lại địa chỉ Email.");
		document.getElementById('check_email').focus();
		return false;
	}
	
	if(document.getElementById('captcha').value.length==0){
		alert("Xin nhập mã xác nhận.");
		document.getElementById('captcha').focus();
		return false;
	}
	
	return true;	
}

//****************************************************
//****************************************************
function validFrmRegisterEdit(){
		
	if(document.getElementById('txt_password').value.length>0){

		if(document.getElementById('txt_password').value.length<6){
			alert("Mật khẩu phải nhiều hơn 6 ký tự.");
			document.getElementById('txt_password').focus();
			return false;
		}
		
		if(document.getElementById('txt_repassword').value!=document.getElementById('txt_password').value){
			alert("Mật khẩu và xác nhận mật khẩu không giống nhau.");
			document.getElementById('txt_repassword').focus();
			return false;	
		}
	}
	return true;
}


//****************************************************
//****************************************************
function validFrmLogin(){
	var theForm = document.frmLogin;

	if(trim(theForm.username.value)==""){
		alert("Bạn chưa nhập tên đăng nhập.");
		theForm.username.focus();
		return false;
	}
	
	if(trim(theForm.password.value)==""){
		alert("Bạn chưa nhập mật khẩu.");
		theForm.password.focus();
		return false;
	}
	
	return true;	
}

//****************************************************
//****************************************************
function validFrmLogin2(){
	var theForm = document.frmLogin2;

	if(trim(theForm.username.value)==""){
		alert("Bạn chưa nhập tên đăng nhập.");
		theForm.username.focus();
		return false;
	}
	
	if(trim(theForm.password.value)==""){
		alert("Bạn chưa nhập mật khẩu.");
		theForm.password.focus();
		return false;
	}
	
	return true;	
}

//****************************************************
//****************************************************
function validFrmRePass(){
	var theForm = document.frmRePassword;

	//mail
	if(theForm.member_mail.value.length > 0){
		if (!isEmail(theForm.member_mail.value)){
			alert("Email không đúng định dạng.");
			theForm.member_mail.focus();
			theForm.member_mail.select()
			return false;
		}
	}else{
		alert("Bạn chưa nhập email liên hệ.");
		theForm.member_mail.focus();
		return false;
	}
	
	return true;	
}

//****************************************************
//****************************************************
function validFrmChangePass(){
	//var theForm = document.frmChangePass;

	if(document.getElementById('old_password').value.length==0){
		alert("Xin nhập mật khẩu cũ!");
		document.getElementById('old_password').focus();
		return false;
	}
	
	if(document.getElementById('old_password').value.length<6){
		alert("Xin nhập mật khẩu cũ phải nhiều hơn 6 ký tự.");
		document.getElementById('old_password').focus();
		return false;
	}
	
	if(document.getElementById('txt_password').value.length==0){
		alert("Xin nhập mật khẩu mới!");
		document.getElementById('txt_password').focus();
		return false;
	}
	
	if(document.getElementById('txt_password').value.length<6){
		alert("Xin nhập mật khẩu mới phải nhiều hơn 6 ký tự.");
		document.getElementById('txt_password').focus();
		return false;
	}
	
	if(document.getElementById('txt_repassword').value.length==0){
		alert("Xin nhập xác nhận mật khẩu mới!");
		document.getElementById('txt_repassword').focus();
		return false;
	}
	
	if(document.getElementById('txt_repassword').value!=document.getElementById('txt_password').value){
		alert("Mật khẩu mới và xác nhận mật khẩu mới không giống nhau.");
		document.getElementById('txt_repassword').focus();
		return false;	
	}
	
	return true;	
}
