function ajaxAddToBasket(formId,prodId)
{
	var jQAForm = jQuery('#'+formId);
	
	if (jQAForm.children("input[name='bAjaxaddtobasket']").length==0)
	{
		var bAjaxElement='<input type="hidden" name="bAjaxaddtobasket" id="bAjaxaddtobasket" value="true"/>';
    	jQuery(bAjaxElement).appendTo(jQAForm);
	}
	
	jQAForm.ajaxSubmit({
		success: function(data){
    		data=parseJSON(data);
    		if (data['message']=='addedtobasket')
    		{    			
    			var item_desc=data['item_total']>1?' Items':' Item';
    			
    			jQuery("#messages_product_view .messages").hide(); //supressing error message (if any)
    			
    			//Filling up data
    			jQuery(".total").html(data['grand_total']);
    			jQuery(".item_total").html(data['item_total'] + item_desc);
    			jQuery("#BasketConfirmationBox .ajax_product_image").attr("src",jQuery('#ajax_product_image_' + prodId).val());
    			jQuery("#BasketConfirmationBox .ajax_product_image").attr("alt",jQuery('#ajax_product_name_' + prodId).val());
    			jQuery("#BasketConfirmationBox .ajax_product_name").attr("innerHTML",jQuery('#ajax_product_name_' + prodId).val());
    			jQuery("#BasketConfirmationBox .ajax_product_price").attr("innerHTML",jQuery('#price-box-'+prodId).html());

    			// adding additional info to the mini-basket
    			var sOption1 = jQuery("#product-options-wrapper td.option_data img[src$='selected.jpg']").attr('alt');
    			var sOption2 = jQuery("#product-options-wrapper td.option_data img[src$='selected.jpg']").attr('title');
    			var sStyleno = jQuery(".product-shop div.styleno").html();
    			var sQty = jQuery("input#qty").attr('value');
    			jQuery("#BasketConfirmationBox .ajax_product_styleno").html(sStyleno);
    			jQuery("#BasketConfirmationBox .ajax_product_size").html("Size: " + sOption2);
    			jQuery("#BasketConfirmationBox .ajax_product_color").html("Colour: " + sOption1);
    			jQuery("#BasketConfirmationBox .ajax_product_qty").html("Qty: " + sQty);
    			
    			jQuery('#BasketConfirmationBox').css('top', (jQuery(window).scrollTop()+40) + 'px');
		    	jQuery('#BasketConfirmationBox').hide().slideDown(500,function (){
		      		var timer = self.setTimeout(function() {fnSlideUp('BasketConfirmationBox')}, 10000);
				});
    		}
    		else
    		{
    			if (data['url'].length>0 && formId.indexOf('product')<0)
    			{
    				window.location.href=data['url'];
    			}
    			else
    			{
    				alert(data['message']);	
    			}
    		}		
		}
    });
}
function fnSlideUp(sID)
{
	jQuery('#'+sID).slideUp('slow')
}
function parseJSON(str){
	return  eval('('+str+')');;
}
