/*<!-- mp_trans_disable_start -->*/ 
var ConnectionGuide={constructor:function()
{Event.observe(window,'load',this.windowOnLoad.bindAsEventListener(this));this.airportFormSections=1;this.airportOptions=new Object();},windowOnLoad:function(event)
{this.setupAddAirportListeners(this.airportFormSections);Event.observe($('searchfrm'),'submit',this.onFormSubmit.bindAsEventListener(this));Event.observe($('clearForm'),'click',this.clearFormOnClick.bindAsEventListener(this));},clearFormOnClick:function(event)
{if(confirm('Are you sure you want to clear the form?'))
{$('product-printPdf-menu').hide();var firstFormSection=this.getNewFormSectionHTML(1);Element.update($('airpotFormSections'),firstFormSection);this.setupAddAirportListeners(1);this.deSelectOtherOptions(1);this.deSelectAllOption(1);$('chkMaps_1').disabled=false;$('chkTransfers_1').disabled=false;$('chkCities_1').disabled=false;$('chkLounges_1').disabled=false;$('chkAll_1').disabled=false;if($('addAirportSelection_1'))
Element.show($('addAirportSelection_1'));this.airportFormSections=1;Element.update($('searchFormResults'),'');}
Event.stop(event);},formOnValidate:function(culprits,errors,form)
{for(var i=1;i<=this.airportFormSections;i++)
{if($('airport_'+i).selectedIndex<1)
{errors.push('Please select an airport for leg '+i+' of your journey');culprits.push($('airport_'+i));}
var bValid=false;['chkMaps','chkTransfers','chkCities','chkLounges','chkAll'].each(function(chk)
{if($(chk+'_'+i).checked)
bValid=true;}.bind(this));if(!bValid)
{errors.push('Please check at least one option on leg '+i+' of your journey');culprits.push($('airport_'+i));}}},formOnDisplayErrors:function(culprits,errors,form)
{alert("Sorry, some required fields were not provided: \n*   "+errors.join("\n*   "));},onFormSubmit:function(event)
{var culprits=[];var errors=[];this.formOnValidate(culprits,errors,$('searchfrm'));if(errors.length)
{this.formOnDisplayErrors(culprits,errors,$('searchfrm'));Event.stop(event);return false;}
Element.update($('searchFormResults'),$('loadingMsg').innerHTML);new Ajax.Updater($('searchFormResults'),$('searchfrm').action,{postBody:Form.serialize($('searchfrm'))+'&isAjax=1&ajaxAction=getResults',onComplete:this.setupPrintListeners.closure(this)});Event.stop(event);return false;},printPage:function(event)
{var winHandle=window.open('about:blank','printWin','width=800,height=600,resizable=yes,scrollbars=yes');$('searchfrm').action+='?print=1';$('searchfrm').target="printWin";$('showConnectionInfoSubmit').click();$('searchfrm').target='';$('searchfrm').action=$('searchfrm').action.replace(/\?print=1/gi,'');if(winHandle)
winHandle.focus();Event.stop(event);},pdfPage:function(event)
{window.open(Event.element(event).href,'printWin','width=800,height=600,resizable=yes,scrollbars=yes');Event.stop(event);},setupPrintListeners:function(event)
{['pdfConnectionInfoA4Top','pdfConnectionInfoLetterTop','pdfConnectionInfoA4Bottom','pdfConnectionInfoLetterBottom'].each(function(elm)
{Event.observe($(elm),'click',this.pdfPage.bindAsEventListener(this));}.bind(this));if($('product-printPdf-menu'))
{$('product-printPdf-menu').show();$('product-printPdf-menu').style.display='block';$('product-printPdf-menu').visibility='visible';$A($('product-printPdf-menu').getElementsByTagName('a')).each(function(link)
{link.href+='&'+Form.serialize($('searchfrm'));Event.observe(link,'click',this.pdfPage.bindAsEventListener(this));}.bind(this));}},setupAddAirportListeners:function(i)
{if($('addAirportSelection_'+i))
{Event.observe($('addAirportSelection_'+i),'click',this.duplicateFormElements.bindAsEventListener(this));}
if($('airport_'+i))
{Event.observe($('airport_'+i),'change',this.airportOnChange.bindAsEventListener(this));}
if($('chkAll_'+i))
{Event.observe($('chkAll_'+i),'click',this.allCheckOnClick.bindAsEventListener(this));Event.observe($('chkMaps_'+i),'click',this.otherOptionsOnClick.bindAsEventListener(this));Event.observe($('chkTransfers_'+i),'click',this.otherOptionsOnClick.bindAsEventListener(this));Event.observe($('chkLounges_'+i),'click',this.otherOptionsOnClick.bindAsEventListener(this));Event.observe($('chkCities_'+i),'click',this.otherOptionsOnClick.bindAsEventListener(this));}},resetCheckBoxes:function(i)
{$('chkMaps_'+i).disabled=false;$('chkTransfers_'+i).disabled=false;$('chkLounges_'+i).disabled=false;$('chkCities_'+i).disabled=false;$('chkMaps_'+i).checked=false;$('chkTransfers_'+i).checked=false;$('chkLounges_'+i).checked=false;$('chkCities_'+i).checked=false;},airportOnChange:function(event)
{var elm=Event.element(event);var formSectionIndex=elm.id.split('_')[1];var airportCode=Form.Element.getValue(elm);if(elm.selectedIndex>0)
{this.resetCheckBoxes(formSectionIndex);if(!this.airportOptions[airportCode])
{new Ajax.Request($('searchfrm').action,{postBody:'ajaxAction=getAirportDataOptions&isAjax=1&airport='+airportCode+'&formSectionIndex='+formSectionIndex,onSuccess:this.onAirportDataOptionsResult.closure(this)});}
else
{this.airportOptions[airportCode].formSectionIndex=formSectionIndex;this.processAirportOptions(this.airportOptions[airportCode]);}}},onAirportDataOptionsResult:function(response)
{try
{eval(response.responseText);}
catch(err)
{alert('failed to get the options available for this airport: '+err.message);}},processAirportOptions:function(objOptions)
{if(!this.airportOptions[objOptions.airport])
{this.airportOptions[objOptions.airport]=objOptions;}
$('chkLounges_'+objOptions.formSectionIndex).disabled=(!objOptions.chkLounges);$('chkCities_'+objOptions.formSectionIndex).disabled=(!objOptions.chkCities);$('chkTransfers_'+objOptions.formSectionIndex).disabled=(!objOptions.chkTransfers);$('chkMaps_'+objOptions.formSectionIndex).disabled=(!objOptions.chkMaps);},allCheckOnClick:function(event)
{var elm=Event.element(event);var idx=elm.id.split('_')[1];this.deSelectOtherOptions(idx);},deSelectAllOption:function(index)
{if($('chkAll_'+index))
$('chkAll_'+index).checked=false;},otherOptionsOnClick:function(event)
{var elm=Event.element(event);var idx=elm.id.split('_')[1];this.deSelectAllOption(idx);},deSelectOtherOptions:function(index)
{if($('chkMaps_'+index))
$('chkMaps_'+index).checked=false;if($('chkTransfers_'+index))
$('chkTransfers_'+index).checked=false;if($('chkLounges_'+index))
$('chkLounges_'+index).checked=false;if($('chkCities_'+index))
$('chkCities_'+index).checked=false;},duplicateFormElements:function(event)
{var elm=Event.element(event);var formIndex=parseInt(elm.id.split('_')[1]);var newIndex=parseInt(formIndex+1);if($('connectionDB_'+formIndex))
new Insertion.After($('connectionDB_'+formIndex),this.getNewFormSectionHTML(newIndex));this.setupAddAirportListeners(newIndex);this.deSelectOtherOptions(newIndex);this.deSelectAllOption(newIndex);if($('airport_'+newIndex))
$('airport_'+newIndex).selectedIndex=0;if($('addAirportSelection_'+formIndex))
Element.hide($('addAirportSelection_'+formIndex));if($('addAirportSelection_'+newIndex))
Element.show($('addAirportSelection_'+newIndex));this.airportFormSections++;Event.stop(event);return false;},getNewFormSectionHTML:function(idx)
{var sHTML=Element.outerHTML($('connectionDB_1'));sHTML=sHTML.replace(/_1/gi,'_'+idx);return sHTML;}};ConnectionGuide=Base.extend(ConnectionGuide);
 /*<!-- mp_trans_disable_end -->*/