// Highcliff Veterinary Practice JavaScript (mostly JQuery-related)

$(document).ready(function() {

	// Start transitioning news
	$("#banners").newsticker(12000);
	$(".newslist").newsticker(5000);

	// Apply Cufon fonts
	Cufon.replace('.firstnavigationitem');
	Cufon.replace('.navigationitem');
	Cufon.replace('.titletext');

	// Set the navigation mouseovers
	$("#navourpractice").mouseover(function() {
		$('.panelsubnavigation').css("background-image", "url(/images/body/navigationbgs/ourpractice.png)");
		// Display correct DIV (display: none; on others)
		hideNavigationMenus();
		$('#navtextourpractice').css("display", "block");
	  });
	  
	$("#navdomesticpets").mouseover(function() {
		$('.panelsubnavigation').css("background-image", "url(/images/body/navigationbgs/domesticpets.png)");
		// Display correct DIV (display: none; on others)
		hideNavigationMenus();
		$('#navtextdomesticpets').css("display", "block");
	  });

	$("#navfarmequine").mouseover(function() {
		$('.panelsubnavigation').css("background-image", "url(/images/body/navigationbgs/farmandequine.png)");
		// Display correct DIV (display: none; on others)
		hideNavigationMenus();
		$('#navtextfarmequine').css("display", "block");
	  });
	  
	$("#navhelpadvice").mouseover(function() {
		$('.panelsubnavigation').css("background-image", "url(/images/body/navigationbgs/helpandadvice.png)");
		// Display correct DIV (display: none; on others)
		hideNavigationMenus();
		$('#navtexthelpadvice').css("display", "block");
	  });
	  
	$("#navcontactus").mouseover(function() {
		$('.panelsubnavigation').css("background-image", "url(/images/body/navigationbgs/contactus.png)");
		// Display correct DIV (display: none; on others)
		hideNavigationMenus();
		$('#navtextcontactus').css("display", "block");
	  });
	
	// Setup the homepage tabs
	$("#hometabparentcontainer").tabs({ fx: {  } }).tabs('rotate', 8000);
	$('#hometabparentcontainer').hover(function(){
			$(this).tabs('rotate', 0, false);
		},function(){
			$(this).tabs({ fx: {  } }).tabs('rotate', 8000);
		}
	);
	
	// Setup the mini-gallery lightbox
	$('.imagegallery a').lightBox({fixedNavigation:true});
	
	// Setup the toggle accordion panels
	$(document).ready(function() {
	  $('div.showhide:eq(0)> div:not(:first)').hide();
	  $('div.showhide:eq(0)> h2').click(function() {
	 $(this).next().slideToggle('fast');
	  });
	});
	
	// Set equal heights on the body navigation and content
	//$(".equalheightcolumn").equalHeights(500,1000000);
	//setEqualHeight($(".equalheightcolumn"), 0);

	//Hide (Collapse) the toggle containers on load
	//showHidePanel();
	
	//Switch the "Open" and "Close" state per click then slide up/down (depending on open/close state)
	/*
	$("#togglenewspanel").click(function(){
		$("#paneltop").slideToggle(function() {
				$.cookie("panelDisplay", $('#paneltop').is(':visible'), { expires: 30 }); // Set a cookie to track the panel state, set to expire in one month
				
				togglePanelDisplay();					
		  });
	
	});*/
	
	// Function called when the page is loaded to show/hide the news panel
	function showHidePanel()
	{
		if ($.cookie("panelDisplay") == 'false')
		{
			$("#paneltop").hide();
		} 
		
		// Display the correct show/hide button
		togglePanelDisplay();
	}
	
	// Display the show/hide image for the news panel
	function togglePanelDisplay()
	{	
		//alert($.cookie("panelDisplay"));
	
		if ($.cookie("panelDisplay") == 'true')
		{
			$('#togglenewspanel').attr('src', '/images/hidenewspanel.png');
		}
		else
		{
			$('#togglenewspanel').attr('src', '/images/shownewspanel.png');
		}
	}
	
	function setEqualHeight(columns, additional)  
	{  
		var tallestcolumn = 0;  
		columns.each
		(  
		function()  
			{  
				currentHeight = $(this).height();  
				if(currentHeight > tallestcolumn)  
				{  
					tallestcolumn = currentHeight + additional;  
				}  
			}  
		);  
		columns.height(tallestcolumn);  
	}
	
	function hideNavigationMenus()
	{
		$('.panelsubnavigation').css("display", "none");	
	}

});
