_debug_ = true;
function showPic(picture,title){
  var pic_rel_path = "\.\." + "/img/CLOSE.gif";
  var pic_abs_path = "/img/CLOSE.gif";
  var close_pic;
  for (var i=0; i < document.all.tags("script").length; i++)
  {
    var obj = document.all.tags("script")[i];
    var ScriptFile = obj.src.substr(obj.src.lastIndexOf("\/") + 1);
    if (ScriptFile == "show_pic.js")
    {
      close_pic = obj.src.substr(0, obj.src.lastIndexOf("\/")) + "\/" + pic_rel_path;
      break;
    }
    else
    {
      close_pic = pic_abs_path;
    };
  }
//  alert(close_pic);
  if (picture=='') return false;
  newWindow = window.open("","newWindow","width="+100+",height="+100+",left="+100+",top="+100);
  newWindow.document.open();
  newWindow.document.write('<html><head><title>'+title+'</title>');
  newWindow.document.write('<script>function resize(){ ');
  newWindow.document.write('   var pic = document.getElementById("pic");');
  newWindow.document.write('   if (typeof(pic)!="undefined"){ ');
  newWindow.document.write('       self.resizeTo(pic.width,pic.height+30);');
  newWindow.document.write('   }');
  newWindow.document.write('}');
  newWindow.document.write('\</script\>');
  newWindow.document.write('</head><body leftmargin="0" topmargin="0" marginheight="0" marginwidth="0" onload="resize()">');
  newWindow.document.write('<div id="Layer1" style="position:absolute; width:100%; height:100%; z-index:2; left: 0px; top: 0px; overflow: visible;">'); 
  newWindow.document.write('<table border="0" width="100%" height="100%" cellspacing="0" cellpadding="0"><tr><td height="100%" valign="bottom" align="right"><a href="javascript:self.close();"><img border=0 src="'+close_pic+'"></a></td></tr></table>');
  newWindow.document.write('</div><div id="Layer2" style="position:absolute; width:100%; height:100%; z-index:1; left: 0px; top:0px;">'); 
  newWindow.document.write('<table border="0" width="100%" height="100%" cellspacing="0" cellpadding="0"><tr><td align="center" valign="middle"><img id="pic" src="'+picture+'"></td></tr></table>');
  newWindow.document.write('</div></body></html>');
  newWindow.document.close();
  newWindow.focus();
}

function win(href,width,height){
    newWindow = window.open(href,"","width="+width+",height="+height+",left="+(screen.width-width)/2+",top="+(screen.height-height)/2+",resizable=yes,scrollbars=yes");
    newWindow.resizeTo(width,height);
    newWindow.focus();
    return void(0);
}

function showModel(model,title){
    if (typeof(model)=='undefined') return;
    win('/order/model.php?model='+model,800,600);
}
function loadPic(picture){
    // тихонько уходим если ничего не получили
    InstalledPlugin = false;
    if (typeof(picture)=='undefined') {
        alert('Неуказан файл изображения');
        return;
    }
    var obj = document.all["Place"];
    // некуда загужать картинку
    if (typeof(obj)=='undefined'){
        showPic(picture,"");
    } else {
        obj.innerHTML = '<img border="1" src="'+picture+'" alt="" >';
    }
}

function reloadOpener(){
    if (typeof(window.opener)!='undefined'){
        window.opener.location.reload();
    }
}

function debug(message){
    if (typeof(debug_)!="undefined"){
        alert(message);
    }
}