	
	
	loadintFlights = function(departureCity){
		jQuery("#int-airfare-ctn .airfare-content-ctn").html('<img src="/wcsstore/ConsumerDirectStorefrontAssetStore/images/home/ajax-loader-airfare.gif" />');
		jQuery.ajax({
			url: '/fcweb/flights/home-flights2.jsp?destination=international&departure='+departureCity,
			type: 'GET',
			dataType: 'html',
			timeout: 9000,
			error: function(){
			jQuery("#int-airfare-ctn .airfare-content-ctn").html("<p style='font-size: 11px; padding: 20px;'>There was an error in loading our airfare specials. Please refresh the page or <a href='http://www.flightcentre.com.au/webapp/wcs/stores/servlet/MakeEnquiryView?langId=-1&amp;storeId=10102&amp;catalogId=10101&amp;enquiry=general'>email us</a> your travel details.</p>");
			},
			success: function(html){
				jQuery('#int-airfare-ctn .airfare-content-ctn').html(html);
				jQuery('#int-airfare-ctn .airfare-content-ctn a:even').addClass('even');
			}
		});
	}
	
	
	loaddomFlights = function(departureCity){
	jQuery("#dom-airfare-ctn .airfare-content-ctn").html('<img src="/wcsstore/ConsumerDirectStorefrontAssetStore/images/home/ajax-loader-airfare.gif" />');
	jQuery.ajax({
		 url: '/fcweb/flights/home-flights2.jsp?destination=domestic&departure='+departureCity,
		 type: 'GET',
		 dataType: 'html',
		 timeout: 9000,
		 error: function(){
			jQuery("#dom-airfare-ctn .airfare-content-ctn").html("<p style='font-size: 11px; padding: 20px;'>There was an error in loading our airfare specials. Please refresh the page or <a href='http://www.flightcentre.com.au/webapp/wcs/stores/servlet/MakeEnquiryView?langId=-1&amp;storeId=10102&amp;catalogId=10101&amp;enquiry=general'>email us</a> your travel details.</p>");
		 },
		 success: function(html){
			jQuery('#dom-airfare-ctn .airfare-content-ctn').html(html);
			jQuery('#dom-airfare-ctn .airfare-content-ctn a:even').addClass('even');
		}
	});
	}
	
	hoverOverAirfare = function() {
		$('.airfare-product-line').hover(
			function(){
				$(this).addClass('hover');
			},
			function() {
				$(this).removeClass('hover');
		});
	}
	
	cityCodeTrans = function(dest) {
		var cityCodesRef = [{code:'SYD',name:'sydney'}, {code:'MEL', name:'melbourne'}, {code:'BNE',name:'brisbane'}, {code:'ADL', name:'adelaide'}, {code:'PER', name:'perth'}, {code:'CNS', name:'cairns'}, {code:'DRW', name:'darwin'}];
		var destTrans = '';
		if(dest.toString().length==3){
			destTrans = 'sydney';
			for(x in cityCodesRef) {
				if(cityCodesRef[x].code == dest){
					destTrans = cityCodesRef[x].name;
				}
			}
		} else {
			destTrans = 'SYD';
			for(x in cityCodesRef) {
				if(cityCodesRef[x].name == dest){
					destTrans = cityCodesRef[x].code;
				}
			}
		}
		return destTrans;
	}
		
	$(document).ready(function(){
		var departureCity = "sydney";
		var departureCityCode = 'SYD';

		if($.cookie('departCity')!=null){
			departureCityCode = $.cookie('departCity');
		}
			
		departureCity = cityCodeTrans(departureCityCode);
	
		$("#intAirfareDisplayFrom select").val(departureCity);
		$("#domAirfareDisplayFrom select").val(departureCity);
		
		$("#intAirfareDisplayFrom").submit(function(){
			var departureCity = $("#intAirfareDisplayFrom select").val();
      try {
			/*Google Event Tracking Start*/
			pageTracker._trackPageview('/on-page-event/home-page/airfare/international-flyfrom-clicked');
			/*Google Event Tracking End*/
      }catch(err){
        
      }
			$.cookie('departCity', cityCodeTrans(departureCity));
			loadintFlights(departureCity);
			return false;
		});
		
		$("#domAirfareDisplayFrom").submit(function(){
			var departureCity = $("#domAirfareDisplayFrom select").val();		
      try {
        /*Google Event Tracking Start*/
        pageTracker._trackPageview('/on-page-event/home-page/airfare/domestic-flyfrom-clicked');
      /*Google Event Tracking End*/
      }catch(err){
        
      }
			$.cookie('departCity', cityCodeTrans(departureCity));
			loaddomFlights(departureCity);
			return false;
		});
		
		jQuery.ajax({
			url: '/fcweb/flights/home-flights2.jsp?destination=international&departure='+departureCity,
			type: 'GET',
			dataType: 'html',
			timeout: 9000,
			error: function(){
			jQuery("#int-airfare-ctn .airfare-content-ctn").html("<p style='font-size: 11px; padding: 20px;'>There was an error in loading our airfare specials. Please refresh the page or <a href='http://www.flightcentre.com.au/webapp/wcs/stores/servlet/MakeEnquiryView?langId=-1&amp;storeId=10102&amp;catalogId=10101&amp;enquiry=general'>email us</a> your travel details.</p>");
			},
			success: function(html){
				jQuery('#int-airfare-ctn .airfare-content-ctn').html(html);
				jQuery('#int-airfare-ctn .airfare-content-ctn a:even').addClass('even');
			}
		});
		
		jQuery.ajax({
			 url: '/fcweb/flights/home-flights2.jsp?destination=domestic&departure='+departureCity,
			 type: 'GET',
			 dataType: 'html',
			 timeout: 9000,
			 error: function(){
				jQuery("#dom-airfare-ctn .airfare-content-ctn").html("<p style='font-size: 11px; padding: 20px;'>There was an error in loading our airfare specials. Please refresh the page or <a href='http://www.flightcentre.com.au/webapp/wcs/stores/servlet/MakeEnquiryView?langId=-1&amp;storeId=10102&amp;catalogId=10101&amp;enquiry=general'>email us</a> your travel details.</p>");
			 },
			 success: function(html){
				jQuery('#dom-airfare-ctn .airfare-content-ctn').html(html);
				jQuery('#dom-airfare-ctn .airfare-content-ctn a:even').addClass('even');
			}
		});
	});