﻿//overlay function
$(function() {
    // if the function argument is given to overlay, it is assumed to be the onBeforeLoad event listener

    CreateOverlay();

    var api = $("a[rel]").overlay({ api: true });
    // define function that opens the overlay    
    window.openOverlay = function() {
        api.load();
    }

    //close overlay function
    $("#ContinueShopping").click(function() {
        api.close();
    });

    

});

function CreateOverlay() {
    $("a[rel]").overlay({

        onBeforeLoad: function() {
            // grab wrapper element inside content
            var wrap = this.getContent().find("div.wrap");

            // load only for the first time it is opened
            wrap.load(this.getTrigger().attr("href"));
        },

        onClose: function() {
            updatePanel();
        }

    });
}

function BuyProduct() {
    Sys.WebForms.PageRequestManager.getInstance().add_pageLoaded(pageLoaded);
}

function pageLoaded(sender, args) {
    openOverlay();
    $("ul.tabs").tabs("div.panes > div");
    $("ul.tabs-big").tabs("div.panes-big > div");
    CreateOverlay();
    Sys.WebForms.PageRequestManager.getInstance().remove_pageLoaded(pageLoaded);
}
