


<!--
function MM_preloajadmin_images() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloajadmin_images.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_displayStatusMsg(msgStr) { //v1.0
  status=msgStr;
  document.MM_returnValue = true;
}

function pviiW3Cbg(obj, pviiColor) { //v1.1 by Project VII
	obj.style.backgroundColor=pviiColor
}
//-->

//check the numeric numbers
function checkNumerics(varPassed) {
	
	if(isNaN(varPassed.value)) {
		return 1;
	}
	return 0;
}

//check the negative numbers
function checkNegatives(varPassed) {
	if(varPassed.value<=0) {
		return 1;
	}
	return 0;
}
//It validates User ID
function validateUserID(strUid)
{
	var val;
	val=strUid.value;
	var len=val.length;
	//var spchr = new Array("_","~","`","!","@","#","$","%","^","&","*","(",")","-","+","=","[","{","]","}","|","\\",":",";","'","\"","<",",",">","/","?");
	//var spchr = new Array("~","`","!","@","#","$","%","^","&","*","(",")","_","+","=","[","{","]","}","|","\\",":",";","'","\"","<",">","/","?",".",",");
 	  var spchr = new Array(".","~","`","!","@","#","$","%","^","&","*","(",")","-"," ","+","=","[","{","]","}","|","\\",":",";","'","\"","<",",",">","/","?");
  	l = spchr.length;
	if(val!=" ")
    {
		if(val!="")
  		{
			
			if(len<5)
			{
  				//alert("Enter minimum of 5 characters data in " + getfieldname(strUid.name));
  				alert(getfieldname(strUid.name) + " cannot be less than 5 characters"  );
   				strUid.value="";
   				strUid.select();
   				strUid.focus(); 
   				return false;     				
			}
			else
			{
				for(i=0;i<l;i++)
				{
					var spchk = strUid.value.indexOf(spchr[i]);
					if (spchk >= 0)
					{
						//alert("Special characters are not allowed in "+ getfieldname(strUid.name));
						alert(getfieldname(strUid.name)+" can have (a/A - z/Z, 0 - 9 and  _ ) characters only");
						strUid.value="";
						strUid.select();
						strUid.focus();
						return false;
					}
				}				
			}
			
				
  			if(!isNaN(val))
  			{
  				alert("Enter character data in "+ getfieldname(strUid.name));
   				strUid.value="";
   				strUid.select();
   				strUid.focus(); 
   				return false;     
			}
			else
			{					
				for(i=0;i<l;i++)
				{
					var spchk = strUid.value.indexOf(spchr[i]);
					if (spchk >= 0)
					{
						//alert("Special characters are not allowed in " + getfieldname(strUid.name));
						alert(getfieldname(strUid.name)+" cannot have special characters");
						strUid.value="";
						strUid.select();
						strUid.focus();
						return false;
					}
				}
			}
		}		
	}
	
	return true;
}

//It Validate Password
function validatePassword(strPwd)
{
	val=strPwd.value;
  	if(val!=" ")
  	{
		if(val!="")
  		{
  			if(val.length<=7)
  			{
				alert("Password field must be atleast 8 characters.");
				strPwd.value="";
				strPwd.focus();
				//strPwd.select();
				return false;	
			}
		}
	}
	//alert("hi");
	return	validateUserID(strPwd);
}

//******************Name  Validations********************
function validatename_fml(o) {
	var val;
	val=o.value;
	var len=val.length;
  	//var spchr = new Array("_","~","`","!","@","#","$","%","^","&","*","(",")","-","+","=","[","{","]","}","|","\\",":",";","'","\"","<",",",">","/","?");
  	//var spchr = new Array(".","~","`","!","@","#","$","%","^","&","*","(",")","-"," ","+","=","[","{","]","}","|","\\",":",";","'","\"","<",",",">","/","?");
  	  var spchr = new Array("~","`","!","@","#","$","%","^","&","*","(",")","+","=","[","{","]","}","|","\\",":",";","'","\"","<",",",">","/","?","-",".");
  	l = spchr.length;
	if(val!=" ") {
		if(val!="") {
			if(!isNaN(val)) {
  				alert("Enter character data in "+ getfieldname(o.name));
   				o.value="";
   				o.select();
   				o.focus(); 
   				return false;     
			}
			else {					
				for(i=0;i<l;i++) {
					var spchk = o.value.indexOf(spchr[i]);
					if (spchk >= 0) {
						//alert("Special characters are not allowed in " + getfieldname(o.name));
						alert(getfieldname(o.name)+" can have (a/A - z/Z, 0 - 9, _ and space ) characters only");
						o.value="";
						o.select();
						o.focus();
						return false;
					}
				}
			}
			//alert(o.value.substr(0,1));
			
			if(!isNaN(o.value.substr(0,1))) {
  				alert(getfieldname(o.name) + " should start with characters");
   				o.value="";
   				o.select();
   				o.focus(); 
   				return false;     
			}
		}		
	}
	return true;		
}
//Validate Email Address
function validateEmail(strString)
{
	var str=strString.value;	
    var len=str.length;
    var uscore=strString.value.indexOf("_");
    var luscore=strString.value.lastIndexOf("_");
	var ind=strString.value.indexOf("@");
    var dot=strString.value.indexOf(".");
    var lind=strString.value.lastIndexOf("@");
    var ldot=strString.value.lastIndexOf(".");
    var spchr = new Array("`","~","!","#","$","%","^","&","*","(",")","-","+","=","{","[","]","}","|","\\",":",";","'","\"","?","/",">","<",","," ");
  	l = spchr.length;
	if(str!="")
  	{
   		if(str!=" ")
   		{
   			if ((ind.valueOf()<=0)||(lind.valueOf()>=ldot.valueOf())||(dot.valueOf()<=0)||(lind.valueOf()!=ind.valueOf())||(len<=ldot.valueOf()+1)||(ind.valueOf()+1==ldot.valueOf())||(ind.valueOf()+1==dot.valueOf())||(dot.valueOf()+1==ind.valueOf())||(luscore.valueOf()>=ldot.valueOf())||(uscore.valueOf()==0))//||(luscore.valueOf()>=ldot.valueOf())||(uscore.valueOf()==0)
			{
				alert("Enter Email in the format of LoginName@ServiceProvider.com");
				//strString.value="";
				strString.focus();
				strString.select();
				return false;						
			}    
    		if((ind>0)&&(dot>0))
    		{
				for(i=0;i<l;i++)
				{
					var spchk = strString.value.indexOf(spchr[i]);
					if (spchk >= 0)
					{
						alert("Enter Email in the format of LoginName@ServiceProvider.com");
						//strString.value="";
						strString.focus();
						strString.select();
						return false;
						break;
					}
				}
				for (i=0;i<len;i++)
				{
	 				if(((str.charAt(i)==".")&&(str.charAt(i+1)=="@"))||((str.charAt(i)==".")&&(str.charAt(i+1)=="."))||((str.charAt(i)==".")&&(str.charAt(i-1)=="@"))||((str.charAt(i)==".")&&(str.charAt(i+1)=="_"))||((str.charAt(i)=="_")&&(str.charAt(i+1)=="_"))||((str.charAt(i)=="@")&&(str.charAt(i+1)=="_"))||((str.charAt(i)==".")&&(str.charAt(i-1)=="_"))||((str.charAt(i)=="@")&&(str.charAt(i-1)=="_")))//||((str.charAt(i)==".")&&(str.charAt(i+1)=="_"))||((str.charAt(i)=="_")&&(str.charAt(i+1)=="_"))||((str.charAt(i)=="@")&&(str.charAt(i+1)=="_"))||((str.charAt(i)==".")&&(str.charAt(i-1)=="_"))||((str.charAt(i)=="@")&&(str.charAt(i-1)=="_"))
					{
						alert("Enter Email in the format of LoginName@ServiceProvider.com");
						strString.focus();
						strString.select();
						return false;						
				    }	 					
				}									
			}
    		else
   			{
    			alert("Enter Email in the format of LoginName@ServiceProvider.com");
    			//strString.value="";
				strString.select();
				strString.focus();
				return false;
    		}
   		}
	}
	
	return true;
}
//Validate Text Area
function validateTextArea(o,s)
{
	//alert(s);
	var count;
	var str1;
	var len;
	var val;
	val=o.value;
	len = val.length;
	//alert(len);
	if(val!=" ")
	{
	
		if(val!="")
		{
			if(len > s)
			{
				alert("Error in entering data for "+ getfieldname(o.name) +", You can not exceed "+s+" characters");
					o.value="";
   					o.select();
   					o.focus(); 
				return false;
			}
			else if(validateAddress(o)==false){
				//alert("Error in entering data for "+ getfieldname(o.name) +" ,You can not exceed "+s+" characters");
					//o.value="";
   					o.select();
   					o.focus(); 
				return false;
			}
			else if(len > 10)
			{			
				count=0;
				while(count < len)
				{
					str1 = val.substring(count,count+20);
					str1len = str1.length
					
					if(str1len >= 10)				
					{
						if(str1.indexOf(" ")==-1)
						{
								alert("Maximum word length can be only 10 characters");
								o.value="";
   								o.select();
   								o.focus(); 
							return false;
						}
					}
					count = count + 10
				}
			}	
			
			if(!(isNaN(val)))
			{
				alert("Enter character data in " + getfieldname(o.name))
				o.value="";
   				o.select();
   				o.focus(); 
				return false;     
			}
		}
	}
}

//Validate Address
function validateAddress(o)
{
	//alert(o);
	var val;
	val=o.value;
	var len=val.length; 
	//alert(len);
  	var spchr = new Array("~","`","!","@","$","%","^","*","+","=","[","{","]","}","|","\\",":",";","\"","<",">");
  	l = spchr.length;
	if(val!=" ")
    {
		if(val!="")
  		{
			
			for(i=0;i<l;i++)
			{
				var spchk = o.value.indexOf(spchr[i]);
				if (spchk >= 0)
				{
					//alert("Special characters are not allowed in " + getfieldname(o.name));
					alert(getfieldname(o.name)+" can have (a/A - z/Z, 0 - 9, #, &, (, ), -, _, ', /, ., ?, space and , ) characters only");
					
					//o.value="";
					o.select();
					o.focus();
					return false;
				}
			}				
				
  			if(!isNaN(val))
  			{
  				alert("Enter character data in "+ getfieldname(o.name));
   				o.value="";
   				o.select();
   				o.focus(); 
   				return false;     
			}
			else
			{					
				for(i=0;i<l;i++)
				{
					var spchk = o.value.indexOf(spchr[i]);
					if (spchk >= 0)
					{
						//alert("Special characters are not allowed in " + getfieldname(o.name));
						alert(getfieldname(o.name)+" can have (a/A - z/Z, 0 - 9, #, &, (, ), -, _, ', /,. and , ) characters only");
						o.value="";
						o.select();
						o.focus();
						return false;
					}
				}
			}
		}		
	}
	return true;
}


//Validate Address with size
function validateAddresswithsize(o,s)
{
	//alert(o);
	var val,str1,str1len;
	val=o.value;
	var len=val.length; 
	//alert(len);
  	var spchr = new Array("~","`","!","@","$","%","^","*","+","=","[","{","]","}","|","\\",":",";","\"","<",">");
  	l = spchr.length;
	if(val!=" ")
    {
		if(val!="")
  		{
			if(len > s)
			{
				alert("Error in entering data for "+ getfieldname(o.name) +", You can not exceed "+s+" characters");
					//o.value="";
   					o.select();
   					o.focus(); 
				return false;
			}
			
		
			for(i=0;i<l;i++)
			{
				var spchk = o.value.indexOf(spchr[i]);
				if (spchk >= 0)
				{
					alert(getfieldname(o.name)+" can have (a/A - z/Z, 0 - 9, #, &, (, ), -, _, ', /, ., ?, space and , ) characters only");
					//o.value="";
					o.select();
					o.focus();
					return false;
				}
			}				
				
  			if(!isNaN(val))
  			{
  				alert("Enter character data in "+ getfieldname(o.name));
   				o.value="";
   				o.select();
   				o.focus(); 
   				return false;     
			}
			else
			{					
				for(i=0;i<l;i++)
				{
					var spchk = o.value.indexOf(spchr[i]);
					if (spchk >= 0)
					{
						alert(getfieldname(o.name)+" can have (a/A - z/Z, 0 - 9, #, &, (, ), -, _, ', /,. and , ) characters only");
						o.value="";
						o.select();
						o.focus();
						return false;
					}
				}
			}
			if ( len > 100)
			{			
				count=0;
				while(count < len)
				{
					str1 = val.substring(count,count+30);
					str1len = str1.length
					if(str1len >= 30)				
					{
						if ( (str1.indexOf(" ")==-1))
						{
							alert("The number of characters in a word cannot exceed 100 characters,give spaces in between "+ getfieldname(o.name));
							
							o.focus();
							return false;
						}
					}
					count = count + 100
				}
				
		}
		}		
	}
	return true;
}
//Validate city
function validateCity(o)
{
	var val;
	var str1;
	var count;
	val=o.value;
	var len=o.value.length;
	//var spchr = new Array("~","`","!","@","#","$","%","^","&","*","(",")","-","_","+","=","[","{","]","}","|","\\",":",";","'","\"","<",",",">","/","?",".");
	  var spchr = new Array("~","`","!","@","#","$","%","^","&","*","(",")","_","+","=","[","{","]","}","|","\\",":",";","'","\"","<",">","/","?",".");
  	l = spchr.length;
	if(val!=" ")
    {
		if(val!="")
  		{
			if(len > 50)
			{			
				count=0;
				while(count < len)
				{
					str1 = val.substring(count,count+30);
					str1len = str1.length
					
					if(str1len >= 50)				
					{
						if(str1.indexOf(" ")==-1)
						{
							//alert("Error in entering data for "+ getfieldname(o.name));
							alert("Maximum word length can be only 50 characters");
							o.focus();
							return false;
						}
					}
					count = count + 50
				}
			}		
			  		
  			if(!isNaN(val))
  			{
  				alert("Enter character data in "+ getfieldname(o.name));
   				o.value="";
   				o.select();
   				o.focus(); 
   				return false;     
			}
			else
			{					
				for(i=0;i<l;i++)
				{
					var spchk = o.value.indexOf(spchr[i]);
					if (spchk >= 0)
					{
						//alert("Special characters are not allowed in  " + getfieldname(o.name));
						alert(getfieldname(o.name)+" can have (a/A - z/Z, 0 - 9, - and space ) characters only");
						o.value="";
						o.select();
						o.focus();
						return false;
					}
				}
			}
		}		
	}
	return true;
}
function validatepostcode(o)
{

	var val;
	var count;
	val=o.value;
	var len=o.value.length;
	var spchr = new Array("~","`","!","@","#","$","%","^","&","*","(",")","-","_","+","=","[","{","]","}","|","\\",":",";","'","\"","<",",",">","/","?",".");
  	l = spchr.length;
	if (val!=" ")
    {
		if(val!="")
		{
	 //  	if(!isNaN(val))
  	//		{
  	//			alert("Enter valid data in "+ getfieldname(o.name));
   	//			o.value="";
   	
   	//			o.focus(); 
   	//			return false;     
	//		}
	//		else
	//		{					
				for(i=0;i<l;i++)
				{
					var spchk = o.value.indexOf(spchr[i]);
					if (spchk >= 0)
					{
						alert("Enter valid data in "+ getfieldname(o.name));
						//o.value="";
						o.select();
						o.focus();
						return false;
					}
				}
	//		}
		}
		if ( len > 30)
		{			
				count=0;
				while(count < len)
				{
					str1 = val.substring(count,count+30);
					str1len = str1.length
					if(str1len >= 30)				
					{
						if ( (str1.indexOf(" ")==-1))
						{
							alert("The number of characters in a word cannot exceed 30 characters,give spaces in between "+ getfieldname(o.name));
							
							o.focus();
							return false;
						}
					}
					count = count + 30
				}
				
		}
		if ( (val.indexOf('"')>=0)|| (val.indexOf("'")>=0))
	{
		alert("Please enter valid data in "+ getfieldname(o.name));
		//o.value="";
		o.focus();
		return false;
	}
	}
	return true;		
}

//Validate Phone Number
function validatePhone(o)
{
	//mytrim(o);
	val=o.value;
	//alert(val);
	var len=val.length;
  	var spchr = new Array("+","-","."," ");
  	l = spchr.length;	
  	for(i=0;i<l;i++)
	{
		var spchk = o.value.indexOf(spchr[i]);
		if (spchk >= 0)
		{
		
			alert(getfieldname(o.name)+" can have only numbers.");
			o.value="";
			o.focus();
			//o.select();
			return false;
			break;
		}
	}	
	if(val!="")
	{
		if(val!=" ") 
   		{
   			retval=checkNumerics(o);
   			if((o.name=="txtphone_a"||o.name=="txtfax_a" ||o.name=="txtmob_a" ) && (o.value!="" )) {
  				/*
  				if(len!=3) {
  					if(o.name=="txtphone_a")
  						alert("Country code of phone number should be 3 digits only.");
  					
  					if(o.name=="txtfax_a")
  						alert("Country code of fax number should be 3 digits only.");
  					if(o.name=="txtmob_a")
  						alert("Country code of mobile number should be 3 digits only.");
  					o.focus();
  					return false; 
  				
  				}
  				*/
  				if(len<5) {
  					if(o.name=="txtphone_a")
  						alert("Country code of phone number should be 5 digits only.");  					
  					if(o.name=="txtfax_a")
  						alert("Country code of fax number should be 5 digits only.");
  					if(o.name=="txtmob_a")
  						alert("Country code of mobile number should be 5 digits only.");
  					o.focus();
  					return false;
  				}
  				else
  				{
  				if(o.name.substring(0,3)== "00 ")
   					{
   						alert("Enter Web URL in the format of www.sitename.com")
   						o.focus();
						o.select();
						return false;
   					}
  				}
  				
  			}
  			
  			
   				
   				
   			if((o.name=="txtphone_b"||o.name=="txtfax_b") && (o.value!="" )) {
  				if(len<=2) {
  					if(o.name=="txtphone_b")
  						alert("Area code of phone number should be 3 to 5 digits only.");
  					if(o.name=="txtfax_b")
  						alert("Area code of fax number should be 3 to 5 digits only.");
  					o.focus();
  					return false;
  				}
  			}
  			if((o.name=="txtphone_c"||o.name=="txtfax_c" ||o.name=="txtmob_c" )&& (o.value!="" ))	 {
  				if(len<=3) {
  					if(o.name=="txtphone_c")
  						alert("Phone number should be 4 to 7 digits only.");
  					if(o.name=="txtfax_c")
  						alert("fax number should be 4 to 7 digits only.");
  					if(o.name=="txtmob_c")
  						alert("mobile number should be 4 to 11 digits only.");
  					o.focus();
  					return false;
  				}
  			}
  		//	if((o.name=="txtmob_a"||o.name=="txtmob_c" )&& (o.value!="" ))	 {
  		//		if(len<5) {
  		//			if(o.name=="txtmob_a")
  		//				alert("Mobile number should be 5 digits only.");
  		//			if(o.name=="txtmob_c")
  		//				alert("Mobile number should be 5 digits only.");
  		//			o.focus();
  		//			return false;
  		//		}
  		//	}
  		
			if(retval==1)
			{
				alert(getfieldname(o.name)+" can have only numbers.");
				o.value="";
				o.focus();
				return false;
			}
   			else
			{
				retval=checkNegatives(o);
				if(retval==1)
				{
					alert("Enter a value greater than 0");
					o.value="";
					o.focus();
					return false;
				}
				else
				{
					for(i=0;i<l;i++)
					{
						var spchk = o.value.indexOf(spchr[i]);
						if (spchk >= 0)
						{
							alert(getfieldname(o.name)+" can have only numbers.");
							o.value="";
							o.focus();
							//o.select();
							return false;
							break;
						}
					}
				}
								
			}
   		}
	}
	return true;
}
//Validate Country Code
//Validate Country Code
function validateCcode(o)
{
	//mytrim(o);
	val=o.value;
	//alert(val);
	var len=val.length;
  	var spchr = new Array("+","-",".");
  	l = spchr.length;	
  	for(i=0;i<l;i++)
	{
		var spchk = o.value.indexOf(spchr[i]);
		if (spchk >= 0)
		{
		
			alert(getfieldname(o.name)+" can have only numbers.");
			o.value="";
			o.focus();
			//o.select();
			return false;
			break;
		}
	}
	
	if(val!="")
	{
		if(val!=" ") 
   		{
			if(o.value.substring(0,2) != "00")
   				{
   					alert("Country Code should start with '00'");
   					o.focus();
					o.select();
					return false;
   				}
   
	
			var arr1;
			var arrflag;
			arrflag = "false";
	
				arr1=o.value.split(" ");			
				for(i=0;i<arr1.length;i++)
				{
					if(isNaN(arr1[i])==true){
						arrflag = "true";
					}
				}
				if(arrflag=="true")
					{
						alert("Please enter numeric value in "+getfieldname(o.name));
						o.value="";
						o.select();
						o.focus();
						return false;
					}
		}
	}
	
	
}

//BEGIN validatename(CHARACTERS WITH SPACES and '.')  FUNCTION
function validatename(o)
{
	
	var val;
	var count;
	val=o.value;
	var len=o.value.length;
	var spchr = new Array("~","`","!","@","#","$","%","^","&","*","(",")","-","+","=","[","{","]","}","|","\\",":",";","\"","<",",",">","?","1","2","3","4","5","6","7","8","9","0");
  	l = spchr.length;
	if ((val!=""))
    {		
		if((val!=" "))
		{	
  			if(!isNaN(val))
  			{
  			
  				alert("Please enter valid data in "+ getfieldname(o.name));
   				o.value="";
   				o.focus(); 
   				//o.select();
   				
   				return false;     
			}
			else
			{					
				for(i=0;i<l;i++)
				{
					var spchk = o.value.indexOf(spchr[i]);
					if (spchk >= 0)
					{
				
					alert("Please enter valid data in "+ getfieldname(o.name));
						//o.value="";
						o.select();
						o.focus();
						return false;
					}
				}
			}
		}
		if ( len > 50)
		{			
				count=0;
				while(count < len)
				{
					str1 = val.substring(count,count+30);
					str1len = str1.length
					if(str1len >= 30)				
					{
						if ( (str1.indexOf(" ")==-1))
						{
							alert("The number of characters in a word cannot exceed 30 characters,give spaces in between "+ getfieldname(o.name));
							
							o.focus();
							return false;
						}
					}
					count = count + 50
				}
				
		}
	
	}
	return true;		
}							


//END validate name FUNCTION
//*********************************************************************************

//BEGIN validateScenarioname(alphanumeric WITH SPACES and '.','/','\')  FUNCTION
function validateScenarioname(o)
{
	
	var val;
	var count;
	val=o.value;
	var len=o.value.length;
	var spchr = new Array("~","`","!","@","#","$","%","^","&","*","(",")","-","+","=","[","{","]","}","|",":",";","<",",",">","?");
  	l = spchr.length;
	if ((val!=""))
    {		
		if((val!=" "))
		{	
  			if(!isNaN(val))
  			{
  			
  				alert("Please enter valid data in "+ getfieldname(o.name));
   				o.value="";
   				o.focus(); 
   				//o.select();
   				
   				return false;     
			}
			else
			{					
				for(i=0;i<l;i++)
				{
					var spchk = o.value.indexOf(spchr[i]);
					if (spchk >= 0)
					{
				
					alert("Please enter valid data in "+ getfieldname(o.name));
						//o.value="";
						o.select();
						o.focus();
						return false;
					}
				}
			}
		}
		if ( len > 30)
		{			
				count=0;
				while(count < len)
				{
					str1 = val.substring(count,count+30);
					str1len = str1.length
					if(str1len >= 30)				
					{
						if ( (str1.indexOf(" ")==-1))
						{
							alert("The number of characters in a word cannot exceed 30 characters,give spaces in between "+ getfieldname(o.name));
							
							o.focus();
							return false;
						}
					}
					count = count + 30
				}
				
		}
	
	}
	return true;		
}							


//END validate name FUNCTION
//*********************************************************************************

//*********************************************************************************
//BEGIN OF NUMBERS WITH SPACES FUNCTION
function numbers(o)
{
	
	var val;
	var count;
	val=o.value;
	var len=o.value.length;
	var spchr = new Array("~","`","!","@","#","$","%","^","&","*","(",")","-","_","+","=","[","{","]","}","|","\\",":",";","'","\"","<",",",">","/","?",".","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z");
  	l = spchr.length;
	if ((val!=" "))
    {
	  if((val!=""))
	  {
		/*if(isNaN(val))
  			{
  				alert("Enter valid data in "+ getfieldname(o.name));
   				o.value="";
   				//o.select();
   				o.focus(); 
   				return false;     
			}
		else
			{	*/				
				for(i=0;i<l;i++)
				{
					var spchk = o.value.indexOf(spchr[i]);
					if (spchk >= 0)
					{
						alert("Enter valid data in " + getfieldname(o.name));
						o.value="";
						//o.select();
						o.focus();
						return false;
					}
				}
			//}
		}
	}
	return true;		
}	
//END NUMBERSONLY WITHOUT SPACES FUNCTION
//*********************************************************************************

//*********************************************************************************
//BEGIN OF NUMBERS WITHOUT SPACES FUNCTION
function phonenumbers(o)
{
	var val;
	var count;
	val=o.value;
	var len=o.value.length;
	var spchr = new Array("~","`","!","@","#","$","%","^","&","*","(",")","-","_","+","=","[","{","]","}","|","\\",":",";","'","\"","<",",",">","/","?","."," ");
  	l = spchr.length;
	if ((val!=" "))
    {
	  if((val!=""))
	  {
		if(isNaN(val))
  			{
  				alert("Enter valid data in "+ getfieldname(o.name));
   				o.value="";
   				//o.select();
   				o.focus(); 
   				return false;     
			}
		else
			{					
				for(i=0;i<l;i++)
				{
					var spchk = o.value.indexOf(spchr[i]);
					if (spchk >= 0)
					{
						alert("Enter valid data in " + getfieldname(o.name));
						o.value="";
						//o.select();
						o.focus();
						return false;
					}
				}
			
			if ( len < 13)
				{			
				alert(getfieldname(o.name) + " should be of 13 digits");
				o.focus();
				return false;
				}
			}	
		
		}
	}
	return true;		
}	
//END NUMBERSONLY WITHOUT SPACES FUNCTION
//*********************************************************************************

//*********************************************************************************

//BEGIN OF ALPHANUMERICS WITH SPECIAL CHARACTER "-","."," ","+","#","/",",","@",":","(",")","[","]" FUNCTION
function alphnumericwithspecialcharacters(o)
{

	var val;
	var count;
	val=o.value;
	var len=o.value.length;
	var spchr = new Array("~","`","!","$","%","^","&","*","_","=","{","}","|","\\","'","\"","<",";",">","?");
  	l = spchr.length;
	if ((val!=" "))
    {
     if((val!=""))
     {
    	if(!isNaN(val))
  			{
  				alert("Enter valid data in "+ getfieldname(o.name)); 
   				o.value="";
   				//o.select();
   				o.focus(); 
   				return false;     
			}
			else
			{					
				for(i=0;i<l;i++)
				{
					var spchk = o.value.indexOf(spchr[i]);
					if (spchk >= 0)
					{
						alert("Enter valid data in "+ getfieldname(o.name)); 
						//H.No: #1-2/3,xyz,block(A)
						//o.value="";
						o.select();
						o.focus();
						return false;
					}
				}
			}
		}
		if ( len > 30)
		{			
				count=0;
				while(count < len)
				{
					str1 = val.substring(count,count+30);
					str1len = str1.length
					if(str1len >= 30)				
					{
						if ( (str1.indexOf(" ")==-1))
						{
							alert("The number of characters in a word cannot exceed 30 characters,give spaces in between "+ getfieldname(o.name));
							
							o.focus();
							return false;
						}
					}
					count = count + 30
				}
				
		}
		if ( (val.indexOf('"')>=0)|| (val.indexOf("'")>=0))
	{
		alert("Please enter valid data in "+ getfieldname(o.name));
		//o.value="";
		o.focus();
		return false;
	}
	}
	return true;		
}	

//END ALPHANUMERICS WITH SPECIAL CHARACTER "-","."," ","#","/",",","@",":","(",")","[","

//*********************************************************************************
 //BEGIN OF TEXTAREA WITH SPECIAL CHARACTERS FUNCTION
function textareasplchars(o,s)
{
	var count;
	var str1;
	var len;
	val=o.value;
	len = o.value.length;
	
	
	/*if(val.indexOf(" ")==-1)
	{
		alert("Please enter valid data for "+ getfieldname(o.name));
		o.value="";
		o.focus();
		return false;
	}
	*/
	if(val!=" ")
	{
		if(val!="")
		{
			if(len > s)
			{
				alert("You cannot exceed "+s+" characters for "+ getfieldname(o.name));
				o.focus();
				return false;
			}
			
			else if ( (val.indexOf("\n")==-1) &&(len > 30))
			{			
				count=0;
				while(count < len)
				{
					str1 = val.substring(count,count+30);
					str1len = str1.length
					if(str1len >= 30)				
					{
						if ( (str1.indexOf(" ")==-1))
						{
							alert("The number of characters in a word cannot exceed 30 characters,give spaces");
							o.focus();
							return false;
						}
					}
					count = count + 30
				}
				
			}	
			
			/*if(!(isNaN(val)))
			{
				alert(" Please Enter valid data in " + getfieldname(o.name))
				o.value="";
				o.select();
				o.focus(); 
				return false;     
			}*/
		}
	}
	return true;
}

//END OF TEXTAREA WITH SPECIAL CHARACTERS FUNCTION
//*********************************************************************************


//BEGIN validateaccountname(CHARACTERS WITH SPACES and '.')  FUNCTION
function validateaccountname(o)
{
	
	//alert(o);
	var val;
	var count;
	val=o.value;
	var len=o.value.length;
	var spchr = new Array("~","`","!","@","#","$","%","^","*","_","+","=","[","{","]","}","|","\\",":",";","\"","<",",",">","?","1","2","3","4","5","6","7","8","9","0");
  	l = spchr.length;
	if ((val!=""))
    {		
		if((val!=" "))
		{	
  			if(!isNaN(val))
  			{
  			
  				alert("Please enter valid data in "+ getfieldname(o.name));
   				o.value="";
   				o.focus(); 
   				//o.select();
   				
   				return false;     
			}
			else
			{					
				for(i=0;i<l;i++)
				{
					var spchk = o.value.indexOf(spchr[i]);
					if (spchk >= 0)
					{
				
					alert("Please enter valid data in "+ getfieldname(o.name));
						//o.value="";
						o.select();
						o.focus();
						return false;
					}
				}
			}
		}
		if ( len > 50)
		{			
				count=0;
				while(count < len)
				{
					str1 = val.substring(count,count+30);
					str1len = str1.length
					if(str1len >= 30)				
					{
						if ( (str1.indexOf(" ")==-1))
						{
							alert("The number of characters in a word cannot exceed 50 characters,give spaces in between "+ getfieldname(o.name));
							
							o.focus();
							return false;
						}
					}
					count = count + 50
				}
				
		}

	}
	return true;		
}							


//END validate account name FUNCTION



//Validate Bnk Street
function validatestreet(o)
{
	var val;
	var str1;
	var count;
	val=o.value;
	var len=o.value.length;
	//var spchr = new Array("~","`","!","@","#","$","%","^","&","*","(",")","-","_","+","=","[","{","]","}","|","\\",":",";","'","\"","<",",",">","/","?",".");
	  var spchr = new Array("~","`","!","@","#","$","%","^","&","*","(",")","_","+","=","[","{","]","}","|","\\",":",";","'","\"","<",">","?",".");
  	l = spchr.length;
	if(val!=" ")
    {
		if(val!="")
  		{
			if(len > 50)
			{			
				count=0;
				while(count < len)
				{
					str1 = val.substring(count,count+30);
					str1len = str1.length
					
					if(str1len >= 30)				
					{
						if(str1.indexOf(" ")==-1)
						{
							//alert("Error in entering data for "+ getfieldname(o.name));
							alert("Maximum word length can be only 30 characters");
							o.focus();
							return false;
						}
					}
					count = count + 50
				}
			}		
			  		
  			if(!isNaN(val))
  			{
  				alert("Enter character data in "+ getfieldname(o.name));
   				o.value="";
   				o.select();
   				o.focus(); 
   				return false;     
			}
			else
			{					
				for(i=0;i<l;i++)
				{
					var spchk = o.value.indexOf(spchr[i]);
					if (spchk >= 0)
					{
						//alert("Special characters are not allowed in  " + getfieldname(o.name));
						alert(getfieldname(o.name)+" can have (a/A - z/Z, 0 - 9, -, /, , and space ) characters only");
						o.value="";
						o.select();
						o.focus();
						return false;
					}
				}
			}
		}		
	}
	return true;
}


function validateExpenses(o)
{
o.value=mytrimval(o.value);
if(o.value.length==0) o.value="0";
if(isNaN(o.value))
{
	alert("Enter only numerics in "+ getfieldname(o.name));
	o.select();
	//o.value="";
	o.focus();
	return false;   
}
return true;
}

//Validate Float
function validateFloat(o,s,p)
{	
	var val=o.value;
	var len=o.value.length;
	var flag;
	var p1=o.value.indexOf(".")
	var spchr = new Array("+","-");
  	l = spchr.length;			
  	if(p1=="-1")
  	{
  	var s1=o.value;
  	var s2="";
  	}
  	else
  	{
  	var s1=o.value.substr(0,p1);
	var s2=o.value.substr(p1,len);
	}
	if(val!="")
	{
		if(val!=" ")
		{
			if(val!=0)
			{	
		//	alert(p1);
		//	alert(s1);
		//	alert(s2);
					if((isNaN(s1))||(isNaN(s2)))
					{
						alert("Enter only numerics in "+ getfieldname(o.name));
						o.select();
						//o.value="";
						o.focus();
						return false;   
					}
				
				
				if((len == parseInt(p)+1)||(len > parseInt(p)-parseInt(s)))
				{
					if(val.indexOf(".")>-1)
					{
						//alert(val.indexOf("."));
						//alert(val.indexOf(".")+3);
						//alert(len);
						if(val.lastIndexOf(".")+parseInt(s)+1<len)
						{
							alert(" Enter "+s+" digit(s) number only after decimal point.");
							o.select();
							//o.value="";
							o.focus();
							return false;   		
						} 
						
						if(val.indexOf(".")==0)//||(val.indexOf(".")!=val.lastIndexOf("."))
						{
							alert(" Enter Atleast one Digit Number Before Dicimal Point.");
							o.select();
							//o.value="";
							o.focus();
							return false;   		
						}
						
						if(s1.length > (parseInt(p)-parseInt(s)))
						{
							alert(" Enter "+ (parseInt(p)-parseInt(s)) +" digit(s) number before Dicimal Point.");
							o.select();
							o.focus();
							return false;
						}
						
						/*if(s1==0)
						{
							alert(" enter a value greaterthan 0 before decimal point.");
							o.select();
							//o.value="";
							o.focus();
							return false;   		
						}*/		  	 
					}
					else
					{
						//alert(p);
						//alert(" Enter a value containing a Decimal point.");
						alert(" Enter "+ (parseInt(p)-parseInt(s)) +" digit(s) number.");
						
						o.select();
						o.focus();
						return false;	
					}
				}
				else if(len < (parseInt(p)-parseInt(s)))
				{
					if(val.indexOf(".")>-1)
					{
						//alert(val.indexOf("."));
						//alert(val.indexOf(".")+3);
						//alert(len);
						if(val.lastIndexOf(".")+parseInt(s)+1<len)
						{
							alert(" Enter only "+s+" Digit(s) after Dicimal Point.");
							o.select();
							//o.value="";
							o.focus();
							return false;   		
						} 
						
						if(val.indexOf(".")==0)//||(val.indexOf(".")!=val.lastIndexOf("."))
						{
							alert(" Enter atleast one Digit Number Before Dicimal Point.");
							o.select();
							//o.value="";
							o.focus();
							return false;   		
						}
						
						if(s1.length > (parseInt(p)-parseInt(s)))
						{
							alert(" Enter "+ (parseInt(p)-parseInt(s)) +" digit(s) number before Dicimal Point.");
							o.select();
							o.focus();
							return false;
						}
						
						/*if(s1==0)
						{
							alert(" enter a value greaterthan 0 before decimal point.");
							o.select();
							//o.value="";
							o.focus();
							return false;   		
						}*/		  	 
					}
					
				
				}
				
				for(i=0;i<l;i++)
				{
					var spchk = o.value.indexOf(spchr[i]);
					if (spchk >= 0)
					{
						alert(" Enter Unsigned Numbers in" + getfieldname(o.name));
						//o.value="";
						o.focus();
						o.select();
						return false;
					}
				}
			}
			else
			{
				alert(" Enter a value greater than 0 " + getfieldname(o.name));
				//o.value="";
				o.focus();
				o.select();
				return false;			
			}
		}
	}
}
//Validate Percentage
function validatePercent(o,s,p,maxper)
{
	var val=o.value;
	var len=o.value.length;
	var flag;
	var p1=o.value.indexOf(".")
	var spchr = new Array("+","-");
  	l = spchr.length;			
  	if(p1=="-1")
  	{
  	var s1=o.value;
  	var s2="";
  	}
  	else
  	{
  	var s1=o.value.substr(0,p1);
	var s2=o.value.substr(p1,len);
	}
	if(val!="")
	{
		if(val!=" ")
		{
			if(val!=0)
			{	
			if (parseFloat(val) > parseFloat(maxper))
			{
				alert(getfieldname(o.name) + " should not be greater than "+ maxper);
				o.focus();
				return false;
			}
			
			//alert(p1);
			//alert(isNaN(s1));
			//alert(s2);
				if((isNaN(s1))||(isNaN(s2)))
				{
					alert("Enter only numerics in "+ getfieldname(o.name));
					o.select();
					//o.value="";
					o.focus();
					return false;   
				}
				if((len == parseInt(p)+1)||(len > parseInt(p)-parseInt(s)))
				{
					if(val.indexOf(".")>-1)
					{
						//alert(val.indexOf("."));
						//alert(val.indexOf(".")+3);
						//alert(len);
						if(val.lastIndexOf(".")+parseInt(s)+1<len)
						{
							alert(" Enter "+s+" digit(s) number after decimal point.");
							o.select();
							//o.value="";
							o.focus();
							return false;   		
						} 
						
						/*
						if(val.indexOf(".")==0)//||(val.indexOf(".")!=val.lastIndexOf("."))
						{
							alert(" Enter Atleast one Digit Number Before Dicimal Point.");
							o.select();
							//o.value="";
							o.focus();
							return false;   		
						}
						*/
						if(s1.length > (parseInt(p)-parseInt(s)))
						{
							alert(" Enter "+ (parseInt(p)-parseInt(s)) +" digit(s) number before Dicimal Point.");
							o.select();
							o.focus();
							return false;
						}
						
						/*if(s1==0)
						{
							alert(" enter a value greaterthan 0 before decimal point.");
							o.select();
							//o.value="";
							o.focus();
							return false;   		
						}*/		  	 
					}
					else
					{
						//alert(" Enter a value containing a Decimal point.");
						alert(" Enter "+ (parseInt(p)-parseInt(s)) +" digit(s) number.");
						o.select();
						o.focus();
						return false;	
					}
				}
				else if(len < (parseInt(p)-parseInt(s)))
				{
					if(val.indexOf(".")>-1)
					{
						//alert(val.indexOf("."));
						//alert(val.indexOf(".")+3);
						//alert(len);
						if(val.lastIndexOf(".")+parseInt(s)+1<len)
						{
							alert(" Enter only "+s+" Digit(s) after Dicimal Point.");
							o.select();
							//o.value="";
							o.focus();
							return false;   		
						} 
						
						if(val.indexOf(".")==0)//||(val.indexOf(".")!=val.lastIndexOf("."))
						{
							alert(" Enter atleast one Digit Number Before Dicimal Point.");
							o.select();
							//o.value="";
							o.focus();
							return false;   		
						}
						
						if(s1.length > (parseInt(p)-parseInt(s)))
						{
							alert(" Enter "+ (parseInt(p)-parseInt(s)) +" digit(s) number before Dicimal Point.");
							o.select();
							o.focus();
							return false;
						}
						
						/*if(s1==0)
						{
							alert(" enter a value greaterthan 0 before decimal point.");
							o.select();
							//o.value="";
							o.focus();
							return false;   		
						}*/		  	 
					}
					
				
				}
				
				for(i=0;i<l;i++)
				{
					var spchk = o.value.indexOf(spchr[i]);
					if (spchk >= 0)
					{
						alert(" Enter Unsigned Numbers in" + getfieldname(o.name));
						//o.value="";
						o.focus();
						o.select();
						return false;
					}
				}
			}
			else
			{
				alert(" Enter a value greater than 0 " + getfieldname(o.name));
				//o.value="";
				o.focus();
				o.select();
				return false;			
			}
		}
	}
}

//Validate Date
function validateDate(d, m, y)
{
	var startdate;;
var m_date;
//var d;
//var m;
//var y;
//d= d.value;
//m = m.value;
//y = y.value;

	if (m==2)
	{
		
		if (d>29) 
		{
			alert("Invalid date! February cannot have more than 29 days");
			return false;
		}
		if ((y%4)!==0) 
		{
			if (d>=29)
			{
				alert("Invalid date! February cannot have more than 28 days");
				return false;
			}
		}
	}
	
	
	if (d==31)
	{
		switch (parseInt(m))
		{
			case 4:
				alert ("Invalid date! April cannot have more than 30 days ");
				return false;		
			case 6:
				alert ("Invalid date! June cannot have more than 30 days");
				return false;
			case 9:
				alert ("Invalid date! September cannot have more than 30 days");
				return false;
			case 11:
				alert ("Invalid date! November cannot have more than 30 days");
				return false;
		}
	}
	
	m_date= d + "/" + m + "/" + y;
	
	/*startdate = new Date(m_date);
	var today = new Date();
	if (startdate<today)
	{
		alert ("Date cannot be less than current system date")
		return false;
	}*/
	return true;
}

//*********************************************************************************

//BEGIN CHARACTERS WITH SPACES FUNCTION
function charwithspaces(o)
{
	var val;
	var count;
	val=o.value;
	var len=o.value.length;
	var spchr = new Array("~","`","!","@","#","$","%","^","&","*","(",")","-","_","+","=","[","{","]","}","|","\\",":",";","'","\"","<",",",">","/","?",".","1","2","3","4","5","6","7","8","9","0");
  	l = spchr.length;
	if ((val!=""))
    {		
		if((val!=" "))
		{	
  			if(!isNaN(val))
  			{
  			
  				alert(" "+ getfieldname(o.name) + " can have only characters");
   				o.value="";
   				o.focus(); 
   				//o.select();
   				
   				return false;     
			}
			else
			{					
				for(i=0;i<l;i++)
				{
					var spchk = o.value.indexOf(spchr[i]);
					if (spchk >= 0)
					{
						alert(" "+getfieldname(o.name) + " can have ('a/A - z/Z', 'space') values only");
						//o.value="";
						o.select();
						o.focus();
						return false;
					}
				}
			}
			if ( len > 30)
			{			
				count=0;
				while(count < len)
				{
					str1 = val.substring(count,count+16);
					//alert(str1);
					str1len = str1.length
					//alert(str1len);
					if(str1len >= 30)				
					{
						if ( (str1.indexOf(" ")==-1))
						{
							alert("A word cannot be more than 30 characters for " + getfieldname(o.name) +"");
							o.focus();
							return false;
						}
					}
					count = count + 30
				}
				
			}
			
		}
	if ( (val.indexOf('"')>=0)|| (val.indexOf("'")>=0))
	{
		alert("Please enter valid data in "+ getfieldname(o.name));
		//o.value="";
		o.focus();
		return false;
	}
	}
	return true;		
}							

//END CHARACTERS WITH SPACES FUNCTION


//*********************************************************************************


//*********************************************************************************

 //BEGIN OF TEXTAREA FOR ADDRESS FUNCTION
function textareaforaddress(o,s)
{
	var count;
	var str1;
	var len;
	var spchr = new Array("~","`","!","$","%","^","*","_","+","=","{","}","|","\\","'","\"","<",";",">","?");
  	l = spchr.length;
	val=o.value;
	len = o.value.length;
	
	
	/*if(val.indexOf(" ")==-1)
	{
		alert("Please enter valid data for "+ getfieldname(o.name));
		o.value="";
		o.focus();
		return false;
	}*/
	
	
	
	if(val!=" ")
	{
		if(val!="")
		{
			if(len > s)
			{
				alert("You cannot exceed "+s+" characters for "+ getfieldname(o.name));
				o.focus();
				return false;
			}
			else if ( (val.indexOf("\n")==-1) &&(len > 30))
			{			
				count=0;
				while(count < len)
				{
					str1 = val.substring(count,count+30);
					str1len = str1.length
					if(str1len >= 30)				
					{
						if(str1.indexOf(" ")==-1)
						{
							alert("The number of characters in a word cannot exceed 30 characters,give spaces");
							o.focus();
							return false;
						}
					}
					count = count + 30
				}
			 }
			
				for(i=0;i<l;i++)
				{
					var spchk = o.value.indexOf(spchr[i]);
					if (spchk >= 0)
					{
					alert("Please enter valid data in "+ getfieldname(o.name) + "  like 'H.No: #1-2/3,xyz,block(A)' ");
						//o.value="";
						o.select();
						o.focus();
						return false;
					}
				}	
			
			/*if(!(isNaN(val)))
			{
				alert(" Please enter valid data in " + getfieldname(o.name))
				o.value="";
				o.select();
				o.focus(); 
				return false;     
			}*/
		}
	}
}
//END OF TEXTAREA FOR ADDRESS FUNCTION
//*********************************************************************************

//*********************************************************************************

//BEGIN OF ALPHANUMERICS WITH SPECIAL CHARACTER "-","."," ","+","#","/",",","@",":","(",")","[","]" FUNCTION
function alphnumericwithspecialcharacters(o)
{

	var val;
	var count;
	val=o.value;
	var len=o.value.length;
	var spchr = new Array("~","`","!","$","%","^","&","*","_","=","{","}","|","\\","'","\"","<",";",">","?");
  	l = spchr.length;
	if ((val!=" "))
    {
     if((val!=""))
     {
    	if(!isNaN(val))
  			{
  				alert("Enter valid data in "+ getfieldname(o.name) + "  like '" + getfieldmessage(o.name)+"'"); 
   				o.value="";
   				//o.select();
   				o.focus(); 
   				return false;     
			}
			else
			{					
				for(i=0;i<l;i++)
				{
					var spchk = o.value.indexOf(spchr[i]);
					if (spchk >= 0)
					{
						alert("Enter valid data in "+ getfieldname(o.name) + "  like '" + getfieldmessage(o.name)+"'"); 
						//H.No: #1-2/3,xyz,block(A)
						//o.value="";
						o.select();
						o.focus();
						return false;
					}
				}
			}
		}
		if ( len > 30)
		{			
				count=0;
				while(count < len)
				{
					str1 = val.substring(count,count+30);
					str1len = str1.length
					if(str1len >= 30)				
					{
						if ( (str1.indexOf(" ")==-1))
						{
							alert("The number of characters in a word cannot exceed 30 characters,give spaces in between "+ getfieldname(o.name));
							
							o.focus();
							return false;
						}
					}
					count = count + 30
				}
				
		}
		if ( (val.indexOf('"')>=0)|| (val.indexOf("'")>=0))
	{
		alert("Please enter valid data in "+ getfieldname(o.name) + "  like  " + getfieldmessage(o.name));
		//o.value="";
		o.focus();
		return false;
	}
	}
	return true;		
}	

//END ALPHANUMERICS WITH SPECIAL CHARACTER "-","."," ","#","/",",","@",":","(",")","[","]" FUNCTION
//*********************************************************************************

function mytrimval(val)
{
	while(val.charAt(0)==" ")
	 {
		val=val.slice(1);
	 }
	while(val.charAt(val.length-1)==" ")
	 {
		val=val.slice(0,-1);
	 }
	 if(val.length==0) val="0";
	return val;
}  



function checkemail(o) {

		//	trim(o);
			emailStr=o.value;
		
	
	if(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 is invalid (check @ and .'s)")
		//if(typeof(o)=="object")
		o.focus();
		return false
	    }
		var user=matchArray[1]
		var domain=matchArray[2]
		if (user.match(userPat)==null) {
	    alert("Email - Username doesn't seem to be valid.")
	    //if(typeof(o)=="object")
	    o.focus();
	    return false
		}
		var IPArray=domain.match(ipDomainPat)
		if (IPArray!=null){
	      for (var i=1;i<=4;i++) {
		    if (IPArray[i]>255) {
		        alert("Email - Destination IP address is invalid!")
		       // if(typeof(o)=="object")
		        o.focus();
				return false
		    }
	    }
	   return true
	}
	var domainArray=domain.match(domainPat)
	if (domainArray==null) {
		alert("Email - Domain name doesn't seem to be valid.")
		//if(typeof(o)=="object")
		o.focus();
		alert(emailStr);
		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) {
	   alert("Email address must end in a three letter domain or two letter country.")
	   //if(typeof(o)=="object")
	   o.focus();
	   return false
	}
	if (len<2) {
	   var errStr="Email - address is missing a hostname!"
	   alert(errStr)
	   //if(typeof(o)=="object")
	   o.focus();
	   return false
	}
	if(isEmail(emailStr)==false)
		{
			alert("Email address is invalid");
		//	if (typeof(o)=="object")
		//	{
				o.focus();
				o.select();
		//	}
			return false;
		}
  }
return true;
}
function isEmail(string) {
    if (string.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1)
        return true;
    else
        return false;
}


// this function checkes wheather valid date is selected.

function isDate(cmbD,cmbM,cmbY)
{
	eval("VDate=document.forms[0]."+cmbD+".options(document.forms[0]."+cmbD+".selectedIndex).value");
	eval("VMonth=document.forms[0]."+cmbM+".options(document.forms[0]."+cmbM+".selectedIndex).value");
	eval("VYear=document.forms[0]."+cmbY+".options(document.forms[0]."+cmbY+".selectedIndex).value");

	if(VDate=="NONE" || VMonth=="NONE" || VYear=="NONE")
	{
		return false;
	}

	if(VMonth==4 || VMonth==6 || VMonth==9 || VMonth==11)
	{
		if(parseInt(VDate)==31)
		{
			return false;
		}
	} 
	if(VMonth==2)	//For Feb.
	{
		if((parseInt(VYear) % 4)!=0)
		{
			if(parseInt(VDate)>28)
			{
				return false;
			}
		}
		else if((parseInt(VYear) % 400)==0)
		{
			if(parseInt(VDate)>29)
			{
				return false;
			}
		}
		else if((parseInt(VYear) % 100)==0)
		{
			if(parseInt(VDate)>28)
			{
				return false;
			}
		}
		else
		{
			if(parseInt(VDate)>29)
			{
				return false;
			}
		}
	}
	return true;
}  

// this function compares if Date 1 > Date2
function isGreater(cmbD1,cmbM1,cmbY1,cmbD2,cmbM2,cmbY2)
{


	eval("VDate=document.forms[0]."+cmbD1+".options(document.forms[0]."+cmbD1+".selectedIndex).value");
	eval("VMonth=document.forms[0]."+cmbM1+".options(document.forms[0]."+cmbM1+".selectedIndex).value");
	eval("VYear=document.forms[0]."+cmbY1+".options(document.forms[0]."+cmbY1+".selectedIndex).value");

	eval("curdate=document.forms[0]."+cmbD2+".options(document.forms[0]."+cmbD2+".selectedIndex).value");
	eval("curmonth=document.forms[0]."+cmbM2+".options(document.forms[0]."+cmbM2+".selectedIndex).value");
	eval("curyear=document.forms[0]."+cmbY2+".options(document.forms[0]."+cmbY2+".selectedIndex).value");


	if(parseInt(VYear)>parseInt(curyear))
	{
		return false;
	}
	if(parseInt(curyear)==parseInt(VYear))
	{
		if(parseInt(VMonth)>parseInt(curmonth))
		{
			return false;
		}
		if(parseInt(curmonth)==parseInt(VMonth))
		{
			if(parseInt(VDate)>parseInt(curdate))
			{
				return false;
			}
		}
	}
	return true;
}


// this function compares date with current date

function isGreaterCD(cmbD1,cmbM1,cmbY1)
{
var d=new Date();

	eval("VDate=document.forms[0]."+cmbD1+".options(document.forms[0]."+cmbD1+".selectedIndex).value");
	eval("VMonth=document.forms[0]."+cmbM1+".options(document.forms[0]."+cmbM1+".selectedIndex).value");
	eval("VYear=document.forms[0]."+cmbY1+".options(document.forms[0]."+cmbY1+".selectedIndex).value");

	curdate=d.getDate()-1;
	curmonth=d.getMonth()+1;
	curyear=d.getFullYear();

	if(parseInt(VYear)>parseInt(curyear))
	{ 
		return false;
	}
	if(parseInt(curyear)==parseInt(VYear))
	{
		if(parseInt(VMonth)>parseInt(curmonth))
		{
			return false;
		}
		if(parseInt(curmonth)==parseInt(VMonth))
		{
			if(parseInt(VDate)>parseInt(curdate))
			{
				return false;
			}
		}
	}
	return true;
}


function isCurDate(cmbD1,cmbM1,cmbY1)
{
var d=new Date();

	eval("VDate=document.forms[0]."+cmbD1+".options(document.forms[0]."+cmbD1+".selectedIndex).value");
	eval("VMonth=document.forms[0]."+cmbM1+".options(document.forms[0]."+cmbM1+".selectedIndex).value");
	eval("VYear=document.forms[0]."+cmbY1+".options(document.forms[0]."+cmbY1+".selectedIndex).value");

	curdate=d.getDate();
	curmonth=d.getMonth()+1;
	curyear=d.getFullYear();

	if(parseInt(VYear)>parseInt(curyear))
	{ 
		return false;
	}
	if(parseInt(curyear)==parseInt(VYear))
	{
		if(parseInt(VMonth)>parseInt(curmonth))
		{
			return false;
		}
		if(parseInt(curmonth)==parseInt(VMonth))
		{
			if(parseInt(VDate)>parseInt(curdate))
			{
				return false;
			}
		}
	}
	return true;
}


//date validation for text box
//date validation

var dtCh= "/";
var minYear=1900;
var maxYear=2100;

function isInteger(s){
	var i;
    for (i = 0; i < s.length; i++){   
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    // All characters are numbers.
    return true;
}

function stripCharsInBag(s, bag){
	var i;
    var returnString = "";
    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.
    for (i = 0; i < s.length; i++){   
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}

function daysInFebruary (year){
	// February has 29 days in any year evenly divisible by four,
    // EXCEPT for centurial years which are not also divisible by 400.
    return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
}
function DaysArray(n) {
	for (var i = 1; i <= n; i++) {
		this[i] = 31
		if (i==4 || i==6 || i==9 || i==11) {this[i] = 30}
		if (i==2) {this[i] = 29}
   } 
   return this
}

function Datevalid(dtStr)
{
   	var daysInMonth = DaysArray(12)
	var pos1=dtStr.indexOf(dtCh)
	var pos2=dtStr.indexOf(dtCh,pos1+1)
	var strMonth=dtStr.substring(0,pos1)
	var strDay=dtStr.substring(pos1+1,pos2)
	var strYear=dtStr.substring(pos2+1)
	strYr=strYear;
	if (strDay.charAt(0)=="0" && strDay.length>1) strDay=strDay.substring(1)
	if (strMonth.charAt(0)=="0" && strMonth.length>1) strMonth=strMonth.substring(1)
	for (var i = 1; i <= 3; i++)
	{
		if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1)
	}
	month=parseInt(strMonth)
	day=parseInt(strDay)
	year=parseInt(strYr)
	if (pos1==-1 || pos2==-1){
		alert("The date format should be : mm/dd/yyyy");
		return false;
	}
	if (strMonth.length<1 || month<1 || month>12){
		alert("Please enter a valid month");
		return false;
	}
	if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month]){
		alert("Please enter a valid day");		
		return false;	
	}
	if (strYear.length != 4 || year==0 || year<minYear || year>maxYear){
		alert("Please enter a valid 4 digit year between "+minYear+" and "+maxYear);
		return false;
	}
	if (dtStr.indexOf(dtCh,pos2+1)!=-1 || isInteger(stripCharsInBag(dtStr, dtCh))==false){
		alert("Please enter a valid date");
		return false;
	}
//return true;
}

// for trim function

function Trim(s) 
{
  // Remove leading spaces and carriage returns
  
  while ((s.substring(0,1) == ' ') || (s.substring(0,1) == '\n') || (s.substring(0,1) == '\r'))
  {
    s = s.substring(1,s.length);
  }

  // Remove trailing spaces and carriage returns

  while ((s.substring(s.length-1,s.length) == ' ') || (s.substring(s.length-1,s.length) == '\n') || (s.substring(s.length-1,s.length) == '\r'))
  {
    s = s.substring(0,s.length-1);
  }
  return s;
}


/*
//for time validation
function IsValidTime(timeStr) {
// Checks if time is in HH:MM:SS AM/PM format.
// The seconds and AM/PM are optional.
var timePat = /^(\d{1,2}):(\d{2})(:(\d{2}))?(\s?(AM|am|PM|pm))?$/;
var matchArray = timeStr.match(timePat);
if (matchArray == null) {
alert("Time is not in a valid format.");
return false;
}
hour = matchArray[1];
minute = matchArray[2];
second = matchArray[4];
ampm = matchArray[6];

if (second=="") { second = null; }
if (ampm=="") { ampm = null; }

if (hour < 0  || hour > 23) {
alert("Hour must be between 1 and 12. (or 0 and 23 for military time)");
return false;
}
if (hour <= 12 && ampm == null) {
if (confirm("Please indicate which time format you are using.  OK = Standard Time, CANCEL = Military Time")) {
alert("You must specify AM or PM.");
return false;
   }
}
if  (hour > 12 && ampm != null) {
alert("You can't specify AM or PM for military time.");
return false;
}
if (minute<0 || minute > 59) {
alert ("Minute must be between 0 and 59.");
return false;
}
if (second != null && (second < 0 || second > 59)) {
alert ("Second must be between 0 and 59.");
return false;
}
}

*/

//for time validation
function IsValidTime(timeStr) {
// Checks if time is in HH:MM:SS AM/PM format.
// The seconds and AM/PM are optional.
var timePat = /^(\d{1,2}):(\d{2})(:(\d{2}))?(\s?(AM|am|PM|pm|Am|Pm|aM|pM))?$/;
var matchArray = timeStr.match(timePat);
if (matchArray == null) {
alert("Time is not in a valid format.");
return false;
}
hour = matchArray[1];
minute = matchArray[2];
//second = matchArray[4];
ampm = matchArray[6];

//if (second=="") { second = null; }
if (ampm=="") { ampm = null; }

if (hour < 0  || hour > 23) {
alert("Hour must be between 1 and 12. (or 0 and 23 for military time)");
return false;
}
if (hour <= 12 && ampm == null) {
if (confirm("Please indicate which time format you are using.  OK = Standard Time, CANCEL = Military Time")) {
alert("You must specify AM or PM.");
return false;
   }
}
if  (hour > 12 && ampm != null) {
alert("You can't specify AM or PM for military time.");
return false;
}
if (minute<0 || minute > 59) {
alert ("Minute must be between 0 and 59.");
return false;
}
//if (second != null && (second < 0 || second > 59)) {
//alert ("Second must be between 0 and 59.");
//return false;
//}
return true;
}

