function balloon_init() {
    if (_balloon.x == null || _balloon.y == null) {
        $('balloon').style.top = '100px';
        $('balloon').style.left = '600px';
    } else {
        $('balloon').style.top = _balloon.y + 'px';
        $('balloon').style.left = _balloon.x + 'px';
    }
    
    new Ajax.Updater('balloon_content',
                     _siteWebroot + 'Balloon/msg/tour_de/start',
                     {
                        onLoading: function() { new Effect.Appear('balloon'); },
                        evalScripts: true
                     });
}

/*var _balloon_marker_old_elm;
var _balloon_marker_old_border;

function balloon_mark_element(elm) {
    if (elm.length >= 1) {
        elm = elm[0];
    }

    if(_balloon_marker_old_elm) {
        _balloon_marker_old_elm.style.border = _balloon_marker_old_border; 
    }
    if(elm) {
        _balloon_marker_old_elm = elm;
        _balloon_marker_old_border = elm.style.border;
        elm.focus();
        elm.style.border = '2px solid YellowGreen';
    }
}*/

function balloon_mark_element(elm, type) {
    if (elm.length >= 1) {
        elm = elm[0];
    }
    
    $('balloon_marker').innerHTML = '';
    
    if (type == 'arrow_left') {
        var myMarkerImage = document.createElement("img");
        myMarkerImage.src = _siteWebroot + 'img/arrow.left.png';
        $('balloon_marker').appendChild(myMarkerImage);
        
        $('balloon_marker').style.top = (elm.viewportOffset().top + elm.getHeight()/2 - $('balloon_marker').getHeight()/2) + 'px';
        $('balloon_marker').style.left = (elm.viewportOffset().left + elm.getWidth()) + 'px';
    
        $('balloon_marker').show();
        $('balloon_marker').pulsate(); 
    } else {
        /*
        $('balloon_marker').style.top = elm.viewportOffset().top + 'px';
        $('balloon_marker').style.left = (elm.viewportOffset().left - 2) + 'px'; 
        $('balloon_marker').style.width = elm.getWidth() + 'px';
        $('balloon_marker').style.height = (elm.getHeight() - 2) + 'px';
        $('balloon_marker').style.border = '2px solid YellowGreen'; 
        
        $('balloon_marker').show();
        
        _balloon_marked_element = elm;
        $('balloon_marker').observe('click', function(event) {
            $('balloon_marker').hide();
            _balloon_marked_element.fire('click');
        });
        */
    }
}                    

function balloon_savePosition() {
    new Ajax.Request(_siteWebroot + 'Balloon/savePosition/' + $('balloon').style.left.replace(/px/g, '') + '/' + $('balloon').style.top.replace(/px/g, ''));
}

function balloon_loading() {
    $('balloon_marker').hide();
    $('balloon_content').innerHTML = '<i>lade...</i>';
}

//window.setTimeout('balloon_init()', 100);