function SubmitForm()
{
//alert( 'in SubmitForm');
if(validate())
{

var val=document.property.apartment_type.value;
//alert('val=='+val);
var valarray=val.split(",");
//alert('valarray==='+valarray[0]+' '+valarray[1]+' '+valarray[2]);
var duration=document.property.duration.value;
var extra=document.getElementById("check1").value;
//alert(duration);
//alert(valarray[2]);
if(document.getElementById("check1").checked == true) 
{
	valarray[1]=((parseInt(valarray[1])+parseInt(extra))/4)*parseInt(duration);
}
else
{
valarray[1]=(parseInt(valarray[1])/4)*parseInt(duration);
}
//alert(valarray[2]);
document.property.Amount.value=valarray[1];
document.property.Order_Id.value=valarray[2];
document.property.submit();
}
}



function Calculate_Form() 
{
 var date1=document.property.Checkin.value;
 var date2=document.property.Checkout.value;
 var mon1=date1.substring(5,7);
 var mon2=date2.substring(5,7);
 if(mon1=="")
 {
  alert("Enter CheckOut Date"); 
  return false;
 }
  
 if(mon2=="")
 {
  alert("Enter CheckIn Date");
  return false; 
 }
 
 var day1=date1.substring(8,10);
 var day2=date2.substring(8,10);
 
 var yer1=date1.substring(0,4);
 var yer2=date2.substring(0,4);
 
 var myDate1=new Date();
 var myDate2=new Date();
 myDate1.setFullYear(yer1,mon1-1,day1);
 myDate2.setFullYear(yer2,mon2-1,day2);
 
  if (myDate2<=myDate1)
  {
   alert("You Can't Take CheckOut Date less Then CheckIn Date");  
   document.property.Checkin.value= "" ;
   document.property.Checkout.value= "" ;
   return false;
  }
  else
  { 
   document.property.duration.value=(myDate2-myDate1)/(1000*60*60*24); 
   return true;  
  }

}
function check2ndDate()
{
//alert('Hi');

 if(document.property.Checkout.value != "")
 {
  //alert("HI jaswin");
  Calculate_Form(); 
 }
}


function validate()
{
if(document.property.Name.value== "")
 {
  alert('pls Fill your name');
  document.property.Name.focus();
  return false;
 }
 else if(document.property.Location.value== "-1")
 {
  alert('pls select location');
  document.property.Location.focus();
  return false;
 }
  else if(document.property.apartment_type.value== "-1")
 {
  alert('pls select apartment type');
  document.property.apartment_type.focus();
  return false;
 }

else if(document.property.Adults.value== "")
 {
  alert('pls fill no of Adults');
  document.property.Adults.focus();
  return false;
 }
 
 else if(document.property.Children.value== "")
 {
  alert('pls fill no of Children');
  document.property.Children.focus();
  return false;
 }

 else if(document.property.Checkin.value== "")
 {
  alert('pls select Checkin Date');
  document.property.Checkin.focus();
  return false;
 }
  else if(document.property.Checkout.value== "")
 {
  alert('pls select Checkout Date');
  document.property.Checkout.focus();
  return false;
 }
 
 else if(document.property.Country.value== "-1")
 {
  alert('pls select Country');
  document.property.Country.focus();
  return false;
 }
 else if(document.property.City.value== "")
 {
  alert('pls Fill your City');
  document.property.City.focus();
  return false;
 }
 else if(document.property.Email.value== "")
 {
  alert('pls fill your Email address');
  document.property.Email.focus();
  return false;
 }
 
 else if(document.property.Contact_no.value== "")
 {
  alert('pls fill your Contact no');
  document.property.Contact_no.focus();
  return false;
 }
 else return true;
	
}
