




function popupNewBrowserWindow(args) {
	if (!args || !args.url) return null;

	var left = (args.left ? args.left : 0);
	var top = (args.top ? args.top : 0);
	var width = (args.width ? args.width : 1024);
	var height = (args.height ? args.height : 768);

	popUpWin = open(args.url, '_blank', 'toolbar=yes,location=yes,directories=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes,copyhistory=no,width='+width+',height='+height+',left=0, top=0,screenX='+left+',screenY='+top+'');
	//popUpWin.resizeTo(screen.availWidth,screen.availHeight); //popUpWin.moveTo(0,0);
}












function popupImage( args ) {
	if (!args || !args.url) return;

	var url = args.url;
	var omschrijving = args.omschrijving;
	var previous = args.previous;
	var next = args.next;

	var html = '<table style="width:1px;" cellpadding="0" cellspacing="0">';

			html+= '<tr>';
			if (previous) html+= '<td align="left" valign="middle"><img onclick="var x = document.getElementById(\'' +previous+ '\'); if (x && x.onclick) { hidePopup(); x.onclick(); };" style="position:absolute;width:13px;height:21px;margin-left:-11px;cursor:pointer;" src="./img/product_icon_gallerij_vorige.png" title="Terug bladeren" /></td>';
			html+= '<td align="left" valign="top"><img onload="showPopupRecalculate();" onclick="hidePopup();" style="margin:2px 7px 0px 7px;cursor:pointer;" src="' +url+ '" title="Klik om te sluiten" /></td>';
			if (next) html+= '<td align="left" valign="middle"><img onclick="var x = document.getElementById(\'' +next+ '\'); if (x && x.onclick) { hidePopup(); x.onclick(); };" style="position:absolute;width:13px;height:21px;margin-left:-2px;cursor:pointer;" src="./img/product_icon_gallerij_volgende.png" title="Vooruit bladeren" /></td>';
			html+= '</tr>';
			html+= '</table>';

			if (omschrijving) html+= '<div style="padding:1px 10px 0px 12px;font-size:85%;color:#444;">"' +omschrijving+ '"</div>';
	
			showPopup( { html: html, centerOn: 'screen' } );
}







function zoomImage(obj, zoom) {
	var zoomParent = (obj && obj.parentNode ? obj.parentNode.parentNode : null);
		if (!obj || !zoomParent) return;

	if (zoom) {
		obj.widthOld = obj.clientWidth;
		obj.heightOld = obj.clientHeight;
		var widthNew = Math.ceil((obj.widthOld / 100) * zoom);
		var heightNew = Math.ceil((obj.heightOld / 100) * zoom);
		var xDiff = Math.ceil((obj.widthOld - widthNew) / 2);
		var yDiff = Math.ceil((obj.heightOld - heightNew) / 2);
		obj.style.width = widthNew + 'px';
		obj.style.height = heightNew + 'px';
		zoomParent.style.left = xDiff + 'px';
		zoomParent.style.top = yDiff + 'px';
	} else {
		obj.style.width = obj.widthOld + 'px';
		obj.style.height = obj.heightOld + 'px';
		zoomParent.style.left = '';
		zoomParent.style.top = '';
	}
}







function dimmerOn(x) {
	var dimmer = document.getElementById("page_dimmer");
			if (!dimmer) return;

	var i, objs = document.getElementsByTagName("select"); // all select elements on page
		for (i = 0; i != objs.length; i++) if (objs[i].style) objs[i].style.visibility = "hidden"; // hide all

	dimmer.style.display = "block"; // show dimmer obj
	dimmer.style.zIndex = setAndGetNextHighestDepth(); // update zIndex

	setOpacity(dimmer, (x*1 > 1 ? x : 30)); // set opacity
	var browser = getBrowserDimensions(); // get browser object
			dimmer.style.width = (browser.documentWidth) + 'px';
			dimmer.style.height = (browser.documentHeight) + 'px';
}




function dimmerOff() {
	var dimmer = document.getElementById("page_dimmer");
			if (!dimmer) return;

	var i, objs = document.getElementsByTagName("select"); // all select elements on page
		for (i = 0; i != objs.length; i++) if (objs[i].style) objs[i].style.visibility = "visible"; // show all

	dimmer.style.width = '1px';
	dimmer.style.height = '1px';
	dimmer.style.display = "none"; // hide dimmer obj
}





function showHourglass(x,y) {
	var hourglass = document.getElementById("page_hourglass");
			if (!hourglass) return;

	var browser = getBrowserDimensions(document); // get browser object
			hourglass.style.display = "block";
			hourglass.style.zIndex = setAndGetNextHighestDepth(); // update zIndex

			hourglass.style.left = (x > 0 ? (x + browser.scrollLeft) : Math.round(((browser.viewportWidth - hourglass.offsetWidth) / 2) + browser.scrollLeft)) + 'px';
			hourglass.style.top = (y > 0 ? (y + browser.scrollTop) : Math.round(((browser.viewportHeight - hourglass.offsetHeight) / 2) + browser.scrollTop)) + 'px';
}




function hideHourglass() {
	var hourglass = document.getElementById("page_hourglass");
			if (!hourglass) return;

			hourglass.style.left = '0px';
			hourglass.style.top = '0px';
			hourglass.style.display = "none";
}



function dimmerOnAndShowHourglass() { showHourglass(); dimmerOn(33); }
function dimmerOffAndHideHourglass() { hideHourglass(); dimmerOff(); }



function hideHourglassAndWait(t) { setTimeoutLiteral((t ? t : 1000), dimmerOffAndHideHourglass); }





function showPopup( args ) {
	if (!args || !args.html) return;

	var popup = document.getElementById("page_popup");
	if (!popup) return;

	var popup_content = document.getElementById("page_popup_content");
	if (!popup_content) return;

			dimmerOn(33);
			popup.closeButton = true;

			popup.centerOn = (args.centerOn == 'content' ? 'content' : 'screen'); // save this choice
			if (args.confirm == true) {
				popup.confirmYes = args.confirmYes;
				popup.confirmYesArgs = args.confirmYesArgs;
				popup.confirmNo = args.confirmNo;
				popup.confirmNoArgs = args.confirmNoArgs;
				args.html+= '<div align="center" style="margin:20px auto 0px auto;"><span style="padding:0px 15px 0px 0px;"><img style="cursor:pointer;" onclick="showPopup_confirm_yes();" src="./img/page_button_ja.png" alt="Ja" /></span><span style="padding:0px 0px 0px 15px;"><img style="cursor:pointer;" onclick="showPopup_confirm_no();" src="./img/page_button_nee.png" alt="Nee" /></span></div>';
			}

			if (args.ok == true) {
				popup.closeButton = false;
				args.html+= '<div align="center" style="margin:15px auto 0px auto;"><img style="cursor:pointer;" onclick="hidePopup();" src="./img/page_button_ok.png" alt="Ok" /></div>';
			}

			if (args.reloadPage == true) {
				popup.closeButton = false;
				popup.confirmYes = function() { self.location.replace( self.location.href ); };
				args.html+= '<div align="center" style="margin:20px auto 0px auto;"><img style="cursor:pointer;" onclick="showPopup_confirm_yes();" src="./img/page_button_ok.png" alt="Ok" /></div>';
			}

			if (args.clickPopupClose == true) { popup.onclick = function(){ hidePopup(); }; popup.style.cursor = 'pointer'; } else { popup.onclick = null; popup.style.cursor = ''; } // whole popup as close button
			if (args.closeButton == false) popup.closeButton = false; // if given false, no close button in any case
			if (args.sound) execFlash['swf_exif'].send( { action: "exif_playSound",  sound: args.sound } ); // play sound

			popup.style.display = "block"; // display
			popup.style.zIndex = setAndGetNextHighestDepth(); // update zIndex

			popup.style.left = "0px"; // off screen
			popup.style.top = "0px"; // off screen
			popup.style.width = ""; // clean width style
			popup.style.height = ""; // clean height style
			showPopupRecalculate();
			popup_content.innerHTML = args.html;
			popup_content.style.width = (args.width ? args.width : ""); // set or clean width style

			var popupcloseButton = document.getElementById("page_popup_close_button");
				if (popupcloseButton) popupcloseButton.style.display = (popup.closeButton == false ? 'none' : 'block');

			showPopupRecalculate();
}






function showPopup_confirm_yes() {
	var popup = document.getElementById("page_popup");
	if (popup && popup.confirmYes) popup.confirmYes(popup.confirmYesArgs);
	hidePopup();
}







function showPopup_confirm_no() {
	var popup = document.getElementById("page_popup");
	if (popup && popup.confirmNo) popup.confirmNo(popup.confirmNoArgs);
	hidePopup();
}






function showPopupRecalculate() {
	var popup = document.getElementById("page_popup");
	var browser = getBrowserDimensions(document); // get browser object
	var content = document.getElementById("content_column");
			if (!popup || !browser || !content) return;

			popup.style.left = (popup.centerOn == 'screen' ? Math.round(((browser.viewportWidth - popup.offsetWidth) / 2) + browser.scrollLeft) : Math.round((content.offsetWidth - popup.offsetWidth) / 2) + getLeft(content)) + 'px';
			popup.style.top = Math.round(((browser.viewportHeight - popup.offsetHeight) / 2) + browser.scrollTop) + 'px';
}







function hidePopup() {
	var popup = document.getElementById("page_popup");
	var popup_content = document.getElementById("page_popup_content");
	if (!popup || !popup_content) return;

	popup_content.innerHTML = "&nbsp;"; // empty content
	popup.confirmYes = null;
	popup.confirmYesArgs = null;
	popup.confirmNo = null;
	popup.confirmNoArgs = null;
	popup.style.width = '1px'; // 1px
	popup.style.height = '1px'; // 1px
	popup.style.left = "-1000px"; // off screen
	popup.style.top = "-1000px"; // off screen
	popup.style.display = "none";
	dimmerOffAndHideHourglass();
}







function onKeyEvent(evt, codes, func, args) {
	//
	// example: onKeyEvent(event, [13,9], updateTotaalPrijs);

	// 13 = enter
	// 9 = tab

	evt = (evt) ? evt : event;
	var charCode = (evt.charCode) ? evt.charCode : ((evt.which) ? evt.which : evt.keyCode);
	if (!evt || !charCode || !codes) return;

	var codematch = false;
	for (var code in codes) if (charCode == codes[code]) { codematch = true; break; }
	if (codematch == false) return;

	if (func) func(args); // if function, execute it

	// prevent focusing somewhere else
	evt.cancelBubble = true;
	evt.returnValue = false;
	if (evt.preventDefault) evt.preventDefault(); // firefox
	if (evt.stopPropagation) evt.stopPropagation(); // firefox
	return false;
}







function execFlashReportError( args ) {
	dimmerOffAndHideHourglass();
	var reloadPage = (args && args['reloadPage'] && args['reloadPage'] == true ? true : false);
	var html = (args && args['error'] ? exif_unescape(args['error']) : 'Algemene foutmelding.');
	showPopup( { html: html, width: '300px', centerOn: 'content', reloadPage: (reloadPage) } );
}






// ----------------------------------------------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------------------------------------------------



function gaNaarThema( url ) { keepSession(); self.location.href = url; }



function showGameObject() {

	var gameplayer_timer = document.getElementById("gameplayer_timer");

	if (gameplayer_timer && wizard.game_timeout_sec > 1) {
		wizard.game_timeout_sec--;
		gameplayer_timer.innerHTML = wizard.game_timeout_sec + ' sec';
		setTimeout(showGameObject , wizard.game_timeout_msecs);
		return;
	}

	var gameplayer_obj = document.getElementById("gameplayer_swf");
	var gameplayer_bg = document.getElementById("gameplayer_bg");

	if (wizard.gameInfo.contentWindow == 'popup') { gameplayer_bg.innerHTML = gameplayer_obj.innerHTML; return; }


			gameplayer_obj.style.width = wizard.gameInfo.width + 'px';
			gameplayer_obj.style.height = wizard.gameInfo.height + 'px';
			gameplayer_bg.style.display = "none";
}




