
function OpenPhoto(img, w, h, title){
  if (w && h) {
    if (w > screen.availWidth || h > screen.availHeight) {
      if (w / screen.availWidth > h / screen.availHeight) {
        h *= screen.availWidth / w;
        w = screen.availWidth;
      }
      else {
        w *= screen.availHeight / h;
        h = screen.availHeight;
      }
    }
    if (!title) title = 'Просмотр фотографии';
    var win = window.open("", "_blank", "width="+w+", height="+h);
    win.document.write("<html><head>\n");
    win.document.write("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=windows-1251\">\n");
    win.document.write("<title>"+title+"</title></head>\n");
    win.document.write("<body style=\"padding: 0; margin: 0; cursor: hand;\">\n");
    win.document.write("<img src=\""+img+"\" width=\""+w+"\" height=\""+h+"\" alt=\""+title+"\" title=\""+title+"\" onclick=\"window.close()\">\n");
    win.document.write("</body></html>");
    win.focus();
  }
}


function LoadImage(e, Id){
  photo = document.getElementById(Id);
  photo.src = e.value;
  return true;
}

function Dump(d,l) {
    if (l == null) l = 1;
    var s = '';
    if (typeof(d) == "object") {
        
        s += typeof(d) + " {<br />";

        for (var k in d) {
            for (var i=0; i<l; i++) s += "  ";
            s += k+": " + d[k];
//            s += k+": " + Dump(d[k],l+1);
        }

        for (var i=0; i<l-1; i++) s += "  ";

        s += "}<br />"

    } else {
        s += "" + d + "<br />";
    }
    return s;
}
