
function printArticle( artUrl ){
    behind = window.open(artUrl ,'printwin','height=620,width=590,status=yes,toolbar=yes,directories=no,menubar=no,location=no,resizable=no,scrollbars=yes');
}

function colCh(cellname,mOver) {
	if (document.all)
        document.all[cellname].style.background = (mOver)?"#A10000":"white";
	else if (document.getElementById)
		document.getElementById(cellname).style.background = (mOver)?"green":"white" ;
}

function getAbsolutePos(el){
	for (var lx=0,ly=0;el!=null;
		lx+=el.offsetLeft,ly+=el.offsetTop,el=el.offsetParent);
	return {x:lx,y:ly}
}

function mecaPreloadImg(imageurl) {
    var newimg = new Image();
    newimg.src = imageurl;
    return newimg;
}

function ExpandMenu2 (catID) {
	
	// first, check if the children layer exists
	 if (layerNamesByID[catID]) {
	   	// get the height of the layer
		var startX = layerNamesByID[catID].getTop() + layerNamesByID[catID].getHeight();
		var moved = 0;
		var layersAlreadyMoved = new Array();
		
		// move all layers that have the same x and a higher y
		// than our layer
		
		  
		// we need to find all layers that have this as the parent, 
		// and show them
		for (i=0; i < parentMap.length; i++) {
		   	if (parentMap[i][1] == catID) {
				//alert(i + "parent er" + parentMap[i][1]);
				//alert(i + "id er " + parentMap[i][0]);
				
				layerNamesByID[parentMap[i][0]].setTop(startX);
				startX += layerNamesByID[parentMap[i][0]].getHeight();
				moved += layerNamesByID[parentMap[i][0]].getHeight();					
                layersAlreadyMoved[layersAlreadyMoved.length] = layerNamesByID[parentMap[i][0]].objLayName;
				
				if (openState[catID] == 0) {
                    layerNamesByID[parentMap[i][0]].show();
				} else {
					layerNamesByID[parentMap[i][0]].hide();
				}
			}
		}		  
		  
		// then walk through all layers with a getTop() higher than 
		// getTop() of the active layer....
		var largestHeight = 0;
		for (i=0; i< layerNames.length; i++) {
			if (layerNames[i].getTop() >  layerNamesByID[catID].getTop()) {
				// check if layer has already been moved..
				var alreadyMoved = false;
				for (j=0; j < layersAlreadyMoved.length; j++ ) {
                    if (layerNames[i].objLayName == layersAlreadyMoved[j]) {
						alreadyMoved = true;
					}
				}
				if (alreadyMoved == false) {
					if (openState[catID] == 0) {
						//alert("moving layers down by " + moved);
						layerNames[i].setTop(layerNames[i].getTop() + moved);
					} else {
						layerNames[i].setTop(layerNames[i].getTop() - moved);
					}
				}
				
                if (largestHeight < (layerNames[i].getTop() + layerNames[i].getHeight())) {
					largestHeight = (layerNames[i].getTop() + layerNames[i].getHeight())
				}
				
			}
		}

        // adjust for menu offset....
        largestHeight -= 140;
		
		// check if we are to set new height of the td
		if (getContentAreaHeight() < largestHeight) {
            //alert ("contentarea is " + getContentAreaHeight() + " , largestheight is " + largestHeight);
			expandTD(largestHeight);
		}

		
	 
		// set open state   
		if (openState[catID] == 1) {
            openState[catID] = 0 ;
			
			// if we are closing, we need to make sure to close all open
			// sub childs as well....
			
			for (i=0; i < parentMap.length; i++) {
				if (parentMap[i][1] == catID) {
					if (openState[parentMap[i][0]] == 1) {
						ExpandMenu2(parentMap[i][0]);
					}
				}
			}
			
        } else {
			openState[catID] = 1 ;
		}
    }	
}

		 
function expandTD(newheight) {
	if (document.all)
        document.all["menuheighholder"].height = newheight;
	else if (document.getElementById)
		document.getElementById("menuheighholder").height = newheight;
}
		
function getContentAreaHeight() {
    if (document.all) {
        var ret  =  document.all["menuheighholder"].height;
    } else if (document.getElementById) {
		var ret =  document.getElementById("menuheighholder").height;
    }

    /*
    if (window.innerWidth && window.innerHeight) {
        win_height = window.innerHeight;
        win_width = window.innerWidth;
     } else if (document.body.clientWidth && document.body.clientHeight) {
        win_height = document.body.clientHeight;
        win_width = document.body.clientWidth;
     } else if (window.screen) {
        win_height = screen.availHeight;
        win_width = screen.availWidth;
     } else {
        // assuming low resolution
        win_height = 600;
        win_width = 800;
     }  
     var ret  =win_height - 120 - 25;*/

     //alert('contentarea is ' + ret);
    return  ret;

}		
		 
function Login() {
    alert("Du må være logget inn for å få tilgang til dette menypunktet");
}

