var dests = new Array();
dests[0] = "fdest";
dests[1] = "hdest";
dests[2] = "cdest";
dests[3] = "pdest";

var deplbl = new Array();
deplbl[0] = "lcdepart";
deplbl[1] = "ldepart";

var retlbl = new Array();
retlbl[0] = "lcreturn";
retlbl[1] = "lreturn";

var retd = new Array();
retd[0] = "ckoutdt";
retd[1] = "tdate";

var fromd = new Array();
fromd[0] = "ckindt";
fromd[1] = "fdate";

var fromt = new Array();
fromt[0] = "ftime";
fromt[1] = "putime";

var rett = new Array();
rett[0] = "ttime";
rett[1] = "dotime";

function SetRfrr(type)
{
	// Note empty referrers where we don't need them
	var d = document.Wiz;
	switch(type)
	{
		case "flight":
			d.rfrr.value = "";
			break;
		case "flightlink":
			d.rfrr.value = "";
			break;
		case "hotel":
			d.rfrr.value = "";
			break;
		case "hotellink":
			d.rfrr.value = "";
			break;
		case "car":
			d.rfrr.value = "";
			break;
		case "carlink":
			d.rfrr.value = "";
			break;
		case "flighthotel":
			d.rfrr.value = "-12642";
			break;
		case "flighthotellink":
			d.rfrr.value = "";
			break;
		case "flighthotelcar":
			d.rfrr.value = "-12641";
			break;
		case "flighthotelcarlink":
			d.rfrr.value = "";
			break;
		case "flightcar":
			d.rfrr.value = "-12640";
			break;
		case "flightcarlink":
			d.rfrr.value = "";
			break;
	}
}

function HandleWiz(type)
{
	SetRfrr(type);
	var d = document.Wiz;
	switch(type)
	{
		//case "flight":
		//case "flightlink":
			//d.GOTO.value = "EXPFLTWIZ"; 
			//ShowFromArray("fopt", opts);
			//ShowFromArray("fdest", dests);
			//ShowFromArray("ldepart", deplbl);
			//break;
		//case "hotel":
		//case "hotellink":
		//	d.GOTO.value = "HOTSEARCH"; d.SearchType.value = "DESTINATION";
		//	ShowFromArray("hopt", opts);
		//	ShowFromArray("hdest", dests);
		//	ShowFromArray("ckoutdt", retd); ShowFromArray("ckindt", fromd);
		//	ShowFromArray("", deplbl); ShowFromArray("", retlbl); 
		//	ShowFromArray("", rett);ShowFromArray("", fromt);
		//	HideLayer("dfrom");HideLayer("ftime");HideLayer("putime");
		//	HideLayer("senpax");
		//	break;
		//case "car":
		//case "carlink":
		//	d.GOTO.value = "CARSEARCH"; d.SearchType.value = "AIRPORT";
		//	ShowFromArray("copt", opts);
		//	ShowFromArray("cdest", dests);
		//	ShowFromArray("lcdepart", deplbl);
		//	ShowFromArray("lcreturn", retlbl);
		//	ShowLayer("cclass");
		//	ShowLayer("cardisc");
		//	ShowFromArray("fdate", fromd);
		//	ShowFromArray("tdate", retd);
		//	ShowFromArray("dotime", rett);ShowFromArray("putime", fromt);
		//	HideLayer("dfrom");
		//	HideLayer("pax");
		//	break;
		case "flighthotel":
		case "flighthotellink":
			d.PackageType.value = 2; // find out what this should be
			break;
		case "flighthotelcar":
		case "flighthotelcarlink":
			d.PackageType.value = 1; // find out what this should be
			break;
		case "flightcar":
		case "flightcarlink":
			d.PackageType.value = 5; // find out what this should be
			break;
	}
	//if (type == "hotellink" || type == "hotel")
	//{
	//	document.getElementById("returndets").style.display = "none";
	//}
	//else
	//{
		document.getElementById("returndets").style.display = "block";
	//}
	if (type != "car" && type != "carlink")
	{
		HideLayer("cclass");
		ShowLayer("pax");
	}
	if (type == "car" || type == "carlink" || type == "flightcar" || type == "flightcarlink" || type == "flighthotelcar" || type == "flighthotelcarlink")
	{
		ShowLayer("cardisc");
	}
	else
	{
		HideLayer("cardisc");
	}
	if (type == "flightcar" || type == "flightcarlink" || type == "flighthotel" || type == "flighthotellink" || type == "flighthotelcar" || type == "flighthotelcarlink" || type == "flight" || type == "flightlink")
	{
		if (type != "flight" && type != "flightlink")
		{
			d.GOTO.value = "PACKAGEWIZ";
			ShowFromArray("pdest", dests);
			ShowFromArray("ldepart", deplbl);
			
		}
		ShowFromArray("fdate", fromd);
		ShowFromArray("tdate", retd);
		ShowFromArray("lreturn", retlbl);
		ShowFromArray("ttime", rett);ShowFromArray("ftime", fromt);
		ShowLayer("dfrom");
		ShowLayer("senpax");
	}
	if (type == "flightlink")
	{
		window.location.href = "/pubspec/scripts/eap.asp?GOTO=EXPFLTWIZ&Rfrr=-13024&NoSubmit=1&FrAirport=" + d.FrAirport.value + "&ToAirport=" + d.ToAirport.value + "&FromDate=" + d.FromDate.value + "&ToDate=" + d.ToDate.value + "&shps=1&NumAdult=" + d.NumAdult.options[d.NumAdult.selectedIndex].value; + "&NumChild=" + d.NumChild.options[d.NumChild.selectedIndex].value + "&NumSenior=" + d.NumSenior.options[d.NumSenior.selectedIndex].value + "&child1Age=" + d.child1Age.options[d.child1Age.selectedIndex].value + "&child2Age=" + d.child2Age.options[d.child2Age.selectedIndex].value + "&child3Age=" + d.child3Age.options[d.child3Age.selectedIndex].value + "&child4Age=" + d.child4Age.options[d.child4Age.selectedIndex].value + "&child5Age=" + d.child5Age.options[d.child5Age.selectedIndex].value + "&ToTime=" + d.ToTime.options[d.ToTime.selectedIndex].value + "&FromTime=" + d.FromTime.options[d.FromTime.selectedIndex].value;
	}
	else if (type == "hotellink")
	{
		window.location.href = "/pubspec/scripts/eap.asp?GOTO=HOTLAUNCH&Rfrr=-13025&MoreOptions=1&NoSubmit=1&CityName=" + d.CityName.value + "&InDate=" + d.InDate.value + "&OutDate=" + d.OutDate.value + "&NumAdult=" + d.NumAdult.options[d.NumAdult.selectedIndex].value + "&NumChild=" + d.NumChild.options[d.NumChild.selectedIndex].value + "&NumSenior=" + d.NumSenior.options[d.NumSenior.selectedIndex].value + "&child1Age=" + d.child1Age.options[d.child1Age.selectedIndex].value + "&child2Age=" + d.child2Age.options[d.child2Age.selectedIndex].value + "&child3Age=" + d.child3Age.options[d.child3Age.selectedIndex].value + "&child4Age=" + d.child4Age.options[d.child4Age.selectedIndex].value + "&child5Age=" + d.child5Age.options[d.child5Age.selectedIndex].value;
	}
	else if (type == "carlink")
	{
		window.location.href = "/pubspec/scripts/eap.asp?GOTO=CARWIZD&Rfrr=-13026&PickupLoc=" + d.PickupLoc.value +  "&PickUpDate=" + d.FromDate.value + "&DropOffDate=" + d.ToDate.value + "&PickUpTime=" + d.PickUpTime.value + "&DropTime=" + d.DropTime.value + "&CarClass=" + d.Class.options[d.Class.selectedIndex].value;
	}
	else if (type == "flighthotellink")
	{
		window.location.href = "/pubspec/scripts/eap.asp?GOTO=PKGLAUNCH&Rfrr=-13027&PackageType=2&NoSubmit=1&FrAirport=" + d.FrAirport.value + "&DestName=" + d.ToAirport.value + "&FromDate=" + d.FromDate.value + "&ToDate=" + d.ToDate.value + "&NumAdult=" + d.NumAdult.options[d.NumAdult.selectedIndex].value + "&NumChild=" + d.NumChild.options[d.NumChild.selectedIndex].value + "&NumSenior=" + d.NumSenior.options[d.NumSenior.selectedIndex].value + "&child1Age=" + d.child1Age.options[d.child1Age.selectedIndex].value + "&child2Age=" + d.child2Age.options[d.child2Age.selectedIndex].value + "&child3Age=" + d.child3Age.options[d.child3Age.selectedIndex].value + "&child4Age=" + d.child4Age.options[d.child4Age.selectedIndex].value + "&child5Age=" + d.child5Age.options[d.child5Age.selectedIndex].value + "&ToTime=" + d.ToTime.options[d.ToTime.selectedIndex].value + "&FromTime=" + d.FromTime.options[d.FromTime.selectedIndex].value;
	}
	else if (type == "flighthotelcarlink")
	{
		window.location.href = "/pubspec/scripts/eap.asp?GOTO=PKGLAUNCH&Rfrr=-13027&PackageType=1&NoSubmit=1&FrAirport=" + d.FrAirport.value + "&DestName=" + d.ToAirport.value + "&FromDate=" + d.FromDate.value + "&ToDate=" + d.ToDate.value + "&NumAdult=" + d.NumAdult.options[d.NumAdult.selectedIndex].value + "&NumChild=" + d.NumChild.options[d.NumChild.selectedIndex].value + "&NumSenior=" + d.NumSenior.options[d.NumSenior.selectedIndex].value + "&child1Age=" + d.child1Age.options[d.child1Age.selectedIndex].value + "&child2Age=" + d.child2Age.options[d.child2Age.selectedIndex].value + "&child3Age=" + d.child3Age.options[d.child3Age.selectedIndex].value + "&child4Age=" + d.child4Age.options[d.child4Age.selectedIndex].value + "&child5Age=" + d.child5Age.options[d.child5Age.selectedIndex].value + "&ToTime=" + d.ToTime.options[d.ToTime.selectedIndex].value + "&FromTime=" + d.FromTime.options[d.FromTime.selectedIndex].value;
	}
	else if (type == "flightcarlink")
	{
		window.location.href = "/pubspec/scripts/eap.asp?GOTO=PKGLAUNCH&Rfrr=-13027&PackageType=5&NoSubmit=1&FrAirport=" + d.FrAirport.value + "&DestName=" + d.DestName.value + "&FromDate=" + d.FromDate.value + "&ToDate=" + d.ToDate.value + "&NumAdult=" + d.NumAdult.options[d.NumAdult.selectedIndex].value + "&NumChild=" + d.NumChild.options[d.NumChild.selectedIndex].value + "&NumSenior=" + d.NumSenior.options[d.NumSenior.selectedIndex].value + "&child1Age=" + d.child1Age.options[d.child1Age.selectedIndex].value + "&child2Age=" + d.child2Age.options[d.child2Age.selectedIndex].value + "&child3Age=" + d.child3Age.options[d.child3Age.selectedIndex].value + "&child4Age=" + d.child4Age.options[d.child4Age.selectedIndex].value + "&child5Age=" + d.child5Age.options[d.child5Age.selectedIndex].value + "&ToTime=" + d.ToTime.options[d.ToTime.selectedIndex].value + "&FromTime=" + d.FromTime.options[d.FromTime.selectedIndex].value;
	}
}

function SyncChildAges()
{
	var d = document.Wiz;
	d.Age1.value = d.child1Age.options[d.child1Age.selectedIndex].value;
	d.Age2.value = d.child2Age.options[d.child2Age.selectedIndex].value;
	d.Age3.value = d.child3Age.options[d.child3Age.selectedIndex].value;
	d.Age4.value = d.child4Age.options[d.child4Age.selectedIndex].value;
	d.Age5.value = d.child5Age.options[d.child5Age.selectedIndex].value;
	d.Age6.value = d.child6Age.options[d.child6Age.selectedIndex].value;
}

function SyncDestinations(val) 
{
	var d = document.Wiz;
	d.ToAirport.value = val;
	d.DestName.value = val;
	d.CityName.value = val;
	d.PickupLoc.value = val;
}

function SyncRetDates(val) 
{
	var d = document.Wiz;
	d.OutDate.value = val;
	d.ToDate.value = val;
}


function SyncDepDates(val)
{
	var d = document.Wiz;
	d.FromDate.value = val;
	d.InDate.value = val;
}

function ShowFromArray(id, s)
{
	for(i=0;i<s.length;i++)
	{
		if (id == s[i])
		{
			ShowLayer(s[i]);
		}
		else
		{
			HideLayer(s[i]);
		}
	}
}

function ShowLayer(id)
{
	if (document.getElementById)
		document.getElementById(id).style.display = "block";
	else
		document.all[id].style.display = "block";
}

function HideLayer(id)
{
	if (document.getElementById)
		document.getElementById(id).style.display = "none";
	else
		document.all[id].style.display = "none";
}

function ShowChildAges(val)
{
	if (val == 0 || val == null)
	{
		HideLayer("childages");
	}
	else
	{
		ShowLayer("childages");
	}
	
	for(i=1;i<7;i++)
	{
		if (i <= val)
		{
			ShowLayer("tdChild" + i);
		}
		else
		{
			HideLayer("tdChild" + i);
		}
	}
}
