window.onload = doen;
var home
var titel

var isIE = (navigator.appName.indexOf("Microsoft") != -1)+1-1;

var hasFlash = function(){
	var nRequiredVersion = 8;
	if(navigator.appVersion.indexOf("MSIE") != -1 && navigator.appVersion.indexOf("Windows") > -1){
		document.write('<script language="VBScript"\> \non error resume next \nhasFlash = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash." & ' + nRequiredVersion + '))) \n</script\> \n');
		if(window.hasFlash != null){
			return window.hasFlash;};
	};
	if(navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"] && navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin){
		var flashDescription = (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]).description;
		var vr = parseInt(flashDescription.charAt(flashDescription.indexOf(".") - 1)); if (vr < 4) vr += 10;	
		return vr >= nRequiredVersion;
	};
	return false;
}();

document.write('<style type="text/css">.alleenjs{display:block}</style>');
if (isIE){document.write('<style type="text/css">#popup{width:expression(document.getElementById("breedste").clientWidth)} #waas{height:expression(document.body.offsetHeight);}</style>')}

function zetVideo(welke){
	welke2 = welke; h = 245;
	if (!hasFlash) {welke2 = welke + '_7'}
	if (welke2.indexOf('Video') > -1) {h=260; welke= welke.replace('Video ',''); welke2 = welke;}
	document.getElementById('video').innerHTML='<embed src="/swf/flvplayer.swf" id="devideo" menu="false" width="400" height="' + h + '" allowfullscreen="true" flashvars="file=/video/' + welke2 + '.flv&height=' + h +'&image=/video/' + welke + '.jpg&width=400" />'}

function doen(){	
	if (document.getElementsByTagName){
		var anchors = document.getElementsByTagName('a');
		for (var i=0; i<anchors.length; i++){
			var anchor = anchors[i];
			if (anchor.getAttribute('href')){
				if (anchor.getAttribute('href').toLowerCase().match('.jpg')){
				anchor.onclick = function () {groot(this); return false;}
				if (anchor.title=='') anchor.title = anchor.firstChild.title;
				anchor.firstChild.title = '';
			}
			}
		}
	}

	if (document.getElementById("video")) {zetVideo(document.getElementById('video').innerHTML)}
	
	if (document.getElementById("intro")){setTimeout("ss()",5500);}
}

function ss(){
	$slish('balkimg',"grafiek/verbouwing.png;afb/_250/Restauratie_13.jpg;afb/_250/Bijgebouwen_01.jpg;afb/_250/Collectiebeheer_07.jpg;afb/_250/Huis_07.jpg;",900);
	$slishPLAY(5500);
	}


function interieur(kamer){
		popup('<div id="bijschrift"><a id="sluit" href="javascript:sluitpopup()"></a>Plattegrond Kasteel Amerongen</div><embed src="/swf/plattegrond.swf" bgcolor="#FFFFFF" base="/" menu="false" width="800" height="600" flashvars="kamer=' + kamer + '" wmode="transparent" id="breedste" />');
}

function tuin(){
	if (hasFlash){	
		popup('<div id="bijschrift"><a id="sluit" href="javascript:sluitpopup()"></a>Plattegrond van de kasteeltuin</div><embed src="/swf/tuinplattegrond.swf" bgcolor="#FFFFFF" menu="false" width="800" height="600" wmode="transparent" id="breedste" />');}
	else {
		popup('<div id="bijschrift"><a id="sluit" href="javascript:sluitpopup()"></a>Plattegrond Kasteel Amerongen</div><img src="/afb/_800/Diversen_plattegrond.jpg" alt="plattegrond" id="breedste" />');}
}

function pano(){
	if (isIE) {
	popup('<div id="bijschrift"><a id="sluit" href="javascript:sluitpopup()"></a>Panorama\'s rond Kasteel Amerongen</div><iframe src="/panoview/index.html" width="600" height="450" frameborder="0" id="breedste"></iframe>');
	} else {
		popup('<div id="bijschrift"><a id="sluit" href="javascript:sluitpopup()"></a>Panorama\'s rond Kasteel Amerongen</div><embed width="600" height="450" flashvars="lwImg=kasteel_amerongen_kasteel_ame_wait_pano_600_450.jpg&lwBgColor=255,255,255,255&lwBarBgColor=255,255,255,255&lwBarColor=255,98,124,59&lwBarBounds=181,248,215,7&lwShowLoadingPercent=false&iniFile=config_kasteel_amerongen.bin" scale="noscale" allowfullscreen="true" bgcolor="#E8EFF7" src="/panoview/twviewer.swf" type="application/x-shockwave-flash" wmode="transparent" base="/panoview/"/>');
	}
}


function flash(movie, w, h, bg, wm, flashvars){
	if (isIE){
		return '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" id="'+movie+'" width="'+ w + '" height="' + h + '"><param name="movie" value="' + movie + '" /><param name="FlashVars" value="' + flashvars + '" /><param name="quality" value="high" /><param name="menu" value="false" /><param name="wmode" value="' + wm + '" /><param name="bgcolor" value="' + bg + '" /></object>';
	} else {
		return '<embed src="' + movie + '" quality="high" wmode="' + wm + '" bgcolor="' + bg + '" menu="false" width="'+ w + '" height="'+ h + '" FlashVars="' + flashvars + '" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />';}
}

function groot(welke){
	href = welke.href;
	if (document.getElementById("intro")) {href = welke.firstChild.src; href = href.replace('_250','_800')} 
	titel2 = document.getElementById("balktekst").innerHTML;
	if (welke.title + '' != '') {titel2 = welke.title}
	
	popup('<div id="bijschrift"><a id="sluit" href="javascript:sluitpopup()"></a>' + titel2 + '</div><img id="breedste" src="' + href + '"/>');
		
	}

function popup(html){
	if (document.getElementById('devideo')){document.getElementById('devideo').style.visibility='hidden';}
	window.scroll(0, 0);
	if (!document.getElementById('popupwrap')) {
			var objBody = document.getElementsByTagName("body").item(0);
			var objOverlay = document.createElement("div");
			objOverlay.setAttribute('id','waas');
			if (!isIE){objOverlay.style.height = (objBody.offsetHeight) + 'px';}
			objBody.appendChild(objOverlay);

			var objOverlay = document.createElement("div");
			objOverlay.setAttribute('id','popupwrap2');
			objBody.appendChild(objOverlay);
			document.getElementById('popupwrap2').innerHTML = '<table id="popupwrap"><tr><td align="center"><div id="popup"></div></td></tr></table>';
		}
		document.getElementById('popup').innerHTML = html;
		document.getElementById('waas').style.display='block';
		if (isIE) {document.getElementById('popupwrap').style.display='block'; document.onkeydown = terugtoets;} 
		else {document.getElementById('popupwrap').style.display='table'; document.onkeypress = terugtoets;}
}

function terugtoets(e) {
  if(!e) e=window.event;
  key = e.keyCode ? e.keyCode : e.which;
  if (document.getElementById("popupwrap").style.display != 'none' && (key==8 || key==32 || key==37)){
  sluitpopup();return false;}
}


function sluitpopup(){
	if (document.getElementById('popup')) {
		if (document.getElementById('devideo')){document.getElementById('devideo').style.visibility='visible';}
		document.getElementById('waas').style.display='none';
		document.getElementById('popupwrap').style.display='none';
		//document.getElementById('popup').innerHTML = '<p></p>';		
			
	}
}