// shared.js script, version 2.1, 08-13-03

// global vars ======================================================
var loc = location.pathname.split('/');
loc.length = loc.length - 1; // removes filename 

var d = location.pathname.replace(/\/[^\/]*/g,'../'); // return one depth too deep, see next line for fix
d = d.substring(0,(d.length-3)); // turns this: ../../ into this ../
// /global vars ======================================================

// img preloads =====================================================
/*
hh = new Image(); hh.src = "/pix/hh.gif"; hh_roll = new Image(); hh_roll.src = "/pix/hh_roll.gif";
*/	
// /img preloads =====================================================

// popup window functions ==========================================
function popflex(URL,winName,W,H,scroll) {
	if (scroll == "no")
		{scroll = "scrollbars=no";}
	else if (scroll == "yes")
		{scroll = "scrollbars";}
	var popwin = window.open(URL, winName,"top=0,left=30,width="+W+",height="+H+",resizable=no,"+scroll+"");
	popwin.focus();
	}	
// /popup window functions ==========================================

function showhide_v3() {
	divid = arguments[0];
	classes = arguments[1];
	onstate = arguments[2];
	force = ''; //stops toggling between on and off and forces either on or off whenever clicked 
	if (typeof arguments[3] != 'undefined') {force = arguments[3];}

	var state = 'none';
	if (document.getElementById(divid).className == classes+' none' || 
	document.getElementById(divid).className == 'none') {
		var state = onstate;
		}
	if (force != '') {state = force;}
	document.getElementById(divid).className = classes+' '+state;
	return divid;
	}

function load_functions() {
	/*
	NOTE: this function MUST be called from body onload, ex: <body onload="load_functions();">
	this avoids render timing issues in Safari
	*/

	// functions to be run on every page:
	detect_height();
	
	// functions run on a per/page basis. loadfunctions is an array declared in /folder/pagescript.js, each array object represents a function declared either in /shared.js or /folder/pagescript.js
	if (typeof loadfunctions !== 'undefined') {
		for (var n=0; n < loadfunctions.length; n++) {
			eval(loadfunctions[n]+'();');
			}
		}
	}

function detect_height() {
	/*
	NOTE: this function MUST be called from body onload, ex: <body onload="detect_height();">
	this avoids render timing issues in Safari
	*/
	
	var textbox_bg = document.getElementById('textbox_bg');
	var textbox = document.getElementById('textbox');
	if (!textbox_bg && !textbox) {return;}
	var H = textbox.offsetHeight+10;
	
	var boxes = new Array();
	
	// reset all containers to the longest value =====
	if (textbox_bg != null) {textbox_bg.style.height = H+'px';}
	if (document.all) {
 		if (textbox_bg != null) {textbox_bg.style.setExpression("height",'"'+H+'px"');}
	  document.recalc(true);
		}
	// reset all containers to the longest value =====
	
	return true;
	}

