function getQuote()
{
  //  alert("Test Message1");
  var frm = document.getElementById("form1"); 
  window.open("query/quote.php?datefrom=" + frm["dropoff_date"].value + "&dateto=" + frm["pickup_date"].value , "_blank", "location='no', menubar=0, status=0, resizable=1, scrollbars=1 , titlebar=0, toolbar=0, width=600,height=250");

  // window.showModalDialog("faq.html", "PopUp", 'dialogHeight:250px,dialogWidth:600px, status:no');

}
function validateEmail(email)
{
  //    if(email.length <= 0)
  //        {
  //          return true;
  //        }
  var splitted = email.match(/^([\w\-%~\.]+)@([\w\-\.]+\.[\w]{2,4})$/);
  if(splitted == null) return false;
  if(splitted[1] != null )
  {
    var regexp_user=/^\"?[\w-_\.]*\"?$/;
    if(splitted[1].match(regexp_user) == null) return false;
  }
  if(splitted[2] != null)
  {
    var regexp_domain=/^[\w-\.]*\.[A-Za-z]{2,4}$/;
    if(splitted[2].match(regexp_domain) == null)
    {
      var regexp_ip =/^\[\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\]$/;
      if(splitted[2].match(regexp_ip) == null) return false;
    }// if
    return true;
  }
  return false;
}
function initDates() 
{
  //   alert('entering initdates1');

  var start = new Date();

  var frm = document.getElementById("form1"); 
  start.setDate(start.getDate() );
  frm["dropoff_date"].value = start.format('m/d/Y');
  var end = start;
  end.setDate(start.getDate() + 4);
  frm["pickup_date"].value =  end.format('m/d/Y');
} 
function validateForm(form_id) { 
  //alert ("entering validate form");
  // check required fields
  var frm = document.getElementById(form_id); 
  var fields = ['f_name', 'l_name', 'email', 'make', 'model', 'l_plate', 'dropoff_date', 'pickup_date', 'dropoff_time', 'pickup_time', 'veh_size'];

  for(var i=0; i<fields.length; i++) 
  {
    var fld = frm[fields[i]];
    fld.style.backgroundColor = "#ffffff";
    if (fld.value.length < 1) 
    { 
      alert ('Please, fill all Required fields.'); 
      fld.style.backgroundColor = "#ffff00";
      fld.focus(); 
      return false;  
    } 
  } 
  if (!validateEmail(frm['email'].value)) { 
    alert ('Invalid e-mail.'); 
    //                frm['email'].style.backgroundColor = "#ffff00";
    frm['email'].focus(); 
    return false; 
  }
  // validate dates
  var today = new Date();
  var dropoff_date = new Date(frm['dropoff_date'].value + " " + frm['dropoff_time'].value);
  var pickup_date = new Date(frm['pickup_date'].value  + " " + frm['pickup_time'].value);
  if (dropoff_date < today || pickup_date < dropoff_date)
  {
    alert ('Invalid period for the reservation. Please check Drop off Date and Pick up Date and try again'); 
    frm['dropoff_date'].style.backgroundColor = "#ffff00";
    frm['pickup_date'].style.backgroundColor = "#ffff00";
    return false;
  }

   var dropoff_date1 = new Date(frm['dropoff_date'].value);

// check_ blackout_dates;
/*  var pickup_date1 = new Date(frm['pickup_date'].value);
  var end_date1 = new Date('12/31/2008');
  var time_diff = pickup_date1.valueOf() - dropoff_date1.valueOf();
  var time_comp = 4 * 24 * 60 * 60 * 1000 ;

  if ( time_diff < time_comp && dropoff_date1.valueOf() <= end_date1.valueOf() )
  {
    alert ('Reservation period is less than 5 days. Please check Drop off Date and Pick up Date and try again'); 
    frm['dropoff_date'].style.backgroundColor = "#ffff00";
    frm['pickup_date'].style.backgroundColor = "#ffff00";
    return false;
  }
*/
  /*    new Date("12/21/2008") , 
	new Date("12/22/2008") , 
	new Date("12/23/2008") , 
	new Date("12/24/2008") , 
	new Date("12/25/2008") , 
	new Date("12/26/2008") , 
	new Date("12/27/2008") , 
	new Date("12/28/2008")
*/
  var blockeddates = [ 
    new Date("4/9/2009"),
    new Date("4/10/2009")
      ];

  for(var i=0; i<blockeddates.length; i++) 
  {
    if (blockeddates[i].valueOf() == dropoff_date1.valueOf())
    {
      alert ('We are sorry, but our parking lot is full for the dates you have selected. Please change the Drop off Date and try again'); 
      frm['dropoff_date'].style.backgroundColor = "#ffff00";
      return false;
    }
  }
 

//  frm['reserve'].disabled = true;
  //        alert("exiting validate form");
  return true;
}

