var is_cleartip = false;
emptyString = /^\s*$/;
		var nbsp = 160;    // non-breaking space char
		var node_text = 3; // DOM text node-type
		var proceed = 2;
		
		// -----------------------------------------
		//                  trim
		// Trim leading/trailing whitespace off string
		// -----------------------------------------
		
		function trim(str)
		{
		  return str.replace(/^\s+|\s+$/g, '')
		};
		
		// -----------------------------------------
		//                  msg
		// Display warn/error message in HTML element only
		// if the field exists and has browser support.
		// -----------------------------------------
		
		function msg(fld,     // id of element to display message in
		             msgtype, // class to give element ("contentred")
		             message) // string to display
		{
		    // only display if field exists and can be accessed by browser
			if (commonExistenceCheck(fld)) {
			  	// setting an empty string can give problems if later set to a
			  	// non-empty string, so ensure a space present. (For Mozilla and Opera one could
			  	// simply use a space, but IE demands something more, like a non-breaking space.)
				var dispmessage;
    var cssDisplay = "";
    if (emptyString.test(message)) {
     dispmessage = String.fromCharCode(nbsp);
     cssDisplay = "none"; // if empty message, set display to none
    }
    else
     dispmessage = message;

    var elem = document.getElementById(fld);
    if (elem.firstChild) {
     elem.firstChild.nodeValue = dispmessage;
     elem.className = msgtype;

     // this toggles the display (tries to)
     try {
      elem.style.display = cssDisplay;
     }
     catch(e) {}
    }
   }
  };
		
		// -----------------------------------------
		//            commonExistenceCheck
		// Common code to:
		// (a) check for older / less-equipped browsers
		// (b) check if field exists
		// -----------------------------------------
		function commonExistenceCheck(ifld) {
			if (!document.getElementById)
		    	return false;  // not available on this browser - leave validation to the server
		
		  	var elem = document.getElementById(ifld);
		  	if (elem == null)
		  		return false;  // element does not exists
		  	if (!elem.firstChild)
		    	return false;  // not available on this browser
		  	if (elem.firstChild.nodeType != node_text)
		    	return false;  // fifld is wrong type of node
		   return true;
		}
		
		
		// -----------------------------------------
		//            commonCheck
		// Common code for all validation routines to:
		// (a) check for older / less-equipped browsers
		// (b) check if empty fields are required
		// Returns true (validation passed),
		//         false (validation failed) or
		//         proceed (don't know yet)
		// -----------------------------------------
		
		function commonCheck    (vfld,   // element to be validated
		                         fifld,  // id of element to receive error indicator
		                         mifld,  // id of element to receive error message
		                         bShow,  // true if want errors displayed
		                         reqd,   // true if required
		                         fError) // error flag
		
		{
		  	if (fError == null) fError = "*";
		  	if (emptyString.test(vfld.value)) {
				
		    	if (reqd) {
		    		if (bShow) {
			      		msg (fifld, "formErrorLabel", fError);
			      		msg (mifld, "formErrorLabel", "Required field is empty.");
			      		//vfld.focus();
		    		}
		      		return false;
		    	}
		    	if (bShow) {
			    	msg (fifld, "", ""); // no errors
			      	msg (mifld, "", "");
			    }
		    	return true;
		  	}
		  	return proceed;
		}
		
		

		
		
		// -----------------------------------------
		//            validatePresent
		// Validate if something has been entered
		// Returns true if so
		// -----------------------------------------
		
		function validatePresent(vfld,	 // element to be validated
								 fifld,	 // id of element to receive error indicator
		                         mifld,  // id of element to receive info/error msg
		                         bShow,  // true if want errors displayed
		                         fError) // error flag string
		{
		  	var stat = commonCheck (vfld, fifld, mifld, bShow, true, fError);
     var classToUse = "formErrorLabel";
     if (stat) classToUse = "";
		  	if (stat != proceed) return stat;
		  	if (fError == null) fError = "*";
     if (bShow) {  // no errors
      msg (fifld, classToUse, fError);
      msg (mifld, classToUse, "");
     }
		  	return true;
		};
		
		
		// -----------------------------------------
		//               validateEmail
		// Validate if e-mail address
		// Returns true if so (and also if could not be executed because of old browser)
		// -----------------------------------------
		
		function validateEmail  (vfld,   // element to be validated
								 fifld,	 // id of element to receive error indicator
		                         mifld,  // id of element to receive info/error msg
		                         bShow,  // true if want errors displayed
		                         reqd)   // true if required
		{
			var stat = commonCheck (vfld, fifld, mifld, bShow, reqd);
		  	if (stat != proceed) return stat;
		
		  	var tfld = trim(vfld.value);  // trim whitespaces
		  	var email = /^[^@]+@[^@.]+\.[^@]*\w\w$/			// something@something.something-ending-with-at-least-two-chars
		  	if (!email.test(tfld)) {
		  		if (bShow) {
			  		if (reqd) {
				    	msg (fifld, "formErrorLabel", "*");		// display error indicator
					}
			    	msg (mifld, "formErrorLabel", "Email format is invalid.");	// display error msg
        //vfld.focus();
		  		}
		    	return false;
		  	}
		
		/* check for warnings as opposed to errors
		  	// unlike errors, warnings will not stop form processing
		  	var email2 = /^[A-Za-z][\w.-]+@\w[\w.-]+\.[\w.-]*[A-Za-z][A-Za-z]$/		// more checks with alpha
		  	if (!email2.test(tfld)) {
		  		if (bShow) {
			  		if (reqd) {
				    	msg (fifld, "formErrorLabel", "*");		// error indicator
				   	}
			    	msg (mifld, "formErrorLabel", "Verify");	// display error
		  		}
		  	} else if (bShow) {  // no errors
		  		if (reqd) {
			    	msg (fifld, "", "*");
				} else {
			    	msg (fifld, "", "");
				}
		      	msg (mifld, "", "");
			} */
		  	return true;
		};
		
		
		
		// -----------------------------------------
		//             ValidateDIgit: used to ensure that the field contians digit
		// Returns true if so (and also if could not be executed because of old browser)
		// -----------------------------------------
		
		function validateDigit  (vfld,   // element to be validated
								 fifld,	 // id of element to receive error indicator
		                         mifld,  // id of element to receive info/error msg
		                         bShow,  // true if want errors displayed
		                         reqd)   // true if required
		{
		
		  var stat = commonCheck (vfld, fifld, mifld, bShow, reqd);
		  	if (stat != proceed) return stat;
		
		  	var tfld = trim(vfld.value);  					// trim whitespace
		  	var telnr = /^\+?[0-9 ()-]+[0-9]$/ ;
		  	if (!telnr.test(tfld)) {
		  		if (bShow) {
			  		if (reqd) {
				    	msg (fifld, "formErrorLabel", "*");		// display error indicator
					}
			    	msg (mifld, "formErrorLabel", "Invalid");	// display error msg
			    	vfld.focus();
		  		}
		    	return false;
					}
		  	return true;
		};
		
		
		// -----------------------------------------
		//             ValidateDIgit: used to ensure that the field contians digit
		// Returns true if so (and also if could not be executed because of old browser)
		// -----------------------------------------
		
		function validateZip  (vfld,   // element to be validated
								 fifld,	 // id of element to receive error indicator
		                         mifld,  // id of element to receive info/error msg
		                         bShow,  // true if want errors displayed
		                         reqd)   // true if required
		{
		
		  var stat = commonCheck (vfld, fifld, mifld, bShow, reqd);
		  	if (stat != proceed) return stat;
		
		  	var tfld = trim(vfld.value);  					// trim whitespace
		  	var telnr = /^\+?[0-9 ()-]+[0-9]$/ ;
		  	if (!telnr.test(tfld)) {
		  		if (bShow) {
			  		if (reqd) {
				    	msg (fifld, "formErrorLabel", "*");		// display error indicator
					}
			    	msg (mifld, "formErrorLabel", "Invalid");	// display error msg
			    	vfld.focus();
		  		}
		    	return false;
					}
					
					if(tfld.length!= 5 && tfld.length!= 10)
					 {
		  		if (bShow) {
			  		if (reqd) {
				    	msg (fifld, "formErrorLabel", "*");		// display error indicator
					}
			    	msg (mifld, "formErrorLabel", "Zip is not the correct length");	// display error msg
			    	vfld.focus();
		  		}
		    	return false;
					}
		  	return true;
		};
		
		
		// -----------------------------------------
		//             ValidateDIgit: used to ensure that the field contians digit
		// Returns true if so (and also if could not be executed because of old browser)
		// -----------------------------------------
		
		function validateCanZip  (vfld,   // element to be validated
								 fifld,	 // id of element to receive error indicator
		                         mifld,  // id of element to receive info/error msg
		                         bShow,  // true if want errors displayed
		                         reqd)   // true if required
		{
		
		  var stat = commonCheck (vfld, fifld, mifld, bShow, reqd);
		  	if (stat != proceed) return stat;
		
		  	var tfld = trim(vfld.value);  					// trim whitespace
				var isValid=1;
				
				var good=" ()-+0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
				 for (var i = 0; i < tfld.length; i++) {
				 if (good.indexOf(tfld.charAt(i)) == -1) { isValid=0;         }
				 }
       if (isValid==0) 
		  	{
		  		if (bShow) {
			  		if (reqd) {
				    	msg (fifld, "formErrorLabel", "*");		// display error indicator
					}
			    	msg (mifld, "formErrorLabel", "Invalid Postal code ");	// display error msg
			    	vfld.focus();
		  		}
		    	return false;
					}
					
					if(tfld.length<6  || tfld.length >7)
					 {
		  		if (bShow) {
			  		if (reqd) {
				    	msg (fifld, "formErrorLabel", "*");		// display error indicator
					}
			    	msg (mifld, "formErrorLabel", "Incorrect Postal code length");	// display error msg
			    	vfld.focus();
		  		}
		    	return false;
					}
		  	return true;
		};
		
		
		
		
		
		
		function validatePasswordSet(vfldPassword,	// password element to be validated
									vfldRetype, 	// retype element to be validated
								 	fifldPassword, 	// id of the password field error indicator
								 	mifldPassword, 	// id of the password field msg
								 	fifldRetype, 	// id of the retype field error indicator
								 	mifldRetype, 	// id of the retype field msg
								 	bShow, 			// true if showing errors
								 	reqd,			// true if required
									loginName)		 // the user's login name
		{
				// Perform all checks on the password field, then just check they are equal.
			var stat = commonCheck (vfldPassword, fifldPassword, mifldPassword, bShow, reqd);
			if (stat != proceed) return stat;

		   var sPassword = trim(vfldPassword.value);
		   var sRetype = trim(vfldRetype.value);
            var badSequenceLength = 4;
   // Check the minimum  & maximum lengths
   if (sPassword.length < 6 || sPassword.length > 16)
   {
		if (bShow) 
		{
			if (reqd) 
			{
				msg (fifldPassword, "formErrorLabel", "*");		// display error indicator
			}
			msg (mifldPassword, "formErrorLabel", "Use 6 to 16 characters");	// display error msg
			vfldPassword.focus();
		}
		return false;
   }

   // Must contain atleast one digit
   if(!/\d/.test(sPassword))
   {
    if (bShow) {
     if (reqd) {
      msg (fifldPassword, "formErrorLabel", "*");		// display error indicator
     }
     msg (mifldPassword, "formErrorLabel", "Include at least 1 number");	// display error msg
     vfldPassword.focus();
    }
    return false;
   }

   // Must contain no spaces
   if(/\s/.test(sPassword))
   {
    if (bShow) {
     if (reqd) {
      msg (fifldPassword, "formErrorLabel", "*");		// display error indicator
     }
     msg (mifldPassword, "formErrorLabel", "No spaces allowed");	// display error msg
     vfldPassword.focus();
    }
    return false;
   }

    if (( sPassword.match(/[A-Z]/gi) || []).length < 1 )
    {    
            if (bShow) 
            {
                if (reqd) 
                {
                    msg (fifldPassword, "formErrorLabel", "*");
                }
                msg (mifldPassword, "formErrorLabel", "Include at least 1 letter.");
                vfldPassword.focus();
                return false;
            }
    }

        var lower   = "abcdefghijklmnopqrstuvwxyz",
            upper   = lower.toUpperCase(),
            numbers = "0123456789",
            qwerty  = "qwertyuiopasdfghjklzxcvbnm",
            start   = badSequenceLength - 1,
            seq     = "_" + sPassword.slice(0, start);
        for (i = start; i < sPassword.length; i++) {
            seq = seq.slice(1) + sPassword.charAt(i);
            if (
                lower.indexOf(seq)   > -1 ||
                upper.indexOf(seq)   > -1 ||
                numbers.indexOf(seq) > -1 ||
                qwerty.indexOf(seq) > -1
            ) {
            if (bShow) 
            {
                if (reqd) 
                {
                    msg (fifldPassword, "formErrorLabel", "*");
                }
                msg (mifldPassword, "formErrorLabel", "Don't use 4 or more number/letter/keyboard sequences (e.g. 1234, wxyz, asdf)");
                vfldPassword.focus();
                return false;
            }
            }
        }

   // Passwords must not contain the login name.
	if(loginName!= null && typeof loginName!= 'undefined' && loginName !='')
	{
		var arr=loginName.split('@');
		var username=arr[0];
		var domainname=arr[1];

        
        if ( (sPassword.toLowerCase().indexOf( username.toLowerCase()) > -1) || ( sPassword.toLowerCase().indexOf( domainname.toLowerCase()) > -1 ))
        {
          	if (bShow) 
			{
				if (reqd) 
				{
					msg (fifldPassword, "formErrorLabel", "*");		// display error indicator
				}
				msg (mifldPassword, "formErrorLabel", "Don't use any part of your Recruiter ID");	// display error msg
				vfldPassword.focus();
			}
            return false;
        }
    }

   // Password is OK, now check the retype
   if (sRetype != sPassword)
   {
    if (bShow) {
     if (reqd) {
      msg (fifldRetype, "formErrorLabel", "*");		// display error indicator
     }
     msg (mifldRetype, "formErrorLabel", "Please verify your password again");	// display error msg
     vfldRetype.focus();
    }
    return false;
   }

   return true;
		};
		
		// -----------------------------------------
		//            validateTelnr
		// Validate telephone number
		// Current checks:
		//	  a) at least 6 digits long;
		//	  b) warn if more than 14 digits or less than 10 digits;
		//    c) Permits spaces, hyphens, brackets and leading +;
		// Returns true if so (and also if could not be executed because of old browser)
		// -----------------------------------------
		
		function validateTelnr  (id,
						 								vfld,   // element to be validated
								             fifld,  // id of element for error flag indicator
		                         mifld,  // id of element to error message
		                         bShow,  // true if want errors displayed
		                         reqd)   // true if required
		{
		
       var stat = commonCheck (vfld, fifld, mifld, bShow, reqd);
		  	if (stat != proceed) return stat;
		
		  	var tfld = trim(vfld.value);  					// trim whitespace
		  	// count digits
		  	var numdigits = 0;
			   var  isTelno=0 ;
		  	for (var j=0; j<tfld.length; j++) {
		    	if (tfld.charAt(j)>='0' && tfld.charAt(j)<='9')
					{ numdigits++;
					}
		   	}
				
				
				var good=" ()-+0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
				 for (var i = 0; i < tfld.length; i++) {
       if (good.indexOf(tfld.charAt(i)) == -1) { isTelno=1;         }
       else { }
        
       }   
				
			// check number of digits
		  	if (numdigits>40 || isTelno==1) 
			{
		  		if (bShow) {
			  		if (reqd) {
				    	msg (fifld, "formErrorLabel", "*");
				   	}
			    	msg (mifld, "formErrorLabel", "Invalid Telephone#");
					//	document.getElementById(id).value=tfld ;
			    	vfld.focus();
		  		}
		    	return false;
		  	}else if (bShow) {	// no errors
       		if (reqd) {
      	    	msg (fifld, "", "*");
      	    } else {
      	    	msg (fifld, "", "");
      	    }
            	msg (mifld, "", "");
        	}
	  	return true;
		};
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		// -----------------------------------------
//            validateCCNum
// Validate credit card number format.
// Current checks:
//	  a) at least 16 digits;
//    b) only spaces and hyphens are allowed;
// Returns true if so (and also if could not be executed because of old browser)
// -----------------------------------------

function validateCCNum  (vfld,   // element to be validated
                         fifld,  // id of element for error flag indicator
                         mifld,  // id of element to error message
                         bShow,  // true if want errors displayed
                         reqd,   // true if required
                         ctype,
												 creditnum) //card type, Amex is 15 digits
{   
 var stat = commonCheck (vfld, fifld, mifld, bShow, reqd);
 if (stat != proceed) return stat;

 var tfld = trim(vfld.value);  // trim whitespaces
 var ccnum = /^[0-9 -]+[0-9]$/;
 if (!ccnum.test(tfld)) {
  if (bShow) {
   if (reqd) {
    msg (fifld, "formErrorLabel", "*");		// display error indicator
   }
   msg (mifld, "formErrorLabel", "Invalid");	// display error msg
   vfld.focus();
  }
  return false;
 }

 // count digits
 var numdigits = 0;
 for (var j=0; j<tfld.length; j++) {
  if (tfld.charAt(j)>='0' && tfld.charAt(j)<='9') numdigits++;
 }
var creditnum = trim(creditnum);
var ctype = trim(ctype);

 if(!checkCreditCard(creditnum,ctype))
 {
  if (bShow) {
   if (reqd) {
    msg (fifld, "formErrorLabel", "*");
   }
   msg (mifld, "formErrorLabel", "Please enter Valid Credit Card");
   vfld.focus();
  }
  return false;
 }
 else if (bShow) {	// no errors
  if (reqd) {
   msg (fifld, "", "*");
  } else {
   msg (fifld, "", "");
  }
  msg (mifld, "", "");
 }


  
 	return true;
};



/*---------------------*/

function validateCSVNum  (vfld,   // element to be validated
						 fifld,  // id of element for error flag indicator
                         mifld,  // id of element to error message
                         bShow,  // true if want errors displayed
                         reqd,   // true if required
                         ctype) //card type, Amex is 15 digits
{   
	var stat = commonCheck (vfld, fifld, mifld, bShow, reqd);
  	if (stat != proceed) return stat;

  	var tfld = trim(vfld.value);  // trim whitespaces
  	var ccnum = /^[0-9 -]+[0-9]$/;
  	if (!ccnum.test(tfld)) {
  		if (bShow) {
	  		if (reqd) {
		    	msg (fifld, "formErrorLabel", "*");		// display error indicator
			}
	    	msg (mifld, "formErrorLabel", "Invalid");	// display error msg
	    	vfld.focus();
  		}
    	return false;
  	}

	// count digits
  	var numdigits = 0;
  	for (var j=0; j<tfld.length; j++) {
    	if (tfld.charAt(j)>='0' && tfld.charAt(j)<='9') numdigits++;
   	}

   	// check number of digits
    if ( ctype=="American Express") {
    if(numdigits >4)
         {
            		if (bShow) {
          	  		if (reqd) {
          		    	msg (fifld, "formErrorLabel", "*");
          		   	}
          	    	msg (mifld, "formErrorLabel", "Too Long");
          	    	vfld.focus();
            		}
              return false;
           }   
           if(numdigits <=3)
         {
            		if (bShow) {
          	  		if (reqd) {
          		    	msg (fifld, "formErrorLabel", "*");
          		   	}
          	    	msg (mifld, "formErrorLabel", "Too Short");
          	    	vfld.focus();
            		}
              return false;
           } 
    	
 	}
  	if ( numdigits >3 && ctype!="American Express") {
            		if (bShow) {
          	  		if (reqd) {
          		    	msg (fifld, "formErrorLabel", "*");
          		   	}
          	    	msg (mifld, "formErrorLabel", "Too Long");
          	    	vfld.focus();
            		}                 
      
    	return false;
 	}
  if ( numdigits <=2 && ctype!="American Express") {
            		if (bShow) {
          	  		if (reqd) {
          		    	msg (fifld, "formErrorLabel", "*");
          		   	}
          	    	msg (mifld, "formErrorLabel", "Too short");
          	    	vfld.focus();
            		}                 
      
    	return false;
 	} else if (bShow) {	// no errors
 		if (reqd) {
	    	msg (fifld, "", "*");
	    } else {
	    	msg (fifld, "", "");
	    }
      	msg (mifld, "", "");
  	}
  	return true;
}

// -----------------------------------------
//            commonCheckBoxCheck
// Common code for checkbox validation routines to:
// (a) check for older / less-equipped browsers
// (b) check if a checkbox is required to be checked
// Returns true (validation passed),
//         false (validation failed) or
//         proceed (don't know yet)
// -----------------------------------------

function commonCheckBoxCheck (vfld,   // element to be validated
                         fifld,  // id of element to receive error indicator
                         mifld,  // id of element to receive error message
                         bShow,  // true if want errors displayed
                         reqd,   // true if required
                         fError) // error flag

{
  	if (fError == null) fError = "*";
  	if (!vfld.checked) {
    	if (reqd) {
    		if (bShow) {
	      		msg (fifld, "formErrorLabel", fError);
	      		msg (mifld, "", "");
	      		vfld.focus();
    		}
      		return false;
    	}
    	if (bShow) {
	    	msg (fifld, "", ""); // no errors
	      	msg (mifld, "", "");
	    }
    	return true;
  	}
  	return proceed;
}


// -----------------------------------------
//            validateCheckBox
// Validate if checkBox was checked
// Returns true if so
// -----------------------------------------

function validateCheckBox(vfld,	 // element to be validated
						 fifld,	 // id of element to receive error indicator
                         mifld,  // id of element to receive info/error msg
                         bShow,  // true if want errors displayed
                         fError) // error flag string
{
  	var stat = commonCheckBoxCheck (vfld, fifld, mifld, bShow, true, fError);
  	if (stat != proceed) return stat;
  	if (fError == null) fError = "*";
	if (bShow) {  // no errors
	  	msg (fifld, "", fError);
      	msg (mifld, "", "");
	}
  	return true;
};


// -----------------------------------------
//          commonRadioButtonCheck
// Common code for radio button validation routines to:
// (a) check for older / less-equipped browsers
// (b) check if one of the radio buttons is required to be checked
// Returns true (validation passed),
//         false (validation failed) or
//         proceed (don't know yet)
// -----------------------------------------

function commonRadioButtonCheck (vfld,   // element to be validated
                         fifld,  // id of element to receive error indicator
                         mifld,  // id of element to receive error message
                         bShow,  // true if want errors displayed
                         reqd,   // true if required
                         fError) // error flag

{
	var selected = false;
  	if (fError == null) fError = "*";

  	// iterate all radio buttons and look
  	// for one that is checked.
	if(typeof vfld.length != 'undefined')//in case  of one payment method support vfld will be an element, not an array.
	{
		for (var i=0; i < vfld.length; i++) {
			if (vfld[i].checked) {
				selected = true;
				break;
			}
		}
	}
	else
	{
		selected = true;
	}

	if (!selected) {
    	if (reqd) {
    		if (bShow) {
	      		msg (fifld, "formErrorLabel", fError);
	      		msg (mifld, "", "");
	      		vfld[0].focus();
    		}
      		return false;
    	}
    	if (bShow) {
	    	msg (fifld, "", ""); // no errors
	      	msg (mifld, "", "");
	    }
    	return true;
  	}
  	return proceed;
}


// -----------------------------------------
//            validateRadioButton
// Validate if radio button was checked
// Returns true if so
// -----------------------------------------

function validateRadioButton(vfld,	 // element to be validated
						 fifld,	 // id of element to receive error indicator
                         mifld,  // id of element to receive info/error msg
                         bShow,  // true if want errors displayed
                         fError) // error flag string
{
  	var stat = commonRadioButtonCheck (vfld, fifld, mifld, bShow, true, fError);
  	if (stat != proceed) return stat;
  	if (fError == null) fError = "*";
	if (bShow) {  // no errors
	  	msg (fifld, "", fError);
      	msg (mifld, "", "");
	}
  	return true;
};
	// Use with the HTML fragment from hj_client_error_HTML.inc
function writeErrorMessage(msg, string_control_name, display_control_name)
{ 
	document.getElementById(string_control_name).innerHTML = msg;
	
	document.getElementById(display_control_name).style.display = 'inline';
}

//form validation function
function validate_form(ValidationTag)
{
	if(ValidationTag != null&&typeof ValidationTag != 'undefined'&&ValidationTag !='')
	{
		var arrInp = YAHOO.util.Dom.getElementsByClassName(ValidationTag);
	}
	else
	{
		var arrInp = YAHOO.util.Dom.getElementsByClassName('validate_me');
	}
	//First remove all errors labels
	for(var i=0; i<arrInp.length; i++)
	{
		obj = arrInp[i];
		currentNodeBeingValidated=obj;		
		try
		{
			YAHOO.util.Dom.replaceClass(obj.getAttribute("hh_validate_label"),'show_1','hide_1');
		}catch(e){
		};
	}
	var j=0;
	for(var i=0; i<arrInp.length; i++)
	{
		obj = arrInp[i];
		currentNodeBeingValidated=obj;
		var result=eval(obj.getAttribute("hh_validate_function")+"("+")");	
		if(result)
		{
				try
				{
					YAHOO.util.Dom.replaceClass(obj.getAttribute("hh_validate_label"),'hide_1','show_1');
					if(j==0)
					{
						var firstErrInp =obj;				
					}j++;					
				}
				catch(e){};				
				pageHasErrors="1";
		}
	}	
	if(firstErrInp != null&&typeof firstErrInp != 'undefined'&&firstErrInp !='')
	{
		try{
			firstErrInp.focus;
			firstErrInp.select();
		}catch(e){}
		return false;
	}
	return true;
}		

function cleartip () 
{
	is_cleartip = true;	
	var d = 0.25;
	var attributes = {opacity: {to:0}};
        var myFadeOut = new YAHOO.util.Anim('tipdiv', attributes, d);
        myFadeOut.animate();	
        //IE override
        var tipdiv = YAHOO.util.Dom.get('tipdiv');
        if(navigator.userAgent.toLowerCase().indexOf('msie') > -1){
            tipdiv.style.opacity = '0';
        }
}
function showtip (objtip) 
{
	var tip = objtip.id;
	var right_padding = 19;
	var padding_right = YAHOO.util.Dom.get(tip).getAttribute("right_pad");
	if(padding_right != null&&typeof padding_right != 'undefined'&&padding_right !='')
	{
		right_padding += parseInt(padding_right);		
	}	
	YAHOO.util.Dom.get('tipdiv').innerHTML = suggestions[tip];	
        var tipdiv = YAHOO.util.Dom.get('tipdiv');
	var reg = YAHOO.util.Dom.getRegion(tip);		
	var x = YAHOO.util.Dom.getX('tipdiv');
	var y = YAHOO.util.Dom.getY('tipdiv');
	if(reg.top != y || (reg.right + right_padding)!= x || is_cleartip == true)
	{
		YAHOO.util.Dom.setStyle("tipdiv", "display", "block");		
		YAHOO.util.Dom.setY("tipdiv", reg.top);
		YAHOO.util.Dom.setX("tipdiv", (reg.right + right_padding));
		YAHOO.util.Dom.setStyle("tipdiv", 'opacity', '0');
		var attributes = {opacity: {to:1}};
		var d = 0.25;
                var myFadeIn = new YAHOO.util.Anim("tipdiv", attributes, d);		
                //edit the IE dom directly to remove the filter attribute.
                if(navigator.userAgent.toLowerCase().indexOf('msie') > -1){
                    myFadeIn.onComplete.subscribe(function(){
                         var toSearch = tipdiv.style.cssText;
                         var start = toSearch.indexOf("FILTER");
                         if(start > -1){
                            var stop = toSearch.indexOf(";", start);
                            if(stop == -1){
                               stop = toSearch.length;
                            }
                            var afterSearch = toSearch.substring(0, start) + toSearch.substring(stop + 1);
                            tipdiv.style.cssText = afterSearch;
                         }
                    });
                    tipdiv.style.opacity = '1';
                }
		myFadeIn.animate();
		is_cleartip = false;
	}	
}

function checkAnswer()
{
	if(string_required())
	{
		return true;
	}
	else if(currentNodeBeingValidated.value.length<4)
	{
		return true;
	}
	else
	{
		return false;
	}
}
//for captcha
var captchaResponseSuccess = function(o)
{
    try{
		var respObj = eval("(" + o.responseText + ")");
		// let's make sure this was a successful request
		if(respObj.ResultCode && respObj.ResultCode == "SUCCESS")
		{				
			// update the cdata and cimg elements
			var img = YAHOO.util.Dom.get("cimg");
			var fld = YAHOO.util.Dom.get("cdata");
			if(img !== null && fld !== null){
				fld.value = respObj.CaptchaTest;
				img.src = respObj.CaptchaServer;				
			}
		}
	}catch(err){
	}
}
var captchaResponseFailure = function(o)
{
	//nothing
}
var captchaCallback =
{
  success:captchaResponseSuccess,
  failure:captchaResponseFailure,
  argument:[]
};
function getNewCaptcha()
{
	var cObj = YAHOO.util.Connect.asyncRequest('POST', CAPTCHAURL, captchaCallback);	
}
//for password validation
function validate_Password()
{
	var currentLabelID = currentNodeBeingValidated.getAttribute("hh_validate_label");
	var currentMsgDiv  =  YAHOO.util.Dom.get(currentLabelID);
	var sPassword  = trim(currentNodeBeingValidated.value);
	var sRetype = trim(YAHOO.util.Dom.get('retype').value);
	var eCode = 'PR107';
	var returnval = false;		
	//var loginTest = new RegExp(login_name);	
	var arr=login_name.split('@');
	var username=arr[0];
	var domainname=arr[1];
	var loginTest = new RegExp(username);
	var domainTest = new RegExp(domainname);

	if(sPassword.length < 6 || sPassword.length > 16)//Min length and Max Length check
    {
		eCode = 'PR100';		
		returnval = true;
	}
	else if(!/\d/.test(sPassword))// Must contain atleast one digit
	{
		eCode = 'PR101';		
		returnval = true;
	}
    else if( ( sPassword.match(/[A-Z]/gi) || []).length < 1  )//Must contain atlease one char this i need to modify to accept char
	{
		eCode = 'PR102';		
		returnval = true;
	}
	else if(/\s/.test(sPassword))// Must contain no spaces
	{
		eCode = 'PR103';		
		returnval = true;
	}
    else if ( (sPassword.toLowerCase().indexOf( username.toLowerCase()) > -1) || ( sPassword.toLowerCase().indexOf( domainname.toLowerCase()) > -1 ))
	{
		eCode = 'PR104';		
		returnval = true;		
	}	
    else
    {
            var lower   = "abcdefghijklmnopqrstuvwxyz",
            upper   = lower.toUpperCase(),
            numbers = "0123456789",
            qwerty  = "qwertyuiopasdfghjklzxcvbnm",
            start   = badSequenceLength - 1,
            seq     = "_" + sPassword.slice(0, start);
        for (i = start; i < sPassword.length; i++) 
        {
            seq = seq.slice(1) + sPassword.charAt(i);
            if (
                lower.indexOf(seq)   > -1 ||
                upper.indexOf(seq)   > -1 ||
                numbers.indexOf(seq) > -1 ||
                qwerty.indexOf(seq) > -1
            ) {
                eCode = 'PR105';
                returnval = true;
            }
        }
    }
    currentMsgDiv.innerHTML = password_rule_msgs[eCode];
	return returnval;
}

function repassword_required()
{
	var sPassword = trim(YAHOO.util.Dom.get('newpwd').value);
	if(string_required())
	{
		return true;
	}
	else if(currentNodeBeingValidated.value!=sPassword)
	{
		return true;
	}
	else
	{
		return false;
	}
}

function sendResetPasswordEmail()
{
	YAHOO.util.Dom.get('reset_email').submit();
}

function clearDefaults(curobj)
{
	if(curobj.value==curobj.getAttribute("default_text"))
	{
		YAHOO.util.Dom.removeClass(curobj,'instructionaltext');
		YAHOO.util.Dom.addClass(curobj,'formfield');
		curobj.value='';
	}
}

function checkFieldValue(curobj)
{
	if(TrimString(curobj.value) == '')
	{
		YAHOO.util.Dom.removeClass(curobj,'formfield');
		YAHOO.util.Dom.addClass(curobj,'instructionaltext');
		curobj.value=curobj.getAttribute("default_text");
	}
	else
	{
		YAHOO.util.Dom.removeClass(curobj,'instructionaltext');
		YAHOO.util.Dom.addClass(curobj,'formfield');
	}
}

var enableRetype = function()
{
	var obj= YAHOO.util.Dom.get('email_retype');
	YAHOO.util.Dom.addClass(obj,'validate_me');
	if (browser.isIE)
	{
		obj.disabled =false;
	}
	else
	{
		obj.removeAttribute("disabled");	
	}
}

var disableRetype = function()
{
	var curobj = YAHOO.util.Dom.get('inp_email');
	var obj= YAHOO.util.Dom.get('email_retype');	
	if(curobj.value==curobj.getAttribute("default_text"))
	{
		obj.value='';
		YAHOO.util.Dom.removeClass(obj,'validate_me');
		if (browser.isIE)
		{
			obj.disabled =true;
		}
		else
		{
			obj.setAttribute("disabled", "true");	
		}
	}
	else
	{
		obj.removeAttribute("disabled");	
		YAHOO.util.Dom.addClass(obj,'validate_me');
	}
}
