// Hero Image Homepage Functions
var timerNumber = 1;
		
function heroRotate() {
	if(timerNumber == 4){
		timerNumber = 0
	}
	timerNumber++;
	$("#heroContainer ul li a").each(function(){
		var curr = $(this);
		if(curr.hasClass("on")){
			curr.removeClass("on");
		}
	});
	$(".heroSection").each(function(){
		var curr = $(this);
		if(curr.css("display") == "block"){
			curr.fadeOut("normal");
		}
	});
	$("#hero" + timerNumber).fadeIn("normal");
	$("#aHero" + timerNumber + " a").addClass("on");
}
// End Hero Image Homepage Functions

/*------------------------------------------
	jQuery:
		DOM ready events
--------------------------------------------*/
$(document).ready(function() {
	$("a.toggle").click(function(){
		$("#popUpDiv").toggle();
		return false;
	});

	

	// Hero Image Homepage Code - Will run only if #heroContainer is on page.
	if(document.getElementById("heroContainer")){	
		$("#heroContainer ul li a").click(function(){
			clearInterval(heroTimer);
			var currLink = $(this).parent().attr("class");
			if($("#" + currLink).css("display") == "none"){
				$("#heroContainer ul li a").each(function(){
					var curr = $(this);
					if(curr.hasClass("on")){
						curr.removeClass("on");
					}
				});
				$(".heroSection").each(function(){
					var curr = $(this);
					if(curr.css("display") == "block"){
						curr.fadeOut("normal");
					}
				});
				$("#" + currLink).fadeIn("normal");
				$(this).addClass("on");
			}
		});
		
		$(".heroSection a").mouseover(function(){
			clearInterval(heroTimer);
		});
		
		var heroTimer = setInterval("heroRotate()", 8000);
	}
	// End Hero Image Homepage Code
	
	//Drop down menu code
	$('#mainNavigation ul li').hoverIntent(
		{
			sensitivity: 1,
				interval: 20,
				over:
					function(){
						$(this).children('.dropdown').slideDown("fast");
					},
				timeout: 500,
				out:
					function(){
						$(this).children('.dropdown').slideUp("fast");
					}
		}
	);
	
	$("#sectionNav ul li a").click(function(){
		$(this).next('ul').slideToggle("normal");
		$(this).toggleClass("on");
	});
	
	
});

/*------------------------------------------
	jQuery:
		Window load Events
--------------------------------------------*/
$(window).load(function() {});


/*------------------------------------------
	jQuery Plugins
--------------------------------------------*/
//	Label Over by Remy Sharp : Apply label over input
jQuery.fn.labelOver = function(overClass) {
	return this.each(function() {
		var label = jQuery(this);
		var f = label.attr('for');
		if (f) {
			var input = jQuery('#' + f);
			this.hide = function() {
				label.css({ textIndent: -10000 })
			}
			this.show = function() {
				if (input.val() == '') label.css({ textIndent: 0 })
			}
			// handlers
			input.focus(this.hide);
			input.blur(this.show);
			label.addClass(overClass).click(function(){ input.focus() });
			if (input.val() != '') this.hide(); 
		}
	});
}

//	vJustify by Michael Futreal: Justify Element Heights
jQuery.fn.vjustify=function() {
	var maxHeight=0;
	this.each(function() {
		if (this.offsetHeight>maxHeight) { maxHeight=this.offsetHeight; }
	});
	this.each(function() {
		$(this).height(maxHeight + "px");
		if (this.offsetHeight>maxHeight) {
			$(this).height((maxHeight-(this.offsetHeight-maxHeight))+"px");
		}
    });
};


/*------------------------------------------
	Without jQuery:
		Attach events when DOM is ready
--------------------------------------------*/
//addEvent(window, 'load', initLinks);
//addEvent(window, 'load', initBgImgFix);

/*------------------------------------------
	Utility Functions
--------------------------------------------*/
/*
function addEvent(obj, evType, fn) { 
	if (obj.addEventListener) { 
		obj.addEventListener(evType, fn, false); 
		return true; 
	} else if (obj.attachEvent) { 
		var r = obj.attachEvent("on"+evType, fn); 
		return r; 
	}
}

function initLinks() {
	if (document.getElementById && document.getElementsByTagName) {
		var links = document.getElementsByTagName('a');
		for (var a = 0; a < links.length; a++) {
			
			// open external links in new window
			// - requires class="externalLink"
			if (links[a].className == 'externalLink') {
				links[a].onclick = function() {
					window.open(this.href);
					return false;
				}
			}
		}
	}
}

// fix the IE6 background image flickr on links
function initBgImgFix() {
	try { document.execCommand("BackgroundImageCache", false, true); }
	catch(err) {}
}
*/