var $j = jQuery.noConflict();
$j(document).ready(function () {
    render_cart_header("CartItemsLBGet", "CartTotalLBGet");
    (getElementByID_Master("CartItemsLBGet").innerHTML == "1") ? getElementByID_Master("CartLiteralSgl").style.display = "inline" : getElementByID_Master("CartLiteralPlural").style.display = "inline";
    setBackground();
    RefreshCart();

    if (location.pathname == "/store/os/shoppingcart.aspx") {
        $j('.CartColumnHeaderFooterNoTopBorder a').attr('href', 'javascript:void(0)');
        $j('.CartColumnHeaderFooterNoTopBorder a').attr('onclick', '');
        $j('.CartColumnHeaderFooterNoTopBorder a').click(function () {
            window.open('/returns.aspx', '', 'scrollbars=yes,width=850,height=650');
        });
    }
});

function RefreshCart() {
    $j.ajax({
        url: '/store/MiniCart.aspx',
        cache: false,
        success: function (html) {
            $j('.mini-cart').html(html);
        }
    });
}

function setBackground() {
    if (location.pathname == "/") {
        $j(document).bgStretcher({
        	images: ['/layout/images/home/homebg_1.jpg', '/layout/images/home/homebg_2.jpg', '/layout/images/home/homebg_3.jpg', '/layout/images/home/homebg_4.jpg'],
            imageWidth: 1258, imageHeight: 891
        });
    } else {
        $j(document).bgStretcher({
            images: ['/layout/images/bg/body-bg-2.jpg'],
            imageWidth: 1258, imageHeight: 891
        });	
    }
}

function RemoveItem(recid, qty) {
    var url = '/store/removeminicartitem.aspx?recid=' + recid;
    $j('.mini-cart').animate({ opacity: 0.40 }, 500);
    $j.ajax({
        url: url,
        cache: false,
        success: function (data) {
            setTimeout(function () { RefreshCart(); }, 500);
            render_cart_header("CartItemsLBGet", "CartTotalLBGet");
            (getElementByID_Master("CartItemsLBGet").innerHTML == "1") ? getElementByID_Master("CartLiteralSgl").style.display = "inline" : getElementByID_Master("CartLiteralPlural").style.display = "inline";
            $j(".mini-cart").animate({ opacity: 1 }, 500);
        },
        error: function (err) {
            return false;
        }
    });
}
