/*
** Custom Ajax Minicart. Webopius.com 2010
*/

$(document).ready(function(){ 

	$(".cartsummary .showcartsumm").click(function() {
	  $(".cartsummary .cartitems").show();	  
	});
	$(".cartsummary").hoverIntent(
	function () {
	 $(".cartsummary .cartitems").fadeIn();
	}, 
	function () {
	   $(".cartsummary .cartitems").fadeOut();
	}) 
	nutrishowcart(0);
});

function nutrishowcart(slidedown)
{
	$.ajax({
            type: "POST",
            url: "/CUSTminicart.aspx" + "/" + "Render",
            data: "{}",
            contentType: "application/json; charset=utf-8",
            dataType: "text",
			success: function(msg) { 
				// msg2 = eval(msg);
				// Get rid of the copyright text that kills JSON
				//index = msg.indexOf('<div align="center">');
				//msg2 = msg.slice(0,index);
				msg2 = msg;
				json = eval("(" + msg2 + ")");
				$("#cartDiv").html(json.d);
				
				if (slidedown==1) {
					$(".cartsummary .cartitems").fadeIn().delay(2000).fadeOut();
				}
			},
			error:function (xhr, ajaxOptions, thrownError){
			alert("Minicart issue");
			}  		

         });

}



