

//This is a simple script for the large drop downs on the main menu

$(document).ready(function() {
	function addMega()
	{
		$(this).addClass("hovering");
		$($(this).find("a")).addClass("hover");
	}
	function removeMega()
	{
		$(this).removeClass("hovering");
		$($(this).find("a")).removeClass("hover");
	}
	var megaConfig = 
	{
		interval: 200,
		sensitivity: 10,
		over: addMega,
		timeout: 300,
		out: removeMega
	};
	$("li.mega").hoverIntent(megaConfig);
});


//Closes large map on the trip page and then allows it to be opened by the enlarge anchor
$(document).ready(function(){
	$('#bigmap').hide();
	$('#zoom_map').bind('click',function(){
		$('#bigmap').show();
	    return false;
	});
	$('#bigmap').bind('click',function(){
		$('#bigmap').hide();
	    return false;
	});
});


//Hides and shows the 'What's this' notes on the trip page
$(document).ready(function(){
	$('.note').hide();
	$('.has_note').toggle(
	    function() {
	        $(this).parent().next('.note').show();
	        $(this).text('Close note!');
	    },
	    function() {
	        $(this).parent().next('.note').hide();
	        $(this).text("What's this?");
	    });
});


//Tabs for the trip page
$(document).ready(function(){
	$('#lodging , #rating').addClass('off');
	$('#tab_itinerary a').addClass('on');
	$('#tab_itinerary').click(function(){
		$('#tabs li h4 a').removeClass('on');
		$('#tab_itinerary a').addClass('on');
		$('.tab_content').addClass('off');
		$('#itinerary').removeClass('off');
	});
	$('#tab_lodging, #other_lodgingTab').click(function(){
		$('#tabs li h4 a').removeClass('on');
		$('#tab_lodging a').addClass('on');
		$('.tab_content').addClass('off');
		$('#lodging').removeClass('off');
	});	
	$('#tab_rating, #other_ratingTab').click(function(){
		$('#tabs li h4 a').removeClass('on');
		$('#tab_rating a').addClass('on');
		$('.tab_content').addClass('off');
		$('#rating').removeClass('off');
	})
});


//Menu slider
$(document).ready(function(){
	if(!$('#calender_nav')){ return false};
	$('#calender_nav ul').hide();
	$('#calender_nav ul:first').show();
	$('#calender_nav h3').click(
	function() {
		var checkElement = $(this).next();
		if((checkElement.is('ul')) && (checkElement.is(':visible'))) {
			return false;
		}
		if((checkElement.is('ul')) && (!checkElement.is(':visible'))) {
			$('#calender_nav ul:visible').slideUp('normal');
			checkElement.slideDown('normal');
			return false;
		}
	}
	);
});


//Table stripe
$(document).ready(function(){
	if(!$('table tr.departures')){ return false};
	$('tr.departures:visible').filter(':nth-child(even)').each(function(index) { 
  		$(this).addClass('odd');
	});
});

//Removing the dotted border off the top region trip in the search results
$(document).ready(function(){
	if(!$('div.region div:first-child')){ return false};
	$('div.region div:first-child').each(function(){
		$(this).addClass('first');
	});
});

//Removing the solid border off the top location group in the search results
$(document).ready(function(){
	if(!$('div.location:nth-child(3)')){ return false};
	$('div.location:nth-child(3)').each(function(){
		$(this).addClass('first');
	});
});


var profiles =
	{
		window600:
		{
			height:600,
			width:500,
			status:1,
			location:0
		}
	};


$(function()
	{
		if($('.popupwindow').length > 0){ 
			$(".popupwindow").popupwindow(profiles);
		};
	});



function openScript(url, width, height, left, top) {
    var Win = window.open(url,"openScript",'width=' + width + ',height=' + height + ',resizable=0,scrollbars=yes,menubar=no,status=no,left=0,top=10' );
}








