var browser=navigator.appName;

function browserSize(){
			if (browser != "Netscape") {
				winW = document.body.offsetWidth;
				winH = document.body.offsetHeight
			} else {
				winW = window.innerWidth;
				winH = window.innerHeight;
			}
			
			return {w:winW, h:winH};
}

function divSize(div){
			winW = parseInt(document.getElementById(div).offsetWidth);
			winH = parseInt(document.getElementById(div).offsetHeight);
			return {w:winW, h:winH};
}

function getScrollXY() {
  var scrOfX = 0, scrOfY = 0;

  if( typeof( window.pageYOffset ) == 'number' ) {
    scrOfY = window.pageYOffset;
  } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
    scrOfY = document.body.scrollTop;

  } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
    scrOfY = document.documentElement.scrollTop;

  }

  return scrOfY;
}

function changeBG(){
			var s = getScrollXY();
			if(s>0){
				
			}
			var bro = browserSize();
			var div1 = document.getElementById("content");
			var div2 = document.getElementById("bgBottom");
			
			if(bro.w-300<883){
				//document.getElementById("debug").innerHTML = "mindre";
				div2.style.position = "absolute";
				div2.style.left = "883px";
				div2.style.top = ((bro.h-150)+s)+"px";
			}else{
				//document.getElementById("debug").innerHTML = "mer";
				div2.style.position = "fixed";
				div2.style.right = "0px";
				div2.style.left = "";
				div2.style.top = "";
				div2.style.bottom = "0px";
				
			}
			div2.style.bottom = "0px";
			
				
			
}
function picture(way){
		
		if(way == "down"){
			if(image[(i-1)] != undefined){
				i--;
			}
		}
		if(way == "up"){
			if(image[(i+1)] != undefined){
				i++;
			}
			
		}
		if(way == "way"){
			if(image[(i+1)] != undefined){
				i++;
			}else{
				i = 0;
			}
			
		}
		Photo();
}

function Photo(){
	
	if(document['img'] != undefined && image[i] != undefined){
		document['img'].src = image[i];
		tempImg = new Image();
		tempImg.src = image[i];
		if(document.getElementById("Gallery") != undefined){
			if(document['img'].width == 28){
				tempImg.onload = function(){
					document.getElementById("showcase-holder").style.width = (tempImg.width+10)+"px";
					document.getElementById("Gallery").style.width = (tempImg.width+10)+"px";
					document.getElementById("Page").style.width = (tempImg.width+10)+"px";
					
				}
			}else{
				document.getElementById("showcase-holder").style.width =  (document['img'].width+10)+"px";
				document.getElementById("Gallery").style.width = (document['img'].width+10)+"px";
				document.getElementById("Page").style.width = (document['img'].width+10)+"px";
			}
		}
		if(document.getElementById("Title") != undefined){
			document.getElementById("Title").style.width = (document['img'].width+10)+"px";
			document.getElementById("Title").innerHTML = "Bild "+(i+1)+"/"+picTOT+" - "+title[i];
		}
	}else{
		if(document.getElementById("Gallery") != undefined){
			document.getElementById("Gallery").style.display = "none";
		}
		
	}
}


function bg(obj,file){
	
	obj.style.backgroundImage = "url("+file+")";
}
var i = 0;
window.onload = function() {
	
	

	var size = 0;
	
	var navigation = document.getElementById('Menu-Holder');

	var navDiv = navigation.getElementsByTagName('div');
	for (i = 0; i < navDiv.length; i++) {
			size += navDiv[i].offsetWidth;
	}

	
	//document.getElementById('Menu-Holder').style.width = (size+5) + "px";
	
	i = 0;
	Photo();
	changeBG();
}
window.onresize = function(){
	changeBG();
}
window.onscroll = function(){
	changeBG();
}

