$('document').ready(function() {
	$('ul#regions > li:first-child').css('background-color','#d9e1c9');
	$('ul#regions > li:nth-child(2)').css('background-color','#a0b8ad');
	$('ul#regions > li:nth-child(3)').css('background-color','#4c7482');
	// set the date format for the calendar plugin
    $.datePicker.setDateFormat('mdy', '/');
	// initalize
    $('input#arrivalDate').datePicker();
    $('input#departureDate').datePicker();
    
    // travel agent section functions
    // --------------------------
    setUpTabs();
    setUpMultiTabs(); //  for the process (post-search) page
    setUpPackageDetailToggle();
});

// show/hide animates the daily details on the packages screen
function setUpPackageDetailToggle(){
	$("a.packageDetailToggle").click(function(){
		$(this).parent().siblings("div.dailyDetail").toggle("fast");
		return false;
	});
}

// for the tabs on pages other than the process (post-search) page
// ---------------------------------------------------------------
function setUpTabs(){
	$('#tabNav li a').click(function(){
		// clear the sibling tabs
		$('#tabNav li').each(function(i){
			$(this).css("backgroundColor","#d7d6c1");
		});
		// hide all of the tab's content areas
		$("#accom, #golf, #activity").hide();
		// find and show the selected tab's content
		$(this).parent().css("backgroundColor","#ffffff");
		if($(this).parent().attr("id") == "tab-accom"){
			$("#accom").fadeIn();
		} else if ($(this).parent().attr("id") == "tab-golf"){
			$("#golf").fadeIn();
		} else if ($(this).parent().attr("id") == "tab-activity"){
			$("#activity").fadeIn();
		}
		return false;
	});
}
// ---------------------------------------------------------------


// for the tabs on the process (post-search) page
// ---------------------------------------------------------------
function setUpMultiTabs(){
	$('.tabNav li a').click(function(){
		
		$(this).parent().parent().children("li").each(function(i){
			$(this).css("backgroundColor","#d7d6c1");
			$(this).parent().siblings("div.accom, div.golf, div.activity").hide();
		});
		// find and show the selected tab's content
		// back up to li and change bg-color
		$(this).parent().css("backgroundColor","#ffffff");
		// bubble out to find the matched div with that class - then fade it in
		$(this).parent().parent().siblings("div."+$(this).parent().attr("title")).fadeIn();
		return false;
	});
}
// ---------------------------------------------------------------