var aD, dD; //Arrival & departure dates
var today = new Date();
today.setDate(today.getDate() + 5); //today's date plus 5
var AFFILIATE = "";//Affiliate code IATA/ARC/CLID, etc
var HOTELONLY = false;

//Go to Reservhotel function will check all parameters before submitting the form
function gotoReservHotel(){
	if (document.myform.aDate.value == "")//Check if arrival date has been selected
		alert("Select your arrival date");
	else if (document.myform.dDate.value == "")//Check if departure date has been selected
		alert("Select your departure date");
	else if (dD < aD)//check to see that departure date is after the arrival date
		alert("The departure date can not be after the return date.");
	else if (HOTELONLY == false && document.getElementById("airport") && document.getElementById("airport").value == "")//check to see if the airport has been selected
		alert("You must select a departing airport for hotel and air packages.");
	else if (aD < today && (document.getElementById("airport") && HOTELONLY == false)){  //check to see packages are selected in the future
		alert("Packages must have be select at least 5 days from today.");
	}else{

		//check affiliate and add hidden attribute to the form
		if  (AFFILIATE != ""){
				var field3 = document.createElement("input");
				field3.setAttribute("type","hidden");
				field3.setAttribute("value",AFFILIATE );
				field3.setAttribute("name","aff");
				document.getElementById("myform").appendChild(field3);
		}
		document.myform.submit();
	}
}

 //Change tab type
function getType(show){
	if (show == "hotel"){
	    document.getElementById("airport").style.display = "none";
	    document.getElementById("airport").selectedIndex = -1;
		HOTELONLY = true;
	}else{
	    document.getElementById("airport").style.display = "";
	    HOTELONLY = false;
	}
}

//Swap pictures functions
function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
