/*Henter skærm størelsen og scroll max height */
	  		function getPageSize(){
	
				var xScroll, yScroll;
	
					if (window.innerHeight && window.scrollMaxY) {	
						xScroll = document.body.scrollWidth;
						yScroll = window.innerHeight + window.scrollMaxY;
					} else if (document.body.scrollHeight > document.body.offsetHeight){ // alle undtagen Explorer Mac
						xScroll = document.body.scrollWidth;
						yScroll = document.body.scrollHeight;
					} else { // Explorer Mac...virker også i Explorer 6, Mozilla og Safari
						xScroll = document.body.offsetWidth;
						yScroll = document.body.offsetHeight;
					}
	
				var windowWidth, windowHeight;
					if (self.innerHeight) {	// alle undtagen Explorer
						windowWidth = self.innerWidth;
						windowHeight = self.innerHeight;
					} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6
						windowWidth = document.documentElement.clientWidth;
						windowHeight = document.documentElement.clientHeight;
					} else if (document.body) { // Andre Explorers
						windowWidth = document.body.clientWidth;
						windowHeight = document.body.clientHeight;
			}	
	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}


	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
	return arrayPageSize;
}

	  		
	  		function lightbox(id, url) {
	  			/*Henter width på bruger skærm - til at sætte lightbox center på skærm og ligge black_overlay oven på siden.*/
				var arrayPageSize = getPageSize(); 	
				
				if (self.innerWidth)  {  // alle undtagen Internet Explore
					document.getElementById('fade').style.height=arrayPageSize[1]+"px";
					
						
					} else if (document.documentElement && document.documentElement.clientWidth) { // Internet Explorer 6
								document.getElementById('fade').style.height=2000;
                                //alert(IE_height);
								
								
							
							} else if (document.body) { // andre Internet Explorers
										document.getElementById('fade').style.height=arrayPageSize[1];
							}
		         			
							document.getElementById('lightbox_content').innerHTML=document.getElementById(url).innerHTML;
							
							document.getElementById('light').style.display='block';
							
							//var top = document.getElementById('light').offsetTop; //Henter placering af light div 
							//var height = document.getElementById('light').offsetHeight; // Henter height på light div
							
                            
                            //top = top+height; // Ligger height og top sammen 
                            //top = (top-arrayPageSize[1])+arrayPageSize[1]+50; //Beregner hvor langt ned div fade skal komme på siden
                            
						
							//if(arrayPageSize[1] < top) { // Tjekker om top er større end Sidens størrelse i alt
							//document.getElementById('fade').style.height=top+'px'; // Forlænger fade sådan at den dækker hele siden.
							//}
							
	  						document.getElementById('fade').style.display='block';
	  		
	  		}

function getPos(elm) {
	for(var zx=zy=0;elm!=null;zx+=elm.offsetLeft,zy+=elm.offsetTop,elm=elm.offsetParent);
	return {x:zx,y:zy}
}

function setlightboxPos(cursorPos) {
	var arrayPageSize = getPageSize();
	
	if(arrayPageSize[3] < arrayPageSize[1]) {
		var top = document.body.scrollTop
    ? document.body.scrollTop
    : (window.pageYOffset
        ? window.pageYOffset
        : (document.body.parentElement
            ? document.body.parentElement.scrollTop
            : 0
        )
    );
    	
		top = top+20;
    	
		document.getElementById('light').style.top=top+'px';
	}
	
	
}


