﻿var frameHoogte = 0;
var frameBreedte = 0;

function getWindowHeight() {
	var windowHeight = 0;
	if (typeof(window.innerHeight) == 'number') {
		windowHeight = window.innerHeight;
	} else {
		if (document.documentElement && document.documentElement.clientHeight) {
			windowHeight = document.documentElement.clientHeight;
		} else {
			if (document.body && document.body.clientHeight) {
				windowHeight = document.body.clientHeight;
			}
		}
	}
	return windowHeight;
}

function getWindowWidth() {
	var windowWidth = 0;
	if (typeof(window.innerWidth) == 'number') {
		windowWidth = window.innerWidth;
	} else {
		if (document.documentElement && document.documentElement.clientWidth) {
			windowWidth = document.documentElement.clientWidth;
		} else {
			if (document.body && document.body.clientWidth) {
				windowWidth = document.body.clientWidth;
			}
		}
	}
	return windowWidth;
}

function setDimensions() {
	frameHoogte = getWindowHeight();
	frameBreedte = getWindowWidth();
}

setDimensions();


function schaalDetail(el) {
	var links = Math.max(Math.floor((frameBreedte-1000)/2),0);
	document.getElementById(el).style.left = links + 'px';	
	var top = 0;
	if (frameHoogte <= 800) {
		top = Math.max(Math.floor((frameHoogte-460)/2),0);
	} else {
		top = 156;
	}
	document.getElementById(el).style.top = top + 'px';	
}

function schaalFotoGroot() {
	if (document.getElementById('divFotoGroot')) {
		var br = Math.min((frameBreedte-80), 1200);
		var ho = Math.min((frameHoogte-80), 1000);
		var le = (frameBreedte - br)/2;
		var to = (frameHoogte - ho)/2;
		document.getElementById('divFotoGroot').style.left = le.toString() + 'px';
		document.getElementById('divFotoGroot').style.width = br.toString() + 'px';
		document.getElementById('divFotoGroot').style.top = to.toString() + 'px';
		document.getElementById('divFotoGroot').style.height = ho.toString() + 'px';
	}
}

function resizeDetail(el) {
	setDimensions();
	if (document.getElementById(el)) {
		schaalDetail(el);
		//alert('resize ' + el);
	}
}

function resizeAlles() {
	//alert('schaal alles');
	setDimensions();
	if (document.getElementById('detailDiv')) {schaalDetail('detailDiv');}    
	if (document.getElementById('sfeerDiv')) {schaalDetail('sfeerDiv');}    
	schaalFotoGroot();
}


function detectMacXFF2() {
	var userAgent = navigator.userAgent.toLowerCase();
 	if (/firefox[\/\s](\d+\.\d+)/.test(userAgent)) {
		var ffversion = new Number(RegExp.$1);
		if (ffversion < 3 && userAgent.indexOf('mac') != -1) {
			return true;
		}
	}
}


function setOpacity(el) {
	var yourShade = document.getElementById(el);
	var d = detectMacXFF2(); //note new detectMacXFF2 script above
	if (d) {
		//alert('FF2/MAC');
		//osx ff css opacity + flash wmode transparent doesn't work
		yourShade.style.backgroundImage= "url(/images/zwart70.png)";
		yourShade.style.backgroundRepeat="repeat";
	} else {
		//  alert('Geen FF2/MAC');
		yourShade.style.backgroundColor = "#000000";
		yourShade.style.MozOpacity = .7;
		yourShade.style.opacity = .7;
		yourShade.style.filter = "alpha(opacity=70)";
	}
}
