WB = {
	root: '/',
	min: 1,
	max: 4
};

WB.shuffle = function (min, max) {
	var mh = document.getElementById('masthead');
	var nr = Math.floor(Math.random() * (this.max - this.min + 1)) + this.min;
	mh.style.backgroundImage = 'url(' + this.root + 'img/bg/shuffle/' + nr + '.jpg)';
};

WB.validate = function (form) {

};

WB.pop = {
	winRef : null,
	reCall : null,
	up : function (uriRef, argStr) {
		if (!this.winRef || this.winRef.closed) {
			this.winRef = window.open(uriRef, "singleton", argStr);
		} else {
			if (uriRef != this.reCall) {
				this.winRef.location = uriRef;
			}
			this.winRef.focus();
		}
		this.reCall = uriRef;
		return false;
	}
};



$(document).ready(function(){
$('.content a').each(function(){
		var matches = $(this).attr('href').match(/http:\/\/www.youtube.com\/watch\?v=(.*)/);
		
		if (matches && matches[1]) {
			$(this).attr('youtube',matches[1]).click(function(){
				WB.showMovie(this);
				return false;
			});
		}
	});

});



WB.showMovie = function(link) {
	var blackerdiv = document.createElement('div');
	blackerdiv.id = 'blacker';

	document.body.appendChild(blackerdiv);
	$('#blacker').fadeTo('fast',0).css('backgroundColor', '#333333');

	var div = document.createElement('div');
	div.id='moviePlayer';
	str= '<a href="#close" class="close">sluiten [X]</a><br/>';
	str+='<object width="560" height="340"><param name="movie" value="http://www.youtube.com/v/'+$(link).attr('youtube')+'&hl=en_US&fs=1&autoplay=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/'+$(link).attr('youtube')+'&hl=en_US&fs=1&autoplay=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="560" height="340"></embed></object>';

	$('#blacker').fadeTo(500,0.8,function(){
		$('html').addClass('lightbox');
		div.innerHTML = str;
		document.body.appendChild(div);
		$('#moviePlayer a.close, #blacker').click(function(){
			$('#moviePlayer').remove();
			$('#blacker').fadeTo(500,0,function(){
				$(this).remove();
				$('html').removeClass('lightbox');
			});
		});
	});
	
	
}



