$(function() {
	//set flight info arrivals
	$.ajax({
	  type: "GET",
	  url: "ajax.fetch.flights.php",
	  data: "type=a",
	  success: function(response){
	  	$("#tbl-flights").html(response);
	  }
	 });

	//initialize Flight Info tabs behavior
	$(".tab").click( function() {
		var tab_data = ($(this).attr("class").split(" ")[1].split("-"));
		if (typeof tab_data[1]=="undefined") {
			$(this).attr("class", "tab " + tab_data[0] + "-on");
			var to_blur = (tab_data[0]=="a") ? "d" : "a";
			$("#" + to_blur).attr("class", "tab " + to_blur);
			$.ajax({
			  type: "GET",
			  url: "ajax.fetch.flights.php",
			  data: "type="+tab_data[0],
			  success: function(response){
			  	$("#tbl-flights").html(response);
			  }
			});
		}
		$(this).blur();
		return false;
	});
});