// 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";}
	window.open(URL, winName,"top=0,left=30,width="+W+",height="+H+",resizable=no,"+scroll+"");
	}	
// /popup window functions ==========================================

function showhide_v2(divid,classes,onstate) {
/*
<div><a href="#" onclick="showhide_v2('text','class_one class_two','block');return false;">[show]</a></div>
<div id="text" class="class_one class_two none">
<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit loboritis nisl ut aliquip ex ea commodo consequat</p>
</div>
*/
	if (document.getElementById(divid).className == classes+' none') {
		document.getElementById(divid).className = classes+' '+onstate;
		}
	else {
		document.getElementById(divid).className = classes+' none';
		}
	}

function nav_img_flip(obj) {
	//if (obj.src.search(/open/) != -1) {obj.src = '/pix/nav_closed.gif';}
	//else if (obj.src.search(/closed/) != -1) {obj.src = '/pix/nav_open.gif';}
	if (obj.className == 'nav_closed') {obj.className = 'nav_open';}
	else if (obj.className == 'nav_open') {obj.className = 'nav_closed';}
	}
	
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 box0 = document.getElementById('pagebox0bottom');
	var box1 = document.getElementById('pagebox1bottom');
	var box2 = document.getElementById('pagebox2bottom');
	var box3 = document.getElementById('pagebox3bottom');
	var boxfull = document.getElementById('pageboxfullbottom');
	
	var boxes = new Array();

	boxes[0] = 0;
	if (box0 != null) {
		box0_H = box0.offsetTop;//alert("0:"+box0_H);
		boxes[0] = box0_H;
		}
	boxes[1] = 0;
	if (box1 != null) {
		box1_H = box1.offsetTop;//alert("1:"+box1_H);
		boxes[1] = box1_H;
		}
	boxes[2] = 0;
	if (box2 != null) {
		box2_H = box2.offsetTop;//alert("2:"+box2_H);
		boxes[2] = box2_H;
		}
	boxes[3] = 0;
	if (box3 != null) {
		box3_H = box3.offsetTop;//alert("3:"+box3_H);
		boxes[3] = box3_H;
		}
	boxes[4] = 0;
	if (boxfull != null) {
		boxfull_H = boxfull.offsetTop;//alert("F:"+boxfull_H);
		boxes[4] = boxfull_H;
		}
	
	// find out who's longest =====
	function numberorder(a,b) {return a-b;}
	boxes.sort(numberorder);
	var longest = boxes[(boxes.length-1)];//alert("l="+longest);
	// /find out who's longest =====
	
	// reset all containers to the longest value =====
	if (box0 != null) {document.getElementById('pagebox0').style.minHeight = longest+'px';}
	if (box1 != null) {document.getElementById('pagebox1').style.minHeight = (longest+10)+'px';}
	if (box2 != null) {document.getElementById('pagebox2').style.minHeight = longest+'px';}
	if (box3 != null) {document.getElementById('pagebox3').style.minHeight = (longest+10)+'px';}
	if (boxfull != null) {document.getElementById('pageboxfull').style.minHeight = longest+'px';}
	document.getElementById('pagecontainer').style.minHeight = longest+'px';
	if (document.all) {
 		if (box0 != null) {document.getElementById('pagebox0').style.setExpression("height",'"'+longest+'px"');}
 		if (box1 != null) {document.getElementById('pagebox1').style.setExpression("height",'"'+(longest)+'px"');}
 		if (box2 != null) {document.getElementById('pagebox2').style.setExpression("height",'"'+longest+'px"');}
 		if (box3 != null) {document.getElementById('pagebox3').style.setExpression("height",'"'+(longest)+'px"');}
 		if (boxfull != null) {document.getElementById('pageboxfull').style.setExpression("height",'"'+longest+'px"');}
 		document.getElementById('pagecontainer').style.setExpression("height",'"'+longest+'px"');
	  document.recalc(true);
		}
	// reset all containers to the longest value =====
	
	return true;
	}

