jQuery(function($){
    if(jQuery('#mobilehome').length > 0) {

        var r = Raphael('mobilehome',720, 495);
        r.safari();
        var _label = r.popup(50, 50, "").hide();
        attributes = {
            'fill' : '#000000',
            'fill-opacity': 0,
            'stroke': 'none',
            'cursor': 'pointer',
            'stroke-linejoin': 'round'
        },
        arr = new Array();

        for (var mobjects in mopaths) {
            var obj = r.path(mopaths[mobjects].path);
            arr[obj.id] = mobjects;
            obj.attr(attributes);
            obj
            .hover(function(){
                this.animate({
                    'fill-opacity': 0.8
                }, 200);
                bbox = this.getBBox();
                //console.log("Y:" + _label.items[1].attrs.y + " - X:" + _label.items[1].attrs.x + " - PATH:" + _label.items[1].attrs.path);
                switch(mopaths[arr[this.id]].slug) {
                    case 'PRESS' :
                        _label.attr({
                            text: mopaths[arr[this.id]].name
                            }).update(bbox.x + bbox.width/2.8, bbox.y + bbox.height/1.2, bbox.width).toFront().show();
                        break;
                    default :
                        _label.attr({
                            text: mopaths[arr[this.id]].name
                            }).update(bbox.x, bbox.y + bbox.height/2, bbox.width).toFront().show();
                        break;
                }
            }, function(){
                this.animate({
                    'fill-opacity': 0
                }, 200);
                _label.hide();
            })
            .click(function(){
                location.href = mopaths[arr[this.id]].url;
            })
        }
    }
});

jQuery.expr[':'].raph=function
    (objNode,intStackIndex,arrProperties,arrNodeStack){
        var c=objNode.getAttribute('class');
        return(c&&c.indexOf(arrProperties[3])!=-1);
    }
