/* Top Login Link */
function Login(){
	var returl = document.URL;
	returl = escape(returl);
	document.location.href = 'https://www.gomlab.com/login/login.gom?lang=eng&returl=' + returl;
}

/* Top Logout Link */
function Logout(){
	var returl = document.URL;
	returl = escape(returl);
	document.location.href = 'https://www.gomlab.com/login/logout.gom?lang=eng&returl=' + returl;
}

/* Top My Profile Link */
function MyProfile(){
	document.location.href = 'https://www.gomlab.com/member/edit_profile.gom?lang=eng';
}

/* Login Check */
function chkLoginForm()
{
	var fm = document.frm;
	if( fm.username.value=='' ){
		alert( 'Please enter your ID (Email).' );
		fm.username.focus();
		return;
	}

	if( fm.password.value=='' ){
		alert( 'Please enter your Password.' );
		fm.password.focus();
		return;
	}

	fm.submit();

	return;
}

/* New Account Agree Check */
function chkAgree(){

	var fm = document.frm;
	if(!fm.agree.checked){
		alert("Please check the box if you agree to the terms.");
		fm.agree.focus();
		return false;
	}
	fm.submit();
	return false;
}

/* Mail Check */
function checkMail(mail)
{
	var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	if (filter.test(mail)) return true;
	else return false;
}

/* Alpha Number Check */
function isAlphaNumCheck(val)
{
	var filter  = /^([a-zA-Z0-9])+$/;
	if (filter.test(val)) return true;
	else return false;
}

/* Register Form Check */
function goRegister(){

	var fm = document.frm;
	if(fm.email.value == ""){
		alert("Please enter your email address in the ID (Email) field.");
		fm.email.focus();
		return false;
	}

	if(!checkMail(fm.email.value)){
		alert('The email address you entered is not valid.');
		fm.email.focus();
		return false;
	}

	if(fm.reemail.value == ""){
		alert("Please enter your email address again in the Confirm Email field.");
		fm.reemail.focus();
		return false;
	}

	if(fm.email.value != fm.reemail.value){
		alert("The information entered in the ID (Email) field and the Confirm Email field does not match.");
		fm.email.focus();
		return false;
	}

	if(fm.username.value == ""){
		alert("Please enter a User Name");
		fm.username.focus();
		return false;
	}

	if(fm.username.value.length < 6 || fm.username.value.length > 20){
		alert( "User Name must be 6 or more characters and/or numbers." );
		fm.username.focus();
		return false;
	}

	if(!isAlphaNumCheck(fm.username.value)){
		alert( "Only characters and/or numbers can be used when entering a User Name (no symbols)." );
		fm.username.focus();
		return false;
	}

	if(fm.new_password.value == ""){
		alert("Please enter a Password.");
		fm.new_password.focus();
		return false;
	}

	if(fm.new_password.value.length < 6 || fm.new_password.value.length > 30){
		alert( "Password must use 6 or more characters and/or numbers." );
		fm.new_password.focus();
		return false;
	}

	if(fm.password_confirm.value == ""){
		alert("Password and Confirm Password do not match.");
		fm.password_confirm.focus();
		return false;
	}

	if(fm.new_password.value != fm.password_confirm.value){
		alert("Password and Confirm Password do not match.");
		fm.password_confirm.focus();
		return false;
	}
	if(fm.locationCode.value == ""){
		alert("Please select a location.");
		fm.locationCode.focus();
		return false;
	}
	if(fm.verification.value == ""){
		alert("Please enter the text that appears in the Verification image into the input box.");
		fm.verification.focus();
		return false;
	}

	fm.submit();
	return false;
}

/* Search ID Form Check */
function goSearchID(){

	var fm =  document.idFrm;
	if(fm.username.value == ""){
		alert("Please insert User Name");
		fm.username.focus();
		return false;
	}

	if(fm.password.value == ""){
		alert("Please insert Your Password");
		fm.password.focus();
		return false;
	}

	fm.submit();
	return false;
}

/* Search Password Form Check */
function goSearchPW(){

	var fm =  document.passFrm;
	if(fm.email.value == ""){
		alert("Please insert Login ID(email)");
		fm.email.focus();
		return false;
	}

	if(fm.username.value == ""){
		alert("Please insert Your User Name");
		fm.username.focus();
		return false;
	}

	fm.submit();
	return false;
}

/* remind_email.gom use*/
function LoginRe(){
	var returl = "http://www.gomlab.com/eng/";
	returl = escape(returl);
	location.href = "/login/login.gom?lang=eng&returl="+returl;
}

/* Delete Account Form Check */
function goDelete(){
	var fm =  document.frm;
	reasonChk = false;
	for(i=0; i < fm.reason.length; i++){
		if(fm.reason[i].checked == true){
			reasonChk = true;
		}
	}
	if(!reasonChk){
		alert('Please select a reason for deleting your account.');
		return false;
	}
	if(fm.reason[3].checked){
		if(fm.reason_text.value == ""){
			alert("Please explain your reason for deleting your account.");
			fm.reason_text.focus();
			return false;
		}
	}
	if(!fm.agree.checked){
		alert("Check the box to confirm that you want to delete your account.");
		return false;
	}

	fm.submit();
	return false;
}

/* Edit Profile Email Change Form Check */
function changeEMail(){
	var fm =  document.upEmail;
	if(fm.new_useremail.value == ""){
		alert("Please insert Change E-mail Address");
		fm.new_useremail.focus();
		return false;
	}

	fm.submit();
	return false;
}

/* Edit Profile UName Change Form Check */
function changeUName(){
	var fm =  document.upUname;
	if(fm.new_username.value == ""){
		alert("Please enter a new User Name.");
		fm.new_username.focus();
		return false;
	}

	fm.submit();
	return false;
}

/* Edit Profile Password Change Form Check */
function changePwd(){
	var fm =  document.upPwd;
	if(fm.password.value == ""){
		alert("Please enter your current Password.");
		fm.password.focus();
		return false;
	}
	if(fm.enter_password.value == ""){
		alert("Please enter your new Password.");
		fm.enter_password.focus();
		return false;
	}
	if(fm.enter_password.value.length < 6 || fm.enter_password.value.length > 30){
		alert( "Password must use 6 or more characters and/or numbers." );
		fm.enter_password.focus();
		return false;
	}
	if(fm.enter_password.value != fm.password_confirm.value){
		alert("The Password you entered did not match");
		fm.password_confirm.focus();
		return false;
	}
	fm.submit();
	return false;
}

/* Edit Profile Additional Information Change Form Check */
function changeOp(){
	var fm =  document.upOp;
	if(fm.locationCode.value == ""){
		alert("Please select your Location.");
		fm.locationCode.focus();
		return false;
	}
	fm.submit();
	return false;
}


