// JavaScript Document
$(document).ready(function() {
						   
//initial page load
$(".panelBG").animate({opacity: "0"}, 0)

						   
$(".panelButton, a.btnText").click(function(){  //panel div click	
							 	
		var panelName = String($(this).attr("name"));
		if (panelName==""){panelName = String($(this).attr("href"));}
		panelName = "#" + panelName;
		//alert(panelName);
		//track panel click with google analytics
		//pageTracker._trackPageview("/" + panelName);
	
		$(".itemWrapper").hide();
		$(".panelContent, .cell, .navlevel1").hide();
		$(".navlevelIntro").fadeIn("slow");
		$("#header").animate({height: "146", opacity: "0"}, 600)
		$(panelName).animate({opacity: "1", height: "490"}, 600).removeClass("panelClosed")
		$(".panel").not(panelName).animate({height: "33"}, 600).removeClass("panelOpen")
		$(".panel").not(panelName).addClass("panelClosed")
		$(".panelBG").animate({opacity: "0"}, 600)
		$(".panelBG").hide("fast");
		$(panelName).addClass("panelOpen")
		$(".panelBtnText").css("background-color", "#908C8D");
		$(".defaultCell").fadeIn("slow");
		switch(panelName)
			{
			case "#about":
			$("#aboutBG").show("fast");
			$("#aboutBG").animate({opacity: "1"}, 600)
			$("#panelBtnTextAbout").css("background-color", "#E60019");
			break;
			case "#news":
			$("#newsBG").show("fast");
			$("#newsBG").animate({opacity: "1"}, 600)
			$("#panelBtnTextNews").css("background-color", "#E60019");
			break;
			case "#capital":
			$("#capitalBG").show("fast");
			$("#capitalBG").animate({opacity: "1"}, 600)
			$("#panelBtnTextCapital").css("background-color", "#E60019");
			break;
			case "#contact":
			$("#contactBG").show("fast");
			$("#contactBG").animate({opacity: "1"}, 600)
				$("#panelBtnTextContact").css("background-color", "#E60019");
				//$(panelName).find(".cell:first").fadeIn("slow");
			break;
			}
		
		$(panelName).find(".panelContent:first").slideDown("slow"); //default panelContent open on load
		//$("a").removeClass("current");
		//$(panelName).find("a:first").addClass("current");
			
	return false;			
	});	

 $(".panelButton").hover(
      function () {
       var panelID = String($(this).attr("name"));
		panelID = "#" + panelID;
		//alert(panelID);
		$(".panelBtnText").css("background-color", "#908C8D");
		switch(panelID)
			{
			case "#about":
			$("#panelBtnTextAbout").css("background-color", "#E60019");
			break;
			case "#news":
			$("#panelBtnTextNews").css("background-color", "#E60019");
			break;
			case "#capital":
			$("#panelBtnTextCapital").css("background-color", "#E60019");
			break;
			case "#contact":
			$("#panelBtnTextContact").css("background-color", "#E60019");
			break;
			}
      }, 
      function () {
      //$(".panelBtnText").animate({backgroundColor: "#908C8D"}, 200)
	  //$(".panelBtnText").css("background-color", "#908C8D");
      }
    );
 
 $("#header, #logo").click(function() 
		{
		
		//track panel click with google analytics
		//var varSelection = String($(this).attr("id"));
//		varSelection = varSelection.replace(/^\s+|\s+$/g, '') ;
		//pageTracker._trackPageview("/homepage");
	
		$(".panelBG").animate({opacity: "0"}, 600)
		$(".panelContent").hide();
		$("#header").animate({opacity: "1", height: "490"}, 600)
		$(".panel").animate({height: "33"}, 600).removeClass("panelOpen")	;
		$(".panelBtnText").css("background-color", "#908C8D");
		return false;							
		}); 


$('a.ajax').live("click", function(){ //start function when any link is clicked
		 				//alert($(this).attr("href"));
						
						
						
						 var content_show = jQuery.trim($(this).attr("href")); 
						 content_show=content_show.toLowerCase();
						  content_show=content_show.replace("http://www.thebalboatheater.org/", "");
						  content_show=content_show.replace("http://thebalboatheater.org/", "");
						  //alert(content_show);
		
		//track 'a.ajax' click with google analytics
		//pageTracker._trackPageview("/" + content_show);
						  
						  
						  
							$.ajax({
							method: "get",url: "ajax.php",data: "page="+content_show,
							beforeSend: function(){$(".cell").fadeOut("slow"); $(".defaultCell").fadeOut("slow"); }, 
							complete: function(){ $(".panelBG").animate({opacity: "0"}, 600); $(".panelBG").hide("fast");}, 
							success: function(html){ //so, if data is retrieved, store it in html
							$(".cell").fadeIn("slow"); //animation
							$(".cell").html(html); //show the html inside .content div
					 }
				 }); //close $.ajax(
				 return false;
         }); //close click(		 
		 
$("a.renovationLink").click(function() {
  panelName = String($(this).attr("href"));
  panelName = "#" + panelName;
  //alert(panelName);	
  $(".itemWrapper").hide();
  $(".panelContent, .navlevel1").hide();
  $(".navlevelIntro").fadeIn("slow");
  $("#header").animate({height: "146", opacity: "0"}, 600)
  $("#capital").animate({opacity: "1", height: "490"}, 600).removeClass("panelClosed")
  $(".panel").not("#capital").animate({height: "33"}, 600).removeClass("panelOpen")
  $(".panel").not("#capital").addClass("panelClosed")
  $(".panelBG").animate({opacity: "0"}, 600)
  $(".panelBG").hide("fast");
  $("#capital").addClass("panelOpen")
  $(".panelBtnText").css("background-color", "#908C8D");
  $("#panelBtnTextCapital").css("background-color", "#E60019");
  $("#capital").find(".panelContent:first").slideDown("slow");	
	$.ajax({
	method: "get",url: "ajax.php",data: "page=renovation_station.htm",
	beforeSend: function(){$(".cell").fadeOut("slow"); $(".defaultCell").fadeOut("slow");}, 
	complete: function(){ $(".panelBG").animate({opacity: "0"}, 600); $(".panelBG").hide("fast");}, 
	success: function(html){ //so, if data is retrieved, store it in html
	$(".cell").fadeIn("slow"); //animation
	$(".cell").html(html); //show the html inside .content div
	}
	}); //close $.ajax(
  return false;							
});
	
	
$("a.donateLink").click(function() {
  panelName = String($(this).attr("href"));
  panelName = "#" + panelName;
  //alert(panelName);	
  $(".itemWrapper").hide();
  $(".panelContent, .navlevel1").hide();
  $(".navlevelIntro").fadeIn("slow");
  $("#header").animate({height: "146", opacity: "0"}, 600)
  $("#capital").animate({opacity: "1", height: "490"}, 600).removeClass("panelClosed")
  $(".panel").not("#capital").animate({height: "33"}, 600).removeClass("panelOpen")
  $(".panel").not("#capital").addClass("panelClosed")
  $(".panelBG").animate({opacity: "0"}, 600)
  $(".panelBG").hide("fast");
  $("#capital").addClass("panelOpen")
  $(".panelBtnText").css("background-color", "#908C8D");
  $("#panelBtnTextCapital").css("background-color", "#E60019");
  $("#capital").find(".panelContent:first").slideDown("slow");	
	$.ajax({
	method: "get",url: "ajax.php",data: "page=capital_contribute_now.htm",
	beforeSend: function(){$(".cell").fadeOut("slow"); $(".defaultCell").fadeOut("slow");}, 
	complete: function(){ $(".panelBG").animate({opacity: "0"}, 600); $(".panelBG").hide("fast");}, 
	success: function(html){ //so, if data is retrieved, store it in html
	$(".cell").fadeIn("slow"); //animation
	$(".cell").html(html); //show the html inside .content div
	}
	}); //close $.ajax(
  return false;							
});
 
 
 
  $(".sendEmail").live("click", function(){
		var varName = $("#varName").val();								 
	    alert(varName);
		
		return false;							
		});
  
  //$(function() {
//    setInterval( "changeSlide()", 2500 ); 
//});	
  
}); //jQuery END

//functions:
//var slideCounterv = 0;
//function changeSlide() {
//	//visionary slideshow
//	slideCounterv += 1;
//	if(slideCounterv==17){slideCounterv=1;}
//	slideCounterIDv = "#v" + slideCounterv;
//	if(slideCounterv % 2 == false) {
//		//alert(slideCounterIDv);
//		//$(".visionaryDiv").fadeOut("slow");
//		$("#v2").fadeOut("slow");
//	}
//}
//



 
