﻿function CreateHandlers()
{
    for (var i = 0; i < document.images.length; i++)
    {
        document.images[i].onclick = PopPhoto;
        document.images[i].onmouseover = new function(){document.images[i].style.cursor='pointer';document.images[i].title = unescape(GetImageName(document.images[i]))};
    }
}
var img;
function PopPhoto(e)
{  
    var source = this.src.replace(/-thumb.jpg/i, '');

    // Preload image
    img = new Image();
    img.src = source;
    img.onload = ShowPhoto(e); // Show photo when loaded
}
function GetImageName(image)
{
    return image.src.substring(image.src.lastIndexOf('/') + 1).replace(/.jpg/ig,'').replace(/-thumb/i,'');
}
function ShowPhoto(e){
   var popWindow = GetElement('popWindow', true);
   
    popWindow.innerHTML = 
        ' <table border="0" cellpadding="0" cellspacing="0" width="100%" height="100%">'
       +'     <tr>'
       +'         <td align="center" valign="middle">'
       +'             <div style="font-weight:bold;background-color:#FFFFFF;filter:alpha(opacity=50);-moz-opacity:.50;opacity:.50;position:absolute;z-index:1000;bottom:5px;right:5px;">'
       +'                 &nbsp;' + unescape(GetImageName(img)) + '&nbsp;'
       +'             </div>'
       +'             <img id="popImage" src="' + img.src + '" border="0">'
       +'         </td>'
       +'     </tr>'
       +' </table>';
    popWindow.style.top = GetMouseY(e) + 100;
    popWindow.style.left = (GetWindowWidth()/2) - 340;
    /*
    popWindow.style.width = img.width;
    popWindow.style.height = img.height;
    */
    popWindow.style.width = 644;
    popWindow.style.height = 484;
    
    if (popWindow.style.visibility = 'hidden')
        ShowPopUp('popWindow', true, 10); 
}
function HidePhoto()
{
    var popWindow = GetElement('popWindow', true);
   
    if (popWindow.style.visibility = 'visible')
        ShowPopUp('popWindow', true);
    
}

function GetWindowWidth()
{
    if(ie4)
        return window.parent.document.body.offsetWidth;
    else
        return window.outerWidth + 12;
}

