/* fullscreen image script by iksi.tv */
/* edited for dennisduijnhouwer.com on january 23rd 2008 */

var full = true;
var real = false;

function checkApp() {
	if (navigator.appName == 'Microsoft Internet Explorer') {
		return true;
	}
	return false;
}

function resizeBackground(w,h) {
	if (real == false) {
	img = document.getElementById('backgroundimage');
	if (full == false) {
		img.style.visibility = "hidden";
		img.style.marginTop = 0+"px";
		img.style.marginLeft = 0+"px";
		full = true;
	}
	img.style.marginTop = 0+"px";
	img.style.marginLeft = 0+"px";
	var width;
	var height;
	
	if (checkApp()) {
		// for internet explorer
		width = document.body.offsetWidth;
		height = document.body.offsetHeight;
	} else {
		// for other browsers
		width = parseInt(window.innerWidth);
		height = parseInt(window.innerHeight);
	}
	
	w = width;
	h = width * (img.height / img.width);
	x = 0;
	y = (height - h) / 2;
	
	if (centered == true && y < 0 || h < height && centered == false) { // y < 0
		h = height;
		w = height * (img.width / img.height);
		y = 0;
		x = (width - w) / 2;
	}
 	img.style.height = h+"px";
 	img.style.width = w+"px";
	img.style.visibility = "visible";
	
	if (centered == true) {
		img.style.marginTop = y+"px";
		img.style.marginLeft = x+"px";
    }
	} else if (real == true) {
		if (checkApp()) {
			// for internet explorer
			width = document.body.offsetWidth;
			height = document.body.offsetHeight;
		} else {
			// for other browsers
			width = parseInt(window.innerWidth);
			height = parseInt(window.innerHeight);
		}
		x = (width - w) / 2;
		y = (height - h) / 2;
		if (y < 0) {
			y = 0;
		}
		if (x < 0) {
			x = 0;
		}
		img.style.marginTop = y+"px";
		img.style.marginLeft = x+"px";
	}
}

function originalSize(w,h) {
	if (full == true) {
		full = false;
		real = true;
	} else {
		real = false;
		resizeBackground();
	}
	if (full == false) {
	img = document.getElementById('backgroundimage');
	img.style.visibility = "hidden";
	//
	if (checkApp()) {
		// for internet explorer
		width = document.body.offsetWidth;
		height = document.body.offsetHeight;
	} else {
		// for other browsers
		width = parseInt(window.innerWidth);
		height = parseInt(window.innerHeight);
	}
	x = (width - w) / 2;
	y = (height - h) / 2;
	if (y < 0) {
		y = 0;
	}
	if (x < 0) {
		x = 0;
	}
	img.style.height = h+"px";
	img.style.width = w+"px";
	img.style.marginTop = y+"px";
	img.style.marginLeft = x+"px";
	img.style.visibility = "visible";
	//
	}
}