function img_popup(img)//отображает картинку в попапе
{
 width=100;
 height=100;

 s_width = screen.width;
 s_height = screen.height;

 win_width=s_width/2-width/2;
 win_height=s_height/2-height/2;
 window.open('img_popup.php?patch='+img,null,'width='+width+',height='+height+',Top='+win_height+',Left='+win_width+',scrollbars=yes,resizable=yes');
}

scrollTop=0;
window.onresize= popupmove;
function popupmove()//отображаем попап во фрейме
{
 width=document.getElementById('popup').style.width;
 height=document.getElementById('popup').style.height;

 if (width=='')width=document.getElementById('popup').width;
 if (height=='')height=document.getElementById('popup').height;

 width=parseInt(width);
 height=parseInt(height);

 s_width = parseInt(document.body.clientWidth);
 s_height = parseInt(document.body.clientHeight);

 win_width=parseInt(s_width/2-width/2);
 win_height=parseInt(s_height/2-height/2+30);

 if (win_width<30)win_width=30;
 if (win_height<30)win_height=30;
 document.getElementById('popup').style.left=win_width;
 document.getElementById('popup').style.top=win_height+scrollTop;
}

 function popup(url)//открывает попап окно с заданый URL
{
 document.getElementById('popup').src=url;
 document.getElementById('popup').style.display='block';
 scrollTop=document.body.scrollTop;;
 popupmove();

}

function move_true(mousex,mousey)
{
 xcor=mousex-parseInt(document.getElementById('popup').style.left);
 ycor=mousey-parseInt(document.getElementById('popup').style.top);
 move=true;
}

move=false;
xcor=0;
ycor=0;

function div_move(mousex,mousey)
{
  if (move)
  {
   div=document.getElementById('popup');
   div.style.left=mousex-xcor;
   div.style.top=mousey-ycor;
  }
}