var myBaseURL = '' ;
var BaseURL = '';
var bigChartSize = false;

var MainQuoteSimbol = '';
var QuoteBoxSimbol = '';



function Update( myLocation, urlContent, preLoader)
{
	var contentHeight = GetObjectHeight( myLocation );

	var contentString = new String;
	this.d = document.getElementById( myLocation );
	
	if ( preLoader )
	{
		this.d.innerHTML = '<div id="loading" style="height: ' + contentHeight + 'px;"><br>Loading...</div>';
	}

	contentString = urlContent.indexOf( "?" ) > 0 ? GetFileContent( urlContent + "&anticache=" + Math.random() ) : GetFileContent( urlContent + "?anticache=" + Math.random() );

	this.d.innerHTML   = contentString;
	return ( true );
 }


 function actionQuoteMenu( theMenuItem, afterLoadAction ) {

	var i;
	var menuItems = new Array();
	var menuQuote = new Array();
	// use a hidden field with symbol value - qs

	menuItems[1] = document.getElementById('q_zbor');
	menuItems[2] = document.getElementById('q_hotel');
	menuItems[3] = document.getElementById('q_car');
	
	menuQuote[1] = "reservations?reserv_action=zbor";
	menuQuote[2] = "reservations?reserv_action=hotel";
	menuQuote[3] = "reservations?reserv_action=car";

	for ( i in menuItems ) {

		if ( menuItems[i] == theMenuItem ) {

			menuItems[i].firstChild.className ="selected";
			Update( 'q_content'  ,myBaseURL+menuQuote[i], true );
			Calendar.setup({
				inputField     :    "date_a",   // id of the input field
				ifFormat       :    "%d/%m/%Y",       // format of the input field
				showsTime      :    false,
				timeFormat     :    "24",
			});
			Calendar.setup({
				inputField     :    "date_b",
				ifFormat       :    "%d/%m/%Y",
				showsTime      :    false,
				timeFormat     :    "24",
			});
			if ( undefined != afterLoadAction ) {
				eval( afterLoadAction );
			}

		} else {
			menuItems[i].firstChild.className ="";
		}
	}
}

function ProcessTSM( what )
{
	var requestUrl;
	switch (what)
	{
		case "f":
			fromCity = ( document.getElementById('from_code').value != "") ? document.getElementById('from_code').value : document.getElementById('from_location').value ;
			toCity = ( document.getElementById('to_code').value != "") ? document.getElementById('to_code').value : document.getElementById('to_location').value;
			passengers = document.getElementById('passengers').options[document.getElementById('passengers').selectedIndex].value;
			fromDate = document.getElementById('date_a').value;
			toDate = document.getElementById('date_b').value;
			requestUrl = myBaseURL + "reservations?reserv_action=zbor&status=process&from="+fromCity+"&to="+toCity+"&pas="+passengers+"&start="+fromDate+"&end="+toDate;
			break;
		case "h":
			fromCity = ( document.getElementById('from_code').value != "") ? document.getElementById('from_code').value : document.getElementById('from_location').value ;
			toCity = ( document.getElementById('to_code').value != "") ? document.getElementById('to_code').value : document.getElementById('to_location').value;
			requestUrl = myBaseURL + "reservations?reserv_action=zbor&status=process&from="+fromCity+"&to="+toCity;
			break;
		case "c":
			fromCity = ( document.getElementById('from_code').value != "") ? document.getElementById('from_code').value : document.getElementById('from_location').value ;
			toCity = ( document.getElementById('to_code').value != "") ? document.getElementById('to_code').value : document.getElementById('to_location').value;
			requestUrl = myBaseURL + "reservations?reserv_action=zbor&status=process&from="+fromCity+"&to="+toCity;
			break;
	}
	Update( 'q_content'  ,myBaseURL+requestUrl+"&via=tsm", true );
	Calendar.setup({
		inputField     :    "date_a",   // id of the input field
		ifFormat       :    "%d/%m/%Y",       // format of the input field
		showsTime      :    false,
		timeFormat     :    "24",
	});
	Calendar.setup({
		inputField     :    "date_b",
		ifFormat       :    "%d/%m/%Y",
		showsTime      :    false,
		timeFormat     :    "24",
	});
	installGSHandler();
	StartTSM ( what );
}


function StartTSM ( what )
{
	if (document.getElementById('ready') == undefined )
	return false;

	switch (what)
	{
		case "f":
	
			alert ('startTSM');
			url = 'http://www.travelstoremaker.com/cgit/runhttl?';
			url +=	'fromcity=' + document.getElementById('fcity').value;
			url +=	'&outmonth=' + document.getElementById('omonthvalue').value;
			url +=	'&outday=' + document.getElementById('odayvalue').value;
			url +=	'&tocity=' + document.getElementById('tcity').value;
			url +=	'&retmonth=' + document.getElementById('rmonthvalue').value;
			url +=	'&retday=' + document.getElementById('rdayvalue').value;
			url +=	'&ptc1=ADT';
			url +=	'&numptc1=' + document.getElementById('npas').value;
			url +=	'&agentid=ddd';
			url +=	'&command=flights';
			url +=	'&externalprefs=Y';
			url +=	'&triptype=ROUNDTRIP';
			url +=	'&serviceclass=Any';
			url +=	'&selectedticket=ETICKET';
			url +=	'&meta_go=*';
			url +=	'&meta_do=do_power';
			url +=	'&path=add/Progress';
			url +=	'&maxfaresshown=30';
			url +=	'&maxflightsshown=10';
			url +=	'&outhour=8';
			url +=	'&rethour=8';
			break;
	}
	alert(url);
	window.open (url,"tsm_window");
	
}

function ProcessEXP( what )
{
	var requestUrl;
	switch (what)
	{
		case "f":
			fromCity = ( document.getElementById('from_code').value != "") ? document.getElementById('from_code').value : document.getElementById('from_location').value ;
			toCity = ( document.getElementById('to_code').value != "") ? document.getElementById('to_code').value : document.getElementById('to_location').value;
			passengers = document.getElementById('passengers').options[document.getElementById('passengers').selectedIndex].value;
			fromDate = document.getElementById('date_a').value;
			toDate = document.getElementById('date_b').value;
			requestUrl = myBaseURL + "reservations?reserv_action=zbor&status=process&from="+fromCity+"&to="+toCity+"&pas="+passengers+"&start="+fromDate+"&end="+toDate;
			break;
		case "h":
			fromCity = ( document.getElementById('from_code').value != "") ? document.getElementById('from_code').value : document.getElementById('from_location').value ;
			toCity = ( document.getElementById('to_code').value != "") ? document.getElementById('to_code').value : document.getElementById('to_location').value;
			requestUrl = myBaseURL + "reservations?reserv_action=zbor&status=process&from="+fromCity+"&to="+toCity;
			break;
		case "c":
			fromCity = ( document.getElementById('from_code').value != "") ? document.getElementById('from_code').value : document.getElementById('from_location').value ;
			toCity = ( document.getElementById('to_code').value != "") ? document.getElementById('to_code').value : document.getElementById('to_location').value;
			requestUrl = myBaseURL + "reservations?reserv_action=zbor&status=process&from="+fromCity+"&to="+toCity;
			break;
	}
	Update( 'q_content'  ,myBaseURL+requestUrl+"&via=exp", true );
	Calendar.setup({
		inputField     :    "date_a",   // id of the input field
		ifFormat       :    "%d/%m/%Y",       // format of the input field
		showsTime      :    false,
		timeFormat     :    "24",
	});
	Calendar.setup({
		inputField     :    "date_b",
		ifFormat       :    "%d/%m/%Y",
		showsTime      :    false,
		timeFormat     :    "24",
	});
	installGSHandler();
	StartEXP ( what );
}


function StartEXP ( what )
{
	if (document.getElementById('ready') == undefined )
	return false;

	switch (what)
	{
		case "f":
			/* http://www.expedia.com/pub/agent.dll?qscr=fexp&flag=q&city1=muc&citd1=sbz&date1=3/17/08&date2=3/23/08&cAdu=1&cSen=0&cChi=0&cInf=&infs=2&tktt=&ecrc=&eccn=&qryt=8&rdct=1&affcid=cj2853360 */
			alert ('startTSM');
			url = 'http://www.expedia.com/pub/agent.dll?';
			url +=	'&qscr=fexp';
			url +=	'&flag=q';
			url +=	'&city1=' + document.getElementById('fcity').value;
			url +=	'&citd1=' + document.getElementById('tcity').value;
			url +=	'&date1=' + document.getElementById('eodate').value;
			url +=	'&date2=' + document.getElementById('erdate').value;
			url +=	'&cAdu=' + document.getElementById('npas').value;
			url +=	'&cSen=0';
			url +=	'&cChi=0';
			url +=	'&cInf=';
			url +=	'&infs=2';
			url +=	'&tktt=';
			url +=	'&ecrc=';
			url +=	'&eccn=';
			url +=	'&qryt=8';
			url +=	'&rdct=1';
			url +=	'&affcid=cj2853360';
			break;
	}
	alert(url);
	window.open (url,"exp_window");
	
}

 