function insertadd2cart(id)
{
	$("#message").html('<div class="ui-widget"><div style="padding: 0 .7em;" class="ui-state-highlight ui-corner-all"><p><img src="images/load.gif" valign="middle" width="32" height="32" alt="loading" title="loading" border="0" style="vertical-align: middle;" /> Adding to cart.. </p></div></div>').fadeIn();
	var url="products_new.php?action=buy_now&products_id="+id;
 	
	$.get(url, function(d){
		 var item_count = parseInt($("#cart_count").val());
		 item_count++; 
		 $("#cart_count").val(item_count);
		 $("#cnttxt").html(item_count);
		 setTimeout('success()', 3000);
	});
}

function success(){
	$("#message").html("<div class='ui-widget'><div style='padding: 0 .7em;' class='ui-state-highlight ui-corner-all'><p>Item added to cart.</p></div></div>").fadeOut(5000);
}

$(document).ready(function(){
	
	$(".vertsubmenu").each(function(){
		
		id = $(this).attr('id');
		$(this).appendTo("#ref"+id);//.removeClass("vertsubmenu");
		
		$(this).live('click',function(){
			return false;
		});		
	});	
	
		$("#catmenu").accordion({ header: ".accheader",active: false}).bind( "accordionchange", function(event, ui) {
				var c = $(this).find('.ui-state-active').next('div').attr('id');
				var s = $(this).find('.ui-state-active').attr('href');
				s = s.replace(/\D/g, '');

				$("#"+c).html('');
				$("#"+c).load('./products.php?p='+s, function(){ $("#"+c).css('height','auto');} );
		});
	
	$('.subitem').live('click', function(e){ e.preventDefault(); var id = $(this).attr('id'); dopreview(id); });
	
});

function dopreview(pid)
{
	pid = pid.replace('p', '');
	$('.grid_18').html('Loading...');
	$('.grid_18').load('preview.php?id='+pid);
	return false;
}
