//generalScript.js
//created: May 8th, 2008
//Author: Jesse Faltus
//All rights reserved.

//onload function to setup current links, hide menus, etc.
function setup()
{

	//First, We want to get the page we're on so that we can
	//highlight the correct link on the page
	
	var url = window.document.location.toString();			//get url
	var urlTokens = new Array();							//stores url tokens delimited by "/"
	var pageTokens = new Array();							//page tokens delimited by "." (ie. index and php)
	
	urlTokens = url.split("/");								//we now have the url tokens
	var numTokens = urlTokens.length;						//we're interested in the last token, so we can use this value to index it
	
	if(numTokens <= 4)//if we're at "www.jessefaltus.com/" with no file name following it
	{
		var currentObj = document.getElementById("index");//default to "index"
		currentObj.style.backgroundImage= 'url(/images/firstHL.jpg)';
	}else
	{
		//highlight objects one directory deep, ie. the main menu headers
		if(urlTokens[3].toString()=="contact")
		{
			var currentObj = document.getElementById("contact");//default to "index"
			currentObj.style.backgroundImage= 'url(/images/endHL.jpg)';	
		}else
		{
			var currentObj = document.getElementById(urlTokens[3].toString());//lets style our current page link
			currentObj.style.backgroundImage= 'url(/images/menuTile.jpg)';
		}
		
		//highlight objects two directories deep, ie. the portfolio menu headers		
		if(numTokens ==6)
		{
				if(urlTokens[4].toString()=="art")
				{
					var currentObj = document.getElementById("mediaBrowser");
					currentObj.style.backgroundImage= 'none';										
					var currentObj = document.getElementById("art");
					currentObj.style.backgroundColor= '#000';					
				}
		}		
	}
	
}


function hlCurrentLink(hlLink)
{
	var hl = document.getElementById(hlLink);
	hl.style.backgroundColor = '#ddd';
	hl.style.borderRight = '5px solid #ddd';	
}

//This function shows/hides any element with id, "obj".  If
//the element is shown, its corresponding flyout is hidden.  If
//the element is hidden, its corresponding flyout is shown. This
//function is not currently being used.

function showHide(obj) {
	
	var menuHead = document.getElementById(obj);
	if ( menuHead.style.display == 'block' ) {
		menuHead.style.display = 'none';
	}
	else {
		menuHead.style.display = 'block';
	}
	
}

//

function more(obj, obj2) {
	
	var textBlock = document.getElementById(obj);
	var moreBlock = document.getElementById(obj2);
	if ( textBlock.style.height == 'auto' ) {
		textBlock.style.height = '35px';
		moreBlock.innerHTML="more...";
	}
	else {
		textBlock.style.height = 'auto';
		moreBlock.innerHTML="hide...";
	}
	
}

function showImg(img){
	var imgFrame = document.getElementById("imgDisplay");
	imgFrame.style.backgroundImage= 'url(/images/'+ img +'.jpg)';
}