var dimLayer;
var contentLayer;


function initialisiereLightbox() {
    myshopClass = document.createElement("div")
    myshopClass.setAttribute("class", "tx_myshop");

    dimLayer = document.createElement("div")
    dimLayer.setAttribute("style", "display: none; position: absolute;");
    dimLayer.setAttribute("class", "dimLayer");
    dimLayer.setAttribute("id", "dimLayer");
    dimLayer.setAttribute("onclick", "hideLightbox();");

    contentLayer = document.createElement("div")
    contentLayer.setAttribute("style", "display: none;")
    contentLayer.setAttribute("class", "contentLayer");
    contentLayer.setAttribute("id", "contentLayer")


    myshopClass.appendChild(dimLayer)
    myshopClass.appendChild(contentLayer)
    document.getElementsByTagName("body")[0].appendChild(myshopClass)
}

function hideLightbox() {
    $('dimLayer').hide();
    $('contentLayer').hide();
}

function showLightbox(articelnumber) {

    ajax = new Ajax.Updater('contentLayer', 'index.php', {
        parameters: {   eID: 'myshop_singleview',
                        an: articelnumber
                    }
    });



    $('dimLayer').setStyle("height: " + $$('body')[0].getHeight() + "px");
    $('dimLayer').show();
    

    //$('contentLayer').setStyle("top: " + document.viewport.getScrollOffsets()['top'] + "px");
    $('contentLayer').setStyle("margin-left: -" + ($('contentLayer').getWidth() / 2) + "px");
    $('contentLayer').show();

}

function addToBasket(articelnumber) {
        var quantity = 0;
        var attribute1 = 0;
        var attribute2 = 0;

        if($('tx_myshop_quantity_' + articelnumber)) {
            quantity = $('tx_myshop_quantity_' + articelnumber).getValue();
        }

        if($('tx_myshop_attributes_1_' + articelnumber)) {
            attribute1 = $('tx_myshop_attributes_1_' + articelnumber).getValue();
        }

        if($('tx_myshop_attributes_2_' + articelnumber)) {
            attribute2 = $('tx_myshop_attributes_2_' + articelnumber).getValue();
        }

        
        ajax = new Ajax.Updater('tx_myshop_smallBasket', 'index.php', {
        parameters: {   eID: 'myshop_basket',
                        view: 'smallBasket',
                        action: 'add',
                        an: articelnumber,
                        at1: attribute1,
                        at2: attribute2,
                        qu: quantity
                    }
        });
}

function addToBasketSingleView(articelnumber) {
        var quantity = 0;
        var attribute1 = 0;
        var attribute2 = 0;

        if($('tx_myshop_singleview_quantity_' + articelnumber)) {
            quantity = $('tx_myshop_singleview_quantity_' + articelnumber).getValue();
        }

        if($('tx_myshop_singleview_attributes_1_' + articelnumber)) {
            attribute1 = $('tx_myshop_singleview_attributes_1_' + articelnumber).getValue();
        }

        if($('tx_myshop_singleview_attributes_2_' + articelnumber)) {
            attribute2 = $('tx_myshop_singleview_attributes_2_' + articelnumber).getValue();
        }


        ajax = new Ajax.Updater('tx_myshop_smallBasket', 'index.php', {
        parameters: {   eID: 'myshop_basket',
                        view: 'smallBasket',
                        action: 'add',
                        an: articelnumber,
                        at1: attribute1,
                        at2: attribute2,
                        qu: quantity
                    }
        });
}


function showSmallBasket() {
        ajax = new Ajax.Updater('tx_myshop_smallBasket', 'index.php', {
        parameters: {   eID: 'myshop_basket',
                        view: 'smallBasket',
                        action: 'show'
                    }
        });
}





