/*
Author: Vincent Hu, Nick Carter (vhu@inphonic.com ncarter@inphonic.com)
Version: 11/3/2006
NOTE:  -The filenames of the TABBED images MUST end in either _on.gif or _off.gif  DO NOT USE ANY OTHER 
 NAMING CONVENTIONS OR FILE FORMATS!!!!!!!!!!!
*/
	function preload_images(){
		if(document.images){
		home_off = new Image();
		home_on = new Image();
		sheds_on = new Image();
		sheds_off= new Image();
		delivery_off= new Image();
		delivery_on= new Image();
		contact_off = new Image();
		contact_on = new Image();
		blog_off = new Image();
		blog_on = new Image();
		forum_off = new Image();
		forum_on = new Image();
		
		path="images/nav/";
		home_off = path + "home_off.gif";
		home_on = path + "home_on.gif";
		sheds_off= path + "sheds_off.gif";
		sheds_on = path + "sheds_on.gif";
		delivery_off= path + "delivery_off.gif";
		delivery_on= path + "delivery_on.gif";
		contact_off = path + "contact_off.gif";
		contact_on = path + "contact_on.gif";
		blog_off = path + "blog_off.gif";
		blog_on = path + "blog_on.gif";
		forum_off = path + "forum_off.gif";
		forum_on = path + "forum_on.gif";   
		picture_off = path + "picture_off.gif";
		picture_on = path + "picture_on.gif"     ;
	
		}
	}
	
	/* main image swapping function.  if the current images is not on the "hover" state, rename the src of image to inclue an "on.gif" or "on" state.*/
	
	function getNextImg(src) {
		var path = src.substr(0, src.lastIndexOf("/") + 1);
		var current = src.substr(src.lastIndexOf("/") + 1);
		var src = current.split("_")[0];
		var current_state = current.split("_")[1];
		var next_state = (current_state.indexOf("on") == -1) ? "on.gif" : "off.gif";
		var next = path + src + "_" + next_state;
		return next;
	}
	
	function swap(){	
		var next = getNextImg(this.src)
		this.src = next;
	}
	
	function addSwap() {
		var tabs = document.getElementById(tabsname);
	

		var imgs = tabs.getElementsByTagName("img");
		for(var i = 0; i < imgs.length; i++) {
			if(imgs[i].parentNode.id == "current_page") {
				imgs[i].src = getNextImg(imgs[i].src);
				continue;
			}
			imgs[i].onmouseover = swap;
			imgs[i].onmouseout = swap;
		}
	}
	

	function addLoadEvent(func) {
		var oldload = window.onload;
		if(typeof window.onload == "function")
			window.onload = function() {
				oldload();
				func();
			}
		else
			window.onload = func;
	}
		
	addLoadEvent(preload_images);
	addLoadEvent(addSwap);

