	var MinLength;
	var formId;
	 var ctrlId="ctl00$ContentPlaceHolder1$";
	function verify_form(form,frmId)
	{
	   formId=frmId;
			// onsubmit =  "return verify_form(this)" 
		var index=0;
		var html = "";
		//alert('asa');
		for(index=0;index<document.forms[formId].length;++index)
		{
			name =document.forms[formId].elements[index].name;
		//alert(name);
			val = document.forms[formId].elements[index].value;
			compulsory = name.charAt(name.length-2);
			datatyp = name.charAt(name.length-1);
			itm = document.forms[formId].elements[index];
		
			if(name.indexOf("txt")!=-1)
			name=name.substring(name.indexOf("txt"),name.length);
			else if(name.indexOf("img")!=-1)
			name=name.substring(name.indexOf("img"),name.length);
			else
			name=name.substring(name.indexOf("cmb"),name.length);
            MinLength=1;
			charAfterUnder=name.indexOf('_');
						if(name.charAt(charAfterUnder+1)=='m')
			{
			    MinLength=parseInt(name.charAt(charAfterUnder+2));
			}
			   
			
				
				//first to check the cumpulsory field
				if(compulsory=='c')
				{
					if(!verify_length(index))
					{
						html= html+"Error: Please fill field ' ";
						if (MinLength>1)
						{
						html=html+write_string_removing_underscore(name.substring(3,name.length-4));
						html=html+" with minimum "+String(MinLength)+" characters"
						}
						else
						{
						if(datatyp=='i'){
						html= "Error: Please select any ' ";
						html= html+write_string_removing_underscore(name.substring(3,name.length-2));
						}
						else
						html= html+write_string_removing_underscore(name.substring(3,name.length-2));
						}
						//html= html+document.forms[0].elements[index].name;
						html= html+"'";
						if (itm.disabled==false)
						{
						alert(html);
					//	itm.style.borderColor='green';
						itm.focus();						
						return false;
						}
					}
				}
				//for number and cumpulsory field
				if(datatyp=='n' && compulsory=='c')
				{
					if(!verify_number(index))
					{
						html= html+"Error : Please fill field ";
						html= html+write_string_removing_underscore(name.substring(3,name.length-2));
						html= html+"With Numeric data..";
						alert (html);
						itm.focus();						
						return false;
					}
				}
				//For Number and optional field
				if(datatyp=='n' && compulsory=='o')
				{
					if(verify_length(index))
					{
						if(!verify_number(index))
						{
							html= html+"Error : Please fill field ";
							html= html+write_string_removing_underscore(name.substring(3,name.length-2));
							html= html+"With Numeric data..\n";
							alert (html);
							itm.focus();							
							return false;
						}
					}
				}
				//For email and cumpulsory field
				if(datatyp=='e' && compulsory=='c')
				{
					if(verify_length(index))
					{
						if(!verify_email(val))
						{
							html= html+"Error : Please fill field ";
							html= html+write_string_removing_underscore(name.substring(3,name.length-2));
							html= html+"With Valid email format..\n";
							alert (html);
							itm.focus();							
							return false;
						}
					}
				}
				//For email and cumpulsory field
				if(datatyp=='e' && compulsory=='o')
				{
					if(!verify_email(val))
					{
						html= html+"Error : Please fill field ";
						html= html+write_string_removing_underscore(name.substring(3,name.length-2));
						html= html+"With Valid email format..\n";
						alert (html);
						itm.focus();						
						return false;
					}
				}
		
				//For date and cumpulsory field
				if(datatyp=='d' && compulsory=='c')
				{
					if(verify_length(index))
					{
						if(!verify_date(name,val))
						{
						   
							html= html+"Error : Please fill field ";
							html= html+write_string_removing_underscore(name.substring(3,name.length-3));
							html= html+"With Valid Date format..\n";
							alert (html);
							itm.focus();							
							return false;
						}
//						if(!CompareDate(name,val))
//						{
//					   
//							html= html+"Error : Please fill field ";
//							html= html+write_string_removing_underscore(name.substring(3,name.length-3));
//							if(name.charAt(name.length-3)=="a")
//							 html= html+"With Current or Future Date";
//							else
//							  html= html+"With Current or Past Date";
//							alert (html);
//							itm.focus();							
//							return false;
//						}
						
						
					}
				}
				//For date and cumpulsory field
				if(datatyp=='d' && compulsory=='o')
				{
				 if(verify_length(index))
				  {
					
					if(!verify_date(name,val))
					{
						html= html+"Error : Please fill field ";
						html= html+write_string_removing_underscore(name.substring(3,name.length-2));
						html= html+"With Valid date format..\n";
						alert (html);
						itm.focus();						
						return false;
					}
				  }
				}
				//For time and cumpulsory field
				
				//for re-type password For matching of passwords
				if(datatyp=='p' && compulsory=='c')
				{
				   	 
				
				  	 if(!verify_password(itm))
						  {
						    html= html+"Error : Password doesn't match ";
						   // html= html+write_string_removing_underscore(name.substring(3,name.length-2));
						    //html= html+"With the same password as above..\n";
						    alert (html);
						    itm.focus();				
						    return false;
					      
					       }
					
				}
				//used for combo box
				if(datatyp=='c' && compulsory=='c')
				{
				   	
				  	 if(itm.selectedIndex==0)
						  {
						    html= html+"Error : Please select any ";
						    html= html+write_string_removing_underscore(name.substring(3,name.length-2));
						    alert (html);
						    itm.focus();	
						    return false;
					      }
				}
					//for file and compulsory
            	if(datatyp=='f' && compulsory=='c')
				{
				
                    if (itm.disabled==false)
					{
						if(!verify_FileExt(val))
					      {
						    html= html+"Error : Please select ";
						    html= html+write_string_removing_underscore(name.substring(3,name.length-2));
						    html= html+" with extension (.jpeg) or (.doc) or (.pdf) or (.xls) or (.ppt) .\n";
						                     
							alert (html);
						    itm.focus();				
						    return false;
					      }
			        }
				}
				
				//for negative decimal numbers and compulsory
				if(datatyp=='u' && compulsory=='c')
				{
			
					     if(!verify_negativenum(val))
					      {
						    html= html+"Error : Please fill field ";
						    html= html+write_string_removing_underscore(name.substring(0,name.length-2));
						    html= html+"With Valid point format..\n";
				    		alert (html);
						    itm.focus();				
						    //itm.style.borderColor='red';		
						    return false;
					      }
				
				}
				//for negative decimal number and optional field
            	if(datatyp=='u' && compulsory=='o')
				{
				if(verify_length(index))
				   {
					     if(!verify_negativenum(val))
					      {
						    html= html+"Error : Please fill field ";
						    html= html+write_string_removing_underscore(name.substring(0,name.length-2));
						    html= html+"With Valid point format..\n";
							alert (html);
						    itm.focus();				
						    itm.style.borderColor='red';		
						    return false;
					      }
				    }
	            }
	            //for website url
            	if(datatyp=='w' && compulsory=='o')
				{
				if(verify_length(index))
				   {
					     if(!verify_Url(val))
					      {
						    html= html+"Error : Please fill field ";
						    html= html+write_string_removing_underscore(name.substring(3,name.length-2));
						    html= html+"With Valid Internet Url(e.g www.e-creatorz.com) .\n";
							alert (html);
						    itm.focus();				
						    return false;
					      }
				    }
	            }
	             //for Image field
            	if(datatyp=='i' && compulsory=='o')
				{
				if(verify_length(index))
				   {
					     if(!verify_image(val))
					      {
						    html= html+"Error : Please select ";
						    html= html+write_string_removing_underscore(name.substring(3,name.length-2));
						    html= html+" with extension (.gif) or (.jpeg) or (.png) or (.tiff) .\n";
						                     
							alert (html);
						    itm.focus();				
						    return false;
					      }
				    }
	            }
	            	if(datatyp=='i' && compulsory=='c')
				{
				       if (itm.disabled==false)
					{
					     if(!verify_image(val))
					      {
						    html= html+"Error : Please select ";
						    html= html+write_string_removing_underscore(name.substring(3,name.length-2));
						    html= html+" with extension (.gif) or (.jpeg) or (.png) or (.tiff) .\n";
						                     
							alert (html);
						    itm.focus();				
						    return false;
					      }
				}
				    
	            }
		/////////////////////////////////end of checks //////////////////////////
		}
		return true;
	}
	function verify_length(index)
	{
		var val=document.forms[formId].elements[index].value.length;
		if(val<MinLength ||val==null)
			return false;
		return true;
	}
	function verify_number(index)
	{
	var val=document.forms[formId].elements[index].value;
	 var number=/^[0-9]*$/;
	     if(val.search(number)==-1)
	         return false;
	     return true;  
//		var val=document.forms[formId].elements[index].value;
//		alert(val);
//		var ver=parseInt(val);
//		if(ver>=0 ||ver <0)
//			return true;
//		return false;
	}
	function write_string_removing_underscore(str)
	{
		var stringtemp = "";
		for(var i=0;i<str.length;++i)
		{
			ch=str.charAt(i);
				if(ch!='_')
				{stringtemp = stringtemp+ch;}
				else
				stringtemp = stringtemp+" ";
		}
		return stringtemp;
	}
	
	function verify_comma(str)
	{
		if(str.indexOf("'")==-1)return true;
		return false;		
	}
	
	function verify_email(email)
	{
		var REemail=/\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/
		if (email.search(REemail)==-1)
      		return false;
		else
			return true;
		
	}	
				
	function verify_date(name,date)
	{
		
			var arrdate= new Array();
			arrdate=date.split("/");
				var year=arrdate[2];
				//date.substring(6,10);
				var month=arrdate[1];
				//date.substring(3,5);
				var day=arrdate[0];
				//date.substring(0,2);
			
				if( (year>=1900 && year<=2050)  && (month>=1 && month<=12) )

                        {                 

                              if(month==2)

                              {

                                    if(year%4==0 && day>=1 && day<=29)

                                    {

                                          return true;

                                    }

                                    else if(day>=1 && day<=28)

                                    {

                                    

                                          return true;                                                

                                          

                                    }

                                    else

                                    {

                                    return false

                                    }

                              }

      

                              if(month==4||month==6||month==9||month==11)

                              {
                                   
                                    if(day>=1 && day<=30)

                                    {

                                          return true;

                                    }

                                    else

                                    {

                                          return false;

                                    }

                              }

 

                              if(day>=1 && day<=31)

                              {
                                
                                    return true;

                              }

                        }     

                  

                  //}

                  return false;


	}	


	function verify_time(time)
	{
	
		if(time.length==6)
		{
			if(!isNaN(time))
			{
				var hour=time.substring(0,2);
				var minute=time.substring(2,4);
				var second=time.substring(4,6);
			
				if( (hour>=0 && hour<=23) && (minute>=0 && minute<=59) && (second>=0 && second<=59) )
				{
					return true;
				}			
			}
		}
		return false;	
	}
	function verify_password(Repasswd)
	{
	    var passwd_id=document.getElementById(Repasswd.name.substring(0,Repasswd.name.length-1)+"s");
	    if(Repasswd.value==passwd_id.value)
	            return true;
	    return false;
	}
	function SetFocus(btnid){
    if(event.keyCode ==13)
   document.getElementById(btnid).focus();
}
function RemoveSpaces(){

    if(event.keyCode == 32)event.returnValue=false; else event.returnValue=true;
}

 function verify_floatingnum(num)
	{
	     var floatingnumber=/^[0-9]*.?\d{1,2}$/;
	     if(num.search(floatingnumber)==-1)
	         return false;
	     return true;   
	}
	function verify_negativenum(num)
	{
	    var negativenumber=/^-?[0-9]*.?\d{1,2}$/;
	     if(num.search(negativenumber)==-1)
	         return false;
	     return true; 
	}
	function verify_Url(Url)
	{
		//var Weburl=/http(s)?:/([\w-]+\.)+[\w-]+(/[\w- ./?%&=]*)?/;
		var Weburl=/^[a-z0-9\-]+(\.[a-z0-9\-]+)*(\.[a-z]{2,3})+$/;
		if(Url.search(Weburl)==-1)
	         return false;
	     return true; 
	}
	//Used for just allow number only
	function AllowNumber(){
    if(event.keyCode > 47 && event.keyCode < 58)event.returnValue=true; else event.returnValue=false;
   
    }
    //compare date with current date
     function CompareDate(name,date)
    {
        var nowdate=new Date();
		var arrdate= new Array();
		 var lessMonth,lessDay,lessYear;
			 var grMonth,grDay,grYear;
		arrdate=date.split("/");
		//a for after today date
		if(name.charAt(name.length-3)=="a")
            {
                  grDay=parseInt(arrdate[1]);
                grMonth=arrdate[0];
                grYear=arrdate[2];
                lessDay=parseInt(nowdate.getDate())
                lessMonth=parseInt(nowdate.getMonth())+1
                lessYear= nowdate.getFullYear()
              
            } 
            else
            {
                             
                lessDay=parseInt(arrdate[1]);
                lessMonth=arrdate[0];
                lessYear=arrdate[2];
                grDay=parseInt(nowdate.getDate())
                grMonth=parseInt(nowdate.getMonth())+1
                grYear= nowdate.getFullYear()
            }       
           
              if (lessYear>grYear)return false;
              if(lessYear==grYear && lessMonth>grMonth)return false;
             // if (lessYear==grYear && lessMonth==lessMonth)
          //    alert(lessMonth+';'+grMonth);
              if (lessYear==grYear && lessMonth==grMonth && lessDay>grDay)
              {
               
              return false;
              }
              return true;
              
    }
    function AllowMaxLength(obj,MaxLength)
    {
 
     var objLenCh=document.getElementById(obj.name.substring(0,obj.name.length-3)).value;
      
        if (obj.value.length<=MaxLength || event.keyCode==8)
        {
            document.getElementById(obj.name.substring(0,obj.name.length-3)).value=MaxLength-obj.value.length;
            event.returnValue=true; 
        }
        else
        {
           document.getElementById(obj.name.substring(0,obj.name.length-3)).value=MaxLength-obj.value.length;
         event.returnValue=false;
        }
    }
    function CheckLength(obj,MaxLength)
    {
        if(obj.value.length>MaxLength)
        {
            alert("Error:Please Enter Max "+String(MaxLength)+" Characters");
            obj.focus();
        }
    }
    
    function verify_image(ImgValue)
    {
   
                     var file=ImgValue;
                    var splitFile =file.split("\\");
                    var fileName=splitFile.pop();
                    var splitExt=fileName.split(".");
                    var fileExt=splitExt.pop();
                 if(fileExt=="gif" || fileExt=="jpeg"|| fileExt=="jpg" || fileExt=="GIF" || fileExt=="JPEG"|| fileExt=="JPG" || fileExt=="png" || fileExt=="tiff")
                       return true;                   
                  else
                      return false;      
                        
         
    }
 						
    function verify_FileExt(ImgValue)
    {
   
                     var file=ImgValue;
                    var splitFile =file.split("\\");
                    var fileName=splitFile.pop();
                    var splitExt=fileName.split(".");
                    var fileExt=splitExt.pop();
                    fileExt=fileExt.toLowerCase();
                 if(fileExt=="doc" || fileExt=="jpeg"|| fileExt=="jpg" || fileExt=="pdf" || fileExt=="xls"|| fileExt=="ppt" )
                       return true;                   
                  else
                      return false;      
                        
         
    }
    //for multiple email with comma seperated
    function Verify(oSrc,args)
{
    var Emails=args.Value;
    var splitEmails=Emails.split(",");
   
    for(var i=0;i<splitEmails.length;i++)
       {
                
        if(!verify_email(splitEmails[i]))
         {
             alert("Please Enter a Valid Email");
             args.IsValid=false;
         }
       }
}
function CompareDateStartEnd(date1,date2)
    {
   
        var arrdate1 = new Array();
        var arrdate2 = new Array();
		var Month1,Day1,Year1;
		var Month2,Day2,Year2;
		
		arrdate1=date1.split("/");
		arrdate2=date2.split("/");
		
		Day1=arrdate1[1];
        Month1=arrdate1[0];
        Year1=arrdate1[2];
        
        Day2=arrdate2[1];
        Month2=arrdate2[0];
        Year2= arrdate2[2];
        //alert(Day1,Month1,Year1);
        if (Year1>Year2)return false;
        if(Year1==Year2 && Month1>Month2)return false;
        if (Year1==Year2 && Month1==Month2 && Day1>Day2)return false;
        return true;              
    }
    
    function CheckStartEndDate(txtDTTo,txtDTFrom)
        {
        // alert(txtDTTo.value);
                
                if(txtDTTo.value.length>0 && txtDTFrom.value.length>0)
                {
                //alert(txtDTTo.value);
                if(verify_date(txtDTTo,txtDTTo.value) && verify_date(txtDTFrom,txtDTFrom.value))
                    {
                    //alert(txtDTTo.value);
                            if(CompareDateStartEnd(txtDTTo.value,txtDTFrom.value))
                            {
                    //        alert(txtDTTo.value);
                                    return true;
                            }
                            else
                            {
                                          
                                    alert("Incorrect Date Range");
                                    txtDTFrom.focus();
                                    return false;
                            }
                    }
                    else
                    {
                    alert ("Error : Please fill field Date With Valid Date format i.e (mm/dd/yyyy)");
                    txtDTTo.focus();
					return false;
                    }               
                }            
        }
function CheckLoginUser(formid)
{
    if(document.getElementById("txtUserName_cs")==null)
    {
        return verify_form('form',formid); 
    } 
    return true;   
}

