sfHover = function() {
	var sfEls = document.getElementById("nav").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
	select_nav();
}

// fade code idea courtesy of http://www.brainerror.net/
var guaranteeTextVisible = false;
var textPosSet = false;

function ShowImg(e) {		
	if (!e) var e = window.event;
	this.src = "/graphics/guaranteeHover.jpg";
}
function HideImg(e) {
	if (!e) var e = window.event;
	if (this.className == "wax") {
		this.src = "/graphics/lostWax.jpg";
	} else if (this.className == "wood") {
		this.src = "/graphics/specifyFloor.jpg";
	} else {
		this.src = "/graphics/guarantee.jpg";
	}
}
function ShowText(e) {
	if (!e) var e = window.event;
	ResetPos(this);
	if (!guaranteeTextVisible) {
		guaranteeTextVisible = true;
		//alert(gt.style.opacity);
		opacity("guaranteeText", 0, 100, 200);
	}
}
function ResetPos(img) {
	var gt = document.getElementById("guaranteeText");
	//div width - image width; padding would need to be factored in if it was there
	gt.style.left = (findPos(img) - (300 - 106)) + "px";
}

function ResizeResetPos() {
	var gt = document.getElementById("guaranteeText");
	var img = document.getElementById("guarantee");
	//div width - image width; padding would need to be factored in if it was there
	gt.style.left = (findPos(img) - (300 - 106)) + "px";
}

function HideText() {
	guaranteeTextVisible = false;
	//opacity("guaranteeText", 100, 0, 200);
	var gt = document.getElementById("guaranteeText").style;
	gt.left = -900 + "px";
	gt.opacity = 0;
	gt.MozOpacity = 0;
	gt.KhtmlOpacity = 0;
	gt.filter = "alpha(opacity=0)";
}

function findPos(obj) {
	var curleft = 0;
	if (obj.offsetParent) {
		curleft = obj.offsetLeft;
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft;
		}
	}
	return curleft;
}

function ShowResourcesImage(image) {
	var ri = document.getElementById(image);
	//alert(ri);
	ri.style.display = "block";
	opacity(image, 0, 100, 400);
}
function HideResourcesImage(image) {
	var ri = document.getElementById(image).style;
	ri.display = "none";
	ri.opacity = 0;
	ri.MozOpacity = 0;
	ri.KhtmlOpacity = 0;
	ri.filter = "alpha(opacity=0)";
}
function opacity(id, opacStart, opacEnd, millisec) {
	//speed for each frame
	var speed = Math.round(millisec / 100);
	var timer = 0;

	//determine the direction for the blending, if start and end are the same nothing happens
	if(opacStart > opacEnd) {
		for(i = opacStart; i >= opacEnd; i--) {
			setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
			timer++;
		}
	} else if(opacStart < opacEnd) {
		for(i = opacStart; i <= opacEnd; i++)
			{
			setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
			timer++;
		}
	}
}

//change the opacity for different browsers
function changeOpac(opacity, id) {
	//alert(id);
	var object = document.getElementById(id).style; 
	object.opacity = (opacity / 100);
	object.MozOpacity = (opacity / 100);
	object.KhtmlOpacity = (opacity / 100);
	object.filter = "alpha(opacity=" + opacity + ")";
}
function currentOpac(id, opacEnd, millisec) {
	//standard opacity is 100
	var currentOpac = 100;	
	//if the element has an opacity set, get it
	if(document.getElementById(id).style.opacity < 100) {
		currentOpac = document.getElementById(id).style.opacity * 100;
	}
	//call for the function that changes the opacity
	opacity(id, currentOpac, opacEnd, millisec)
}

function select_nav() {
	//alert("hello");
   var nav_list_items = document.getElementById('nav').getElementsByTagName('a');
   var selected = location.pathname;
   
   for (var i = 0; i < nav_list_items.length; i++) {
	 
	  if (nav_list_items[i].getAttribute("href")) {
		  
     		var path = nav_list_items[i].pathname;
			//for ie
			 if (path.substring(0, 1) != '/') path = '/' + path;
			 //alert("path: " + path + "\n selected: " + selected);
			
     		if (path == selected) {
       			/*nav_links[i].setAttribute(cattr, 'selected');
	   			alert(path);*/
	   			nav_list_items[i].className += " selected";
			}
	 }
   }
 }
 
 window.onload =  select_nav;
