$(document).ready( function(){
	var standard_submit = true;
	
	/*
	 * Watch for clicks on 'add_to_basket' cells
	 * 
	 *  get the relevant values & su
	 */
	$('.addToBasket input').click(function(evt){
     var xy=$(evt.target).position();
     var msg=$('<p class="addToBasketTxt">Added to basket</p>').css({textAlign:'center',position:'absolute',top:(xy.top-$(this).outerHeight())+5,left:(xy.left+$(evt.target).outerWidth())-5}).appendTo(document.body);
      var t=setTimeout(function(){$(msg).fadeOut('slow',function(){$(this).remove();});},2000);
       
	  
	  
		standard_submit = false;
		var id = $(this).val();
		var qty = $(this).parent('td').prev('td.qty').children('input').val();
		var add_product = [];
		$(this).parent("td").children('input[name="additional_product[]"]').each( function(i){ 
			add_product.push( $(this).val() ); 
			} )
		$.post('marquees_cart.php?action=add_product',
			{add_quantity: qty,
			 products_id: id,
		     "additional_product[]": add_product, 
			 basket_method: 'ajax'},
			 function(data)
			 {
				$('.windowContentCart').html( data )	//affects this class
			 	
			 }
		);	
		return false;
	})
	
	/*
	 *  Prevent the form from submitting normally
	 *  if javascript is enabled.
	 *  Degrades gracefully if no js
	 */	
    $("form").submit(function(e) 
	{	
        if ( standard_submit ) 
		{              
          return true;
        }
        else 
		{
        	return false;            
        }
		});	
	
})	

