/**
 * 
 * Hier volgen een aantal jQuery functions om het afrekenen af te handelen
 * 
 */

	jQuery(function(){
		verwijder_item();
		add_shop_functions();
	});

	function verwijder_item(){
		jQuery('.verwijderItem').each(function(index){
			jQuery(this).click(function(){
				//alert('test');
				var entry_id = jQuery(this).attr('name');
					
				jQuery.get("modules/shop/winkelwagen.php?action=verwijderen&entry_id=" + entry_id, function(data){
					
					

					jQuery.get("modules/shop/winkelwagen.php" + '?logo=' + true + "&action=winkelwagen", function(shopping_bag){
						jQuery('#shopping_bag').html(shopping_bag);
					});
					 
					jQuery('.content_mainpage').html(data);
						verwijder_item();
						add_shop_functions();
					
				});
				
				
				
			});
		});


		jQuery('.aantalEx').each(function(index){
			jQuery(this).change(function(){
				
				var entry_id = jQuery(this).attr('name');
				var aantal = jQuery(this).val();
				//alert(aantal);
				jQuery.get("modules/shop/winkelwagen.php?action=veranderen&entry_id=" + entry_id +"&aantal=" + aantal, function(data){
					jQuery('.content_mainpage').html(data);
					
					jQuery.get("modules/shop/winkelwagen.php" + '?logo=' + true + "&action=winkelwagen", function(data){
						jQuery('#shopping_bag').html(data);
					});
					verwijder_item();
					add_shop_functions();
					
				});
			});
		});
	}

/*	jQuery(function(){
	
		jQuery('.verwijderItem').each(function(index){
			jQuery(this).click(function(){
				//alert('test');
				var entry_id = jQuery(this).attr('name');
				jQuery.get("modules/shop/winkelwagen.php?action=verwijderen&entry_id=" + entry_id, function(data){
					jQuery('.content_mainpage').html(data);

					jQuery.get("modules/shop/winkelwagen.php" + '?logo=' + true + "&action=winkelwagen", function(data){
						jQuery('#shopping_bag').html(data);
					});
					verwijder_item();
				});
				
				
			});
		});


		jQuery('.aantalEx').each(function(index){
			jQuery(this).change(function(){
				
				var entry_id = jQuery(this).attr('name');
				var aantal = jQuery(this).val();
				//alert(aantal);
				jQuery.get("modules/shop/winkelwagen.php?action=veranderen&entry_id=" + entry_id +"&aantal=" + aantal, function(data){
					jQuery('.content_mainpage').html(data);
					
					jQuery.get("modules/shop/winkelwagen.php" + '?logo=' + true + "&action=winkelwagen", function(data){
						jQuery('#shopping_bag').html(data);
					});
					verwijder_item();
				});
			});
		});
		
	});
*/
function add_shop_functions(){
	jQuery(function(){
		jQuery(".gegevens").each(function(index){
			jQuery(this).click(function(){
				var action = '?action=' + jQuery(this).attr('name');
				
				jQuery.get('modules/shop/winkelwagen.php' + action, function(data){
						jQuery('.content_mainpage').html(data);
						
						jQuery.get("modules/shop/winkelwagen.php" + '?logo=' + true + "&action=winkelwagen", function(data){
							jQuery('#shopping_bag').html(data);
						});
							
						add_shop_functions();
					
				});
			});
		});
	});
/*
	jQuery(function(){
		jQuery('.naarKassa').click(function(){
			//alert('test');
			jQuery.get("modules/shop/winkelwagen.php?action=overzicht",'', function(data){
				if(data == '0'){
					alert('u moet eerst een item in uw winkelwagen stoppen, voordat u kunt afrekenen!');
				}else{
					jQuery('#content_links_shop').html(data);
				}
					
			});
		});
	});
	
*/
	
	
	
		jQuery(function(){
			
			jQuery.get("modules/shop/winkelwagen.php" + '?logo=' + true + "&action=winkelwagen", function(data){
				jQuery('#shopping_bag').html(data);
			});
			
		});
		
		jQuery(function(){
	
		//	jQuery(".naarKassa").hide();
				
			
			jQuery('.winkelen').each(function(index){
				jQuery(this).click(function(){
					//alert('test');
					var shopId = jQuery(this).attr('name');
					//alert(shopId);
					jQuery.get("modules/shop/winkelwagen.php" + shopId + "&action=winkelwagen", function(data){
						jQuery('#shopping_bag').html(data);
						jQuery(".naarKassa").show();
					});

					jQuery.jGrowl.defaults.position = 'center';
					jQuery.jGrowl('<div style="color:#E11584;background:white;margin-top:30px;margin-left:30px">Je product is toegevoegd <img src="template/default/images/shop/vinkje.jpg" /></div>', {life:500});
					
					
					
				});
			});
			
	
		});
/*	
		jQuery(function(){
			
			jQuery('.leesverder').each(function(index){
				jQuery(this).click(function(){
					//alert('test');
					var shopId = jQuery(this).attr('name');
					jQuery.get("modules/shop/winkelwagen.php" + shopId + "&action=leesverder", function(data){
						jQuery('#content_links_shop').html(data);
					});
					
					
				});
			});
			
	
		});
		*/
	}
	
 
/*
 jQuery(function(){
	 
	 jQuery("#banner").click(function(e){
		 e.preventDefault();
		 window.location.href = "http://nl.gosupermodel.com/";
	 });
 
 });*/	
