﻿// JScript File
//Author : Prashanth.L
//Date : 05/12/2007

//Validating Combobox
function validateCombo(value)
{
	//var strValue = source.options.selectedIndex;
	var strValue = value.options[value.selectedIndex].text;
	var blnResult = true;
	if(strValue == "Please Select")
	{
		blnResult = false;
	}	
	return blnResult;
}

//Validating ComboboxCount
function validateComboCount(value)
{
	//var strValue = source.options.selectedIndex;
	var strValue = value.options[value.selectedIndex].value;
	var blnResult = true;
	if(strValue.value == 0)
	{
		blnResult = false;
	}	
	return blnResult;
}

//Validate txtbox
function isEmpty(strValue)
	{
		var blnResult = true;
		if (strValue == null || strValue == "")
			{
				blnResult = false;
			}
			//alert(blnResult);
		return blnResult;
	}

// Added By Prashanth on 13/08/2007

// Function to Validate the SSN Number.

function validateSSN(value)
{	
	var blnResult = true;
	var strValue = value.value;
	if (strValue.length < 11)
		{
			//alert("Value is Blank");
			blnResult = false;		
		}
	else if (strValue.charAt(0) == " ")
		{
			//alert("Does not contain space as the first char");
			blnResult = false;
		}
	else if (IsSSNValid(strValue))
		{
			//alert("SSN Check");
			blnResult = false;
		}	
	//alert(value.IsValid);
	return blnResult;
}

//  function to validate radio button
//  Not used

	function valButton(btn)
	 {
		var cnt = -1;
		for (var i=btn.length-1; i > -1; i--) 
		{
			if (btn[i].checked)
			     {cnt = i; i = -1;}
		}
			if (cnt > -1) return btn[cnt].value;
			else return null;
	}
    

// Function to validate the ZIP. for india
function validateZIP(value)
{	
	var blnResult = true;
	var strValue = value.value;
	if (strValue.length < 6)
	{
		//alert("Value is Blank");
		blnResult = false;		
	}
	else if (strValue.charAt(0) == " ")
	{
		//alert("Does not contain space as the first char");
		blnResult = false;
	}
	else if (!isNum(strValue))
	{
		//alert("Value Check");
		blnResult = false;
	}	
	//alert(value.IsValid);
	return blnResult;
}

function validateIndiaPhoneNo(value)
{	
	var blnResult = true;
	var strValue = value.value;
	if (strValue.length < 6)
	{
		//alert("Value is Blank");
		blnResult = false;		
	}
	else if (strValue.charAt(0) == " ")
	{
		//alert("Does not contain space as the first char");
		blnResult = false;
	}
	else if (!isNum(strValue))
	{
		//alert("Value Check");
		blnResult = false;
	}	
	//alert(value.IsValid);
	return blnResult;
}
 function maskPaste(objEvent) {
     var strPasteData = window.clipboardData.getData("Text");
     var objInput = objEvent.srcElement;
   
    // if (!isValid(strPasteData)) {
      // alert("Invalid data");
       objInput.focus();
       return false;
     //}
   }

// Function to validate the Mobile Number.
function validateMoblieNo(value)
{	
	var blnResult = true;
	var strValue = value.value;
	if (strValue.length < 10)
	{
		//alert("Phone No Check");
		blnResult = false;
	}
	else if (strValue.charAt(0) == " " && strValue.charAt(0) == ".")
	{
		//alert("Phone No Check z");
		blnResult = false;
	}
	else if (!IsMobileValid(strValue))
	{
		//alert("Phone No zzz");
		blnResult = false;
	}
	//value.IsValid = false;
	return blnResult;
}

// Function to validate the US Phone Number.
function validatePhoneNo(value)
{	
	var blnResult = true;
	//value.IsValid = true;
	var strValue = value.value;
	if (strValue.length < 11)
	{
		//alert("Phone No Check");
		blnResult = false;
	}
	else if (strValue.charAt(0) == " " && strValue.charAt(0) == ".")
	{
		//alert("Phone No Check z");
		blnResult = false;
	}
	else if (IsPhoneValid(strValue))
	{
		//alert("Phone No zzz");
		blnResult = false;
	}
	//value.IsValid = false;
	return blnResult;
}

//Function to Validate First Name and second Name.
function validateFirstName(value)
{
	var blnResult = true;
	var strValue = value.value;
	if (!isEmpty(strValue))
	{
		//alert("Name ");
		blnResult = false;
	}
	else if (strValue.charAt(0) == " ")
	{
		//alert("Name char");
		blnResult = false;
	}	
	else if (strValue != "")
	{
		for(i=0;i<strValue.length;i++)
		{
			var strChar = strValue.charAt(i)
			if (!((strChar >= "A" && strChar <= "Z" ) || (strChar >= "a" && strChar <= "z") || strChar==" "))
			{	
				//alert ("Only alphabets, space are allowed in " + Cont_Name + " (eg. quality).  Please re-enter correct data.")
				blnResult = false;
			}
		}
	}
	return blnResult;
}


//Function to validate Description.
function validateDescr(value)
{
	var blnResult = true;
	var strValue = value.value;
	if (strValue.charAt(0) == " ")
	{
		blnResult = false;
	}
	else if (strValue != "")
	{
		for(i=0;i<strValue.length;i++)
		{
			var strChar = strValue.charAt(i)
			if (!((strChar >= "A" && strChar <= "Z" ) || (strChar >= "a" && strChar <= "z") || strChar==" "||strChar=="#"||(strChar >= 0 && strChar <=9)) )
			{	
				//alert ("Only alphabets, space are allowed in " + Cont_Name + " (eg. quality).  Please re-enter correct data.")
				blnResult = false;
			}
		}
	}
	return blnResult;
}

//Function to Validate Code.
//eg 1234ABC, ABC1234
function validateCode(value)
{	
	var blnResult = true;
	var strValue = value.value;	
	/*if (strValue.charAt(0) == " ")
	{
		value.IsValid = false;		
	}
	else */if (!((strValue.charAt(0) >= "A" && strValue.charAt(0) <= "Z") || (strValue.charAt(0) >= "a" && strValue.charAt(0) <= "z") || (strValue.charAt(0) >= 0 && strValue.charAt(0) <=9)))
	{
		blnResult = false;
	}
	else if (strValue != "")
	{
		for (i=0;i<strValue.length;i++)
		{
			var strChar = strValue.charAt(i);
			//alert(strChar);
			if ((strChar == " ")|| !((strChar >= "A" && strChar <= "Z" ) || (strChar >= "a" && strChar <= "z") || (strChar >= 0 && strChar <=9)))
			{				
				blnResult = false;
			}
			/*if (i == strValue.length-1)
			{
				if (!(strChar >= 0 && strChar <= 9))
				{
					value.IsValid = false;
				}
			}*/
		}
	}
	return blnResult;
}

//Function to Validate Name. 
//eg. 123 ZIndia, India 1234.
// accepts only alphabetic characters
function validateName(value)
{
	var blnResult = true;
	var strValue = value.value;	
	
	if (strValue.charAt(0) == " ")
	{
		blnResult = false;		
	}
	//else if (!((strValue.charAt(0) >= "A" && strValue.charAt(0) <= "Z") || (strValue.charAt(0) >= "a" && strValue.charAt(0) <= "z") || (strValue.charAt(0) >= 0 && strValue.charAt(0) <=9)))
	else if (!((strValue.charAt(0) >= "A" && strValue.charAt(0) <= "Z") || (strValue.charAt(0) >= "a" && strValue.charAt(0) <= "z")))
	{
		blnResult = false;
	}
	else if (strValue != "")
	{
		for (i=0;i<strValue.length;i++)
		{
			var strChar = strValue.charAt(i);
			if (!((strChar >= "A" && strChar <= "Z" ) || (strChar >= "a" && strChar <= "z") || strChar==" "))
			{				
				blnResult = false;
			}			
		}
	}
	return blnResult;
}

//Function to validate Alpha Numeric
function validateAlphaNum(value)
{
	var blnResult = true;
	var strValue = value;
	if (strValue.charAt(0) == " ")
	{
		blnResult = false;
	}
	else if (!((strValue.charAt(0) >= "A" && strValue.charAt(0) <= "Z") || (strValue.charAt(0) >= "a" && strValue.charAt(0) <= "z") || (strValue.charAt(0) >= 0 && strValue.charAt(0) <=9)))
	{
		blnResult = false;
	}
	else if (strValue != "")
	{
		for (i=0;i<strValue.length;i++)
		{
			var strChar = strValue.charAt(i);
			if (!((strChar >= "A" && strChar <= "Z" ) || (strChar >= "a" && strChar <= "z") || (strChar >= 0 && strChar <=9) || (strChar == "'")))
			{					
				blnResult = false;
			}			
		}
	}
	
	  
	//alert(blnResult);
	return blnResult;
}

//Function to validate Alpha Numeric with no spaces

function validateAlphaNums(value)
{
	var blnResult = true;
	var strValue = value;
	if (strValue.charAt(0) == " ")
	{
		blnResult = false;
	}
	else if (!((strValue.charAt(0) >= "A" && strValue.charAt(0) <= "Z") || (strValue.charAt(0) >= "a" && strValue.charAt(0) <= "z") || (strValue.charAt(0) >= 0 && strValue.charAt(0) <=9)))
	{
		blnResult = false;
	}
	else if (strValue != "")
	{
		for (i=0;i<strValue.length;i++)
		{
			var strChar = strValue.charAt(i);
			if (!((strChar >= "A" && strChar <= "Z" ) || (strChar >= "a" && strChar <= "z") || (strChar >= 0 && strChar <=9) || (strChar == "'")))
			{					
				blnResult = false;
			}			
		}
	}
		 for (i=0;i<strValue.length;i++)
				  {
			        var strChar = strValue.charAt(i);
			            if ((strChar ==" "))
			            {	
			          //  alert(strChar);
			              blnResult = false;
			               break;
			            }	
			        }	
	         		
		   
	  
	//alert(blnResult);
	return blnResult;
}

 


//Function to validate PAN
function validatePAN(value)
{
	var blnResult = true;
	var strValue = value;
	if (strValue.charAt(0) == " ")
	{
		blnResult = false;
	}
	else if (!((strValue.charAt(0) >= "A" && strValue.charAt(0) <= "Z") || (strValue.charAt(0) >= "a" && strValue.charAt(0) <= "z") || (strValue.charAt(0) >= 0 && strValue.charAt(0) <=9)))
	{
		blnResult = false;
	}
	else if (strValue != "")
	{
		for (i=0;i<5;i++)
		{
			var strChar = strValue.charAt(i);
			if (!(strChar >= "A" && strChar <= "Z" ))
			{					
				blnResult = false;
			}			
		}
			for (i=5;i<9;i++)
		{
			var strChar = strValue.charAt(i);
			if (!(strChar >= "0" && strChar <="9"))
			{					
				blnResult = false;
			}			
		}
		
			var strChar = strValue.charAt(9);
			if (!(strChar >= "A" && strChar <= "Z" ))
			{					
				blnResult = false;
			}			
		
	}
	//alert(blnResult);
	return blnResult;
}


//added by asha to validate the html file control

function validateFile(value)
{
 var msg;
 msg = '';
 var flag = true;
	var ext = value.value;
	if (ext != "")
	{
	ext = ext.substring(ext.length-3,ext.length);
	ext = ext.toLowerCase();
	if(ext != 'jpg' && ext != 'gif' && ext != 'bmp' && ext!='swf')

   			{
				//msg += 'File not valid<br>';
				flag = false;
			}
  // document.getElementById('lblError').innerHTML=msg;
	return flag;
	}
}


function validateFile1(value)
{
 var msg;
 msg = '';
 var flag = true;
	var ext = value.value;
	if (ext != "")
	{
	ext = ext.substring(ext.length-3,ext.length);
	ext = ext.toLowerCase();
	if(ext != 'jpg' && ext != 'gif' && ext != 'bmp' ) 

   			{
				//msg += 'File not valid<br>';
				flag = false;
			}
  // document.getElementById('lblError').innerHTML=msg;
	return flag;
	}
}


function validateFilexls(value)
{
var msg;
var startpos;
msg = '';
 var flag = true;
	var ext = value.value;
	if (ext != "")
	{
	startpos = ext.lastIndexOf('\\');	
	
    ext = ext.substring(startpos+1);
	if(ext.toUpperCase() != 'PROJECTMASTER.XLS') 
   			{
				msg += 'File not valid<br>';
				flag = false;
			}
    
	return flag;
	}
}

function valid粐teMoney(value)
{
	var strReg = /^\$?([1-9]{1}[0-9]{0,2}(\,[0-9]{3})*(\.[0-9]{0,2})?|[1-9]{1}[0-9]{0,}(\.[0-9]{0,2})?|0(\.[0-9]{0,2})?|(\.[0-9]{1,2})?)$/;
	var priceValue = value.value; 
	var intbefore = value.value;
	var intafter = value.value;
	var blnResult = true;
	var blnValid = true;
	var blnfound = false;
	var msg = '';

	
	blnResult = strReg.test(priceValue);
	
	if (!blnResult)
	{
		msg='Invalid cost';
	}
	else if (priceValue != "")
	{
		for (i=0;i<priceValue.length;i++)
		{
			var strChar = priceValue.charAt(i);
			if (strChar==".")
			{
				blnfound = true;
				//alert(priceValue.indexOf('.')+1);
				intafter=priceValue.substring(priceValue.indexOf('.')+1,priceValue.length);
				intbefore=priceValue.substring(0, priceValue.indexOf('.'));
			
				if ((intafter.length > 2))
				{
					msg += "Enter two digits after decimal";
					blnValid = false;
				}
				if (intbefore.length > 20)
				{
					msg += "Bill Amount Length before decimal point should not exceed 20 digits";
					blnValid = false;
				}
				if (intbefore.length < 2)
				{
					msg += "Bill Amount Length before decimal point should not be less than 2 digits";
					blnValid = false;
				}
			}			
		}
		if (blnfound == false)
		{
			if (priceValue.length > 10)
				msg += "Cost cannot exceed 10 digits";
		}

	}
	return msg;
	
}
////////////////////////////////////===============================///////////////////////////////////////
// Function to validate Email

	function emailCheck (emailStr) 
{
var checkTLD=1;
var knownDomsPat=/^(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum)$/;
var emailPat=/^(.+)@(.+)$/;
var specialChars="\\(\\)><@,;:\\\\\\\"\\.\\[\\]";
var validChars="\[^\\s" + specialChars + "\]";
var quotedUser="(\"[^\"]*\")";
var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;
var atom=validChars + '+';
var word="(" + atom + "|" + quotedUser + ")";
var userPat=new RegExp("^" + word + "(\\." + word + ")*$");
var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$");
var matchArray=emailStr.match(emailPat);
if (matchArray==null)
	{
		return false; 
	} 
var user=matchArray[1]; 
var domain=matchArray[2];
for (i=0; i<user.length; i++) 
{
	if (user.charCodeAt(i)>127) 
	{
	return false;
   }
}
for (i=0; i<domain.length; i++) 
{
	if (domain.charCodeAt(i)>127) 
		{
		return false;	
		}
}
if (user.match(userPat)==null) 
{
	return false; 
}
var IPArray=domain.match(ipDomainPat);
if (IPArray!=null) 
{
for (var i=1;i<=4;i++) 
{
	if (IPArray[i]>255) 
	{
		return false;
   }
}
return true;
}
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) 
	{ 
	return false;
 }
}
if (checkTLD && domArr[domArr.length-1].length!=2 && domArr[domArr.length-1].search(knownDomsPat)==-1) 
{ 
	return false; 
}
if (len<2)
{
return false;
}
	return true;
}

////////////////////////////////////======================//////////////////////////////////////////////////////

function validateDimension(value)
{
//	var char= "0123456789.,"; 
	var strReg = /^\$?([1-9]{1}[0-9]{0,2}(\,[0-9]{3})*(\.[0-9]{0,2})?|[1-9]{1}[0-9]{0,}(\.[0-9]{0,2})?|0(\.[0-9]{0,2})?|(\.[0-9]{1,2})?)$/;
	var priceValue = value.value; 
	var blnResult = true;
	//alert(value.value);
	//alert('dd');
	blnResult = strReg.test(priceValue);
	//alert(blnResult);
	if (!blnResult)
	{
	return blnResult;
	}
	return blnResult;
	
}

//Function to Validate Numbers only.
function validateNumber(value)
{
	var Cont_Value = value.value;
	//var Cont_Name =source; 
	var blnResult = true;
	if((Cont_Value.charAt(0)=="+") || (Cont_Value.charAt(0)=="-"))
	{
		blnResult = false;
	}
	else if(!isNum(Cont_Value))
	{
		blnResult = false;
	} 
	return blnResult;
}

 // Added By Prashanth
//Function to Validate Indian Phone Numbers only.
function validateIndNumber(value)
{
	var Cont_Value = value.value;
	//var Cont_Name =source; 
	var blnResult = true;
	if((Cont_Value.charAt(0)=="+") || (Cont_Value.charAt(0)=="-"))
	{
		blnResult = false;
	}
	else if(!isNumHyp(Cont_Value))
	{
		blnResult = false;
	} 
	return blnResult;
}

function valida粐eEmail(value)
{	
	var strValue = value.value;	
	var blnResult = true;
/*	if (!((strValue.charAt(0) >= "A" && strValue.charAt(0) <= "Z") || (strValue.charAt(0) >= "a" && strValue.charAt(0) <= "z") || (strValue.charAt(0) >= 0 && strValue.charAt(0) <=9)))
	{
		blnResult = false;
	}
	else */
	if (IsEmail(strValue))
	{
		blnResult = false;
	}
	/*if (strValue.charAt(0) == " ")
	{
		blnResult = false;	
	}*/

	return blnResult;
}



function validateCombobox(value)
{
	//var strValue = source.options.selectedIndex;
	var strValue = value.options[value.selectedIndex].text;
	var blnResult = true;
	if(strValue.toUpperCase() == "SELECT")
	{
		blnResult = false;
	}	
	return blnResult;
}
function validateComboText(value)
{
	//var strValue = source.options.selectedIndex;
	var strValue = value.options[value.selectedIndex].text;
	var blnResult = true;
	if(strValue.toUpperCase() != "SELECT")
	{
		blnResult = false;
	}	
	return blnResult;
}
//
function IsNumeric(value)
{
   var strValidChars = '0123456789.';
   var strChar;
   var blnResult = true;
   var strString = value.value;
	
   if (strString.length == 0) 
		blnResult = false;
   for (i = 0; i < strString.length && blnResult == true; i++)
	{
		strChar = strString.charAt(i);
		if (strValidChars.indexOf(strChar) == -1)
			{
				blnResult = false;
				//blnResult = false;
			}
	}
   return blnResult;
}
//
function IsNumericForPhone(value)
{
   var strValidChars = '0123456789';
   var strChar;
   var blnResult = true;
   var strString = value.value;
	
   if (strString.length == 0) 
		blnResult = false;
   for (i = 0; i < strString.length && blnResult == true; i++)
	{
		strChar = strString.charAt(i);
		if (strValidChars.indexOf(strChar) == -1)
			{
				blnResult = false;
			}
	}
   return blnResult;
}
// Numeric for Indian Phone Numbers

function IsNumericForIndPhone(value)
{
   var strValidChars = '0123456789-';
   var strChar;
   var blnResult = true;
   var strString = value.value;
	
   if (strString.length == 0) 
		blnResult = false;
   for (i = 0; i < strString.length && blnResult == true; i++)
	{
		strChar = strString.charAt(i);
		if (strValidChars.indexOf(strChar) == -1)
			{
				blnResult = false;
			}
	}
   return blnResult;
}
//
// to validate space between the characters in the string
function IsSpaceInString(value)
{
   var strValidChars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890';
   var strChar;
   var blnResult = true;
   var strString = value;
   	
   if (strString.length == 0) 
		blnResult = false;
   for (i = 0; i < strString.length && blnResult == true; i++)
	{
		strChar = strString.charAt(i);     
		if (strValidChars.indexOf(strChar) == -1)
			{
				blnResult = false;
				return blnResult;
			}
	}
   return blnResult;
}

// validate model field 
function ValidateModel(value)
{
   var strValidChars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890-#';
   var strChar;
   var blnResult = true;
   var strString = value;
   	
   if (strString.length == 0) 
		blnResult = false;
   for (i = 0; i < strString.length && blnResult == true; i++)
	{
		strChar = strString.charAt(i);     
		if (strValidChars.indexOf(strChar) == -1)
			{
				blnResult = false;
				return blnResult;
			}
	}
   return blnResult;
}

//function validateCostLength(value)

function validateLength1(value)
	{
		//alert('ghh');
		var strValue = value.value;
		var blnResult = true;
		if (strValue.length > 100)
			{
				
				blnResult = false;
			}
		return blnResult;
	}
//ValidateLengths greater than 250
function validateLength2(value)
	{
		//alert('ghh');
		var strValue = value.value;
		var blnResult = true;
		if (strValue.length > 250)
			{
				
				blnResult = false;
			}
		return blnResult;
	}
//ValidateLengths greater than 300
function validateLength3(value)
	{
		//alert('ghh');
		var strValue = value.value;
		var blnResult = true;
		if (strValue.length > 300)
			{
				
				blnResult = false;
			}
		return blnResult;
	}

function validateNewsLength(value)
	{
		//alert('ghh');
		var strValue = value.value;
		var blnResult = true;
		if (strValue.length > 500)
			{
				blnResult = false;
			}
		return blnResult;
	}

function validateAlertDesc(value)
	{
		//alert('ghh');
		var strValue = value.value;
		var blnResult = true;
		if (strValue.length > 2000)
			{
				
				blnResult = false;
			}
		return blnResult;
	}

function validateLength(value)
	{
		var strValue = value.value;
	 	var blnResult = true;
		if (strValue.length > 250)
			{
				blnResult = false;
			}
		return blnResult;
	}

function validateLendesc(value)
	{
		var strValue = value.value;
		var blnResult = true;
		if (strValue.length > 200)
			{
				
				blnResult = false;
			}
		return blnResult;
	}
//Compare two Values of the control
function CompareValidator(value,value1)
	{
		var strValue = value.value;
		var strValue1 = value1.value;
		var blnResult = true;
		if (!(strValue== strValue1))
			{
				blnResult = false;
			}
		return blnResult;
	}

function ValidateMeasurement(value)
	{
	var blnResult = true;
	var strValue = value.value;	
	if (IsMeasureMent(strValue))
		{
			blnResult = false;
		}
		
		return blnResult;
	}

/*******************End of Functions to be used along with Custom Validator(DotNetComponents.WebValidator)*******************/




/******************** These are Internal Function used by the functions above.*******************************
*********************    Not to be used with Custom Validator(DotNetComponents.WebValidator)   *******************************/

//Function to validate Number using Regualar Expressions.
function isNum(val)
	{
		var re=/[^0-9]/;
		return !re.test(val);
	}
	
//Function to validate Number with hyphen using Regualar Expressions.
function isNumHyp(val)
	{
		//var re=/[^0-9]/;
		var re=/^\[0-9]{2,3}-? ?[0-9]{6,7}$/;
		alert(re.test(val))
		return !re.test(val);
	}



//Function to valid First Name, Second Name etc, using Regular Expression.
function IsNameValid(strValue)
	{
		//var strExpr = (?<FirstName>[A-Z]\.?\w*\-?[A-Z]?\w*)\s?(?<MiddleName>[A-Z]\w+|[A-Z]?\.?)\s(?<LastName>[A-Z]?\w{0,3}[A-Z]\w+\-?[A-Z]?\w*)(?:,\s|)(?<Suffix>Jr\.|Sr\.|IV|III|II|);
		//var blnResult = strExpr.test(strValue);
		//alert(blnResult);
		//return !blnResult;
	}

//Function to validate US Phone Number based on Regular Expressions.
function IsPhoneValid(strValue)
	{
		var strExp = /^0{0,1}[1-9]{1}[0-9]{2}[\s]{0,1}[\-]{0,1}[\s]{0,1}[1-9]{1}[0-9]{6}$/;
		var bnlResult = strExp.test(strValue);
		//alert(bnlResult);
		return !bnlResult;
	}


//Function to validate US Phone Number based on Regular Expressions.
function IsZipValid(strValue)
	{
		var strExp = /^\d{3}\s?\d{3}$/;
		var bnlResult = strExp.test(strValue);
		//alert(bnlResult);
		return !bnlResult;
	}

//Function to validate Mobile Number based on Regular Expressions.
function IsMobileValid(strValue)
	{
		var strExp = /^((\+){0,1}91(\s){0,1}(\-){0,1}(\s){0,1}){0,1}98(\s){0,1}(\-){0,1}(\s){0,1}[1-9]{1}[0-9]{7}$/;
		var bnlResult = strExp.test(strValue);
		//alert(bnlResult);
		return !bnlResult;
	}

// Function to check for if the string is empty.
function isEmpty(strValue)
	{
		var blnResult = true;
		if (strValue == null || strValue == "")
			{
				blnResult = false;
			}
			//alert(blnResult);
		return blnResult;
	}

//Function to Validate SSN Number using Regular Expressions.
function IsSSNValid(strValue)
	{
		var strExp = /^(?!000)([0-6]\d{2}|7([0-6]\d|7[012]))([-])?(?!00)\d\d\3(?!0000)\d{4}$/;
		var blnResult = strExp.test(strValue);
		//alert(blnResult);
		return !blnResult;
	}
/* Implemeneted By : M. Kalyana chakravarthi
			   Purpose : The Below function is used to scrolls up the page when ever there is validation
			   Created Date: 17 Aug 2004
			   Function name: scroller
			*/
var position = 320;	//Position set fo 320		
function scroller() 
	{		//Function header
		if (position != 0)
		{	//Till the top	
				position-=20;	//reduce it by 20 pxls
				scroll(0,position);	//Scroll 
				clearTimeout(timer);// 
				var timer = setTimeout("scroller()",3); // Set time for each iteration
				timer;
			}
		else
			{
				location.replace("#");// same page
				position = 320;	//Position set fo 320		
			}
	}

/*
function scrolldown(position) {		//Function header
		scroll(0,0);	//Scroll 
		scroll(0,position);	//Scroll 
	}*/
//Function to Check for Email usinf Regular Expression.
function IsEmail(strValue)
	{
		var strExp =/^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/;
		//va粐 strExp = /(\w[-._\w]*\w@\w[-._\w]*\w\.\w{2,3})/;
		//var strExp = /(^[a-z]([a-z_\.]*)@([a-z_\.]*)([.][a-z]{3})$)|(^[a-z]([a-z_\.]*)@([a-z_\.]*)(\.[a-z]{3})(\.[a-z]{2})*$)/i;
		var blnExp = strExp.test(strValue);
		//alert(blnExp);
		return !blnExp;
	}

function IsMeasureMent(strValue)
	{
		var strExp =/^((\d+(\.\d*)?)|((\d*\.)?\d+))$/; 
		var blnExp = strExp.test(strValue);
		return !blnExp;
	}


// validate Email

//function to validate an Email
function chkEmail(txtElement,fieldName,allowEmpty)
{
	var exclude=/[^@\-\.\w\_]|^[_@\.\-]|[\._\-]{2}|[@\.]{2}|(@)[^@]*\1/;
	var check=/@[\w\-]+\./;
	var checkend=/\.[a-zA-Z]{2,3}$/;
	var strEmail = txtElement.value
	var email_array=strEmail.split(",");

	if(allowEmpty == false && txtElement.value.length == 0 || txtElement.value == "Email")
		{
			alert("Please enter '" + fieldName + "'");
			txtElement.focus()
			return false;
		}

	if(allowEmpty == true && txtElement.value.length == 0)
		{
			//empty value is allowed
			return true;
		}
	else 
	{
		var email_num=0;
		var checkEmail;
		while (email_num < email_array.length)
		{ 
			var trimemail = trim(email_array[email_num]);
			if(((trimemail.search(exclude) != -1) || 
			(trimemail.search(check)) == -1)   ||	
			(trimemail.search(checkend) == -1))
				{
					checkEmail = "false";
				}
			else
				{
					checkEmail = "true";
				}
			email_num++;

			if(checkEmail == "false")
				{
					alert("Incorrect Email Address!");
					txtElement.focus()
					return false;
				}
		}
	}
	return true;
}
//Function to validate Phone number
function IsfnToCheckPhoneNumber(aStr)
{
			 var a="1234567890";
			 var msg;
			 msg = '';
			 var index;
			 var count = 0;
			 var value=0;
			 var dotCount = 0;
			 var flag = true;
			 var number = "";
			 var countString ="";
			 var blnResult = true;
			for(index=0; index<aStr.length; index++)
			{
				number = number + aStr.charAt(index);
				//Cost of type 0.000...0000000000000
				if(aStr.charAt(index)=="-")
				{
					dotCount=dotCount+1;
					
				} //End of if

			}
			//Checking appearance of more than one dot or -
			if (dotCount>=3)
			{
				blnResult = false;
			}
	return blnResult;
}

//Function to validate morethan one decimal
function IsfnToCheckTwoDecimalPoints(aStr)
{
			 var a="123456789.0";
			 var msg;
			 msg = '';
			 var index;
			 var count = 0;
			 var value=0;
			 var dotCount = 0;
			 var flag = true;
			 var number = "";
			 var countString ="";
			 var blnResult = true;
			for(index=0; index<aStr.length; index++)
			{
				number = number + aStr.charAt(index);
				//Cost of type 0.000...0000000000000
				if(aStr.charAt(index)=="." || aStr.charAt(index)=="-")
				{
					dotCount=dotCount+1;
					
				} //End of if

			}
			//Checking appearance of more than one dot or -
			if (dotCount>=2)
			{
				blnResult = false;
			}
	return blnResult;
}
/*
//Function Validate Phone number with more than one -.

function IsfnToCheckMorethan3SubSymbol(aStr)
{
			 var a="123456789-0";
			 var msg;
			 msg = '';
			 var index;
			 var count = 0;
			 var value=0;
			 var dotCount = 0;
			 var flag = true;
			 var number = "";
			 var countString ="";
			 var blnResult = true;
			for(index=0; index<aStr.length; index++)
			{
				number = number + aStr.charAt(index);
				//Cost of type 0.000...0000000000000
				if(aStr.charAt(index)=="-")
				{
					dotCount=dotCount+1;
					
				} //End of if

			}
			//Checking appearance of more than one dot or -
			if (dotCount > = 3)
			{
				blnResult = false;
			}
	return blnResult;
}
*/
function isValidEmail(email, required) {
	
    if (required==undefined) {   // if not specified, assume it's required
        required=true;
    }
    if (email==null) {
        if (required) {
            return false;
        }
        return true;
    }
    if (email.length==0) {  
        if (required) {
            return false;
        }
        return true;
    }
	if(!checkf粐rlimit(email)){
		return false;
	}
    if (! allValidChars(email)) {  // check to make sure all characters are valid
        return false;
    }
    if (email.indexOf("@") < 1) { //  must contain @, and it must not be the first character
    	return false;
    } else if (email.lastIndexOf(".") <= email.indexOf("@")) {  // last dot must be after the @
     	return false;
    } else if (email.indexOf("@") == email.length) {  // @ must not be the last character
     	return false;
    } else if (email.indexOf("..") >=0) { // two periods in a row is not valid
       	return false;
    } else if (email.indexOf(".") == email.length) {  // . must not be the last character
       	return false;
    }
    return true;
    }

    //Checks for Valid Characters in Email-Id field
    function allValidChars(email) {
       var parsed = true;
       var cnt=0;
       var validchars = "abcdefghijklmnopqrstuvwxyz0123456789@._";
       for (var i=0; i < email.length; i++) {
       c = email.charCodeAt(i);
       if(c==64){
       cnt=cnt+1;
       }
       var letter = email.charAt(i).toLowerCase();
       if (validchars.indexOf(letter) != -1)
       	continue;
       	parsed = false;
       	break;
       }
       if(cnt>1){
       	parsed = false;
       }
       return parsed;
    }

    //Checks for Email-Id limitations
    function checkforlimit(email){
	   d = email.charCodeAt(0);
	   if((d>=97 && d<=122) || (d>=65 && d<=90)) {
       var count=0;
       var s=email.indexOf("@")+1;
       var partAfterAt=email.substring(s,email.length);
       var start=partAfterAt.indexOf(".")+1;
       if(partAfterAt.charAt(start+1)=="")
       	return false;
       var partAfterDot=partAfterAt.substring(start,partAfterAt.length);
       len=partAfterDot.length;
       for(i=0;i<len;i++){
       	var let=partAfterDot.charAt(i);
       	if(let=='.'){
       		count++;
       	}
       }
       if(count==0){
       	if(partAfterDot.length!=3)
       	return false;
       }
       if(count>1){
		return false;
	   }else{
		if(partAfterDot.indexOf(".") != -1){
			var start1=partAfterDot.indexOf(".")+1;
			var ss=partAfterDot.substring(0,start1-1);
			if(ss.length>2)
				return false;
			var partAfterSecondDot=partAfterDot.substring(start1,partAfterDot.length);
			if(partAfterSecondDot.length != 2){
				return false;
			}
		}
		}
	}else{
	return false;
	}
	return true;
	}
	//Date Validation function
function comparedates(value1,value2)
{
		var date1, date2;
		var month1, month2;
		var year1, year2;

		month1 = value1.substring (0, value1.indexOf ("/"));
		date1 = value1.substring (value1.indexOf ("/")+1, value1.lastIndexOf ("/"));
		year1 = value1.substring (value1.lastIndexOf ("/")+1, value1.length);
		
		month2 = value2.substring (0, value2.indexOf ("/"));
		date2 = value2.substring (value2.indexOf ("/")+1, value2.lastIndexOf ("/"));
		year2 = value2.substring (value2.lastIndexOf ("/")+1, value2.length);
					
		if (year1 > year2) return 1;
		else if (year1 < year2) return -1;
		else if (month1 > month2) return 1;
		else if (month1 < month2) return -1;
		else if (date1 > date2) return 1;	//Date1 is > Date2
		else if (date1 < date2) return -1;	//Date1 is < Date2
		else return 0;						//both the dates are same
}


function setMultiLineLength(objEvent, strControl, strLength)
	{
		var  s;
		
		s=document.getElementById(strControl).value;
		//alert(s);
		
		if (s.length > strLength)
			{
				return false;
			}
		else
			{
			return true;
			}
	}
function maskIntegerNumeric(objEvent)
{

var reValidChars = /\d/;
var javawsInstalled = 0; var javaws12Installed = 0; 
var javaws142Installed=0; isIE = "false"; if (navigator.mimeTypes && navigator.mimeTypes.length) 
{    x = navigator.mimeTypes['application/x-java-jnlp-file'];    
	if (x) { 
			  javawsInstalled = 1; 
			  javaws12Installed=1;       
			  javaws142Installed=1;    
			  } 
			} else {    isIE = "true"; } 
      
                    var iKeyCode, strKey;  
                   
                    if (isIE) {
                        iKeyCode = objEvent.keyCode;
                    } else {
                        iKeyCode = objEvent.which;
                    }
                    
                    strKey = String.fromCharCode(iKeyCode);
          
                    if (!reValidChars.test(strKey)) {
                                                                                //you can comment out this alert box if you like;
                        // alert("Invalid Character Detected!\nKeyCode = " + iKeyCode + "\nCharacter =" + strKey);
                         return false;
                    }
                    else
                    {
                     return true;
                    }
                   
               }
               
               
               
               
               
               
               
               
               
               
               
               
function validateSpecialChar(value)
{
var blnResult = true;
	var strValue = value;
	if (strValue.charAt(0) == " ")
	{
		blnResult = false;
	}
	else if (!((strValue.charAt(0) >= "A" && strValue.charAt(0) <= "Z") || (strValue.charAt(0) >= "a" && strValue.charAt(0) <= "z") || (strValue.charAt(0) >= 0 && strValue.charAt(0) <=9)))
	{
		blnResult= false;
	}
	else if (strValue != "")
	{
		for (i=0;i<strValue.length;i++)
		{
			var strChar = strValue.charAt(i);
			
			if (!((AllowSpecialChar(strChar)) ||  (strChar >= "A" && strChar <= "Z" ) || (strChar >= "a" && strChar <= "z") || (strChar >= 0 && strChar <=9)))
			{					
				blnResult = false;
			}			
		}
	}
		 return blnResult; 
}

function checkMailId(mailids)
{
var arr = new Array('.com','.net','.org','.biz','.coop','.info','.museum','.name','.pro','.edu','.gov','.int','.mil','.ac','.ad','.ae','.af','.ag','.ai','.al','.am','.an','.ao','.aq','.ar','.as','.at','.au','.aw','.az','.ba','.bb','.bd','.be','.bf','.bg','.bh','.bi','.bj','.bm','.bn','.bo','.br','.bs','.bt','.bv','.bw','.by','.bz','.ca','.cc','.cd','.cf','.cg','.ch','.ci','.ck','.cl','.cm','.cn','.co','.cr','.cu','.cv','.cx','.cy','.cz','.de','.dj','.dk','.dm','.do','.dz','.ec','.ee','.eg','.eh','.er','.es','.et','.fi','.fj','.fk','.fm','.fo','.fr','.ga','.gd','.ge','.gf','.gg','.gh','.gi','.gl','.gm','.gn','.gp','.gq','.gr','.gs','.gt','.gu','.gv','.gy','.hk','.hm','.hn','.hr','.ht','.hu','.id','.ie','.il','.im','.in','.io','.iq','.ir','.is','.it','.je','.jm','.jo','.jp','.ke','.kg','.kh','.ki','.km','.kn','.kp','.kr','.kw','.ky','.kz','.la','.lb','.lc','.li','.lk','.lr','.ls','.lt','.lu','.lv','.ly','.ma','.mc','.md','.mg','.mh','.mk','.ml','.mm','.mn','.mo','.mp','.mq','.mr','.ms','.mt','.mu','.mv','.mw','.mx','.my','.mz','.na','.nc','.ne','.nf','.ng','.ni','.nl','.no','.np','.nr','.nu','.nz','.om','.pa','.pe','.pf','.pg','.ph','.pk','.pl','.pm','.pn','.pr','.ps','.pt','.pw','.py','.qa','.re','.ro','.rw','.ru','.sa','.sb','.sc','.sd','.se','.sg','.sh','.si','.sj','.sk','.sl','.sm','.sn','.so','.sr','.st','.sv','.sy','.sz','.tc','.td','.tf','.tg','.th','.tj','.tk','.tm','.tn','.to','.tp','.tr','.tt','.tv','.tw','.tz','.ua','.ug','.uk','.um','.us','.uy','.uz','.va','.vc','.ve','.vg','.vi','.vn','.vu','.ws','.wf','.ye','.yt','.yu','.za','.zm','.zw');
var sd = mailids;
var val = true;
if (emailCheck(mailids))
	{
		var ids = sd.split("@");
		if (validateSpecialChar(ids[0])==false)
			{
				return false;
			}
		else
			{
				
				
				
				var mai = sd;
				var dot = mai.lastIndexOf(".");
				var ext = mai.substring(dot,mai.length);
					
				var m = mai.substring(0, dot);
				//alert(m);
				var n =m.split("@");
				//alert(n[1]);
				if (validateSpecialChar(n[1])==false)
					{
						return false;
					}
			else
				{
				//alert(mai);
				//alert(dot);
				//alert(ext);
	
				var at = mai.indexOf("@");

				if(dot > 5 && at >1)
					{
						for(var i=0; i<arr.length; i++)
							{
								if(ext == arr[i])
								{
								val = true;
								break;
								}
								else
								{
								val = false;
								}
							}
						if(val == false)
							{
								//alert("Your maild "+mai+" is not corrrrect");
								return false;
							}
					}
				else
					{
					//alert("Your maild "+mai+" is not correct");
					return false;
					}
				}

			}
			return true;
	}

else
	{
		return false;
	}
}

function AllowSpecialChar(value)
{
if ((value==".") || (value=="_") || (value=="-"))
{
return true;
}
else
{
return false;
}
}
// Added by Prashanth on 21/11/08 to Mask Numeric Values 
     function validateNumKey (objEvent)
        {
         var inputKey =  objEvent.keyCode;
         var returnCode = true; 
         
         if ( inputKey > 46 && inputKey < 58  || inputKey > 35 && inputKey < 41 || inputKey > 95 && inputKey < 106 || (inputKey == 8 ) || (inputKey ==46 ) || (inputKey ==45 ) ) // numbers
         {
          returnCode=true;
         } 
         else
         {
          returnCode = false;
         // objEvent.keyCode = 0;
         }
         objEvent.returnValue = returnCode;
        }
   
