/*
Servco Pacific
Site-wide JavaScript include
Created: 11 October 2007 by Michael Fulk <michael@walltowall.com>
Wall-to-Wall Studios, Inc.
*/

$(function(){
	$("#home-promo-flash").wrap('<div id="home-promo-flash-wrap"></div>');
	$("#home-content").append('<div class="clear"></div>');
	$("#footer").prepend('<div id="footer-left"></div><div id="footer-right"></div>');
	$(".offsite").each(function(){this.setAttribute("target", "_blank")});
	$("#interior #container").append('<div class="clear"></div>').after('<div class="clear"></div>');
	
	var totalMenus = $("#menu").children("li").children("a").length;
	
	$("#menu").children("li").children("a").hover(function(){
		// link mouseover
		var id = $(this).parent().get(0).id;
		if(!($(this).parent().get(0).className.indexOf('first') > -1 && $(this).get(0).className.indexOf('current') > -1)){
			$(this).add($(this).parent().get(0)).addClass("hover");
			if($.browser.msie) {
				$("select").css("visibility", "hidden");
			}
			$('#'+id+'_submenu').show();
		}
	},function(){
		// link mouseout
		var id = $(this).parent().get(0).id;
		if(!($(this).parent().get(0).className.indexOf('first') > -1 && $(this).get(0).className.indexOf('current') > -1)){
			$(this).add($(this).parent().get(0)).removeClass("hover");
			if($.browser.msie) {
				$("select").css("visibility", "visible");
			}
			$('#'+id+'_submenu').hide();
		}
	}).end().each(function(menuIndex){
		// alert(index);
		var id = this.id;
		// taking the id of the links, finding the divs, and attaching behavior.
		$('#'+id+'_submenu').hover(function(){
			$('#'+id).add($('#'+id).children().get(0)).addClass("hover");
			if($.browser.msie) {
				$("select").css("visibility", "hidden");
			}
			$(this).show();
		},function(){
			$('#'+id).add($('#'+id).children().get(0)).removeClass("hover");
			if($.browser.msie) {
				$("select").css("visibility", "visible");
			}
			$(this).hide();
		}).mousemove(function(){
			$('#'+id).add($('#'+id).children().get(0)).addClass("hover");
			if($.browser.msie) {
				$("select").css("visibility", "hidden");
			}
			$(this).show();
		});
	});
	
	
	$("#search_back_link").click(function(){
		history.go(-1);
		return false;
	});
});	

function highlightCurrentSection(section) {
	var link = "#menu_"+section;
	$(link).children("a").addClass("current");
}
