var unself
if (_version != '1.2') {
    window.onerror = new Function("return true;");
}
        var isNS = (navigator.appName == "Netscape");
        var isMacIE = ( (navigator.userAgent.indexOf("IE 4") > -1) && (navigator.userAgent.indexOf("Mac")  > -1) );
        var layerRef = (isNS) ? "document" : "document.all";
        var styleRef = (isNS) ? "" : ".style";
		var isDynamic = ( ((document.layers && document.layers['testmenu']) || (document.all && document.all['testmenu'])) && !isMacIE );


function getXCoord(imgID) {
        if (isNS) xPos = document.images[imgID].x;
        else xPos = getIEXCoord(imgID)
        return xPos;
}

function getYCoord(imgID) {
  if (isNS) yPos = document.images[imgID].y;
  else yPos = getIEYCoord(imgID);
  return yPos;
}

function getIEXCoord(imgElem) {
        xPos = eval(imgElem).offsetLeft;
        tempEl = eval(imgElem).offsetParent;
        while (tempEl != null) {
                xPos += tempEl.offsetLeft;
                tempEl = tempEl.offsetParent;
        }
        return xPos;
}

function getIEYCoord(imgElem) {
        yPos = eval(imgElem).offsetTop;
        tempEl = eval(imgElem).offsetParent;
        while (tempEl != null) {
                yPos += tempEl.offsetTop;
                tempEl = tempEl.offsetParent;
        }
        return yPos;
}


var activeMenu = 0;

function activateMenu(menuLayerRef, imageName, left, top) {
	BrowserVer = navigator.appVersion;
	//MSIE_pos = BrowserVer.indexOf('MSIE');
	if (isNS) { 
		if (eval(BrowserVer.substr(0,3)) > 4 ) {
			//alert(BrowserVer.substr(0,3));
			isDynamic = 1
		} else {
			// not dyn
		}
	}


	var lightsout
    if (isDynamic && activeMenu != menuLayerRef) {
        if (activeMenu) hideMenu("menu" + activeMenu); 
        menuID = "menu" + menuLayerRef;
        activeMenu = menuLayerRef;
        if (isNS) {
			document.getElementById([menuID]).style.left = getXCoord(imageName) - left - 12;
			document.getElementById([menuID]).style.top = getYCoord(imageName) + top;
        } else {
            document.all[menuID].style.pixelLeft = getXCoord(imageName) - left;
            document.all[menuID].style.pixelTop = getYCoord(imageName) + top;
        }
        showMenu(menuID, left, top)
    }
}

function showMenu(layerID, left, top) {
		if (isNS){
			var styleSwitch="').style";
			eval(layerRef+ layerID +styleSwitch+'.visibility="visible"');

        }else { 
			    eval(layerRef + '["' + layerID + '"]' + styleRef + '.visibility = "visible"');
        }
}

function hideMenu(layerID) {
   if (isNS) {
	   var styleSwitch="').style";
		eval(layerRef+layerID+styleSwitch+'.visibility="hidden"');
	}else{
	    eval(layerRef + '["' + layerID + '"]' + styleRef + '.visibility = "hidden"');
	}
}

// check if there's a menu active
function turnOff() {
	var whichClick = "show";
    if (activeMenu) {
        menuID = "menu" + activeMenu;
        hideMenu(menuID);
        activeMenu = 0;
		handleClick(whichClick);
		ieVerHide(whichClick);

    }
}

// kills menu on clickup
function init() {
    if (isDynamic) {
        if (isNS) {
            document.captureEvents(Event.mouseup);
        }
        document.onmouseup = turnOff;
    }

//***********************************************************************

	if (navigator.appName == "Netscape") {
		if(document.getElementById) {
			layerRef="document.getElementById('";
			var styleSwitch="').style";
		}
		else if(document.layers) {
			layerRef="document.layers['";
			var styleSwitch="']";
		}
		}else{
	}
//***********************************************************************
var MSidx; // USED in HandleClick

}

// this function needs to be called from the sub menus DIV
function hideMe() {
    if (activeMenu) {
        menuID = "menu" + activeMenu;
        hideMenu(menuID);
        activeMenu = 0;
    }
}

// Work-around Netscape resize bug
if (isDynamic && isNS) {
    origWidth = innerWidth;
    origHeight = innerHeight;   
}
        
function reDo() {       
    if (innerWidth != origWidth || innerHeight != origHeight) {
        location.reload();
    }
}       

if (isDynamic && isNS) {
    onresize = reDo;
}

function timer(offon)  {
if (offon == 0)	{
    unself = setTimeout('turnOff()', 800);
    }
if (offon ==1)	{
	clearTimeout(unself);
	}
if (offon ==3)	{
    unself = setTimeout('turnOff()', 100);
	}
}


 if(document.images) {
    pics = new Array(); 
    pics[0] = new Image();
    pics[0].src = "images/icon_qt_on.gif"; 
    pics[1] = new Image();
    pics[1].src = "images/icon_qt_off.gif";
    pics[2] = new Image();
    pics[2].src = "images/icon_video_on.gif"; 
    pics[3] = new Image();
    pics[3].src = "images/icon_video_off.gif";
    pics[4] = new Image();
    pics[4].src = "images/arrow_L.gif"; 
    pics[5] = new Image();
    pics[5].src = "images/arrow_L_on.gif";
    pics[6] = new Image();
    pics[6].src = "images/arrow_R.gif"; 
    pics[7] = new Image();
    pics[7].src = "images/arrow_R_on.gif";

  }

    function changer(from,to) {
    if(document.images) {
	//	alert("pics.[" + to + "].src");
		document.images[from].src = eval("pics[" + to + "].src"); 
    }
  }




function hideLayer(whichLayer) {

	if (document.getElementById) {
		// this is the way the standards work
		document.getElementById(whichLayer).style.visibility = "hidden";
	}
	else if (document.all) {
		// this is the way old msie versions work
		document.all[whichlayer].style.visibility = "hidden";
	}
	else if (document.layers) {
		// this is the way nn4 works
		document.layers[whichLayer].visibility = "hidden";
	}
}

function showLayer(whichLayer) {

	if (document.getElementById) {
		// this is the way the standards work
		document.getElementById(whichLayer).style.visibility = "visible";
	}
	else if (document.all) {
		// this is the way old msie versions work
		document.all[whichlayer].style.visibility = "visible";
	}
	else if (document.layers) {
		// this is the way nn4 works
		document.layers[whichLayer].visibility = "visible";
	}

}

function handleClick(whichClick) {
//	var sPath = window.location.pathname;
//	var sPage =  sPath.substring(sPath.lastIndexOf('=') + 1);
//	alert(sPath.lastIndexOf('='));


	totURL = window.location.href;
	var PGid = totURL.split("=");
	if (PGid[1]=="")
	{
	//		alert("Page: " + PGid[1]);
			PGid =  "";		
	} else {
		PGid =  PGid[1]; //.substr(0,totURL.length);
	}


	if (PGid == "sol_somm" || PGid == "billigvarme" || PGid == "Invert") {
	//	alert(whichClick)
		if (whichClick == "hide") {
			// then the user wants to hide the layer
			hideLayer("boxthing");
		}
		else if (whichClick == "show") {
			// then the user wants to show the layer
			showLayer("boxthing");
		}
	}

ieVerHide(whichClick)
}

function ieVerHide(whichClick){
	var mypage= (document.URL).split("?")[0]; // CUTS OFF PAGEID
	var mypage=(mypage.split("/"))[(mypage.split("/")).length-1]
//		mypage= mypage.split("?")[0]; // CUTS OFF PAGEID
	var browser     = '';
	var version     = '';
	var entrance    = '';
	var cond        = '';
	var iever = navigator.appVersion;
	if (browser == ''){
		if (navigator.appName.indexOf('Microsoft') != -1){
			browser = 'IE';			
			var MSidx = iever.indexOf('MSIE');	
			var MSidx = navigator.appVersion.substring(MSidx+5,MSidx+8);
			var MSidx = parseFloat(MSidx);
		}else if (navigator.appName.indexOf('Netscape') != -1)
			browser = 'Netscape'
		else browser = 'NN';
		}
	if (version == ''){
		version= navigator.appVersion;
		paren = version.indexOf('(');
		whole_version = navigator.appVersion.substring(0,paren-1);
		version         = parseInt(whole_version);
	}
	if (browser == 'IE' && version >= 4) entrance = 'yes';
	if (browser == 'IE' && version < 4) entrance = 'no';
	if (browser == 'Netscape' && version >= 2.02) entrance = 'yes';
	if (browser == 'Netscape' && version < 2.02) entrance = 'no';
	if (entrance=='yes'){
	}

//	alert(mypage);
	if (MSidx < 5.5 ) { // IF IE BROWSER IS LESS THAN 5.5
		if (mypage== "OmGidex.html" || mypage== "erhverv.html" || mypage== "Privat.html" || mypage== "Service.html" || mypage=="Nyheder.html" || mypage=="kontakt.html") { // IF CURRENT PAGE CONTAINS IFRAME
			// then the user wants to hide the layer
			if (whichClick == "hide") {
				// then the user wants to hide the layer
				hideLayer("boxthing");
			}
			else if (whichClick == "show") {
				// then the user wants to show the layer
				showLayer("boxthing");
			}		
		}
	}
//	alert(MSidx);

}

