/* Budget Travel - booking module */

$(document).ready(function()
{
	/* submit button roll-over effects */
	$('#wrapper_rightrail #rr_booking_wrapper .submit_form input').hover(function(){$(this).css('background-position','0px -260px');},function(){$(this).css('background-position','0px -240px');});
	$('#wrapper_rightrail #rr_booking_wrapper .submit_form input').click(function(){$(this).css('background-position','0px -280px');});
	
	if(rr_booking_module_version == "popups")
	{
		/* functions for interior pages (popups) */	
		// make the strong tags behave like links
		$('#wrapper_rightrail #rr_booking_wrapper h3').hover(function(){$(this).css('textDecoration','underline');},function(){$(this).css('textDecoration','none');});
		// click the link to display the pop-up
		$('#wrapper_rightrail #rr_booking_wrapper h3').click(function()  /* when you click on the link ... */
		{
			$('#wrapper_rightrail #rr_booking_wrapper form').fadeOut('400');  /* ... hide all the pop-ups inc ase any are open */
			// $('#wrapper_rightrail #rr_booking_wrapper form').removeShadow();
			$(this).next().fadeIn('400');  /* then show this pop-up */
			$('#wrapper_rightrail .adblock').css('zIndex','-1');  /* silly ol' ie */
			// $(this).next().dropShadow({left:-1,top:0,blur:3});
		});
		// pop-ups - the "x" close button and the arrow tab
		$('#wrapper_rightrail #rr_booking_wrapper form').append('<a class="close_popup">x</a>').append('<div class="arrow"></div>');
		$('#wrapper_rightrail #rr_booking_wrapper a.close_popup').click(function()
		{
			// $('#wrapper_rightrail #rr_booking_wrapper form').removeShadow();
			$('#wrapper_rightrail #rr_booking_wrapper form').fadeOut('400');
		});
	
	}
	else
	{
		/* functions for section pages (tabs) */
		// click the first field to display the rest of the form
		$('#wrapper_rightrail #rr_booking_wrapper .places input,#wrapper_rightrail #rr_booking_wrapper h3#titleCruises').click(function()  /* in the initial view, when you click inside the first input ... */
		{
			$('#wrapper_rightrail #rr_booking_wrapper .hidden').hide();  /* ... reset all the forms to the initial view */
			$(this).css('marginBottom','8px');  /* then fix the spacing in this form before we show it */
			$(this).parent().parent().parent().find('.hidden').slideDown('fast');  /* then show the form for all the objects in this form that have the "hidden" class */
			$(this).parent().parent().parent().find('.hidden').addClass('shown');  /* and replace the "hidden" class for all objects in this form with the "shown" class */
			$(this).parent().parent().parent().find('.hidden').removeClass('hidden');
		});
		// click the tabs to switch between forms
		$('#wrapper_rightrail #rr_booking_wrapper h3').click(function()  /* when you click on a tab ... */
		{
			$('#wrapper_rightrail #rr_booking_wrapper h3').removeClass('active');  /* ... clear the "active" class from all objects */
			$('#wrapper_rightrail #rr_booking_wrapper form').removeClass('active');
			$(this).addClass('active');  /* then add the "active" class to the objects for this tab only */
			$(this).next().addClass('active');
			$('#wrapper_rightrail #rr_booking_wrapper .places input').css('marginBottom','0px');  /* then, reset the spacing in the initial view of the form (2do - if the user clicks on the tab while it's active, it sets the margin-bottom to zero, should leave the same per below) */
			$('#wrapper_rightrail #rr_booking_wrapper .hidden').hide();  /* reset all the forms to the initial view */
			$('#wrapper_rightrail #rr_booking_wrapper .shown').addClass('hidden');  /* replace all the instances of the "shown" class with "hidden" */
			$('#wrapper_rightrail #rr_booking_wrapper .shown').removeClass('shown');
		});	
	}
	
	/* the calendar popup */
	$(".inputCalendar").datepicker({
		showOn: "button",
		buttonImage: "http://www.budgettravel.com/bt-srv/images/btn_calendar_001.gif",
		buttonImageOnly: true,
		buttonText: 'Calendar',
		duration: 'fast',
		// showAnim: "drop",
		// showOptions: {direction: "up"},
		closeAtTop: false,
		clearText: '',
		prevText: '&lt;',
		nextText: '&gt;',
		currentText: '',
		changeMonth: false,
		changeYear: false,
		yearRange: '-0:+1',
		dayNamesMin: ['S', 'M', 'T', 'W', 'T', 'F', 'S'],
		changeFirstDay: false,
		minDate: new Date(2007, 1 - 1, 1),
		maxDate: '+2y'
	}).addClass("embed");
});