$(document).ready(function(){

	$('#menu div').not('#welkom').not(".open").hide();
	$('#menu a').not('.submenu_item').click(function(){


			$('.submenudiv').not($(this).next('.submenudiv')).slideUp();
			$(this).next('.submenudiv').slideDown();

			$('.active').toggleClass('active');//.toggleClass('normal');
			$(this).addClass("active");
			
			//$('#menu a').css('margin', '12px' );
			
			return true;
    });
	
	
	$("#slider").easySlider({
		auto: true,
		continuous: true,
		numeric: true,
		pause:4000
	});


});


	$(function(){
      $("#tweets").tweet({
        avatar_size: 32,
        count: 3,
        username: ["RRoordink"],
        loading_text: "tweets ophalen...",
		template: function(i){
		
			//console.log(i); 
			id = i["item"]["id_str"]
			
			links = i["time"];
			links += "&nbsp;<a href=\"http://twitter.com/intent/tweet?in_reply_to="+id+"\" target=\"_blank\">reply</a>";
			links += "&nbsp;<a href=\"http://twitter.com/intent/retweet?tweet_id="+id+"\" target=\"_blank\">retweet</a>";
			links += "&nbsp;<a href=\"http://twitter.com/intent/favorite?tweet_id="+id+"\" target=\"_blank\">favorite</a>";


			return i["text"]+ " <span class=\"tweet_links\">"+links+"</span>";}
      }).bind("empty", function() { $(this).append("nog geen tweets gevonden!"); })
		.bind("full", function() { 

			$("#tweets").easySlider({
				auto: true,
				continuous: true,
				numeric: false,
				controlsShow: false,
				pause: 4000
			});

		});
	  
    });


	
	
	var noticeElement = null;

	function addProduct(product)
	{

	if(noticeElement!=null)
    	noticeElement.html(' ');

	noticeElement = $('#status'+product);
	$('#action'+product).val("js");

    noticeElement.html('Status: verwerken gegevens...');
	noticeElement.removeClass('statusError');
	formName = '#productForm'+product;
	
	$.post('pagina.add.htm',$(formName).serialize(),
	
		function(data){
			
			if (data.match(/^Error: /))
			{
				alert(data);
				noticeElement.html(data);
				noticeElement.addClass('statusError');
			}
			else
			{
				noticeElement.html(data);
				noticeElement.removeClass('statusError');
				updateProductCount();
			}
			

		}
 
	);
	
}

$(document).ready(function(){
	$('.product_image_more a').bind('click', function() {
	  imageName = $(this).attr("href");
	  $('.product_image_current').css('background-image', 'url("'+imageName+'")'); 
	 return false;
	});
});




	function updateProductCount()
	{
		$.ajax({ url: "pagina.shopcart.productCount.true.htm", context: document.body, 
		success: function(data) {
			$('#amount').html(data);
			alert('Load was performed.');
		}

		
		});
	  
	}
    

	function showProduct(product)
	{
    	window.open('d.webshop.pagina.detail.p.'+product+'.htm','','width=350,height=260,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no');
	}
