// JavaScript Document
function pokaz(id) {
var d = document.getElementById(id);
if (d) {d.style.display='block';}
}

function ukryj(id){
var d = document.getElementById(id);
if (d) {d.style.display='none';}
}


function MM_swapImgRestore() { //v3.0
 var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
 var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
 var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
 if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
function MM_swapImage() { //v3.0
 var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
 if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function MM_findObj(n, d) { //v4.01
 var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
 d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
 if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
 for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
 if(!x && d.getElementById) x=d.getElementById(n); return x;
}



function dodaj_dokoszyka() {
var formularz= document.forms['formularz'];
var oki= false;
	for(i=0; i<formularz.elements.length; i++){
		if(formularz.elements[i].name.substring(0,13) == "rozmiar_kolor"){
			if(formularz.elements[i].selectedIndex > 0){
					formularz.elements[i+1].style.background = "#ffffff";
					oki=true;
		}
	}
	}
  if(oki==true)
  {
    document.forms['formularz'].submit();
  }
  else
  {
    alert('Proszę wybrać rozmiar i kolor przynajmniej dla jednego produktu');
  }
}

function dodaj_doulubionych() {
var formularz= document.forms['formularz'];
var oki= false;
	for(i=0; i<formularz.elements.length; i++){
		if(formularz.elements[i].name.substring(0,13) == "rozmiar_kolor"){
			if(formularz.elements[i].selectedIndex > 0){
					formularz.elements[i+1].style.background = "#ffffff";
					oki=true;
		}
	}
	}
  if(oki==true)
  {
	document.forms['formularz'].action='favourite.php';
    document.forms['formularz'].submit();
  }
  else
  {
    alert('Proszę wybrać rozmiar i kolor przynajmniej dla jednego produktu');
  }
}

function check_zaloz(f){
var blad=false;
var tekst='';

if (f.email.value=='') {
	tekst= tekst + "Nie podałeś/aś swojego adresu email\n";
	blad=true;
}
if((f.email.value=='')||(f.email.value.indexOf(".") < 0) ||(f.email.value.indexOf("@") < 0)){
	tekst= tekst + "Błędnie podałeś/aś adres email\n";
	blad=true;
}

if (f.haslo.value=='') {
	tekst= tekst + "Nie podałeś/aś swojego hasła\n";
	blad=true;
}
else{
if (f.haslo.value!=f.rehaslo.value) {
	tekst= tekst + "Podane hasła nie posują do siebie!\n";
	blad=true;
}
}


if (f.imie.value=='') {
	tekst= tekst + "Nie podałeś/aś imienia\n";
	blad=true;
}

if (f.nazwisko.value=='') {
	tekst= tekst + "Nie podałeś/aś nazwiska\n";
	blad=true;
}

if (f.ulica.value=='') {
	tekst= tekst + "Nie podałeś/aś nazwy ulicy\n";
	blad=true;
}

if (f.kod.value=='') {
	tekst= tekst + "Nie podałeś/aś kodu pocztowego\n";
	blad=true;
}
if (f.miejscowosc.value=='') {
	tekst= tekst + "Nie podałeś/aś nazwy miejscowości\n";
	blad=true;
}
if (f.tel.value=='') {
	tekst= tekst + "Nie podałeś/aś telefonu kontaktowego\n";
	blad=true;
}
if (f.akcept.checked==false) {
	tekst= tekst + "Nie zaakceptowałeś/aś regulaminu sklepu www.dlazmyslow.pl oraz nie zgodziłeś/aś się na przetwarzanie danych osobowych\n";
	blad=true;
}

if(blad)
{
alert('Wystąpiły błędy podczas wypełniania formularza:\n---------------------------------------------------------\n\n'+tekst);
return false;
}
else  {
	return true;
}
}




//

var PlnPayTypeArray = new Array();

function PlnDrawSelect() {
	document.write('<select name="pay_type">');
	document.write('<option value="">-- wybierz rodzaj płatności --</option>');
	if ( PlnPayTypeArray ) {
		for ( var i = 0; i < PlnPayTypeArray.length; i++ ) {
			if ( PlnPayTypeArray[i].enable == 'true'  ) {
				document.write('<option value="' + PlnPayTypeArray[i].type + '">' + PlnPayTypeArray[i].name + '</option>');
			}
		}
	}
	document.write('</select>');
}

function PlnDrawRadio() {
	if ( PlnPayTypeArray ) {
		for ( var i = 0; i < PlnPayTypeArray.length; i++ ) {
			document.write('<input type="radio" name="pay_type" value="' + PlnPayTypeArray[i].type + '"' + (PlnPayTypeArray[i].enable != 'true' ? ' disabled' : '') + '>' + PlnPayTypeArray[i].name + '<br />');
		}
	}
}

function PlnSel(i) {
	if (document.getElementById && !document.all && document.getElementById(i)){ 
    	document.getElementById(i).checked=true;
 	}
	if (document.all && document.all[i]){
    	document.all[i].checked=true;
  }
}

function PlnDrawRadioImg(colls) {
	if ( !colls ) colls = 4;
	if ( PlnPayTypeArray ) {
		var c = 1;
		document.write('<table border="0" cellpadding="8" cellspacing="8"><tr>');
		for ( var i = 0; i < PlnPayTypeArray.length; i++ ) {
			if ( c > colls ) {
				document.write('</tr><tr>'); c = 1;
			}
			document.write('<td align="center"><table border="0" cellpadding="0" cellspacing="0"><tr><td><input id="PlnRI' + i + '" type="radio" name="pay_type" value="' + PlnPayTypeArray[i].type + '"' + (PlnPayTypeArray[i].enable != 'true' ? ' disabled' : '') + '></td>');
			document.write('<td align="center">');
			if ( PlnPayTypeArray[i].enable == 'true' ) {
				document.write('<a href="javascript:PlnSel(\'PlnRI' + i + '\')">');
			}
			document.write('<img src="' + PlnPayTypeArray[i].img + '" border="0" align="center">');
			if ( PlnPayTypeArray[i].enable == 'true' ) {
				document.write('</a>');
			}
			document.write('<br />' + PlnPayTypeArray[i].name + '</tr></td></table></td>');
			c++;
		}
		if ( c <= colls ) {			
			document.write('<td colspan="' + (colls - c + 1)  + '">&nbsp;</td>');
		}
		document.write('</tr></table>');
	}
}

function PlnPayType(type, name, enable, img, min, max) {
	this.type = type;
	this.name = name;
	this.enable = enable;
	this.img = img;
	this.min = min;
	this.max = max;
}


PlnPayTypeArray[0] = new PlnPayType('m', 
	'mBank',
	'true',
	'https://www.platnosci.pl/static/images/paytype/on-m.gif',
	'0.5',
	'999999.99');

PlnPayTypeArray[1] = new PlnPayType('n', 
	'Multibank',
	'true',
	'https://www.platnosci.pl/static/images/paytype/on-n.gif',
	'0.5',
	'999999.99');

PlnPayTypeArray[2] = new PlnPayType('w', 
	'BZ WBK',
	'true',
	'https://www.platnosci.pl/static/images/paytype/on-w.gif',
	'0.5',
	'999999.99');

PlnPayTypeArray[3] = new PlnPayType('o', 
	'Pekao SA',
	'true',
	'https://www.platnosci.pl/static/images/paytype/on-o.gif',
	'0.5',
	'999999.99');

PlnPayTypeArray[4] = new PlnPayType('h', 
	'BPH',
	'true',
	'https://www.platnosci.pl/static/images/paytype/on-h.gif',
	'0.5',
	'999999.99');

PlnPayTypeArray[5] = new PlnPayType('i', 
	'Inteligo',
	'true',
	'https://www.platnosci.pl/static/images/paytype/on-i.gif',
	'0.5',
	'999999.99');

PlnPayTypeArray[6] = new PlnPayType('d', 
	'Nordea',
	'true',
	'https://www.platnosci.pl/static/images/paytype/on-d.gif',
	'0.5',
	'999999.99');

PlnPayTypeArray[7] = new PlnPayType('p', 
	'iPKO BP',
	'true',
	'https://www.platnosci.pl/static/images/paytype/on-p.gif',
	'0.5',
	'999999.99');

PlnPayTypeArray[8] = new PlnPayType('g', 
	'ING',
	'true',
	'https://www.platnosci.pl/static/images/paytype/on-g.gif',
	'0.5',
	'999999.99');

PlnPayTypeArray[9] = new PlnPayType('l', 
	'LUKAS Bank',
	'true',
	'https://www.platnosci.pl/static/images/paytype/on-l.gif',
	'0.5',
	'999999.99');

PlnPayTypeArray[10] = new PlnPayType('wr', 
	'Raiffeisen Bank',
	'true',
	'https://www.platnosci.pl/static/images/paytype/on-wr.gif',
	'0.5',
	'999999.99');

PlnPayTypeArray[11] = new PlnPayType('wm', 
	'Millennium',
	'true',
	'https://www.platnosci.pl/static/images/paytype/on-wm.gif',
	'0.5',
	'999999.99');

PlnPayTypeArray[12] = new PlnPayType('wg', 
	'BGŻ',
	'true',
	'https://www.platnosci.pl/static/images/paytype/on-wg.gif',
	'0.5',
	'999999.99');

PlnPayTypeArray[13] = new PlnPayType('wk', 
	'Kredyt Bank',
	'true',
	'https://www.platnosci.pl/static/images/paytype/on-wk.gif',
	'0.5',
	'999999.99');

PlnPayTypeArray[14] = new PlnPayType('wp', 
	'Polbank',
	'true',
	'https://www.platnosci.pl/static/images/paytype/on-wp.gif',
	'0.5',
	'999999.99');

PlnPayTypeArray[15] = new PlnPayType('wc', 
	'Citi Handlowy',
	'true',
	'https://www.platnosci.pl/static/images/paytype/on-wc.gif',
	'0.5',
	'999999.99');

PlnPayTypeArray[16] = new PlnPayType('wd', 
	'Deutsche Bank',
	'true',
	'https://www.platnosci.pl/static/images/paytype/on-wd.gif',
	'0.5',
	'999999.99');

PlnPayTypeArray[17] = new PlnPayType('wi', 
	'Getin Bank',
	'true',
	'https://www.platnosci.pl/static/images/paytype/on-wi.gif',
	'0.5',
	'999999.99');

PlnPayTypeArray[18] = new PlnPayType('wn', 
	'Invest-Bank',
	'true',
	'https://www.platnosci.pl/static/images/paytype/on-wn.gif',
	'0.5',
	'999999.99');

PlnPayTypeArray[19] = new PlnPayType('wy', 
	'Bank Pocztowy',
	'true',
	'https://www.platnosci.pl/static/images/paytype/on-wy.gif',
	'0.5',
	'999999.99');

PlnPayTypeArray[20] = new PlnPayType('c', 
	'Karta Kredytowa',
	'true',
	'https://www.platnosci.pl/static/images/paytype/on-c.gif',
	'1.0',
	'10000.0');

PlnPayTypeArray[21] = new PlnPayType('b', 
	'Przelew bankowy',
	'false',
	'https://www.platnosci.pl/static/images/paytype/on-b.gif',
	'0.5',
	'999999.99');

PlnPayTypeArray[22] = new PlnPayType('u', 
	'Eurobank',
	'true',
	'https://www.platnosci.pl/static/images/paytype/on-u.gif',
	'0.5',
	'999999.99');

PlnPayTypeArray[23] = new PlnPayType('ab', 
	'Alior Bank',
	'true',
	'https://www.platnosci.pl/static/images/paytype/on-ab.gif',
	'0.5',
	'999999.99');

PlnPayTypeArray[24] = new PlnPayType('me', 
	'Meritum Bank',
	'true',
	'https://www.platnosci.pl/static/images/paytype/on-me.gif',
	'0.5',
	'999999.99');




