

function OpenPicture( pic_index , wid_x , hei_y )
	{	
	NewWindow=window.open('','','toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, fullscreen=no, channelmode=no, width='+wid_x+', height='+hei_y+', left=40, top=40');
	NewWindow.document.open();
	
	NewWindow.document.writeln("<head>");
	NewWindow.document.writeln("<title>Foto</title>");
	
	NewWindow.document.writeln("<style type=\"text/css\">");
	NewWindow.document.writeln("body{font-family: Verdana; font-size:12;}");
	NewWindow.document.writeln("a:link{color:#0000FF;text-decoration:none;}");
	NewWindow.document.writeln("a:visited{color:#0000FF;text-decoration:none;}");
	NewWindow.document.writeln("a:hover{color:#EE0000;text-decoration:underline;}");
	NewWindow.document.writeln("</style>");
		
	NewWindow.document.writeln("</head>");	
	NewWindow.document.writeln("<body leftmargin=\"1\" topmargin=\"1\" rightmargin=\"1\">");
	NewWindow.document.writeln("<a href=\"javascript:window.close();\"><img src=\""+pic_index+"\" style=\"border: solid 0;\" alt=\"Zamknij podgląd\"></a>");
	NewWindow.document.writeln("<center>");
	NewWindow.document.writeln("<br><a href=\"javascript:window.close();\">Zamknij</a><br>");
	NewWindow.document.writeln("</center>");
	NewWindow.document.writeln("</body>");
	NewWindow.document.close();
	NewWindow.focus();
	}
	

function img1(name)
  {
	img=new Image();
    img.src = 'http://www.automatyka-budynkowa.com/pliki/'+name+'.png';
	document.images[name].src=img.src;
  }


function img2(name)
  {
	img=new Image();
    img.src = 'http://www.automatyka-budynkowa.com/pliki/'+name+'a.png';
	document.images[name].src=img.src;
  }



function pytanie( adres )
  {
  odp = window.confirm("Czy usunąć wybraną pozycję?");

  if( odp == true )
    window.location.href = adres;
  }	
  
  
function pokaz(div)
  {
  if(document.getElementById(div).style.display=="block")
    document.getElementById(div).style.display="none";
  else
    document.getElementById(div).style.display="block";
  }
  
  
function p_edit(div)
  {
  document.getElementById(div).style.display="block";
  }
  
  
function u_edit(div)
  {
  document.getElementById(div).style.display="none";
  }
  
 
//--------------------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------------------
//-------------------------------------------------------------------------------------------------- 


var tax_rates = new Array();
tax_rates["3"]  = 3;
tax_rates["7"]  = 7;
tax_rates["22"] = 22;


function doRound(x, places)
  {
  return Math.round(x * Math.pow(10, places)) / Math.pow(10, places);
  }

function getTaxRate() 
  {
  var selected_value = document.forma.vat.selectedIndex;
  var parameterVal = document.forma.vat[selected_value].value;

  if ( (parameterVal > 0) && (tax_rates[parameterVal] > 0) )
    return tax_rates[parameterVal];
  else
    return 0;
  }

function updateBrutto() 
  {
  var taxRate = getTaxRate();
  var grossValue = document.forma.cena.value;
        
  grossValue = grossValue.replace(",",".");

  if (taxRate > 0) 
    {
    grossValue = grossValue * ((taxRate / 100) + 1);
    }

  document.forma.brutto.value = doRound( grossValue, 2 );
  }

function updateNetto() {
  var taxRate = getTaxRate();
  var netValue = document.forma.brutto.value;
        
  netValue = netValue.replace(",",".");

  if (taxRate > 0) 
    {
    netValue = netValue / ((taxRate / 100) + 1);
    }

  document.forma.cena.value = doRound( netValue, 2 );
  }

//--------------------------------------------------------------------------------

function updateTotalPrice()
  {
  var tax_rates = new Array();
  tax_rates[5] = 30;
  tax_rates[4] = 15;
  tax_rates[1] = 0;
  tax_rates[3] = 6;
  tax_rates[2] = 7;
  
  var total = parseFloat(document.forma.wartosc.value) + parseFloat(tax_rates[document.forma.wysylka.value]);
  
  getElem('totalLab').innerHTML = zaokr( total , 0.01 );
  }
  
  
function zaokr( Liczba , Dokladnosc )
  {
  if ( Dokladnosc < 0.0001 )
    Dokladnosc = 0.0001;
  var Liczba_str = "" + Math.round(Liczba / Dokladnosc);
  var Liczba_len = Liczba_str.length;
  var poz = Math.log(1/Dokladnosc)/Math.log(10);
  if (Dokladnosc < 1)
    return parseFloat(Liczba_str.substring(0, Liczba_len - poz) + "." + Liczba_str.substring(Liczba_len - poz, Liczba_len));
  else
    return Math.round(Dokladnosc * Liczba_str);
  }

//--------------------------------------------------------------------------------
