// for sign in
function Cssinput_normalSignin(thisInputID) {
	thisInputID.className="input_normal_14px";
}

function Cssinput_focusSignin(thisInputID) {
	thisInputID.className="input_focus_14px";
}

function Cssinput_errorSignin(thisInputID) {
	thisInputID.className="input_error_14px";
}



function CheckFormSignin() {
	if (CheckVerifySigninUserID(document.getElementById("Username"),'txtIDusername')==false){
		return false;
	}
	if (CheckVerifySigninPWD(document.getElementById("Password"),'txtIDpassword')==false){
		return false;
	}
	return true;	
}


function CheckVerifySigninUserID(thisInputID,txtDivID) {
var isError="";
if (thisInputID.value==""){
	isError="yes";
	strError="User ID or E-mail Address information is required."
	}
else{
	if ((thisInputID.value.length<3)||(thisInputID.value.length>50)){
	isError="yes";
	strError="User ID or E-mail Address information is required."
	}
}
var Letters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890-_.@"
for (i=0; i < thisInputID.value.length; i++){
	var CheckChar = thisInputID.value.charAt(i);
	CheckChar = CheckChar.toUpperCase();
	if (Letters.indexOf(CheckChar) == -1)
	{
	isError="yes";
	strError="User ID or E-mail Address information is unregulated."
	}
}

if (isError=="yes"){
	Cssinput_errorSignin(thisInputID);
	document.getElementById(txtDivID).innerHTML="<img src=\"../images/ico/ico_f.gif\" hspace=\"5\" border=\"0\" align=\"absmiddle\" /><br />"+strError;
	return false;
	}
else {
	Cssinput_normalSignin(thisInputID);
	document.getElementById(txtDivID).innerHTML="<img src=\"../images/ico/ico_t.gif\" hspace=\"5\" border=\"0\" align=\"absmiddle\" />";
	return true;
	}

}




function CheckVerifySigninPWD(thisInputID,txtDivID) {
var txtExtra="";
var isError="";
if (thisInputID.value==""){
	isError="yes";
	strError="Password information is required."
	}
else {
	if (thisInputID.value.length<4){
		isError="yes";
		strError="Password should be more than 3 characters."
		}
	if (thisInputID.value.length>20){
		isError="yes";
		strError="Password should be less than 20 characters."
		}
	}

var Letters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890"
for (i=0; i < thisInputID.value.length; i++)
{
	var CheckChar = thisInputID.value.charAt(i);
	CheckChar = CheckChar.toUpperCase();
	if (Letters.indexOf(CheckChar) == -1)
	{
	isError="yes";
	strError="Password is unregulated."
	}
}

if (isError=="yes"){
	Cssinput_errorSignin(thisInputID);
	document.getElementById(txtDivID).innerHTML="<img src=\"../images/ico/ico_f.gif\" hspace=\"5\" border=\"0\" align=\"absmiddle\" /><br />"+strError;
	return false;
	}
else {
	Cssinput_normalSignin(thisInputID);
	document.getElementById(txtDivID).innerHTML="<img src=\"../images/ico/ico_t.gif\" hspace=\"5\" border=\"0\" align=\"absmiddle\" />";
	return true;
	}

}












// for register
function CheckFormReg() {
	if (CheckVerifyUserID(document.getElementById("uname"),'txtIDuname')==false){
		return false;
		}
	if (CheckVerifyPWD(document.getElementById("pwd"),'txtIDpwd')==false){
		return false;
		}
	if (CheckVerifyPWD2(document.getElementById("pwd2"),'pwd','txtIDpwd2')==false){
		return false;
		}
	if (CheckVerifyEmail(document.getElementById("email"),'txtIDemail')==false){
		return false;
		}
	if (CheckVerifyFirstLastName(document.getElementById("uFirstName"),'txtIDuFirstName','First Name')==false){
		return false;
		}
	if (CheckVerifyFirstLastName(document.getElementById("uLastName"),'txtIDuLastName','Last Name')==false){
		return false;
		}
	if (CheckVerifyUCountry(document.getElementById("uCountry"),'txtIDucountry')==false){
		return false;
		}
	if (CheckVerifyUsertype(document.getElementById("usertype"),'txtIDusertype')==false){
		return false;
		}
	if (CheckVerifyIsAgreeTerms(document.getElementById("isAgreeTerms"),'txtIDisAgreeTerms')==false){
		return false;
		}
	return true;	
}


function CheckVerifyUserID(thisInputID,txtDivID) {
	CreateXMLHttp();
	var url = "../ajax/check_reg.asp?checkType=UserID&uname=" + escape(thisInputID.value);
	xmlHttp.open("GET", url, true);
	xmlHttp.onreadystatechange = function(){HandleRequest(txtDivID)};
	xmlHttp.send(null);

	var isError="";
	if ((thisInputID.value=="")||(thisInputID.value.length<3)||(thisInputID.value.length>50)){
		isError="yes";
		}
	var Letters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890-_@."
	for (i=0; i < thisInputID.value.length; i++){
		var CheckChar = thisInputID.value.charAt(i);
		CheckChar = CheckChar.toUpperCase();
		if (Letters.indexOf(CheckChar) == -1){
			isError="yes";
		}
	}

	if (isError=="yes"){
		InputCss(thisInputID,'error');
		return false;
		}
	else {
		InputCss(thisInputID,'');
		return true;
	}

}




function CheckVerifyPWD(thisInputID,txtDivID) {
	var txtExtra="";
	var isError="";
	if (thisInputID.value==""){
		isError="yes";
		strError="Password information is required."
	}
	else {
		if (thisInputID.value.length<4){
			isError="yes";
			strError="Password should be more than 3 characters."
		}
		if (thisInputID.value.length>20){
			isError="yes";
			strError="Password should be less than 20 characters."
		}
	}

	var Letters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890"
	for (i=0; i < thisInputID.value.length; i++){
		var CheckChar = thisInputID.value.charAt(i);
		CheckChar = CheckChar.toUpperCase();
		if (Letters.indexOf(CheckChar) == -1){
			isError="yes";
		strError="Password is unregulated."
		}
	}

	if (isError=="yes"){
		InputCss(thisInputID,'error');
		InputCheckInnerHTML(txtDivID,"ng",strError);
		return false;
	}
	else {
		InputCss(thisInputID,'');
		InputCheckInnerHTML(txtDivID,"ok","");
		return true;
	}

}




function CheckVerifyPWD2(thisInputID,thisInputConfirmID,txtDivID) {
	var txtExtra="";
	var isError="";
	if (thisInputID.value!=document.getElementById(thisInputConfirmID).value){
		isError="yes";
		strError="Password and Confirm Password must match."
	}

	if (thisInputID.value==""){
		isError="yes";
		strError="Confirm Password information is required."
	}
	else {
		if (thisInputID.value.length<4){
			isError="yes";
			strError="Confirm Password should be more than 3 characters."
		}
		if (thisInputID.value.length>20){
			isError="yes";
			strError="Confirm Password should be less than 20 characters."
		}
	}

	var Letters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890"
	for (i=0; i < thisInputID.value.length; i++){
		var CheckChar = thisInputID.value.charAt(i);
		CheckChar = CheckChar.toUpperCase();
		if (Letters.indexOf(CheckChar) == -1){
			isError="yes";
			strError="Confirm Password is unregulated."
		}
	}

	if (isError=="yes"){
		InputCss(thisInputID,'error');
		InputCheckInnerHTML(txtDivID,"ng",strError);
		return false;
	}
	else {
		InputCss(thisInputID,'');
		InputCheckInnerHTML(txtDivID,"ok","");
		return true;
	}
}


function CheckVerifyEmail(thisInputID,txtDivID) {
	CreateXMLHttp();
	var url = "../ajax/check_reg.asp?checkType=email&email=" + escape(thisInputID.value);
	xmlHttp.open("GET", url, true);
	xmlHttp.onreadystatechange = function(){HandleRequest(txtDivID)};
	xmlHttp.send(null);

	var isError="";
	if ((thisInputID.value=="")||(thisInputID.value.length<5)){
		isError="yes";
	}
	if ((thisInputID.value.charAt(0)==".")||(thisInputID.value.charAt(0)=="@")||(thisInputID.value.indexOf('@', 0) == -1)||(thisInputID.value.indexOf('.', 0) == -1)||(thisInputID.value.lastIndexOf("@")==thisInputID.value.length-1)||(thisInputID.value.lastIndexOf(".")==thisInputID.value.length-1)){
		isError="yes";
	}

	if (isError=="yes"){
		InputCss(thisInputID,'error');
		return false;
	}
	else {
		InputCss(thisInputID,'');
		return true;
	}

}




function CheckVerifyFirstLastName(thisInputID,txtDivID,thisObjName) {
	var isError="";
	if (thisInputID.value==""){
		isError="yes";
		strError=thisObjName+" is required."
	}
	else{
		if (thisInputID.value.length<2){
			isError="yes";
			strError=thisObjName+" requires more than 2 characters."
		}
		if (thisInputID.value.length>20){
			isError="yes";
			strError=thisObjName+" requires less than 20 characters."
		}
	}

	if (isError=="yes"){
		InputCss(thisInputID,'error');
		InputCheckInnerHTML(txtDivID,"ng",strError);
		return false;
	}
	else {
		InputCss(thisInputID,'');
		InputCheckInnerHTML(txtDivID,"ok","");
		return true;
	}
}



function CheckVerifyUCountry(thisInputID,txtDivID) {
	var strError="";
	var isError="";
	if (thisInputID.value==""){
		isError="yes";
		strError="Please select your country or region.";
		InputCheckInnerHTML(txtDivID,"ng",strError);
		return false;
	}
	else {
		InputCheckInnerHTML(txtDivID,"ok","");
		return true;
	}
}



function CheckVerifyUsertype(thisInputID,txtDivID) {
	var isError="";
	if (thisInputID.value==""){
		var strError="Please select Membership Type.";
		InputCheckInnerHTML(txtDivID,"ng",strError);
		return false;
	}
	else {
		InputCheckInnerHTML(txtDivID,"ok","");
		return true;
	}
}



function CheckVerifyIsAgreeTerms(thisInputID,txtDivID) {
	if (thisInputID.checked!=true){
		var strError="You must agree our terms and conditions.";
		InputCheckInnerHTML(txtDivID,"ng",strError);
		return false;
	}
	else {
		InputCheckInnerHTML(txtDivID,"ok","");
		return true;
	}
}


