var lang="nl"; $(document).ready(function(){ if ($(window).width() > 461) { $(".quicksearchbox").equalHeights(); } //$(".quicksearchbox").css({'overflow' : 'hidden'}); ajaxLoaderDisplay('ajaxLoaderStep2', 'box2'); ajaxLoaderDisplay('ajaxLoaderStep3', 'box3'); if(typeof(lang) == 'undefined') { lang = 'en'; } $("#origininstructions1,#origininstructions2").css({color:'red'}); $("#destinationinstructions1,#destinationinstructions2,#airlineinstructions1,#airlineinstructions2").css({color:'black'}); $('#Origin').attr('selected', false); $("#Origin").change(function(event){ $('#Destination').empty(); $("#ajaxLoaderStep2").show(); $('#Destination').html(""); $("#destinationinstructions1,#destinationinstructions2").css({color:'red'}); $("#origininstructions1,#origininstructions2,#airlineinstructions1,#airlineinstructions2").css({color:'black'}); // origin is airport code, not an element var origin = $('#Origin').val(); $.getJSON('airline_box1_json.php', {selected_origin: origin, 'lang': lang}, function(json) { var dest = $('#Destination').empty(); //console.debug(json); // TODO. Remove this $.each(json.routes, function(id, route) { var optgroup = $('').attr({value: airport.tocode}).html(airport.airportname + ' (' + airport.tocode + ')').appendTo(optgroup); }); }); $("#ajaxLoaderStep2").hide(); }); $("#airlinegroup").html("Select eindbestemming van de lijst"); _gaq.push(['_trackEvent', 'Searchbox', 'Box1Click']); }); $("#Destination").change(function(event){ $("#ajaxLoaderStep3").show(); $('#airlinegroup').html("Luchthavens laden..."); // origin and destinaion are airport codes var origin = $('#Origin').val(); var destination = $('#Destination').val(); //console.debug(origin, destination); // TODO. Remove this $.get('airline_box2.php', {selected_origin: origin, selected_destination: destination, 'lang': lang}, function(data) { $('#airlinegroup').html(data); $("#ajaxLoaderStep3").hide(); $("#origininstructions1,#origininstructions2,#destinationinstructions1,#destinationinstructions2").css({color:'black'}); $("#airlineinstructions1,#airlineinstructions2").css({color:'red'}); }); _gaq.push(['_trackEvent', 'Searchbox', 'Box2Click']); }); function ajaxLoaderDisplay(loaderDiv, capsuleDiv) { var oHeight = $('#'+capsuleDiv).height(); var oWidth = $('#'+capsuleDiv).width(); var eWidth = $('#'+loaderDiv).width(); var eHeight = $('#'+loaderDiv).height(); var eX = parseInt((oWidth - eWidth)/2); var eY = parseInt((oHeight - eHeight)/2); $('#'+loaderDiv).css({'top' : eY + 'px' , 'left' : eX + 'px', 'position' : 'absolute'}); } });