/* fullscreen image script by iksi.tv */

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

function resizeBackground() {
	center = false;
	img = document.getElementById('backgroundimage');
	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 (center == true && y < 0 || h < height && center == 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 (center == true) {
		img.style.marginTop = y+"px";
		img.style.marginLeft = x+"px";
    }

}

