// JavaScript Document


var imgWidth = 1600;
var imgHeight = 1067;

var myWidth = 0, myHeight = 0;

var	xposDoors = new Array();
var	yposDoors = new Array();

resizeMe();

function resizeMe(){



  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }

if(document.getElementById("rahmen")){
	document.getElementById("rahmen").style.top = "0px";
	document.getElementById("rahmen").style.left = "0px";
	
	document.getElementById("rahmen").style.width = (myWidth-20) + "px";
	document.getElementById("rahmen").style.height = (myHeight-20) + "px";
}
if(document.getElementById("content")){
	document.getElementById("content").style.height = (myHeight-96) + "px";
}
if(document.getElementById("contentblog")){
	document.getElementById("contentblog").style.height = (myHeight-95) + "px";
}
if(document.getElementById("bildercontent")){
	document.getElementById("bildercontent").style.height = (myHeight-166) + "px";
}

	if(document.getElementById("background")){
		
		document.getElementById("background").style.top = "0px";
		document.getElementById("background").style.left = "0px";

		tmpWidthScale = myWidth/imgWidth;
		tmpHeightScale = myHeight/imgHeight;
		
		if(tmpWidthScale > tmpHeightScale)
			scaleFactor = tmpWidthScale;
		else
			scaleFactor = tmpHeightScale;
		
		document.getElementById("background").style.width = (imgWidth*scaleFactor) + "px";
		document.getElementById("background").style.height = (imgHeight*scaleFactor) + "px";
	
	
		newImgWidth = (imgWidth*scaleFactor);
	 
		//Moving:
	//	document.getElementById("apDiv1").innerHTML = document.getElementById("background").style.width + "  " + myWidth;
		
		
		if(newImgWidth > myWidth){
			newPos = (newImgWidth/2) - (myWidth / 2)
			document.getElementById("background").style.left = "-" +  newPos + "px";
		}
		
		if(myHeight < 600){
			document.getElementById("contentWrapper").style.top = "170px";			
			document.getElementById("contentWrapper").style.marginTop = "0px";		
			//document.getElementById("contentWrapper").style.display = "none";
		}
		
		document.getElementById("background").style.display = "block";
		
	}
	document.body.style.visibility = "visible";

}

function getStyle(oElm, strCssRule){
	var strValue = "";
	if(document.defaultView && document.defaultView.getComputedStyle){
		strValue = document.defaultView.getComputedStyle(oElm, "").getPropertyValue(strCssRule);
	}
	else if(oElm.currentStyle){
		strCssRule = strCssRule.replace(/\-(\w)/g, function (strMatch, p1){
			return p1.toUpperCase();
		});
		strValue = oElm.currentStyle[strCssRule];
	}
	return strValue;
}

function placeKalenderDoors(){
	for(i=1; i<25;i++){
		obj = document.getElementById("z" + i);
		xpos = parseInt(getStyle(obj, "left"));
		ypos = parseInt(getStyle(obj, "top"));
		
		xfactor = myWidth / 965;
		obj.style.left = parseInt(xposDoors[i]*xfactor) + "px";
		yfactor = (myHeight-130) / 642;
		obj.style.top = parseInt(yposDoors[i]*yfactor) + "px";
	}	
}


function initKalender(){
	for(i=1; i<25;i++){
		var obj = document.getElementById("z" + i);
		obj.style.top = (parseInt(getStyle(obj, "top")) + 100) + "px";	
		xposDoors[i] = parseInt(getStyle(obj, "left"));
		yposDoors[i] = parseInt(getStyle(obj, "top"));
	}
	placeKalenderDoors();
 }
