function DoSearchResults()
{
    var IsError = 1;
    var fromDate = document.qQ.fromDate.value;
    var toDate = document.qQ.toDate.value;
    var Error = ""; 
    var Product = document.getElementById("ProductType").value; 
    var Location = document.qQ.AirportLocation.options[document.qQ.AirportLocation.selectedIndex].value; 
   
     if(Location == 'Please Select an Airport')
	 {
		IsError = 2;
		Error = 'Please select an airport location';
	 }
	
	 //Splits to and from date by the /,
	 
	 var arrFromDate = fromDate.split("/", 3);
     var arrToDate = toDate.split("/", 3);
	 var comFromDate = new Date(arrFromDate [2], (arrFromDate [1] -1), arrFromDate [0]);
	 
	 if((comFromDate == 'NaN') || (arrFromDate == "") || (comFromDate == 'undefined'))
	 {
		IsError = 2;
		Error = 'Please check the entered start date is valid.';
	 }
	 var current = new Date();
	// alert('comfromdate=' + comFromDate + ', current=' +current);
	 
//  	 if (comFromDate < current)
//	 {
//		IsError = 2;
//		Error = 'The selected start date is before todays date';
//	 }
	 
	 var conToDate = new Date(arrToDate [2], (arrToDate [1] -1), arrToDate [0]);
	 
	 if((conToDate == 'NaN') || (arrToDate == "") || (conToDate == 'undefined'))
	 {
		IsError = 2;
		Error = 'Please check the return date is valid.';
	 }
	 
	 if(conToDate < comFromDate)
	 {
		IsError = 2;
		Error = 'The entered return date is before the departure date.';
	 }
	 
	 if(IsError == 2)
	 {
		alert(Error);
	 }
	 if(IsError == 1)
	 {		
		var fromTime = document.qQ.fromTime.options[document.qQ.fromTime.selectedIndex].value;
		var toTime = document.qQ.toTime.options[document.qQ.toTime.selectedIndex].value;
        	var txtPromoCode = document.getElementById('txtPromoCode').value;
        	var ddHotelRooms = document.getElementById('ddHotelRooms').value;
	    	var ddHotel2ndRoom = document.getElementById('ddHotel2ndRoom').value;
	
        //var String = 'http://seneca.underground.co.uk/QuotePageLoad.aspx?Type='+Product+'&Airport='+Location+'&DateFrom='+fromDate+' '+fromTime+'&DateTo='+toDate+' '+toTime+'&PromotionCode='+txtPromoCode+'&RoomCode='+ddHotelRooms+'&RoomCode2='+ddHotel2ndRoom;
	var String = 'http://quote.airport-parking.co.uk/QuotePageLoad.aspx?Type='+Product+'&Airport='+Location+'&DateFrom='+fromDate+' '+fromTime+'&DateTo='+toDate+' '+toTime+'&PromotionCode='+txtPromoCode+'&RoomCode='+ddHotelRooms+'&RoomCode2='+ddHotel2ndRoom;	
	//alert(String);
        window.location = String;        
      } 
}
	
        	
     

function GetLocations()
{
	//var arrLocations = new Array("Please Select an Airport", "Aberdeen", "Belfast International", "Birmingham", "Blackpool", "Bristol", "Cardiff", "Doncaster Robin Hood", "Dover Port", "Durham Tees Valley", "Edinburgh", "Exeter", "Gatwick North", "Gatwick South","Glasgow", "Heathrow (T1,T2,T3)", "Heathrow (T4)","Humberside","Inverness","Leeds Bradford","Liverpool John Lennon", "London City", "Luton", "Manchester", "Newcastle", "Norwich", "Nottingham East Midlands", "Prestwick", "Southampton", "Stansted");
	
	//for( keyVar in arrLocations)
	//{
	//	document.qQ.AirportLocation.options[keyVar] = new Option(arrLocations[keyVar], arrLocations[keyVar]);
	//}
	//var airport = document.qQ.AirportLocation;
	//airport.value = document.getElementById('Location').value;
}

function AddTimes()
{
	var arrTimes = new Array("00:30","01:00","01:30","02:00","02:30","03:00", "03:30","04:00","04:30","05:00", "05:30","06:00","06:30","07:00","07:30","08:00","08:30","09:00","09:30","10:00","10:30","11:00","11:30","12:00","12:30","13:00","13:30","14:00","14:30","15:00","15:30","16:00","16:30","17:00","17:30","18:00","18:30","19:00","19:30","20:00","20:30","21:00","21:30","22:00","22:30","23:00", "23:30");

	for(keyVar in arrTimes)
	{
		document.qQ.fromTime.options[keyVar] = new Option(arrTimes[keyVar], arrTimes[keyVar]);
		document.qQ.toTime.options[keyVar] = new Option(arrTimes[keyVar], arrTimes[keyVar]);
	}
	var fromEle = document.qQ.fromTime;
	fromEle.value = '09:00';		
	var toEle = document.qQ.toTime;
	toEle.value = '15:00';		
}

function SetDates()
{
    var fromDate
    fromDate = document.getElementById('fromDate');
    toDate = document.getElementById('toDate');
    d = new Date();

	//FromDate.
	d.setUTCDate(d.getDate() + 7);
    var s = "";
	var day = 0;
	day = d.getDate();
	if(day <10)
	{
		day = "0" + day;
	}
    var month = 0;  
    month = d.getMonth()+1;
    if(month<10) 
    {
        month = "0" + month;
    }
    s= day + "/" + month + "/" +  d.getFullYear();
    fromDate.value = s;
	
	//ToDate.
	d.setUTCDate(d.getDate() + 7);
	var s = "";
	var day = 0;
	day = d.getDate();
	if(day < 10)
	{
		day = "0" + day;
	}
	var month = 0;
	month = d.getMonth() + 1;
	if(month < 10)
	{
		month = "0" + month;
	}
	s = day + "/" + month + "/" + d.getFullYear();
	toDate.value = s;
}

function OnLoad()
{
	//GetLocations();
	AddTimes();
	//SetDates();
  if (navigator.userAgent.indexOf("Firefox") != -1) 
  {
     
     document.getElementById('QuickQuote').style.marginLeft = '20px';
     document.getElementById('QuickQuote').style.marginBottom = '20px';
  }
}

function showHotelsDropDowns()
{

    if(document.getElementById('ProductType').value == 'HotelsandParking')
    {
        document.getElementById('RoomLabel').style.display = '';
        document.getElementById('Room2Label').style.display = '';
        document.getElementById('ddHotelRooms').style.display = '';
        document.getElementById('ddHotel2ndRoom').style.display = '';
        document.getElementById('QuickQuote').style.marginBottom = '40px'; 
    }
    else
    {
        document.getElementById('RoomLabel').style.display = 'none';
        document.getElementById('Room2Label').style.display = 'none';
        document.getElementById('ddHotelRooms').style.display = 'none';
        document.getElementById('ddHotel2ndRoom').style.display = 'none';
	if (navigator.userAgent.indexOf("Firefox") != -1) 
 	{
           document.getElementById('QuickQuote').style.marginBottom = '20px';
 	}
	else
	{
     	   document.getElementById('QuickQuote').style.marginBottom = '0px'; 
    	}
    }
}

function RollOverButton(newImg)
{
	butDoSearch = document.getElementById('btnSearch');
    butDoSearch.src = newImg;
}
