function adjustLayout(){
	if(!document.getElementById("popup2Col") && !document.getElementById("popupWide")){
		var contentHeight;		// viewport
		var bodyHeight;			// height of entire content
		var myHeight= 0;
		/* ----- Firefox, Opera: ----- */
		if(typeof(window.innerHeight) == 'number'){
			windowHeight= window.innerHeight;
			footerHeight= document.getElementById("footer").offsetHeight+document.getElementById("disclaimer").offsetHeight;
			if (navigator.platform == "MacPPC") {contentOverflow = 260;} else {contentOverflow = 240;}
			contentHeight = document.getElementById("mainArea").offsetHeight+footerHeight+contentOverflow;
			navHeight= document.getElementById("contentNavRoot").offsetHeight + 170;				// height of LeftNav
			if(windowHeight > contentHeight){
				maxHeight= navHeight > windowHeight ? navHeight : windowHeight;
				document.getElementById("content").style.height = maxHeight + "px";
				document.getElementById("shadowLeft").style.height = maxHeight + "px";
				document.getElementById("shadowRight").style.height = maxHeight + "px";
			}
			else{
				maxHeight= navHeight > windowHeight ? navHeight : contentHeight;
				document.getElementById("content").style.height = maxHeight + "px";
				document.getElementById("shadowLeft").style.height = maxHeight + "px";
				document.getElementById("shadowRight").style.height = maxHeight + "px";
			}
		}
		/* ----- IE6: ----- */
		else if(document.documentElement && document.documentElement.clientHeight){
			contentHeight= document.documentElement.scrollHeight;
			windowHeight= document.documentElement.clientHeight;
			navHeight= document.getElementById("contentNavRoot").offsetHeight + 170;
			if(windowHeight > contentHeight){
				maxHeight= navHeight > windowHeight ? navHeight : windowHeight;
				document.getElementById("content").style.height = maxHeight + "px";
				document.getElementById("shadowLeft").style.height = maxHeight + "px";
				document.getElementById("shadowRight").style.height = maxHeight + "px";
			}
			else{
				maxHeight= navHeight > windowHeight ? navHeight : contentHeight;
				document.getElementById("content").style.height = maxHeight + "px";
				document.getElementById("shadowLeft").style.height = maxHeight + "px";
				document.getElementById("shadowRight").style.height = maxHeight + "px";
			}
		}
		/* ----- IE5.5-: ----- */
		else if(document.body && document.body.clientHeight){
			windowHeight= document.body.clientHeight;
			contentHeight= document.all.mainArea.clientHeight + 360;
			navHeight= document.all.mainArea.offsetHeight + 170;
			if(contentHeight > windowHeight){
				maxHeight= navHeight > windowHeight ? navHeight : contentHeight;
				document.all.content.style.height= maxHeight + "px";
				document.all.shadowLeft.style.height= maxHeight + "px";
				document.all.shadowRight.style.height= maxHeight + "px";
			}
			else{
				maxHeight= navHeight > windowHeight ? navHeight : windowHeight;
				document.all.content.style.height= maxHeight + "px";
				document.all.shadowLeft.style.height= maxHeight + "px";
				document.all.shadowRight.style.height= maxHeight + "px";
			}
		}

		/* adjust tab height */
		var maxHeight = 0;
		var active= document.getElementById("nav").getElementsByTagName("LI");
		var visible = false;
		var refHeight = 0;

		for(var i= 0; i< active.length; i++){
			if(active[i].id.length>3) {
				maxHeight = active[i].offsetHeight  > maxHeight ? active[i].offsetHeight : maxHeight; //the number defines lenght of 1st level ID (L1_ID)
			} else {
				refHeight = active[i].offsetHeight;
			}
		}

		for(var i= 0; i< active.length; i++){
			if(active[i].id.length>3) { //the number defines lenght of 1st level ID (L1_ID)
				active[i].style.height = maxHeight + "px";

				if (active[i].style.height.substring(0,2) < refHeight) {
					active[i].style.height = maxHeight-(0.185185*refHeight) + "px";
				} else {
					var twoCol = true;
				}
				if(active[i].id == L2_ID) active[i].style.background = "#fff";
			}
		}
		var linePos = document.getElementById("globalNavRoot").offsetTop + document.getElementById("globalNavRoot").offsetHeight + maxHeight + (0.12*refHeight);
		if (twoCol) {
			var linePos = document.getElementById("globalNavRoot").offsetTop + document.getElementById("globalNavRoot").offsetHeight + maxHeight + (0.31*refHeight);
		}
		if(L1_ID!="n0")	document.getElementById("head").style.background = "url(/framework/img/pic_tab_line.gif) 0 "+linePos+"px repeat-x";

	}
}

function collapseAll() {
	var active= document.getElementById("contentNavRoot").getElementsByTagName("LI");
	for(var i= 0; i< active.length; i++) {
		if(active[i].className.indexOf("Active") != -1 && active[i].id != L3_ID) {
			active[i].className = active[i].className.substr(0, active[i].className.length-6);
		}
	}
	var active= document.getElementById("contentNavRoot").getElementsByTagName("UL");
	for(var i= 0; i< active.length; i++){
		if(active[i].className.indexOf("Active") != -1) {
			active[i].className = active[i].className.substr(0, active[i].className.length-6);
		}
	}
}
function opennode() {

	actClassName = this.parentNode.className;
	actObj = this.parentNode;

	if(actClassName.indexOf("Active") != -1) {
		if (actObj.id.length > 3) {
			actObj.childNodes[2].className = actObj.childNodes[2].className.substr(0, actObj.childNodes[2].className.length-6);
			actObj.className = actObj.className.substr(0, actObj.className.length-6)
		}
		else {
			collapseAll();
		}
	}
	else {
		collapseAll();
		actObj.childNodes[2].className += "Active";
		set_content_active(this);
	}
}
function set_global_active(){
	//global
	var active= document.getElementById("nav").getElementsByTagName("LI");
	for(var i= 0; i< active.length; i++){
		if(active[i].id == L1_ID || active[i].id == L2_ID) {active[i].className="current";}
	}
}
function set_content_active(node){
	if(node) {
		var active = node;
	}
	else {
		//content
		var active= document.getElementById("contentNavRoot").getElementsByTagName("A");
		for(var i= 0; i< active.length; i++){
			if(active[i].parentNode.className.indexOf("title") != -1) {
				active[i].onclick = opennode;
				//set onclick on a
				active[i].setAttribute("href", "javascript:void(0);");
			}
		}
		//set active on li and ul
		var active = document.getElementById(L3_ID);
		if(!active) active = getActiveNode();
		if(active) L3_ID = active.id;
	}
}

function getActiveNode() {
	var directoryIndexes = new Array("index.html", "index.jsp", "default.asp");

	var rexpHost = new RegExp(document.location.protocol + "//" + document.location.host);
	var docPath = document.location.href.replace(rexpHost, "");
	docPath = docPath.replace(/\#.*/, "");
	docPath = docPath.replace(/\?.*/, "");

	var navlinks = document.getElementById("contentNavRoot").getElementsByTagName("a");
	for(var i = 0; i < navlinks.length; i++) {
		if(navlinks[i].outerHTML) {
			var rexpEmptyHref = new RegExp(/(\#)/);
			rexpEmptyHref.exec("#"); // reset RegExp object
			var rexpHref = new RegExp(/<[aA][^>]+href=["]{0,1}([^"|^\s]+)/);
			rexpHref.exec(navlinks[i].outerHTML);
			var lnkPathBIS = navlinks[i].outerHTML.match(/<[aA][^>]+href=["]{0,1}([^"|^\s]+)/gi);
			var lnkPath = RegExp.$1;
			if(lnkPath.charAt(lnkPath.length - 1) == "#" || lnkPath.charAt(lnkPath.length - 1) == "?") {
				lnkPath = lnkPath.replace(new RegExp(document.location.href), "");
			}
			lnkPath = lnkPath.replace(rexpHost, "");
		}
		else {
			lnkPath = navlinks[i].getAttribute("href").replace(rexpHost, "");
		}
		if(lnkPath != "#") {
			lnkPath = lnkPath.replace(/\#.*/, "");
			lnkPath = lnkPath.replace(/\?.*/, "");
			if(docPath == lnkPath) {
				return navlinks[i].parentNode;
			}
			if(lnkPath.indexOf(docPath) == 0 && lnkPath.lastIndexOf("/") == docPath.lastIndexOf("/")) {
				for(var j = 0; j < directoryIndexes.length; j++) {
					var al = (lnkPath.lastIndexOf("/") == lnkPath.length - 1)? lnkPath + directoryIndexes[j] : lnkPath;
					var dl = (docPath.lastIndexOf("/") == docPath.length - 1)? docPath + directoryIndexes[j] : docPath;
					if(al == dl) {
						return navlinks[i].parentNode;
					}
				}
			}
		}
	}
}

function gen_breadcrumbs() {
	//Global Nav Level 1
	var active= document.getElementById("nav").getElementsByTagName("LI");
	var L1_Name = "";
	var L2_Name = "";
	for(var i= 0; i< active.length; i++){
		//Global Nav Level 1
		if(active[i].id == L1_ID) {
			L1_Name += active[i].childNodes[0].innerHTML;
		}
		//Global Nav Level 2
		if(active[i].id == L2_ID) {
			L2_Name += active[i].childNodes[0].innerHTML;
		}
	}
	//Content Nav
	var L3_Name = "";
	var active= document.getElementById("contentNavRoot").getElementsByTagName("LI");
	for(var i= 0; i< active.length; i++){
		if(active[i].className.indexOf("Active") != -1) {
			L3_Name += " / "+active[i].childNodes[0].innerHTML;
		}
	}
	if (L1_Name != "" && L2_Name != "") {L1_Name = L1_Name+" / "}
	var bc_str = L1_Name+L2_Name+L3_Name;
	var bc_div = document.getElementById("BC4Print");
	if(bc_div) bc_div.innerHTML = bc_str;
}

function init(){
	if(self.name==""){
		set_global_active();
		set_content_active(this);
		adjustLayout();
		gen_breadcrumbs();
		footer_fix_for_opera();
	}
}

function footer_fix_for_opera(){
	if(navigator.userAgent.indexOf("Opera")!=-1) {
		document.getElementById("disclaimer").style.marginLeft = "16.3em";
	}
}

window.onload= function(){init();}
if(self.name==""){window.onresize=function(){adjustLayout();}}

// FUNCTIONS FOR POSITIONING AND RESIZING OF POPUPS:
function moveIntoPosition(){
	var wid= 0;
	var hit= 0;
	var selfwid= 0;
	var intScreenX= 0;
	var intScreenY= 0;
	if(document.documentElement){
		if(navigator.appName=="Microsoft Internet Explorer"){
			wid= opener.document.documentElement.offsetWidth;
			hit= opener.document.documentElement.clientHeight;
			selfwid= document.documentElement.offsetWidth;
			intScreenX= ((wid-selfwid)/2)+opener.screenLeft;
			intScreenY= opener.screenTop;
		}
		else{
			wid= opener.innerWidth;
			hit= opener.innerHeight;
			selfwid= self.innerWidth;
			intScreenX= (wid-selfwid)/2+opener.screenX;
			intScreenY= opener.screenY;
		}
	}
	else if(document.all){

		wid= opener.document.body.clientWidth;
		hit= opener.document.body.clientHeight;
		selfwid= document.body.clientWidth;
		intScreenX= (wid-selfwid)/2+opener.screenLeft;
		intScreenY= opener.screenTop;
	}
	self.moveTo(intScreenX,intScreenY);
}
function getRefToDivMod( divID, oDoc ) {
	if( !oDoc ) { oDoc = document; }
	if( document.layers ) {
		if( oDoc.layers[divID] ) { return oDoc.layers[divID]; } else {
			for( var x = 0, y; !y && x < oDoc.layers.length; x++ ) {
				y = getRefToDivNest(divID,oDoc.layers[x].document); }
			return y; } }
	if( document.getElementById ) { return oDoc.getElementById(divID); }
	if( document.all ) { return oDoc.all[divID]; }
	return oDoc[divID];
}
function resizeWinTo(idOfDiv){
	var horizontalGutter= navigator.appVersion.indexOf('MSIE 5')!=-1 ? 60 : navigator.userAgent.indexOf('Safari')!=- 1 ? 10 : 30;
	var vertikalGutter= 10;
	var maxHeight= 500;

	var oH= getRefToDivMod(idOfDiv); if(!oH){return false;}
	var x= window; x.resizeTo(screen.availWidth, screen.availWidth);
	var oW= oH.clip ? oH.clip.width : oH.offsetWidth;
	var oH= oH.clip ? oH.clip.height : oH.offsetHeight; if(!oH){return false;}
	x.resizeTo(oW + 200, oH + 200);
	var myW= 0, myH= 0, d= x.document.documentElement, b= x.document.body;
	if(x.innerWidth){myW= x.innerWidth; myH= x.innerHeight;}
	else if(d && d.clientWidth){myW= d.clientWidth; myH= d.clientHeight;}
	else if(b && b.clientWidth){myW= b.clientWidth; myH= b.clientHeight;}
	if(window.opera && !document.childNodes){myW+= 16;}
	//second sample, as the table may have resized
	var oH2= getRefToDivMod(idOfDiv);
	var oW2= oH2.clip ? oH2.clip.width : oH2.offsetWidth;
	var oH2= oH2.clip ? oH2.clip.height : oH2.offsetHeight;
	totHeight= (oH2 + ((oH + 200) - myH) + vertikalGutter) > maxHeight ? maxHeight : oH2 + ((oH + 200) - myH) + vertikalGutter;
	x.resizeTo(oW2 + ((oW + 200) - myW) + 10 + horizontalGutter, totHeight);
}
// END POPUP-FUNCTIONS