 function lib_open_img_window(src,width,height){
   if(width==0)
     width=500;
   width+=20;
   if(height==0)
     height=400;
   height+=20;
   if(height>600)
     height=600;
   var left = (screen.availWidth/2) - (width/2);
   var top = (screen.availHeight/2) - (height/2);
   info=window.open('/img_preview.php?src='+src,'info','resizable=1, scrollbars=1, toolbar=0, status=0, width='+width+', height='+height+', left='+left+', top='+top);
   info.focus();
 }
  function opw(id){
   width=700;
   height=500;
   var left = (screen.availWidth/2) - (width/2);
   var top = (screen.availHeight/2) - (height/2);
   info=window.open('/fgallery.php?parent='+id,'photo','resizable=1, scrollbars=1, toolbar=0, status=0, width='+width+', height='+height+', left='+left+', top='+top);
   info.focus();
 }
   function ops(id){
   width=700;
   height=500;
   var left = (screen.availWidth/2) - (width/2);
   var top = (screen.availHeight/2) - (height/2);
   info=window.open('/sgallery.php?id='+id,'photo','resizable=1, scrollbars=1, toolbar=0, status=0, width='+width+', height='+height+', left='+left+', top='+top);
   info.focus();
 }
 function opdoc(id){
   width=700;
   height=500;
   var left = (screen.availWidth/2) - (width/2);
   var top = (screen.availHeight/2) - (height/2);
   info=window.open('/office.php?id='+id,'photo','resizable=1, scrollbars=1, toolbar=0, status=0, width='+width+', height='+height+', left='+left+', top='+top);
   info.focus();
 }
function calc_credit(){
  if(document.forms['credit'].stavka.value==''){
    alert('Ставка кредита пустое');
    return;
  }
  var stavka=parseInt(document.forms['credit'].stavka.value);
  if(document.forms['credit'].month.value==''){
    alert('Срок кредита пустое');
    return;
  }
  var month=parseInt(document.forms['credit'].month.value);

  if(document.forms['credit'].summ.value==''){
    alert('Cумма кредита пустое');
    return;
  }
  var summ=parseInt(document.forms['credit'].summ.value);
  stavka=stavka/100;
  month=month-2;

  res=Math.abs((summ*(stavka/12))/(1-Math.pow((1+stavka/12),-month)));
  res=res*100;
  res=res.toString();
  res=parseInt(res)/100;

  document.forms['credit'].res.value=res;

}