var ec_dan = 'v3.0.0 2007-05-01; like:; req:;';
var gbW3C = true;
var gbDebug = true;
if (!document.getElementsByTagName || !document.getElementById || !document.createElement)
	gbW3C = false;
function gfW3C_Failed() {
	alert('Warning: Some functionality has been disabled due to your aging web browser.');
}
function fGetObj(sObjId) { /* replacement for gfMissingObj */
	v = 'v3.0.0 2007-05-01; like:; req:fAddToDomUnload (v1.0);';
	bIdMissing = false;
	if (document.getElementById) {
		if (document.getElementById(sObjId))
			return fAddToDomUnload(document.getElementById(sObjId))
		else
			bIdMissing = true;
	} else if (document.all) {
		if (document.all[sObjId])
			return fAddToDomUnload(document.all[sObjId])
		else
			bIdMissing = true;
	} else if (document.layers) {
		if (document.layers[sObjId])
			return fAddToDomUnload(document.layers[sObjId])
		else
			bIdMissing = true;
	} else if (gbDebug)
		alert('Warning: Some functionality has been disabled due to your aging web browser.');
	
	if (bIdMissing) {
		if (gbDebug) {
			alert('Warning: ' + sObjId + ' HTML object is missing, please allow this page to fully load.');
			return false;
		}
	} else return false;
} aDomRef = new Array();

function fAddToDomUnload(oDomRef) {
	v = 'v1.0.0 2007-05-01; like:fGetObj (v3.0); req:;';
	if (aDomRef) {
		if (oDomRef != false) {
			aDomRef.push(oDomRef);
		}
	} else 
		if (gbDebug) alert("Webmaster: You're missing the aDomRef array variable.");
	return oDomRef;
}
function fDomUnload() { /* prevent IE Memory Leak */
	v = 'v1.0.0 2007-05-01; like:fGetObj (v3.0), fAddToDomUnload (v1.0); req:;';
	if (aDomRef) {
		for (i=0; i < aDomRef.length; i++)
			eval('aDomRef['+i+'] = null'); // aDomRef[i] = null;
	} else 
		if (gbDebug) alert("Webmaster: You're missing the aDomRef array variable.");
} window.unload = fDomUnload();

function fSafeAddOnload(func){v = 'v3.1.0 2006-11-22; like:; req:;';if(!window.__load_events){var init=function(){if(arguments.callee.done)return;arguments.callee.done=true;if(window.__load_timer){clearInterval(window.__load_timer);window.__load_timer=null;/*@cc_on @*//*@if (@_win32) document.getElementById("__ie_onload").onreadystatechange = "";/*@end @*/}for(var i=0;i<window.__load_events.length;i++){window.__load_events[i]()}window.__load_events=null};if(document.addEventListener){document.addEventListener("DOMContentLoaded",init,false)}/*@cc_on @*//*@if (@_win32) var proto = "src='javascript:void(0)'";if (location.protocol == "https:") proto = "src=//0";document.write("<scr"+"ipt id=__ie_onload defer " + proto + "><\/scr"+"ipt>");var script=document.getElementById("__ie_onload");script.onreadystatechange=function(){if(this.readyState=="complete"){init()}};/*@end @*/if(/WebKit/i.test(navigator.userAgent)){window.__load_timer=setInterval(function(){if(/loaded|complete/.test(document.readyState)){init()}},10)}window.onload=init;window.__load_events=[]}window.__load_events.push(func)}

function fOpenWin(sURL,iW,iH,sName,bScrollBars) { // v1.5.2 2005-10-14; like:; req:;
	iXPos=0, iYPos=15;
	if (window.innerWidth) { // NN4, NN6, O7
		iXPos = (window.innerWidth-iW)/2;
		iYPos = (window.innerHeight-iH)/2;
		iXPos+=window.screenX; iYPos+=window.screenY;
	} else {	// screen width (1 600) not used because I want centred in window on screen
		iXPos = (document.body.clientWidth-iW)/2;	// current window width (800) - new window width (400) / 2 = 200 on each side
		iBrowserHeight = (document.compatMode=="CSS1Compat")?document.documentElement.clientHeight:document.body.clientHeight;
		iYPos = (iBrowserHeight-iH)/2;
		iXPos+=window.screenLeft; iYPos+=window.screenTop;	// current position of window (400) + iXPos (200) = 600 is left pos
	} // left space (600) + new width (400) + right space (600) = screen res (1 600)

	if (typeof bScrollBars == 'boolean')
		bScrollBars = (bScrollBars==true)?'yes':'no';
	else
		bScrollBars = 'yes'; // not defined set to default

	sArgs='width=' +iW+ ',height=' +iH+ ',resizable=yes,scrollbars=' +bScrollBars+ ',status=yes,screenx=' +iXPos+ ',screeny=' +iYPos+ ',left=' +iXPos+ ',top=' +iYPos
	if (!sName) sName = 'popup';
	oWin=window.open(sURL,sName,sArgs);

	if (oWin != null) {
		if (oWin.opener == null) // give orphan child window this parent
			oWin.opener = self;
		oWin.focus()
	}
}
function fApplyLinkBehaviour(sContainerName) { // v1.5.6 2004-10-10; like:fSafeAddOnload; req:fPopupFromTarget(v1.3);
	// sContainerName (optional)
	if (!document.getElementsByTagName) return;
	if (typeof(sContainerName) == 'string') // if page too large force links to behave
		var tAs = document.getElementById(sContainerName).getElementsByTagName('a');
	else // check enitre document
		var tAs = document.getElementsByTagName('a');

	for (i=0; i<tAs.length; i++) {
		tA = tAs[i];
		if (tA.target) {
			if (tA.target == 'fresh')
				tA.target = '_blank';
			else if (tA.target.indexOf('popup') != -1)
				tA.onclick = fPopupFromTarget;
			else if (tA.target == 'self')
				tA.target = '_self';
		} else if (tA.href) { // force PDF into new window, unless target set to self
			if (tA.href.indexOf('.pdf') != -1)
				tA.target = '_blank';
		}
	}
}
fSafeAddOnload(fApplyLinkBehaviour);

function fPopupFromTarget(oA) { // v1.5.0 2005-10-14; like:fApplyLinkBehaviour(v1.5); req:fOpenWin(v1.4);
	oSelf = (this.target) ? this : oA; // if onlick from fApplyLinkBehaviour use THIS else hardcoded onclick use oA (hardcoded as 'this')
	sWinHref = oSelf.href.toString();
	aWinArgs = oSelf.target.split(':');
	sWinTitle = (aWinArgs.length > 3) ? aWinArgs[3] : 'popup'; // window name = fourth argument

	aFilename = sWinHref.split('.');
	sFileType = aFilename[aFilename.length-1];
	
	if (sFileType == "jpg" || sFileType == "gif" || sFileType == "png") { // if image then no scrollbars
		bScrollBars = false; // hide scrollbars with image cuz each browser has different padding
		iImgWinEnlargeOffset = 20; // add this # to w,h cuz opening a win. without HTML (ie img), each browser adds margin/padding
	} else {
		bScrollBars = true;
		iImgWinEnlargeOffset = 0;
	}

	if (aWinArgs[4] == "false") // passed argument precedence over image file type
		bScrollBars = false;
	else
		bScrollBars = true;

	fOpenWin(sWinHref,parseInt(aWinArgs[1])+iImgWinEnlargeOffset,parseInt(aWinArgs[2])+iImgWinEnlargeOffset,sWinTitle,bScrollBars) // href, width, height, name, scrollbars
	return false; // prevent href and target from HTML launching second window
}
