var Freizeitpilot = Freizeitpilot || {};

Freizeitpilot.favorite = function(target){
    var el = $(target);
    var id = el.id.split('-').pop();
    
    if (el.hasClassName('active')) {
        new Ajax.Request('/rpc/unstar/' + id, {
            method: 'POST',
            onSuccess: function(response) {
                    el.removeClassName('active');        
            }
        });
    } else {
        new Ajax.Request('/rpc/star/' + id, {
            method: 'POST',
            onSuccess: function(response) {
                    el.addClassName('active');        
            }
        });        
    }
};

Freizeitpilot.mask = function(target){
    var el = new Element('div');
    var offset = target.cumulativeOffset();
    var dimensions = target.getDimensions();
    el.setStyle({
        position: 'absolute',    
        left: offset.left + 'px',
        top: offset.top + 'px',
        width: dimensions.width + 'px',
        height: dimensions.height + 'px',
        backgroundColor: '#ffffff',
        opacity:.5
    });
    document.body.appendChild(el);
    el.hide();
    return el;  
};



