// JavaScript Document

function validate_form(thisform)
	{
	
	with(thisform)
		{
	    
		////////////////////Null Check 
			
	 //    if (Email_Exist(email,"Given Email id is already registered with us, Please type another email id...!!!")==false)
		// {
	//	 	  email.focus();
	////	      return false;
		
		// }
	///;/
		
		 if (validate_required(Fname,"Please Enter the First Name...!!!")==false)
		 {
		 	  Fname.focus();
		      return false;
		
		 }
	    
		
		 if (validate_required(Lname,"Please Enter the Last Name...!!!")==false)
		 {
		 	  Lname.focus();
		      return false;
		
		 }
	      if (validate_required(Address,"Please Enter the Address Field..!!!")==false)
		  {
		  	Address.focus();
			  return false;
			
		  }
		  
		     if (validate_required(Ccode,"Please Enter the Contry Code..!!!")==false)
		  {
			  Ccode.focus();
		  	  return false;

		  }
		 
		  
		  
	  if (validate_required(city,"Please Enter the city..!!!")==false)
		  {
			  city.focus();
		  	  return false;

		  }
		  
		 if (validate_required(pincode,"Please Enter the pincode..!!!")==false)
		  {
			  pincode.focus();
		  	  return false;

		  }
		  
		   if (validate_required(contry,"Please Enter the contry..!!!")==false)
		  {
			  contry.focus();
		  	  return false;

		  }
		  
		  
	      if (validate_required(Acode,"Please Enter the Area Code..!!!")==false)
		  {
			  Acode.focus();
		  	  return false;

		  }
	      if (validate_required(TelNo,"Please Enter the Telephone Number..!!!")==false)
          {
    			TelNo.focus();
			  return false;

		  }
		       if (validate_required(Mobile,"Please Enter the Mobile Number..!!!")==false)
          {
    			Mobile.focus();
			  return false;

		  }
		  
		     if (validate_required(email,"Please Enter email field..!!!")==false)
          {
    			email.focus();
			  return false;

		  }
		
		 if  (validate_Email(email,"Enter valid E-mail Address..!!")==false)
			{
						  email.focus();
						  return false;
						 
			 }
		   if (validate_required(Your_photo,"Please Upload Photograph...!!!")==false)
		  {    
		     Your_photo.focus();
		  	  return false;
			
		  } 
			 
			 if (validate_required(DOB,"Please Enter the Date of Birth!!!")==false)
		  {    
		     DOB.focus();
		  	  return false;
			
		  } 
		  
		 
	      if (validate_required(Education,"Please Enter the Education...!!!")==false)
		  {Education.focus();
		  	  return false;
			
		  }
		 
		  if (validate_required(Occupation,"Please Enter the Occupation!!!")==false)
		  {Occupation.focus();
		  	  return false;
			
		  }      
		  
		  
		  
		    if (validate_work(previous_work,"Previous Work Maximum 2000 Character...!!!")==false)
		  {		previous_work.focus();
		  	 	return false;
			
		  } 
		  
		     if (validate_required(securityCode,"Enter Security Code..!!!")==false)
		  {		securityCode.focus();
		  	 	return false;
			
		  } 
		  
		    if (isDate(document.form1.DOB.value)==false){
		   document.form1.DOB.focus()
	    	return false
	      }
		  
	 
//if (validate_required(title1,"Please Enter the title field of first Image..!!!")==false)
//		  {   title1.focus();
//		  	  return false;
//			
//		  }     
//		   if (validate_required(title2,"Please Enter the title field of Second Image..!!!")==false)
//		  {   title2.focus();
//		  	  return false;
//			
//		  }   
//		   if (validate_required(title3,"Please Enter the title field of Third Image..!!!")==false)
//		  {   title3.focus();
//		  	  return false;
//			
//		  }   
//		   if (validate_required(title4,"Please Enter the title field of Forth Image..!!!")==false)
//		  {   title4.focus();
//		  	  return false;
//			
//		  }   
//		   if (validate_required(title5,"Please Enter the title field of Fifth Image..!!!")==false)
//		  {   title5.focus();
//		  	  return false;
//			
//		  }   
//	 if (validate_required(Medium1,"Please Enter the Medium field of First Image..!!!")==false)
//		  {   Medium1.focus();
//		  	  return false;
//			
//		  }  
//	if (validate_required(Medium2,"Please Enter the Medium field of Second Image..!!!")==false)
//		  {   Medium2.focus();
//		  	  return false;
//			
//		  }  
//    if (validate_required(Medium3,"Please Enter the Medium field of Third Image..!!!")==false)
//		  {   Medium3.focus();
//		  	  return false;
//			
//		  }  
//		  
//	 if (validate_required(Medium4,"Please Enter the Medium field of Fourth Image..!!!")==false)
//		  {   Medium4.focus();
//		  	  return false;
//			
//		  }  
//	if (validate_required(Medium5,"Please Enter the Medium field of Fifth Image..!!!")==false)
//		  {   Medium5.focus();
//		  	  return false;
//			
//		  } 
//	if (validate_required(hight1,"Please Enter the Hight field of First Image..!!!")==false)
//	     {   hight1.focus();
//		  	  return false;
//			
//		 }
//	 if (validate_required(hight2,"Please Enter the Hight field of Second Image..!!!")==false)
//	     {   hight2.focus();
//		  	  return false;
//			
//		 } 
//    if (validate_required(hight3,"Please Enter the Hight field of Third Image..!!!")==false)
//	     {   hight3.focus();
//		  	  return false;
//			
//		 }
//    if (validate_required(hight4,"Please Enter the Hight field of Fourth Image..!!!")==false)
//	     {   hight4.focus();
//		  	  return false;
//			
//		 } 
//	if (validate_required(hight5,"Please Enter the Hight field of Fifth Image..!!!")==false)
//	     {   hight5.focus();
//		  	  return false;
//			
//		 } 
//		 
//	if (validate_required(width1,"Please Enter the width field of First Image..!!!")==false)
//	     {   width1.focus();
//		  	  return false;
//			
//		 }
//	 if (validate_required(width2,"Please Enter the width field of Second Image..!!!")==false)
//	     {   width2.focus();
//		  	  return false;
//			
//		 } 
//    if (validate_required(width3,"Please Enter the width field of Third Image..!!!")==false)
//	     {   width3.focus();
//		  	  return false;
//			
//		 }
//    if (validate_required(width4,"Please Enter the width field of Fourth Image..!!!")==false)
//	     {   width4.focus();
//		  	  return false;
//			
//		 } 
//	if (validate_required(width5,"Please Enter the width field of Fifth Image..!!!")==false)
//	     {   width5.focus();
//		  	  return false;
//			
//		 } 
//		 
//		 
//		 
//	  if (validate_required(Year1,"Please Enter the Year field of First Image..!!!")==false)
//	     {   Year1.focus();
//		  	  return false;
//			
//		 } 
//	    if (validate_required(Year2,"Please Enter the Year field of Second Image..!!!")==false)
//	     {   Year2.focus();
//		  	  return false;
//			
//		 }
//		 
//	  if (validate_required(Year3,"Please Enter the Year field of Third Image..!!!")==false)
//	     {   Year3.focus();
//		  	  return false;
//			
//		 }
//		 
//	  if (validate_required(Year4,"Please Enter the Year field of Fourth Image..!!!")==false)
//	     {   Year4.focus();
//		  	  return false;
//			
//		 }
//		 
//		   if (validate_required(Year5,"Please Enter the Year field of Fifth Image..!!!")==false)
//	     {   Year5.focus();
//		  	  return false;
//			
//		 }
//		 
//	   if (validate_required(price1,"Please Enter the Price field of First Image..!!!")==false)
//	     {   price1.focus();
//		  	  return false;
//			
//		 }
//		if (validate_required(price2,"Please Enter the Price field of Second Image..!!!")==false)
//	     {   price2.focus();
//		  	  return false;
//			
//		 }
//		if (validate_required(price3,"Please Enter the Price field of Third Image..!!!")==false)
//	     {   price3.focus();
//		  	  return false;
//			
//		 }
//		 if (validate_required(price4,"Please Enter the Price field of Fourth Image..!!!")==false)
//	     {   price4.focus();
//		  	  return false;
//			
//		 }
//		 if (validate_required(price5,"Please Enter the Price field of Fifth Image..!!!")==false)
//	     {   price5.focus();
//		  	  return false;
//			
//		 }
//		if (validate_required(image1,"Please Enter the image field of First Image..!!!")==false)
//	     {   image1.focus();
//		  	  return false;
//			
//		 } 
//		 if (validate_required(image2,"Please Enter the image field of Second Image..!!!")==false)
//	     {   image2.focus();
//		  	  return false;
//			
//		 }
//		 if (validate_required(image3,"Please Enter the image field of Third Image..!!!")==false)
//	     {   image3.focus();
//		  	  return false;
//			
//		 }
//		 if (validate_required(image4,"Please Enter the image field of Fourth Image..!!!")==false)
//	     {   image4.focus();
//		  	  return false;
//			
//		 }	
//		 if (validate_required(image5,"Please Enter the image field of Fifth Image..!!!")==false)
//	     {   image5.focus();
//		  	  return false;
//			
//		 }
		 
		 	 
	  
		 
		 
		 
		 
	  	/////////////////////////////////// finish Null Check --------------
		
		////////// Http Check --------------------------
		
		if (validate_http(Fname,"Http Not allow in Name field!!!")==false)
		 {
		 	  Fname.focus();
		      return false;
		
		 }
		 
		 if (validate_http(Address,"Http Not allow in Address field!!!")==false)
		 {
		 	  Address.focus();
		      return false;
		
		 }
		 
	
		 if (validate_http(Education,"Http Not allow in Education field!!!")==false)
		 {
		 	  Education.focus();
		      return false;
		
		 }
		 if (validate_http(Occupation,"Http Not allow in Occupation field!!!")==false)
		 {
		 	  Occupation.focus();
		      return false;
		
		 }
		 
		 
	
				
		 
		 //  if (validate_http(title1,"Http Not allow in title field of Image 1..!!!")==false)
//		  {   title1.focus();
//		  	  return false;
//			
//		  }     
//		   if (validate_http(title2,"Http Not allow in title field of Image 2..!!!")==false)
//		  {   title2.focus();
//		  	  return false;
//			
//		  }   
//		   if (validate_http(title3,"Http Not allow in title field of Image 3..!!!")==false)
//		  {   title3.focus();
//		  	  return false;
//			
//		  }   
//		   if (validate_http(title4,"Http Not allow in title field of Image 4..!!!")==false)
//		  {   title4.focus();
//		  	  return false;
//			
//		  }   
//		   if (validate_http(title5,"Http Not allow in title field of Image 5..!!!")==false)
//		  {   title5.focus();
//		  	  return false;
//			
//		  }   
//	 if (validate_http(Medium1,"Http Not allow in medium field of Image 1..!!!")==false)
//		  {   Medium1.focus();
//		  	  return false;
//			
//		  }  
//	if (validate_http(Medium2,"Http Not allow in medium field of Image 2..!!!")==false)
//		  {   Medium2.focus();
//		  	  return false;
//			
//		  }  
//    if (validate_http(Medium3,"Http Not allow in medium field of Image 3..!!!")==false)
//		  {   Medium3.focus();
//		  	  return false;
//			
//		  }  
//		  
//	 if (validate_http(Medium4,"Http Not allow in medium field of Image 4..!!!")==false)
//		  {   Medium4.focus();
//		  	  return false;
//			
//		  }  
//	if (validate_http(Medium5,"Http Not allow in medium field of Image 5..!!!")==false)
//		  {   Medium5.focus();
//		  	  return false;
//			
//		  }
//		  
//	 
//	
//		 
//		////////////// Finish Http Check--------------- 
//		
//		//////////////  WWW Word Not Allow
//		
//			if (validate_www(Fname,"www Not allow in Name field!!!")==false)
//		 {
//		 	  Fname.focus();
//		      return false;
//		
//		 }
//		 
//		 if (validate_www(Address,"www Not allow in Address field!!!")==false)
//		 {
//		 	  Address.focus();
//		      return false;
//		
//		 }
//		 if (validate_www(Education,"www Not allow in Education field!!!")==false)
//		 {
//		 	  Education.focus();
//		      return false;
//		
//		 }
//		 if (validate_www(Occupation,"www Not allow in Occupation field!!!")==false)
//		 {
//		 	  Occupation.focus();
//		      return false;
//		
//		 }
//					
//		 
//		   if (validate_www(title1,"www Not allow in title field of Image 1..!!!")==false)
//		  {   title1.focus();
//		  	  return false;
//			
//		  }     
//		   if (validate_www(title2,"www Not allow in title field of Image 2..!!!")==false)
//		  {   title2.focus();
//		  	  return false;
//			
//		  }   
//		   if (validate_www(title3,"www Not allow in title field of Image 3..!!!")==false)
//		  {   title3.focus();
//		  	  return false;
//			
//		  }   
//		   if (validate_www(title4,"www Not allow in title field of Image 4..!!!")==false)
//		  {   title4.focus();
//		  	  return false;
//			
//		  }   
//		   if (validate_www(title5,"www Not allow in title field of Image 5..!!!")==false)
//		  {   title5.focus();
//		  	  return false;
//			
//		  }   
//	 if (validate_www(Medium1,"www Not allow in medium field of Image 1..!!!")==false)
//		  {   Medium1.focus();
//		  	  return false;
//			
//		  }  
//	if (validate_www(Medium2,"www Not allow in medium field of Image 2..!!!")==false)
//		  {   Medium2.focus();
//		  	  return false;
//			
//		  }  
//    if (validate_www(Medium3,"www Not allow in medium field of Image 3..!!!")==false)
//		  {   Medium3.focus();
//		  	  return false;
//			
//		  }  
//		  
//	 if (validate_www(Medium4,"www Not allow in medium field of Image 4..!!!")==false)
//		  {   Medium4.focus();
//		  	  return false;
//			
//		  }  
//	if (validate_www(Medium5,"www Not allow in medium field of Image 5..!!!")==false)
//		  {   Medium5.focus();
//		  	  return false;
//			
//		  }
		  
		  
		
		  
	/////////////////// FINISH 	
		
		////////// text Check --------------------------
		
		  //if (validate_text(address," Special character ' Not allow in Address !!!")==false)
		    // {
		 	// address.focus();
		  // return false;
	
		 // }
		////////////// Finish text Check--------------- 
		
		/////////// Validate Account no------------------
		if (validate_accountno(Mobile,"Mobile Number Must having 10 digits !!!")==false)
		 {  Mobile.focus();  return false; }
		 
		 
		// if (validate_year(Year1,"Year Must having 4 digits !!!")==false)
//		 {
//			  Year1.focus();
//		      return false;
//		
//		 }
//		  if (validate_year(Year2,"Year Must having 4 digits !!!")==false)
//		 {
//			  Year2.focus();
//		      return false;
//		
//		 }
//		  if (validate_year(Year3,"Year Must having 4 digits !!!")==false)
//		 {
//			  Year3.focus();
//		      return false;
//		
//		 }
//		  if (validate_year(Year4,"Year Must having 4 digits !!!")==false)
//		 {
//			  Year4.focus();
//		      return false;
//		
//		 }
//		  if (validate_year(Year5,"Year Must having 4 digits !!!")==false)
//		 {
//			  Year5.focus();
//		      return false;
//		
//		 }
//	
//	
//		 if (validate_Number(hight1,"Character Not Allowded in hight One !!!")==false)
//		 {
//			  hight1.focus();
//		      return false;
//		
//		 } 
//		  if (validate_Number(hight2,"Character Not Allowded in hight Two !!!")==false)
//		 {
//			  hight2.focus();
//		      return false;
//		
//		 } 
//		  if (validate_Number(hight3,"Character Not Allowded in hight Three !!!")==false)
//		 {
//			  hight3.focus();
//		      return false;
//		
//		 } 
//		  if (validate_Number(hight4,"Character Not Allowded in hight Foure !!!")==false)
//		 {
//			  hight4.focus();
//		      return false;
//		
//		 } 
//		  if (validate_Number(hight5,"Character Not Allowded in hight Five !!!")==false)
//		 {
//			  hight5.focus();
//		      return false;
//		
//		 } 
//		 
//		 
//		 
//		 
//		 
//  if (validate_Number(width1,"Character Not Allowded in width One !!!")==false)
//	{width1.focus(); return false; } 
//  if (validate_Number(width2,"Character Not Allowded in width Two !!!")==false)
//	{width2.focus(); return false; } 
//  if (validate_Number(width3,"Character Not Allowded in width Three !!!")==false)
//	{width3.focus(); return false; } 		
//  if (validate_Number(width4,"Character Not Allowded in width Four !!!")==false)
//	{width4.focus(); return false; }
//  if (validate_Number(width5,"Character Not Allowded in width Five !!!")==false)
//	{width5.focus(); return false; }  
//	
//	
//  if (validate_Number(Year1,"Character Not Allowded in Year One !!!")==false)
//	 {Year1.focus(); return false; }
//  if (validate_Number(Year2,"Character Not Allowded in Year Two !!!")==false)
//	 {Year2.focus(); return false; } 
//  if (validate_Number(Year3,"Character Not Allowded in Year Three !!!")==false)
//	 {Year3.focus(); return false; } 
//  if (validate_Number(Year4,"Character Not Allowded in Year Four !!!")==false)
//	 {Year4.focus(); return false; } 
//  if (validate_Number(Year5,"Character Not Allowded in Year Five !!!")==false)
//	 {Year5.focus(); return false; } 
//	
//	
//  if (validate_Number(price1,"Character Not Allowded in Price One !!!")==false)
//	 {price1.focus(); return false; }
//  if (validate_Number(price2,"Character Not Allowded in Price Two !!!")==false)
//	 {price2.focus(); return false; }
//  if (validate_Number(price3,"Character Not Allowded in Price Three !!!")==false)
//	 {price3.focus(); return false; }
//  if (validate_Number(price4,"Character Not Allowded in Price Four !!!")==false)
//	 {price4.focus(); return false; }
//  if (validate_Number(price5,"Character Not Allowded in Price Five !!!")==false)
//	 {price5.focus(); return false; }
	 
	 
	 
	 
   if (validate_Number(Acode,"Character Not Allowded in Area code Field !!!")==false)
	  {Acode.focus(); return false; }
   if (validate_Number(TelNo,"Character Not Allowded in Telephone No Field !!!")==false)
	  {TelNo.focus(); return false; }
if (validate_Number(Temp_Acode,"Character Not Allowded in Area code Field !!!")==false)
	  {Temp_Acode.focus(); return false; }
if (validate_Number(Temp_TelNo,"Character Not Allowded in Telephone No Field !!!")==false)
	  {Temp_TelNo.focus(); return false; }

if (validate_Number(Mobile,"Character Not Allowded in Mobile No Field !!!")==false)
	  {Mobile.focus(); return false; }
	  
	  
	  
	    if (validate_Number(pincode,"Character Not Allowded in Pincode Field !!!")==false)
	  {pincode.focus(); return false; }
		  /////////////////// Finish Account no validation
		  
		} 
		
		
	
	  }
///////////////////////////////////////////////////////////////////////
function validate_accountno(field,alerttxt)
	{
	with (field)
	{
		if (value.length != 10)
		  {alert(alerttxt);return false;}
		else {return true}
	}
	}
	
function validate_year(field,alerttxt)
	{
	with (field)
	{
		if (value.length != 4)
		  {alert(alerttxt);return false;}
		else {return true}
	}
	}
	
////////////////// Validation For find ' in text area	
	
	function validate_text(field,alerttxt)
	{
	with (field)
	{
	 	 var patt2=new RegExp("'");
         var ans;
          ans = (patt2.test(value));
           if (ans == true)
               {alert(alerttxt);return false;}
		     else {return true}
	}
	}

///////////////////////////////////////////////////
function validate_http(field,alerttxt)
	{
	with (field)
	{
	 	 var patt1=new RegExp("http");
         var ans;
          ans = (patt1.test(value));
           if (ans == true)
               {alert(alerttxt);return false;}
		     else {return true}
	}
	}
//////////////////////////////////////////////////////////////////////
function validate_www(field,alerttxt)
	{
	with (field)
	{
	 	 var patt1=new RegExp("www");
         var ans;
          ans = (patt1.test(value));
           if (ans == true)
               {alert(alerttxt);return false;}
		     else {return true}
	}
	}
//////////////////////////////////////////////////////////////////////
function validate_required(field,alerttxt)
	{
	with (field)
	{
		if (value==null||value=="")
		  {alert(alerttxt);return false;}
		else {return true}
	}
	}
	
/////////////////////////////////////////////////////////////	
//	validate_work
	
	
	function validate_work(field,alerttxt)
	{
	with (field)
	{
		var txt = value;
		if (txt.length >2000)
		  {alert(alerttxt);return false;}
		else {return true}
	}
	}
/////////////////////////////////////////////////////////////////////	
function validate_Email(field,alerttxt)
					{
						with (field)
						{
						 var length = value.length;
						 var counter =0;
						   	apos=value.indexOf("@");
							dotpos=value.lastIndexOf(".");
						
								if (apos<1||dotpos-apos<2) 
								 {
										   alert(alerttxt);
										   return false;
								 }
								 //alert((dotpos+1) );
								
						    	if((dotpos+1) == length )
								{
										alert("Dot should Not be at the End");
										return false;
								}
								
								//Repetation of @ sign	
								var counter = 0;					  
										for(var i=0;i<length;i++)
										{ 
											 if(value.charAt(i)=="@")
											 {
											   counter++;
											   
											 }
										}
																		
								if(counter!= 1)
								 {
									  alert(" '@' Character Must Be One ");
									  return false;
								 }
								 
								 //Repetation of dot sign
							/*	var dotcounter = 0	;				  
										for(var i=0;i<length;i++)
										{ 	 
											 if(value.charAt(i)==".")
											 {
											   dotcounter++;
											   
											 }
										}																	
										
								if(dotcounter!=1)
								 {
									  alert(" '.' Character Must Be One ");
									  return false;
								 }
								 
								 ////code for space not allowed
								 for(var i=0;i<length;i++)
										{ 
											 if(value.charAt(i)==" ")
											 {
											  alert("Space should not be Allowed ");
									           return false;
											 }
										}*/
										
							///code for specialcharacter
							var chars = new Array("~","`","!","#","$","%","^","&","*","(",")","+","=","|","\\","{","}","[","]",":",";","'","/","'","<",">","?",","," ","\"");
																			
					          for(var i=0;i<length;i++)
							  		{ 
							           for(var j=0;j<31;j++)
										{ 
											 if(value.charAt(i)==chars[j])
											 {
											   alert("Special Character should not be Allowed ");
									           return false;
											 }
											
										}		
								
							         }
							 
								 
								 
								 
					//////////Code for check the last number
								var d = (length);
							for(var j=0;j<=4;j++)
							{ 	
								
							if ( (value.charAt(d)=="1") || (value.charAt(d) == "2") || (value.charAt(d) == "3") ||								                                (value.charAt(d) == "4") || (value.charAt(d) == "5") || (value.charAt(d) == "6") ||								                                (value.charAt(d) == "7") || (value.charAt(d) == "8") || (value.charAt(d) == "9") ||							                                (value.charAt(d) == "0" ) )	
										{
											  alert("Number Should Not At the last Character of Email ");
											  return false;
										}
									d--;
									
						       }		 
										 
 	 
								
								 
						}
					} 
	
	// End Email Validation Function
	////////////////////////////////////////////////////////
	function noNumbers(e)
	{
		var keynum;
		var keychar;
		var numcheck;if(window.event) // IE
		{
		  keynum = e.keyCode;
	     }
		else if(e.which) // Netscape/Firefox/Opera
	    {
		  keynum = e.which;
		}
		keychar = String.fromCharCode(keynum);
		numcheck = /\d/;
		return !numcheck.test(keychar);
	}
	
	function Numbers(e)
	{
			var keynum;
			var keychar;
			var numcheck;
			
			if(window.event) // IE
				{
				keynum = e.keyCode;
				}
			else if(e.which) // Netscape/Firefox/Opera
				{
				keynum = e.which;
				}
			keychar = String.fromCharCode(keynum);
			numcheck = /\d/;
			return numcheck.test(keychar);
		}
		//////////////////////////////////////////////////////////////


var ctrlFlag=false;function noKeyPaste(e){ if((e.keyCode?e.keyCode:e.which)==17) {  ctrlFlag=true;  return false; } else if(ctrlFlag) {  return false; } else  return true;}function resetCtrl(e){ if((e.keyCode?e.keyCode:e.which)==17)  ctrlFlag=false;} 





function validate_Number(field,alerttxt)
	{
	with (field)
	{
		if (isNaN(value))
		  {alert(alerttxt);return false;}
		else {return true}
	}
	}
	
	
	var d=new Date();
var dtCh= "-";
var minYear=1900;
//alert(d.getYear());
var maxYear= 2010

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 isDate(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
}

