function openCars( url )
{
  var win = window.open(url,"AutoRusso","toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=yes,resizable=no,width=637,height=620");
  win.focus();
}

function openURL( url, w, h )
{
  var winurl = window.open(url,"AutoRusso","toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=yes,resizable=no,width="+w+",height="+h);
  winurl.focus();
}

function calc(formname)
{
  var drivekm, consumption, benprice, gasprice
  var bencosts, gascosts, gassaving
  
  drivekm = formname.drivekm.value;
  consumption = formname.consumption.value.replace( ",", "." );
  benprice = formname.benprice.value.replace( ",", "." );
  gasprice = formname.gasprice.value.replace( ",", "." );

  bencosts = roundval( drivekm / 100 * consumption * benprice, 2 );
  gascosts = roundval( drivekm / 100 * consumption * 1.2 * gasprice, 2 );
  
  formname.bencosts.value = bencosts;
  formname.gascosts.value = gascosts;
  formname.gassaving.value = roundval( bencosts - gascosts, 2 );
}

function roundval(x, n) {
  if( n < 1 || n > 14 )
    return false;

  var e = Math.pow( 10, n );
  var k = ( Math.round( x * e ) / e ).toString();

  if( k.indexOf( '.' ) == -1 )
    k += '.';

  k += e.toString().substring( 1 );

  return k.substring( 0, k.indexOf( '.' ) + n + 1);
}
