	  
	  function validatef()
	  {		
		var familyType=document.getElementById("familyTypeid");
		var familydate=document.getElementById("birthdate");
		var sdate=document.getElementById("sdate");
		var edate=document.getElementById("edate");		
		var duration=document.getElementById("travelDuration");
		var coverage=document.getElementById("coveragef");
	    var stripsum=document.getElementById("singletripsum");
		
		validateCheckBox();		
		
		// Family Type Validate
		if(familyType.value=="selected"){
		alert("Please Select Family Type");		
		return false;	
	    }
		
		//Sum insured
		if(stripsum.value=="selected")
		{
		  alert("Please Select Sum Insured");
		  return false;
		}
		

		// Date of Birth Validation

		if((trim(familydate.value))==""){
		alert("Please Enter Date of Birth");
		familydate.focus();
		familydate.select();
		return false;	
	    }
				
		if(trim(familydate.value).length > 10){
	 		alert('Please Enter Valid Date of Birth(dd/MM/yyyy)');
			familydate.focus();
		    familydate.select();
		  	return false;	
		}

		if(trim(familydate.value).length <= 0){
			alert("Please Enter Valid Date of Birth");
			familydate.focus();
			familydate.select();
			return false;	
	   	}

		if(isDate(trim(familydate.value))==false){
			alert('Please Enter Valid Birth Date(dd/MM/yyyy)');
			familydate.focus();
			familydate.select();
			return false;
		}

		if(isLessThenCurrentDate(trim(familydate.value))==false){
			alert('Please enter valid Date of Birth');
			familydate.focus();
			familydate.select();
			return false;
		}
		
		// Plan Start date validation
				
	    if((trim(sdate.value))==""){
		alert("Please Enter Journey Start Date(dd/MM/yyyy)");
		sdate.focus();
		sdate.select();
		return false;	
	    }
		if(trim(sdate.value).length > 10){
	 	alert('Please Enter Valid Journey Start Date(dd/MM/yyyy)');
		sdate.focus();
		sdate.select();
		return false;	
	    }
	    if(isDate(trim(sdate.value))==false){
		alert('Please Enter Valid Journey Start Date(dd/MM/yyyy)');
		sdate.focus();
		sdate.select();
		return false;
	    }
	    if(isLessThenCurrentDate(trim(sdate.value))==true){
		alert('Please enter Start Date which is after current date');
		sdate.focus();
		sdate.select();
		return false;
		}		
		if(limitDays(trim(sdate.value),100)==false){
		   alert("Journey start date should be with in 100 days");
		   sdate.focus();
           sdate.select();
		   return false;
		}

		// Plan End Date Validation
		
		 if((edate.value)==""){
						alert("Please Enter Journey End Date(dd/MM/yyyy)");
						edate.focus();
						edate.select();
						return false;	
					}
				if(trim(edate.value).length > 10){
	 					alert('Please Enter Valid Journey End Date(dd/MM/yyyy)');
						edate.focus();
						edate.select();
						return false;	
				}
				if(isDate(trim(edate.value))==false){
						alert('Please Enter Valid Journey End Date(dd/MM/yyyy)');
						edate.focus();
						edate.select();
						return false;
				}    	
			  if(datt(sdate,edate) == false)
				{
					alert('Journey End Date should not be prior or equal to Start Date');
					edate.focus();
					edate.select();
					return false;
				}		
				
				if(trim(duration.value) <= 0){
					alert("Invalid Duration");
					edate.focus();
					edate.select();
					return false;	
				}			



		// duration validation

		if((trim(duration.value))==""){
		alert("Please Enter Duration of Journey");
		duration.focus();
		duration.select();
		return false;	
	    }
		if(isAlphabetic(trim(duration.value)) == true){
		alert("Please Enter Valid Duration");
		duration.focus();
		duration.select();
		return false;	
		}
		if(isInteger(trim(duration.value)) == false){
		alert("Please Enter Valid Duration");
		duration.focus();
		duration.select();
		return false;	
		}
		if(trim(duration.value).length > 3){
		alert("Please Enter Valid Duration");
		duration.focus();
		duration.select();
		return false;	
		}
		if(trim(duration.value) < 1){
		alert("Please Enter Valid Duration");
		duration.focus();
		duration.select();
		return false;	
		}

		if((coverage.value)==""){
		alert("Please Select Travelling Zone");
		return false;	
	    }
		document.getElementById("controlscript").value="";	
	  }
 

 //VALIDATION FOR CHECK NAMES

var reAlphabetic = /^[a-zA-Z]+$/
var defaultEmptyOK = false

function isEmpty(s){ 
	return ((s == null) || (s.length == 0))
}

function isAlphabetic(s){  
	var i;
    if (isEmpty(s)) 
       if (isAlphabetic.arguments.length == 1) return defaultEmptyOK;
       else return (isAlphabetic.arguments[1] == true);
    else {
       return reAlphabetic.test(s)
    }
}
	/**
 * DHTML date validation script for dd/mm/yyyy. Courtesy of SmartWebby.com (http://www.smartwebby.com/dhtml/)
 */
// Declaring valid date character, minimum year and maximum year
var dtCh= "/";
var minYear=1900;
var maxYear=2100;

function isIntegers(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 strDay=dtStr.substring(0,pos1)
	var strMonth=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("Please enter valid Date(dd/mm/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 || isIntegers(stripCharsInBag(dtStr, dtCh))==false){
		//alert("Please enter a valid date")
		return false
	}
   return true
   }

   //VALIDATION FOR NUMBER
	var reInteger = /^\d+$/
	function isInteger(s){
	var i;
    if (isEmpty(s)) 
       if (isInteger.arguments.length == 1) return defaultEmptyOK;
       else return (isInteger.arguments[1] == true);

    return reInteger.test(s)
	}

	//VALIDATION FOR ALPHANUMERIC
    function isAlphaNumeric(val)
   {
   if (val.match(/^[a-zA-Z0-9]+$/))
    {
   return true;
   }
   else
   {
    return false;
   } 
   }

   // for Date Difference

   function datt(s1,s2)
	  {
		t1=s1;
		//alert(t1.value);
		t2=s2;
		//alert(t2.value);
		//Total time for one day
        var one_day=1000*60*60*24; 
		//Here we need to split the inputed dates to convert them into standard format
		//for furter execution
        var x=t1.value.split("/");     
        var y=t2.value.split("/");
		//date format(Fullyear,month,date) 

        var date1=new Date(x[2],(x[1]-1),x[0]);
        var date2=new Date(y[2],(y[1]-1),y[0])
        var month1=x[1]-1;
        var month2=y[1]-1;
        
        //Calculate difference between the two dates, and convert to days
               
        _Diff=Math.ceil((date2.getTime()-date1.getTime())/(one_day)); 
		//alert(_Diff);
		if(_Diff <=0) { 
			return false;
		}
		
     }
     
      //VALIDATION FOR CHECK DATE NOT LESS THAN CURRECT DATE

	function isLessThenCurrentDate(dateStr)
	{
	
	var mydate=new Date(commonServerDate.getFullYear(), commonServerDate.getMonth(), commonServerDate.getDate());
	var a1=new Array();
	a1=dateStr.split("/");
	var userdate=new Date(a1[2],a1[1]-1,a1[0]);
	var one_day=1000*60*60*24
	var noOfDays=Math.ceil((mydate.getTime()-userdate.getTime())/(one_day));

	if(noOfDays<=0){
	return false;
	}
	return true;
	}

	//Search Screen Check Box Validation
	
    function checkEditable1()
	{
	   document.getElementById("indiaid").checked=false;
	   document.getElementById("coveragef").value="";
	}

   function validateDomestic()
   {
       document.getElementById("coveragef").value="";
       if(document.getElementById("indiaid").checked==true)
		{	  
		  document.getElementById("excljapanid").checked=false;
		  document.getElementById("incljapanid").checked=false;
		  document.getElementById("AUSid").checked=false;       
          document.getElementById("AFid").checked=false;
          document.getElementById("Eroid").checked=false;
          document.getElementById("SAid").checked=false;
          document.getElementById("NAexclid").checked=false;
          document.getElementById("NAinclid").checked=false;		 
	    }

   }
	   
	function validateCheckBox()
	{
	    var status="";
		

		 if(document.getElementById("coveragef").value!="India")		
		 {
			document.getElementById("coveragef").value="";
		 }

		 if(document.getElementById("excljapanid").checked==true)
		 {
			 status=status+"/Asia(ExcludingJapan)";
		 }
		 
		 if(document.getElementById("incljapanid").checked==true)
		 {
		     status=status+"/Asia";
		 }
		 
		 if(document.getElementById("AUSid").checked==true)
		 {
		   status=status+"/Worldwide(Excluding America and Canada)";
		 }

	 
		 if(document.getElementById("AFid").checked==true)
		 {
		     status=status+"/Worldwide(Excluding America and Canada)";
		 }

         if(document.getElementById("Eroid").checked==true)
		 {
		    status=status+"/Worldwide(Excluding America and Canada)";
		 }

         if(document.getElementById("SAid").checked==true)
		 {
		     status=status+"/Worldwide(Excluding America and Canada)";
		 }
         
		 if(document.getElementById("NAexclid").checked==true)
		 {
		    status=status+"/Worldwide(Excluding America and Canada)";
		 }
         
		 if(document.getElementById("NAinclid").checked==true)
		{
		   status=status+"/Worldwide(Including America and Canada)";
		}
		 
		

		if(document.getElementById("indiaid").checked==true)
		{
			status="/Domestic(WithinIndia)";
		}
		

		document.getElementById("coveragef").value=status;	
	}
	
function limitDays(sdate,days)
{
   var mydate=new Date(commonServerDate.getFullYear(), commonServerDate.getMonth(), commonServerDate.getDate());   
   mydate.setDate(mydate.getDate()+days);	
   a1=sdate.split("/");
   var userdate=new Date(a1[2],a1[1]-1,a1[0]);
   var noOfDays=mydate.getTime()-userdate.getTime();   
   if(noOfDays<=0){     
      return false;
   }else
	{
	   return true;
	}	
}





function calculateDuration(){
	
		t1=document.getElementById('sdate');
		t2=document.getElementById('edate');		
		var planStartDate=document.getElementById('sdate');
		
		if(trim(planStartDate.value).length>0){
			if(isLessThenCurrentDate(trim(planStartDate.value))==true){							
				alert('Please enter Start Date which is after current date');
				document.getElementById("edate").value="";
				document.getElementById("travelDuration").value="";
				planStartDate.focus();
				planStartDate.select();
				return false;
			 }
		}

		if(trim(t2.value)!=''){
			if(isDate(trim(t2.value))==false){					
					alert('Please Enter Valid Journey End Date(dd/MM/yyyy)');		  		            
					document.getElementById('travelDuration').value="";
	  		        t2.focus();
			        t2.select();		      	
					return false;
		        }
		 }
			
		//alert(t2.value);
		//Total time for one day
        var one_day=1000*60*60*24; 
		//Here we need to split the inputed dates to convert them into standard format
		//for furter execution
        var x=trim(t1.value).split("/");     
        var y=trim(t2.value).split("/");
		//date format(Fullyear,month,date) 

        var date1=new Date(x[2],(x[1]-1),x[0]);
        var date2=new Date(y[2],(y[1]-1),y[0]);
        var month1=x[1]-1;
        var month2=y[1]-1;
        
		var leaf=date1.getYear();
		var lyear=leaf+1;
		if((lyear%4)==0){
			   if((date1.getMonth()+1)>=3){
					 date1.setDate(date1.getDate()+trvDays);	
				 }else {						
				   date1.setDate(date1.getDate()+(trvDays-1));
				 }
		 }
        //Calculate difference between the two dates, and convert to days
               
        _Diff=Math.ceil((date2.getTime()-date1.getTime())/(one_day)); 
		
		//alert(_Diff);
		if(isNaN(_Diff)==false){
		_Diff=_Diff+1;
		document.getElementById('days').value=_Diff;
		//document.getElementById('caldays').value=_Diff;				
		}
		if(_Diff < 1){
			document.getElementById('travelDuration').value="";
			alert("Journey End Date should not be prior or equal to Start Date");
			//document.getElementById('edate').value="";
			
			t2.focus();
			t2.select();
			return false;	
		}		
	    if(trim(t2.value).length>0){			    
			document.getElementById('travelDuration').value=_Diff;		
	    }
}

function calculateEndateByDuration(){
	t1=document.getElementById('sdate');
	var trvDays=0;
	if(trim(t1.value).length>0){		     
			var trvDuration=document.getElementById('travelDuration');
			if(trim(trvDuration.value).length>0){
				 if(!isInteger(trim(trvDuration.value))){
					 alert("Invalid Duration");
					 trvDuration.focus();
					 trvDuration.select();
					 return false;
				 }
			}
			var sdate=document.getElementById("sdate");		  
	        var trip=document.getElementById("select2");	  	  
			var x=trim(sdate.value).split("/");
			var date1=new Date(x[2],(x[1]-1),x[0]);			 
			var leaf=date1.getYear();
			var lyear=leaf+1;
			
			if(trim(trvDuration.value).length>0){
				trvDays=parseInt(trvDuration.value);
			 }
			  		
			 //leaf year calculation	
			 if((leaf%4)==0)
		     {
               if((date1.getMonth()+1)==1 || (date1.getMonth()+1)==2)
				 {
				   date1.setDate(date1.getDate()+trvDays);
				 }
				 else
				 {
				    date1.setDate(date1.getDate()+(trvDays-1));
				 }
			   
			 }else
		     {
			   
		        if((lyear%4)==0)
				 {
					if((date1.getMonth()+1)>=3)
					 {
						date1.setDate(date1.getDate()+trvDays);	
					 }else
						{
							
						   date1.setDate(date1.getDate()+(trvDays-1));
					    }				 

				 }else
				 {
				   date1.setDate(date1.getDate()+(trvDays-1));
				 }
			 }
			 var dd2=date1.getDate()+"";
			 var mm2=(date1.getMonth()+1)+"";
			 var yy2=date1.getYear();

			 if(dd2.length==1)dd2="0"+dd2;
             if(mm2.length==1)mm2="0"+mm2;
			 if(yy2-1900 <= 0)yy2=yy2+1900;
			 var endDate=dd2+"/"+mm2+"/"+yy2;			
			 //document.getElementById("mdate").value="";	
			 if(trim(trvDuration.value).length>0){
				 document.getElementById("edate").value=endDate;
			 }
			}
		
	}



function travelDateValidation(){

      var bdate=document.getElementById('birthdate');	  

	  // Birth Date Validation
		if(isLessThenCurrentDate(trim(bdate.value))==false){
			alert('Please enter valid Date of Birth');
			bdate.focus();
			bdate.select();
			return false;
		}
		
		// Start Date Validation
		
		var planStartDate=document.getElementById('sdate');
		
		if(trim(planStartDate.value).length>0){
			if(isLessThenCurrentDate(trim(planStartDate.value))==true){								
				alert('Please enter Start Date which is after current date');
				document.getElementById("edate").value="";
				document.getElementById("travelDuration").value="";
				planStartDate.focus();
				planStartDate.select();
				return false;
			 }
		}

		// End Date Validation
		
      	t1=document.getElementById('sdate');
		t2=document.getElementById('edate');
		
		if(trim(t2.value)!=''){
			if(isDate(trim(t2.value))==false){
					//document.getElementById('edate').value="";
					 alert('Please Enter Valid Journey End Date(dd/MM/yyyy)');		  
		            document.getElementById('birthdate').focus();			
	  		        t2.focus();
			        t2.select();		      	
					return false;
		        }
			}
	
		//alert(t2.value);
		//Total time for one day
        var one_day=1000*60*60*24; 
		//Here we need to split the inputed dates to convert them into standard format
		//for furter execution
        var x=trim(t1.value).split("/");     
        var y=trim(t2.value).split("/");
		//date format(Fullyear,month,date) 

        var date1=new Date(x[2],(x[1]-1),x[0]);
        var date2=new Date(y[2],(y[1]-1),y[0])
        var month1=x[1]-1;
        var month2=y[1]-1;
        
        //Calculate difference between the two dates, and convert to days
               
        _Diff=Math.ceil((date2.getTime()-date1.getTime())/(one_day)); 
		//alert(_Diff);
		if(isNaN(_Diff)==false){
		_Diff=_Diff+1;
		document.getElementById('days').value=_Diff;
		//document.getElementById('caldays').value=_Diff;				
		}
		if(_Diff < 1){
			document.getElementById('travelDuration').value="";
			alert("Journey End Date should not be prior or equal to Start Date");
			//document.getElementById('edate').value="";			
			t2.focus();
			t2.select();
			return false;	
		}		
	    
		 if(trim(t2.value).length>0){
			 document.getElementById('travelDuration').value=_Diff;
		 }	 
	
}
