var detail_popup = {
    
    loadContent : function (url, event_id, target_div) {
      var Target = $(target_div);
      
      new Ajax.Request(url, {
        method: 'POST',
        parameters : {
            'id' : event_id
        },
        onSuccess: function(transport) {
            Target.update(transport.responseText);
            var main_height = 'display:block; height:' + $('main').getStyle('height');
            $('grey').setStyle(main_height);
            lightwindowInit();
        }
      });
    },

    scrollen : function (speed) {
       if (weiter==1)
       {
           objekt=document.getElementById('scroll_container');
           //objekt.scrollTop=objekt.scrollHeight;
           if (speed==2) {
               y = objekt.scrollLeft+2;
               objekt.scrollLeft=y;
               if ((weiter)&&(y<objekt.scrollWidth))
                setTimeout("scrollen("+speed+")",1); 
           }
           if (speed==-2 && objekt.scrollLeft>0) {
               y=objekt.scrollLeft-2;
               objekt.scrollLeft=y;
               if ((weiter)&&(y>0)) setTimeout("scrollen("+speed+")",1);
           }
       }
    },

    show : function (event_id) {
        detail_popup.loadContent('/modules/tort_information_connect/tort_detail_proxy.php', event_id, 'ajax_content');
        $('grey').show();
        $('ajax_content').show();
        
        $('ajax_content').setStyle({
            'top' : (($('tort_information_link_'+event_id).positionedOffset()[1])-($('ajax_content').getHeight()/2)).round()+'px'
        }).scrollTo();

    },

    init_divs : function(){
        divs = '<div id="grey" style="display:none; z-index:100; width:100%; filter:alpha(opacity=60); opacity: 0.6; height:100%; position:absolute; left:0px; top:0px; background-color:#000;">&nbsp;</div>';
        divs += '<div id="ajax_content" style="z-index:101; position:absolute; left:0px; top:0px; width:100%;"></div>';
        $('body').insert( {
            bottom : divs
        } );
        
    },

    hide : function () {
      $('ajax_content').hide();
      $('grey').hide();
    }

}

document.observe("dom:loaded", function() {
    detail_popup.init_divs();
});
