$(document).ready(function() {

	// Setup Download tracking
	$("a.track_download").click(function() {
	  var v = $(this).html().replace(/[\s\"\'\/]+/ig, "_");  
	  pageTracker._trackPageview("/downloadsen/"+v);
	});

						   
	// Jquery breedte checken en fixen	
	$.fn.width = function() {
		var $browser = document.documentElement.clientWidth;
		if($browser>915){
			$("body").css('overflow-x', 'hidden');
		}
		else {
			$("body").css('overflow-x', 'visible');
		}
		var $height = $('#container').height();
		if($height<757){
			$newheight = $height;
			$('#glow').css('height', $newheight+'px');
		}
	}
	
	// Jquery top	
	$("ul.dropdown li a:first").addClass("top");
	$("ul.dropdown li:first").hover(
		function(){$(this).addClass("active");},
		function(){$(this).removeClass("active");}
	);	
	
	// Jquery nieuws items
	jQuery.fn.hovers = function() {
		$(this).hover(
			function(){
				var $this = $(this);
				var $new = $this.attr('rel');
				var $old = $($this).children("img").attr('src');	
				$($this).attr('rel',$old);
				$($this).children("img").attr('src',$new);			
			},
			function(){		
				var $this = $(this);
				var $new = $this.attr('rel');
				var $old = $($this).children("img").attr('src');	
				$($this).attr('rel',$old);
				$($this).children("img").attr('src',$new);	
			}
		);
	}
	$('ul.news li a').hovers();
	$('ul.beurzen li a').hovers();
	
		
		$("tbody tr:last-child td").css('border', '0');
	
	if($('#accordion').size() > 0){
	  $('#accordion').accordion({
			 selectedClass: 'open',
			 autoHeight: false
		});
		$('#accordion h3:first small').html('');
		
		$('#accordion h3').bind('click', function(event, ui) {		  
      $('#accordion h3 small').html('More information');      		  
      $(this).find("small").html(''); 

      $("body").width();
     });  
	}
	
  $("body").width();
  $(window).resize(function(){$("body").width();});
	
	$('.overzicht ul li a').hover(function(){
		$(this).parents().prev('strong').css('color',  '#436a8f');
	},function(){
		$(this).parents().prev('strong').css('color',  '#767676');
	}
	);
	
	
	// Slideshow	
	$('#next').hide();
	$('#prev').hide();
	
  if($('.images div').size()>0) {

  	$('.images div').cycle({ 
 		 fx:     'fade', 
  		 speed:  'slow',
  		 next:   '#next', 
  		 prev:   '#prev',        
  		 after:	onAfter
  	});

	}
		
	function onAfter(curr,next,opts) {
		if(opts.slideCount>1){
			$('#next').show();
			$('#prev').show();
			$('#slideshow').css();
			var caption = '' + (opts.currSlide + 1) + '/' + opts.slideCount;
			$('#pages').html(caption);
		}
	}
	
	// Usage
    var detective = new Detector();
	  if(detective.test('Myriad Pro')==false)
		  $('*').css("font-family","Arial");									
});

Shadowbox.init({
	//skipSetup: 			true,
	language:   			"en",
	players:    			["img","flv","iframe"],
	displayNav:         	true,
	handleUnsupported:  	"remove",
	autoplayMovies:     	true,
	overlayColor:			'#000',	
	overlayOpacity: 		'0.6' 
});

function showShadowBoxPopup(urlToShow, width, height){
	
	if(width == undefined){
		width = 350;
		}
	if(height == undefined){
		height = 350;
		}

    // open a welcome message as soon as the window loads
    Shadowbox.open({
        content:    urlToShow,
        player:     "iframe",
        title:      "",
        height:     height,
        width:      width
    });
	 
 };