$(function(){  
    var options = { path: '/', expires: 1};
    var site_id = $.jqURL.get('site');
    var cookie_name = "IT-MS-CART-" + site_id; 
    
    if ($.cookie(cookie_name) > 0)
    {
        $("div#shopping-cart a").text("View your shopping cart (" + $.cookie(cookie_name) + ")");
    }
    
    
    $(".buy").click(function() {
        var productID = $.jqURL.get('id');
        $.post("http://www.itgovernance.co.uk/add_basket.aspx", {product_id: productID, qty:1 },hideAndShow());
    });    

function hideAndShow() {
    var i = $.cookie(cookie_name);
    if (i == null) {i = 0;}
    i = eval(i + "+1");
    var puralItems = "item"; 
    if (i > 1) 
    {
        puralItems = "items";
    }
    $("div#shopping-cart a").text("View your shopping cart (" + i + ")");
    $.cookie(cookie_name, i, options);
    $("a.buy").slideUp();
    $("#ajaxText").html("<p>Item added to your basket - you now have "+ i + " " + puralItems + " in your basket <a href='http://www.itgovernance.co.uk/isapi/isapi.dll?order'>click here to checkout now!</p>  This will be added to your Shopping Cart on IT Governance</a>"); 
    $("div#shopping-cart").css("font-size", "1.3em").effect("pulsate", { times: 3 }, 1000);
    };  
});