function imgchng(name, src){
	document[name].src = src;
}

function popbill(pop){
	var i;
	
	if (pop){
		document.forms[0].txtCardholder.value = p1fn + ' ' + p1ln;
		document.forms[0].txtAddr1.value = p1a1;
		document.forms[0].txtAddr2.value = p1a2;
		document.forms[0].txtCity.value = p1ct;
		document.forms[0].txtPCode.value = p1pc;
		document.forms[0].txtPhone.value = p1ph;		
		document.forms[0].lstProv.selectedIndex = p1pr;	
		inner: for(i = 0; i < document.forms[0].lstCtry.length; i++){
			if(document.forms[0].lstCtry.options[i].value == p1cn){
				document.forms[0].lstCtry.options[i].selected = true;
				break inner;
			}
		}
		inner: for(i = 0; i < document.forms[0].lstProv.length; i++){
			if(document.forms[0].lstProv.options[i].value == p1pr){
				document.forms[0].lstProv.options[i].selected = true;
				break inner;
			}
		}
	}
	else{
		document.forms[0].txtCardholder.value = '';
		document.forms[0].txtAddr1.value = '';
		document.forms[0].txtAddr2.value = '';
		document.forms[0].txtCity.value = '';
		document.forms[0].txtPCode.value = '';
		document.forms[0].txtPhone.value = '';		
		document.forms[0].lstProv.selectedIndex = 0;
		document.forms[0].lstCtry.selectedIndex = 0;
	}
}

// Method to create the shop item desription page.../

var shopDetails_window

function DisplayShopDetails(sSSRName, sSSRDesc, sSSRPrice) {
	var  w, h;
	
	if (document.all || document.layers) {
		w = screen.availWidth;
		h = screen.availHeight;
	} else {
		w = screen.width;
		h = screen.height;
	}
	
	if (window_available()) {
			// if the window is open, close it.../
			shopDetails_window.close()		
	}

	// Center window
		var popW = 520;
		var popH = 300;
		var popH;
		var leftPos = (w-popW)/2, topPos = h/5;
	
		var dimensions = "width=" + popW +
						 ", height=" + popH +
						 ",top=" + topPos +
						 ",left=" + leftPos;				
								
		shopDetails_window = window.open("", 'shopDetails_window', 'location=no,toolbar=no,status=no,resizable=no,scrollbars=yes,'+ dimensions);
		//shopDetails_window.focus()
		
		// write the html tags for the new window.../
		shopDetails_window.document.writeln('<html>')
		shopDetails_window.document.writeln('<link rel="stylesheet" href="styles/resstyles.css" type="text/css">')		
		shopDetails_window.document.writeln('<head>')
		shopDetails_window.document.writeln('<title>')
		shopDetails_window.document.writeln('<\/title>')
		shopDetails_window.document.writeln('<\/head>')
		
		// make sure that there are no margins.../
		shopDetails_window.document.writeln('<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">')
		shopDetails_window.document.writeln('<table>')
		// header info row.../
		shopDetails_window.document.writeln('<tr>')
		shopDetails_window.document.writeln('<td class=tdShopDetsHdr align=left>')
		shopDetails_window.document.writeln(sSSRName)
		shopDetails_window.document.writeln('<\/td>')
		shopDetails_window.document.writeln('<\/tr>')
		// details info row.../
		shopDetails_window.document.writeln('<tr>')
		shopDetails_window.document.writeln('<td class=tdShopDetsDesc align=left>')
		shopDetails_window.document.writeln(sSSRDesc)
		shopDetails_window.document.writeln('<\/td>')
		shopDetails_window.document.writeln('<\/tr>')
		// details price row.../
		shopDetails_window.document.writeln('<tr>')
		shopDetails_window.document.writeln('<td class=tdShopDetsDesc align=left>')
		shopDetails_window.document.writeln(sSSRDesc)
		shopDetails_window.document.writeln('<\/td>')
		shopDetails_window.document.writeln('<\/tr>')
		shopDetails_window.document.writeln('<\/table>')
		shopDetails_window.document.writeln('</html>')		
		
	}
	
function window_available() {
	if (!shopDetails_window) {
		return false
	}
	else if (shopDetails_window.closed) {
		return false
	}
	else {
		return true
	}	
}


// create popup window to search for pax
function paxsearch(pax) {
	var searchwin
	var query
	var w, h;

	if (document.all || document.layers) {
		w = screen.availWidth;
		h = screen.availHeight;
	} else {
		w = screen.width;
		h = screen.height;
	}	
		
	// Center window
	var popW = 850, popH = 400;
	var leftPos = (w-popW)/2, topPos = (h-popH)/2;
	
	if(pax==1)
		query = '&pax=' + pax + '&paxid=' + document.forms[0].elements['hidPax' + pax + '_Search'].value + '&fname=' + document.forms[0].elements['txtPax' + pax + '_FName'].value + '&lname=' + document.forms[0].elements['txtPax' + pax + '_LName'].value + '&phone1=' + document.forms[0].elements['txtPax' + pax + '_Phone1'].value + '&phone2=' + document.forms[0].elements['txtPax' + pax + '_Phone2'].value
	else
		query = '&pax=' + pax + '&paxid=' + document.forms[0].elements['hidPax' + pax + '_Search'].value + '&fname=' + document.forms[0].elements['txtPax' + pax + '_FName'].value + '&lname=' + document.forms[0].elements['txtPax' + pax + '_LName'].value + '&phone1=' + document.forms[0].elements['txtPax' + pax + '_Phone1'].value
        
	searchwin = window.open('searchpax.aspx' + location.href.substr(location.href.indexOf('?')) + query, '_paxsearch', 'location=no,toolbar=no,status=yes,scrollbars=yes,resizable=no,'+'width=' + popW + ',height=' + popH + ',top=' + topPos + ',left=' + leftPos); }

// create popup window to search for pax
function paxsearchadd(pax) {
	var searchwin
	var query
	var w, h;

	if (document.all || document.layers) {
		w = screen.availWidth;
		h = screen.availHeight;
	} else {
		w = screen.width;
		h = screen.height;
	}	
		
	// Center window
	var popW = 850, popH = 400;
	var leftPos = (w-popW)/2, topPos = (h-popH)/2;
	
	query = '&pax=' + pax + '&paxid=' + document.forms[0].elements['hidPax' + pax + '_Search'].value + '&fname=' + document.forms[0].elements['txtPaxNew' + pax + '_FName'].value + '&lname=' + document.forms[0].elements['txtPaxNew' + pax + '_LName'].value + '&phone1=' + document.forms[0].elements['txtPaxNew' + pax + '_Phone1'].value
        
	searchwin = window.open('searchpax.aspx' + location.href.substr(location.href.indexOf('?')) + query, '_paxsearchadd', 'location=no,toolbar=no,status=yes,scrollbars=yes,resizable=no,'+'width=' + popW + ',height=' + popH + ',top=' + topPos + ',left=' + leftPos); }


function DisplayCityPairs(sQTName, sIdent) {				
				
	var sHeader = "<h2>Valid City Pairs</h2>";
	var sHTML = "<table width='100%'><tr><td colspan='2'>" + sQTName + " - <a href='javascript:HideCityPairs();'>Hide</a></td></tr>";
	var sFooter = "</table>";
	var sItems = "<tr><th width='50%'>From</th><th>To</th></tr>";				
	var i;	
	
	// loop through the array to get all the required city pairs and output to screen.../
	for	(i = 0; i < aQuickTickets[sIdent].length; ++i){
		var sDepApt;
		var sArvApt;
		
		sDepApt = aQuickTickets[sIdent][i].slice(0,1)
		sArvApt = aQuickTickets[sIdent][i].slice(1)
			
		sItems = sItems + "<tr><td align='center'>" + sDepApt + "</td><td align='center'>" + sArvApt + "</td></tr>";
					
	}
	sHTML = sHeader + sHTML + sItems + sFooter;
	document.getElementById("QTCityPairs").innerHTML = sHTML;							
}

function HideCityPairs() {
	document.getElementById("QTCityPairs").innerHTML = "";
}
