	 /*
	  Functions in this document
	    
		(1) minLength(field,val,msg)
		       [ This function check minimum length is giveen or not] 
		(2) maxLength(field,val,msg)
		       [ This function used to limit maximum text] 
	    (3) isZeroLead(field)  
		  	   [ This function check leading zero on the field text]
		(4) isNumber(numberField,fieldString)
		       [ This function check valid number]
        (5) isCNumber(numberField,fieldString)
		       [ This function check valid Integer]
		(6) echeck(str)
		       [ This function check valid email]
		(7) CheckBoxCheck(msg)
		       [ This function check if atleast one check box is checked]
		(8) portionCheckBoxCheck(name,msg)
		       [ This function check if atleast one check box is checked in a given portion]
		(9) checkUncheckAll(field)
			   [ This function is used to check or uncheck all check boxes in a given form]
	    (10) alphabetCheck(fieldToCheck)		
			  [ This function is used to check alphabetic charcters]
	    (11) validTextMaker(textField)
	          [ This function is used to restrict special charcters in some text field]
		(12) finalCheck(finalField)
	          [ This function is used to restrict special charcters ]
        (13) removeLeadingAndTrailingChar (fieldToRemoveChar, removeChar)	
			  [ This function is used to erase special charcters from beginning and end of field ]
	    (14) yearCheck(yearField)  
	          [ This function is used to check for valid year ] 
	*/ 
	var mikExp = /[$\\@\\\#%\^\&\*\(\)\[\]\+\{\}\`\~\=\|\'\"\<\>]/;
//	var mikExp = /[$\\@\\\#%\^\&\*\(\)\[\]\+\{\}\`\~\=\|\'\"\<\>]/;
	// Special Charcters that are restricted to user
//	var mikExp=/[\\\\^\&\*\`\~\=\|\'\"\ ]/; 

	/** (1)
	*  This method is used to check if 
	*  the text length of a field is meeting
	*  the minimum range of requirements
	*/
	function minLength(field,val,msg) {
		if ( field.value.length < val) {
			alert(msg);
			field.select();
			field.focus();
			return false;
		}
		return true;
	}
	
	/** (2)
	*  This function is used to check if  
	*  text is not exceeding the maximum
	*  limit
	*/
	function maxLength(field,val,msg) {
		if ( field.value.length > val ) {
			alert(msg);
			field.select();
			field.focus();
			return false;
		}
		return true;
	}

	/** (3)
	*  This Function is used to check if  
	*  ther is a zero charcter in the 
	*  very first position of field 
	*/
	function isZeroLead(field){
		var a = "";
		a = field.value.charAt(0);
		if (a=="0") {
		   alert('There is zero in starting position');
		   field.select();
	  	   field.focus();
		   return false;
		} 
		return true;
	} 

	/** (4)
	*  This field is used to check if
	*  the given field text is a valid
	*  number 
	*/
	function isNumber(inputString,fieldString) {
	     flag = true;
		 //inputString=inputString.trim();
  		 for (i=0; i< inputString.length; i++) {	
   			if (isNaN(parseInt(inputString.charAt(i)))) { 
				 if(inputString.charAt(i)!=".") {
				  	 flag=false;
	    	  	 }
			}
	 	 }//end for
	   for (i=0; i< inputString.length; i++) {	
   			 if(inputString.charAt(i)==".") {
				flag=false;
	   	     } // end if 
		 }//end for
	   if(flag == false ) {
	    alert(fieldString);
	     return false;
	   }
	 return true;
	}
	
	/** (5)
	*  This field is used to check if
	*  the given field text is a valid
	*  number not float 
	*/
	function isCNumber(inputString,fieldString) {
	   // alert(inputString);
		flag = true;
		 //inputString=inputString.trim();
  		 for (i=0; i< inputString.length; i++) {	
   			if (isNaN(parseInt(inputString.charAt(i)))) { 
				 if(inputString.charAt(i)!=".") {
				  	 flag=false;
	    	  	 }
			}
	 	 }//end for
	  if(flag == false ) {
	    alert(fieldString);
	     return false;
	   }
	 return true;
   }
   
   /** (6)
	*  This method is used to checked 
	*  for the validity of the Email 
	*/
	function echeck(str) {
		emailStr = str.value;
		/* The following variable tells the rest of the function whether or not
		to verify that the address ends in a two-letter country or well-known
		TLD.  1 means check it, 0 means don't. */
		var checkTLD=1;
		/* The following is the list of known TLDs that an e-mail address must end with. */
		var knownDomsPat=/^(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum)$/;
		/* The following pattern is used to check if the entered e-mail address
		fits the user@domain format.  It also is used to separate the username
		from the domain. */
		var emailPat=/^(.+)@(.+)$/;
		/* The following string represents the pattern for matching all special
		characters.  We don't want to allow special characters in the address. 
		These characters include ( ) < > @ , ; : \ " . [ ] */
		var specialChars="\\(\\)><@,;:\\\\\\\"\\.\\[\\]";
		/* The following string represents the range of characters allowed in a 
		username or domainname.  It really states which chars aren't allowed.*/
		var validChars="\[^\\s" + specialChars + "\]";
		/* The following pattern applies if the "user" is a quoted string (in
		which case, there are no rules about which characters are allowed
		and which aren't; anything goes).  E.g. "jiminy cricket"@disney.com
		is a legal e-mail address. */
		var quotedUser="(\"[^\"]*\")";
		/* The following pattern applies for domains that are IP addresses,
		rather than symbolic names.  E.g. joe@[123.124.233.4] is a legal
		e-mail address. NOTE: The square brackets are required. */
		var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;
		/* The following string represents an atom (basically a series of non-special characters.) */
		var atom=validChars + '+';
		/* The following string represents one word in the typical username.
		For example, in john.doe@somewhere.com, john and doe are words.
		Basically, a word is either an atom or quoted string. */
		var word="(" + atom + "|" + quotedUser + ")";
		// The following pattern describes the structure of the user
		var userPat=new RegExp("^" + word + "(\\." + word + ")*$");
		/* The following pattern describes the structure of a normal symbolic
		domain, as opposed to ipDomainPat, shown above. */
		var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$");
		/* Finally, let's start trying to figure out if the supplied address is valid. */
		/* Begin with the coarse pattern to simply break up user@domain into
		different pieces that are easy to analyze. */
		var matchArray=emailStr.match(emailPat);
		if (matchArray==null) {
			/* Too many/few @'s or something; basically, this address doesn't
			even fit the general mould of a valid e-mail address. */
			//alert("Your email address is not correct ");
			//str.select();
			//str.focus();
			return false;
		}
		var user=matchArray[1];
		var domain=matchArray[2];
		// Start by checking that only basic ASCII characters are in the strings (0-127).
		for (i=0; i<user.length; i++) {
			if (user.charCodeAt(i)>127) {
				//alert("Ths username contains invalid characters.");
				//str.select();
				//str.focus();
				return false;
			}
		}
		for (i=0; i<domain.length; i++) {
			if (domain.charCodeAt(i)>127) {
				//alert("Ths domain name contains invalid characters.");
				//str.select();
				//str.focus();
				return false;
			}
		}
		// See if "user" is valid 
		if (user.match(userPat)==null) {
			// user is not valid
			//alert("The username doesn't seem to be valid.");
			//str.select();
			//str.focus();
			return false;
		}
		/* if the e-mail address is at an IP address (as opposed to a symbolic
		host name) make sure the IP address is valid. */
		var IPArray=domain.match(ipDomainPat);
		if (IPArray!=null) {
			// this is an IP address
			for (var i=1;i<=4;i++) {
				if (IPArray[i]>255) {
					//alert("Destination IP address is invalid!");
					//str.select();
					//str.focus();
					return false;
				}
			}
			return true;
		}
		// Domain is symbolic name.  Check if it's valid.
		var atomPat=new RegExp("^" + atom + "$");
		var domArr=domain.split(".");
		var len=domArr.length;
		for (i=0;i<len;i++) {
			if (domArr[i].search(atomPat)==-1) {
				//alert("The domain name does not seem to be valid.");
				//str.select();
				//str.focus();
				return false;
			}
		}
		/* domain name seems valid, but now make sure that it ends in a
		known top-level domain (like com, edu, gov) or a two-letter word,
		representing country (uk, nl), and that there's a hostname preceding 
		the domain or country. */
		if (checkTLD && domArr[domArr.length-1].length!=2 && 
		domArr[domArr.length-1].search(knownDomsPat)==-1) {
			//alert("The address must end in a well-known domain or two letter " + "country.");
			//str.select();
			//str.focus();
			return false;
		}
		// Make sure there's a host name preceding the domain.
		if (len<2) {
			//alert("This address is missing a hostname!");
			//str.select();
			//str.focus();
			return false;
		}
		// If we've gotten this far, everything's valid!
		return true;
	}
	
	/** (7)
	*  This method is used to check if 
	*  there is at least one check box 
	*  is checked in the page 
	*/ 
	function CheckBoxCheck(msg) {
		flag = true;
		for	(i=0;i<document.form1.elements.length; i++) {
			if (document.form1.elements[i].type=="checkbox") {
			   if (document.form1.elements[i].checked) {
				  flag = false;
			   }//end if
			}//end if outer
		}//end for
		if (flag) {
		    alert(msg);
			return false;
		} else {
			return true;
		}
	}//end deleteMe
	
	/** (8)
	*  This method is used to check if 
	*  there is at least one check box 
	*  is checked in the given portion 
	*/ 
	function portionCheckBoxCheck(name,msg) {
		bol = true;
		for	(i=0; i<document.form1.elements.length; i++) {
			if (document.form1.elements[i].type == "checkbox") {
				if(document.form1.elements[i].name==name){
			    	if (document.form1.elements[i].checked) {
				  	  bol = false;
			   		}//end if
				}//end if center
			}//end if outer
		}//end for
		if (bol) {
		    alert(msg);
			return false;
		} else {
			return true;
		}
	}//end deleteMe
	
	/** (9)
	*  This method is used to check or 
	*  uncheck all the check boxes in 
	*  the page against the check or 
	*  uncheck state of some particulat check box
	*/
	function checkUncheckAll(field) {
		if (field.checked) {
			for (i=0; i<document.form1.elements.length; i++) {
				if (document.form1.elements[i].type=="checkbox") {
					document.form1.elements[i].checked=true;
				}//end if outer
			}//end for
		} else {
			for (i=0; i<document.form1.elements.length; i++) {
				if (document.form1.elements[i].type=="checkbox") {
					document.form1.elements[i].checked=false;
				}//end if inner
			}//end for
		} // end of else
	}//end deleteMe

	/** (10)
	*  This method is used to check  
	*  if the given text in the field 
	*  is only alphabetic charcters or 
	*  space
	*/
	function alphabetCheck(fieldToCheck) {
		var box = fieldToCheck;//document.frm1.box;
		re=/^[a-zA-Z\ ]*$/;
		if(!re.exec(box.value)) {
			alert("Only alphabetic characters or space allowed!");
			box.select();
			box.focus();
			return false;
		}//end name if
	  return true;
	}
	
    /** (11)
	*  This function is used to check 
	*  for charcter validity at current 
	*  time and remove invalid charcter
	*  from string 
	*/
	function validTextMaker(textField) {
		/*var strPass = textField.value;
		var strLength = strPass.length;
		var lchar = textField.value.charAt((strLength) - 1);
		if (lchar.search(mikExp) != -1) {
			var tst = textField.value.substring(0, (strLength) - 1);
			textField.value = tst;
		}*/
	} 
	/** (12)
	*  This method is used to check 
	*  if all text in given field is
	*  valid
	*/
	function finalCheck(finalField) {
		/*if (finalField.value.search(mikExp) == -1) {
		return true;
		}	else {
		 alert("Following characters\n\r\n\r ^\&\*\`\~\=\|\'\" \n\r\n\rare not allowed!\n");
		  finalField.select();
		  finalField.focus();
		  return  false;
		}*/
		return true;
	}
	
	/** (13)
	*  This method is used to remove 
	*  leading and ending charcters .eg space
	*  from the given text field text 
	*/
	function removeLeadingAndTrailingChar (fieldToRemoveChar, removeChar) {
		var returnString = fieldToRemoveChar.value;
		if (removeChar.length)
		{
		  while(''+returnString.charAt(0)==removeChar)
			{
			  returnString=returnString.substring(1,returnString.length);
			}
			while(''+returnString.charAt(returnString.length-1)==removeChar)
		  {
			returnString=returnString.substring(0,returnString.length-1);
		  }
		}
		return returnString;
	}

	
	/** (14)
	*  This Function is used to restrict
	*  the user to give year input in a
	*  given range
	*/
	function yearCheck(yearField) {
		var year = yearField.value;
		myyear = parseInt(year);
		if (myyear<1947||myyear>2004) {
		   alert("Given year is not valid");
		   yearField.select();
		   yearField.focus();
		   return false;
		}
		return true;
	}
   ////////////////////////////////////////////////////////////////////////////////////
     function isEmpty(form,msg) {
	  if (form.value.length < 1) {
		  //alert(msg);
   		  //form.select();
		  //form.focus();
		  return false ; 
	  }
	  /*
	  if (form.value.search(mikExp) == -1) {
	  	return true;
	  }	else {
 alert("Following characters\n\r\n\r ^\&\*\`\~\=\|\'\" \n\r\n\rare not allowed!\n");
		  form.focus();
		  return  false;
     }*/
	 return true;
 }
 
  ////////////////////////////////////////////////////////////////////////////////////
     function isEmpty_UserName(form,msg) {
	  if (form.value.length < 1) {
		  alert(msg);
   		  form.select();
		  form.focus();
		  return false ; 
	  }
	  
	  if (form.value.search(mikExp) == -1) {
	  	return true;
	  }	else {
 alert("Username is not in an allowable format. Please retry.");
		  form.focus();
		  return  false;
     }
	 return true;
 }
 
 ////////////////////////////////////////////////////////////////////////////////////////
 /** (14)
	*  This Function is used to Compare 
	*  the values of two fields 
	*  for equalance
	*/
	function equalityCheck(firstField,secondField,msg) {
		if (firstField.value!=secondField.value) {
		   alert(msg);
		   secondField.select();
		   secondField.focus();
		   return false;
		}
		return true;
	}

   /*
       var field = form.email; // email field
	   var str = field.value; // email string
  	   var reg1 = /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)/; // not valid
  	   var reg2 = /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?)$/; // valid
  	   if (!(!reg1.test(str) && reg2.test(str)))
      		{ 
       			alert("\"" + str + "\" is an invalid e-mail!"); // this is also optional
       			form.email.focus();
	   			return false;
	  		}

   */
	
	function IsNotNumeric(strString)
   //  check for valid numeric strings	
   {
   var strValidChars = "0123456789.'!''@''#'$''%''&''*''+''-''";
   var strChar;
   var blnResult = true;

   if (strString.length == 0) return false;

   //  test strString consists of valid characters listed above
   for (i = 0; i < strString.length && blnResult == true; i++)
      {
      strChar = strString.charAt(i);
      if (strValidChars.indexOf(strChar) == -1)
         {
         blnResult = false;
         }
      }
   return blnResult;
   }
   
    function alphabetCheck(fieldToCheck) {
		var box = fieldToCheck;//document.frm1.box;
		re=/^[a-zA-Z\ ]*$/;
		if(!re.exec(box.value)) {
			alert("Your name is not correct");
			//box.select();
			box.focus();
			return false;
		}//end name if
	  return true;
	}
	
	//////----------------------------------------------------------------
	//function of Check is Number 0 to 9 or .  and change the color of row
	////----------------------------------------------------------------

	function isNumbercheck(inputString) {
	     flag = true;
		 //inputString=inputString.trim();
  		 for (i=0; i< inputString.length; i++) {	
   			if (isNaN(parseInt(inputString.charAt(i)))) { 
				 if(inputString.charAt(i)!=".") {
				  	 flag=false;   
	    	  	 }
			}
	 	 }//end for
	   for (i=0; i< inputString.length; i++) {	
   			 if(inputString.charAt(i)==".") {
				flag=false; 
	   	     } // end if 
		 }//end for
	   if(flag == false ) {
	
	  //  alert(fieldString);
	  
	     return false;
	   }
	 return true;
	}
///////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////
	function updatePasswordStrength(){
      var password = document.form1.pass.value;
	  var strength = 0;

          // easy_guesses: strings that should not be used in password
	  var easy_guesses = new Array();
          easy_guesses.push('password'); // does this need to be localized?
        //  easy_guesses.push('youtube');
          var email_words = document.form1.email.value.match(/\w+/g); // contiguous words contained in email
	  if (email_words)
		easy_guesses = easy_guesses.concat(email_words);
		//if (document.form1.username.value)
		//easy_guesses.push(document.form1.username.value);

	  locase_matches = password.match(/[a-z_]/g); // lowercase and '_' matches
	  digit_matches = password.match(/[0-9]/g);   // numeric matches
	  upcase_matches = password.match(/[A-Z]/g);  // uppercase matches
	  special_matches = password.match(/\W/g);    // special matches (not in a-z, A-Z, 0-9, _)

	  if (password.length>5)
	  { // for less than 5, leave strength at 0 since password too short

             // 1 point for each character more than 5
            strength += password.length - 5;

 	    // 1 point for each upcase character mixed with lowercase
	    if (locase_matches && upcase_matches)
	      strength += upcase_matches.length;

            // 1 point for each numeric character mixed with lowercase
	    if (locase_matches && digit_matches)
	      strength += digit_matches.length;

 	    // 1 point for each special characters
            if (special_matches)
	      strength += special_matches.length;

	   // 2 bonus points if mix of letters, numbers and special
           if ((locase_matches || upcase_matches) && special_matches && digit_matches)
             strength += 2;
          }

          // Reset strength to 0 if any easy guess in password (easy guess should be more than 3 chars)
          for (var i=0; i < easy_guesses.length; ++i)
	  {
           if (easy_guesses[i].length>3 && (password.indexOf(easy_guesses[i])!=-1))
           { 
             strength=0;
             break;
           }
          }

        //  var pstrength_elem = document.getElementById('password_strength');
          var pstrength_text = document.getElementById('password_strength_text');
          if (password.length==0)
          {	imgList="bar_grey_medium.gif";
          //  pstrength_elem.className = 'password_empty';             
            pstrength_text.innerHTML = 'None';
          }
	  else if (strength<3)
          {	 imgList="bar_red_medium.gif";
           // pstrength_elem.className = 'password_weak';
            pstrength_text.innerHTML = 'Weak';
          }
          else if (strength<7)
          {	imgList="bar_yellow_medium.gif";
            //pstrength_elem.className = 'password_fair';
            pstrength_text.innerHTML = 'Fair';
          }
          else if (strength<10)
          {	imgList="bar_blue_medium.gif";
         //   pstrength_elem.className = 'password_good';
            pstrength_text.innerHTML = 'Good';
          }
          else
          {	imgList="bar_green_medium.gif";
           // pstrength_elem.className = 'password_strong';
            pstrength_text.innerHTML = 'Strong';
          }
		  
		  
		  document.ImageFrame.src='images/'+imgList;
	
	}