/************************************************************************************************************
Name			: Reshma
Created Date	: 03-01-2006
File Name		: Validatior.js
Purpose			: This JS File is used for Client Side Validation of the TextBoxes.
************************************************************************************************************/


/*******************These are Functions to be used along with Custom Validator(DotNetComponents.WebValidator)****************/
function AllowSpecialChar(value)
{
if ((value==".") || (value=="_") || (value=="-"))
{
return true;
}
else
{
return false;
}
}
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 setMultiLineLength(objEvent, strControl, strLength)
	{
	var  s;
	
	s=document.getElementById(strControl).value;
	
	if (s.length > strLength)
		{
		
		 return false;
		 
		}
	else
		{
		return true;
		}
	}
	
  function maskPhoneNumeric(objEvent, strControl)
       {
       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
                    {
                    
                   var s=document.getElementById(strControl).value;
                  
                   if (s.length==3 || s.length==7)
                   {
                  
                   document.getElementById(strControl).value=s+'-';
                   } 
                    }
                   
       }
       
 function formatPhoneNumber(value, strControl)
		{
		
	var s=value;
	
	//	var s=document.getElementById("txtSponsorCPhone").value;
	if (s!='')
	{
		//alert(s);
	if ((s.substring(3,4)!='-') && (s.substring(7,8)!='-'))
	{
		
		var a;
		a=	s.substring(0,3) + '-' + s.substring(3,6) + '-' + s.substring(6,11)
		//alert(a)
		document.getElementById(strControl).value=a;

	}
	}	
		}    		
		
		
//-----------------------------------------------------------------

function maskCheckZip(objEvent, strControl)
       {
       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
                    {
                    
                   var s=document.getElementById(strControl).value;
                  
                   if (s.length==5)
                   {
                  
                   document.getElementById(strControl).value=s+'-';
                   } 
                    }
                   
       }
       
 		
		
//-----------------------------------------------------------------
		
		
		
		
		
		
		
		
		
		
function RoundOffReal(input) {
  
    if (input.indexOf (".") == -1) input += ".00";
    else input += "00";
 
    var pattern = /\d*.\d\d/;
    var result = pattern.exec (input);
    if (result != null) 
    return result[0];
}
function maskRealNumeric(objEvent) {
var reValidChars = /\d/;
var reValidChars1 = /\./;


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) && !reValidChars1.test(strKey)) {
                                                                                //you can comment out this alert box if you like;
                        // alert("Invalid Character Detected!\nKeyCode = " + iKeyCode + "\nCharacter =" + strKey);
                         return false;
                    }
  
               }
               
               function maskNames(objEvent) {
var reValidChars = /\b[A-Za-z]/;



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;
                    }
                  //  alrt(strKey);
                   
                    strKey = String.fromCharCode(iKeyCode);
         //  strKey=strKey.Remove(' ');
                    if (!reValidChars.test(strKey)) {
                    if (strKey !=' ' )
                    {
                                                                                //you can comment out this alert box if you like;
                        // alert("Invalid Character Detected!\nKeyCode = " + iKeyCode + "\nCharacter =" + strKey);
                         return false;
                     }
                    }
               }
               
               
               
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 LTrim(VALUE){
var w_space = String.fromCharCode(32);
if(v_length < 1){
return"";
}
var v_length = VALUE.length;
var strTemp = "";

var iTemp = 0;

while(iTemp < v_length){
if(VALUE.charAt(iTemp) == w_space){
}
else{
strTemp = VALUE.substring(iTemp,v_length);
break;
}
iTemp = iTemp + 1;
} //End While
return strTemp;
} //End Function


function RTrim(VALUE)
{
//alert(VALUE);
var w_space = String.fromCharCode(32);
var v_length = VALUE.length;
var strTemp = "";
if(v_length < 0)
	{
	return"";
	}
var iTemp = v_length -1;
while(iTemp > -1)
	{
	if(VALUE.charAt(iTemp) == w_space)
		{
		}
	else
		{
		strTemp = VALUE.substring(0,iTemp +1);
		break;
		}
	iTemp = iTemp-1;

	} //End While
return strTemp;

} //End Function



function validateCurrency(strValue)
{
  var objRegExp  = /^\d+(\.\d\d)?$/;
   return objRegExp.test(strValue);
}

function validateRealNumber(strValue)
{
  var objRegExp  = /^\d+(\.\d\d)?$/;
  if (objRegExp.test(strValue))
  {
  return objRegExp.test(strValue);
  }
  else
  {
   var objRegExp  = /^\d+(\.\d)?$/;
   return objRegExp.test(strValue);
    }
}



function validateUSPhone( strValue ) 
{
/************************************************
DESCRIPTION: Validates that a string contains valid
  US phone pattern.
  Ex. (999) 999-9999 or (999)999-9999

PARAMETERS:
   strValue - String to be tested for validity

RETURNS:
   True if valid, otherwise false.
*************************************************/
  var objRegExp  = /^\([1-9]\d{2}\)\s?\d{3}\-\d{4}$/;

  //check for valid us phone with or without space between
  //area code
  //alert(objRegExp.test(strValue));
  return objRegExp.test(strValue);
}

//Function to validate the Numeric values

function doDateCheck(from, to) 
{

  var blnResult = true;
if (Date.parse(from) > Date.parse(to)) {
   blnResult = false;

}
else {
   
blnResult = true;

   }
   return blnResult; 
}



function checkZip(value)
{
   var strValidChars = '0123456789-';
   var strChar;
   var blnResult = true;
   var strString = value;
if (strString.length != 10)
{
	blnResult = false;
}
else
{
 for (i = 0; i < strString.length && blnResult == true; i++)
   {
      strChar = strString.charAt(i);
      if (strValidChars.indexOf(strChar) == -1)
         {
			
			blnResult = false;
			
         }
   }
 
}
  var strArr = value.split("-");
if (strArr.length != 2)
{
 blnResult = false;
}
else
{
if (strArr[1].length != 4)
{
blnResult = false; 
}
}

  return blnResult; 
}

function checkPhone(value)
{
   var strValidChars = '0123456789.';
   var strChar;
   var blnResult = true;
   var strString = value;
if (strString.length!=10)
{
	blnResult = false;
}
else
{
 for (i = 0; i < strString.length && blnResult == true; i++)
   {
      strChar = strString.charAt(i);
      if (strValidChars.indexOf(strChar) == -1)
         {
			
			blnResult = false;
			
         }
   }
 
}
  return blnResult; 
}

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 IsBlank(value)
{
var blnResult = true;
	var strValue = value;
	//alert(strValue);
	if ((isEmpty(strValue))|| (strValue=='') || (strValue=='null') )
	{
	//alert(strValue);
		//alert("Name ");
		blnResult = false;
	}
	return blnResult
}





//Function to validate the Numeric values
function IsNumeric(value)
{
   var strValidChars = '0123456789.';
   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; 
}


//Function to validate the SSN values
function IsNumericSSN(value)
{	
 var blnResult = true;
 
	var strValue =value;
	if(strValue.length != 9)
	{
		//alert("Value is Blank");
		blnResult = false;		
	}
	else
	{
		var Cont_Value = value;
		//var Cont_Name =source; 
	 
		if((Cont_Value.charAt(0)=="+") || (Cont_Value.charAt(0)=="-"))
		{
			blnResult= false;
		}
		else if(!isNum(Cont_Value))
		{
			blnResult=false;
		} 
		else
			blnResult=true;
		 
	}
	 return blnResult; 
}


// Function to validate the US Phone Number.
//Eg. 123-456-7890
/*function validatePhoneNo(value)
{
//alert(value);
	 var blnResult = true;
	var strValue = value;
	//alert(strValue);
	//alert(strValue.length);
	if (strValue.length < 12)
	{
		//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 validateName(value)
{
 var blnResult = true;
	var strValue = value;
	//alert(strValue);
	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 Null names
function validateNullName(value)
{
 var blnResult = true;
	var strValue = value;
	//alert(strValue);
	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;
	//alert(strValue);
	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==" "))
			{	
				//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;	
	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)))
			{				
				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.
function validateName(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==" "))
			{				
			blnResult= false;
			}
			/*if (i == strValue.length-1)
			{
				if (!(strChar >= 0 && strChar <= 9))
				{
					value.IsValid = false;
				}
			}*/
		}
	}
	 return blnResult; 
}

function validateIntegerNumbers(value)
{
var blnResult = true;
	var strValue = value;
	if (strValue.charAt(0) == " ")
	{
		blnResult = false;
	}
	else if (strValue != "")
	{
		for (i=0;i<strValue.length;i++)
		{
			var strChar = strValue.charAt(i);
			if (!((strChar >= 0 && strChar <=9)))
			{					
				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)))
			{					
				blnResult = false;
			}			
		}
	}
		 return blnResult; 
}

//Function to Validate Numbers only.
function validateNumber(value)
{
var blnResult = true;
	var Cont_Value = value;
	//var Cont_Name =source; 
 
	if((Cont_Value.charAt(0)=="+") || (Cont_Value.charAt(0)=="-"))
	{
		blnResult = false;
	}
	else if(!isNum(Cont_Value))
	{
		blnResult=false;
	} 
	else
		blnResult=true;
	return blnResult;
}

function validateEmail(value)
{	
var blnResult = true;
	var strValue = value;	
	//alert(strValue);
	if (strValue.charAt(0) == " ")
	{
		//alert("1");
	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)))
	{
		//alert("2");
		blnResult = false;
	}
	else if (IsEmail(strValue))
	{
		//alert("3");
		blnResult = false;
	}
	return blnResult;
}

function validateCombo(value)
{
var blnResult = true;
	//var strValue = source.options.selectedIndex;
	var strValue = value;
	if(strValue.toUpperCase() == "SELECT")
	{
		blnResult = false;
	}	
	return blnResult;
}

function validateCombo1(value)
{
var blnResult = true;
	//var strValue = source.options.selectedIndex;
	//alert("Hi");
	var strValue = value;
	
	if(strValue.toUpperCase() == "SELECT ONE")
	{
		blnResult = false;
	}	
	//alert(blnResult);
	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 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.815-3945655
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 strExp = /^(?:\([0-9]\d{2}\)\ ?|(?:[0-9]\d{2}\-))[0-9]\d{2}\-\d{4}$/ ;
		var bnlResult = strExp.test(strValue);
		//alert(bnlResult);
		return !bnlResult;
	}


// Function to check for if the string is empty.
function isEmpty(strValue)
{
	if (strValue == null || strValue == "")
	{
		return true;
	}
	return false;
}

//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})(\]?)$/;
		//var 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 validateMoblieNo(value)
{	
	var blnResult = true;
	var strValue = value
	//alert(strValue);
	//alert(strValue.length);
	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 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 validate the US Phone Number.
function validatePhoneNo(value)
{	
	var blnResult = true;
	//value.IsValid = true;
	var strValue = value;
	//alert(strValue);
	//alert(strValue.length);
	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 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 DateCompare()
	{*/
	
	function DateCompare(myDate)
{
//var objDays = document.getElementById("Days");
//var myDate = new Date(objDays.value);
var currentDate = new Date();

if (myDate > currentDate)
{

//alert ('You cannot enter the time sheet for future days!!');
return false;
}
}
	
		// Current Date
	/*var d = new Date();
	var curr_date = d.getDate();
	var curr_month = d.getMonth();
	
	var curr_year = d.getFullYear();
	var currentDate = curr_month + "/" + curr_date + "/" + curr_year;
	//
	var objDays = document.getElementById("Days");
	
	// Formatting the date from the drop down list
	var myDate = new Date(objDays.value);
	var cmbcurr_date = myDate.getDate();
	var cmbcurr_month = myDate.getMonth();
	
	var cmbcurr_year = myDate.getFullYear();
	var cmbcurrentDate = cmbcurr_month + "/" + cmbcurr_date + "/" + cmbcurr_year;

	//compareDates(cmbcurrentDate,'mm/dd/yyyy',currentDate,'mm/dd/yyyy');
	
	alert(cmbcurrentDate);
	alert(currentDate);
	
	if (cmbcurrentDate > currentDate)
	{
		alert ('You cannot enter the time sheet for future days!!');
		return false;
	}
		
	}
/*
function compareDates(date1,dateformat1,date2,dateformat2) {
	var d1=getDateFromFormat(date1,dateformat1);
	var d2=getDateFromFormat(date2,dateformat2);
	if (d1 &gt; d2) 
		{
		alert ('You cannot enter the time sheet for future days!!');
		return false;
		//return 1;
		}
	return true; */
	//}

// Function to validate Email

	/*function emailCheck (emailStr)
		{
			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) {
				//alert("Email address seems incorrect (check @ and .'s)")
				return false
			}
			var user=matchArray[1]
			var domain=matchArray[2]

			if (user.match(userPat)==null)
			 {
				// user is not valid
				//alert("The username doesn't seem to be valid.")
				return false
			 }
			
			// Domain is symbolic name
			var domainArray=domain.match(domainPat)
			if (domainArray==null) {
				//alert("The domain name doesn't seem to be valid.")
				return false
			}

			var atomPat=new RegExp(atom,"g")
			var domArr=domain.match(atomPat)
			var len=domArr.length
			if (domArr[domArr.length-1].length<2 || domArr[domArr.length-1].length>3) 
				{
					// the address must end in a two letter or three letter word.
					//alert("The address must end in a three-letter domain, or two letter country.")
					return false
				}

			// Make sure there's a host name preceding the domain.
			if (len<2) 
			{
				var errStr="This address is missing a hostname!"
				//alert(errStr)
				return false
		    }

			// If we've gotten this far, everything's valid!
			return true;
		}*/
		
		
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;
}

function UrlValidation(value)//(e.g, http://www.abc.com)";
{
	var fvalue=value;
	var urlResult=true;
	//alert(fvalue);
	if (fvalue.length>0 )
	{
		var j = new RegExp(); 
		j.compile("http://|www.+[A-Za-z0-9-]+\.[A-Za-z0-9]+");  
        if (!j.test(fvalue))
        { 
			//alert(fvalue);
        	urlResult= false;
        }
	}
	return urlResult;
	
}
