function profileEdit()
{
	if (document.frmEditProf.firstname.value=="" || !isNaN(document.frmEditProf.firstname.value))
	{
		alert("First Name cannot be empty ");
		document.frmEditProf.firstname.select();
		return false;
	}
	else
	{
		document.frmEditProf.hidSave.value = "save";
		document.frmEditProf.method="post";
		document.frmEditProf.action =  "clientEditProfile.asp";
		document.frmEditProf.submit();
	}
}
	
function charchk() 
{
	event.keyCode=DisallowNum(event.keyCode)
}
function DisallowNum(keyPressed)
{
	if (keyPressed>=97 && keyPressed<=122 || keyPressed>=65 && keyPressed<=90 || keyPressed==32 || keyPressed==46)
	{
	}
	else
	{
		keyPressed = 0
	}
		return keyPressed	
}

function citycharchk() 
{
	event.keyCode=DisallowCity(event.keyCode)	
}
function DisallowCity(keyPressed)
{
	if (keyPressed>=97 && keyPressed<=122 || keyPressed>=65 && keyPressed<=90 || keyPressed==32 || keyPressed==45)
	{
	}
	else
	{
		keyPressed = 0
	}
		return keyPressed	
}

function zipnumchk() 
{
	event.keyCode=ZipDisallowChar(event.keyCode)	
}
function ZipDisallowChar(keyPressed)
{
	if (keyPressed>=48 && keyPressed<=57)
	{
	}
	else
	{
		keyPressed = 0
	}
		return keyPressed	
}

function telnumchk() 
{
	event.keyCode=TelDisallowChar(event.keyCode)	
}
function TelDisallowChar(keyPressed)
{
	if (keyPressed>=48 && keyPressed<=57 || keyPressed>=65 && keyPressed<=90 || keyPressed>=97 && keyPressed<=122 || keyPressed==32 || keyPressed==45)
	{
	}
	else
	{
		keyPressed = 0
	}
		return keyPressed	
}
function faxnumchk() 
{
	event.keyCode=FaxDisallowChar(event.keyCode)	
}
function FaxDisallowChar(keyPressed)
{
	if (keyPressed>=48 && keyPressed<=57 || keyPressed==32 || keyPressed==45)
	{
	}
	else
	{
		keyPressed = 0
	}
		return keyPressed	
}

function clientRegister() //Validations for Registration
{
	if (document.frmRegister.txtLoginid.value=="")
	{
		alert("Login Id cannot be empty ");
		document.frmRegister.txtLoginid.select();
		return false;
	}
	if (document.frmRegister.txtLoginid.value.indexOf("@") == -1 || document.frmRegister.txtLoginid.value.indexOf(".") == -1 || ! isEmail(document.frmRegister.txtLoginid.value))
	{
		alert("Invalid Login Id, Please include a proper Email Address as your login Id.");
		document.frmRegister.txtLoginid.select();
		return false;
	}
	if (document.frmRegister.txtPassword.value=="")
	{
		alert("Password cannot be empty ");
		document.frmRegister.txtPassword.focus();
		return false;
	}
	if (document.frmRegister.txtPassword.value.length < 5)
	{
		alert("Password cannot be less than 5 characters ");
		document.frmRegister.txtPassword.focus();
		return false;
	}
	if (document.frmRegister.txtRePassword.value=="")
	{
		alert("Please confirm the password ");
		document.frmRegister.txtRePassword.focus();
		return false;
	}
	if (document.frmRegister.txtPassword.value!=document.frmRegister.txtRePassword.value)
	{
		alert("The passwords are not matching \nPlease enter the passwords again.");
		document.frmRegister.txtRePassword.focus();
		return false;
	}
	else
		return true;
}

function isEmail(strEMail) //validations for email
{
	var strInvalidChars,blnTemp,i,strTemp,intdot,IsMail,strEMailRev,intAtTheRate;
    intdot = strEMail.lastIndexOf(".");
	if (intdot == -1 )
		return false;
    
	intdot=strEMail.length-intdot-1;
	if (intdot < 2 )
		return false;
    
    // Disallowed characters
    strInvalidChars = "!#$%^&*()=+{}[]|\;:'/?>,< ";

	intAtTheRate = strEMail.indexOf("@") ;

    // Check that there is at least one '@' and a character before @
    if (intAtTheRate < 1)
		blnTemp=true;
	else
		blnTemp=false;

    if (blnTemp)
		return !blnTemp;
	
	// Check that there is at least one '.' in the form a@a.com
    blnTemp = (strEMail.indexOf(".") < 3);
   if (blnTemp)
		return !blnTemp;

	//   Check that there is at least one char between '.' and @ after @
	intdot= strEMail.indexOf(intAtTheRate+1,".");
	blnTemp = (intdot==2);
     if (blnTemp)
		return !blnTemp;

	//   Check that there is at least one char between '.' and @ before @
    blnTemp = (strEMail.substring(intAtTheRate - 1, intAtTheRate) == ".");
    if (blnTemp)
		return !blnTemp;

	//  and that the length is at least six (a@a.co)
    blnTemp = (strEMail.length < 6);
   if (blnTemp) 
		return !blnTemp;
	//  Check that there is only one '@'
    blnTemp = (intAtTheRate != strEMail.lastIndexOf("@"));
    
   if (blnTemp)
	return !blnTemp;
   //    extra checks
  //     AFTER '@' space is not allowed
	strTemp=strEMail.substring(intAtTheRate+1);
	blnTemp = (strTemp.indexOf(" ") > 0);
   if (blnTemp) 
		return !blnTemp;

  //   Check that there is one dot AFTER '@'
    blnTemp = (strTemp.indexOf(".") == 0);
   if (blnTemp)
		return !blnTemp;
    
	//    Check if there's a quote (")
    blnTemp = strEMail.indexOf("\"") > 0;
     if (blnTemp )
		return !blnTemp;
    
	//     Check if there's any other disallowed chars
	//     optimize a little if strEMail longer than strInvalidChars
	//     check the other way around
    if (strEMail.length > strInvalidChars.length)
	{
        for(var i = 0; i< strInvalidChars.length;i++)
		{
            if (strEMail.indexOf(strInvalidChars.substring(i,i+1)) > 0 )
                  blnTemp = true;
            if (blnTemp )
				break;
        } //end for
    } //end if
	else
	{
        for(var i = 0 ;i< strEMail.length;i++)
		{
            if (strInvalidChars.indexOf(strEMail.substring(i,i+1)) > 0) 
                  blnTemp = true;
            if (blnTemp )
				break;
        } //end for
    } //end else
    if (blnTemp)
		return !blnTemp;
    
	//     extra check
	 //    no two consecutive dots
    blnTemp = strEMail.indexOf("..") > 0;
    if (blnTemp)
		return !blnTemp;
    
	//    if any of the above are true, invalid e-mail
    return !blnTemp;

}

function clientLogin(reffile)
{
	if (document.frmLogin.txtLoginid.value=="")
	{
		alert("Please enter the login id ");
		document.frmLogin.txtLoginid.focus();
		return false;
	}
	if (document.frmLogin.txtPassword.value=="")
	{
		alert("Please enter the password ");
		document.frmLogin.txtPassword.focus();
		return false;
	}
	else
		document.frmLogin.method = "post";
		document.frmLogin.action = "ClientCheckLogin.asp?submit=yes&Filename="+reffile;
		document.frmLogin.submit();
}

function clientForgotPassword()
{
	if (document.frmClientLogin.txtLoginid.value=="")
	{
		alert("Please enter the login id ");
		document.frmClientLogin.txtLoginid.focus();
		//return false;
	}
	else if (document.frmClientLogin.txtLoginid.value.indexOf("@") == -1 || document.frmClientLogin.txtLoginid.value.indexOf(".") == -1 || ! isEmail(document.frmClientLogin.txtLoginid.value))
	{
		alert("Invalid Login Id, Please include a proper Email Address as your login Id.");
		document.frmClientLogin.txtLoginid.select();
		//return false;
	}
	else
	{
		document.frmClientLogin.method = "post";
		document.frmClientLogin.action = "ClientForgotPwd.asp";
		document.frmClientLogin.submit();
	}
}

function clientLoginpage(reffile)
{
	if (document.frmClientLogin.txtLoginid.value=="")
	{
		alert("Please enter the login id ");
		document.frmClientLogin.txtLoginid.focus();
		return false;
	}
	if (document.frmClientLogin.txtLoginid.value.indexOf("@") == -1 || document.frmClientLogin.txtLoginid.value.indexOf(".") == -1 || ! isEmail(document.frmClientLogin.txtLoginid.value))
	{
		alert("Invalid Login Id, Please include a proper Email Address as your login Id.");
		document.frmClientLogin.txtLoginid.select();
		return false;
	}
	if (document.frmClientLogin.txtPassword.value=="")
	{
		alert("Please enter the password ");
		document.frmClientLogin.txtPassword.focus();
		return false;
	}
	document.frmClientLogin.method = "post";
	document.frmClientLogin.action = "ClientCheckLogin.asp?submit=yes&Filename="+reffile;
	document.frmClientLogin.submit();
}

function clientChangePassword() //Validations for Change Password
{
	if (document.frmChangePassword.txtOldPassword.value=="")
	{
		alert("Please enter the old password ");
		document.frmChangePassword.txtOldPassword.focus();
		return false;
	}
	if (document.frmChangePassword.txtOldPassword.value.length < 5)
	{
		alert("The password cannot be less than 5 characters ");
		document.frmChangePassword.txtOldPassword.focus();
		return false;
	}
	if (document.frmChangePassword.txtNewPassword.value=="")
	{
		alert("Please enter the new password ");
		document.frmChangePassword.txtNewPassword.focus();
		return false;
	}
	if (document.frmChangePassword.txtNewPassword.value.length < 5)
	{
		alert("The password cannot be less than 5 characters ");
		document.frmChangePassword.txtNewPassword.focus();
		return false;
	}
	if (document.frmChangePassword.txtRePassword.value=="")
	{
		alert("Please confirm the new password ");
		document.frmChangePassword.txtRePassword.focus();
		return false;
	}
	if (document.frmChangePassword.txtNewPassword.value!=document.frmChangePassword.txtRePassword.value)
	{
		alert("The passwords are not matching \nPlease enter the passwords again.");
		document.frmChangePassword.txtRePassword.focus();
		return false;
	}
	else
		return true;
}
