// JavaScript Document

// To just activate current page
// <script>currentNav('<ID OF ENCLOSING DIV>');</script>

// To do auto rollovers on div contents
// <script>activateNav('<ID OF ENCLOSING DIV>');</script>


	function activateNav(rootName) {	
			root = document.getElementById(rootName);
			
			imgs = root.getElementsByTagName("IMG");
			var i=0
			while(imgs[i]) {
			
			imgs[i].onmouseover = function() {
				switchImage(this);
			}
			imgs[i].onmouseout = function() {
				revertimage(this);
			}
			i++;	
			}
	}
	
	function manualNav(eleId) {
		var ele = document.getElementById(eleId);
		var oldsrc = new String(ele.src);
		ele.src= oldsrc.replace("_up","_over");
	}
	
	function currentNav(rootName) {	
	root = document.getElementById(rootName);
	
	var l = parseUri(location);
	var newloc = l.protocol+'://'+l.domain+l.directoryPath;
	loc = location;
			hnode = toolbox_nodes_getActiveLink(root,loc);
			if (!hnode && (newloc==loc)) {
			hnode = toolbox_nodes_getActiveLink(root,loc+'index.html');
			}
			if (hnode) {
			inode = toolbox_nodes_getFirstOf(hnode,'IMG');
			var nSrc = new String(inode.src);
			inode.src = nSrc.replace('_up','_over');
			inode.onmouseout=function(){}
			}
	}
			
	function switchImage(obj) {	
	oldsrc = new String(obj.src);
	obj.src = oldsrc.replace('_up','_over');
	obj.lastsrc = oldsrc;	
	}
	
	function revertimage(obj) {
		obj.src = obj.lastsrc;
	}
	
	function writeEA() {
		
	document.write('<a href="mailto:'+'info'+'@'+'wannabanna.com">info'+'@'+'wannabanna.com</a>');
		
	}
	

	
	function parseUri(sourceUri){
    var uriPartNames = ["source","protocol","authority","domain","port","path","directoryPath","fileName","query","anchor"];
    var uriParts = new RegExp("^(?:([^:/?#.]+):)?(?://)?(([^:/?#]*)(?::(\\d*))?)?((/(?:[^?#](?![^?#/]*\\.[^?#/.]+(?:[\\?#]|$)))*/?)?([^?#/]*))?(?:\\?([^#]*))?(?:#(.*))?").exec(sourceUri);
    var uri = {};
    for(var i = 0; i < 10; i++){
        uri[uriPartNames[i]] = (uriParts[i] ? uriParts[i] : "");
    }
    // Always end directoryPath with a trailing backslash if a path was present in the source URI
    // Note that a trailing backslash is NOT automatically inserted within or appended to the "path" key
    if(uri.directoryPath.length > 0){
        uri.directoryPath = uri.directoryPath.replace(/\/?$/, "/");
    }
    return uri;
}
	
//# PB Toolbox Base Utils

//# CSS
	
			
			function toolbox_style_toggleDisplay(obj) {
			if (obj.style.display=='none') {
			obj.style.display = '';
			} else {
			obj.style.display='none';
			}
			}
			
//# DOM
			
			function toolbox_nodes_getFirstOf(obj,ntype) {
			if (obj && obj!=undefined) {
			chElements = obj.getElementsByTagName(ntype);
			return chElements[0];
			}
			return false;
			}
			
			function toolbox_nodes_getActiveLink(root,url) {
			var refList = root.getElementsByTagName("a");
			var i = 0;
			while(refList[i]) {
			if (refList[i].href == url) {
			return refList[i];
			}
			i++;
			}
			return false;
			}
			
			function toolbox_nodes_getFirstParentByType(root,ntype) {
				var p = root.parentNode;
				while(p!=undefined && p.nodeName!=ntype) {
					p = p.parentNode;
				}
				if (p==undefined) {
				 return root.parentNode;
			 } else {
				return p;
				}
			
			}