// 

openWindow = function(url, name, w, h, menubar, toolbar, scrollbars) {
	var x = parseInt(screen.width / 2) - parseInt(w/2);
	var y = parseInt(screen.height / 2) - parseInt(h/2);
	var parameters = 'toolbar=0,location=0,status=0,menubar=' + menubar + ',toolbar=' + toolbar + ',scrollbars=' + scrollbars + ',width=' + w + ',height=' + h + ',top=' + y + ',left=' + x + ',screenY=' + y + ',screenX=' + x;
	var w = window.open(url, name, parameters);
	if (w.focus) w.focus();
	return w;
}

createMailto = function(pers, domain, customText) {
	var email = pers + '@' + domain;
	(customText == null) ? lnk = email : lnk = customText;
	document.write('<a href="mailto:'+email+'">'+lnk+'</a>');
}


checkSearch = function(f) {
	if (f.keywords.value.length < 3) {
		alert('Je dient minimaal 3 letters in te voeren.');
		f.keywords.focus();
		return false;
	}
}

createFlashMovie = function(id, src, width, height, isSolid) {
	var str = '';
	str += '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="'+width+'" height="'+height+'" id="'+id+'">';
	str += '<param name="allowScriptAccess" value="sameDomain" />\n';
	str += '<param name="movie" value="'+src+'" />\n';
	str += '<param name="quality" value="high" />\n';
	str += '<param name="menu" value="false" />\n';
	if (!isSolid) str += '<param name="wmode" value="transparent" />\n';
	str += '<embed src="'+src+'" quality="high" ';
	if (!isSolid) str += 'wmode="transparent" ';
	str += 'width="'+width+'" height="'+height+'" name="'+id+'" menu="false" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />\n';
	str += '</object>\n';
	document.write(str);
}

openMediaPopup = function(src, w, h) {
	var x = parseInt(screen.width/2) - parseInt(w/2);
	var y = parseInt(screen.height/2) - parseInt(h/2);
	var parameters = 'toolbar=0,location=1,status=0,menubar=0,toolbar=0,scrollbars=0,width=' + w + ',height=' + h + ',top=' + y + ',left=' + x + ',screenY=' + y + ',screenX=' + x;
	var d = new Date();
	var name = 'pop' + d.getTime();
	var w = window.open(src, name, parameters);
	if (w.focus) w.focus();
}

initNav = function() {
	$('#nav1 img').bind("mouseenter", function(e) {
		src = this.src;
		ext = src.substring(src.lastIndexOf('.'), src.length);
		if (src.indexOf('_s' + ext) == -1) this.src = src.replace(ext, '_s'+ext);
	});
	$('#nav1 img').bind("mouseleave", function(e) {
		src = this.src;
		ext = src.substring(src.lastIndexOf('.'), src.length);
		if (src.indexOf('_s' + ext) != -1) this.src = src.replace('_s'+ext, ext);
	});
	$('#nav1 img.active').unbind();
}

initSIFR = function() {
	if (typeof sIFR == "function") {
		sIFR.replaceElement(named({sSelector:"h1.expo", sFlashSrc:"/_swf/antiqueolivebold.swf", sColor:"#000", sBgColor:"#54f759", sWmode:"transparent"}));
		sIFR.replaceElement(named({sSelector:"#expos h1", sFlashSrc:"/_swf/antiqueolivebold.swf", sColor:"#000", sBgColor:"#54f759", sWmode:"transparent"}));
		// common
		sIFR.replaceElement(named({sSelector:"h1", sFlashSrc:"/_swf/antiqueolivebold.swf", sColor:"#000", sBgColor:"#fff", sWmode:"transparent"}));
		sIFR.replaceElement(named({sSelector:"h2", sFlashSrc:"/_swf/antiqueolivebold.swf", sColor:"#000", sBgColor:"#fff", sWmode:"transparent"}));
		//sIFR.replaceElement(named({sSelector:"h3", sFlashSrc:"/_swf/antiqueolivebold.swf", sColor:"#000", sBgColor:"#fff", sWmode:"transparent"}));
		//sIFR.replaceElement(named({sSelector:"h4", sFlashSrc:"/_swf/antiqueolivebold.swf", sColor:"#000", sBgColor:"#fff", sWmode:"transparent"}));
		//sIFR.replaceElement(named({sSelector:"h6", sFlashSrc:"/_swf/antiqueolivebold.swf", sColor:"#000", sBgColor:"#fff", sWmode:"transparent"}));
	};
}

initYouTube = function() {
	// small YouTube movies
	$('.youtube1').each(function() {
		id = $(this).html();
		code = '<object width="225" height="182"><param name="movie" value="http://www.youtube.com/v/' + id + '"></param><param name="wmode" value="transparent" /><param name="allowFullScreen" value="true"></param><embed src="http://www.youtube.com/v/' + id + '" type="application/x-shockwave-flash" allowfullscreen="true" width="225" height="182" wmode="transparent"></embed></object>';
		
		$(this).html(code);
	});
	
	// normal YouTube movies
	$('.youtube2, .youtube').each(function() {
		id = $(this).html();
		code = '<object width="425" height="344"><param name="movie" value="http://www.youtube.com/v/' + id + '"></param><param name="wmode" value="transparent" /><param name="allowFullScreen" value="true"></param><embed src="http://www.youtube.com/v/' + id + '" type="application/x-shockwave-flash" allowfullscreen="true" width="425" height="344" wmode="transparent"></embed></object>';
		$(this).html(code);
	});
	
	//$('.ytfr').show();
}


initDailyMotion = function() {
	// small DailyMotion movies
	$('.dailymotion1').each(function() {
		id = $(this).html();
		code = '<object width="225" height="190"><param name="movie" value="http://www.dailymotion.com/swf/'+id+'&related=1"></param><param name="wmode" value="transparent" /><param name="allowFullScreen" value="true"></param><param name="allowScriptAccess" value="always"></param><embed src="http://www.dailymotion.com/swf/'+id+'&related=1" type="application/x-shockwave-flash" width="225" height="190" allowFullScreen="true" allowScriptAccess="always" wmode="transparent"></embed></object>';
		
		$(this).html(code);
	});
	
	// normal DailyMotion movies
	$('.dailymotion2, .dailymotion').each(function() {
		id = $(this).html();
		code = '<object width="425" height="344"><param name="movie" value="http://www.dailymotion.com/swf/'+id+'&related=1"></param><param name="allowFullScreen" value="true"></param><param name="wmode" value="transparent" /><param name="allowScriptAccess" value="always"></param><embed src="http://www.dailymotion.com/swf/'+id+'&related=1" type="application/x-shockwave-flash" width="425" height="344" allowFullScreen="true" allowScriptAccess="always" wmode="transparent"></embed></object>';
		$(this).html(code);
	});
}

initImagePopups = function() {
	$('a[href*=".jpg"], a[href*=".jpeg"], a[href*=".gif"], a[href*=".JPG"], a[href*=".JPEG"], a[href*=".GIF"]').bind("click", function(e) {
		src = this.href;
		var myImg = new Image();
		myImg.onload = function() {
			var w = this.width; var h = this.height; var scrollbars = 0;
			if (w > screen.availWidth) { w = screen.availWidth; scrollbars = 1; }
			if (h > screen.availHeight) { h = screen.availHeight; scrollbars = 1; }
			var url = '/image.php?src='+escape(src);
			openMediaPopup(url, w, h);
		}
		myImg.src = src;
		return false;
	});
}

initTickerTape = function() {
	$('#tickerTape').html($('#tickerTapeData').html());
	$('#news').bind("click", function(e) {
		document.location.href = '/nieuws/';
	});
	$(function() {
		$('#tickerTape ul').liScroll({travelocity: 0.05});
	});
}

vault = {
	cnt: 0,
	images: null,
	
	init: function() {
		if (this.images.length > 0) {
			// enable prev and next button
			if (this.images.length > 1) { 
				$('#vaultPrev').bind("click", function(e) { vault.prev(); });	
				$('#vaultNext').bind("click", function(e) { vault.next(); });
			} else {
				$('#vaultPrev').hide();	
				$('#vaultNext').hide();
			}
			
			// show first image
			this.show();
			
			// show vault
			$('#vault').show();
		}
	},
	
	next: function() {
		this.cnt++;	
		if (this.cnt >= this.images.length) this.cnt = 0;
		this.show();
	},
	
	prev: function() {
		this.cnt--;	
		if (this.cnt < 0) this.cnt = this.images.length - 1;
		this.show();
	},
	
	show: function() {
		$('#vaultImage').html('<img src="' + this.images[this.cnt].attr('src') + '" title="' + this.images[this.cnt].attr('alt') + '" align="center" />');
		$('#vaultInfo').html(this.images[this.cnt].attr('alt'));
	}
};

initVaults = function() {
	var vaultImages = [];
	$('#vault .vault-photos').find('img').each(function(e) {
		vaultImages[vaultImages.length] = $(this);							  
	});
	vault.images = vaultImages;
	vault.init();
}


$(document).ready(function() {
	initNav();
	initSIFR();
	initYouTube();
	initDailyMotion();
	initImagePopups();
	initVaults();
	// initTickerTape();
});



