var lastShowList;
var lastShowNav;
var HideMenuTimer;
var ThisPage;
var PageAddress;
lastShowList='nothing';
lastShowNav='nothing';
ThisPage="nothome";
PageAddress=window.location.href;

function showEmailThisPage(){
	document.getElementById('EmailThisPage').style.visibility='visible';
}
function hideEmailThisPage(){
	document.getElementById('EmailThisPage').style.visibility='hidden';
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
			window.open(theURL,winName,features);
}
		
		
function showList(list){
	//expand or collapse secondary nav menu
	if(document.getElementById(list).className=='hideItem'){
		
			document.getElementById(list).className='showItem';
		if(lastShowList!='nothing' && list!=lastShowList){
			document.getElementById(lastShowList).className='hideItem';
		}
		lastShowList=list;
	}else{
		document.getElementById(list).className='hideItem';
	}
}

function showNav(navItem){
	//expand or collapse main nav menu
	
		
	if(document.getElementById(navItem).className=='hideItem'){
			
			document.getElementById(navItem).className='showItem';
			
		if(lastShowNav!='nothing' && navItem!=lastShowNav){
			hideNav(lastShowNav);
		}
		lastShowNav=navItem;
	}else{
		hideNav(navItem);
	}
	
}

function hideNav(navItem){
	if(ThisPage!="htmlhome"){
		document.getElementById(navItem).className='hideItem';
	}
	
}

function startTimeout(navItem)

{

	start = new Date();

	DHFlag = true;

	HideMenuTimer = setTimeout("hideNav('"+ navItem +"')", 1000);

}

function clearTimer(){
	
	if (HideMenuTimer) clearTimeout(HideMenuTimer);

	HideMenuTimer = null;

	DHFlag = false;
}



// Set Cookie
function onSetClicked( value ) {
	
	var expdate = new Date (); 
	FixCookieDate (expdate); 
	expdate.setTime (expdate.getTime() + (365 * 2 * 24 * 60 * 60 * 1000));

	SetCookie( 'horizonEntrySelection', value, expdate );

	return( true );
}

function FixCookieDate (date) { 
	var base = new Date(0); 
	var skew = base.getTime();
	if(skew > 0)
		date.setTime (date.getTime() - skew);     
} 

function SetCookie (name,value,expires,path,domain,secure) { 
	document.cookie = name + "=" + escape (value) + 
	((expires) ? "; expires=" + expires.toGMTString() : "") + 
	((path) ? "; path=" + path : "") + 
	((domain) ? "; domain=" + domain : "") + 
	((secure) ? "; secure" : ""); 
}




function getURL(url){
	if(url!="#" && url!="")
	{
		window.open(escape(url));	
	}
}




/*
	MENU HIGHLIGHTING
	-----------------------------------------------------------------------------------
	Fetches the path portion of a URL, e.g.
				
		input = http://localhost/about.us/board.of.trustees/trustee.profiles.shtml
		output = http://localhost/about.us/board.of.trustees/

*/
function getPathFromURL( url ) {

	return url.substr( 0, url.lastIndexOf( "/" )+1 );
}


/*
	Fetches the path portion of a URL, e.g.
				
		input = http://localhost/about.us/board.of.trustees/trustee.profiles.shtml
		output = http://localhost/about.us/board.of.trustees/

*/
function getStripParamFromURL( url ) {

	if( url.substr( 0, url.lastIndexOf( "?" ) ) != '' )
		return url.substr( 0, url.lastIndexOf( "?" ) );
	else
		return url;
}

/*
	The following is an override variable for the highlightMenuLink() function. To force
	 a menu item to be highlighted, set 'highlightMenuLinkOverride' equal to the EXACT
	 URL specified in the menu's <a href=> tag, e.g.:
	 
	 <script language='javascript'>highlightMenuLinkOverride = 'http://localhost/about.us/board.of.trustees/index.shtml';</script>
		
	 This SHOULD NOT BE DONE HERE -- place the override command anywhere in an editable region.
*/
var highlightMenuLinkOverride = null;

/*
	This function highlights a menu item using three different methods:
	
		1) If highlightMenuLinkOverride has been set to the exact URL (see above), this is used.
		2) An exact URL match is attempted (index pages MUST be named 'index.shtml')
		3) A directory name match is attempted
*/
function highlightMenuLink() {

	theSecondaryNav = document.getElementById('secondaryNav');
	if(theSecondaryNav){
		theLinks = theSecondaryNav.getElementsByTagName('a');
		itemHTML="nothing";
		//alert(location.href);
		for(p=0;p<theLinks.length;p++){
				
				if(theLinks[p].href == location.href || theLinks[p]+"default.aspx" == location.href){
					theLinks[p].style.color="black";	
					
					
					//alert(theLinks[p].parentNode);
				
					parentNotFound=1;
					thisParentNode = theLinks[p].parentNode;
					//find the parent td
					while(parentNotFound<20){
						
						
						if(thisParentNode.tagName=="TD"){
							
							itemHTML = thisParentNode.innerHTML;
	
							subList = thisParentNode.getElementsByTagName('span');
							
							if(subList[0]){
								subList[0].className = "showItem";		
								
							}
							
							parentNotFound=21;
						}				
						
						thisParentNode = thisParentNode.parentNode;
						parentNotFound++;
					}
					
				}
		}
	}
	
}


function absoluteTemplate(){
	theHeader = document.getElementById('header');	
	theFooter = document.getElementById('footer');

	//alert(document.domain);
	
	if(theHeader){
	
		if(PageAddress.indexOf('http://www.horizonwind.com')==-1 && PageAddress.indexOf('http://horizonwind.com')==-1 && PageAddress.indexOf('http://localhost')==-1 && PageAddress.indexOf('http://horizon.esiteful.com')==-1){
			headLinks = theHeader.getElementsByTagName('a');
			footLinks = theFooter.getElementsByTagName('a');
			absoluteLinks = [];
			
			for(z=0; z<headLinks.length;z++){
				absoluteLinks[z]=headLinks[z];	
			}
			
			for(z=0;z<footLinks.length;z++){
				absoluteLinks[z+headLinks.length]=footLinks[z];
			}
			//alert(absoluteLinks.length);
		
			for(p=0; p<absoluteLinks.length;p++){
				
				if(absoluteLinks[p].href.indexOf('http://www.horizon')!=0 && absoluteLinks[p].href.indexOf('http://horizon')!=0 && absoluteLinks[p].href.indexOf('javascript')!=0){
					tmpLink = absoluteLinks[p].href.split('/');
					tmpLink = tmpLink.slice(3,tmpLink.length);
					newSegment="";
					for(g=0;g<tmpLink.length;g++){
						if(g!=0){
							newSegment+="/";	
						}
						newSegment+=tmpLink[g];
					}
					
					absoluteLinks[p].href="http://www.horizonwind.com/"+newSegment;
					
				}
			}
		}
	}
}