jQuery.noConflict();

/*
 * The background must be relative to the rest of the page elements.
 * The background position.left = 0px when the offset.left of the container = 362.
 * The new background position.left is based on the current position of the container.
 */
var beginBackgroundPositionLeft = 362;
var newLeft = 0;
function changeBackgroundPosition() {
	newLeft = jQuery("div.container").offset().left;
	newLeft = (-1 * beginBackgroundPositionLeft + newLeft) + "px";
	jQuery("body").css("background-position", newLeft + " 0px");
}

jQuery(window).resize(function(e){
	// Change the position of the background 
	// when resizing the window.
	changeBackgroundPosition();
});

jQuery(document).ready(function() {
	
	// Remove the container class
	// otherwise the outfaded items will not be visible (because of the static container width)
	var $cmsContentContainer = jQuery("div.content-container");
	var $cmsContentSliders = jQuery(".sliders", $cmsContentContainer);
	if ($cmsContentSliders.length > 0) {
		$cmsContentContainer.removeClass("container");
	}
	
	// Change the position of the background on entering the page..
	// Is needed because we don't know the resolution of the user so it can't be done with css.
	changeBackgroundPosition();
	/*
	    Support
	*/
	var hoogteSupport = jQuery('div#support').height();

	jQuery('div#support_button').click( function() {
		
		if( !jQuery('div#support').is(':visible') )	{
			// SlideDown
			jQuery('div#support_button').addClass('active');
		    jQuery('div#support').slideDown(500);
			
			var backgroundPos =  '('+newLeft + " " + hoogteSupport+'px)';
   		    jQuery('body').animate({ backgroundPosition: backgroundPos}, 500);
			
		} else {
			// SlideUp
		    jQuery('div#support').slideUp(500);
			var backgroundPos =  '('+newLeft + " " + '0px)';
		    jQuery('body').animate({ backgroundPosition: backgroundPos }, 500);
		    jQuery('div#support_button').removeClass('active');
		}

	});
	
	jQuery('div#support_button a').hover(
		function(){
			jQuery(this).stop().animate({backgroundColor:'#e20000'}, 250);
		},
		function() {
			if (!jQuery('div#support_button').hasClass('active')) {
				jQuery(this).stop().animate({backgroundColor:'#333333'}, 250);
			}
		}
	);
	
	/*
	 	 Share
	 */
	jQuery("div#share_button").hover(
		function() {
			jQuery("div#share_button ul").show();
			jQuery("div#share_button div").stop().fadeTo(500,1);
			jQuery("div#share_button span").stop().animate({'color':'#E20000'}, 0);
			jQuery("div#share_button span").css({'background-image':'url("/images/menu_plus_hover.png")'}, 250);
		}, function() {
			jQuery("div#share_button span").stop().animate({'color':'#fff'}, 0);
			jQuery("div#share_button span").css({'background-image':'url("/images/menu_plus.png")'}, 250);
			
			jQuery("div#share_button div").stop().fadeTo(250, 0, function() {
				jQuery("div#share_button ul").hide();
			});
		}
	);

});    
/**
 * End of document.onready
 */

/**
	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;
}

function followLink( element, redirectionLink ) {
	if( jQuery( element ).hasClass('in_active') ) {
		return false;
	} else {
		document.location.href = redirectionLink;
	}
}
