// JavaScript Document

$(document).ready(function() {




	$("#carriers .checkbox input").click(function() {
		services();				
	})
	
	$(".none").click(function() {
		$("#carriers input:checkbox").attr('checked', false);			
		services();
	})
	$(".all").click(function() {
		$("#carriers input:checkbox").attr('checked', true);
		services();
	})
	
	services();
		
	
function services(){
	arr = new Array;
	$(".checkbox input:checked").each(
		function() {
			arr.push($(this).val());
		});
			
			$.post("services.php",{
				   'carrier[]': arr
			 }, function(response){
				$("#main table").html('<tr style="background:url(images/bg.gif) repeat-x top;"><th style="background:url(images/left.gif) no-repeat left top; width:100px !important;" width="100"><p>Airline<img src="images/question.gif" title="Toggle carrier choice and Domestic or International using filter boxes to the left" alt="tooltip" /></p></th><th width="150" style="width:150px"><p>Baggage fees<img src="images/question.gif" title="Fees charged for bags that exceed airline allowances" alt="tooltip" /></p></th><th width="150"><p>Amenity fees<img src="images/question.gif" alt="tooltip" title="Fees charged for optional onboard extras" /></p></th><th width="200"><p>Seating fees<img src="images/question.gif" alt="tooltip" title="Fees charged for choice of preferred seat; unaccompanied minor fees generally include escort during travel for minor child" /></p></th><th width="100"><p>Minor Range<img src="images/question.gif" title="Age range allowed by airline for children to travel alone" alt="tooltip" /></p></th><th width="50" style="background:url(images/right.gif) no-repeat right top;"><p style="background:none;">Total</p></th></tr>' + response );
				
				$("#main input:checkbox").click(function(){
					//calculate
					var row = $(this).parent().parent();
					
					var n = 1*0;
					var str = "";
					$("input:checked", row).each(function() {
						n += 1*$(this).attr("value");	
					});
					n = n.toFixed(2);
					$("td span", row).text(n);
					
				});	
				$('th img').tooltip({ track: true, delay: 0, showURL: false});
				
				})
			
		
		
		return false;
}




	
});	
