$(document).ready(function() {
	getDeals('fat','departure');
	// Features Cycle plugin
	$('#s2').cycle({
		startingSlide: 0,
    	fx:     'scrollLeft',
    	timeout:  10000,
		speed: 500,
		pager:  '#nav',
		pagerAnchorBuilder: function(idx, slide) { 
       		return '<a href="#"><img src="/images/feature/feature_default.png" alt="anchor" /></a>';
    	},
		before: function(idx, slide) {
			$('#nav a').html('<img src="/images/feature/feature_default.png" alt="anchor" />');
			$('#nav a').eq($(slide).index()).html('<img src="/images/feature/feature_selected.png" alt="selected" />');
		}
	});
	$('.activeSlide').html('<img src="/images/feature/feature_selected.png" alt="selected" />');
	
	
	// Announcements -------------------------
	$("#news-slider").css({
		'height': $('#AnnouncementWrapper').height() - 79 + 'px'
	});
	var max = $('#news-feed').height() - $('#AnnouncementWrapper').height() + 10;
	if (max > 0) {
	$('#news-feed').css('top',0+'px');
	$("#news-slider").slider({
		orientation: "vertical",
		min: -max,
		max: 0,
		value: max,
		slide: function(event, ui) {
			$('#news-feed').css({'top': ui.value + 'px'});
		}
	}).removeClass('ui-corner-all');
	
	if ($('#news-feed').height() < $('#AnnouncementWrapper').height()) {
		$("#news-slider").slider("disable");
	}
	//scroll
	$('#AnnouncementWrapper').bind('mousewheel', function(event, delta) {
		 var dir = delta > 0 ? 'Up' : 'Down', vel = Math.abs(delta)*5;
		 var pos = parseInt($('#news-feed').css('top'));
		 
		 if (dir == 'Up') {
			pos = pos + vel;
		 } else if (dir == 'Down') {
			 pos = pos - vel;
		 }
		 $('#news-feed').css({'top': pos + 'px'});
		 $("#news-slider").slider('value',pos);
		 
		 if (pos >= 0) {
			 $('#news-feed').css({'top': '0'});
		 } else if (pos <= -max) {
			 $('#news-feed').css({'top':-max+'px'});
		 }
		 
	     return false;
	});
	}
	
	$("#FlightPlanner").submit(function() {
		if (($("#flighttxt").val() != $("#flighttxt").attr('title')) && ($("#airline").val() == 'ALL')) {
			alert("Please choose the airline associated with the flight number.");
		} else {
			return true;
		}
		return false;
	});
});
