function zaznacz_format(p){
document.forms[0].format[p].checked = 'true';
przekaz_format();
}

function zaznacz_format_kub(p){
document.forms[0].format[p].checked = 'true';
}

function zaznacz_rozmiar(p){
document.forms[0].rozmiar[p].checked = 'true';
}

function zaznacz_kolor(p){
document.forms[0].kolor[p].checked = 'true';
}

function zaznacz_format_mag(p){
document.forms[0].format[p].checked = 'true';
przekaz_magnes();
}


function przekaz_magnes(){
	for (i = 0; i < document.forms[0].format.length; i++) {
		if (document.forms[0].format[i].checked) {
			document.forms[0].suma_f.value = document.forms[0].format[i].value;
			sumuj();
		}
	}
}


function zaznacz_rame(p){
document.forms[0].typrama[p].checked = 'true';
przekaz_rame();
}

var cena_formatu=new Array();
//anty, alu, dre, "wlasny"
//"20x30", "40x60", "60x90", "wlasny"
cena_formatu[0] = new Array("10", "38", "65", "0" );
cena_formatu[1] = new Array("35", "80", "150", "0" );
cena_formatu[2] = new Array("70", "150", "240", "0" );


//warrtosc formatu
function przekaz_format(p) {
	if (p) {document.forms[0].format[3].checked = 'true';}
	if (document.forms[0].format[3].checked) {document.getElementById('cool').style.display = 'inline';}
	else {document.getElementById('cool').style.display = 'none';}
for (i=0;i<document.forms[0].format.length;i++) {
	if (document.forms[0].format[i].checked) {
		document.forms[0].suma_f.value = document.forms[0].format[i].value;
		for (f = 0; f < 3; f++) {
			document.getElementById("cenar" + f).innerHTML = cena_formatu[f][i] + " PLN";
		}
	}
	}

	przekaz_rame();


}


//wartosc ramy
function przekaz_rame(){
	
	if (document.defaultView) {
    var g = document.defaultView.getComputedStyle(document.getElementById('showrama'), '').display;
	}
	else {var g = document.getElementById('showrama').currentStyle.display;}
	
	
	if (g == 'block') {
		resetuj_rama();
		for (i = 0; i < document.forms[0].typrama.length; i++) {
			if (document.forms[0].typrama[0].checked) {
				var j = 0;
				break;
			}
			if (document.forms[0].typrama[i].checked) {
				document.getElementById('kolorama' + [i]).style.display = 'inline';
				var j = i;
			}
		}
		for (i = 0; i < document.forms[0].format.length; i++) {
			if (document.forms[0].format[i].checked) {
				document.forms[0].suma_r.value = cena_formatu[j][i];
				sumuj();
			}
		}
	}
}

function resetuj_rama(){
	
	for (i = 1; i  < 3; i++ )
	{document.getElementById('kolorama' + i).style.display = 'none';}
		}



//wartosc kuriera
function przekaz_kurier() {
	document.forms[0].suma_k.value = document.forms[0].odbior.value;	
	sumuj();
	
	if (document.defaultView) {
    var g = document.defaultView.getComputedStyle(document.getElementById('adres'), '').display;
	}
	else {var g = document.getElementById('adres').currentStyle.display;}
	
	if (g == 'none') {document.getElementById('adres').style.display = 'block';}
	else {document.getElementById('adres').style.display = 'none';}
}


//sumowanie
function sumuj() {
	
	var sumanowa = parseInt(document.forms[0].suma_f.value) + parseInt(document.forms[0].suma_r.value) + parseInt(document.forms[0].suma_k.value);
	var sumastara = parseInt(document.forms[0].suma_c.value);
	if ((sumastara - sumanowa) > 0) {
		for (i = sumastara; i >= sumanowa; i--)
		{document.forms[0].suma_c.value = i;}

	}
	else if ((sumastara - sumanowa) < 0) {
		for (i = sumastara; i <= sumanowa; i++)
		{document.forms[0].suma_c.value = i;}
	}
//	document.forms[0].suma_c.value = sumanowa;

}

//do sprawdzenia formularza
function resetujalerty() {
 document.getElementById('brak_wymiar').style.display = 'none';
 document.getElementById('brak_adres').style.display = 'none';
 document.getElementById('brak_kontakt').style.display = 'none';
 document.getElementById('brak_emailnews').style.display = 'none';
}

function resetujalerty2() {
 document.getElementById('brak_adres').style.display = 'none';
 document.getElementById('brak_kontakt').style.display = 'none';
 document.getElementById('brak_emailnews').style.display = 'none';
 if (document.getElementById('brak_uwagispec')) {
 	document.getElementById('brak_uwagispec').style.display = 'none';
 }
}


function resetujalerty3() {
 document.getElementById('brak_adres').style.display = 'none';
 document.getElementById('brak_kontakt').style.display = 'none';
 document.getElementById('brak_emailnews').style.display = 'none';
 if (document.getElementById('brak_uwagispec')) {
 	document.getElementById('brak_uwagispec').style.display = 'none';
 }
}

//sprawdzenie formularza zdjec
//errorcode
function sprawdz_formularz()
{
	resetujalerty();
 		blad = 0;
	if (document.forms[0].format[3].checked) {
	 	if (document.forms[0].wlasny_1.value == 0 || document.forms[0].wlasny_2.value == 0) {
			document.getElementById('brak_wymiar').style.display = 'block';
			blad = 1;
		}
	}
     if (document.forms[0].odbior.value == 20 && document.forms[0].adres.value == 0) {
			document.getElementById('brak_adres').style.display = 'block';
			blad = 1;

	}
	if (document.forms[0].email.value == 0) {
			document.getElementById('brak_kontakt').style.display = 'block';
			blad = 1;
			
	}
   if (document.forms[0].newsletter.checked == true && document.forms[0].email.value == 0) {
	document.getElementById('brak_emailnews').style.display = 'block';
    blad = 1;
	}
	if (blad == 1) {return false;}
	else {
		document.forms[0].checker.value = 'checked';
		return true;}


}


//sprawdzenie formularz kazdy
//errorcode
function sprawdz_form()
{
	resetujalerty2();
 		blad = 0;
	if (document.forms[0].email.value == 0 && document.forms[0].tel.value == 0) {
			document.getElementById('brak_kontakt').style.display = 'block';
			blad = 1;
			
	}
   if (document.forms[0].newsletter.checked == true && document.forms[0].email.value == 0) {
	document.getElementById('brak_emailnews').style.display = 'block';
    blad = 1;
	}
	
	if (document.forms[0].uwagispec)
	{if (document.forms[0].uwagispec.value == 0) {
			document.getElementById('brak_uwagispec').style.display = 'block';
			blad = 1;}}
	else 	{
			if (document.forms[0].odbior.value == 15 && document.forms[0].adres.value == 0) {
			document.getElementById('brak_adres').style.display = 'block';
			blad = 1;}
			}
	
	if (blad == 1) {return false;}
	else {
		document.forms[0].checker.value = 'checked';
		return true;}
}




//pokaz / ukryj papier hint  == 'hidden' || 
function papier_hint(){
	if (document.defaultView) {
    var i = document.defaultView.getComputedStyle(document.getElementById('papier_hint'), '').visibility;
	}
	else {i = document.getElementById('papier_hint').currentStyle.visibility;}
	if (i == 'hidden') {
		document.getElementById('papier_hint').style.visibility = 'visible';
	}
	else {
		document.getElementById('papier_hint').style.visibility = 'hidden';
	}
}

	
//pokaz / ukryj rama hint
function rama_hint() {
	if (document.defaultView) {
		var i = document.defaultView.getComputedStyle(document.getElementById('rama_hint'), '').visibility;
	}
	else {i = document.getElementById('rama_hint').currentStyle.visibility;}
	if (i == 'hidden') {
		document.getElementById('rama_hint').style.visibility = 'visible';
 		document.getElementById('typ1').style.visibility = 'visible';
		d = document.getElementById('ramatyp').getElementsByTagName('li');
		for (i=0; i < d.length; i++) {d[i].style.color = 'red';}
		d[0].style.color = 'white';
		resetujpodtypy();
        document.getElementById('anty1').style.visibility = 'visible';
		var wyzszosc = document.getElementById('typ1');
		var nizszosc = wyzszosc.getElementsByTagName('li');
		for (var i=0; i<nizszosc.length;i++) {
 		nizszosc[i].style.color = 'red';
		nizszosc[0].style.color = 'white';
 }

	}
	else {
		document.getElementById('rama_hint').style.visibility = 'hidden';
		h = document.getElementById('typy').getElementsByTagName('div');
		for (i = 0; i < h.length; i++) {
		h[i].style.visibility = 'hidden';}
		
		x = document.getElementById('podtypy').getElementsByTagName('div');
		for (i = 0; i < x.length; i++) {
		x[i].style.visibility = 'hidden';}
		
	}
}





function pokazrama() {
	if (document.forms[0].rama.value == 'bezramy') {
	document.getElementById('showrama').style.display='none';
	a = document.forms[0].suma_r.value;
	document.forms[0].suma_r.value = 0;
	sumuj(); 	
	}
	else {
		document.getElementById('showrama').style.display='block';
		document.forms[0].suma_r.value = a;
		sumuj();
	}

}


function resetujpodtypy() {
 var wyzszosc3 = document.getElementById('podtypy');
 var nizszosc3 = wyzszosc3.getElementsByTagName('div');
 for (var i=0; i<nizszosc3.length;i++) {
 	nizszosc3[i].style.visibility = 'hidden';
	 }
}	
	
	
	
function rama_hint_typ (typ, obj) 
{
	
var wyzszosc2 = document.getElementById('typy');
var nizszosc2 = wyzszosc2.getElementsByTagName('div');
var wyzszosc4 = document.getElementById('typ' + typ);
var nizszosc4 = wyzszosc4.getElementsByTagName('li');

for (var i=0; i<nizszosc4.length;i++) {
	nizszosc4[i].style.color = 'red';
	}
	
for (var i=0; i<nizszosc2.length;i++) {
	nizszosc2[i].style.visibility = 'hidden';
	}
	
document.getElementById('typ' + typ).style.visibility = 'visible';
nizszosc4[0].style.color = 'white';
var wyzszosc = document.getElementById('ramatyp');
var nizszosc = wyzszosc.getElementsByTagName('li');
for (var i=0; i<nizszosc.length;i++) {
 	nizszosc[i].style.color = 'red';
 }
 obj.style.color = 'white';
 
    if (typ == '1') {var podtyp = 'anty1';}
	if (typ == '2') {var podtyp = 'alu1';}
	if (typ == '3') {var podtyp = 'dre1';}
	if (typ == '4') {var podtyp = 'pia1';}
	if (typ == '5') {var podtyp = 'szu1';}
	if (typ == '6') {var podtyp = 'bzu1';}
	resetujpodtypy();
	document.getElementById(podtyp).style.visibility = 'visible';

 
}



function kubek_hint() {
	if (document.defaultView) {
		var i = document.defaultView.getComputedStyle(document.getElementById('rama_hint'), '').visibility;
	}
	else {i = document.getElementById('rama_hint').currentStyle.visibility;}
	if (i == 'hidden') {
		document.getElementById('rama_hint').style.visibility = 'visible';
 		document.getElementById('typ1').style.visibility = 'visible';
		d = document.getElementById('ramatyp').getElementsByTagName('li');
		for (i=0; i < d.length; i++) {d[i].style.color = 'red';}
		d[0].style.color = 'white';
		var wyzszosc = document.getElementById('typ1');
		var nizszosc = wyzszosc.getElementsByTagName('li');
		for (var i=0; i<nizszosc.length;i++) {
 		nizszosc[i].style.color = 'red';
		nizszosc[0].style.color = 'white';
 }

	}
	else {
		document.getElementById('rama_hint').style.visibility = 'hidden';
		h = document.getElementById('typy').getElementsByTagName('div');
		for (i = 0; i < h.length; i++) {
		h[i].style.visibility = 'hidden';}
				
	}
}


function rama_kubek_typ (typ, obj) 
{
	
var wyzszosc2 = document.getElementById('typy');
var nizszosc2 = wyzszosc2.getElementsByTagName('div');
var wyzszosc4 = document.getElementById('typ' + typ);

for (var i = 0; i < nizszosc2.length; i++) {
	nizszosc2[i].style.visibility = 'hidden';
	document.getElementById('typ' + typ).style.visibility = 'visible';
}
var wyzszosc = document.getElementById('ramatyp');
var nizszosc = wyzszosc.getElementsByTagName('li');
for (var i=0; i<nizszosc.length;i++) {
 	nizszosc[i].style.color = 'red';
 }
 obj.style.color = 'white';
}




function showkolor(numer, typ, co) {
	if (typ == 'anty') {var typnr = 'typ1';}
	if (typ == 'alu') {var typnr = 'typ2';}
	if (typ == 'dre') {var typnr = 'typ3';}
	if (typ == 'pia') {var typnr = 'typ4';}
	if (typ == 'szu') {var typnr = 'typ5';}
	if (typ == 'bzu') {var typnr = 'typ6';}
 var wyzszosc = document.getElementById(typnr);
 var nizszosc = wyzszosc.getElementsByTagName('li');
 for (var i=0; i<nizszosc.length;i++) {
 	nizszosc[i].style.color = 'red';
 }
 co.style.color = 'white';
 resetujpodtypy();
 document.getElementById(typ + numer).style.visibility = 'visible';
}


function sprawdz_kontakt() {
	blad = 0;
	document.getElementById('brak_kontakt').style.display = 'none';
if (document.forms[0].email.value == 0) {
	document.getElementById('brak_kontakt').style.display = 'block';
	blad = 1;
	}
	if (blad == 1) {return false;}
	else {return true;}
}

function sprawdz_formularzyk(){
	resetujalerty2();
	blad = 0;
	if (document.forms[0].odbior.value == 20 && document.forms[0].adres.value == 0) {
		document.getElementById('brak_adres').style.display = 'block';
		blad = 1;
		
	}
	if (document.forms[0].email.value == 0) {
		document.getElementById('brak_kontakt').style.display = 'block';
		blad = 1;
		
	}
	if (document.forms[0].newsletter.checked == true && document.forms[0].email.value == 0) {
		document.getElementById('brak_emailnews').style.display = 'block';
		blad = 1;
	}
	if (blad == 1) {
		return false;
	}
	else {
		document.forms[0].checker.value = 'checked';
		return true;
	}
}

