function addToBookmarks(id) {
    showLightbox('lb_panel',254);
    YAHOO.util.Dom.get('panel_message').innerHTML = 'Dodawanie produktu do schowka';
    YAHOO.util.Connect.asyncRequest(
    'GET',
    base + lang + '/bookmarks/addproducttobookmark/'+ id + '/quantity/1/',
    {
        success: function(r){
        }
    }
    );
    setTimeout("hideLightBox('lb_panel')",700);
}

function countBookmarkProducts() {
    YAHOO.util.Connect.asyncRequest(
    'GET',
     base + lang + '/bookmark/index/countproducts/',
    {
        success: function(r){

            var bookmarkProducts = YAHOO.lang.JSON.parse(r.responseText);

            if (document.getElementById('bookmark_quantity')) {

                if (bookmarkProducts.numberOfProducts > 0) {

                    YAHOO.util.Dom.get('bookmark_quantity').innerHTML = '&nbsp;(' + bookmarkProducts.numberOfProducts + ')';

                }else{

                    YAHOO.util.Dom.get('bookmark_quantity').innerHTML = '';

                }
            }
        }
    }
    );
}

 function book_change(id){
    var countValue = YAHOO.util.Dom.get('book_count['+id+']').value;


    var callback = {
        success : function(o){
            window.location= base + lang + '/catalog/cart/';
        }
    }
    YAHOO.util.Connect.asyncRequest(
    'GET',
    base + lang + '/bookmark/index/updateproduct/id/'+id+'/quantity/'+countValue, callback
    );

}
/**
 * usuwanie produktu
 */
function book_remove(id){

    var callback = {
        success : function(o){
            window.location= base + lang + '/catalog/cart/';
        }
    }
    YAHOO.util.Connect.asyncRequest(
    'GET',
    base + lang + '/bookmark/index/removebookmarkproduct/id/'+id, callback
    );
}

function book_minusOne(id){
    var count = YAHOO.util.Dom.get('book_count['+id+']');
    count.value = parseInt(count.value) - 1;
}

function book_plusOne(id){
    var count = YAHOO.util.Dom.get('book_count['+id+']');
    count.value = parseInt(count.value) + 1;
}

function movetocart(id){
    var callback = {
        success : function(o){
            window.location= base + lang + '/catalog/cart/';
        }
    }
    YAHOO.util.Connect.asyncRequest(
    'GET',
    base + lang + '/bookmark/index/converttocart/id/'+id, callback
    );
}

function movetobookmark(id){
    var callback = {
        success : function(o){
            window.location= base + lang + '/catalog/cart/';
        }
    }
    YAHOO.util.Connect.asyncRequest(
    'GET',
    base + lang + '/bookmark/index/converttobookmarks/id/'+id, callback
    );
}
    
function Startsend(){

    YAHOO.namespace('Sendmail');

    YAHOO.Sendmail = {

        init: function(){
            this.openPopup()
            YAHOO.util.Event.addListener('send','click', YAHOO.dialog.show, YAHOO.dialog, true);
        },
        /*
         * zdefiniowanie popupa
         */
        openPopup : function(){

            YAHOO.namespace('dialog');

            var handleSubmit = function() {

                YAHOO.Sendmail.sendRequest();
                this.cancel();

            };
            var handleCancel = function() {
                this.cancel();
            };
            YAHOO.util.Dom.setStyle("dialog1", 'display', 'block');
            YAHOO.dialog = new YAHOO.widget.Dialog("dialog1",
            { width : "300px",
                fixedcenter : true,
                visible : false,
                constraintoviewport : true,
                buttons : [ { text:"Wyślij", handler:handleSubmit, isDefault:true },
                    { text:"Zamknij", handler:handleCancel } ]
            } );

            YAHOO.dialog.render();

        },
        sendRequest : function(){
            var callback = {
                success: function(oResponse){
                    alert(oResponse.responseText);
                },
                failure: function(oResponse){
                    alert('Przeprszamy, wystąpił błąd, zgłoś awarie administratorowi.');
                }
            }
            YAHOO.util.Connect.setForm('aForm');
            YAHOO.util.Connect.asyncRequest('POST', base + lang + '/bookmark/index/senddocument', callback);
        }
    };
    YAHOO.Sendmail.init();
}
