var imgWin = null;
function sbPopupImg(imageURL,imageTitle)
{
    imageTitle = imageTitle.replace(/##/g, '\\"');
    imageTitle = imageTitle.replace(/\^\^/g, "'");
    
    if (!imgWin || imgWin.closed)
    {
        imgWin = window.open('about:blank','','resizable=yes,scrollbars=no,width=300,height=300,left=0,top=0');
    }
    if (imgWin)
    {
        with (imgWin.document)
        {
            open("text/html", "replace");
            writeln('<html><head><title>Loading...</title><style>html,body{margin:0px;padding:0px;width:100%;height:100%;}</style>');
            writeln('<sc'+'ript>');
            writeln('function resizeWnd(){if(!document.images[0].complete) {setTimeout(resizeWnd, 100);return;};');
            writeln('window.resizeTo(300,300);');
            writeln('var w=Math.max(300, 300-parseInt(document.body.clientWidth)+parseInt(document.images[0].width));');
            writeln('var h=Math.max(300, 300-parseInt(document.body.clientHeight)+parseInt(document.images[0].height));');
            writeln('window.resizeTo(w,h);');
            writeln('var t = (window.screen.height - h) / 2;');
            writeln('var l = (window.screen.width - w) / 2;');
            writeln('window.moveTo(l, t);doTitle();self.focus()}');
            writeln('function doTitle(){document.title="'+imageTitle+'";}');
            writeln('</sc'+'ript>');
            writeln('</head><body scroll="no" style="width:100%;height:100%;margin:0px;padding:0px;">');
            writeln('<table width="100%" height="100%" cellpadding="0" cellspacing="0"><tr><td align="center" valign="middle">');
            writeln('<img name="popup_img" src='+imageURL+' style="display:block" onclick="window.close();" style="cursor:hand;cursor:pointer;">');
            writeln('</td></tr></table></body>');
            writeln('<sc'+'ript>');
            writeln('resizeWnd();');
            writeln('doTitle();');
            writeln('</sc'+'ript>');
            writeln('</html>');
            close();
        }
    }
}

var div_el = null;
function sbGetAbsoluteLeft(htmlObject)
{
    var xPos = htmlObject.offsetLeft;
    var temp = htmlObject.offsetParent;

    while(temp != null)
    {
        xPos+= temp.offsetLeft;
        temp = temp.offsetParent;
    }

    return xPos;
}

function showHint(evt, el)
{
    var e = (window.event) ? window.event : evt;
    var div_els = el.getElementsByTagName('DIV');
    if (div_els)
    {
        if (div_els[0].innerHTML != '')
        {
            div_el = div_els[0];
            div_el.style.left = e.clientX + 10 + document.body.scrollLeft - sbGetAbsoluteLeft(document.getElementById("main_div"));
            div_el.style.top = e.clientY + 10 + document.body.scrollTop;
            div_el.style.display = 'block';
        }
    }
}

function hideHint(el)
{
    var div_els = el.getElementsByTagName('DIV');
    
    if (div_els)
    {
        div_els[0].style.display = 'none';
        div_el = null;
    }
}

function moveHint(evt)
{
    var e = (window.event) ? window.event : evt;

    if (div_el != null)
    {
        div_el.style.left = e.clientX + 10 + document.body.scrollLeft - sbGetAbsoluteLeft(document.getElementById("main_div"));
        div_el.style.top = e.clientY + 10 + document.body.scrollTop;
    }
}

function showDopForm(el)
{
    document.getElementById("dop_form").style.display = el.checked ? "block" : "none";
}