function Is ()
{
        var agt = navigator.userAgent.toLowerCase();

        this.created = true;

        this.major = parseInt(navigator.appVersion);
        this.minor = parseFloat(navigator.appVersion);

        this.nav = ((agt.indexOf('mozilla')!=-1) && ((agt.indexOf('spoofer')==-1) && (agt.indexOf('compatible') == -1)));
        this.nav2 = (this.nav && (this.major == 2));
        this.nav3 = (this.nav && (this.major == 3));
        this.nav4 = (this.nav && (this.major == 4));

        //Netscape 6
        this.nav5 = (this.nav && (this.major == 5));
        this.nav6 = (this.nav && (this.major == 5));
        this.gecko = (this.nav && (this.major >= 5));

        this.ie = (agt.indexOf('msie') != -1);
        this.ie3 = (this.ie && (this.major == 3));
        this.ie4 = (this.ie && (this.major == 4));
        this.ie5 = (this.ie && (this.major == 5));

        this.opera = (agt.indexOf('opera') != -1);

        this.nav4up = this.nav && (this.major >= 4);
        this.ie4up = this.ie  && (this.major >= 4);
}

var is = new Is();
loaded = 1;

function showpic(lay)
{
        if(loaded == 0)return false;
        if(is.ie4up) document.all(lay).style.visibility = 'visible';
        else if(is.gecko) document.getElementById(lay).style.visibility = 'visible';
        // else document.layers[lay].visibility='show';
}

function hidepic(lay)
{
        if(loaded==0)return false;
        if(is.ie4up)document.all(lay).style.visibility = 'hidden';
        else if(is.gecko) document.getElementById(lay).style.visibility = 'hidden';
        // else document.layers[lay].visibility='hide';
}


function big_image(img, w, h)
{
    var lnk = '';

    var wx = (screen.width-w)/2;
    var wy = (screen.height-h)/2;

    scrwin = open("", "", "width="+ w + ", height="+ h +", toolbar=no,menubar=no,location=no,scrollbars=no,resize=no, left=" +wx+ ", top=" +wy);
    scrwin.document.open();
    scrwin.document.write("<html>\n");
    scrwin.document.write("<head>\n");
    scrwin.document.write("<title>Перемены.ру - Просмотр фото </title>\n");
    scrwin.document.write("<meta http-equiv='Content-Type' content='text/html; charset=windows-1251'>\n");
    scrwin.document.write("<style> body { margin: 0px; padding: 0px; } </style>\n");
    scrwin.document.write("</head>\n");
    scrwin.document.write("<body onclick='window.close();' oncontextmenu='return false'><table width=100% height=100%><td width=100% height=100% valign=middle align=center><img src='",img,"'></td></table></body>\n");
    scrwin.document.write("</html>\n");
    scrwin.document.close();
    scrwin.focus();
}



var isInternetExplorer = navigator.appName.indexOf("Microsoft") != -1;

// Handle all the FSCommand messages in a Flash movie.
   function loader_DoFSCommand(command, args)
   {
     var loaderObj = isInternetExplorer ? document.all.loader : document.loader;

     if (command == "popup")
     {
        popup = open(args, "displayWindow", "width=770, height=600, status=no, toolbar=no, menubar=no, resizable=0, scrollbars=1");
     }

     if (command == "popup_small")
     {
        popup = open(args, "smallWindow", "width=1024, height=768, status=no, toolbar=no, menubar=no, resizable=0, scrollbars=1");
     }

   }

// Hook for Internet Explorer.
   if (navigator.appName && navigator.appName.indexOf("Microsoft") != -1 && navigator.userAgent.indexOf("Windows") != -1 && navigator.userAgent.indexOf("Windows 3.1") == -1)
   {
     document.write('<script language=\"VBScript\"\>\n');
     document.write('On Error Resume Next\n');
     document.write('Sub loader_FSCommand(ByVal command, ByVal args)\n');
     document.write('        Call loader_DoFSCommand(command, args)\n');
     document.write('End Sub\n');
     document.write('</script\>\n');
   }


// Handle all the FSCommand messages in a Flash movie.
   function top_DoFSCommand(command, args)
   {
     var topObj = isInternetExplorer ? document.all.top : document.top;

     if (command == "popup")
     {
        popup = open(args, "displayWindow", "width=770, height=600, status=no, toolbar=no, menubar=no, resizable=0, scrollbars=1");
     }

     if (command == "popup_small")
     {
        popup = open(args, "smallWindow", "width=1024, height=768, status=no, toolbar=no, menubar=no, resizable=0, scrollbars=1");
     }

   }

// Hook for Internet Explorer.
   if (navigator.appName && navigator.appName.indexOf("Microsoft") != -1 && navigator.userAgent.indexOf("Windows") != -1 && navigator.userAgent.indexOf("Windows 3.1") == -1)
   {
     document.write('<script language=\"VBScript\"\>\n');
     document.write('On Error Resume Next\n');
     document.write('Sub top_FSCommand(ByVal command, ByVal args)\n');
     document.write('        Call top_DoFSCommand(command, args)\n');
     document.write('End Sub\n');
     document.write('</script\>\n');
   }



// Handle all the FSCommand messages in a Flash movie.
   function bottom_DoFSCommand(command, args)
   {
     var bottomObj = isInternetExplorer ? document.all.bottom : document.bottom;

     if (command == "popup")
     {
        popup = open(args, "displayWindow", "width=770, height=600, status=no, toolbar=no, menubar=no, resizable=0, scrollbars=1");
     }

     if (command == "popup_small")
     {
        popup = open(args, "smallWindow", "width=1024, height=768, status=no, toolbar=no, menubar=no, resizable=0, scrollbars=1");
     }

   }

// Hook for Internet Explorer.
   if (navigator.appName && navigator.appName.indexOf("Microsoft") != -1 && navigator.userAgent.indexOf("Windows") != -1 && navigator.userAgent.indexOf("Windows 3.1") == -1)
   {
     document.write('<script language=\"VBScript\"\>\n');
     document.write('On Error Resume Next\n');
     document.write('Sub bottom_FSCommand(ByVal command, ByVal args)\n');
     document.write('        Call bottom_DoFSCommand(command, args)\n');
     document.write('End Sub\n');
     document.write('</script\>\n');
   }


function addEvent(obj, evType, fn)
{
    if (obj.addEventListener) {
        obj.addEventListener(evType, fn, false);
        return true;
    } else if (obj.attachEvent) {
        var r = obj.attachEvent("on" + evType, fn);
        return r;
    }

    return false;
}


function getEventTarget(event)
{
    if (event.srcElement) {
        return window.event.srcElement;
    }

    return event.target;
}

function findPosX(obj)
{
    var curleft = 0;
    if (obj.offsetParent)
    {
        while (obj.offsetParent)
        {
            curleft += obj.offsetLeft
            obj = obj.offsetParent;
        }
    }
    else if (obj.x)
        curleft += obj.x;
    return curleft;
}

function findPosY(obj)
{
    var curtop = 0;
    if (obj.offsetParent)
    {
        while (obj.offsetParent)
        {
            curtop += obj.offsetTop
            obj = obj.offsetParent;
        }
    }
    else if (obj.y)
        curtop += obj.y;
    return curtop;
}



function atachPopUp()
{
   for (var i = 0; i < document.images.length; i++) {
        var img = document.images[i];

        if (img.alt && img.alt.length > 5) {
            addEvent(img, "mouseover", imgMouseOver);
            addEvent(img, "mouseout",  imgMouseOut);

            img.hint = img.alt;
            img.alt = "";
        }
   }
}

function imgMouseOver(evt)
{
    var img = getEventTarget(evt);
    var x = findPosX(img) + 5;
    var y = findPosY(img) + img.height - 40;

    var popup = document.getElementById("ipopup");

    popup.style.top  = y+"px";
    popup.style.left = x+"px";
    popup.style.zIndex = 9999;
    popup.style.display = "block";
    lnght = img.hint.length*7;
    if (lnght > 590)
    {
    	popup.style.width = "590px";
    } else {
    	popup.style.width = lnght + "px";
    }
    popup.innerHTML = img.hint;
}

function imgMouseOut(evt)
{
    document.getElementById("ipopup").style.display = "none";
}

addEvent(window, "load", atachPopUp);

