$(document).ready(function(){
	$("#left-navigation a").each(function() { 
		if(this.href == window.location || this.href == document.location.protocol + "//" + window.location.hostname + window.location.pathname)
		$(this).addClass("current-page"); 
	});    
    $("table tr:nth-child(odd)").addClass("alternatetablerow");
	$("table tr:nth-child(even)").addClass("tablerow");
	$("input#banner_search_SearchInput").ezpz_hint();
	$("a.filetype[href$='.pdf']").addClass("PDF");
    $("a.filetype[href$='.doc']").addClass("DOC");
	$("a.filetype[href$='.xls']").addClass("XLS");
	$("a.filetype[href$='.ppt']").addClass("PPT");
	$("a[href*='doc']").attr({target:"_blank",title:"MS Word document - opens in a new window"});
	$("a[href*='pdf']").attr({target:"_blank",title:"PDF document - opens in a new window"});
	$("a[href*='ppt']").attr({target:"_blank",title:"MS PowerPoint document - opens in a new window"});
	$("a[href*='xls']").attr({target:"_blank",title:"MS Excel document - opens in a new window"});
	$("a[href*='http://']:not([href*='"+location.hostname+"'])")
	.attr({target:"_blank",title:"External link - opens in a new window"});
	$('.normal').click(function(){$('html').css("font-size", "100%");$.cookie("font", "100%", {expires: 365, path: '/'});return false;});
    $('.large').click(function(){$('html').css("font-size", "120%");$.cookie("font", "120%", {expires: 365, path: '/'});return false;});
    $('.larger').click(function(){$('html').css("font-size", "130%");$.cookie("font", "130%", {expires: 365, path: '/'});return false;});
    if($.cookie("font")){$('html').css("font-size", $.cookie("font"));};
	if($.cookie("css")){var stylesheet = $.cookie("css");$("link.switchstyle").attr("href", stylesheet);
	if(stylesheet === $('.normalContrast').attr("rel")){displayHighContrastLink()}else{displayNormalContrastLink();}}else{displayHighContrastLink();}
    $('#textLinks').show();$('#contrastLink').show();
	// banner images
			var show = $("#slideshow").slideshow({ speed:5000, pagination:'#pagination' });
			show.start();
			$("#pause").click(function(){
				show.pause();
			});
			$("#play").click(function(){
				show.start();
			});
			$("#prev").click(function(){
				show.prev();
			});
			$("#next").click(function(){
				show.next();
			});
			$("#pagination .goto").click(function(){
				show.goTo($(this).attr('href'));
				return false;
			});	
});

function setActiveStyleSheet(cssFileName) {
    $("link.switchstyle").attr("href", cssFileName);
    $.cookie("css", cssFileName, {expires: 365, path: '/'});
    return false;
}

function displayNormalContrastLink() {
    $('.highContrast').hide();
    $('.normalContrast').show();
}

function displayHighContrastLink() {
    $('.normalContrast').hide();
    $('.highContrast').show();
}

//FAQ
$(document).ready(function(){
	$(".faq-hidden").hide();
	$(".faq-closed").click(function(){
		$(this).next(".faq-hidden").slideToggle(500);
		$(this).toggleClass('faq-open');
	});
	
	$('#expand-links').show();
	$(".expand").click(function(){
		$(".faq-hidden").slideDown(500);
		$(".faq-closed").addClass('faq-open');
	});
	$(".collapse").click(function(){
		$(".faq-hidden").slideUp(500);
		$(".faq-closed").removeClass('faq-open');
	});
});

//sitemap
this.sitemapstyler = function(){
	var sitemap = document.getElementById("sitemap")
	if(sitemap){
		
		this.listItem = function(li){
			if(li.getElementsByTagName("ul").length > 0){
				var ul = li.getElementsByTagName("ul")[0];
				ul.style.display = "none";
				var span = document.createElement("span");
				span.className = "collapsed";
				span.onclick = function(){
					ul.style.display = (ul.style.display == "none") ? "block" : "none";
					this.className = (ul.style.display == "none") ? "collapsed" : "expanded";
				};
				li.onkeydown = function(e){
					var KeyID = (window.event) ? event.keyCode : e.keyCode;
					switch(KeyID){
						case 37: // left arrow key press
							ul.style.display = "none";
							span.className = "collapsed";
						break;
						case 39: // right arrow key press
							ul.style.display = "block";
							span.className = "expanded";
						break;
					}
				};
				li.appendChild(span);
			};
		};
		
		var items = sitemap.getElementsByTagName("li");
		for(var i=0;i<items.length;i++){
			listItem(items[i]);
		};
		
	};	
};

window.onload = sitemapstyler;

function openMap(){
	var sitemap = document.getElementById("sitemap")
	if(sitemap){
		
		this.listItem = function(li){
			if(li.getElementsByTagName("ul").length > 0){
				var ul = li.getElementsByTagName("ul")[0];
				ul.style.display = "block";
				var span = document.createElement("span");
				span.className = "expanded";
				span.onclick = function(){
					ul.style.display = (ul.style.display == "none") ? "block" : "none";
					this.className = (ul.style.display == "none") ? "collapsed" : "expanded";
				};
				li.onkeydown = function(e){
					var KeyID = (window.event) ? event.keyCode : e.keyCode;
					switch(KeyID){
						case 37:
							ul.style.display = "none";
							span.className = "collapsed";
						break;
						case 39:
							ul.style.display = "block";
							span.className = "expanded";
						break;
					}
				};
				li.appendChild(span);
			};
		};
		
		var items = sitemap.getElementsByTagName("li");
		for(var i=0;i<items.length;i++){
			listItem(items[i]);
		};
		
	};	
};

function closeMap(){
	var sitemap = document.getElementById("sitemap")
	if(sitemap){
		
		this.listItem = function(li){
			if(li.getElementsByTagName("ul").length > 0){
				var ul = li.getElementsByTagName("ul")[0];
				ul.style.display = "none";
				var span = document.createElement("span");
				span.className = "collapsed";
				span.onclick = function(){
					ul.style.display = (ul.style.display == "none") ? "block" : "none";
					this.className = (ul.style.display == "none") ? "collapsed" : "expanded";
				};
				li.onkeydown = function(e){
					var KeyID = (window.event) ? event.keyCode : e.keyCode;
					switch(KeyID){
						case 37:
							ul.style.display = "none";
							span.className = "collapsed";
						break;
						case 39:
							ul.style.display = "block";
							span.className = "expanded";
						break;
					}
				};
				li.appendChild(span);
			};
		};
		
		var items = sitemap.getElementsByTagName("li");

		for(var i=0;i<items.length;i++){
			listItem(items[i]);
		};
		
	};	
};
// EZPZ Hint v1.1.1; Copyright (c) 2009 Mike Enriquez, http://theezpzway.com; Released under the MIT License
(function(a){a.fn.ezpz_hint=function(e){var f={hintClass:'ezpz-hint',hintName:'ezpz_hint_dummy_input'};var c=a.extend(f,e);return this.each(function(){var b;var d;text=a(this).attr('title');a('<input type="text" name="temp" value="" />').insertBefore(a(this));b=a(this).prev('input:first');b.attr('class',a(this).attr('class'));b.attr('size',a(this).attr('size'));b.attr('name',c.hintName);b.attr('autocomplete','off');b.attr('tabIndex',a(this).attr('tabIndex'));b.addClass(c.hintClass);b.val(text);a(this).hide();a(this).attr('autocomplete','off');b.focus(function(){d=a(this);a(this).next('input:first').show();a(this).next('input:first').focus();a(this).next('input:first').unbind('blur').blur(function(){if(a(this).val()==''){a(this).hide();d.show()}});a(this).hide()});if(a(this).val()!=''){b.focus()};a('form').submit(function(){a('.'+c.hintName).remove()})})}})(jQuery);


