function displayWindow(url, width, height) {
    var Win = window.open(url,"displayWindow",'width=' + width + ',height=' + height + ',resizable=0, scrollbars=yes, menubar=no' );
}



function modele() {

	var marka_id = document.getElementById('marka_id').value;

	$(document).ready(function() {
		$('#ajaxModele').load('/ajax.php5?markaId=' + marka_id);
	});

//	if (marka_id == 0) {

		$('#ajaxRoczniki').html('<select name="rocznik" disabled="disabled"><option value="0">wybierz rocznik</option></select>');
		$('#ajaxZdjecie').html('');

//	}

	zablokujDalej();

}





function roczniki() {

	var model_id = document.getElementById('model_id').value;

	$(document).ready(function() {

		$('#ajaxRoczniki').load('/ajax.php5?rocznikId=' + model_id);
		$('#ajaxZdjecie').html('');

		pobierzZdjecieModel();

	});

	zablokujDalej();

}





function odblokujDalej() {
//	document.model.dalej.disabled = false;

//	obj = document.getElementById('dalej');
//	obj.style.display = "border:10px solid red;";

	obj = document.getElementById("submit");
	obj.style.display = "block";

	obj2 = document.getElementById("submitDisabled");
	obj2.style.display = "none";

}





function zablokujDalej() {
//	document.model.dalej.disabled = true;

//	obj = document.getElementById('dalej');
//	obj.style.display = "border:10px solid blue;";

	obj = document.getElementById("submit");
	obj.style.display = "none";

	obj2 = document.getElementById("submitDisabled");
	obj2.style.display = "block";

}





function pobierzZdjecieModel() {

	var model_id = document.getElementById('model_id').value;

	$(document).ready(function() {
		$('#ajaxZdjecie').load('/ajax.php5?zdjecieId=' + model_id);
	});

}





function pobierzZdjecieRocznik() {

	var rocznik_id = document.getElementById('rocznik_id').value;

	$(document).ready(function() {
		$('#ajaxZdjecie').load('/ajax.php5?zdjecieId=' + rocznik_id);
	});

	if (rocznik_id == 0) {
		zablokujDalej();
	}
	else {
		odblokujDalej();
	}

}





function zmienKolor(kolor) {

	if (kolor == 1 || kolor == 3) {
		$('#ajaxMaterial').html('<ul class="box_opcje_material"><li><a href="javascript:displayWindow(\'/wydruk/s/7/\',500,500)"><img src="/_szablony_/public/img/help.gif" /></a><label for="m1"><strong>Polipropylen</strong>(wersja standard)</label><input id="m1" type="radio" disabled="disabled" name="material" value="pp" /></li><li><a href="javascript:displayWindow(\'/wydruk/s/7/\',500,500)"><img src="/_szablony_/public/img/help.gif" /></a><label for="m2"><strong>Poliamid</strong>(wersja exlusive)</label><input id="m2" type="radio" name="material" value="pa" checked="checked" /></li><ul>');
	}

	if (kolor == 2) {
		$('#ajaxMaterial').html('<ul class="box_opcje_material"><li><a href="javascript:displayWindow(\'/wydruk/s/7/\',500,500)"><img src="/_szablony_/public/img/help.gif" /></a><label for="m1"><strong>Polipropylen</strong>(wersja standard)</label><input id="m1" type="radio" name="material" value="pp" checked="checked" /></li><li><a href="javascript:displayWindow(\'/wydruk/s/7/\',500,500)"><img src="/_szablony_/public/img/help.gif" /></a><label for="m2"><strong>Poliamid</strong>(wersja exlusive)</label><input id="m2" type="radio" disabled="disabled" name="material" value="pa" /></li><ul>');
	}

	if (kolor == 4) {
		$('#ajaxMaterial').html('<ul class="box_opcje_material"><li><a href="javascript:displayWindow(\'/wydruk/s/7/\',500,500)"><img src="/_szablony_/public/img/help.gif" /></a><label for="m1"><strong>Polipropylen</strong>(wersja standard)</label><input id="m1" type="radio" name="material" value="pp" checked="checked" onchange="zdjecieMaterial(1);" /></li><li><a href="javascript:displayWindow(\'/wydruk/s/7/\',500,500)"><img src="/_szablony_/public/img/help.gif" /></a><label for="m2"><strong>Poliamid</strong>(wersja exlusive)</label><input id="m2" type="radio" name="material" value="pa" onchange="zdjecieMaterial(2);" /></li><ul>');
	}


	if (kolor == 1) {
		$('#ajaxMaterialZdjecie').html('<img src="/_pliki_/kolory/bez_pa.jpg" alt="" />');
		$('#ajaxMaterialZdjecieDuze').html('<img src="/_pliki_/kolory/bez_pa_d.jpg" alt="" />');
	}

	if (kolor == 2) {
		$('#ajaxMaterialZdjecie').html('<img src="/_pliki_/kolory/czarny_pp.jpg" alt="" />');
		$('#ajaxMaterialZdjecieDuze').html('<img src="/_pliki_/kolory/czarny_pp_d.jpg" alt="" />');
	}

	if (kolor == 3) {
		$('#ajaxMaterialZdjecie').html('<img src="/_pliki_/kolory/szary_pp.jpg" alt="" />');
		$('#ajaxMaterialZdjecieDuze').html('<img src="/_pliki_/kolory/szary_pp_d.jpg" alt="" />');
	}

	if (kolor == 4) {
		$('#ajaxMaterialZdjecie').html('<img src="/_pliki_/kolory/antracyt_pp.jpg" alt="" />');
		$('#ajaxMaterialZdjecieDuze').html('<img src="/_pliki_/kolory/antracyt_pp_d.jpg" alt="" />');
	}

	przeliczCene();

}





function zdjecieMaterial(material) {


	$('#ajaxMaterialZdjecie').html('');
	$('#ajaxMaterialZdjecieDuze').html('');

	if (material == 1) {
		$('#ajaxMaterialZdjecie').html('<img src="/_pliki_/kolory/antracyt_pp.jpg" alt="" />');
		$('#ajaxMaterialZdjecieDuze').html('<img src="/_pliki_/kolory/antracyt_pp_d.jpg" alt="" />');
		$('#ajaxCena').html('80');
	}

	if (material == 2) {
		$('#ajaxMaterialZdjecie').html('<img src="/_pliki_/kolory/antracyt_pa.jpg" alt="" />');
		$('#ajaxMaterialZdjecieDuze').html('<img src="/_pliki_/kolory/antracyt_pa_d.jpg" alt="" />');
		$('#ajaxCena').html('100');
	}

	przeliczCene();

}





function zmienWzmocnienie() {

	var wzmocnienie_id = document.getElementById('wzmocnienie_id').value;

	if (wzmocnienie_id == 0) {
		$('#ajaxWzmocnienieZdjecie').html('');
	}

	if (wzmocnienie_id == 1) {
		$('#ajaxWzmocnienieZdjecie').html('<img src="/_pliki_/wzmocnienie/welur.jpg" alt="" />');
	}

	if (wzmocnienie_id == 2) {
		$('#ajaxWzmocnienieZdjecie').html('<img src="/_pliki_/wzmocnienie/guma.jpg" alt="" />');
	}

}





function przeliczCene() {

	var cena = 0;

	var stoper_id = document.getElementById('stoper_id').value;
	var stoper_liczba = document.getElementById('stoper_liczba').value;
	var ilosc = document.getElementById('ilosc').value;
	var nadruk = document.getElementById('nadruk').value;

	if (stoper_id == 0) {
		var stoper_cena = 0;
	}
	else {
		var stoper_cena = 3;
	}


	if (document.produkt.m1.checked == true) {
		cena = cena + 80;
	}

	if (document.produkt.m2.checked == true) {
		cena = cena + 120;
	}

	if (document.produkt.nadruk.checked == true) {
		cena = cena + 20;
	}

	if (document.produkt.plik_info.checked == true) {
		cena = cena + 40;
	}

//	if (document.getElementById('kolor_obszycia').value == 'nić srebrna' || document.getElementById('kolor_obszycia').value == 'nić czerwona' || document.getElementById('kolor_obszycia').value == 'nić niebieska') {
//		cena = cena + 8;
//	}

	cena = (cena + (stoper_liczba * stoper_cena)) * ilosc;
	cena = cena + ',00';

	$('#ajaxCena').html(cena);

}





function zmienStoper() {

	var stoper_id = document.getElementById('stoper_id').value;

	if (stoper_id == 0) {
		$('#ajaxStoperyZdjecie').html('');
		document.produkt.stoper_liczba.disabled = true;
	}

	if (stoper_id == 1) {
		$('#ajaxStoperyZdjecie').html('<img src="/_pliki_/stopery/owalne.jpg" alt="" />');
		document.produkt.stoper_liczba.disabled = false;
	}

	if (stoper_id == 2) {
		$('#ajaxStoperyZdjecie').html('<img src="/_pliki_/stopery/okragle.jpg" alt="" />');
		document.produkt.stoper_liczba.disabled = false;
	}

	przeliczCene();

}



function zaznacz(id) {

	document.getElementById(id).focus();
	document.getElementById(id).select();

}



function pokazPomoc(id) {

	obj = document.getElementById(id);
	obj.style.display = "block";

}


function ukryjPomoc(id) {

	obj = document.getElementById(id);
	obj.style.display = "none";

}



function zmienNadruk() {

	if (document.produkt.nadruk.checked == true) {

		document.produkt.napis.disabled = false;
		document.produkt.napis_kolor.disabled = false;

	}
	else {

		document.produkt.napis.disabled = true;
		document.produkt.napis_kolor.disabled = true;

	}

	przeliczCene();

}



function zalaczPlik() {

	document.produkt.plik.value = '';

	if (document.produkt.plik_info.checked == true) {
		document.produkt.plik.disabled = false;
	}
	else {
		document.produkt.plik.disabled = true;
	}

	przeliczCene();

}



function zmienKolorObszycia() {

	var kolor_obszycia = document.getElementById('kolor_obszycia').value;

	if (kolor_obszycia == 'lamówka czarna') {
		$('#ajaxObszycieZdjecie').html('<img src="/_pliki_/obszycie/brak.jpg" alt="" />');
	}

	if (kolor_obszycia == 'lamówka srebrna') {
		$('#ajaxObszycieZdjecie').html('<img src="/_pliki_/obszycie/srebrna.jpg" alt="" />');
	}

	if (kolor_obszycia == 'lamówka czerwona') {
		$('#ajaxObszycieZdjecie').html('<img src="/_pliki_/obszycie/czerwona.jpg" alt="" />');
	}

	if (kolor_obszycia == 'lamówka beżowa') {
		$('#ajaxObszycieZdjecie').html('<img src="/_pliki_/obszycie/bezowa.jpg" alt="" />');
	}

	if (kolor_obszycia == 'nić czarna') {
		$('#ajaxObszycieZdjecie').html('<img src="/_pliki_/obszycie/czarny.jpg" alt="" />');
	}

	if (kolor_obszycia == 'nić srebrna') {
		$('#ajaxObszycieZdjecie').html('<img src="/_pliki_/obszycie/srebrny.jpg" alt="" />');
	}

	if (kolor_obszycia == 'nić czerwona') {
		$('#ajaxObszycieZdjecie').html('<img src="/_pliki_/obszycie/czerwony.jpg" alt="" />');
	}

	if (kolor_obszycia == 'nić niebieska') {
		$('#ajaxObszycieZdjecie').html('<img src="/_pliki_/obszycie/niebieski.jpg" alt="" />');
	}

	przeliczCene();

}