function wmPopup (imageURL, caption, theme) {
  var windowTop = 20;
  var windowLeft = 50;
  var defaultWidth = 600;
  var defaultHeight = 900;
  var location = 0;
  var toolbar = 0;
  var menubar = 0;
  var scrollbars = 0;
  var onLoseFocusExit = true;
  var undefined;
  var Options = "location=" + location + ",scrollbars=" + scrollbars + ",width=" + defaultWidth + ",height=" + defaultHeight + ",top=" + windowTop + ",left=" + windowLeft + ""
  var myScript = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1//EN\" \"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd\">\n" +
    "<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"ru\" lang=\"ru\">\n" +
    "<head>\n" +
    "<title>" + caption + "\</title>\n" +
    "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=windows-1251\">\n" +
    "<meta http-equiv=\"Content-Language\" content=\"ru\">\n" +
    "<meta http-equiv=\"pragma\" content=\"no-cache\">\n" +
	"<meta http-equiv=\"cache-control\" content=\"0\">\n" +
    "<meta http-equiv=\"imagetoolbar\" content=\"no\">\n" +
"<style type=\"text/css\">\n" +
"img.watermark {\n" +
"  position: absolute;\n" +
"  bottom: 2px;\n" +
"  right: 3px;\n" +
"}\n" +
"-->\n" +
"</style>\n" +
    "<script language=\"JavaScript\" type=\"text/javascript\">\n" +
    "function resizewindow () {\n" +
    "  var width = document.myimage.width;\n" +
    "  var height = document.myimage.height;\n";
  if (navigator.appName.indexOf("Netscape") != -1) {
    myScript = myScript +  "  window.innerHeight = height;\n  window.innerWidth = width;\n"
  }
  else if (navigator.appName.indexOf("Opera") != -1) {
    myScript = myScript +  "  window.resizeTo (width+12, height+31);\n"
  }
  else if (navigator.appName.indexOf("Microsoft") != -1) {
    myScript = myScript + "  window.resizeTo (width+12, height+31);\n"
  }
  else {
    myScript = myScript + "  window.resizeTo (width+14, height+34);\n"
  }
  myScript = myScript + "}\n" + "window.onload = resizewindow;\n" +
    "</script>\n</head>\n" + "<body ";
  if (onLoseFocusExit) {myScript = myScript + "onblur=\"window.close()\" ";}
  myScript = myScript + "style=\"margin: 0px; padding: 0px;\">\n" +
    "<img src=\"" + imageURL + "\" alt=\"" + caption + "\" title=\"" + caption + "\" name=\"myimage\">\n" +
"<img class=\"watermark\" src=\""+theme+"/watermark.png\">\n" +
    "</body>\n" +  "</html>\n";
  var imageWindow = window.open ("","imageWin",Options);
  imageWindow.document.write (myScript)
  imageWindow.document.close ();
  if (window.focus) imageWindow.focus();
  return false;
}


function ShowWindow(page, width, height,tgt){
   if(width==null)   width=500;
   if(height==null) height=500;
   if(tgt==null) tgt="_blank";

   window.open(page,tgt, "top=0,left=0,location=0,scrollbars=0,width="+width.toString()+", height="+height.toString());
}

function ExpandPanel(idPanel){
  var rl=document.getElementById(idPanel);
  if(rl!=null){
    if(rl.style.display=="inline"){
      rl.style.display="none";
    }else{
      rl.style.display="inline";
    }
  }
  return false;
}
    
function UseElement(id, func){
  var obj=document.getElementById(id);
  if(obj!=null){
    func(obj);
  }else{
     window.alert('Объект с идентификатором '+id+' не найден');
  }              
}

//function SetOnCloseDialogFunc(func){
//    window.OnCloseDialog=func;
//}