 $(document).ready(function($) {
		$('#preloader').fadeOut('slow');
	
		  var currentPosition = 0;
		  var slideWidth = 980;
		  var slides = $('.slide');
		  var numberOfSlides = slides.length;
		
		  // Remove scrollbar in JS
		  $('#slidesContainer').css('overflow', 'hidden');
		
		  // Wrap all .slides with #slideInner div
		  slides
		    .wrapAll('<div id="slideInner" style="position:absolute;" ></div>')
		    // Float left to display horizontally, readjust .slides width
			.css({
		      'float' : 'left',
		      'width' : slideWidth
		    });
		
		  // Set #slideInner width equal to total width of all slides
		  $('#slideInner').css('width', slideWidth * numberOfSlides);
		
		  // Hide left arrow control on first load
		  manageControls(currentPosition);
		
		  // Create event listeners for .controls clicks
		  $('.control')
		    .bind('click', function(){
		    // Determine new position
			if(currentPosition==0)
			{
				// we zijn links
				//currentPosition=numberOfSlides-1;
				currentPosition = ($(this).attr('id')=='rightControl') ? currentPosition +1 : currentPosition=numberOfSlides-1;
			}
			else if(currentPosition==numberOfSlides-1)
			{
				// we zijn rechts
				currentPosition = ($(this).attr('id')=='rightControl') ? currentPosition =0 : currentPosition-1;
			}
			else
			{
				// ergens in het midden
				currentPosition = ($(this).attr('id')=='rightControl') ? currentPosition +1 : currentPosition-1;
			}
					    
			// Hide / show controls
		    manageControls(currentPosition);
		    // Move slideInner using margin-left
		    $('#slideInner').stop(false,false).animate({
		      'marginLeft' : slideWidth*(-currentPosition)},{
		      duration: 1300 , 
		      easing : "easeOutCubic"
		      });
		  });
		
		  // manageControls: Hides and Shows controls depending on currentPosition
		  function manageControls(position){
		    // Hide left arrow if position is first slide
			if(position==0){ $('#leftControl').show() } else{ $('#leftControl').show() }
			// Hide right arrow if position is last slide
		    if(position==numberOfSlides-1){ $('#rightControl').show() } else{ $('#rightControl').show() }
		    
		    
		    
			 }
 
 	
 		$(function() { $("ul.single-nav").tabs("div#single-container > div", { effect: 'fade',fxSlide: true, rotate: true, event: 'mouseover'});});	
 
 		
		//run the currently selected effect
		function toggleMenu(action){

			//run the effect
			
			// check current position of the menucontent div
			
			if($('#menucontent').position().top==-498 && action!="closeonly")
			{
				$("#menucontent").stop().animate({top: 0},{ duration: 1300 ,easing:'easeOutQuad'});
		
				$("#menu_button").hide('slide',{ direction: "up" },100);
				$("#supercharged_logo").hide('slide',{ direction: "up" },100);
				//$("#search").hide('slide',{ direction: "up" },100);

			}
			else
			{
				if($('#menucontent').position().top!=-498)
					{
					$("#menucontent").stop().animate({top: -498},{ duration: 700 ,easing:'easeOutQuad'});
					$("#menu_button").show('slide',{ direction: "up" },100);
					$("#supercharged_logo").show('slide',{ direction: "up" },100);
					//$("#search").show('slide',{ direction: "up" },100);
				}

			}
					
			
		};
		
		//set effect from select menu value
		$("#menu_button_image").click(function() {
			toggleMenu();
			return false;
		});
		$("#menu_closebutton_image").click(function() {
			toggleMenu();
			return false;
		});
		
		$("html").click(function(){
			toggleMenu("closeonly");
		});
		
		$("#location").click(function() {
			$("#map").toggle();
			//$("#map").css("height",400);
			//$("#content_benedenheader");
			return false;
		});
		

		// accordion
		
	
		$("#mostviewed_container").accordion({
		  
		    event: 'mouseover', 

		    animated: 'swing' 
		});
	
		$("#random_items .title").hover(
			function() {
				$(this).stop(true,true);
		
				$(".label, .the_time, .comments",this).stop(true,true).animate( {opacity: 'show'});
		

				
				$(this).stop(true,true).animate({"height": "127px"}, 10 );
				$(this).stop(true,true).animate({"marginTop": "0px"}, "slow" );
				$("a", this).stop(true,true).animate({"marginTop": "16px"}, "slow" );
				
			},function () { 
		
				$(".label, .the_time, .comments",this).animate( {opacity: 'hide'});
				$(this).animate({"marginTop": "75px"}, "slow" );
				$(this).animate({"height": "38px"}, 10 );
				$("a", this).animate({"marginTop": "0px"}, "slow" );
			});	
		

		$("#openfooter_button").click(function() {
			$("#openfooter").toggle('slide',{ direction: "up" },500);
			$("#closedfooter").toggle('slide',{ direction: "down" },10);
			location.hash="#Footer";
			
			//$("#content_benedenheader");
			return false;
		});
		
		$("#closefooter_button").click(function() {
			$("#openfooter").toggle('slide',{ direction: "up" },500);
			$("#closedfooter").toggle('slide',{ direction: "down" },10);
			
			//$("#content_benedenheader");
			return false;
		});
		
		$(".addtoany_share_save").mouseover(function() {
			$(".addtoany_share_save img").attr("src", "wp-content/themes/supercharged/images/share_red.png");
			
		});
		
		$(".addtoany_share_save").mouseout(function() {
			$(".addtoany_share_save img").attr("src", "wp-content/themes/supercharged/images/share_grey.png");
			
		});
		
		$("#comments_button").click(function() {
				$("#decoratie").toggle('slide',{ direction: "right" },00);
			$("#comments_template").toggle('slide',{ direction: "up" },500);
		

			return false;
		});
		
		$("#control-left").mouseover(function() {
			$("#next_item").show();
			
		});
		
		$("#control-left").mouseout(function() {
			$("#next_item").hide();
			
		});

		$("#control-right").mouseover(function() {
			$("#prev_item").show();
			
		});
		
		$("#control-right").mouseout(function() {
			$("#prev_item").hide();
			
		});
		
		$("#map").css("margin-left",0);
		$("#map").hide();
	
		
		// function om afbeeldingen kleur te maken op mouseover
		function headerimgmouseover(obj) 
		{
			var colorsrc = $(obj).attr("link");
			$("#headerimg"+obj.id).attr("src",colorsrc);
		};
		
		// afbeeldingen weer z/w maken
		function headerimgmouseout(obj)
		{
			 	$("#headerimg"+obj.id).attr("src","wp-content/themes/supercharged/greyscale.php?file=" + $(obj).attr("link"));
		 };



	});
