var hub;

function hideNav(hide) {
	if (hide) {
		getEl("printcontent").style.left="-170";
		getEl("printcontent").style.top="0";
		getEl("sidenav").style.visibility="hidden";
		getEl("banner").style.visibility="hidden";
		getEl("pfvbutton").style.display="none";
		getEl("pfxbutton").style.display="block";
	} else {
		getEl("printcontent").style.left="0";
		getEl("printcontent").style.top="99";
		getEl("sidenav").style.visibility="visible";
		getEl("banner").style.visibility="visible";
		getEl("pfxbutton").style.display="none";
		getEl("pfvbutton").style.display="block";
	}
}
/*
function hideNav(hide) {
	if (hide) {
		getEl("printcontent").style.left="0";
		getEl("printcontent").style.top="0";
		getEl("sidenav").style.display="none";
		getEl("banner").style.display="none";
		getEl("pfvbutton").style.display="none";
		getEl("pfxbutton").style.display="block";
	} else {
		getEl("printcontent").style.left="170";
		getEl("printcontent").style.top="99";
		getEl("sidenav").style.display="block";
		getEl("banner").style.display="block";
		getEl("pfxbutton").style.display="none";
		getEl("pfvbutton").style.display="block";
	}
}
*/
function getEl(el) {
if (document.getElementById) {
el = document.getElementById(el);
} else if(document.all) {
el = document.all[el];
} else {
return null;
}
return el;
}

/* Two functions from the navigate component */
/*
function isHi(cls) {
return (cls=="section_open") ? "section_open":"section_hi";
}

function isNo(cls) {
return (cls=="section_open") ? "section_open":"section_no";
}
*/
/* One function called by the banner component */

function setStyles(hub,sub,gc,doc) {
self.hub = hub;
setNav(); //render the tabs component, if one is present

//var navtree = getEl(hub + " Nav"); //unhide the correct subnav tree
//if (navtree) navtree.className='HubHi';
//alert("*" + doc + "*");
doc = doc.replace(/[^a-zA-Z0-9]/g,"");
//sub = sub.replace(/ /g,"");
sub = sub.replace(/[^a-zA-Z0-9]/g,"");
if (doc==sub) doc += "&nbsp;";
display_sub(hub,sub,gc,doc); //highlight correct links in nav

var hubhigh = getEl(hub + "Button"); //highlight the proper hub button
if (hubhigh) hubhigh.className='HubHi';

var hubimg = getEl(hub + "BannerBtn"); //new! img rollover the proper hub button
if (hubimg) {
	hubnl = hubimg.src.split("_"); 
	hubimg.src = hubnl[0] + "_hi.gif";
}

morphbuttons();
displayCounter(hub);
MM_preloadImages('http://www.vtpaddlers.net/images/bannerbuttons/GoPaddling_hi.gif','http://www.vtpaddlers.net/images/bannerbuttons/TalkPaddling_hi.gif','http://www.vtpaddlers.net/images/bannerbuttons/GetInvolved_hi.gif','http://www.vtpaddlers.net/images/bannerbuttons/More_hi.gif');
}

/* Two functions for the tabs component */

function setNav() {
if (getEl('alltabs')) {
tabHi();
getEl('contenttbl').className='tbltabs'
} else {
getEl('titlecell').innerHTML=document.title
}
}
/*DELETE ONE OF THESE FUNCTIONS ONCE TEST SUCCEEDS/FAILS
function tabHi() {
	var el = getEl(document.title + " Tab");
	//if (el) el.className = "tabHi";
	self.status = document.title;
	if (el) {
	//self.status = el.id;
	el.className = el.className.replace("tab ","tabHi ");
	}
	return;
}
*/
function tabHi() {
	var el = getEl(document.title + " Tab");
	//if (el) el.className = "tabHi";
	self.status = document.title;
	if (el) {
	//self.status = el.id;
	el.className = el.className.replace("tab","tab Hi");
	}
	return;
}

function display_sub(hub,section,subsection,doc) {
var el = getEl(section + "Sub");
if (el) el.style.display = "block";//OPEN THE RELEVANT SECTION NAV

el = getEl(section);
if (el) el.className = (section!=doc) ? "section_open":"section_active";
//FORMAT THE SUBNAV BUTTON DEPENDENT ON WHETHER IT IS TRULY THE OPEN PAGE OR JUST THE ACTIVE NAV

if (section!=doc) {
el = getEl(doc);
if (el) el.className = "page_active";
//FORMAT THE PAGE LABEL DEPENDENT IF A AT THE BOTTOM OF THE TREE...?
}
}

function display(doc) {
if (doc) window.location.href=doc;
}

function morphbuttons() {
	for (frms=0;frms<document.forms.length;frms++) {
		for (els=0;els<document.forms[frms].elements.length;els++) {
			var el = document.forms[frms].elements[els];
			if (el.type == "button" || el.type == "reset" || el.type == "submit") {
				el.style.backgroundColor = "Silver";
			} else if (el.type == "checkbox" || el.type == "radio") {
				el.style.backgroundColor = "transparent";
			} else if (el.type != "hidden") {
				el.style.backgroundColor = "#99CC99";//"LemonChiffon";//"Lavender";//"Honeydew";
				if (!document.all && document.getElementById && el.type != "select" && el.type != "button" && el.type != "submit") {
					if (el.size) el.size = parseInt(el.size/2);
					if (el.cols) el.cols = parseInt(el.cols/2);
				}
			}
		}
	}
}

function displayCounter(hub) {
	var title = document.title.replace(/ /g,"+");
	title = title.replace(/'/g,"");
	
	//var url = self.location.href;
	var url = self.location.href.split("?");
	
	//hub = hub.replace(/ /g,"+");
	document.images["counter"].src = "http://www.vtpaddlers.net/common/counter.php?method=get&title="+title+"&url="+url[0]+"&hub="+hub;
}

function refreshMe() {
alert("Depending on your browser settings you may need to\nreload/refresh the results page in order to see\nyour submission.\n\nThanks for keeping the VPC site up to date!");
return true;
}

function MM_swapImgRestore() { //v3.0
//  if (document.MM_sr.id.indexOf(self.hub)==-1) {
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}