var OpenedArr = new Array(4);
var WinWidtht = (screen.availWidth/2)-6;
var WinHeight = (screen.availHeight/2)-24;

function OpenPopup(title,name, resizible, bscroll)
{
if (resizible=="undefined") resizible=0;
if (bscroll=="undefined") bscroll=0;
var EmptyFrame;
var OpenedCount=-1;

for(var i=0; i<4;i++)
{
        if(""+OpenedArr[i]!="undefined")
            {
                if (!(OpenedArr[i].closed))
                {
                    if (OpenedArr[i].name == name) {OpenedCount=i; break;}
                }
            }

}
if (OpenedCount==-1)
{
    for(var i=0; i<4;i++)
    {

        var isClosed=false;
        if(""+OpenedArr[i]=="undefined")
            {
                isClosed = true;
            }
        else
            {
                if(OpenedArr[i].closed) isClosed = true;
            }

        if (isClosed) {OpenedCount = i; break;}
    }
}
if (OpenedCount == -1) return;


WinPart = 0;
if((OpenedCount+1)%2 == 0) WinPart = 1;

var WinLeft = (screen.availWidth/2) * WinPart;
var WinTop = 0;
if(OpenedCount>1) WinTop = (screen.availHeight/2);

OpenedArr[OpenedCount] = open(title,name, "location=0, menubar=0, resizable="+resizible+", scrollbars="+bscroll+", status=0, titlebar=1, toolbar=0, top="+WinTop+", left="+WinLeft+", width="+WinWidtht+", height="+WinHeight);
OpenedArr[OpenedCount].focus();


}

function opnewWin (s)
{winank = window.open ("./opros/opros.php", s, "width=440 height=670")
}

//Detecting the browser type
var isNetscape = (navigator.appName == "Netscape");
var isMacIE = ( (navigator.userAgent.indexOf("IE 4")  > -1) && (navigator.userAgent.indexOf("Mac")  > -1) );
var layerRef = (isNetscape) ? "document" : "document.all";
var styleRef = (isNetscape) ? "" : ".style";
var DHTML_Enabled = ( (document.layers || document.all) && !isMacIE );

// To hide from old browsers generate the menu
// dynamically, invisible at the beginning
function MenuCall(Content, Width, BackgrColor, MenuNumber)
  {
      MenuID=MenuNumber;
      WidthMenu=Width;
      Color=BackgrColor;

      if (DHTML_Enabled)
         {
            if (isNetscape)
               {
                 document.write("<LAYER bgcolor="+Color+"  width="+WidthMenu+"  visibility=hidden  id="+MenuID+"   onMouseover=\"MenuActivate('"+MenuID+"')\" onMouseOut=\"MenuKill('"+MenuID+"')\">"+Content+"</LAYER>");
               }
            else
               {
                   document.write("<DIV id="+MenuID+" STYLE=\"position:absolute; padding-top: 12px; padding-bottom: 6px; visibility:hidden; background:"+Color+"\"  onMouseover=\"MenuActivate('"+MenuID+"')\" onMouseOut=\"MenuKill('"+MenuID+"')\">"+Content+"</DIV>");
                     eval(layerRef + '["'+MenuID+'"]'+ styleRef + '.width ='+WidthMenu);
                  }
        }

  }

// To activate a menu just change the visibility parameter
function MenuActivate(MenuNumber)
  {
         MenuID=MenuNumber;

         if (DHTML_Enabled)
            {
               if (isNetscape)
                  {
                      MenuIDPlace=MenuID+"Place"
                      MenuIDPicture=MenuID+"Picture"
                      // alert ( "MenuIDPicture="+MenuIDPicture)
                      CoordX=document.anchors[MenuIDPlace].x+document.images[MenuIDPicture].width;
                      CoordY=document.anchors[MenuIDPlace].y ;
                      eval(layerRef + '["'+MenuID+'"]' + styleRef + '.top = '+CoordY);
                      eval(layerRef + '["'+MenuID+'"]' + styleRef + '.left = '+CoordX);
                      eval(layerRef + '["'+MenuID+'"]' + styleRef + '.visibility = "visible"');

                  }
               else
                  {
                      eval(layerRef + '["'+MenuID+'"]' + styleRef + '.visibility = "visible"');
                  }
        }
   }
// To de-activate a menu just change the visibility parameter
function MenuKill(MenuNumber)
   {
      MenuID=MenuNumber;
     if(document.getElementById(MenuNumber)!=null)
                document.getElementById(MenuNumber).style.visibility="hidden";

      if (DHTML_Enabled)
           {
//But first fixing a bug in IE4
             if (  (!isNetscape)&&(window.event.toElement.tagName== 'A') )
                 {
                   return;
                 }
             if (  (!isNetscape)&&(window.event.toElement.tagName== 'DIV') )
                 {
                   return;
                 }
// Now changing the visibility parameter
            eval(layerRef + '["'+MenuID+'"]' + styleRef + '.visibility = "hidden"');
                }
   }
// that's all
