var timer;
var ua = navigator.userAgent.toLowerCase();
var isOpera = (ua.indexOf('opera')  > -1);
var isIE = (!isOpera && ua.indexOf('msie') > -1);

function getDocumentHeight() {
  return Math.max(document.compatMode != 'CSS1Compat' ? document.body.scrollHeight : document.documentElement.scrollHeight, getViewportHeight());
}

function getViewportHeight() {
  return ((document.compatMode || isIE) && !isOpera) ? (document.compatMode == 'CSS1Compat') ? document.documentElement.clientHeight : document.body.clientHeight : (document.parentWindow || document.defaultView).innerHeight;
}

function Xoffset()
{
    var x = 0;
    if (typeof( window.pageYOffset ) == 'number')
    { 
        x = window.pageXOffset; //Netscape 
    } else if (document.body && ( document.body.scrollLeft || document.body.scrollTop ))
    { 
        x = document.body.scrollLeft; //DOM 
    } else if (document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ))
    { 
        x = document.documentElement.scrollLeft; //IE 
    }
    return x;
}

function Yoffset()
{
    var y = 0;
    if (typeof( window.pageYOffset ) == 'number')
    { 
        y = window.pageYOffset; //Netscape 
    } else if (document.body && ( document.body.scrollLeft || document.body.scrollTop ))
    { 
        y = document.body.scrollTop; //DOM 
    } else if (document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ))
    { 
        y = document.documentElement.scrollTop; //IE 
    }
    return y;
}

function SetVisible(i,w,h,img_path) {
    var e=document.getElementById('magnifier');
    e.style.position="absolute";
    rows=Math.floor((i-(PhPage-1)*PhotosLimit)/3);
    cols=(i-(PhPage-1)*PhotosLimit)%3;
    if (getDocumentHeight()<(230+Xoffset()))
    {
        e.style.left=143+(cols*189);
    } else {
        e.style.left=237+(cols*189);
    }
    if (getDocumentHeight()<(230+Xoffset()))
    {
        e.style.top=10+(rows*290);
    } else {
        e.style.top=210+(rows*290);
    }
    e.style.width=w;
    e.style.height=h;
    e.style.zIndex=1;
    e.innerHTML='<img src="'+img_path+'">';
    e.style.visibility="visible";
}

function ShowDiv(i,w,h,img_path) {
    timer=setTimeout("SetVisible("+i+","+w+","+h+",'"+img_path+"')",2000);
}

function HideDiv() {
    document.getElementById('magnifier').style.visibility="hidden";
    clearTimeout(timer);
}

function SetVisible2() {

    var e=document.getElementById('magnifier');
    e.style.visibility="visible";
}

