
img1=new Image();

function imgopen(imgf,tit){

img1.src=imgf;
img1.onload=new Function('if(img1.width!=0) eval(iopen);');

rand_id='image'+(Math.round(Math.random()*1000));

outf="<html><head>"
 +"<"+"title>"+tit+"<"+"/title>"
 +"<style>body{margin:0px}</style>"
 +"</head>"
 +"<body leftmargin=0 topmargin=0>"
 +"<img src=\""+imgf+"\"  style=\"cursor:pointer;cursor:hand\" onclick=\"self.close()\">"
 +"</body></html>" ;

iopen="iwin=self.open('"+imgf+"', '"+rand_id+"', 'width='+(img1.width)+',height='+(img1.height)+',top=50,left=50');"
 +"iwin.document.write('"+outf+"');"
 +"iwin.focus();";

// теперь нужно подождать загрузки изображения
// для этого используется обработчик события загрузки картинки onLoad описанный ранее

/*if(img1.width!=0) eval(iopen);
  else alert("Не удалось определить размеры картинки!");*/
}

function pic(wid,heg,which) {
    wtop = 50;
    wleft = (screen.width/2-wid/2);
    blank = window.open('','_blank','status=0,width='+ wid +',height='+ heg +',top=' + wtop + ',left='+ wleft);
    page =	 '<html><head><title>Изображение</title></head><body style="padding:0;margin:0;background:#FFFFFF  50% 50% no-repeat">'+
	     '<img src="' + which +'" width="'+ wid +'" height="'+ heg +'" style="cursor:pointer;cursor:hand" onclick="self.close()" alt="" />'+
	     '</body></html>';
    blank.document.open();
    blank.document.write(page);
    blank.document.close();
    return false;
}


function stopError() {
  return true;
}
//window.onerror = stopError; 
function showhide(vid, SubMenuId,MaxMenu, MaxSubMenu)
{
MaxMenu = 20;
MaxSubMenu = 20;
if (!SubMenuId)
   {
for (i=1;i<=MaxSubMenu;i++)
   {
    if (document.getElementById("Menu"+vid+"S"+i)) {    
	if (document.getElementById("Menu"+vid+"S"+i).style.display)
	{
	    document.getElementById("Menu"+vid+"S"+i).style.display = "none";
	}
    }
   }
for (i=1;i<=MaxMenu;i++)
{
 obj=document.getElementById("Menu"+i);
if (obj) {    
    if (obj.style.display && i != vid)
    {
	obj.style.display = "none";
    }
}
}

if (document.getElementById("Menu"+vid)) {
 if (document.getElementById("Menu"+vid).style.display == "none")
    {
 document.getElementById("Menu"+vid).style.display = "block";
    }
 else
     {
     document.getElementById("Menu"+vid).style.display = "none";
     } 
}
 }
else
 {
 for (i=1;i<=MaxSubMenu;i++)
   {
if (document.getElementById("Menu"+vid+"S"+i)) { 
  if (document.getElementById("Menu"+vid+"S"+i).style.display && i != SubMenuId)
    {
    document.getElementById("Menu"+vid+"S"+i).style.display = "none";
    }
}
   }
if (document.getElementById("Menu"+vid+"S"+SubMenuId)) {
  if (document.getElementById("Menu"+vid+"S"+SubMenuId).style.display == "none")
    {
 document.getElementById("Menu"+vid+"S"+SubMenuId).style.display = "block";
    }
 else
     {
     document.getElementById("Menu"+vid+"S"+SubMenuId).style.display = "none";
     } 
}
 }
}


