
var loc = location.pathname.split('/');

loc.length = loc.length - 1; // removes filenam
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 ../


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+"");
}





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 showhide_v2(divid,classes,onstate) {

	if (document.getElementById(divid).className == classes+' none'

	document.getElementById(divid).className == 'none') {

		document.getElementById(divid).className = classes+' '+onstate;

		}

	else {

		document.getElementById(divid).className = classes+' none';

		}

	return divid;

}



function hideall(total,partialid,classes) {

	for (var n = 0; n < total; n++) {

		document.getElementById(partialid+n).className = classes+' none';

		}
}







function detect_height () {

	/*

	NOTE: this function MUST be called from body onload, ex: <body onload="detect_height();">

	this avoids render timing issues in Safar



	This is used for a 2-col layout where the right col is absolute positioned

	in the margin/padding of the left column. The left column, given no position, dynamically

	pushes the bottom of the page shell down. If the right column content is longer than

	the left col content, the right col content will flow out of the shell. To stop this,

	each column has a div placed as the last object and the code below is run.

	<div id="page"> <<-- relative positioned

		<div id="pagebox1"> <<-- right padding/margin width set, no position

			content here

			<div id="pagebox1bottom"></div>

		</div>

		<div id="pagebox2"> <<-- absolute positioned right:0px, top:0px, width set to margin/padding width above

			content here

			<div id="pagebox2bottom"></div>

		</div>

	</div>

	*/




	if (document.getElementById('pagebox2')) {

		var box1 = document.getElementById('pagebox1bottom');

		var box2 = document.getElementById('pagebox2bottom');

		if (document.all) {

			// needed for IE because box1 is not positioned or floated

			box1_H = box1.offsetTop - box1.offsetParent.offsetTop;

			}

		else {

			box1_H = box1.offsetTop;

			}

		box2_H = box2.offsetTop;

		//alert(box1_H);

		//alert(box2_H);

		if (box1_H <= box2_H) {

			var reset = box2_H;

			if (document.all) {

	   		document.getElementById('pagecontainer').style.setExpression("height",'"'+(reset+10)+'px"');

			  document.recalc(true);

				}

			document.getElementById('pagecontainer').style.minHeight = (reset+20)+'px';

			return true;

	 		}

		}

	box1.display = 'none';

	box2.display = 'none';
}
