


function populateDestinations(destinationAirports, countryCodeSelect)
{


	countryCode = countryCodeSelect[countryCodeSelect.selectedIndex].value;

	if (countryCode != '')
	{
		//frames['iframe2'].location.href = '/jsincluder2.htm?countrycode=' + countryCode;
		document.getElementById('iframe2').src = '/jsincluder2.htm?countrycode=' + countryCode;
		document.forms[0].elements['arvcountry'].disabled = true;
		document.forms[0].elements['arv'].disabled = true;
	}



}

function populateQuerystringFromSelects(theLink) {

	dptc =  document.forms[0].elements['dptCounty'][document.forms[0].elements['dptCounty'].selectedIndex].value;
	dpt = document.forms[0].elements['dpt'][document.forms[0].elements['dpt'].selectedIndex].value;
	arrc = document.forms[0].elements['arvcountry'][document.forms[0].elements['arvcountry'].selectedIndex].value;
	arr = document.forms[0].elements['arv'][document.forms[0].elements['arv'].selectedIndex].value;
	start = theLink.href;

	theLink.href = start + '&dptc=' + dptc + '&dpt=' + dpt + '&arrc=' + arrc + '&arr=' + arr;

}



function PopulateHiddenFieldsxxx()
{

//departure date
document.forms[0].elements['date'].value = document.forms[0].elements['flight-finder-departure-year-control'][document.forms[0].elements['flight-finder-departure-year-control'].selectedIndex].value  + document.forms[0].elements['flight-finder-departure-month-control'][document.forms[0].elements['flight-finder-departure-month-control'].selectedIndex].value  + document.forms[0].elements['flight-finder-departure-day-control'][document.forms[0].elements['flight-finder-departure-day-control'].selectedIndex].value ;  

//return date
document.forms[0].elements['retdate'].value = document.forms[0].elements['flight-finder-return-year-control'][document.forms[0].elements['flight-finder-return-year-control'].selectedIndex].value  + document.forms[0].elements['flight-finder-return-month-control'][document.forms[0].elements['flight-finder-return-month-control'].selectedIndex].value  + document.forms[0].elements['flight-finder-return-day-control'][document.forms[0].elements['flight-finder-return-day-control'].selectedIndex].value;

//deals with airport groups,  hardcoded currently
if (document.forms[0].elements['dpt'].value == 'MAIN' || document.forms[0].elements['arrAirport'].value == 'LON')
{
	if (document.forms[0].elements['dptCounty'].value == 'SCO') {
		document.forms[0].elements['arrAirport'].value = 'Glasgow';
		document.forms[0].elements['dpt'].value = 'GLA';
		document.forms[0].elements['arrAirportGroup'].value = 'ABZ|Aberdeen,DND|Dundee,GLA|Glasgow,EDI|Edinburgh,PIK|Glasgow Prestwick,NCL|Newcastle';
	}

	if (document.forms[0].elements['dptCounty'].value == 'NE') {
		document.forms[0].elements['arrAirport'].value = 'Manchester';
		document.forms[0].elements['dpt'].value = 'MAN';
		document.forms[0].elements['arrAirportGroup'].value = 'MAN|Manchester,NCL|Newcastle,MME|Teeside,BLK|Blackpool,LBA|Leeds Bradford,LPL|Liverpool,DSA|Doncaster Sheffield,HUY|Humerside';
	}

	if (document.forms[0].elements['dptCounty'].value == 'NI') {
		document.forms[0].elements['arrAirport'].value = 'Belfast';
		document.forms[0].elements['dpt'].value = 'BFS';
		document.forms[0].elements['arrAirportGroup'].value = 'BFS|Belfast,BHD|Belfast City,LDY|Derry';
	}

	if (document.forms[0].elements['dptCounty'].value == 'CE') {
		document.forms[0].elements['arrAirport'].value = 'London Stanstead';
		document.forms[0].elements['dpt'].value = 'STN';
		document.forms[0].elements['arrAirportGroup'].value = 'STN|Standstead,LTN|Luton,MAN|Manchester,EMA|East Midlands,CVT|Coventry,BHX|Birmingham,NWI|Norwich';
	}

	if (document.forms[0].elements['dptCounty'].value == 'SW') {
		document.forms[0].elements['arrAirport'].value = 'Southamton';
		document.forms[0].elements['dpt'].value = 'SOU';
		document.forms[0].elements['arrAirportGroup'].value = 'SOU|Southampton,BRS|Bristol,CWL|Cardiff,EXE|Exeter,NQY|Newquay,PLH|Plymouth,LEQ|Lands End,PZE|Penzance,GCI|Guernsey,ACI|Alderney,JER|Jersey,BOH|Bournmouth';
	}

	if (document.forms[0].elements['dptCounty'].value == 'SE') {
		document.forms[0].elements['arrAirport'].value = 'London Heathrow';
		document.forms[0].elements['dpt'].value = 'LHR';
		document.forms[0].elements['arrAirportGroup'].value = 'LHR|London Heathrow,STN|London Stanstead,LGW|London Gatwick,LTN|London Luton,LCY|London City,SOU|Southampton,BOH|Bournmouth,BSH|Brighton,LYX|Lydd';
	}

	if (document.forms[0].elements['dptCounty'].value == 'SE'){
		document.forms[0].elements['arrAirport'].value = 'London Heathrow';
		document.forms[0].elements['dpt'].value = 'LHR';
		document.forms[0].elements['arrAirportGroup'].value = 'LHR|London Heathrow,STN|London Stanstead,LGW|London Gatwick,LTN|London Luton,LCY|London City';
	}
}

document.forms[0].elements['destCountry'].value = document.forms[0].elements['arvcountry'][document.forms[0].elements['arvcountry'].selectedIndex].text;
document.forms[0].elements['destAirport'].value = document.forms[0].elements['arv'][document.forms[0].elements['arv'].selectedIndex].text;
document.forms[0].elements['arrRegion'].value =  document.forms[0].elements['dptCounty'][document.forms[0].elements['dptCounty'].selectedIndex].text;
document.forms[0].elements['arrAirport'].value =  document.forms[0].elements['dpt'][document.forms[0].elements['dpt'].selectedIndex].text;



}

var qsParm = new Array();
function qs() {
	var query = window.location.search.substring(1);
	var parms = query.split('&');
	for (var i=0; i<parms.length; i++) {
   	var pos = parms[i].indexOf('=');
   	if (pos > 0) {
      var key = parms[i].substring(0,pos);
      var val = parms[i].substring(pos+1);
      qsParm[key] = val;
      }
   }
}




