/*
    customDPT.js
    basic scripts for digital publishing Tool
*/

window.status = "powered by DPT";

// **************************
// scroller
// **************************


function getWindowWidth(){
	if (window.innerWidth) return window.innerWidth;
	else if (document.documentElement && document.documentElement.clientWidth) return document.documentElement.clientWidth;
	else if (document.body && document.body.offsetWidth) return document.body.offsetWidth;
	else return 0;
}
function getWindowHeight(){
	if (window.innerHeight) return window.innerHeight;
	else if (document.documentElement && document.documentElement.clientHeight) return document.documentElement.clientHeight;
	else if (document.body && document.body.offsetHeight) return document.body.offsetHeight;
	else return 0;    
}

function getObject ($id) {
	if (document.all){
		return document.all[$id];
	}
	else if (document.getElementById){
		return document.getElementById($id);
	}
	else if (document.layers){
		document.layers[$id].style = document.layer[$id];
		return document.layers[$id];
	}
	else {
		alert("Fehler: Browsertyp nicht erkannt...");
		return false;
	}
}

function scrollReset(){
	window.scroll(0,0);
}

setPageSize = function(w,h){
   setPageWidth(w);
   setPageHeight(h);
}

setPageHeight = function(h){
	var resize_layer = getObject("dpt_flash_content");
	var resize_movie = getObject("dptcontent");
	if (!isNaN(h)){
		if (parseInt(h)<getWindowHeight()){
			resize_layer.style.height = "100%";
			resize_movie.style.height = "100%";
		}
		else{ 
			resize_layer.style.height = String(h)+"px";
			resize_movie.style.height = String(h)+"px";
		}
		scrollReset();
	}
}

setPageWidth = function(w){
	var resize_layer = getObject("dptcontent");
	if (!isNaN(w)){
		if (parseInt(w)<getWindowWidth()){
			resize_layer.style.width = "100%";
		}
		else{
			resize_layer.style.width = String(w)+"px";
		}
	}
}

window.onresize = function(){        

// wenn ein window resize passiert, dann muss der div angepasst werden. 
	var div = getObject("dptcontent");
	
	if (getWindowWidth() > 800){
		// in this case, the flash div should have 100% width
		div.style.width = "100%"; 
	}     
	else{
		// fix the div width at 800 px
		div.style.width = "800px";
	}
	window.status = div.style.width;

   if (getWindowHeight() > 600){
		// in this case, the flash div should have 100% height
		div.style.height = "100%"; 
	}     
	else{
		// fix the div height at 600 px
		div.style.height = "600px";
	}
//     window.status = div.style.height;

} 
