var hint = null;
var hintText = '<h1>Seite befindet sich noch im Aufbau</h1>';
var currentKeypressObserver = null;
var hintStyle = {
    color:           '#FFFFFF',
    backgroundColor: '#B13D20',
    border:          '1px solid white',
    padding:         '5px',
    margin:          '0px'
};
var hintCloseButton = {
    path:   '/images/layout/close.gif',
    width:  17,
    height: 17
};
function showHint() {
    
    if(!hint) {
        createHint();
    }
    
    var body = $(document.body);
    body.block({
        color: '#888888',
        opacity: .75
    });
    
    // FIX: Footer wir in body.height nicht berücksichtigt
    var winHeight = window.innerHeight
        || document.documentElement.clientHeight
        || document.body.clientHeight;
    
    var minHeight = (winHeight > $(document.body).getHeight()) ? winHeight: $(document.body).getHeight();
    
    body.blocker.setStyle( {
        'height': minHeight + 'px'
    });
    
    // "Esc" schließt Popup
    currentKeypressObserver = function(event) { event.keyCode == 27 && hideHint(); }; 
    Event.observe(document, 'keypress', currentKeypressObserver);
        
    hint.centerOnScreen();
    hint.show();
    
}
function hideHint() {
    hint.hide(); 
    $(document.body).unblock();
            
    if(currentKeypressObserver != null) {
        Event.stopObserving(document, 'keypress', currentKeypressObserver);
        currentKeypressObserver = null;
    }
}
    
function createHint() {
    
    new Insertion.Top(
        document.body, 
        '<div id="hint" style="position: absolute; display: none; text-align: right">' + 
          'Schließen&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<image id="hint_close_button" src="'+hintCloseButton.path+'" ' +
                  'width="'+hintCloseButton.width+'" ' +
                  'height="'+hintCloseButton.height+'" />' +
          hintText +
        '</div>'
    );
    hint = $('hint');
    closeButton = $('hint_close_button')
    
    hint.style.zIndex = 5001;
    hint.setStyle(hintStyle);
    
    closeButton.setStyle({
        cursor: 'pointer',
        position: 'absolute',
        top: '5px',
        right: '5px'
    });
    
    closeButton.onclick = hideHint
}