$(document).ready(function(){

//needs to be in body onload for safari as well
	//positionSearchBox();

	$("ul.nav").superfish({
		//hoverClass	: "sfHover",
		//pathClass	: "overideThisToUse",
		delay		: 800,
		//animation	: {opacity:"show"},
		//animation	: {opacity:"show"},
		animation : { height:"show"},
		//speed		: "normal",
		oldJquery	: false, /* set to true if using jQuery version below 1.2 */
		disableHI	: false, /* set to true to disable hoverIntent detection */
		onInit		: function(){},
		onBeforeShow	: function(){},
		onShow		: function(){},
		onHide		: function(){}
	})
	/*
	.find(">li:has(ul)")
		.mouseover(function(){
			$("ul", this).bgIframe({opacity:false});
		})
		.find("a")
			.focus(function(){
				$("ul", $(".nav>li:has(ul)")).bgIframe({opacity:false});
			});
			*/

	positionSearchBox = function (){

		if(undefined===window.is_home){
		window.is_home = '';
		}
		if(undefined===window.blank_sidebar){
		window.blank_sidebar = '';
		}
		
		if($("#leftNarrow").length > 0){
			leftHeight = $("#leftNarrow").height();
		} 
		if($("#slideWide").length > 0){
			bottomText = $(".bottomTxt").length > 0 ? $(".bottomTxt").height() : 0;
			leftHeight = 	$("#slideWide").height() + bottomText;
		}
		if($("#rightNarrow").length > 0 && !is_home){
				midHeight = $("#midColumn").height();
				searchHeight = $("search").height();
				
				if(leftHeight){
					newHeight = leftHeight > midHeight ? leftHeight : midHeight;
				} else {
					newHeight = midHeight;
				}
				
//				console.log('leftHeight: ' + leftHeight + ' midHeight: ' + midHeight);
				
				$("#rightNarrow").height(newHeight + 44);
				$("#search").css('position','absolute');
				$("#search").css('right','1px');
				//Nav header = 40px
				if(blank_sidebar){
						midColumnHeight = newHeight;
					$("#leftNarrow").height($("#rightNarrow").height() - 40);
//					error_log('blank_sidebar: newHeight ' + newHeight)
				}
		}
		
	}
	
	
	positionSearchBox();
	
	
});
function popupform(myform, windowname)
{
if (! window.focus)return true;
window.open('', windowname, 'height=400,width=450,scrollbars=yes');
myform.target=windowname;
return true;
}


function emailPage(pageUrl){
	window.open('form_emailpage.php?pageUrl='+pageUrl, 'EmailForm', 'height=400,width=450,scrollbars=yes');
}
function printPage(pageUrl){
	window.open(pageUrl, 'printWin', 'width=800, height=700, scrollbars=1, menubar=1');
}
function printThis(){
	window.print();
}
var expanded = 0;
function toggleMore(id, linkId){
	
	if(!expanded){
		//$('#'+linkId).html('Less');
		$('#'+linkId).addClass('readLessLink');
		$('#'+linkId).removeClass('readMoreLink');
		$('#'+id).slideDown();
		expanded = 1;
	} else {
		$('#'+id).hide();
		$('#'+linkId).addClass('readMoreLink');
		$('#'+linkId).removeClass('readLessLink');
		//$('#'+linkId).html('Read More');
		expanded = 0;
	}
}
