	
function _VerifyData(alphabet,number,deci,space,e)
{
	var correctData=false;
	if(e.which)
	{
		if (number == 1)
		{
			if (e.which > 47 && e.which < 58) 
				{
					correctData = true;
				}
		}
		if(deci == 1)
		{
			if ( e.which == 46) 
				{
					correctData = true;
				}
		}
		if(alphabet == 1)
		{
			if ((e.which > 64 && e.which < 91) || (e.which > 96 && e.which < 123)  || (e.which == 45))
				{
					correctData = true;
				}
		}	
		if ( e.which == 8) 
				{
					correctData = true;
				}
		if (space == 1)
		{		
			if ( e.which == 32) 
				{
					correctData = true;
				}		
		}
	 
	}
	else
	{
		if (number == 1)
		{
			if (event.keyCode > 47 && event.keyCode < 58) 
				{
					correctData = true;
				}
		}
		if(deci == 1)
		{
			if ( event.keyCode == 46) 
				{
					correctData = true;
				}
		}
		if(alphabet == 1)
		{
			if ((event.keyCode > 64 && event.keyCode < 91) || (event.keyCode > 96 && event.keyCode < 123)  || (event.keyCode == 45))
				{
					correctData = true;
				}
		}	
		if ( event.keyCode == 8) 
				{
					correctData = true;
				}
		if (space == 1)
		{		
			if ( event.keyCode == 32) 
				{
					correctData = true;
				}		
		}
	
	}		
	return correctData;	
}

//Created by karan 
// Both the functions Works similarly, can use any one
function validateURL(id)
{
	var Weburl=document.getElementById(id).value;
	var lengthValue = Weburl.length;
	if(lengthValue != 0)
	{
		var j = new RegExp();
		j.compile("^[A-Za-z]+://[A-Za-z0-9-]+\.[A-Za-z0-9]+"); 
		if(Weburl.indexOf("http://")!=-1)
		{
			if (!j.test(Weburl))
			{ 
				alert("Please enter valid URL.");
				return false;
			}
		}
		else
		{
			Weburl= "http://"+Weburl;
			if (!j.test(Weburl))
			{ 
				alert("Please enter valid URL.");
				return false;
			}
		}		
	}
}

function isUrl(Weburl)
{
	var regexp = /(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/
	/*if(Weburl.indexOf("http://")==-1)
	{
		Weburl= "http://"+Weburl;
	}*/
	return regexp.test(Weburl);
}

	
function CheckValidTo(id)
 {
	var dat = document.getElementById(id).value;
	var dt = new Date();
	var entrdate,curdate;
	if(dat.indexOf("-") != -1)
	{
		var d1 = dat.split('-');
		entrdate = new Date(d1[2],d1[0]-1,d1[1]);
		curdate = new Date(dt.getFullYear(),dt.getMonth(),dt.getDate());
	}
	else
	{
		var d1 = dat.split('/');
		entrdate = new Date(d1[2],d1[0]-1,d1[1]) ;
		curdate = new Date(dt.getFullYear(),dt.getMonth(),dt.getDate());		
	}
	if(entrdate >= curdate)
	{
		return true;
	}
	else
	{
		alert('Please Enter Current or Future Date');
		return false;
	} 
 }

function CheckFiles(id)
{
	
	var filename = document.getElementById(id).value;
	if(filename=="")
	{
		alert("Please Browse an Image");
		return false;
	}
	var ext = filename.substring(filename.lastIndexOf('.')+1);
	if(ext == "jpg" || ext == "JPG" || ext == "GIF" || ext =="gif")
	{
		return true;
	}
	else
	{
		alert("Upload jpg or gif images Only");
		document.getElementById(id).focus();
		return false;
	}
	return true;			
}

function CheckExcelFiles(id)
{
	
	var filename = document.getElementById(id).value;
	if(filename=="")
	{
		alert("Please Browse an Excel File");
		return false;
	}
	var ext = filename.substring(filename.lastIndexOf('.')+1);
	if(ext == "xls" || ext == "XLS" )//|| ext == "xlsx" || ext =="XLSX" || ext == "ods" || ext == "ODS")
	{
		return true;
	}
	else
	{
		alert("Upload Excel Files Only");
		document.getElementById(id).focus();
		return false;
	}
	return true;			
}

 
function trim(str)
{
 var strReturn = str ;
 var i = 0 ;
 for(i = 0;i< strReturn.length;i++)
 {
  if(!(strReturn.charAt(i)==' '))
   break ;
 }
 strReturn = strReturn.substring(i);
 for(i = strReturn.length ; i>0 ; i--)
 {
  if(!(strReturn.charAt(i-1)==' '))
   break;
 }
 strReturn = strReturn.substring(0,i);
 return strReturn;

}

function isEmail( theValue )
		{
			var chk_mail = "true";
			var ch = "";
			var at = "";
			var dot="";
			//theValue = trim(theValue) ;  /* ------  removes leading & trailing spaces ------ */
			var theLen = theValue.length ;
			
						
			if(theValue.indexOf('@', 0) == -1)  /*---- if @ is not present ---- */
			{
				alert("Email Must Contain Domain Name");
				return(false) ;
			}
			if(theValue.charAt(0)=='@' || theValue.charAt(theLen)=='@' || theValue.charAt(theLen-1)=='@')
			{
				alert("@ Not Allowed At Start or End of Email") ;
				return false ;
			}
			
			/* ------  no dot allowed at start, end  ------ */
			if(theValue.charAt(0)=='.' || theValue.charAt(theLen)=='.' || theValue.charAt(theLen-1)=='.')
			{
				alert("Dot(.) Not Allowed At Start or End of Email") ;
				return false ;
			}
			
			at = theValue.indexOf('@', 0) ;

			dotat=theValue.indexOf('.',0) ;	

			if( theValue.charAt(dotat+1) == '.' || theValue.charAt(dotat+1) == '@' )
			{
				alert("Dot and @ are not Allowed immediately following the Dot in Email") ;
				return false ;
			}

			/*  ----  no @ or dot allowed following @ ----  */
			if( theValue.charAt(at+1) == '.' || theValue.charAt(at+1) == '@' )
			{
				alert("Dot and @ are not Allowed Immediately Following the @ in Email") ;
				return false ;
			}
				
			if ((theValue.indexOf('@', at+1))!=-1)  /* ---  multiple @ in email-id  ---  */
			{
				alert("Multiple @ are not Allowed in Email ");
				return false ;
			}	
			
			/* ------  no @ allowed at start, end  ------ */
			
						
			if(theValue.indexOf(" ",0) != -1)  /* ---- blank spaces present in email-id  ----  */
			{
				alert("Blank Spaces Are Not Allowed in Email") ;
				return false ;
			}

			for (k = 0 ; k < theLen ; ++k)
			{
				ch =  theValue.substring(k, k+1)
				if (ch =="@")
				{
					if(theValue.substring(k, theLen)=='@')
					{
						return false ;
					}
					if(theValue.indexOf('.', k) == -1) /* --- dot not present after @ ---  */
					{
						alert("Invalid Email Id")
						return false ;
					}
				}
				
				/*  ------  no dot allowed immediately following @  ------  */
				if ((ch == '.')&&(theValue.substring(k+1, k+2) == "."))
				{
					alert("Consecutive Dots Are Not Allowed in Email") ;
					dot = k
					return false ;					
				}

				if (!( (ch >= 'a' && ch <= "z") || (ch >= 'A' && ch <= "Z") || (ch >= '0' && ch <= "9") || ch =="@" || ch =="." || ch =="_" || ch =="-" ))
				{
					alert("No Special Characters Allowed Except @ and Dot(.)") ;
					return false ;					
				}
			}  /* ---  end of for loop  ---  */

			for(var j=theValue.indexOf('.', at);j<=theLen;++j)
			{
				if(theValue.charAt(j)>='0' && theValue.charAt(j)<='9')
				{
					alert("Invalid domain name  ");
					return false;
					break;
				}
			}

			return true            /*  ------ if no above condition found to be true ------  */
		}  //   end of isEmail()


function isAlphabetic(str)
	// returns true if str is alphabetic
	// that is only A-Z a-z or space
	// returns false otherwise
	// returns false if empty
	{
		var len= str.length;
		if (len==0)
		return false;
		//else
		var p=0;
		var ok= true;
		var ch= "";
		while (ok && p<len)
		{
		ch= str.charAt(p);
		if (  ('A'<=ch && ch<='Z')
		||('a'<=ch && ch<='z')
		||(ch==" ")
		)
		p++;
		else
		ok= false;
		}
		return ok;
	}	
	
function number1(e)
{
	if(e.which)
	{		
		if (e.which < 45 || e.which > 57)
			return false;
	}
	else
	{
		if (e.keyCode < 45 || e.keyCode > 57) 
			return false;
	}
 }
 
function NumericKeyPress(e)
{
	if(e.which)
	{
		if (e.which < 45 || e.which > 57) 
			return false;
	}
	else
	{
		if (e.keyCode < 45 || e.keyCode > 57) 
			return false;
	}
}

function imposeMaxLength(obj,len)
{
	if(obj.value.length>=len)
		return false;
}


function CheckUrl(id)
{
	var url=trim(document.getElementById(id).value)	
	if(url.indexOf("http://")==-1)
	{
		url="http://"+url;
	}	
	if((url.indexOf(".")==-1) || (url.length==url.lastIndexOf(".")+1) || (url.indexOf(".")==url.indexOf("http://")+7))
	{		
		alert("Incorrect Url");
		return false;
	}	
	
	var i,ch,count;//Count no. of Dots
	count=0;
	var arr=new Array();
	for(i=0;i<url.length;i++)
	{	
		arr[i]=url.substring(i,i+1);		
		if((arr[i] == "."))
			count++;	
		
		/*ch =  url.substring(i,i+1)		
		if((ch == '.')&&(url.substring(i+1,i+2) == "."))
		{			
			alert("Consecutive Dots are not Allowed in Web Address");
			document.getElementById(id).focus();
			return false;				
		}
		*/				
	}
	for(i=0;i<arr.length-1;i++)
	{		
		if((arr[i] == ".") && (arr[i+1] == "."))
		{
			alert("Consecutive Dots are not Allowed in Web Address");
			document.getElementById(id).focus();
			return false;				
		}
	}
	if(url.indexOf("www")>0 && count < 2)
	{
		alert("Please Enter Domain Name");
		document.getElementById(id).focus();
		return false;
	}	
}

function nospaces(e)
{
	if(e.which)
	{
		if (e.which == 32) 
			return false;					
	}
	else
	{
		if (e.keyCode == 32) 
			return false;
	}
}



