
openedPage = '';

$(document).ready(function() {
	
	init();

	$('#foto-menu a[href$=2009]').mouseover(function(){
		$('#foto-menu').css('background-image','url(/2011/img/block_2009.png)');
	});
	$('#foto-menu a[href$=2010]').mouseover(function(){
		$('#foto-menu').css('background-image','url(/2011/img/block_2010.png)');
	});
	$('#foto-menu a[href$=2011]').mouseover(function(){
		$('#foto-menu').css('background-image','url(/2011/img/block_2011.png)');
	});
	$('#foto-menu a:not(.selected)').mouseout(function(){
		$('#foto-menu').css('background-image','url(/2011/img/block.png)');
	});
	
	$('a[href$=#!/home]').click(function(){
		openPage('home.php','/2011/');
	});
		
	$('a[href$=#!/foto-2009]').click(function(){
		openPage('foto.php?jaar=2009','/2011/foto-2009');
	});
	$('a[href$=#!/foto-2010]').click(function(){
		openPage('foto.php?jaar=2010','/2011/foto-2010');
	});
	$('a[href$=#!/foto-2011]').click(function(){
		openPage('foto.php?jaar=2011','/2011/foto-2011');
	});
	$('#sponsor-worden').click(function(){
		_gaq.push(['_trackPageview', '/2011/files/sponsorbrochure.pdf']);
	});
	
	$('#tweets').vTicker({
		speed: 300,
		pause: 3500,
		showItems: 3,
		animation: 'fade',
		mousePause: false,
		height: 0,
		direction: 'up',
		mousePause: true,
		height: 150
	});		


});

function openPage(htreq,page){
	if(htreq != openedPage){	
		$.get('/2011/ajax/' + htreq, function(data) {
			_gaq.push(['_trackPageview', page]);
			$('#user-content').html(data);
			init();
		});	
	}
}

function init(){
	
	$('#images a.current').fancybox({
		'transitionIn'		: 'elastic',
		'transitionOut'		: 'elastic',
		'titlePosition' 	: 'over',
		'rel'				: $(this).attr('rel'),
		'titleFormat'		: function(title, currentArray, currentIndex, currentOpts) {

			url = title;
			
			html = 'Deze foto delen: <a href="http://www.facebook.com/sharer.php?u=' + url + '" target="_blank"><img src="/2011/img/social/facebook.png" alt="Deel op Facebook" border="0" /></a><a href="http://www.hyves.nl/profilemanage/add/tips/?name=&amp;text=' + url + '" target="_blank"><img src="/2011/img/social/hyves.png" alt="Deel op Hyves" border="0" /></a><a href="http://twitter.com/home?status=' + url + '" target="_blank"><img src="/2011/img/social/twitter.png" alt="Deel op Twitter" border="0" /></a>';
					
			return '<span id="fancybox-title-over">' + html + '</span>';
		}
	}).trigger('click');

	$("#images a").fancybox({
		'transitionIn'		: 'elastic',
		'transitionOut'		: 'elastic',
		'titlePosition' 	: 'over',
		'rel'				: $(this).attr('rel'),
		'titleFormat'		: function(title, currentArray, currentIndex, currentOpts) {
			url = title;
			html = 'Deze foto delen: <a href="http://www.facebook.com/sharer.php?u=' + url + '" target="_blank"><img src="/2011/img/social/facebook.png" alt="Deel op Facebook" border="0" /></a><a href="http://www.hyves.nl/profilemanage/add/tips/?name=&amp;text=' + url + '" target="_blank"><img src="/2011/img/social/hyves.png" alt="Deel op Hyves" border="0" /></a><a href="http://twitter.com/intent/tweet?text=' + url + '" target="_blank"><img src="/2011/img/social/twitter.png" alt="Deel op Twitter" border="0" /></a>';
			return '<span id="fancybox-title-over">' + html + '</span>';
		},
		'onComplete': function(currentArray, currentIndex, currentOpts){
			url = 'Foto: ' + String(currentArray[currentIndex]);
			_gaq.push(['_trackPageview', url]);
		}
	});

}

function runSwf(src,width,height,flashvars){
	document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="' + width + '" height="' + height + '">');
	document.write('<param name="movie" value="' + src + '">');
	document.write('<param name="quality" value="high">');
	document.write('<param name="menu" value="false">');
	document.write('<param name="author" value="Sven de Bie">');
	document.write('<param name="copyright" value="de Bie productions 2011">');
	document.write('<param name="flashvars" value="&' + flashvars + '">');
	document.write('<param name="wmode" value="transparent">');
	document.write('<embed src="' + src + '" flashvars="&' + flashvars + '" menu="false" wmode="transparent" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="' + width + '" height="' + height + '"></embed>');
	document.write('</object>');	
}
