jQuery(document).ready(function() {

    jQuery('.buy_product').each(function() {

        var $link = jQuery(this);
        var $width = (jQuery('.emp').length) ? 467 : 980;

        var $dialog = jQuery('<div></div>');
        
        jQuery.ajax({
            url: $link.attr('href'),
            success: function(a, b, c){            
                //                alert(a.length);
                $dialog.html(a).dialog({
                    autoOpen: false,
                    buttons: {
                        Fermer: function() {
														jQuery('object').css('display','inline');
                            jQuery(this).dialog('close');
                        }
                    },
                    dialogClass: 'toto',
                    title: $link.attr('title'),
                    modal: true,
                    resizable: false,
                    width: $width
                });
                $link.click(function() {
										jQuery('object').css('display','none');
                    $dialog.dialog('open');
                    return false;
                });
            },
            error: function (a, b, c){
                alert(c);
            }
        }); 

    });

});
//function showModalBoxSurlayer(html, width, height, scroll)
//{
//    if (scroll == undefined)
//        scroll = true;
//    if (!height)
//        height = 630;
//    if (!width)
//        width =  '997';
//        //width =  '500';
//    var div = new Element('div', {
//        'id': 'mb_wrapper'
//    }).update(html);
//    var divStyles = {
//        //maxHeight: (document.viewport.getHeight() - 70) + 'px'
//        maxHeight: height+'px'
//    };
//    if (scroll)
//        divStyles.overflowY = 'scroll';
//    div.setStyle(divStyles);
//    Modalbox.show(div, {
//        title: "",
//        overlayClose: false,
//        transitions: false,
//        autoFocusing: false,
//        overlayOpacity: .3,
//        width: 900
//    });
//    var leftCenter = Math.round(document.viewport.getWidth() / 2) - width / 2; //450 => width / 2 by sa
//    $("MB_window").setStyle({
//        marginTop: "40px",
//        width: width+"px",
//        minWidth: width+"px",
//        height: height+"px",
//        left: leftCenter + 'px'
//    });
//    var header = $('MB_header');
//    header.setStyle({
//        backgroundColor: '#DDDDDD'
//    });
//    header.show();
//}
//
//function initBuyProduct()
//{
//    $$(".buy_product").each(function (link) {
//        link.observe("click", function(event) {
//            event.stop();
//            new Ajax.Request(link.href, {
//                method: 'get',
//                onSuccess: function(transport) {
//                    showModalBoxSurlayer(transport.responseText);
//                }
//            });
//        });
//    });
//    $$(".buy_product_emp").each(function (link) {
//        link.observe("click", function(event) {
//            event.stop();
//            new Ajax.Request(link.href, {
//                method: 'get',
//                onSuccess: function(transport) {
//                    showModalBoxSurlayer(transport.responseText, 467);
//                }
//            });
//        });
//    });
//    $$(".buy_product_sal").each(function (link) {
//        link.observe("click", function(event) {
//            event.stop();
//            new Ajax.Request(link.href, {
//                method: 'get',
//                onSuccess: function(transport) {
//                    showModalBoxSurlayer(transport.responseText, 500, 480, false);
//                }
//            });
//        });
//    });
//}
//
//function initSurLayer() {
//    initBuyProduct();
//}
//
//document.observe("dom:loaded", initSurLayer);

