// JavaScript Document

function tac_check(tac){
	if (tac.checked == true){
		document.getElementById('action').disabled = false;
	} else {
		document.getElementById('action').disabled = true;
	}
}
function check_empty(){

	//var nickname_c25 = document.getElementById('nickname_c25').value;
	var fname_c25 = document.getElementById('fname_c25').value;
	var lname_c25 = document.getElementById('lname_c25').value;
	var gender_c1 = document.getElementById('gender_c1').value;
	var bday_month	 = document.getElementById('bday_month').value;
	var bday_day	 = document.getElementById('bday_day').value;
	var bday_year	 = document.getElementById('bday_year').value;
	var country_c45	 = document.getElementById('country_c45').value;
	var email_c45	 = document.getElementById('email_c45').value;
	var password_c12 = document.getElementById('password_c12').value;
	var sq_m		 = document.getElementById('sq_m').value;
	var sa_m		 = document.getElementById('sa_m').value;

	if (fname_c25 == "" || lname_c25 == "" || bday_month == "-1" || bday_day == "-1"
		|| bday_year == "-1" || country_c45 == "" || gender_c1 == "-1" || email_c45 == ""
		|| password_c12 == "" || sq_m == "" || sa_m == "" || country_c45=="-1"){
		alert("Please fill up all required fields.");
		return false;
	}
	else {
		if (document.getElementById('email_c45').value != document.getElementById('confirm_email_c45').value ){
			document.getElementById('confirm_email_c45').select();
			alert('Please confirm not having the same email address');
			var chk = 1;
		}
		if (document.getElementById('password_c12').value != document.getElementById('confirm_password_c12').value ){
			document.getElementById('confirm_password_c12').select();
			alert('Please confirm not having the same password');
			var chk = 1;
		}
		if (chk == 1){
			return false;
		}
	
		return true;
	}
}

function checkEmail(val){
	if (val.value != ""){
	    var searchEmail = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/
		//var searchEmail = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/
		matchEmail = searchEmail.test(val.value);

		if(matchEmail == true){
			//val.style.backgroundColor = "white";
			//val.style.color = "black";
			return true;
		} else{
			//val.style.backgroundColor = "red";
			//val.style.color = "white";
			alert('Invalid email address.');
			val.select();
			val.focus();
			return false;
		}
	}
	else{
		return true;
	}
}