$(document).ready(function() {
	$('.scrollToTop').click(function(){
		$('html, body').animate({scrollTop:0}, { duration: 800 });
	});	
	
	// ImgBox Plugin for zoom imgs
	$(".zoom-me").imgbox({
		'allowMultiple'		:	false,
		'overlayShow'		:	true,	
		'overlayOpacity'	:	0
	});	
});

// Call the function to make animation
function addToCart(id, quantity, pic, cart, img, classOrId) {
	
	disableUpdate = 0;
	
	// If function is not running (= 0) then make start the magic
	if(disableUpdate == 0) {
		$('.addtocart, .addtocart_big').attr("disabled", true); 
		$('.addtocart, .addtocart_big').html('Opdaterer ...');
		disableUpdate = 1;
	
					
		setTimeout(function() {
			$('.addtocart, .addtocart_big').attr("disabled", false);
			$('.addtocart, .addtocart_big').html('Tilføj til reparationsliste'); 
			disableUpdate = 0;
		}, 2000); 		
		
		$("#saved").html('Reparationen blev lagt til bestillingsliste');	 
		$("#saved").animate({"marginTop": "+=90px"},400, function(){	
			$("#saved").animate({"marginTop": "-=0px"},1500, function(){
				$("#saved").animate({"marginTop": "-=90px"},400, function(){	
				active = 0;
				});	
			});	
		});	
		$('#cart').load('/includes/cart.php?id='+id+'&quantity='+quantity);

		$.add2cart( pic, cart, img, '', 'class' );
		$('html, body').animate({scrollTop:0}, { duration: 800 });
		
	}
	
}
