var portalCode="fiestatravel";

function createActionUrl(pageToGo)

{

	return "http://epowerv4.amadeus.com.tr/" + portalCode + "/portals/" + portalCode +"/" + pageToGo;



}



function getActionUrl(formObj,pageToGo)

{

	formObj.action= createActionUrl(pageToGo);

	return true;

}


$(document).ready(function(){



		

		/*

		$('#qfAmadeus').submit(function () {

			var prov = jQuery('[name=External_FlightSearchTypeByProvider]');

			var i = 0;

			jQuery.each(prov, function() {

				if (jQuery(this).attr('checked') == true) {

					i++;

				}

			});



			if(i == 0) {

				alert('Моля, изберете тип превозвач.');

				return false;

			}

		});

		*/



	   $('#calendar-trigger-img').click(function(){



		   showHideIE('none');

		   });

	   $('#calendar-trigger-to-img').click(function(){



		   showHideIE('none');

		   });



	 });



function showHideIE(type)

{



	if ($.browser.msie && $.browser.version.substr(0,1)<7) {



	//$('#div-B_LOCATION_1').css('display',type);

	$('#div-E_LOCATION_1').css('display',type);

	$('#div-CHDPAX').css('display',type);

	$('#div-selectInf').css('display',type);



	}

}


function PopupOpenCenter(OpenPage,PopupName,Width,Height,Properties)

{

	Left=(screen.availWidth-Width)/2;



	Top=(screen.availHeight-Height)/2;



	window.name = "flightForm";

	window.open(OpenPage,PopupName,Properties + ',top='+Top+',left='+Left+ ',width='+Width+',height='+Height);

}



//AMADEUS

DDLHeight=30;

function ctl00_ctl00_ctl00_wpm1_gwpc1_c1_lbAirlineList_ddlAirlineDDLClear()

{

	document.getElementById('ctl00_ctl00_ctl00_wpm1_gwpc1_c1_lbAirlineList_text').value='';

	document.getElementById('ctl00_ctl00_ctl00_wpm1_gwpc1_c1_lbAirlineList_value').value='';

	DDLHeight=15;

	clearDD(document.getElementById('ctl00_ctl00_ctl00_wpm1_gwpc1_c1_lbAirlineList_ddl'));

	jQuery('#ctl00_ctl00_ctl00_wpm1_gwpc1_c1_lbAirlineList_ddl').css("height", 20);

}



function ctl00_ctl00_ctl00_wpm1_gwpc1_c1_lbAirlineList_ddladdItemAirlineDDl(addText,addValue)

{

	var i=0;

	addDDL=document.getElementById('ctl00_ctl00_ctl00_wpm1_gwpc1_c1_lbAirlineList_ddl');

	if (addDDL)

	{

		DDLHeight+=15;

		jQuery('#ctl00_ctl00_ctl00_wpm1_gwpc1_c1_lbAirlineList_ddl').css("height", DDLHeight);

		addDDL.options[addDDL.options.length]=new Option(addText,addValue);

		document.getElementById('ctl00_ctl00_ctl00_wpm1_gwpc1_c1_lbAirlineList_text').value='';

		document.getElementById('ctl00_ctl00_ctl00_wpm1_gwpc1_c1_lbAirlineList_value').value='';

		for(i=0;i<addDDL.options.length;i++)

		{

			document.getElementById('ctl00_ctl00_ctl00_wpm1_gwpc1_c1_lbAirlineList_text').value+=addDDL[i].text+';';

			document.getElementById('ctl00_ctl00_ctl00_wpm1_gwpc1_c1_lbAirlineList_value').value+=addDDL[i].value+';';

		}

	}

}

function ctl00_ctl00_ctl00_wpm1_gwpc1_c1_lbAirlineList_ddlStartValuesFill()

{

	var i=0;

	var ItemTexts=document.getElementById('ctl00_ctl00_ctl00_wpm1_gwpc1_c1_lbAirlineList_text').value.split(';');

	var ItemValues=document.getElementById('ctl00_ctl00_ctl00_wpm1_gwpc1_c1_lbAirlineList_value').value.split(';');

	ctl00_ctl00_ctl00_wpm1_gwpc1_c1_lbAirlineList_ddlAirlineDDLClear();

	for(i=0;i<ItemTexts.length;i++)

	{

		if(ItemTexts[i]!='')

		{

			ctl00_ctl00_ctl00_wpm1_gwpc1_c1_lbAirlineList_ddladdItemAirlineDDl(ItemTexts[i],ItemValues[i]);

		}

	}

}



function ctl00_ctl00_ctl00_wpm1_gwpc1_c1_lbAirlineList_ddlAirlineDDLClear()

{

	document.getElementById('ctl00_ctl00_ctl00_wpm1_gwpc1_c1_lbAirlineList_text').value='';

	document.getElementById('ctl00_ctl00_ctl00_wpm1_gwpc1_c1_lbAirlineList_value').value='';

	DDLHeight=15;

	clearDD(document.getElementById('ctl00_ctl00_ctl00_wpm1_gwpc1_c1_lbAirlineList_ddl'));

	jQuery('#ctl00_ctl00_ctl00_wpm1_gwpc1_c1_lbAirlineList_ddl').css("height", 20);

}



function clearDD(oDropDown)

{

  if(oDropDown==null)

      return;

  var	oOptions = oDropDown.options;

  for(var	i=oOptions.length; i>=0; i--){

    oOptions[i]	= null;

  }

}



function getDDValue(oDropDown)

{

  return oDropDown.options[oDropDown.selectedIndex].value;

}



$().ready(function() {

	function set(event, data, formatted) {

		$('#External_FlightFareSearch_From').val(formatted);

	}



	function setTo(event, data, formatted) {

		$('#External_FlightFareSearch_To').val(formatted);

	}



	function formatItem(row) {

		//return row[0] + " (<strong>" + row[1] + "</strong>)";

		return row[0];

	}

	function formatResult(row) {



		return row[0].replace(/(<.+?>)/gi, '');



	}



	//================================================== FROM

	$("#External_FlightFareSearch_FromAC").autocomplete('forms/epower/airports.php', {

		minChars: 3,

		width: 310,

		matchContains: true,

		max: 50,

		autoFill: true,

		mustMatch: false,

		parse: function(data) {

			eval('var json = ' + data);



			var array = new Array();



			jQuery.each(json, function(idx, item) {

				array.push({data: item.name, value: item.code, result: item.nameResult});

			});



			return array;



		},

		formatItem: function(v) {

			return v;

		}

	}).result(set);



	//================================================== TO airport

	$("#External_FlightFareSearch_ToAC").autocomplete('forms/epower/airports.php', {

		minChars: 3,

		width: 310,

		matchContains: true,

		max: 50,

		autoFill: true,

		mustMatch: false,

		parse: function(data) {

			eval('var json = ' + data);



			var array = new Array();



			jQuery.each(json, function(idx, item) {

				array.push({data: item.name, value: item.code, result: item.nameResult});

			});



			return array;



		},

		formatItem: function(v) {

			return v;

		}

	}).result(setTo);

});
