function preview_image1(img_id)
{
  var t=window.open('img_id', 
  '_blank',
  'toolbar=no,width=10,height=10,left=0,top=0, status=no,scrollbars=yes,resize=no');
  var s='<body onload="ol()" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0"><script>function ol(){ '+
  ' var corrx=0; var corry=0; if (window.screen.height-50<=document.images[0].height+30){corry=document.images[0].height+30-window.screen.height+50;} if (window.screen.width<=document.images[0].width+28) {corrx=document.images[0].width+28-window.screen.width;}'+
  'window.resizeTo(document.images[0].width+28-corrx,'+
  'document.images[0].height+30-corry);} '+
  '<'+'/script><img src="'+img_id+'" onload="ol()" onclick="window.close();" ></body>';
  t.document.writeln(s);
}

  function next_image(){
      image_id++;
      if (image_id > images_count) {
          image_id = 1;
      }
      document.getElementById('im_progress').innerHTML = (image_id)+' из '+(images_count);
      document.getElementById('big_url1').href = big_images[image_id];
      document.getElementById('big_url2').href = big_images[image_id];
//      document.getElementById('big_url1').innerHTML='';
//      document.getElementById('big_url1').innerHTML='<img src="'+small_images[image_id]+'" border="0" alt="Увеличить фото" title="Увеличить фото" name="car_image">';
      document.images.car_image.src = small_images[image_id];
      return false;

  }

  function prev_image(){
      image_id--;
      if (image_id < 1) {
          image_id = images_count;
      }
      document.getElementById('im_progress').innerHTML = (image_id)+' из '+(images_count);
      document.getElementById('big_url1').href = big_images[image_id];
      document.getElementById('big_url2').href = big_images[image_id];
//      document.getElementById('big_url1').innerHTML='';
//      document.getElementById('big_url1').innerHTML='<img src="'+small_images[image_id]+'" border="0" alt="Увеличить фото" title="Увеличить фото" name="car_image">';
      document.images.car_image.src = small_images[image_id];
           return false;
  }

function preview_image(img_src) {
    pic = new Image();
    pic.src = img_src;
    setTimeout('view_image(pic.src, pic.width, pic.height);', 500);
}

function view_image(img_src, img_width, img_height){
    if (img_width>screen.availWidth-150 || img_width==0) {
        win_width = screen.availWidth-150;
    } else {
        win_width = img_width+20;
    }
    if (img_height>screen.availHeight-150 || img_height==0) {
        win_height = screen.availHeight-150;
    } else {
        win_height = img_height+20;
    }
    win_top  = Math.abs((screen.availHeight - win_height)/3);
    win_left = Math.abs((screen.availWidth -win_width)/3);
    photoWindow = window.open('', '', "resizable=yes,top=" + win_top + ',left=' + win_left + ",width="+win_width+',height='+win_height+",status=0,menubar=0,toolbar=0,scrollbars=yes");
    photoWindow.document.write('<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html>');
    photoWindow.document.write('<head><title>Компания Навигатор</title><style type="text/css"><!-- body {margin: 0; padding: 0;} --></style>');
    photoWindow.document.write('<script type=text/javascript>');
    photoWindow.document.write('document.onkeypress = function CloseOnEsc(key) { if(document.all) { var keyCode = window.event.keyCode; } else { if (key.which == 0) {window.close(); return;} } if (keyCode == 27) {window.close(); return;} }');
    photoWindow.document.write('</script>');
    photoWindow.document.write('</head><body bgcolor="#ffffff" topmargin="0" rightmargin="0" bottommargin="0" leftmargin="0" marginheight="0" marginwidth="0">');
    photoWindow.document.write('<table cellpadding="0" cellspacing="0" border="0" width="100%" height="100%"><tr><td align="center"><a href="javascript:void(0);" onclick="javascript:window.close();">');
    photoWindow.document.write('<img src="'+img_src+'" ');
    if ( (img_width > 1) && (img_height > 1) ) {
        photoWindow.document.write('width="'+img_width+'" height="'+img_height+'"');
    }
    photoWindow.document.write(' border="0" img="Зарыть окно" title="Зарыть окно">');
    photoWindow.document.write('</a></td></tr></table></body></html>');
    photoWindow.document.close()
}

