// JavaScript Document
function SignIn(){	
	document.frmLogin.method="post";
	document.frmLogin.action="index.asp?act=log";
	document.frmLogin.submit();
}
function OpenMe(url,wcode){		
	if (wcode=="1"){
		window.open(url,"new_")
	}else{
		window.open(url,"new_","width=790,height=650,toolbar=0,status=0,titlebar=1,resizable=1,scrollbars=1")
	}
}
function OpenLink_ForgotPassword(){		
	if (document.frmLogin.hidSelection.value == "3") {
		alert('Please select either Customer Information Center (CIC), Agents Information Center (AIC) or myCocolife!');
		return;
	}
	if (document.frmLogin.hidSelection.value == "0") {
		OpenMe('https://116.50.224.232/forgotpassword.asp','0');
	}else if (document.frmLogin.hidSelection.value == "1") {
		OpenMe('https://116.50.224.231/forgotpassword.asp','0');
	}else{
		OpenMe('http://www.cocolife.com/mycocolife.com/forgotpassword.asp','1');
	}
}
function OpenLink_Signup(){
	if (document.frmLogin.hidSelection.value == "3") {
		alert('Please select either Customer Information Center (CIC), Agents Information Center (AIC) or myCocolife!');
		return;
	}
	if (document.frmLogin.hidSelection.value == "0") {
		OpenMe('https://116.50.224.232/registration-00.asp','0');
	}else if (document.frmLogin.hidSelection.value == "1") {
		OpenMe('https://116.50.224.231/registration-00.asp','0');
	}else{
		OpenMe('http://www.cocolife.com/mycocolife.com/register_step01.asp','1');
	}
}
function OpenAccess()
{
	var code = document.frmLogin.txtCode.value;		
	var pwd = document.frmLogin.txtPwd.value;
	
	pwd = '<%=objRC4Encryption.DecryptPassword("+pwd+")%>'
	
	alert(pwd);
	
	if (document.frmLogin.hidSelection.value == "3") {
		alert('Please select either Customer Information Center (CIC), Agents Information Center (AIC) or myCocolife!');
		return;
	}
	
	if (document.frmLogin.txtCode.value == "") {
		alert('Please input user name!');
		return;
	}
	if (document.frmLogin.txtPwd.value == "") {
		alert('Please input password!');
		return;
	}
	
	document.frmLogin.txtCode.value = "";
	document.frmLogin.txtPwd.value = "";
	
	if (document.frmLogin.hidSelection.value == "0") {
		OpenMe('http://erwin/webcic-internet/validate_cis.asp?act=do&ac='+code+'&pw='+pwd,'0');
		return;
	}else if (document.frmLogin.hidSelection.value == "1") {
		OpenMe('http://erwin/webaic-internet/validate_cis.asp?act=do&ac='+code+'&pw='+pwd,'0');
		return;
		}
	else{
		OpenMe('https://203.167.109.126/validate.asp?act=login&ac='+code+'&pw=<%=server.URLEncode(passwd)%>','1');	
		return;
	}
	
}		
function save_HiddenValue(selvalue){
	document.frmLogin.hidSelection.value = selvalue;
}
function ValidateInput(strValue){
	if(strValue.match(/([\<])([^\>]{1,})*([\>])/i) != null) {
    	return false;
    } else {
    	return true;
    }
}
function Check(whatform) {
	for(i=0; i<whatform.elements.length; i++){
		if ((whatform.elements[i].type=="text") || (whatform.elements[i].type=="password")) {
			if (ValidateInput(whatform.elements[i].value)==false) {
				return false;
			}
		}		
	}
}
