function invalidChars(Val)
	{
		var alp = "*";
		for (var i=0;i<Val.value.length;i++)
		{
			temp=Val.value.substring(i,i+1);
			
			if (alp.indexOf(temp)!=-1)
			{
				
				//var resstr="No special characters \nValid entries are [a-z][A-Z][ space ]";
				return 0;
			}
		} // closing the for loop
	} // closing the function textOnly()

function GenValidation(str,output,divname)
	{
		if(str.value == "")
		{
			var res=output;
			//alert(res);
			document.getElementById(divname).innerHTML = res;
			document.getElementById(divname).style.display = "block";
			return 0;
		}
    }
function textOnly(Val,output,divname)
	{
	//var alp = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ أبتثجحخدذرزسشصضطظعغفقكلمنهـوي أبتثجحخدذرزسشصضطظعغفقكلمنهـوي";
		var alp="~`!#$%^&*()-_+=|\/.><,?1234567890";
	
		for (var i=0;i<Val.value.length;i++)
		{
			temp=Val.value.substring(i,i+1);
			if (alp.indexOf(temp)!=-1)
			{
				//var resstr="No special characters \nValid entries are [a-z][A-Z][ space ]";
				var resstr=output;
				document.getElementById(divname).innerHTML = resstr;
				document.getElementById(divname).style.display = "block";
				return 0;
			}
			
		} // closing the for loop
	} // closing the function textOnly()

function ALPHANUM3(Val,MESG,divname) {
		//var alp = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 ";
		var alp="~`!#$%^&*()-_+=|\/.><,?";
		for (var i=0;i<Val.value.length;i++)
		{
			temp=Val.value.substring(i,i+1);
			if (alp.indexOf(temp)!=-1)
			{
				//var resstr="Please enter a valid "+MESG+" [A-Z] [0-9] Allowed";
				var resstr=MESG;
				//alert(resstr);return false;
				document.getElementById(divname).innerHTML = resstr;
				document.getElementById(divname).style.display = "block";
				return 0;
			}
			//return false;
		} // closing the for loop
	
	}
	 // closing the function SplCharacters()
function validateintegers(Val,MESG,divname) {
	
		var alp = "1234567890 ";
	
		for (var i=0;i<Val.value.length;i++)
		{
			temp=Val.value.substring(i,i+1);
			if (alp.indexOf(temp)==-1)
			{
				var resstr="Please enter a valid "+MESG+" [0-9] Allowed";
				Val.focus();
				document.getElementById(divname).innerHTML = resstr;
				document.getElementById(divname).style.display = 'block';
				return 0;
			}
		} // closing the for loop
	
	}
function validateonlyintegers(Val,MESG,divname) {
	
		var alp = "1234567890+-";
	
		for (var i=0;i<Val.value.length;i++)
		{
			temp=Val.value.substring(i,i+1);
			if (alp.indexOf(temp)==-1)
			{
				//var resstr="Please enter a valid "+MESG+" [0-9] Allowed";
				var resstr=MESG;
				Val.focus();
				document.getElementById(divname).innerHTML = resstr;
				document.getElementById(divname).style.display = 'block';
				return 0;
			}
		} // closing the for loop
	
	}	
	// E-mail Validations
	
	function EmailValidation(Element,output,divname)
	{
	
		Flag  = 1;
		count = 0;
	
		var alp = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_@.-";
		
		if(Element.value.length > 0)
		{
			for (var i=0; i<Element.value.length; i++)
			{
				temp = Element.value.substring(i, i+1);
	
				if (alp.indexOf(temp) == -1)
				{
					Flag = 0;
				}
			} // closing the for loop
		}
		else
		{
			Flag = 0;
		}
	
		for(var i=0; i <= Element.value.length; i++)
		{
			if(Element.value.charAt(0)=='@')
			{
				Flag = 0;
				break;
			}

			if(Element.value.charAt(Element.value.length-1)=='@')
			{
				Flag = 0;
				break;
			}

			if(Element.value.charAt(i)=='@') 
			{
				count = count + 1;

				if(count>1)
				{
					Flag = 0;
					break;
				}
			  
				if((Element.value.charAt(i-1)=='.') || (Element.value.charAt(i+1)=='.'))
				{
					Flag = 0;
					break;
				}
			}
			if(Element.value.indexOf('@')==-1)
			{
				Flag = 0;		    	
				break;
			}
			if(Element.value.charAt(0)=='.')
			{
				Flag = 0;
				break;
			}
			if(Element.value.indexOf('.')==-1)
			{
				Flag = 0;		    	
				break;
			}
		  } //closing the for loop
		
		if(Element.value.charAt(Element.value.length-1) == '.')
			Flag = 0;
			
			var val=Element.value;
			var len=Element.value.length;
			var dotcheck1=val.substring(len-4,len-3);
			var dotcheck2=val.substring(len-3,len-2);
			//alert(dotcheck1);
			//alert(dotcheck2);
		if(dotcheck1!='.' && dotcheck2!=".")
		{
			Flag = 0;
			
		}
			
			
			
		if(Flag == "0")
		{
			//resstr="Please enter a valid Email Address";
			resstr = output;
			Element.focus();
			document.getElementById(divname).innerHTML = resstr;
			return 0;
		}	
		else
			return 1;
	}
////////////////   Date Validation
function DateValidation(dd, mm, yy, msg) {
	
	   
	/* if(NumValidation(dd,'Date','','num') == 0)
	 return 0;
	 
	 if(NumValidation(mm,'Month','','num') == 0)
	 return 0;
	 
	 if(NumValidation(yy,'Year','','num') == 0)
	 return 0;*/
	 
	 d = parseInt(dd.value);
	 m = parseInt(mm.value);
	 y = parseInt(yy.value);
	 
	 if(m > 12 || m == 0) {
		alert("Invalid month selected for " + msg);
		mm.focus();
		return 0;
	 }
	 else {
	 
	 var vDays = [ 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 ];
	 var flag = 0;
	 if(m == 2) {
		if(isLeapYear(y)) {
		  if( d > 29 || d < 1 ) {
		   flag = 0;
		  }
		  else {
		   flag = 1;
		  }
		}
		else if( d > vDays[m] || d < 1 ) {
		 flag = 0;
		}
		else {
			 flag = 1;
		}
	 }
	 else {
		if( d > vDays[m] || d < 1 ) {
		 flag = 0;
		}
		else {
		 flag = 1;
		}  
	 }
	 }
	 if(flag == 0) {
	
		alert("Invalid Date Selected");
		dd.focus();
		return false;
	 }
	 else {
		return 1;
	 }
	 
	 
	} 
	
function isValidDate(dd, mm, yy)
	{
		/*
			This fucntion can be used for date validations.
	
			INPUT:	Day in numeric format [d]
						Month in numeric format [m]
						4 digit year [y]
	
			OUTPUT: Returns true if the date is valid else false.
	
			USAGE:
						isValidDate( 1, 4, 2001 )	- Returns true
	
						isValidDate( 1, 13, 2002 )	- Returns false coz month is > 12
						
						isValidDate( 30, 2, 2001)	- Returns false coz Feb will never have 30th
		*/
	
		var d = parseInt(dd);
		var m = parseInt(mm);
		var y = parseInt(yy);
		
		
		/*if( isNaN(d) || isNaN(m) || isNaN(y) )
alert("Please select date");
			return false;
			
		if( d <= 0 || m <= 0 || y <=0 )
		
			return false;
		
		if( d > 31 || m > 12 )

			return false;
	
		if( y < 1000 || y > 9999 )
			return false;
	*/
		var vDays = [ 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 ];
		
		if( m == 2 )
		{
			
			if( isLeapYear(y) )
			{
				if( d > 29 || d < 1 )
				{
					return false;
				}
				else
				{
					return true;
				}
			}
			else if( d > vDays[m] || d < 1 )
			{
				return false;
			}
			else
			{
				return true;
			}
		}
		else if( d > vDays[m] || d < 1 )
		{
			return false;
		}
		else
		{
			return true;
		}
	}
  ///////	End isValidDate
function isLeapYear(y)
	{
		 if( y % 4 == 0) 
		 {
			if( y % 100 == 0 ) 
			{
				 if( y % 400 == 0) 
				 {
					  return true;
				 }
				 else
				 {
					  return false;
				 }
			}
			else 
			{
				return true;
			}
		 }
		 else 
		 {
			return false;
		 }
	} // closing the function isLeapYear()
	
	
	function urlValidation(str,output,divname)
{
	   var totalstring=str.value;
	   var l=totalstring.length;
	   var t= totalstring.substring(l-3,l-2);
	   var f= totalstring.substring(l-4,l-3);
	   var enddot= totalstring.substring(l,l-1);
	   if(t!='.' && f!='.' || enddot=='.')
	   {
			var res= output;
			document.getElementById(divname).innerHTML = res;
			document.getElementById(divname).style.display = "block";
			return 0;
	   }
}
