var dxFilter=null;
var BV=parseFloat(navigator.appVersion.indexOf("MSIE")>0?navigator.appVersion.split(";")[1].substr(6):navigator.appVersion);
var BN=navigator.appName;
var nua = navigator.userAgent;
var IsWin=(nua.indexOf('Win')!=-1);
var IsMac=(nua.indexOf('Mac')!=-1);
var KQ=(BN.indexOf('Konqueror')!=-1&&(BV>=5))||(nua.indexOf('Safari')!=-1);
var OP=(nua.indexOf('Opera')!=-1&&BV>=4);
var NS=(BN.indexOf('Netscape')!=-1&&(BV>=4&&BV<5)&&!OP);
var SM=(BN.indexOf('Netscape')!=-1&&(BV>=5) ||OP);
var IE=(BN.indexOf('Explorer')!=-1&&(BV>=4)||SM||KQ);
var IX=(IE&&IsWin&&!SM&&!OP&&(BV>=5.5)&&(dxFilter!=null)&&(nua.indexOf('CE')==-1));

function GetImgXY(img) {
    //IE,NS,SM,OP,KQ
    //This function returns the x,y coordinates of an image.
    //------------------------------
    //Version 1.4
    //
    var x;
    var y;
      
    if(IE)  {
      y = getOffset(img);
      x = y[0];
      y = y[1];
    } else  {
      y = GetImgOffset(cFrame, img.name, 0, 0);
      x = img.x + y[0];
      y = img.y + y[1];
    }      
    return [x, y];    
}

function getOffset(img) {
    //IE,NS,SM,OP,KQ
    //This function returns the horizontal and vertical offset of an object.
    //------------------------------
    //Version 1.2
    //
    xy = [img.offsetLeft, img.offsetTop];
    ce = img.offsetParent;
    while(ce!=null)  {
      xy[0] += ce.offsetLeft;
      xy[1] += ce.offsetTop;
      ce = ce.offsetParent;
    }
    return xy;
  }

function GetImgOffset(d, img, ox, oy) {
    //NS
    //This function finds the offset to an image regardless of its location in the document structure.
    //------------------------------
    //Version 1.0
    //
    var i;
    var tmp;
    
    if(d.left) {
      ox += d.left;
      oy += d.top;
    }
        
    if(d.document.images[img]) return [ox, oy];
    
    for(i=0; i<d.document.layers.length; i++) {
      tmp = GetImgOffset(d.document.layers[i], img, ox, oy);
      if(tmp) return [tmp[0], tmp[1]];
    }    
    return null;
}

function windowSize() {
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myHeight = window.innerHeight;
  } else {
    if( document.documentElement &&
        ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
      //IE 6+ in 'standards compliant mode'
      myHeight = document.documentElement.clientHeight;
    } else {
      if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
        //IE 4 compatible
        myHeight = document.body.clientHeight;
      }
    }
  }
  return myHeight;
}

function fNav1_HidePipe() {
	if (document.getElementById("headerNav").firstChild ) {
		var bIsCurrent = false;
		if (document.getElementById("headerNav").firstChild.className == 'MenuTopcurrent')
			bIsCurrent = true;
		if( bIsCurrent )
			document.getElementById("headerNav").firstChild.className = 'MenuTop2current';
		else
			document.getElementById("headerNav").firstChild.className = 'MenuTop2';
	}
}



function fNav2_HidePipe() {
	if (document.getElementById("leftMenu").lastChild ) {
		var bIsCurrent = false;
		if (document.getElementById("leftMenu").lastChild.className == 'Menu1current')
			bIsCurrent = true;
		if( bIsCurrent )
			document.getElementById("leftMenu").lastChild.className = 'Menu2current';
		else
			document.getElementById("leftMenu").lastChild.className = 'Menu2';
	}
}




// Multiple window.onload functions and body onLoad="this_included_too()"
var aSafeOnload = new Array();
function fSafeAddOnload(fFunctionName) { // v2.0.2 2005-02-23; like:; req: fSafeOnload;
	if (window.addEventListener) { // W3C, Firefox
		window.addEventListener('load',fFunctionName,false)
	} else if (document.addEventListener) { // W3C, Opera
		document.addEventListener('load',fFunctionName,false)
	} else if (document.attachEvent) { // IE
		window.attachEvent('onload',fFunctionName)
	} else { // Mac IE 4.5 blows out on testing window.onload
		window.onload = fSafeOnload;
		aSafeOnload[aSafeOnload.length] = fFunctionName;
	}
}
function fSafeOnload() { // v1.01 2003-11-10; like: fSafeAddOnload; req:;
	for (var i=0;i<aSafeOnload.length;i++)
		aSafeOnload[i]();
}


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.4.0 2004-10-15; 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;
	}

	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
}

function fOpenWin(sURL,iW,iH,sName,bScrollBars) { // v1.5.0 2004-12-22; 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)?'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()
	}
}