function checkPassword(){
	var _new1 = document._changepassword.fcp_new1.value;
	var _new2 = document._changepassword.fcp_new2.value;
	if (_new1 == _new2) {
		return true;
	} else {
        alert("Nowe hasło różni się z jego potwierdzeniem.");
		return false;
	}
}
function getLab2(_select){
	document._product._p_lab2.options.length = 0;
	var choice = document._product._p_lab1;
    var _lab1_value = choice.options[choice.selectedIndex].value;
    var _lab1_name = choice.options[choice.selectedIndex].text;

    var _i = 0;
    var _i2s = -1;
	var _dsc = "";
	var _source = document._product._p_label;
	for(i=0;i<_source.length;i=i+1){
	  if(_source.item(i).value == _lab1_value) {
		_dsc = _source.options[i].text;
		_end = _dsc.indexOf("<",0);
		_start = _dsc.indexOf(">",0);
		_id = _dsc.substr(0,_end);
		_lab2 = _dsc.substr(_start+1,_dsc.length);
		if(_select == _id) {
          _i2s = _i;
			document._product._p_lab2.options[_i] = new Option(_lab2, _id);
		} else {
			document._product._p_lab2.options[_i] = new Option(_lab2, _id);
		}
		_i = _i + 1;
	  }
    }

    var _len = document._product._p_lab2.options.length;
    if((_i2s > -1) && (_i2s + 1== _len)){
        document._product._p_lab2.options[_len-1].selected = true;
    }
    if((_i2s > -1) && (_i2s + 1 != _len)){
        document._product._p_lab2.options[_i2s].selected = true;
    }
}

function getLab2_fp(_select){
	document._productfind.fp_lab2.options.length = 0;
	var choice = document._productfind.fp_lab1;
    var _lab1_value = choice.options[choice.selectedIndex].value;
    var _lab1_name = choice.options[choice.selectedIndex].text;
    var _i = 0;
    var _i2s = -1;
	var _dsc = "";
	var _source = document._productfind.fp_label;
	for(i=0;i<_source.length;i=i+1){
	  if(_source.item(i).value == _lab1_value) {
		_dsc = _source.options[i].text;
		_end = _dsc.indexOf("<",0);
		_start = _dsc.indexOf(">",0);
		_id = _dsc.substr(0,_end);
		
		_lab2 = _dsc.substr(_start+1,_dsc.length);
	
		if(_select == _id) {
          _i2s = _i;
			document._productfind.fp_lab2.options[_i] = new Option(_lab2, _id);
		} else {
			document._productfind.fp_lab2.options[_i] = new Option(_lab2, _id);
		}
		_i = _i + 1;
	  }
    }

    document._productfind.fp_lab2.options[_i] = new Option("", -1);
    var _len = document._productfind.fp_lab2.options.length;
    if((_i2s > -1) && (_i2s + 1== _len) && _select != -1){
        document._productfind.fp_lab2.options[_len-1].selected = true;
    }
    if((_i2s > -1) && (_i2s + 1 != _len) && _select != -1){
        document._productfind.fp_lab2.options[_i2s].selected = true;
    }
    if(_select == -1){
        document._productfind.fp_lab2.options[_i].selected = true;
    }

}

function getLab2_ff_88(_select){
	document._ff.ff_lab2.options.length = 0;
	var choice = document._ff.ff_lab1;
    var _lab1_value = choice.options[choice.selectedIndex].value;
    var _lab1_name = choice.options[choice.selectedIndex].text;
    var _i = 0;
    var _i2s = -1;
	var _dsc = "";
	var _source = document._ff.ff_label;

	for(i=0;i<_source.length;i=i+1){
	  if(_source.item(i).value == _lab1_value) {
		_dsc = _source.options[i].text;
		_end = _dsc.indexOf("<",0);
		_start = _dsc.indexOf(">",0);
		_id = _dsc.substr(0,_end);
		_lab2 = _dsc.substr(_start+1,_dsc.length);
		if(_select == _id) {
          _i2s = _i;
			document._ff.ff_lab2.options[_i] = new Option(_lab2, _id);
		} else {
			document._ff.ff_lab2.options[_i] = new Option(_lab2, _id);
		}
		_i = _i + 1;
	  }
    }

    document._ff.ff_lab2.options[_i] = new Option("", -1);
    var _len = document._ff.ff_lab2.options.length;
    if((_i2s > -1) && (_i2s + 1== _len) && _select != -1){
        document._ff.ff_lab2.options[_len-1].selected = true;
    }
    if((_i2s > -1) && (_i2s + 1 != _len) && _select != -1){
        document._ff.ff_lab2.options[_i2s].selected = true;
    }
    if(_select == -1){
        document._ff.ff_lab2.options[_i].selected = true;
    }

}

function getLab2_ff(_select){
    if (document.getElementById) {
        document.all["ff_lab2"].options.length = 0;
    } else {
        document._ff.ff_lab2.options.length = 0;
    }

	//var choice = document._ff.ff_lab1;
	var choice = "";
    if (document.getElementById) {
        choice = document.all["ff_lab1"];
    } else {
        choice = document._ff.ff_lab1;
    }
    var _lab1_value = choice.options[choice.selectedIndex].value;
    var _lab1_name = choice.options[choice.selectedIndex].text;
    var _i = 0;
    var _i2s = -1;
	var _dsc = "";
	//var _source = document._ff.ff_label;
	var _source = "";

    if (document.getElementById) {
        _source = document.all["ff_label"];
    } else {
        _source = document._ff.ff_label;
    }
	for(i=0;i<_source.length;i=i+1){
	  if(_source.item(i).value == _lab1_value) {
		_dsc = _source.options[i].text;
		_end = _dsc.indexOf("<",0);
		_start = _dsc.indexOf(">",0);
		_id = _dsc.substr(0,_end);
		_tmpLenght = _dsc.length;
		_lab2 = _dsc.substr(_start+1,_dsc.length);
		if(_select == _id) {
          _i2s = _i;
            if (document.getElementById) {
                document.all["ff_lab2"].options[_i] = new Option(_lab2, _id);
            } else {
                document._ff.ff_lab2.options[_i] = new Option(_lab2, _id);
            }
		} else {
            if (document.getElementById) {
                document.all["ff_lab2"].options[_i] = new Option(_lab2, _id);
            } else {
                document._ff.ff_lab2.options[_i] = new Option(_lab2, _id);
            }
		}
		_i = _i + 1;
	  }
    }

    var _len = 0;

    if (document.getElementById) {
        document.all["ff_lab2"].options[_i] = new Option("", -1);
        _len = document.all["ff_lab2"].options.length;
    } else {
        document._ff.ff_lab2.options[_i] = new Option("", -1);
        _len = document._ff.ff_lab2.options.length;
    }

    if((_i2s > -1) && (_i2s + 1== _len) && _select != -1){
        if (document.getElementById) {

            document.all["ff_lab2"].options[_len-1].selected = true;
        } else {
           document._ff.ff_lab2.options[_len-1].selected = true;
        }
    }

    if((_i2s > -1) && (_i2s + 1 != _len) && _select != -1){
        //document._ff.ff_lab2.options[_i2s].selected = true;
        if (document.getElementById) {

            document.all["ff_lab2"].options[_i2s].selected = true;
        } else {
           document._ff.ff_lab2.options[_i2s].selected = true;
        }
    }
    if(_select == -1){
        //document._ff.ff_lab2.options[_i].selected = true;

        if (document.getElementById) {
            document.all["ff_lab2"].options[_i].selected = true;
        } else {
           document._ff.ff_lab2.options[_i].selected = true;
        }

    }
}


function setColor(){
	document._product._p_kolor0.options.length = 0;
	document._product._p_kolor.value = "";

	var _kolor = "";
	var _kolorTab = "";
	var _source = document._product._p_kolor1;
	var _i = 0;
	for(i=0;i<_source.length;i=i+1){
		_kolor = _source.options[i].text;
		_kolorTab = _source.options[i].value;
		if(_source.options[i].selected){
			document._product._p_kolor0.options[_i] = new Option(_kolor, _kolorTab);
			document._product._p_kolor.value = document._product._p_kolor.value + _kolorTab + ",";
			_i = _i +1;
		}
	}
	var _t1 = "";
	var _t2 = "";

	if(_i>0){
		var _choice = document._product._p_kolor0;
		for(m=0;m<_choice.length;m=m+1){
			for(i=0;i<_source.length;i=i+1){
				_t1 = document._product._p_kolor0.options[m].text;
				_t2 = document._product._p_kolor1.options[i].text;
				//alert (_t1 + " " + _t2);
				if( _t1 == _t2) {
					document._product._p_kolor0.options[m].style.backgroundColor = document._product._p_kolor1.options[i].style.backgroundColor;
					//document._product._p_kolor0.options[m].style.color = document._product._p_kolor1.options[i].style.color;
					//alert ("asdf");
				}
			}
		}
	}
}
function setBrutto(){
    var _netto = document._product._p_netto.value;
    var choice = document._product._p_vat;
    var _vat = choice.options[choice.selectedIndex].value;
    if(!isNaN(_netto)) {
        document._product._p_brutto.value = eval(_netto) + (eval(_netto)/100)*eval(_vat);
    }
}

function checkKonto(){
    var _atrybut = document._konto._login.value;
    if(_atrybut == 0){
		alert ('Login - pole jest wymagane');
        return false;
    }
    _atrybut = document._konto._firm.value;
    if(_atrybut == 0){
		alert ('Nazwa firmy - pole jest wymagane');
        return false;
    }
    _atrybut = document._konto._nip.value;
    if(_atrybut == 0){
		alert ('NIP - pole jest wymagane');
        return false;
    }
    
    _atrybut = document._konto._street1.value;
    if(_atrybut == 0){
		alert ('Ulica, nr (adres firmy) - pole jest wymagane');
        return false;
    }
    
    _atrybut = document._konto._post1.value;
    if(_atrybut == 0){
		alert ('Miejscowość (adres firmy) - pole jest wymagane');
        return false;
    }

    _atrybut = document._konto._kod_pocztowy1.value;
    if(_atrybut == 0){
		alert ('Kod pocztowy (adres firmy) - pole jest wymagane');
        return false;
    }

    _atrybut = document._konto._name1.value;
    if(_atrybut == 0){
		alert ('Imię (osoba upoważniona  \r\ndo składania zamówień) - pole jest wymagane');
        return false;
    }
    
    _atrybut = document._konto._surname1.value;
    if(_atrybut == 0){
		alert ('Nazwisko (osoba upoważniona \r\ndo składania zamówień) - pole jest wymagane');
        return false;
    }
    
    _atrybut = document._konto._phone1.value;
    if(_atrybut == 0){
		alert ('Telefon stacjonarny (osoba upoważniona \r\ndo składania zamówień) - pole jest wymagane');
        return false;
    }
    
    _atrybut = document._konto._email1.value;
    if(_atrybut == 0){
		alert ('Adres email (osoba upoważniona \r\ndo składania zamówień) - pole jest wymagane');
        return false;
    }



}
function checkProduct(){
    var _atrybut = document._product._p_prodid.value;
    if(_atrybut == 0 || isNaN(_atrybut)){
		alert ('Produk ID - pole jest wymagane (liczba)');
        return false;
    }
    _atrybut = document._product._p_nazwa.value;
    if(_atrybut == 0 ){
		alert ('Nazwa produktu - pole jest wymagane');
        return false;
    }
    _atrybut = document._product._p_opis.value;
    if(_atrybut == 0 ){
		alert ('Opis produktu - pole jest wymagane');
        return false;
    }
    _atrybut = document._product._p_lab1.value;
    if(_atrybut == -1 ){
		alert ('Kategoria 1 - pole jest wymagane');
        return false;
    }
    _atrybut = document._product._p_netto.value;
    if(_atrybut == 0 || isNaN(_atrybut) ){
		alert ('Cena netto - pole jest wymagane (liczba)');
        return false;
    }

}

function my_counter(_c){
    var _color = _c.name.substr(0,3);
	var _what = _c.name.substr(3,3);
    var _len1 = _c.name.length-6;
	var _prodid = _c.name.substr(6,_len1);
	var _counter = _color.concat("cou");
	_counter = _counter.concat(_prodid);

	var _ile = 0;
    if (document.getElementById) {
        _ile=document.all[_counter].value;
    } else {
        _ile=document._wybrane_produkty.elements(_counter).value;
    }
	if(!isNaN(_ile)) {
		_ile = _ile - (_ile % 1);
		if(_ile<0) {
			_ile = ile * (-1);
		}
		if(_what == "add"){
            if (document.getElementById) {
                document.all[_counter].value = _ile + 1;
            } else {
                document._wybrane_produkty.elements(_counter).value = _ile + 1;
            }
		}
		if(_what == "min"){
			if(_ile > 1) {
                if (document.getElementById) {
                    document.all[_counter].value = _ile - 1;
                } else {
                    document._wybrane_produkty.elements(_counter).value = _ile - 1;
                }
			} else {
                if (document.getElementById) {
                    document.all[_counter].value = 0;
                } else {
                    document._wybrane_produkty.elements(_counter).value = 0;
                }
			}
		}
	} else {
        if (document.getElementById) {
            document.all[_counter].value = 0;
        } else {
            document._wybrane_produkty.elements(_counter).value = 0;
        }
	}
}


function my_counter_change(_c){
	var _ile = 0
    if (document.getElementById) {
        _ile = document.all[_c.name].value;
    } else {
        _ile = document._wybrane_produkty.elements(_c.name).value;
    }
    if(_ile == 0) {
      _ile = 0;
    }
	if(!isNaN(_ile)) {
		_ile = _ile - (_ile % 1);
		if(_ile<0) {
			_ile = _ile * (-1);
		}

        if (document.getElementById) {
            document.all[_c.name].value = _ile;
        } else {
            document._wybrane_produkty.elements(_c.name).value = _ile;
        }
	} else {
        if (document.getElementById) {
            document.all[_c.name].value = 0;
        } else {
            document._wybrane_produkty.elements(_c.name).value = 0;
        }
	}

}

function addparametr(_a){
    var _len1 = _a.name.length-4;
	var _prodid = _a.name.substr(4,_len1);
	var _prodi_base = "cou".concat(_prodid);

	var _link = "";
    if (document.getElementById) {
        _link = document.all[_a.name].href;
    } else {
        _link = document.links(_a.name).href;
    }
    _link = _link.concat("&_kolory=");

    var _tmpn = "";
    if (document.getElementById) {
        _tmpn = "cze".concat(_prodi_base);
        if(document.all[_tmpn] && document.all[_tmpn].value > 0) {
          _link = _link.concat("czerwony,");
          _link = _link.concat(document.all[_tmpn].value);
          _link = _link.concat(",");
        }
        _tmpn = "nie".concat(_prodi_base);
        if(document.all[_tmpn] && document.all[_tmpn].value > 0) {
          _link = _link.concat("niebieski,");
          _link = _link.concat(document.all[_tmpn].value);
          _link = _link.concat(",");
        }       
        _tmpn = "zie".concat(_prodi_base);
        if(document.all[_tmpn] && document.all[_tmpn].value > 0) {
          _link = _link.concat("zielony,");
          _link = _link.concat(document.all[_tmpn].value);
          _link = _link.concat(",");
        }
        _tmpn = "zol".concat(_prodi_base);
        if(document.all[_tmpn] && document.all[_tmpn].value > 0) {
          _link = _link.concat("zolty,");
          _link = _link.concat(document.all[_tmpn].value);
          _link = _link.concat(",");
        }
        _tmpn = "cza".concat(_prodi_base);
        if(document.all[_tmpn] && document.all[_tmpn].value > 0) {
          _link = _link.concat("czarny,");
          _link = _link.concat(document.all[_tmpn].value);
          _link = _link.concat(",");
        }
        _tmpn = "roz".concat(_prodi_base);
        if(document.all[_tmpn] && document.all[_tmpn].value > 0) {
          _link = _link.concat("rozowy,");
          _link = _link.concat(document.all[_tmpn].value);
          _link = _link.concat(",");
        }
        _tmpn = "bia".concat(_prodi_base);
        if(document.all[_tmpn] && document.all[_tmpn].value > 0) {
          _link = _link.concat("bialy,");
          _link = _link.concat(document.all[_tmpn].value);
          _link = _link.concat(",");
        }
        _tmpn = "fio".concat(_prodi_base);
        if(document.all[_tmpn] && document.all[_tmpn].value > 0) {
          _link = _link.concat("fioletowy,");
          _link = _link.concat(document.all[_tmpn].value);
          _link = _link.concat(",");
        }
        _tmpn = "bor".concat(_prodi_base);
        if(document.all[_tmpn] && document.all[_tmpn].value > 0) {
          _link = _link.concat("bordowy,");
          _link = _link.concat(document.all[_tmpn].value);
          _link = _link.concat(",");
        }
        _tmpn = "pom".concat(_prodi_base);
        if(document.all[_tmpn] && document.all[_tmpn].value > 0) {
          _link = _link.concat("pomaranczowy,");
          _link = _link.concat(document.all[_tmpn].value);
          _link = _link.concat(",");
        }
        _tmpn = "sre".concat(_prodi_base);
        if(document.all[_tmpn] && document.all[_tmpn].value > 0) {
          _link = _link.concat("srebrny,");
          _link = _link.concat(document.all[_tmpn].value);
          _link = _link.concat(",");
        }
        _tmpn = "tur".concat(_prodi_base);
        if(document.all[_tmpn] && document.all[_tmpn].value > 0) {
          _link = _link.concat("turkusowy,");
          _link = _link.concat(document.all[_tmpn].value);
          _link = _link.concat(",");
        }
        _tmpn = "zlo".concat(_prodi_base);
        if(document.all[_tmpn] && document.all[_tmpn].value > 0) {
          _link = _link.concat("zloty,");
          _link = _link.concat(document.all[_tmpn].value);
          _link = _link.concat(",");
        }
        _tmpn = "sza".concat(_prodi_base);
        if(document.all[_tmpn] && document.all[_tmpn].value > 0) {
          _link = _link.concat("szary,");
          _link = _link.concat(document.all[_tmpn].value);
          _link = _link.concat(",");
		  
		}
        _tmpn = "dym".concat(_prodi_base);
        if(document.all[_tmpn] && document.all[_tmpn].value > 0) {
          _link = _link.concat("dymny,");
          _link = _link.concat(document.all[_tmpn].value);
          _link = _link.concat(",");
		}
        _tmpn = "bez".concat(_prodi_base);
        if(document.all[_tmpn] && document.all[_tmpn].value > 0) {
          _link = _link.concat("bezbarwny,");
          _link = _link.concat(document.all[_tmpn].value);
          _link = _link.concat(",");
		  
        }
        _tmpn = "def".concat(_prodi_base);
        if(document.all[_tmpn] && document.all[_tmpn].value > 0) {
          _link = _link.concat("default,");
          _link = _link.concat(document.all[_tmpn].value);
          _link = _link.concat(",");
        }
    } else {
        _tmpn = _color_base.concat("czerwony");
        if(document._wybrane_produkty.elements(_tmpn) && document._wybrane_produkty.elements(_tmpn).checked == true) {
          _link = _link.concat("czerwony,");
        }
        _tmpn = _color_base.concat("niebieski");
        if(document._wybrane_produkty.elements(_tmpn) && document._wybrane_produkty.elements(_tmpn).checked == true) {
          _link = _link.concat("niebieski,");
        }
        _tmpn = _color_base.concat("zielony");
        if(document._wybrane_produkty.elements(_tmpn) && document._wybrane_produkty.elements(_tmpn).checked == true) {
          _link = _link.concat("zielony,");
        }
        _tmpn = _color_base.concat("zolty");
        if(document._wybrane_produkty.elements(_tmpn) && document._wybrane_produkty.elements(_tmpn).checked == true) {
          _link = _link.concat("zolty,");
        }
        _tmpn = _color_base.concat("czarny");
        if(document._wybrane_produkty.elements(_tmpn) && document._wybrane_produkty.elements(_tmpn).checked == true) {
          _link = _link.concat("czarny,");
        }
        _tmpn = _color_base.concat("rozowy");
        if(document._wybrane_produkty.elements(_tmpn) && document._wybrane_produkty.elements(_tmpn).checked == true) {
          _link = _link.concat("rozowy,");
        }
        _tmpn = _color_base.concat("bialy");
        if(document._wybrane_produkty.elements(_tmpn) && document._wybrane_produkty.elements(_tmpn).checked == true) {
          _link = _link.concat("bialy,");
        }
        _tmpn = _color_base.concat("fioletowy");
        if(document._wybrane_produkty.elements(_tmpn) && document._wybrane_produkty.elements(_tmpn).checked == true) {
          _link = _link.concat("fioletowy,");
        }
        _tmpn = _color_base.concat("bordowy");
        if(document._wybrane_produkty.elements(_tmpn) && document._wybrane_produkty.elements(_tmpn).checked == true) {
          _link = _link.concat("bordowy,");
        }
        _tmpn = _color_base.concat("pomaranczowy");
        if(document._wybrane_produkty.elements(_tmpn) && document._wybrane_produkty.elements(_tmpn).checked == true) {
          _link = _link.concat("pomaranczowy,");
        }
        _tmpn = _color_base.concat("srebrny");
        if(document._wybrane_produkty.elements(_tmpn) && document._wybrane_produkty.elements(_tmpn).checked == true) {
          _link = _link.concat("srebrny,");
        }
        _tmpn = _color_base.concat("turkusowy");
        if(document._wybrane_produkty.elements(_tmpn) && document._wybrane_produkty.elements(_tmpn).checked == true) {
          _link = _link.concat("turkusowy,");
        }
        _tmpn = _color_base.concat("zloty");
        if(document._wybrane_produkty.elements(_tmpn) && document._wybrane_produkty.elements(_tmpn).checked == true) {
          _link = _link.concat("zloty,");
        }
        _tmpn = _color_base.concat("szary");
        if(document._wybrane_produkty.elements(_tmpn) && document._wybrane_produkty.elements(_tmpn).checked == true) {
          _link = _link.concat("szary,");
        }
		_tmpn = _color_base.concat("dymny");
        if(document._wybrane_produkty.elements(_tmpn) && document._wybrane_produkty.elements(_tmpn).checked == true) {
          _link = _link.concat("dymny,");
        }
		_tmpn = _color_base.concat("bezbarwny");
        if(document._wybrane_produkty.elements(_tmpn) && document._wybrane_produkty.elements(_tmpn).checked == true) {
          _link = _link.concat("bezbarwny,");
        }
    }
    if (document.getElementById) {
        document.all[_a.name].href = _link;
    } else {
        document.links(_a.name).href =_link;
    }
    
}

function myPrint(_myVar){
    page="koszyk_print.php?view_koszyk_id=" + _myVar;
	properties = "width=700,height=600,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes";
	okno=window.open(page,'HEXAGON',properties);
}

function myPrintView(_myVar){
    page="koszyk_print_view.php?view_koszyk_id=" + _myVar;
	properties = "width=700,height=600,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes";
	okno=window.open(page,'HEXAGON',properties);
}



