var NA_STATE_CODE = ["","AL", "AK", "AS", "AZ", "AR", "AE", "AA", "AP", "CA", "CO", "CT", "DE", "DC", "FM", "FL", "GA", "GU", "HI", "ID", "IL", "IN", "IA", "KS", "KY", "LA", "ME", "MH", "MD", "MA", "MI", "MN", "MS", "MO", "MT", "NE", "NV", "NH", "NJ", "NM", "NY", "NC", "ND", "MP", "OH", "OK", "OR", "PW", "PA", "PR", "RI", "SC", "SD", "TN", "TX", "UT", "VT", "VI", "VA", "WA", "WV", "WI", "WY"];
var CA_STATE_CODE = ["","AB", "BC", "MB", "NB", "NL", "NT", "NS", "ON", "PE", "QC", "SK", "YT","NU"];
var BR_STATE_CODE=["AC","AL","AP","AM","BA","CE","DF","ES","GO","MA","MT","MS","MG","PA","PB","PR","PE","PI","RJ","RN","RS","RO","RR","SC","SP","SE","TO"];
var NA_STATE_NAME = ["---Select---","Alabama", "Alaska", "American Samoa", "Arizona", "Arkansas", "Armed Forces", "Armed Forces Americas", "Armed Forces Pacific", "California", "Colorado", "Connecticut", "Delaware", "District of Columbia", "Federated States of Micronesia", "Florida", "Georgia", "Guam", "Hawaii", "Idaho", "Illinois", "Indiana", "Iowa", "Kansas", "Kentucky", "Louisiana", "Maine", "Marshall Islands", "Maryland", "Massachusetts", "Michigan", "Minnesota", "Mississippi", "Missouri", "Montana", "Nebraska", "Nevada", "New Hampshire", "New Jersey", "New Mexico", "New York", "North Carolina", "North Dakota", "Northern Mariana Islands", "Ohio", "Oklahoma", "Oregon", "Palau", "Pennsylvania", "Puerto Rico", "Rhode Island", "South Carolina", "South Dakota", "Tennessee", "Texas", "Utah", "Vermont", "Virgin Islands", "Virginia", "Washington", "West Virginia", "Wisconsin", "Wyoming"];
var CA_STATE_NAME = ["---Select---","Alberta", "British Columbia", "Manitoba", "New Brunswick", "Newfoundland and Labrador", "North West Territories", "Nova Scotia", "Ontario", "Prince Edward Island", "Quebec", "Saskatchewan", "Yukon","Nunavut"];
var BR_STATE_NAME=["Acre","Alagoas","Amapa","Amazonas","Bahia","Ceara","Distrito Federal","Espirito Santo","Goias","Maranhao","Mato Grosso","Mato Grosso do Sul","Minas Gerais","Para","Paraiba","Parana","Pernambuco","Piaui","Rio de Janeiro","Rio Grande do Norte","Rio Grande do Sul","Rondonia","Roraima","Santa Catarina","Sao Paulo","Sergipe","Tocantins"];

function ValidatedChar(inString)
{
	if (inString.length < 4)
	{
		alert("Length of Guest ID should be 4 - 10 characters!"); return false;
	}
	if (inString.length > 10)
	{
		alert("Length of Guest ID should be 4 - 10 characters!"); return false;
	}
	if (!isValidStringType1(inString))
	{
		alert("We're sorry, special characters are not allowed."); return false;
	}
	window.open('http://www.koreanair.com/global/gp/eng/ft/mb/mp_checkID.jsp?username=' + 
	document.forms[0].username.value,'','width=400,height=200,top=250,left=300');
    return true;
}
function checkKoreanOnly( koreanChar ) {
   
   if ( koreanChar == null ) return false ;
   
   for(var i=0; i < koreanChar.length; i++){ 

     var c=koreanChar.charCodeAt(i); 

     //( 0xAC00 <= c && c <= 0xD7A3 ) ÃÊÁßÁ¾¼ºÀÌ ¸ðÀÎ ÇÑ±ÛÀÚ 
     //( 0x3131 <= c && c <= 0x318E ) ÀÚÀ½ ¸ðÀ½ 

     if( !( ( 0xAC00 <= c && c <= 0xD7A3 ) || ( 0x3131 <= c && c <= 0x318E ) ) ) {      
        return false ; 
     }
   }  
   return true ;
}

function checkHangul(val,obj)
{
	if(!isEng(val))
	{
		var thename;
		thename = eval("document.f1."+obj);
		 	
		alert("ADDRESS in Western alphabet-Required.");
		thename.value = "";
		thename.focus();
	}
}
function isInclude4(pwd, val)
{
	for (var i=0; i < pwd.length-3; i++)
	{
		 if (val.indexOf(pwd.substring(i,i+4)) != -1)
		 {
			return true;
		 }
	}
	return false;
}

function are_same_numAlpha4( str )
{
	var	pos;
	for( pos = 0; pos < str.length; pos++ )
	{
		if( is_numAlpha( str.charAt(pos) ) )
		{
			if( is_numAlpha( str.charAt(pos+1) ) )
			{
				if( is_numAlpha( str.charAt(pos+2) ) )
				{
					if( is_numAlpha( str.charAt(pos+3) ) )
					{
						if( str.charAt(pos).indexOf(str.charAt(pos+1))>-1 
						&& str.charAt(pos+1).indexOf(str.charAt(pos+2))>-1
						&& str.charAt(pos+2).indexOf(str.charAt(pos+3))>-1
						)
						{
							break;
						}
					}
				}
			}
		}
	}
	if( pos == str.length )
	{
		return true;
	}
	return false;
}
function isIncludeRes(theform, res)
{
	if(theform.password.value.indexOf(res)!=-1)
	{
		return true;
	}
	return false;
}
function isIncludeRes2(theform, res)
{
	if(theform.newpassword.value.indexOf(res)!=-1)
	{
		return true;
	}
	return false;
}
function isIncludePhone(theform, phone)
{
	if(theform.password.value.indexOf(phone)!=-1)
	{
		return true;
	}
	return false;
}
function isIncludePhone2(theform, phone)
{
	if(theform.newpassword.value.indexOf(phone)!=-1)
	{
		return true;
	}
	return false;
}
function isIncludeMobile(theform, mobile)
{
	if(theform.password.value.indexOf(mobile)!=-1)
	{
		return true;
	}
	return false;
}
function isIncludeMobile2(theform, mobile)
{
	if(theform.newpassword.value.indexOf(mobile)!=-1)
	{
		return true;
	}
	return false;
}
function isIncludeID(uid, pwd)
{
	if(uid!=pwd&&pwd.indexOf(uid)!=-1)
	{
		return true;
	}
	return false;
}
function isContinual(_value)
{
	var _validStringElementsType1 ="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; 
	for (var i=0; i < _value.length-5; i++)
	{
		 if (_validStringElementsType1.indexOf(_value.substring(i,i+6)) != -1)
		 {
			return true;
		 }
	}
	return false;
}
//confirm
function isContinual4(_value)
{
	var _validStringElementsType1 ="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; 
	for (var i=0; i < _value.length-3; i++)
	{
		 if (_validStringElementsType1.indexOf(_value.substring(i,i+4)) != -1)
		 {
			return true;
		 }
	}
	return false;
}
function getStrLen(str)
{
	if(str==null || str=='') return 0;
	var strlen=0;
	for(var i=0; i<str.length; i++)
	{
		var c=str.charCodeAt(i);
		if( c < 0xac00 || 0xd7a3 < c ) strlen++;
		else strlen+=2; 
	}
	return strlen;
}	
function selState(theform,ctry)
{
	for(var k = 0; k<theform.addr_state.options.length;k++)
	{
		theform.addr_state.options[k] = null;
	}
	if(ctry == "USa")
	{
		for(var r = 0; r <NA_STATE_CODE.length; r++)
		{
			theform.addr_state.options[r] = new Option(NA_STATE_NAME[r],NA_STATE_CODE[r]);
		}
	}
	else if(ctry == "CAa")
	{
		for(var r = 0; r <CA_STATE_CODE.length; r++)
		{
			theform.addr_state.options[r] = new Option(CA_STATE_NAME[r],CA_STATE_CODE[r]);
		}
	}
	else if(ctry == "BRa")
	{
		for(var r = 0; r <BR_STATE_CODE.length; r++)
		{
			theform.addr_state.options[r] = new Option(BR_STATE_NAME[r],BR_STATE_CODE[r]);
		}
	}

	else
	{
	// don't display sate;
	}	
}

function is_num( str )		
{
	if( str >= '0' && str <= '9' )
		return true;
		
	return false;
}
function is_alpha(str)
{
	if((str>="a" && str<="z")||(str>="A"&&str<="Z")) return true;
	return false;
}
function is_numAlpha(str)
{
	if((str>="0"&&str<="9")||(str>="a" && str<="z")||(str>="A"&&str<="Z")) return true;
	return false;
}
function are_num( str )
{
	var	pos;
	for( pos = 0; pos < str.length; pos++ )
	{
		if( is_num( str.charAt(pos) ) != true ) break;
	}
	if( pos == str.length ) return true;
	return false;
}
function are_alpha( str )
{
	var	pos;
	for( pos = 0; pos < str.length; pos++ )
	{
		if( is_alpha( str.charAt(pos) ) != true ) break;
	}
	if( pos == str.length ) return true;
	return false;
}
function are_numAlpha( str )
{
	var	pos;
	for( pos = 0; pos < str.length; pos++ )
	{
		if( is_numAlpha( str.charAt(pos) ) != true ) break;
	}
	if( pos == str.length ) return true;
	return false;
}
function are_same_num( str )
{
	var	pos;
	for( pos = 0; pos < str.length; pos++ )
	{
		if( is_numAlpha( str.charAt(pos) ) )
		{
			if( is_numAlpha( str.charAt(pos+1) ) )
			{
				if( is_numAlpha( str.charAt(pos+2) ) )
				{
					if( is_numAlpha( str.charAt(pos+3) ) )
					{
						if( is_numAlpha( str.charAt(pos+4) ) )
						{
							if( is_numAlpha( str.charAt(pos+5) ) )
							{
								if( str.charAt(pos).indexOf(str.charAt(pos+1))>-1 
								&& str.charAt(pos+1).indexOf(str.charAt(pos+2))>-1
								&& str.charAt(pos+2).indexOf(str.charAt(pos+3))>-1
								&& str.charAt(pos+3).indexOf(str.charAt(pos+4))>-1
								&& str.charAt(pos+4).indexOf(str.charAt(pos+5))>-1
								)
								{
									break;

								}
							}
						}
					}
				}
			}
		}
	}
	if( pos == str.length )
	{
//	alert(pos);
		return true;
	}
	return false;
}
function compare_id_pass( str1, str2 )
{
	var	pos1;
	var	pos2;
	for( pos1 = 0; pos1 < str1.length; pos1++ )
	{
		for( pos2 = 0; pos2 < str2.length; pos2++ )
		{
			if( str1.charAt(pos1).indexOf(str2.charAt(pos2))>-1 && (pos1 < str1.length-2) && (pos2 < str2.length-2))
			{
				if( str1.charAt(pos1+1).indexOf(str2.charAt(pos2+1))>-1 )
				{
					if( str1.charAt(pos1+2).indexOf(str2.charAt(pos2+2))>-1) 
					{
						return false;
					}
				}
			}
		}
	}
	if( pos1 == str1.length ) return true;
}
function is_same_id_pass( str1, str2 )
{
	if(str1==str2)
	{
		return true;
	}
	return false;
}
/// end 
function upper(obj,str)
{
	obj.value = obj.value.toUpperCase();
}
function onlyNumber2(loc) 
{
	if(/[^0123456789]/g.test(loc.value)) 
	{
		alert("Please input the number only");
		loc.value = "";
		loc.focus();
	}
}
function isEng(str)
{ 
	for(var i=0;i<str.length;i++)
	{ 
		achar = str.charCodeAt(i);
		if( achar > 255 )
		{
			return false; 
		} 
	} 
	return true; 
}
function checkAge(theform)
{
	var time=new Date();
	var year=time.getYear();
	var age;
		
	if (year < 2000)
	{    // Y2K Fix, Isaac Powell
		year = year + 1900; // http://onyx.idbsu.edu/~ipowell		
	}
	age = year - theform.birthdayyyyy.value ;	
	var natval;
	natval=theform.nationality.value;

	if (age<14 && natval == "KOr")  
	{
		alert("Please input the junior member additional information")
		document.all.under14_1.style.display = "block";
		document.all.under14_2.style.display = "block";
	}
	else
	{
		document.all.under14_1.style.display = "none";
		document.all.under14_2.style.display = "none";
	}
}
function sel_Residence(fname,theform)
{
	
	if(fname == "USa" || fname== "CAa" || fname=="BRa")
	{
		document.all.addrUSa1.style.display = "block";
		document.all.addrUSa2.style.display = "block";
		document.all.addrUSa3.style.display = "block";
		document.all.addrUSa4.style.display = "block";
		document.all.addrKOr1.style.display = "none";
		document.all.addrKOr2.style.display = "none";
		document.all.addrKOr3.style.display = "none";
		document.all.addrElse1.style.display = "none";
		document.all.addrElse2.style.display = "none";
		document.all.addrElse3.style.display = "none";
	}
	else if(fname == "KOr")
	{
		if(theform.nationality.value == "KOr")
		{
			document.all.addrUSa1.style.display = "none";
			document.all.addrUSa2.style.display = "none";
			document.all.addrUSa3.style.display = "none";
			document.all.addrUSa4.style.display = "none";
			document.all.addrKOr1.style.display = "block";
			document.all.addrKOr2.style.display = "block";
			document.all.addrKOr3.style.display = "block";
			document.all.addrElse1.style.display = "none";
			document.all.addrElse2.style.display = "none";
			document.all.addrElse3.style.display = "none";
			if(theform.keaction.value == "createnewaccount")
			{		
				document.all.koreanform1.style.display = "block";			
				document.all.koreanform2.style.display = "block";		
			}
		}
		else
		{
			document.all.addrUSa1.style.display = "none";
			document.all.addrUSa2.style.display = "none";
			document.all.addrUSa3.style.display = "none";
			document.all.addrUSa4.style.display = "none";
			document.all.addrKOr1.style.display = "block";
			document.all.addrKOr2.style.display = "block";
			document.all.addrKOr3.style.display = "block";
			document.all.addrElse1.style.display = "none";
			document.all.addrElse2.style.display = "none";
			document.all.addrElse3.style.display = "none";
			if(theform.keaction.value == "createnewaccount")
			{		
				document.all.koreanform1.style.display = "none";			
				document.all.koreanform2.style.display = "none";		
			}
		}
	}
	else if(fname != "KOr")
	{
		if(theform.nationality.value == "KOr")
		{	
			document.all.addrUSa1.style.display = "none";
			document.all.addrUSa2.style.display = "none";
			document.all.addrUSa3.style.display = "none";
			document.all.addrUSa4.style.display = "none";
			document.all.addrKOr1.style.display = "none";
			document.all.addrKOr2.style.display = "none";
			document.all.addrKOr3.style.display = "none";
			document.all.addrElse1.style.display = "block";
			document.all.addrElse2.style.display = "block";
			document.all.addrElse3.style.display = "block";
			if(theform.keaction.value == "createnewaccount")
			{
				document.all.koreanform1.style.display = "block";			
				document.all.koreanform2.style.display = "block";			
			}
		}
		else
		{	
			document.all.addrUSa1.style.display = "none";
			document.all.addrUSa2.style.display = "none";
			document.all.addrUSa3.style.display = "none";
			document.all.addrUSa4.style.display = "none";
			document.all.addrKOr1.style.display = "none";
			document.all.addrKOr2.style.display = "none";
			document.all.addrKOr3.style.display = "none";
			document.all.addrElse1.style.display = "block";
			document.all.addrElse2.style.display = "block";
			document.all.addrElse3.style.display = "block";
			if(theform.keaction.value == "createnewaccount")
			{
				document.all.koreanform1.style.display = "none";			
				document.all.koreanform2.style.display = "none";			
			}
		}
	}
	else
	{
		document.all.addrUSa1.style.display = "none";
		document.all.addrUSa2.style.display = "none";
		document.all.addrUSa3.style.display = "none";
		document.all.addrUSa4.style.display = "none";
		document.all.addrKOr1.style.display = "none";
		document.all.addrKOr2.style.display = "none";
		document.all.addrKOr3.style.display = "none";
		document.all.addrElse1.style.display = "block";
		document.all.addrElse2.style.display = "block";
		document.all.addrElse3.style.display = "block";
	}
}
function sel_nation(theform)
{	
	var time=new Date();
	var year=time.getYear();
	var age;
	if (year < 2000)
	{    // Y2K Fix, Isaac Powell
		year = year + 1900; // http://onyx.idbsu.edu/~ipowell		
	}
	age = year - theform.birthdayyyyy.value ;	
	var natval;
	natval=theform.nationality.value;
	if(natval == "KOr" )
	{
		if(theform.addr_country.value == "KOr")
		{
			if (age<14)  
			{
				alert("Please input the junior member additional information")
				document.all.under14_1.style.display = "block";
				document.all.under14_2.style.display = "block";
			}
			else
			{
				document.all.under14_1.style.display = "none";
				document.all.under14_2.style.display = "none";
			}
			document.all.addrUSa1.style.display = "none";
			document.all.addrUSa2.style.display = "none";
			document.all.addrUSa3.style.display = "none";
			document.all.addrUSa4.style.display = "none";
			document.all.addrKOr1.style.display = "block";
			document.all.addrKOr2.style.display = "block";
			document.all.addrKOr3.style.display = "block";
			document.all.addrElse1.style.display = "none";
			document.all.addrElse2.style.display = "none";
			document.all.addrElse3.style.display = "none";
			if(theform.keaction.value == "createnewaccount")
			{
				document.all.koreanform1.style.display = "block";			
				document.all.koreanform2.style.display = "block";			
			}
		}
		else
		{
			if(theform.addr_country.value== "USa"  ||theform.addr_country.value=="CAa"||theform.addr_country.value=="BRa")
			{
				document.all.addrUSa1.style.display = "block";
				document.all.addrUSa2.style.display = "block";
				document.all.addrUSa3.style.display = "block";
				document.all.addrUSa4.style.display = "block";
				document.all.addrKOr1.style.display = "none";
				document.all.addrKOr2.style.display = "none";
				document.all.addrKOr3.style.display = "none";
				document.all.addrElse1.style.display = "none";
				document.all.addrElse2.style.display = "none";
				document.all.addrElse3.style.display = "none";
			}
			else
			{
				document.all.addrUSa1.style.display = "none";
				document.all.addrUSa2.style.display = "none";
				document.all.addrUSa3.style.display = "none";
				document.all.addrUSa4.style.display = "none";
				document.all.addrKOr1.style.display = "none";
				document.all.addrKOr2.style.display = "none";
				document.all.addrKOr3.style.display = "none";
				document.all.addrElse1.style.display = "block";
				document.all.addrElse2.style.display = "block";
				document.all.addrElse3.style.display = "block";
				if(theform.keaction.value == "createnewaccount")
				{
					document.all.koreanform1.style.display = "block";			
					document.all.koreanform2.style.display = "block";			
				}
			}
		}	
	}
	else if(natval!= "KOr" )
	{
		document.all.under14_1.style.display = "none";
		document.all.under14_2.style.display = "none";
		if(theform.addr_country.value == "KOr")
		{
			document.all.addrUSa1.style.display = "none";
			document.all.addrUSa2.style.display = "none";
			document.all.addrUSa3.style.display = "none";
			document.all.addrUSa4.style.display = "none";
			document.all.addrKOr1.style.display = "block";
			document.all.addrKOr2.style.display = "block";
			document.all.addrKOr3.style.display = "block";
			document.all.addrElse1.style.display = "none";
			document.all.addrElse2.style.display = "none";
			document.all.addrElse3.style.display = "none";
			if(theform.keaction.value == "createnewaccount")
			{
				document.all.koreanform1.style.display = "none";			
				document.all.koreanform2.style.display = "none";			
			}
		}
		else
		{
			if(theform.addr_country.value== "USa"  ||theform.addr_country.value=="CAa" ||theform.addr_country.value=="BRa")
			{
				document.all.addrUSa1.style.display = "block";
				document.all.addrUSa2.style.display = "block";
				document.all.addrUSa3.style.display = "block";
				document.all.addrUSa4.style.display = "block";
				document.all.addrKOr1.style.display = "none";
				document.all.addrKOr2.style.display = "none";
				document.all.addrKOr3.style.display = "none";
				document.all.addrElse1.style.display = "none";
				document.all.addrElse2.style.display = "none";
				document.all.addrElse3.style.display = "none";
			}
			else
			{
				document.all.addrUSa1.style.display = "none";
				document.all.addrUSa2.style.display = "none";
				document.all.addrUSa3.style.display = "none";
				document.all.addrUSa4.style.display = "none";
				document.all.addrKOr1.style.display = "none";
				document.all.addrKOr2.style.display = "none";
				document.all.addrKOr3.style.display = "none";
				document.all.addrElse1.style.display = "block";
				document.all.addrElse2.style.display = "block";
				document.all.addrElse3.style.display = "block";
				if(theform.keaction.value == "createnewaccount")
				{
					document.all.koreanform1.style.display = "none";			
					document.all.koreanform2.style.display = "none";			
				}
			}
		}	
	}
	else
	{
		if(theform.addr_country.value == "USa" || theform.addr_country.value == "CAa" ||theform.addr_country.value == "BRa")
		{ 
			document.all.addrUSa1.style.display = "block";
			document.all.addrUSa2.style.display = "block";
			document.all.addrUSa3.style.display = "block";
			document.all.addrUSa4.style.display = "block";
			document.all.addrKOr1.style.display = "none";
			document.all.addrKOr2.style.display = "none";
			document.all.addrKOr3.style.display = "none";
			document.all.addrElse1.style.display = "none";
			document.all.addrElse2.style.display = "none";
			document.all.addrElse3.style.display = "none";		
		}
		else
		{
			document.all.addrUSa1.style.display = "none";
			document.all.addrUSa2.style.display = "none";
			document.all.addrUSa3.style.display = "none";
			document.all.addrUSa4.style.display = "none";
			document.all.addrKOr1.style.display = "none";
			document.all.addrKOr2.style.display = "none";
			document.all.addrKOr3.style.display = "none";
			document.all.addrElse1.style.display = "block";
			document.all.addrElse2.style.display = "block";
			document.all.addrElse3.style.display = "block";		
		}
		if(theform.keaction.value == "createnewaccount")
		{
			document.all.koreanform1.style.display = "none";			
			document.all.koreanform2.style.display = "none";			
		}
	}
}
function sel1970()
{
	var i;
	i=0;
	for(i=0;i<document.f1.birthdayyyyy.options.length;i++)
	{
		if(document.f1.birthdayyyyy.options[0].selected == true)
		{
			if(document.f1.birthdayyyyy.options[i].value == 1970 )
			{
				document.f1.birthdayyyyy.options[i].selected = true;
			}
		}
	}
}
function checkBirthDate(theform)
{
    alert("Birth Date can't be modified After SignUp !!!");
    theform.birthdaymm.value = theform.PreBirthMonth.value;
    theform.birthdaydd.value   = theform.PreBirthDay.value;
    theform.birthdayyyyy.value  = theform.PreBirthYear.value;
    return;        
}
function zipPop()
{
	window.open("http://www.koreanair.com/global/bl/mp/mp_zipCode.jsp","zippop","width=540,height=300, scrollbars=yes");
}
function validateName(length1, length2)
{
	if((length1+length2)>22)
	{
		alert("Length of the name can not exceed 22 characters.");
		document.f1.firstname.focus();
		return false;
	}
	else
	{
		return true;
	}
}
function isEmail(theForm)
{
	var s = theForm.EMAIL0.value+"@"+theForm.EMAIL1.value;
	if(s.search(/^\s*[\w\~\-\.]+\@[\w\~\-]+(\.[\w\~\-]+)+\s*$/g)>=0)
	{
	}else
	{
		alert("Invalid Email.");
		theForm.EMAIL0.focus()
	}
}
function validateform(theform)
{	if(theform.koreanname&&theform.koreanname.value!=null&&theform.koreanname.value!=""&&!checkKoreanOnly(theform.koreanname.value))
	{
		alert("Enter a Korean alphabet only");
		theform.koreanname.focus();
		return false;
	}
	if (theform.keaction.value == "updateaccount")
	{
		if (!isValidStringType1(theform.newpassword.value))
		{
			alert("We're sorry, special characters are not allowed." + theform.newpassword.value);
			theform.newpassword.focus();
			return false;
		}		
		if (isEmpty(theform.password.value) || theform.oldpassword != null &&(theform.password.value.toUpperCase() != theform.oldpassword.value.toUpperCase()))
		{ 
			alert("The entered password does not match your profile. Please make sure to enter correct data.");
			theform.password.focus();
			return false;	
		}
			if (isEmpty(theform.confirmpassword.value))
			{ 
				alert("Length of new password confirmation should be 6-20 characters.");
				theform.confirmpassword.focus();
					return false;
			} 
			if (theform.newpassword.value != theform.confirmpassword.value)
			{ 
				alert("Password is not confirming. Please enter password again.");
				theform.confirmpassword.focus();
				return false;
			}
		if (theform.newpassword.value.length < 6 || theform.newpassword.value.length >20)
		{ 
			alert("Length of password should be 6-20 characters.");
			theform.newpassword.focus();
			return false;
		}

		if(are_num(theform.newpassword.value))
		{
			alert("Password needs to include at least one English character. Enter your password again. ");
			theform.newpassword.focus();
			return false;
		}
		if(isContinual(theform.newpassword.value))
		{
			alert("More than 6 continual digits or chracters in row is restricted as a password. Please re-enter." + theform.newpassword.value);
			theform.newpassword.focus();
			return false;
		}
		if(!are_same_num(theform.newpassword.value))
		{
			alert("More than 6 continual digits or chracters in row is restricted as a password. Please re-enter.");
			theform.newpassword.focus();
			return false;
		}
		if(is_same_id_pass( theform.username.value.toUpperCase(), theform.newpassword.value.toUpperCase()))
		{
			alert("Password should not be the same as your own ID number. Please re-enter.");
			theform.newpassword.focus();
			return false;
		}
		if(theform.resno1&&theform.resno1.value!=""&&isIncludeRes2(theform, theform.resno1.value))
		{
			alert("Password should not include the whole front part of your own ID number. Please re-enter.");
			theform.newpassword.focus();
			return false;
		}
		if(theform.resno2&&theform.resno2.value!=""&&isIncludeRes2(theform, theform.resno2.value))
		{
			alert("Password should not include the whole last part of your own ID number. Please re-enter.");
			theform.newpassword.focus();
			return false;
		}
		var phone = theform.TELEPHONE0.value+theform.TELEPHONE1.value+theform.TELEPHONE2.value;
		if(phone!=""&&isIncludePhone2(theform, phone))
		{
			alert("Password should not include the whole part of your own phone number. Please re-enter.");
			theform.newpassword.focus();
			return false;
		}
		var mobile = theform.HAND_PHONE0.value+theform.HAND_PHONE1.value+theform.HAND_PHONE2.value;
		if(mobile!=""&&isIncludeMobile2(theform, theform.HAND_PHONE0.value+theform.HAND_PHONE1.value+theform.HAND_PHONE2.value))
		{
			alert("Password should not include the whole part of your own mobile number. Please re-enter.");
			theform.newpassword.focus();
			return false;
		}


		//confirm
		if(isContinual4(theform.newpassword.value))
		{
			if(!confirm("More than 4 continual digits or charactors were enterd. In this case, there is a danger of hacking. If you still want to continue please press the 'confirm' button. " + theform.newpassword.value))
			{
				theform.newpassword.focus();
				return false;
			}
		}
		if(!are_same_numAlpha4(theform.newpassword.value))
		{
			if(!confirm("More than 4 same digits or charactors were enterd. In this case, there is a danger of hacking. If you still want to continue please press the 'confirm' button." + theform.newpassword.value))
			{
				theform.newpassword.focus();
				return false;
			}
		}
		if(isIncludeID( theform.username.value.toUpperCase(), theform.newpassword.value.toUpperCase()))
		{
			if(!confirm("The password you entered includes your own ID number.  In this case, there is a danger of hacking. If you still want to continue please press the 'confirm' button."))
			{
				theform.newpassword.focus();
				return false;
			}
		}
		if(theform.resno1&&theform.resno1.value!=""&&isInclude4(theform.newpassword.value, theform.resno1.value))
		{
			if(!confirm("The password you entered includes more than 4 front digits of your own ID number. In this case, there is a danger of hacking. If you still want to continue please press the 'confirm' button. "))
			{
				theform.newpassword.focus();
				return false;
			}
		}
		if(theform.resno2&&theform.resno2.value!=""&&isInclude4(theform.newpassword.value, theform.resno2.value))
		{
			if(!confirm("The password you entered includes more than 4 last digits of your own ID number. In this case, there is a danger of hacking. If you still want to continue please press the 'confirm' button. "))
			{
				theform.newpassword.focus();
				return false;
			}
		}
		if(phone!=""&&isInclude4( theform.newpassword.value.toUpperCase(), phone))
		{
			if(!confirm("The password you entered includes more than 4 digits of your own phone number. In this case, there is a danger of hacking. If you still want to continue please press the 'confirm' button. "))
			{
				theform.newpassword.focus();
				return false;
			}
		}
		if(mobile!=""&&isInclude4( theform.newpassword.value.toUpperCase(), mobile))
		{
			if(!confirm("The password you entered includes more than 4 digits of your own mobile number. In this case, there is a danger of hacking. If you still want to continue please press the 'confirm' button. "))
			{
				theform.newpassword.focus();
				return false;
			}
		}
	}
	else
	{
		if (!isValidStringType1(theform.username.value))
		{
		   alert("We're sorry, special characters are not allowed.");
			theform.username.focus();
			return false;
		}
		if (!isValidStringType1(theform.password.value))
		{
			alert("We're sorry, special characters are not allowed." + theform.password.value);
			theform.password.focus();
			return false;
		}
		if (theform.password.value.length < 6 || theform.password.value.length >20)
		{ 
			alert("Length of password should be 6-20 characters.");
			theform.password.focus();
			return false;
		}
		if(are_num(theform.password.value))
		{
			alert("Password needs to include at least one English character. Enter your password again. ");
			theform.password.focus();
			return false;
		}
		if(isContinual(theform.password.value))
		{
			alert("More than 6 continual digits or chracters in row is restricted as a password. Please re-enter." + theform.password.value);
			theform.password.focus();
			return false;
		}
		if(!are_same_num(theform.password.value))
		{
			alert("More than 6 continual digits or chracters in row is restricted as a password. Please re-enter.");
			theform.password.focus();
			return false;
		}
		if(is_same_id_pass( theform.username.value.toUpperCase(), theform.password.value.toUpperCase()))
		{
			alert("Password should not be the same as your own ID number. Please re-enter.");
			theform.password.focus();
			return false;
		}
		if(theform.resno1&&theform.resno1.value!=""&&isIncludeRes(theform, theform.resno1.value))
		{
			alert("Password should not include the whole front part of your own ID number. Please re-enter.");
			theform.password.focus();
			return false;
		}
		if(theform.resno2&&theform.resno2.value!=""&&isIncludeRes(theform, theform.resno2.value))
		{
			alert("Password should not include the whole last part of your own ID number. Please re-enter.");
			theform.password.focus();
			return false;
		}
		var phone = theform.TELEPHONE0.value+theform.TELEPHONE1.value+theform.TELEPHONE2.value;
		if(phone!=""&&isIncludePhone(theform, phone))
		{
			alert("Password should not include the whole part of your own phone number. Please re-enter.");
			theform.password.focus();
			return false;
		}
		var mobile = theform.HAND_PHONE0.value+theform.HAND_PHONE1.value+theform.HAND_PHONE2.value;
		if(mobile!=""&&isIncludeMobile(theform, theform.HAND_PHONE0.value+theform.HAND_PHONE1.value+theform.HAND_PHONE2.value))
		{
			alert("Password should not include the whole part of your own mobile number. Please re-enter.");
			theform.password.focus();
			return false;
		}
		if (theform.password.value != theform.confirmpassword.value)
		{ 
			alert("Password is not confirming. Please enter password again.");
			theform.confirmpassword.focus();
			return false;
		}

		//confirm
		if(isContinual4(theform.password.value))
		{
			if(!confirm("More than 4 continual digits or charactors were enterd. In this case, there is a danger of hacking. If you still want to continue please press the 'confirm' button. " + theform.password.value))
			{
				theform.password.focus();
				return false;
			}
		}
		if(!are_same_numAlpha4(theform.password.value))
		{
			if(!confirm("More than 4 same digits or charactors were enterd. In this case, there is a danger of hacking. If you still want to continue please press the 'confirm' button." + theform.password.value))
			{
				theform.password.focus();
				return false;
			}
		}
		if(isIncludeID( theform.username.value.toUpperCase(), theform.password.value.toUpperCase()))
		{
			if(!confirm("The password you entered includes your own ID number.  In this case, there is a danger of hacking. If you still want to continue please press the 'confirm' button."))
			{
				theform.password.focus();
				return false;
			}
		}
		if(theform.resno1&&theform.resno1.value!=""&&isInclude4(theform.password.value, theform.resno1.value))
		{
			if(!confirm("The password you entered includes more than 4 front digits of your own ID number. In this case, there is a danger of hacking. If you still want to continue please press the 'confirm' button. "))
			{
				theform.password.focus();
				return false;
			}
		}
		if(theform.resno2&&theform.resno2.value!=""&&isInclude4(theform.password.value, theform.resno2.value))
		{
			if(!confirm("The password you entered includes more than 4 last digits of your own ID number. In this case, there is a danger of hacking. If you still want to continue please press the 'confirm' button. "))
			{
				theform.password.focus();
				return false;
			}
		}
		if(phone!=""&&isInclude4( theform.password.value.toUpperCase(), phone))
		{
			if(!confirm("The password you entered includes more than 4 digits of your own phone number. In this case, there is a danger of hacking. If you still want to continue please press the 'confirm' button. "))
			{
				theform.password.focus();
				return false;
			}
		}
		if(mobile!=""&&isInclude4( theform.password.value.toUpperCase(), mobile))
		{
			if(!confirm("The password you entered includes more than 4 digits of your own mobile number. In this case, there is a danger of hacking. If you still want to continue please press the 'confirm' button. "))
			{
				theform.password.focus();
				return false;
			}
		}
	}

		if((theform.firstname.value.length+theform.lastname.value.length)>22)
		{
			alert("Length of the name can not exceed 22 characters.");
			theform.firstname.focus();
			return false;
		}
		if (isEmpty(theform.addr_country.value))
		{
			alert("Invalid country of residence");
			theform.addr_country.focus();
        	return false;	
		}	
		if (isEmpty(theform.nationality.value))
		{
			alert("Invalid nationality");
			theform.nationality.focus();
    	    return false;	
		}		
		if( !isEng(theform.firstname.value))
		{
			alert("First Name in Western alphabet Required.");
			theform.firstname.focus();
	        return false;	
		}	
		if (isEmpty(theform.firstname.value))
		{ 
			alert("First Name in Western alphabet(Max 20)-Required.");
			theform.firstname.focus();
    	    return false;
		} 
		if (theform.firstname.value.length < 1 || theform.firstname.value.length > 20)
		{ 
			alert("First Name in Western alphabet(Max 20)-Required.");
			theform.firstname.focus();
	       return false;
		}
		if( !isEng(theform.lastname.value))
		{
			alert("Last Name in Western alphabet Required.");
			theform.lastname.focus();
    	    return false;	
		}		
		if (isEmpty(theform.lastname.value))
		{ 
			allvalid = 0;
			alert("Last Name in Western alphabet(Max 30)-Required");
			theform.lastname.focus();
	        return false;
		} 
		if (theform.lastname.value.length <= 1 || theform.lastname.value.length > 30)
		{ 
			alert("Last Name in Western alphabet(Max 30)-Required");
			theform.lastname.focus();
	        return false;
		}
		if (isEmpty(theform.birthdaymm.value))
		{ 
			alert("Invalid Birthdate month.");
			theform.birthdaymm.focus();
	        return false;
		}
		if (isEmpty(theform.birthdaydd.value))
		{ 
			alert("Invalid Birthdate day.");
			theform.birthdaydd.focus();
        	return false;
		}
		if (isEmpty(theform.birthdayyyyy.value))
		{ 
			alert("Invalid Birthdate year.");
			theform.birthdayyyyy.focus();
	        return false;
		}	
//	nationality
		if (theform.nationality.value == "KOr" && theform.addr_country.value =="KOr")
		{
			if(isEmpty(theform.koreanname.value))
			{
				alert("Invalid Korean Name.");
				theform.koreanname.focus();
				return false;		
			}
			if(isEmpty(theform.resno1.value))
			{
				alert("Invalid Korean Registration Number");
				theform.resno1.focus();
				return false;		
			}
			if(isEmpty(theform.resno2.value))
			{
				alert("Invalid Korean Registration Number");
				theform.resno2.focus();
				return false;		
			}
			if((theform.gender[0].checked == true && theform.resno2.value.substring(0,1)=='2')
			  || (theform.gender[1].checked == true && theform.resno2.value.substring(0,1)=='1')){
				alert("Gender ORYU");
				theform.resno2.focus();
				return false;
			}			
		}	
		if (theform.addr_country.value == "KOr")
		{
			if(isEmpty(theform.KOR_ADDRESS_ZIP1.value))
			{
				alert("Invalid zipcode");
				theform.KOR_ADDRESS_ZIP1.focus();
				return false;		
			}	
			if(isEmpty(theform.KOR_ADDRESS_ZIP2.value))
			{
				alert("Invalid zipcode");
				theform.KOR_ADDRESS_ZIP2.focus();
				return false;		
			}				
			if(isEmpty(theform.KOR_ADDRESS0.value))
			{
				alert("Invalid address");
				theform.KOR_ADDRESS0.focus();
				return false;		
			}	
			if(isEmpty(theform.KOR_ADDRESS1.value))
			{
				alert("Invalid address");
				theform.KOR_ADDRESS1.focus();
				return false;		
			}
			if((getStrLen(theform.KOR_ADDRESS0.value)+getStrLen(theform.KOR_ADDRESS1.value))>85)
			{
				alert("The address is too long. Please shorten the address to less than 42 korean characters and resubmit");
				theform.KOR_ADDRESS0.focus();
				return false;
			}
		}	
		else if	(theform.addr_country.value == "USa" || theform.addr_country.value == "CAa"|| theform.addr_country.value == "BRa")
		{
			if(isEmpty(theform.USA_ADDRESS_ZIP.value))
			{
				alert("Invalid zipcode");
				theform.USA_ADDRESS_ZIP.focus();
				return false;		
			}	
			if(isEmpty(theform.USA_ADDRESS1.value))
			{
				alert("Invalid address");
				theform.USA_ADDRESS1.focus();
				return false;		
			}	
			if(isEmpty(theform.USA_ADDRESS_CITY.value))
			{
				alert("Invalid address city");
				theform.USA_ADDRESS_CITY.focus();
				return false;		
			}				
			if(isEmpty(theform.addr_state.value))
			{
				alert("Invalid address state");
				theform.addr_state.focus();
				return false;		
			}						
		}
		else
		{
			if(isEmpty(theform.addr_zip.value))
			{
				alert("Invalid zipcode");
				theform.addr_zip.focus();
				return false;		
			}										
			if(theform.address1&&isEmpty(theform.address1.value))
			{
				alert("Invalid address");
				theform.address1.focus();
				return false;		
			}							
			if(isEmpty(theform.addr_city.value))
			{
				alert("Invalid address city");
				theform.addr_city.focus();
				return false;		
			}									
		}
		if(theform.address1&&getStrLen(theform.address1.value)>85)
		{
			alert("The address is too long. Please shorten the address to less than 85 characters and resubmit.");
			theform.address1.focus();
			return false;
		}
		if(theform.USA_ADDRESS1&&getStrLen(theform.USA_ADDRESS1.value)>85)
		{
			alert("The address is too long. Please shorten the address to less than 85 characters and resubmit.");
			theform.USA_ADDRESS1.focus();
			return false;
		}
		if (isEmpty(theform.username.value))
		{ 
			alert("Length of Guest ID should be 4-10 characters.");
			theform.username.focus();
    	    return false;
		}
		if (theform.username.value.length < 4 || theform.username.value.length > 10) 
		{ 
			alert("Length of Guest ID should be 4-10 characters.");
			theform.username.focus();
    	    return false;
		} 
		if (isEmpty(theform.password.value))
		{ 
			alert("Length of password should be 5-8 characters.");
			theform.password.focus();
        	return false;
		}

		if (isEmpty(theform.EMAIL0.value))
		{ 
			alert("Invalid Email.");
			theform.EMAIL0.focus();
    	    return false;
		} 
		if (isEmpty(theform.EMAIL1.value))
		{ 
			alert("Invalid Email.");
			theform.EMAIL1.focus();
	        return false;
		} 	
		if(theform.emailnotify.checked)
		{
			theform.emailnotify.value = "on";
		}
		else
		{
			theform.emailnotify.value = "";
		}
		if(isEmpty(theform.TELEPHONE0.value))
		{
	        alert("Enter TelePhone number!");
    	    theform.TELEPHONE0.focus();
	        return false;
		}
		if(isEmpty(theform.TELEPHONE1.value))
		{
			alert("Enter TelePhone number!");
	        theform.TELEPHONE1.focus();
    	    return false;
		}
		if(isEmpty(theform.TELEPHONE2.value))
		{
        	alert("Enter TelePhone number!");
		    theform.TELEPHONE2.focus();
        	return false;
		}			
		if (theform.keaction.value == "createnewaccount" && theform.agreecheck.checked == false)
		{ 
			alert("Please read the agreement and check it.");
			theform.agreecheck.focus();
			return false;
		}
	theform.submit();
}
