/*
-----------------------------------------------------------------------------
SchlesingerCompanies.com JAVASCRIPT Styles

updated:		20 May 2008
code author:	Red Studio
email:			kristi@redstudio.net
-----------------------------------------------------------------------------*/

/* news section 'faux page' tabs behavior */
$(function(){
	$(".news h3").click(
		function(){
			$(this).parent("div").addClass("active");
			$(this).parent("div").siblings().removeClass("active");
		}
	);
});

/* banner images hover zoom - toggle behavior */
// $(function(){
// 	$("#content-images img.main").addClass("last-main");
// 	$("#content-images .main").siblings().mouseover(
// 		function(){
// 			$("#content-images .main").removeClass("main");
// 			$(this).addClass("main");
// 		}
// 	);
// 	$("#content-images .last-main").mouseover(
// 		function(){
// 			$("#content-images .main").removeClass("main");
// 			$(this).addClass("main");
// 		}
// 	);
// });

/* banner images hover zoom - animated behavior */
$(function(){
	$("#content-images img").mouseover(
		function(){
			if ( $(this).hasClass("portrait") ) {
				$(this).siblings().animate({ top: "42px", height: "84px" }, "fast" );
				$(this).animate({ top: "-63px", height: "251px" }, "fast" );
			} else {
				$(this).siblings().animate({ top: "42px", height: "84px" }, "fast" );
				$(this).animate({ top: "0", height: "182px" }, "fast" );
			}
		}
	);
});

/* add active class ('current') to currently displayed page */
$(function() {
	// Figure out the location based on the browser URL
	var path = location.pathname;

	// Set your homepage path here, eg. /index.php or /
	var home = "/";
	// Check the home link against the path and set the navigation accordingly. 
	if (path == home || path == "/") {
		// Note that the jQuery selector matches *only* the home link
		var $nav = $('.nav a[@href="' + home + '"]');
	} else {
		var $nav = $('.nav a[@href$="' + path + '"]');
	}

	// Add the active class to the current anchor's parent <li> elements
	$nav.parents("li").addClass('current')
});

/* set margin-top value on #branding element to accommodate primary-level nav group vertical height */
$(function() {
	var height = $("ul.secondary-nav").height();
	var padding_top = parseInt($("ul.secondary-nav").css("padding-top"));
	var padding_bottom = parseInt($("ul.secondary-nav").css("padding-bottom"));
	var height_new = height + padding_top + padding_bottom - 1; /* 1px difference on display for some reason */
	$('#branding').css("margin-top",height_new);
});

/* set top value on secondary-level nav group to accommodate vertical height of primary-level nav group + banner */
$(function() {
	// primary-level nav group total height
	var height = $("ul.secondary-nav").height();
	var padding_top = parseInt($("ul.secondary-nav").css("padding-top"));
	var padding_bottom = parseInt($("ul.secondary-nav").css("padding-bottom"));
	var height_primary_level = height + padding_top + padding_bottom;
	// banner height
	var height_banner = $("#branding").height();
	// secondary-level nav padding-top
	var nav_padding_top = parseInt($(".secondary-nav li.current ul").css("padding-top"));
	if (nav_padding_top == '') nav_padding_top = "0";
    // final value
	var height_new = height_primary_level + height_banner - nav_padding_top;
	$('.secondary-nav li.current ul').css("top",height_new);
});

/* set padding-top on h2 element within secondary & tertiary pages to accommodate secondary-level nav group vertical height */
$(function() {
	var height = $(".secondary-nav li.current ul").height();
	var padding_top = parseInt($(".secondary-nav li.current ul").css("padding-top"));
	var padding_bottom = parseInt($(".secondary-nav li.current ul").css("padding-bottom"));
	var height_new = height + padding_top + padding_bottom + 14;
	$('.secondary #content-primary h2').css("padding-top",height_new);
});

/* set top value on tertiary-level nav group to accommodate vertical height of preceeding elements */
/* custom overrides have had to be set for IE6 & IE7; if editing below also update 'sc-ie6.js' and 'sc-ie7.js' */
$(function() {
	var second_level_top = parseInt($(".secondary-nav li.current ul").css("top"));
	var content_top = $("#content-primary .container").offset();
	var height_new = content_top.top - second_level_top + 30;
	$('.secondary-nav li.current ul ul').css("top",height_new);
});

/* set top value on background-design-images to accommodate vertical height of preceeding elements */
/* custom overrides have had to be set for IE6 & IE7; if editing below also update 'sc-ie6.js' and 'sc-ie7.js' */
$(function() {
	// basic settings
	var content_top = $("#content-primary .container").offset();
	var content_top_padded = content_top.top + 1;
	var h2_top = $("#content-primary h2").offset();
	$(".secondary #background-design-image").css("top",content_top_padded);
	$(".tertiary #background-design-image").css("top",content_top_padded);

	// different height for .primary level pages - turn on if wanted when images updated */
	// $(".primary #background-design-image").css("top",h2_top.top);

	// make sure content area is big enough for image
	var image_height = $("#background-design-image").height() + 10;
	$("#content-primary .container").css("min-height",image_height);
});

/* set top value on .team page design-image spans to match vertical height of corresponding headlines */
/* custom overrides have had to be set for IE6 & IE7; if editing below also update 'sc-ie6.js' and 'sc-ie7.js' */
$(function() {
	var team01_top = $("#team-01").offset();
	$("#team-image-01").css("top",team01_top.top);
	var team02_top = $("#team-02").offset();
	$("#team-image-02").css("top",team02_top.top);
	var team03_top = $("#team-03").offset();
	$("#team-image-03").css("top",team03_top.top);
	var team04_top = $("#team-04").offset();
	$("#team-image-04").css("top",team04_top.top);
	var team05_top = $("#team-05").offset();
	$("#team-image-05").css("top",team05_top.top);
	//var team06_top = $("#team-06").offset();
	//$("#team-image-06").css("top",team06_top.top);
});