function zaokraglaj(liczba)
{
liczba = liczba*100;
liczba = Math.round(liczba);
liczba = liczba/100;
return liczba;
}
function popitup(index,id)
{
var op_w = document.getElementById('op_w'+id);
if(index!='')
	{
		op_w.className = 'widoczny';
		var string = "materialy.php?rodz="+index+"&id="+id;
		window.open(string,"","");
		return;
	}
else
  {
		op_w.className = 'niewidoczny';
		var ide = document.getElementById('ide'+id).value = '';
		var tw = document.getElementById('tw'+id).value = '';
		var wz = document.getElementById('wz'+id).value = '';
		var wzy = document.getElementById('wzy'+id).value = '';
		var gw = document.getElementById('gw'+id).value = '';
	}
return;
}

function kasuj(id)
{
var op_w = window.opener.document.getElementById('op_w'+id);
var ide = window.opener.document.getElementById('ide'+id).value = '';
var rw = window.opener.document.getElementById('rw'+id).value = '';
var tw = window.opener.document.getElementById('tw'+id).value = '';
var wz = window.opener.document.getElementById('wz'+id).value = '';
var wzy = window.opener.document.getElementById('wzy'+id).value = '';
var gw = window.opener.document.getElementById('gw'+id).value = '';
rw.selectedIndex = 0;
op_w.className='niewidoczny';
window.close();
return;
}

function pobierz(id)
{
var ide = window.opener.document.getElementById('ide'+id).value = document.produkt.id.value;
var tw = window.opener.document.getElementById('tw'+id).value = document.produkt.typ.value;
var wz = window.opener.document.getElementById('wz'+id).value = document.produkt.waga_zbrojenia.value;;
var wzy = window.opener.document.getElementById('wzy'+id).value = document.produkt.waga_zywicy.value;
var gw = window.opener.document.getElementById('gw'+id).value = document.produkt.grubosc.value;
window.close();
return;
}

function przepisz_zelkot_topcoat(ide,typp)
{
document.produkt.id.value = ide;
document.produkt.typ.value = typp;
document.produkt.waga_zbrojenia.value = 0;
document.produkt.grubosc.value = 0.6;			//algorytm od gracjana = tutaj wstawi�
document.produkt.waga_zywicy.value = zaokraglaj(1.2 * document.produkt.grubosc.value);
return;
}

function zmien_grubosc_zelkot_topcoat()
{
document.produkt.waga_zywicy.value = zaokraglaj(1.2 * document.produkt.grubosc.value);
return;
}


function przepisz_mate(ide,typp,waga_zbr)
{
var zawartosc = opener.document.obliczenia.wag_sz_maty.options[opener.document.obliczenia.wag_sz_maty.selectedIndex].value;
document.produkt.id.value = ide;
document.produkt.typ.value = typp;
document.produkt.waga_zbrojenia.value = waga_zbr;
var bufor = zaokraglaj((waga_zbr/(zawartosc/100) - waga_zbr));
document.produkt.waga_zywicy.value = bufor;
document.produkt.grubosc.value = zaokraglaj((waga_zbr + bufor)/(1.1 + (zawartosc/100)));
return;
}


function przepisz_tkanine(ide,typp,waga_zbr)
{
var zawartosc = opener.document.obliczenia.wag_sz_tkanin.options[opener.document.obliczenia.wag_sz_tkanin.selectedIndex].value;
document.produkt.id.value = ide;
document.produkt.typ.value = typp;
document.produkt.waga_zbrojenia.value = waga_zbr;
var bufor = zaokraglaj((waga_zbr/(zawartosc/100) - waga_zbr));
document.produkt.waga_zywicy.value = bufor;
document.produkt.grubosc.value = zaokraglaj((waga_zbr + bufor)/(1.1 + (zawartosc/100)));
return;
}

function przepisz_firet_coremat(ide,typp,waga_zbr,waga_zyw,grub)
{
document.produkt.id.value = ide;
document.produkt.typ.value = typp;
document.produkt.waga_zbrojenia.value = waga_zbr;
document.produkt.waga_zywicy.value = waga_zyw;
document.produkt.grubosc.value = grub;
return;
}


function przepisz_przekladka(ide,typp,waga_zbr,grub)
{
document.produkt.id.value = ide;
document.produkt.typ.value = typp;
document.produkt.waga_zbrojenia.value = zaokraglaj(grub/1000*waga_zbr);
document.produkt.waga_zywicy.value = 1.00;
document.produkt.grubosc.value = zaokraglaj(grub);
return;
}

function wybor_zywicy(lang)
{
var adr = "materialy.php?lang="+lang+"&rodz=6";
window.open(adr,"","");
return;
}

function przepisz_zywice(ide,typp,cenaa)
{
document.produkt.id.value=ide;
document.produkt.typ.value=typp;
document.produkt.cena.value=cenaa;
return;
}

function pobierz_zywice()
{
var type = window.opener.document.getElementById('typ_zywicy').value = document.produkt.typ.value;
var cenaa = window.opener.document.getElementById('cena_zywicy').value = document.produkt.cena.value;
window.close();
return;
}

function wybor_utwardzacza(lang,il_zywicy)
{
var adr = "materialy.php?lang="+lang+"&rodz=7&utw="+il_zywicy;
window.open(adr,"","");
return;
}

function przepisz_utwardzacz(ide,typp,cenaa,procent)
{
document.produkt.id.value=ide;
document.produkt.typ.value=typp;
document.produkt.cena.value=cenaa;
document.produkt.procentowo_do_zywicy.value=procent;
return;
}

function pobierz_utwardzacz(il_zywicy)
{
var typpp = window.opener.document.getElementById('typ_utwardzacza').value = document.produkt.typ.value;
var cenaa = window.opener.document.getElementById('cena_utwardzacza').value = document.produkt.cena.value;
var proc = window.opener.document.getElementById('procentowo_do_zywicy').value = document.produkt.procentowo_do_zywicy.value;
var utwa = window.opener.document.getElementById('il_utwardzacza').value = zaokraglaj(il_zywicy*(document.produkt.procentowo_do_zywicy.value/100));
window.close();
return;
}


function calc_window_open(url) {
	var newwindow = window.open(url);
	if (window.focus) {newwindow.focus();}
	return;
}