function sendAjaxCartStatus(status) {
    viewParams = new Array();
    viewParams[0] = status;
    fetchAjax('cart', 'mode', '', '', '', null, 'p', 'HTML', 0, null, null, viewParams);
}

window.addEvent('domready', function() {
    
//    var size = $('itemBox').measure(function(){
//            return this.getSize();
//        });       //BUG: Trouble with measure and IE8 (mootools update)
    var size;
    size = $('itemBox').getSize();

    var fixit = false;
    $('einkaufszettel').addEvent('mousedown', function() {
        fixit = !(fixit);
        if(fixit == true){
            $('fixit').setStyle('display', 'block');
            sendAjaxCartStatus('on');
        }else{
            $('fixit').setStyle('display', 'none');
            sendAjaxCartStatus('off');
        }
    });

 
    // expand
    $('einkaufszettel').addEvent('mouseenter', function() {
 
	var fx_tween = new Fx.Tween($('shoppinglist'), {
            duration: 950,
            transition: 'bounce:out'
        });

        var fx_bottom_tween = new Fx.Tween($('shoppinglist_bottom'), {
            duration: 950,
            transition: 'bounce:out'
        });
        if(fixit != true){
            fx_tween.pause();
            fx_tween.start('height', [66, size.y + 140]);
            fx_bottom_tween.start('height', [28, 0]);
        }
        
    });


    // close
    $('einkaufszettel').addEvent('mouseleave', function() {
        //$('shoppinglist_closed').setStyle('display', 'block');

        var fx_tween = new Fx.Tween($('shoppinglist'), {
            duration: 950,
            transition: 'bounce:out'
        });
        var fx_bottom_tween = new Fx.Tween($('shoppinglist_bottom'), {
            duration: 950,
            transition: 'bounce:out'
        });
        if(fixit != true){
            fx_tween.pause();
            fx_tween.start('height', [size.y + 140, 66]);
            fx_bottom_tween.start('height', [0, 28]);
        }
    });


    if($('cartvisible').get('html') == 'false') {
        $('einkaufszettel').fireEvent('mouseleave');
    }else{
        $('einkaufszettel').fireEvent('mouseenter');
        fixit = false;
        $('einkaufszettel').fireEvent('mousedown');
    }
    
 
});
