			/**
	
			 * @filename: checkValidate.js
			 
			 * @purpose: applying various check on registration form
			 
			 * @author: Vipin Chawla <vipinc@smartdatainc.us>
			 
			 * @creation date: 20th DEC 2005
			 
			 * @creation time: 12:30:11 PM
			 
			 * @last modified: 
			 
			 * @module: Registration			
			 
			 * @ables referred: none
			 
			 * @tables updated: none
			 
			 *
			*/


// VARIABLE DECLARATIONS

var digits = "0123456789";

var lowercaseLetters = "abcdefghijklmnopqrstuvwxyz"

var uppercaseLetters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"


// whitespace characters
var whitespace = " \t\n\r";
// Check whether string s is empty.

function isEmpty(s){
	return ((s == null) || (s.length == 0))
}



// Returns true if string s is empty or 
// whitespace characters only.

function isWhitespace (s){
	var i;

    // Is s empty?
    if (isEmpty(s)) return true;

    // Search through string's characters one by one
    // until we find a non-whitespace character.
    // When we do, return false; if we don't, return true.

    for (i = 0; i < s.length; i++){   
        // Check that current character isn't whitespace.
        var c = s.charAt(i);
        if (whitespace.indexOf(c) == -1) return false;
    }

    // All characters are whitespace.
    return true;
}
//check for a valid email Id
 function emailCheck(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
            prompt("Enter the valid e-mail id !");
		    alert("Enter the valid e-mail id !")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
            prompt("Enter the valid e-mail id !");
            alert("Enter the valid e-mail id")
		    return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
            prompt("Enter the valid e-mail id !");
			alert("Enter the valid e-mail id");
		    return false;
		}

		 if (str.indexOf(at,(lat+1))!=-1){
            prompt("Enter the valid e-mail id !");
			alert("Enter the valid e-mail id");
		    return false;
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
            prompt("Enter the valid e-mail id !");
			alert("Enter the valid e-mail id");
		    return false;
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
            prompt("Enter the valid e-mail id !");
			alert("Enter the valid e-mail id");
		    return false;
		 }
		
		 if (str.indexOf(" ")!=-1){
            prompt("Enter the valid e-mail id !");
		    alert("Enter the valid e-mail id !");
		    return false;
		 }

 		 return true					
	}

//Trim the sting Pass to it return trimmed string

function ltrim ( s ){
	return s.replace( /^\s*/, "" )
}

function rtrim ( s ){
	return s.replace( /\s*$/, "" );
}

function trim ( s ){
	return rtrim(ltrim(s));
}

// Display prompt string s in status bar.

function prompt (s){
	window.status = s
}



function is_NaN(s)
{
	if (isCharsInBag (s, "0123456789") == false)
    {
        return true;
    }
    return false;
}

function isCharsInBag (s, bag)
{
    var i;
    // Search through string's characters one by one.
    // If character is in bag, append to returnString.
 
    for (i = 0; i < s.length; i++)
    {
        var c = s.charAt(i);
		
        if (bag.indexOf(c) == -1) return false;
    }
    return true;
}


function isAlphabets(s)
{
    if (isCharsInBag (s, "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ ") == false)
    {
        return false;
    }
    return true;
}






function checkContactUsValidation(){
	  var frm = document.frmContactUs;
	  if(trim(frm.txtFirstname.value) == ""){
		  prompt("Please enter first name  !");
		  alert("Please enter first name  !");
		  frm.txtFirstname.focus();
		  return false;
	  }
	
	  if(!isAlphabets(trim(frm.txtFirstname.value)))
		{
		  prompt("Please enter valid first name  !");
		  alert("Please enter valid first name  !");
		  frm.txtFirstname.focus();
		  return false;
		
		}
	


	  if(trim(frm.textLastname.value) == ""){
		  prompt("Please enter last name !");
		  alert("Please enter last name !");
		  frm.textLastname.focus();
		  return false;
	  }

	 if(!isAlphabets(trim(frm.textLastname.value)))
		{
		  prompt("Please enter valid last name  !");
		  alert("Please enter valid last name  !");
		  frm.textLastname.focus();
		  return false;
		
		}

	  
	  if(trim(frm.txtDayphone.value) == ""){
		  prompt("Please enter daytime phone !");
		  alert("Please enter daytime phone !");
		  frm.txtDayphone.focus();
		  return false;
	  }
	 
	  if(trim(frm.txtEmail.value) == ""){
		  prompt("Please enter your email !");
		  alert("Please enter your email !");
		  frm.txtEmail.focus();
		  return false;
	  }
	

	if(!emailCheck(frm.txtEmail.value)){
	frm.txtEmail.focus();
	return false;
	}

	 if(trim(frm.txtComments.value) == ""){
		  prompt("Please enter your comments !");
		  alert("Please enter your comments !");
		  frm.txtComments.focus();
		  return false;
	  }


	return true;
}


function checkTellaFriendValidation(){
	  var frm = document.frmTellaFriend;
	  if(trim(frm.txtFirstname.value) == ""){
		  prompt("Please enter first name  !");
		  alert("Please enter first name  !");
		  frm.txtFirstname.focus();
		  return false;
	  }
	
	if(!isAlphabets(trim(frm.txtFirstname.value)))
		{
		  prompt("Please enter valid first name  !");
		  alert("Please enter valid first name  !");
		  frm.txtFirstname.focus();
		  return false;
		
		}


	  if(trim(frm.txtLastname.value) == ""){
		 prompt("Please enter last name !");
		  alert("Please enter last name !");
		  frm.txtLastname.focus();
		  return false;
	  }

	if(!isAlphabets(trim(frm.txtLastname.value)))
		{
		  prompt("Please enter valid last name  !");
		  alert("Please enter valid last name  !");
		  frm.txtLastname.focus();
		  return false;
		
		}

	  
	  if(trim(frm.txtTelephone.value) == ""){
		  prompt("Please enter telephone number !");
		  alert("Please enter telephone number !");
		  frm.txtTelephone.focus();
		  return false;
	  }
	 
	  if(trim(frm.txtEmail.value) == ""){
		  prompt("Please enter your email !");
		  alert("Please enter your email !");
		  frm.txtEmail.focus();
		  return false;
	  }
	

	if(!emailCheck(frm.txtEmail.value)){
	frm.txtEmail.focus();
	return false;
	}
	
	  if(trim(frm.txtReferralFirstname.value) == ""){
		  prompt("Please enter referral first name  !");
		  alert("Please enter referral  first name  !");
		  frm.txtReferralFirstname.focus();
		  return false;
	  }
		
	 if(!isAlphabets(trim(frm.txtReferralFirstname.value)))
		{
		  prompt("Please enter valid guest's first name  !");
		  alert("Please enter valid guest's first name  !");
		  frm.txtReferralFirstname.focus();
		  return false;
		
		}
	


	  if(trim(frm.txtReferralLastname.value) == ""){
		  prompt("Please enter referral last name !");
		  alert("Please enter referral last name !");
		  frm.txtReferralLastname.focus();
		  return false;
	  }

	  if(!isAlphabets(trim(frm.txtReferralLastname.value)))
		{
		  prompt("Please enter valid guest's last name  !");
		  alert("Please enter valid guest's last name  !");
		  frm.txtReferralLastname.focus();
		  return false;
		
		}
	  
	  if(trim(frm.txtReferralTelephone.value) == ""){
		  prompt("Please enter referral telephone !");
		  alert("Please enter  referral telephone !");
		  frm.txtReferralTelephone.focus();
		  return false;
	  }
	 
	  if(trim(frm.txtReferralEmail.value) == ""){
		  prompt("Please enter referral email !");
		  alert("Please enter referral email !");
		  frm.txtReferralEmail.focus();
		  return false;
	  }
	
	if(!emailCheck(frm.txtReferralEmail.value)){
	frm.txtReferralEmail.focus();
	return false;
	}
	 

	return true;
}


function checkChecked()
{
	var frm = document.frmRegistration;
	  if(frm.radPayment[1].checked ==true)
	  {	
			document.getElementById("card").style.display="inline";
			document.getElementById("cheque").style.display="none";
	  }else{		
			document.getElementById("card").style.display="none";
			document.getElementById("cheque").style.display="inline";
	  }
}


function checkPayment()
{
	var frm = document.frmRegistration;

	if(frm.radPayment[0].checked != true){
		return true;
	}
   if(frm.radPayment[0].checked ==false)
	{
  	  if(trim(frm.txtSubscriberCCName.value) == ""){
		  prompt("please enter your display name on card!");
		  alert("please enter your display name on card!");
		  frm.txtSubscriberCCName.focus();
		  return false;
	  }
  	  if(trim(frm.txtSubscriberCCAddress.value) == ""){
		  prompt("please enter your address!");
		  alert("please enter your address!");
		  frm.txtSubscriberCCAddress.focus();
		  return false;
	  }
  	  if(trim(frm.txtSubscriberCCZip.value) == ""){
		  prompt("please enter your zip code!");
		  alert("please enter your zip code!");
		  frm.txtSubscriberCCZip.focus();
		  return false;
	  }
  	  if(trim(frm.txtSubscriberCCCity.value) == ""){
		  prompt("please enter your city name!");
		  alert("please enter your city name!");
		  frm.txtSubscriberCCCity.focus();
		  return false;
	  }
  	  if(trim(frm.txtSubscriberCCState.value) == ""){
		  prompt("please enter your state name!");
		  alert("please enter your state name!");
		  frm.txtSubscriberCCState.focus();
		  return false;
	  }
	  if(trim(frm.txtSubscriberCCNumber.value) == ""){
		  prompt("please enter your paymemt details!");
		  alert("please enter your paymemt details!");
		  frm.txtSubscriberCCNumber.focus();
		  return false;
	  }
	  if(trim(frm.txtSubscriberCCNumber.value) != ""){
		  if(frm.txtSubscriberCCNumber.value.length > 16 || frm.txtSubscriberCCNumber.value.length<14){
				  prompt("Please enter a correct credit card number !");
				  alert("Please enter a correct credit card number !");
				  frm.txtSubscriberCCNumber.focus();
				  return false;
 		  }
	  }
	}
	return true;
}


function checkOffice()
{
      var frm = document.frmRegistration;
	  if(frm.radUnderOffice[1].checked){

		frm.txtGuestFirstName.disabled = true; 	
		frm.txtGuestLastName.disabled = true; 
		frm.txtGuestAreaCode.disabled = true; 
		frm.txtGuestPhone.disabled = true; 
		frm.txtGuestAlternativeAreaCode.disabled = true; 
		frm.txtGuestAlternativePhone.disabled = true; 
		frm.txtGuestEmailId.disabled = true;    
		}else{		
		  frm.txtGuestFirstName.disabled = false; 	
		frm.txtGuestLastName.disabled = false; 
		frm.txtGuestAreaCode.disabled = false; 
		frm.txtGuestPhone.disabled = false; 
		frm.txtGuestAlternativeAreaCode.disabled = false; 
		frm.txtGuestAlternativePhone.disabled = false; 
		frm.txtGuestEmailId.disabled = false;   		
	  }
}



function checkBill()
{
	var frm = document.frmPriceListing;
	  if(frm.radPayment[1].checked ==true)
	  {	

			document.getElementById("card").style.display="inline";
			document.getElementById("cheque").style.display="none";
	  }else{		

			document.getElementById("card").style.display="none";
			document.getElementById("cheque").style.display="inline";
	  }
}

function formSubmission(action, Url){
		if( confirm('Are you sure to update this record?')){
					document.frmPriceListing.action=Url+"?cmdSubmit="+action;
					document.frmPriceListing.submit();
		}
	}

function continue1(Url){	

			document.frmPriceListing.action=Url;
			document.frmPriceListing.submit();
	}

function formSubmission1(action, Url, isConfirm){
					document.frmPriceListing.action=Url+"?cmdSubmit="+action;
					document.frmPriceListing.submit();
	
	}



function showHide(){
	if(document.getElementById("chkUnderCompany").checked){
			document.getElementById("AccountCode").style.display="inline";
	}else{
			document.getElementById("AccountCode").style.display="none";
	}
}

function hideShowQuestions(value){
	if((value==1) || (value=="2")){
			document.getElementById("tblChoicesheader").style.display="inline";
			document.getElementById("tblChoices").style.display="inline";
	}else{
			document.getElementById("tblChoicesheader").style.display="none";
			document.getElementById("tblChoices").style.display="none";
	}
}


function checkRequireData(){
		frm = document.frmRegistration5;	
		if(frm.chkMLSFeed.checked ==false ){
			 prompt("Please checked the MLS feed setup fee!");
			 alert("Please checked the MLS feed setup fee!");
			 return false;
		 }
		 return true;
}


function pcase(str) {
	strlen = str.length
	jj = str.substring(0,1).toUpperCase()
	jj = jj + str.substring(1,strlen).toLowerCase()
	  for (i = 2; i <= strlen; i++) {
		if (jj.charAt(i)==" ") {
  		lefthalf = jj.substring(0,i+1)
			righthalf = jj.substring(i+1,strlen)
			righthalf = righthalf.substring(0,1).toUpperCase()+righthalf.substring(1,strlen)
			jj=lefthalf+righthalf
		}
	}
    return jj
}

function showHideState(){
    var frm = document.frmRegistration;
	   
		 
         if(trim(frm.txtHowYouHeard.value) == "Other"){
	    		document.getElementById("oState").style.display="inline";
		     	document.getElementById("oState1").style.display="inline";
    			

      	  }
		  else
			  {
			document.getElementById("oState").style.display="none";
			document.getElementById("oState1").style.display="none";
			
			}
}


function showHideSeminarPurpose(){
     var frm = document.frmRegistration;
	   
		 
         if(trim(frm.seminarpurpose.value) == "Other"){
	    		document.getElementById("oseminarpurpose").style.display="inline";
		     	document.getElementById("oseminarpurpose1").style.display="inline";
    			

      	  }
		  else
			  {
			document.getElementById("oseminarpurpose").style.display="none";
			document.getElementById("oseminarpurpose1").style.display="none";
			
			}
}

function isblank(s) {
     for (var i = 0; i < s.length; i++) {
          var c = s.charAt(i);
          if ((c != ' ') && (c != '\n') && (c != '\t')) return false;
          }
     return true;
}
function isAlphaQuote(elm) {
    if (elm.value == "") {
        return false;
    }
    for (var i = 0; i < elm.value.length; i++) {
        if ((elm.value.charAt(i) < "a" || elm.value.charAt(i) > "z") &&
           (elm.value.charAt(i) < "A" || elm.value.charAt(i) > "Z")  &&
	   (elm.value.charAt(i) != " ")&&
	   (elm.value.charAt(i) != "'")) {
            return false; 
        }
    }
    return true;
}



function checkform_guest (form)
{
	
   if (isblank(form.frm_firstname.value)) {
    alert( "Please enter your First Name." );
    form.frm_firstname.focus();
    return false ;
  }

   if (isAlphaQuote(form.frm_firstname) == false) {
    alert( "Only alphabets allowed for First Name." );
    form.frm_firstname.focus();
    return false ;
  }

   if (isblank(form.frm_lastname.value)) {
    alert( "Please enter your Last Name." );
    form.frm_lastname.focus();
    return false ;
  }

   if (isAlphaQuote(form.frm_lastname) == false) {
    alert( "Only alphabets allowed for Last Name." );
    form.frm_lastname.focus();
    return false ;
  }

 if (isblank(form.frm_address1.value)) {
    alert( "Please enter Address1." );
    form.frm_address1.focus();
    return false ;
  }

 if (isblank(form.frm_town.value)) {
    alert( "Please enter Town." );
    form.frm_town.focus();
    return false ;
  }
   
  if (isblank(form.frm_county.value)) {
    alert( "Please enter County." );
    form.frm_county.focus();
    return false ;
  }

   if (isblank(form.frm_zip.value)) {
    alert( "Please enter Postal Code." );
    form.frm_zip.focus();
    return false ;
  }

 if (isblank(form.frm_country.value)) {
    alert( "Please enter Country." );
    form.frm_country.focus();
    return false ;
  }

  if (isblank(form.frm_email.value)) {
    alert( "Please enter your Email Address." );
    form.frm_email.focus();
    return false ;
  }

  /*if (isEmail(form.frm_email) == false) {
        alert("Please enter valid Email Address.");
        form.frm_email.focus();
        return false;
  }*/
  
  if(!emailCheck(form.frm_email.value)){
	form.frm_email.focus();
	return false;
	}

  if (isblank(form.frm_email_confirm.value)) {
    alert( "Please enter your Confirm Email Address." );
    form.frm_email_confirm.focus();
    return false ;
  }

  /*if (isEmail(form.frm_email_confirm) == false) {
        alert("Please enter valid Confirm Email Address.");
        form.frm_email_confirm.focus();
        return false;
  }*/
   if(!emailCheck(form.frm_email.value)){
	 form.frm_email_confirm.focus();
	return false;
	}
  if (form.frm_email.value != form.frm_email_confirm.value) {
	    alert("Please check you Email Address, as the two addresses are not same.");
        form.frm_email.focus();
        return false;
  }
  if (!form.terms.checked) {
	alert ("Please read the Terms and Conditions before proceeding.");
	return false;
  }

  return true ;
}


function Validator(frmname)
	{
		
	  this.formobj=document.forms[frmname];
	
		if(!this.formobj)
		{
		  alert("BUG: couldnot get Form object "+frmname);
			return;
		}
		if(this.formobj.onsubmit)
		{
			
		 this.formobj.old_onsubmit = this.formobj.onsubmit;
		 this.formobj.onsubmit=null;
		}
		else
		{
			
		 this.formobj.old_onsubmit = null;
		}
		
		this.formobj.onsubmit=form_submit_handler; 
		this.addValidation = add_validation;
		this.setAddnlValidationFunction=set_addnl_vfunction;
		this.setAddnlValidationFunctionAdmin=set_addnl_vfunctionAdmin;
		this.clearAllValidations = clear_all_validations;
	}

// ---------To check the Password & confirm Password (Registration)

function set_addnl_vfunction(DoCustomValidation)
	{
	  this.formobj.addnlvalidation = DoCustomValidation;
	}



function DoCustomValidation()
{

  if(frmRegister.txtPassword.value != frmRegister.txtConfirmPassword.value)
   {
    alert('Confirm password does not match with new password !! ');
	frmRegister.txtPassword.value="";
	frmRegister.txtConfirmPassword.value="";
	frmRegister.txtPassword.focus();
	frmRegister.txtPassword.style.backgroundColor="#FFFFCC";
	frmRegister.txtConfirmPassword.style.backgroundColor="#FFFFCC";

    return false;
  }
  else
  {
    return true;
  }
}

//----------



// ---------To check the Password & confirm Password (Change Password Admin)

function set_addnl_vfunctionAdmin(DoCustomValidationAdmin)
	{ 
	  this.formobj.addnlvalidation = DoCustomValidationAdmin;
	}

function DoCustomValidationAdmin()
{
   
  if(frmChangePassword.txtNewPassword.value != frmChangePassword.txtConfirmPassword.value)
  {
    alert('Confirm password does not match with new password !! ');
	frmChangePassword.txtNewPassword.value="";
	frmChangePassword.txtConfirmPassword.value="";
	frmChangePassword.txtNewPassword.focus();
	frmChangePassword.txtNewPassword.style.backgroundColor="#FFFFCC";
	frmChangePassword.txtConfirmPassword.style.backgroundColor="#FFFFCC";
    return false;
  }
  else
  {
    return true;
  }
}

//----------

function clear_all_validations()
{
	for(var itr=0;itr < this.formobj.elements.length;itr++)
	{
		this.formobj.elements[itr].validationset = null;
	}
}
function form_submit_handler()
{
	for(var itr=0;itr < this.elements.length;itr++)
	{
		if(this.elements[itr].validationset &&
	   !this.elements[itr].validationset.validate())
		{
		  return false;
		}
	}
	if(this.addnlvalidation)
	{
	  str =" var ret = "+this.addnlvalidation+"()";
	  eval(str);
    if(!ret) return ret;
	}
	return true;
}
function add_validation(itemname,descriptor,errstr)
{

  if(!this.formobj)
	{
	  alert("BUG: the form object is not set properly");
		return;
	}//if
	var itemobj = this.formobj[itemname];
  if(!itemobj)
	{
	  alert("BUG: Couldnot get the input object named: "+itemname);
		return;
	}
	if(!itemobj.validationset)
	{
	  itemobj.validationset = new ValidationSet(itemobj);
	}
  itemobj.validationset.add(descriptor,errstr);
}


function ValidationDesc(inputitem,desc,error)
{
  this.desc=desc;
	this.error=error;
	this.itemobj = inputitem;
	this.validate=vdesc_validate;
}

function vdesc_validate()
{
 if(!V2validateData(this.desc,this.itemobj,this.error))
 {
    this.itemobj.focus();
	this.itemobj.style.backgroundColor="#FFFFCC";
		return false;
 }
 return true;
}

function ValidationSet(inputitem)
{
    this.vSet=new Array();
	this.add= add_validationdesc;
	this.validate= vset_validate;
	this.itemobj = inputitem;
}

function add_validationdesc(desc,error)
{
  this.vSet[this.vSet.length]= 
	  new ValidationDesc(this.itemobj,desc,error);
}
function vset_validate()
{
   for(var itr=0;itr<this.vSet.length;itr++)
	 {
	   if(!this.vSet[itr].validate())
		 {
		   return false;
		 }
	 }
	 return true;
}

function checkForgotLogin()

{
	
	
	var frm = document.frmForgot;
	
	if(trim(frm.email.value) == ""){
		  prompt("Please enter email !");
		  alert("Please enter email !");
		  frm.email.focus();
		  return false;
	  }
	
	if(!emailCheck(frm.email.value)){
		
	frm.email.focus();
	return false;
	}
	
	return true;

	
	}


	/* change start*/
	
function V2validateData(strValidateStr,objValue,strError) 
{ 
    var epos = strValidateStr.search("="); 
    var  command  = ""; 
    var  cmdvalue = ""; 
    var  textboxname = (objValue.name).substring(3);//To Print the textboxname while error occurs
	
	if(epos >= 0) 
    { 
     command  = strValidateStr.substring(0,epos); 
     cmdvalue = strValidateStr.substr(epos+1); 
    } 
    else 
    { 
     command = strValidateStr; 
    }
	
    switch(command) 
    { 
        case "req": 
        case "required": 
         { 
			
           if(eval(objValue.value.length) == 0) 
           { 
              if(!strError || strError.length ==0) 
              { 
                strError ="Required Field !!"; 
				//objValue.name.focus();
			   
              
			  }//if 
              alert(strError); 
              return false; 
           }//if 

			var at=objValue.value.charAt(0);
			if(at==0) {
		  
			alert("Please enter Valid Character !!");
			objValue.value="";
		    return false
			}

           break;             
         }//case required 
        case "maxlength": 
        case "maxlen": 
          { 
             if(eval(objValue.value.length) >  eval(cmdvalue)) 
             { 
               if(!strError || strError.length ==0) 
               { 
                 strError = cmdvalue+" characters maximum "; 
               }//if 
             //  alert(strError + "\n(Current length = " + objValue.value.length + " )"); 
			     alert(strError); 
				 objValue.value="";
               return false; 
             }//if 
             break; 
          }//case maxlen 
        case "minlength": 
        case "minlen": 
           {
			
             if(eval(objValue.value.length) <  eval(cmdvalue)) 
             { 
               if(!strError || strError.length ==0) 
               { 
                 strError =  "Minimum " + cmdvalue + " characters required !! "; 
               }//if               
             //  alert(strError + "\n(Current length = " + objValue.value.length + " )"); 
               alert(strError);
                 objValue.value ="";
               return false;                 
             }//if 
             break; 
            }//case minlen 

         case "Faxminlength": 
        case "Faxminlen": 
           {
			 if(objValue.value!=""){
             if(eval(objValue.value.length) <  eval(cmdvalue)) 
             { 
               if(!strError || strError.length ==0) 
               { 
                 strError =  "Minimum " + cmdvalue + " characters required !! "; 
               }//if               
             //  alert(strError + "\n(Current length = " + objValue.value.length + " )"); 
               alert(strError);
                 objValue.value ="";
               return false;                 
             }//if 
             break; 
			 }
            }//case minlen 

        case "alnum": 
        case "alphanumeric": 
           { 
              var charpos = objValue.value.search("[^A-Za-z0-9]"); 
			  var At=objValue.value.charAt(0);
			  if(isNaN(objValue.value.charAt(0))==0){
			  alert("Please Enter Valid character !!");
              objValue.value="";
			  return false;
			  }else if(objValue.value.length > 0 &&  charpos >= 0)  
					  {
						if(!strError || strError.length ==0) 
							{ 
							  strError ="Only alpha-numeric characters allowed !!"; 
							}//if 
					alert(strError + "\n ( Error character position " + eval(charpos+1)+")"); 
					return false; 
					  }
				//}//else 
			  
			  break; 
       }//case alphanumeric 


        case "alnumlogin": 
        case "alphanumericlogin": 
           { 
			  
              var charpos = objValue.value.search("[^A-Za-z0-9_-]"); 
              var At=objValue.value.charAt(0);
			
			 if((objValue.value.charCodeAt(0)>=65) && (objValue.value.charCodeAt(0)<=90) || (objValue.value.charCodeAt(0)>=97) && (objValue.value.charCodeAt(0)<=122)){
			 }else{
				 alert("First Character of Login Id should be an alphbet.");
				objValue.value="";
					return false;
			 }
			  if(isNaN(objValue.value.charAt(0))==0){
			  alert("Enter valid Login Id !!");
			  objValue.value="";
			  return false;
			  }else if(objValue.value.length > 0 &&  charpos >= 0) 
              { 
               if(!strError || strError.length ==0) 
                { 
                  strError ="Only alpha-numeric, undescores, dash are allowed !! "; 

                }//if 
             //   alert(strError + "\n (Error character position " + eval(charpos+1)+")"); 
			 alert(strError); 
			 objValue.value="";
                return false; 
              }//if 
              break; 
			 
           }//case alphanumericlogin 
		  
        case "num": 
        case "numeric": 
           { 
              var charpos = objValue.value.search("[^0-9]"); 
			  
              if(objValue.value.length > 0 &&  charpos >= 0) 
              { 
                if(!strError || strError.length ==0) 
                { 
                  strError = "Only digits allowed "; 
                }//if               
               // alert(strError + "\n ( Error character position " + eval(charpos+1)+")"); 
                alert(strError ); 
				objValue.value="";
				return false; 
              }//if 
              break;               
           }//numeric 

         case "Faxnum": 
        case "Faxnumeric": 
           { 
             alert(objValue.value);
			  if(objValue.value!=""){
				alert("mas"); 
			  var charpos = objValue.value.search("[^0-9]"); 
			  
              if(objValue.value.length > 0 &&  charpos >= 0) 
              { 
                if(!strError || strError.length ==0) 
                { 
                  strError = "Only digits allowed "; 
                }//if               
               // alert(strError + "\n ( Error character position " + eval(charpos+1)+")"); 
                alert(strError ); 
				objValue.value="";
				return false; 
              }//if 
              break;    
			  }
           }//numeric 

        case "alphabetic": 
        case "alpha": 
           { 
              var charpos = objValue.value.search("[^A-Za-z]"); 
              if(objValue.value.length > 0 &&  charpos >= 0) 
              { 
                  if(!strError || strError.length ==0) 
                { 
                  strError = "Only alphabetic characters allowed !!"; 
                }//if                             
             //   alert(strError + "\n ( Error character position " + eval(charpos+1)+")"); 
				alert(strError); 
				objValue.value="";
				//objValue.focus();
                return false; 
              }//if 
              break; 
           }//alpha 
					
		 case "alphabeticumerictrim": 
         case "alpha1numtrim": 
          { 
			/*var at=objValue.value.charAt(0);
			if(at==0) {
			alert("Enter the first character without white space");
		    return false
			}*/
			if(objValue.value.length < 0 &&  charpos < 0 ) 
              {
                  if(!strError || strError.length ==0) 
                { 
                  strError = "Only alphabetic characters allowed !!"; 
                }//if                             
                alert(strError + "\n [Error character position " + eval(charpos+1)+"]"); 
                return false; 
              }//if 
              break; 
           }//alphalnumtrim 
		
		 case "whitespaceatbegining": 
         case "whitespatbeg": 
          { 
			var at=objValue.value.charAt(0);
			if(at==0) {
			alert("Enter the first character without white space !!");
		    return false
			}
		break;
		 }
		 
	
		case "alnumhyphen":
			{
              var charpos = objValue.value.search("[^A-Za-z0-9\-_]"); 
              if(objValue.value.length > 0 &&  charpos >= 0) 
              { 
                  if(!strError || strError.length ==0) 
                { 
                  strError = "characters allowed are A-Z,a-z,0-9,- and _"; 
                }//if                             
                alert(strError + "\n (Error character position " + eval(charpos+1)+")"); 
                return false; 
              }//if 			
			break;
			}
		
        case "email": 
          { 
               if(!validateEmailv2(objValue.value)) 
               { 
                 if(!strError || strError.length ==0) 
                 { 
                    strError ="Enter a valid Email Id!! "; 
					 
                 }//if                                               
                 alert(strError); 
                 return false; 
               }//if 

				var at=objValue.value.charAt(0);
				if(objValue.value.indexOf('@.') != -1 || objValue.value.indexOf('.@') != -1 || objValue.value.indexOf('..') != -1 || at=='.'){
				alert("Enter a valid Email Id!! ");
				}
				
				/*
				if(at==".") {
				alert("Enter a valid Email address ");
				return false
				}*/

           break; 
          }//case email 
        case "lt": 
        case "lessthan": 
         { 
            if(isNaN(objValue.value)) 
            { 
              alert("Should be a number !!"); 
              return false; 
            }//if 
            if(eval(objValue.value) >=  eval(cmdvalue)) 
            { 
              if(!strError || strError.length ==0) 
              { 
                strError = " value should be less than "+ cmdvalue; 
              }//if               
              alert(strError); 
              return false;                 
             }//if             
            break; 
         }//case lessthan 
        case "gt": 
        case "greaterthan": 
         { 
            if(isNaN(objValue.value)) 
            { 
              alert("Should be a number !!"); 
              return false; 
            }//if 
             if(eval(objValue.value) <=  eval(cmdvalue)) 
             { 
               if(!strError || strError.length ==0) 
               { 
                 strError =" value should be greater than "+ cmdvalue; 
               }//if               
               alert(strError); 
               return false;                 
             }//if             
            break; 
         }//case greaterthan 
        case "regexp": 
         { 
		 	if(objValue.value.length > 0)
			{
	            if(!objValue.value.match(cmdvalue)) 
	            { 
	              if(!strError || strError.length ==0) 
	              { 
	                strError = " Invalid characters found !! "; 
	              }//if                                                               
	              alert(strError); 
	              return false;                   
	            }//if 
			}
           break; 
         }//case regexp 
        case "dontselect": 
         { 
            if(objValue.selectedIndex == null) 
            { 
              alert("BUG: dontselect command for non-select Item"); 
              return false; 
            } 
            if(objValue.selectedIndex == eval(cmdvalue)) 
            { 
             if(!strError || strError.length ==0) 
              { 
              strError =" Please Select one option !! "; 
              }//if                                                               
              alert(strError); 
              return false;                                   
             } 
             break; 
         }//case dontselect 
    }//switch 
    return true; 
}
function ltrim ( s ){
	return s.replace( /^\s*/, "" )
}

function rtrim ( s ){
	return s.replace( /\s*$/, "" );
}

function trim ( s ){
	return rtrim(ltrim(s));
}

//check for a valid email Id
 function emailCheckNew(str)
 {
		var retStr=''
		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1)
		{
          retStr="Enter the valid e-mail id !";
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr)
		{
            retStr="Enter the valid e-mail id !";		    
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr)
		{
             retStr="Enter the valid e-mail id !";
		     
		}

		 if (str.indexOf(at,(lat+1))!=-1){
            retStr="Enter the valid e-mail id !";
		    
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot)
		 {
            retStr="Enter the valid e-mail id !";
		 }

		 if (str.indexOf(dot,(lat+2))==-1)
		 {
            retStr="Enter the valid e-mail id !";
		 }
		
		 if (str.indexOf(" ")!=-1)
		 {
             retStr="Enter the valid e-mail id !";
		 }

 		 return retStr;					
	}

function filterInput1(e) 
{
// Get the regular expression to test against for this particular object
			
			 regAllow = e.getAttribute('allow');	
			str= String.fromCharCode(event.keyCode);    
			var re = new RegExp(regAllow);
		 
		if(event.keyCode==13)
		{
			
		}
		else
		{
			if (str.search(re) != -1)
					event.returnValue=true;
				else
					event.returnValue=false;
		}
 }
 
  
 function checkExpression(expr)
 {
 			var modifiedExp = trim(expr);
			//Removing Extra Spaces from the expression
			for(cntr = 0; cntr < modifiedExp.length ; cntr++)
			{
				tempStr = modifiedExp.charAt(cntr);
				if(tempStr == " " && modifiedExp.charAt(cntr+1) == " ")
				{
					tempExp = modifiedExp.substring(0,cntr) +
					modifiedExp.substring(cntr+1,modifiedExp.length);
					modifiedExp = tempExp;
					cntr--;
				}
			}
			return modifiedExp;
 }
 
 function hideSpan(obj)
 { 
	 document.getElementById(obj).innerHTML='';	 
 }
 
////////////////////////////////////////
/* function to get Query string value */
////////////////////////////////////////

	function queryString(val)
	{
		var q  = unescape(location.search.substr(1)).split('&');
	
		for(var i=0; i<q.length; i++){
			var t=q[i].split('=');
			if(t[0].toLowerCase()==val.toLowerCase()) return t[1];
		}
		return '';
	}
		
/*	 change finish*/


