// JavaScript Document
$(document).ready(function() {
						   
$(".panel:first").addClass("panelOpen"); //default panel open on load
				   			  						   
$("#btnHome").click(function(){  //panel div click						  
		$("#header").animate({opacity: "1", height: "400"}, 600)
			$("#header").addClass("panelOpen")
			$(".subContentPanel").hide();
			$("#news, #about, #calendar, #contact, #planning").animate({opacity: "0.5", height: "51"}, 600)
			$("#news, #about, #calendar, #contact, #planning").removeClass("panelOpen");
			$(".subNav").hide("slow");
			$("#header").addClass("headerBG");
	return false;			
	});		

$("#btnNews").click(function(){  //panel div click						  
		$(".subNav").hide("fast");
		$(".subContentPanel").fadeOut("fast");
		$("#about, #calendar, #contact, #planning").animate({opacity: "0.5", height: "51"}, 600)
		$("#about, #calendar, #contact, #planning").removeClass("panelOpen");
		$("#header").animate({opacity: "0.5", height: "125"}, 600)
		$("#header").removeClass("headerBG"); //hide header BG image
		$("#news").find(".subNav").fadeIn("slow");
		$("#news").animate({opacity: "1", height: "400"}, 600)
		$("#news").addClass("panelOpen")
		//$("#about").find(".subContentPanel").slideDown("slow");
		$("#news").find(".subContentPanel:first").slideDown("slow"); //default subContentPanel open on load
		$("li").removeClass("active")
		$("#news").find("li:first").addClass("active");
		$(".photoSet").hide();
		$("#news").find("#1").show();
	return false;			
	});	

$("#btnAbout").click(function(){  //panel div click						  
		$(".subNav").hide("fast");
		$(".subContentPanel").fadeOut("fast");
		$("#news, #calendar, #contact, #planning").animate({opacity: "0.5", height: "51"}, 600)
		$("#news, #calendar, #contact, #planning").removeClass("panelOpen");
		$("#header").animate({opacity: "0.5", height: "125"}, 600)
		$("#header").removeClass("headerBG"); //hide header BG image
		$("#about").find(".subNav").fadeIn("slow");
		$("#about").animate({opacity: "1", height: "400"}, 600)
		$("#about").addClass("panelOpen")
		//$("#about").find(".subContentPanel").slideDown("slow");
		$("#about").find(".subContentPanel:first").slideDown("slow"); //default subContentPanel open on load
		$("li").removeClass("active")
		$("#about").find("li:first").addClass("active");
	return false;			
	});	

$("#btnCalendar").click(function(){  //panel div click						  
		$(".subNav").hide("fast");
		$(".subContentPanel").fadeOut("fast");
		$("#about, #news, #contact, #planning").animate({opacity: "0.5", height: "51"}, 600)
		$("#about, #news, #contact, #planning").removeClass("panelOpen");
		$("#header").animate({opacity: "0.5", height: "125"}, 600)
		$("#header").removeClass("headerBG"); //hide header BG image
		$("#calendar").find(".subNav").fadeIn("slow");
		$("#calendar").animate({opacity: "1", height: "400"}, 600)
		$("#calendar").addClass("panelOpen")
		//$("#calendar").find(".subContentPanel").slideDown("slow");
		$("#calendar").find(".subContentPanel:first").slideDown("slow"); //default subContentPanel open on load
		$("li").removeClass("active")
		$("#calendar").find("li:first").addClass("active");
	return false;			
	});	

$("#btnContact").click(function(){  //panel div click						  
		$(".subNav").hide("fast");
		$(".subContentPanel").fadeOut("fast");
		$("#about, #calendar, #news, #planning").animate({opacity: "0.5", height: "51"}, 600)
		$("#about, #calendar, #news, #planning").removeClass("panelOpen");
		$("#header").animate({opacity: "0.5", height: "125"}, 600)
		$("#header").removeClass("headerBG"); //hide header BG image
		$("#contact").find(".subNav").fadeIn("slow");
		$("#contact").animate({opacity: "1", height: "400"}, 600)
		$("#contact").addClass("panelOpen")
		//$("#contact").find(".subContentPanel").slideDown("slow");
		$("#contact").find(".subContentPanel:first").slideDown("slow"); //default subContentPanel open on load
		$("li").removeClass("active")
		$("#contact").find("li:first").addClass("active");
	return false;			
	});	

$("#btnPlanning").click(function(){  //panel div click						  
		$(".subNav").hide("fast");
		$(".subContentPanel").fadeOut("fast");
		$("#about, #calendar, #contact, #news").animate({opacity: "0.5", height: "51"}, 600)
		$("#about, #calendar, #contact, #news").removeClass("panelOpen");
		$("#header").animate({opacity: "0.5", height: "125"}, 600)
		$("#header").removeClass("headerBG"); //hide header BG image
		$("#planning").find(".subNav").fadeIn("slow");
		$("#planning").animate({opacity: "1", height: "400"}, 600)
		$("#planning").addClass("panelOpen")
		//$("#planning").find(".subContentPanel").slideDown("slow");
		$("#planning").find(".subContentPanel:first").slideDown("slow"); //default subContentPanel open on load
		$("li").removeClass("active")
		$("#planning").find("li:first").addClass("active");
	return false;			
	});	
			
 
 $("#logo").click(function() //logo click for windows IE
						   {
			$("#header").animate({opacity: "1", height: "400"}, 600)
			$("#header").addClass("panelOpen")
			$(".subContentPanel").hide();
			$("#news, #about, #calendar, #contact, #planning").animate({opacity: "0.5", height: "51"}, 600)
			$("#news, #about, #calendar, #contact, #planning").removeClass("panelOpen");
			$(".subNav").hide("slow");
			$("#header").addClass("headerBG");
			
		return false;			
		
		
	});
 
 
 $("li").click(function(){
	
		$("li").removeClass("active")
		$(this).addClass("active")
		//alert($(this).text());   //VERY handy debugger
		//detect which li clicked, and clean up string. IE adds a space. Bastards.
		var varSelection = String($(this).text());
		varSelection = varSelection.replace(/^\s+|\s+$/g, '') ;
		//varSelection = varSelection.replace(' ', '') ;
		varSelection = varSelection.replace(/ /gi, "");
		//alert(varSelection);
		$(".subContentPanel").fadeOut("slow");
		//alert($(this).parent().find(".subContentPanel").text());
		
		switch(varSelection)
		{
			case "Romano Blog":		
		$("#Headlines").fadeIn("slow");
		break;
		case "How to Help":		
		$("#HowtoHelp").fadeIn("slow");
		break;
		case "Packing List":		
		$("#PackingList").fadeIn("slow");
		break;
		case "Preparation Manual":		
		$("#PreparationManual").fadeIn("slow");
		break;
		default :
		$("#" + varSelection + "").fadeIn("slow");
		break;
		}
	return false;
	});
 
 $(".photoLink").click(function(){
	
		
		//alert($(this).text());   //VERY handy debugger
		//detect which li clicked, and clean up string. IE adds a space. Bastards.
		var varSelection = String($(this).attr("name"));
		//varSelection = varSelection.replace(/^\s+|\s+$/g, '') ;
		//varSelection = varSelection.replace(' ', '') ;
		//varSelection = varSelection.replace(/ /gi, "");
		//alert(varSelection);
		$(".photoSet").hide();
		$("#" + varSelection + "").show();
		//$("#" + varSelection + "").fadeIn("slow");
		//alert($(this).parent().find(".subContentPanel").text());
		
		
	return false;
	});


// $("a").click(function(){
//		var varSelection = String($(this).text());
//		varSelection = varSelection.replace(/^\s+|\s+$/g, '') ;
//		alert(varSelection);
//	return false;
//	});
 
	

$(function() {
    setInterval( "slideSwitch()", 5000 );
});		 
  
}); //jQuery END


 
 function slideSwitch() {
    var $active = $('#slideshow IMG.activeSlide');

    if ( $active.length == 0 ) $active = $('#slideshow IMG:last');

    var $next =  $active.next().length ? $active.next()
        : $('#slideshow IMG:first');

    $active.addClass('last-active');

    $next.css({opacity: 0.0})
        .addClass('activeSlide')
        .animate({opacity: 1.0}, 1000, function() {
            $active.removeClass('activeSlide last-active');
        });
}



 