var LastTabOpen = "flights"

$(document).ready(function() {
		
	//Opening Times in Header
	$('a.headerOpentimes').hover(
		function() {
			$('div#headerTimes').slideDown();
		},
		function() {
			$('div#headerTimes').slideUp('fast');
	});
	
	//blueboxcontent clickable Divs
	$('div.blueboxcontent div.ListBox , div.orgboxcontent div.ListBox').each(function() {
		
		var thisLink = $(this).find('h3').children('a').attr('href');
		$(this).click(function() {
			window.location = thisLink;
		})
	})

	//hotels sidebar clickable Divs
	$('.LeftBox .View .Content .row').each(function() {
		
		var thisLink = $(this).children('div.left').find('strong a').attr('href');
		$(this).click(function() {
			window.location = thisLink;
		})
	})	
	
	
	// index blue and orange deals box hover
	$('div.blueboxcontent div.ListBox , ul.hotelsBox li , ul.domesticList li , ul.categoryList li').hover(
	function() {
		$(this).addClass('blueBoxHover');
	},
	function() {
		$(this).removeClass('blueBoxHover');	
	});
	
	$('div.orgboxcontent div.ListBox').hover(
	function() {
		$(this).addClass('orangeBoxHover');
	},
	function() {
		$(this).removeClass('orangeBoxHover');	
	});
	
	//hotelInfoext gallery tabs
	$('div#thumb-navigation img').each(function() {
		var thisImgLink = $(this).attr('src');
		$(this).click(function() {
			$('div.stack div.tab a img').attr('src' , thisImgLink.replace('/prev',''));
			$('div.stack div.tab a').attr('href' , thisImgLink.replace('/prev',''));
		})
	})
	
	$('ul.hotelsBox li:nth-child(4n) , ul.toursList li:nth-child(4n) , ul.domesticList li:nth-child(4n)').css('margin-left','0');

	//main tv
	$('div#main-photo-slider div.panel div.wrapper').each(function() {
		var tvLink = $(this).find('a').attr('href');
		$(this).click(function() {
			window.location = tvLink
		})
	});


	//page tables
	$('div.pageM_Tables table.flights tr').hover(
		function() {
			$(this).css('background-color','#f3f3f5');
		},
		function() {
		$(this).css('background-color','white');
	});
	

	$(function() {
		$("div#pingPongScroller").smoothDivScroll({
			autoScroll: "always",
			autoScrollDirection: "backandforth",
			pauseAutoScroll: "mouseover"
			});
	});
	

	var navigation_underline_functions = {
		hide: function(element) {
			$(element).slideUp(400);
		},
		show: function(element) {
			$(element).slideDown(400);
		}
	}

	$("#search .navigation").each(function(i) {
		var functions;
		if ($(this).hasClass("navigation-underline"))
			functions = navigation_underline_functions;

		var tab = new tabs({
			name: $(this).find("label input").attr("name"),
			tabs: $(this).parent().find("> .stack > .tab"),
			labels: $(this).find("label"),
			functions: functions
		});
	});
	if ($("#search-price .search-wrapper")) {
		$("#search-price .navigation").each(function(i) {
			var tab = new tabs({
				name: $(this).find("label input").attr("name"),
				tabs: $(this).parent().find("> .stack > .tab"),
				labels: $(this).find("label")
			});
		});
	}

	

	
});
