﻿var now = new Date();
var nowplus7 = new Date();
var nowplus14 = new Date();
nowplus7.setDate(now.getDate()+7);
nowplus14.setDate(now.getDate()+14);

function chgTripType(sType)
{
	switch(sType){
		case "rdbOneWay" : {
			document.getElementById("pnlFlight2").style.display = "none";
			document.getElementById("pnlFlight3").style.display = "none";
			break;
		}
		case "rdbRoundTrip" : {
			document.getElementById("pnlFlight2").style.display = document.all? "block" : "table-row";
			document.getElementById("pnlFlight3").style.display = "none";
			break;
		}
		case "rdbMultiCity" : {
			document.getElementById("pnlFlight2").style.display = document.all? "block" : "table-row";
			document.getElementById("pnlFlight3").style.display = document.all? "block" : "table-row";
			break;
		}
	}
}

function focusObj(obj){
	if(obj.value=="Airport or City")obj.value="";
}

function blurObj(obj){
	if(obj.value=="")obj.value = "Airport or City";
}

function copyTextbox(obj1, obj2){
    obj2.value = obj1.value;
}

function validateSearch(){
	alert_message = "";
	formObj = document.forms["flight"];
	var now = new Date();

	if(formObj.txtDepCity1.value == "" || formObj.txtDepCity1.value == formObj.txtDepCity1.getAttribute("defValue")) alert_message += " - Specify a Departure City for Flight 1\n";
	if(formObj.txtArrCity1.value == "" || formObj.txtArrCity1.value == formObj.txtArrCity1.getAttribute("defValue")) alert_message += " - Specify a Destination City for Flight 1\n";
	if(formObj.PickupDDMMYY.value == "" || formObj.PickupDDMMYY.value == formObj.PickupDDMMYY.getAttribute("defValue")) alert_message += " - Specify a Destination Date for Flight 1\n";

	if(formObj.TripType[1].checked || formObj.TripType[2].checked){
		if(formObj.txtDepCity2.value == "" || formObj.txtDepCity2.value == formObj.txtDepCity2.getAttribute("defValue")) alert_message += " - Specify a Departure City for Flight 2\n";
		if(formObj.txtArrCity2.value == "" || formObj.txtArrCity2.value == formObj.txtArrCity2.getAttribute("defValue")) alert_message += " - Specify a Destination City for Flight 2\n";
       	if(formObj.DropDDMMYY.value == "" || formObj.DropDDMMYY.value == formObj.DropDDMMYY.getAttribute("defValue")) alert_message += " - Specify a Destination Date for Flight 2\n";
	}
	
	if(formObj.TripType[2].checked){
		if(formObj.txtDepCity3.value == "" || formObj.txtDepCity3.value == formObj.txtDepCity3.getAttribute("defValue")) alert_message += " - Specify a Departure City for Flight 3\n";
		if(formObj.txtArrCity3.value == "" || formObj.txtArrCity3.value == formObj.txtArrCity3.getAttribute("defValue")) alert_message += " - Specify a Destination City for Flight 3\n";
    	
    	if(formObj.DropDDMMYY1.value == "" || formObj.DropDDMMYY1.value == formObj.DropDDMMYY1.getAttribute("defValue")) alert_message += " - Specify a Destination Date for Flight 3\n";
	}

	if(alert_message!=""){
		alert("Please fix the following problems: \n" + alert_message);
		return false;
	}
	return true;
}

function validateSearch1()
   {
 
 alert_message = "";
	formObj = document.forms["flight"];
	var now = new Date();

	if(formObj.DepCity1.value == "" || formObj.DepCity1.value == formObj.DepCity1.getAttribute("defValue")) alert_message += " - Specify a Departure City\n";
	if(formObj.ArrCity1.value == "" || formObj.ArrCity1.value == formObj.ArrCity1.getAttribute("defValue")) alert_message += " - Specify a Destination City\n";
	if(formObj.PickupDDMMYY.value == "" || formObj.PickupDDMMYY.value == formObj.PickupDDMMYY.getAttribute("defValue")) alert_message += " - Specify a Departure Date\n";
	
	if(formObj.TripType[1].checked){
		if(formObj.DropDDMMYY.value == "" || formObj.DropDDMMYY.value == formObj.DropDDMMYY.getAttribute("defValue")) alert_message += " - Specify a Return Date\n";
	}
    
   if(alert_message!=""){
		alert("Please fix the following problems: \n" + alert_message);
		return false;
	}
	return true;
     
   }
