jQuery.noConflict();

jQuery(document).ready(function() {
	
	//Every a.fancybox_movieplayer get's renderd in 
	jQuery("a.fancybox_movieplayer").fancybox({
		'zoomOpacity'			: true,
		'overlayColor' 			: '#000',
		'overlayShow'			: true,
		'titleShow'				: false,
		'overlayOpacity' 		: 0.75,
		'padding' 				: 0,
		'enableEscapeButton'	: true,
		'hideOnContentClick'	: false,
		'showCloseButton'		: true,
		'onComplete': function(){
			jQuery().fancybox.resize();
			jQuery().fancybox.center();
		}
		
	});
	
	jQuery("div#menu ul").first().css("marginLeft", (jQuery("div#header").width() - jQuery("div#menu ul").first().width() ) / 2);
	jQuery("div#menu li ul").first().css("marginLeft", (jQuery("div#header").width() - jQuery("div#menu li ul").first().width() ) / 2);

	if( jQuery("div#menu li ul").is(":visible") ) { jQuery("div#menu").addClass("submenu"); }

	var breedteFooter = (280 - jQuery("div#contentvlak div.blok.footer").width() );

	jQuery("div#contentvlak div.blok.footer div.strack, div#contentvlak div.blok.footer").css("marginRight", breedteFooter);
	jQuery("div#contentvlak div.blok.footer div.strack, div#contentvlak div.blok.footer div.eleven").css("width", breedteFooter);

	jQuery("div#contentvlak div.blok.footer a.strack, div#contentvlak div.blok.footer div.strack, div#contentvlak div.blok.footer div.tussen_strack").hover(
	    function()
	    {
		jQuery("div#contentvlak div.blok.footer div.strack").show();
		jQuery("div#contentvlak div.blok.footer div.tussen_strack").show();
		jQuery("div#contentvlak div.blok.footer div.tussen_eleven").hide();
		jQuery("div#contentvlak div.blok.footer div.strack, div#contentvlak div.blok.footer").css("marginRight", "0px");
	    },
	    function()
	    {
		jQuery("div#contentvlak div.blok.footer div.strack").hide();
		jQuery("div#contentvlak div.blok.footer div.tussen_strack").hide();
		jQuery("div#contentvlak div.blok.footer div.tussen_eleven").show();
		jQuery("div#contentvlak div.blok.footer div.strack, div#contentvlak div.blok.footer").css("marginRight", breedteFooter);
	    }
	);

	jQuery("div#contentvlak div.blok.footer a.eleven, div#contentvlak div.blok.footer div.eleven, div#contentvlak div.blok.footer div.tussen_eleven").hover(
	    function()
	    {
		jQuery("div#contentvlak div.blok.footer div.eleven").show();
		jQuery("div#contentvlak div.blok.footer div.tussen_strack").hide();
		jQuery("div#contentvlak div.blok.footer div.tussen_eleven").show();
		jQuery("div#contentvlak div.blok.footer div.strack, div#contentvlak div.blok.footer").css("marginRight", "0px");
	    },
	    function()
	    {
		jQuery("div#contentvlak div.blok.footer div.eleven").hide();
		jQuery("div#contentvlak div.blok.footer div.tussen_strack").show();
		jQuery("div#contentvlak div.blok.footer div.tussen_eleven").hide();
		jQuery("div#contentvlak div.blok.footer div.strack, div#contentvlak div.blok.footer").css("marginRight", breedteFooter);
	    }
	);

    }
);

jQuery(window).ready(function() {
	
	//This is needed for the start to execute the first time... (IE)
	var pageload = true;
	
	jQuery("div#contentvlak").vgrid(
	{
	    easeing: "easeOutQuint",
	    useLoadImageEvent: true,
	    time: 400,
	    delay: 0,
	    fadeIn:
	    {
		time: 500,
		delay: 50
	    },
	    onFinish: function()
	    {
		start();
	    }

	});

	function start()
	{
		//Prevent the start from executing twice in a resize
		//Check of there is any margin on the jQuery("div#contentvlak_container")
		if (jQuery("div#contentvlak_container").css("margin-left") == '0px' || pageload) {
			 pageload = false;	
			 //Width of the wide blok = 640 (this is the number the plugin works with)
			 numberOfWideBloks = (jQuery("div.blok").size() - (jQuery("div.small").size()  +jQuery("div.blok_small_empty").size()));
			 var widthOfWideBloks = numberOfWideBloks * 640;
			 
			 var widthContentvlak =  jQuery("div#contentvlak").outerWidth();
			 var widthForSmallBloks = widthContentvlak - widthOfWideBloks;
			 
			 //Get width left for centering
		    numberOfSmallBloks =  Math.floor( widthForSmallBloks / 320 );
		    var widthSmallBlokItems = ( 320 * numberOfSmallBloks );
		    var widthLeft = ( widthForSmallBloks - widthSmallBlokItems ) / 2;
		    
		    jQuery("div#contentvlak_container").animate( { marginLeft: widthLeft }, 500);
		    
		    //Position the possible paging 
		    jQuery("div#paginatieText").css('display', 'block');
		    jQuery("div#paginatieText").animate({ opacity: 0 }, 0);
	
		    jQuery("div#paginatieText").animate({right: widthLeft+10, opacity: 1}, 500);
		}
	}

	//Because the onFinish isn't called the first time
	start();
	
	jQuery(window).resize(
	    function()
	    {
	    	start();
	    }
	);
	
	if (jQuery.browser.msie) {
		jQuery("div.blok").each(function() { PIE.attach(this); });
1	}
	
    }
);

/**
Facebook
*/
function fbs_click(urls,titles) {
	u=urls;
	t=titles;
	window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(u)+'&amp;t='+encodeURIComponent(t),'sharer','toolbar=0,status=0,width=626,height=436');
	return false;
}
