﻿// hoover lightbox

var _hooverLightbox = null;
var _hooverInner = null;

function hooverLightbox(imgUrl, caption) {
    
    if(_hooverLightbox == null && _hooverInner == null) {
        _initializeLightbox();
    }
    
    if(imgUrl == null && caption == null)
    {
        _hooverLightbox.style.display = 'none';
        _hooverInner.style.display = 'none';
        return false;
    }
    
    _hooverInner.innerHTML = '<img src="' + imgUrl + '" />';
    
    _hooverInner.style.left = '50%';
    _hooverInner.style.top = '50%';
    
    _hooverInner.style.marginLeft = '-' + (_hooverInner.getWidth() / 2 ) + 'px';
    _hooverInner.style.marginTop = '-' + (_hooverInner.getHeight() / 2 ) + 'px';
    
    _bottomCaption = '<br />';
    /*_bottomCaption += '<table width="' + _hooverInner.getWidth() + '" style="border-top:solid 1px #ccc;"><tr>';*/
    _bottomCaption += '<table style="border-top:solid 1px #ccc;"><tr>';
    _bottomCaption += '<td style="width: 90%; padding-top:10px;"><strong>' + caption + '</strong></td>';
    _bottomCaption += '<td style="width:50px; text-align: center">';
    _bottomCaption += '<a href="javascript:void(0)" onclick="return hooverLightbox(null,null)">Close<br />Window</a></td></tr></table>';
    
    _hooverInner.innerHTML += _bottomCaption;
    
    _hooverLightbox.style.display = 'block';
    _hooverInner.style.display = 'block';
    
    return false;
}

function _initializeLightbox() {
    
    _hooverLightbox = $('__hooverLightbox');
    _hooverLightbox.style.width = '100%';
    _hooverLightbox.style.height = '100%';
    _hooverLightbox.style.position = 'fixed';
    _hooverLightbox.style.left = '0px';
    _hooverLightbox.style.top = '0px';
    _hooverLightbox.style.background = 'black';
    _hooverLightbox.style.zIndex = '10000';
    _hooverLightbox.style.display = 'none';
    
    _hooverInner = $('__hooverInner');
    _hooverInner.style.position = 'fixed';
    _hooverInner.style.zIndex = '10001';
    _hooverInner.style.display = 'none';
    
}

function hooverFrame(url) {

    if(_hooverLightbox == null && _hooverInner == null) {
        _initializeLightbox();
    }
    
    var _html = '<iframe src="' + url + '" id="_hooverRequestFrame" style="width:600px;height:500px;border:0px"';
    _html += ' frameborder="0"></iframe>';
    
    _hooverInner.innerHTML = _html;
    
    _hooverInner.style.left = '50%';
    _hooverInner.style.top = '50%';
    
    _hooverInner.style.marginLeft = '-' + (_hooverInner.getWidth() / 2 ) + 'px';
    _hooverInner.style.marginTop = '-' + (_hooverInner.getHeight() / 2 ) + 'px';
    
    _hooverLightbox.style.display = 'block';
    _hooverInner.style.display = 'block';
    
    return false;
}

function closeHoverFrame(refresh) 
{
    _hooverLightbox.style.display = 'none';
    _hooverInner.style.display = 'none';
    
    if(refresh == true)
    {
        history.go(0);
    }
}