<!-- <![CDATA[

function reloadAjaxData(boxik,label_id){
	var adres = "zawartosc/" + boxik + ".php?lang=" + document.getElementById("lang_js").value;

	advAJAX.get({
    url: 'lib/php/get_label.php?lang=' + document.getElementById("lang_js").value + '&dzial_url='+label_id,
    onSuccess : function(obj) {document.getElementById("ajax_label").innerHTML = obj.responseText;}
  });

	if (boxik == 'ulsugi' || boxik == 'glowna') {
		document.getElementById("box_wysyp").className='box_wysyp_gl';
	}
	else {
		document.getElementById("box_wysyp").className='box_wysyp_st box_wysyp_';
	}
	document.getElementById("box_wysyp").innerHTML = '<br />Data base conected - loading data ...<br /><br /><br />';
	advAJAX.get({
    url: adres,
    onSuccess : function(obj) {
			document.getElementById("box_wysyp").innerHTML = obj.responseText;
     }
  });
}

function ladujFlasz(urlStr,f_width,f_height,backGround,zmienne) {
  var hasRightVersion = DetectFlashVer(requiredMajorVersion, requiredMinorVersion, requiredRevision);
  if(hasRightVersion){
    var tmp = 	'<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="'+f_width+'" height="'+f_height+'" id="index" align="middle">'
              + '<param name="allowScriptAccess" value="sameDomain" />'
              + '<param name="movie" value="'+urlStr+'.swf?'+zmienne+'"/>'
              + '<param name="menu" value="false" />'
              + '<param name="quality" value="high" />';
    if (backGround != undefined && backGround != 'transparent') {tmp += '<param name="bgcolor" value="'+backGround+'" />';}
    else {tmp += '<param name="wmode" value="transparent"/>';}
    tmp += '<embed src="'+urlStr+'.swf?'+zmienne+'" quality="high" ';
    if (backGround != undefined && backGround != 'transparent') {tmp += 'bgcolor="'+backGround+'" ';}
    else {tmp += 'wmode="transparent"';}
    tmp += 'width="'+f_width+'" height="'+f_height+'" name="index" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" />'
        + '</object>';
    document.write(tmp);
  }
  else {
    var alternateContent = '<a href="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash"><img src="'+urlStr+'.png" style="width: "'+f_width+'"px; height: "'+f_height+'"px;" alt="'+urlStr+'" title="'+urlStr+'" border="0"/></a>';
    document.write(alternateContent);
  }
}


function nowe_okno(url,w,h) {
  var opcje = 'left=50,top=20, menubar=no, toolbar=no, location=no, directories=no, status=no, scrollbars=yes, resizable=yes, fullscreen=no, channelmode=no, width='+w+', height='+h+'';
  new_window = window.open( url ,'popup', opcje);
  if (window.focus) {new_window.focus();}
}

function sprawdz_cechy(form_name) {
  var i = 0;
  var flaga = true;
  while (document.getElementById('select_cecha_' + i) && flaga) {
    var select_cechy = document.getElementById('select_cecha_' + i);
    if (select_cechy.value == 0) {
      alert('Wybierz cechę');
      select_cechy.style.background = '#F4FFD4';
      flaga = false;
    }
    i++;
  }

  if (flaga) {document.forms[form_name].submit();}
}

function usuwanie(newURL) {
	if (confirm('Czy napewno usun±ć ?!')) {location.href=newURL;}
}

function go_url(newURL, new_window) {
	if (new_window) {nowe_okno(newURL, 760, 600);}
	else {location.href=newURL;}
}

function usun_z_koszyka(form_name, id_koszyk_produkty, message) {
  if (document.getElementById(form_name)) {
    if (window.confirm(message)) {
      document.getElementById('id_koszyk_produkty').value = id_koszyk_produkty;
      document.getElementById('akcja_koszyka').value = 'usun';
      document.getElementById(form_name).submit();
      return true;
    }
  }
  else {alert('Error forms !?');}
}

function aktualizuj_koszyk(form_name) {
  alert(form_name);
  if (document.getElementById(form_name)) {
    document.getElementById('akcja_koszyka').value = 'set_ilosc';
    document.getElementById(form_name).submit();
    return true;
  }
  else {alert('Error forms !?');}
}

function usun_adres_dodatkowy(form_name, id_user_adres, message) {
  if (document.getElementById(form_name)) {
    
    if (window.confirm(message)) {
      document.getElementById('id_user_adres').value = id_user_adres;
      zmiana_akcji(form_name, 'usun_adres');
    }
  }
  else {alert('Error forms !?'); return false;}
}

function sprawdz_ile_adresow(message, max_adresow) {
  if (document.getElementById('ilosc_adresow').value > max_adresow-1) {
    message+=max_adresow;
    alert(message);
  }
  else {
    location.href='index.php?c=moje_konto&go=add_adres';
  }
}

function change_adres() {
  var tmp = '';
  adres_dostawy = document.getElementById("adres_dostawy");

  for (var i = 0; i < adres_dostawy.length; i++) {
    id_adres_activ = adres_dostawy.options[i].selected;
    id_adres = adres_dostawy.options[i].value;

    tmp += "id_adres: " + id_adres + ', ';
    if (id_adres_activ) {document.getElementById(id_adres).style.display = 'block';}
    else {document.getElementById(id_adres).style.display = 'none';}
  }
}

function set_adres(i, typ_adresu) {
  if (typ_adresu == 'faktura') {
    clear_form_style('faktura_firma_osoba'); document.getElementById('faktura_firma_osoba').value = document.getElementById('faktura_nazwisko_'+i).innerHTML + ' ' + document.getElementById('faktura_imie_'+i).innerHTML;
    clear_form_style('faktura_adres'); document.getElementById('faktura_adres').value = document.getElementById('faktura_adres_'+i).innerHTML;
    clear_form_style('faktura_kod_poczt'); document.getElementById('faktura_kod_poczt').value = document.getElementById('faktura_kod_'+i).innerHTML;
    clear_form_style('faktura_miasto'); document.getElementById('faktura_miasto').value = document.getElementById('faktura_miasto_'+i).innerHTML;
    clear_form_style('faktura_nip'); document.getElementById('faktura_nip').value = document.getElementById('faktura_nip_'+i).innerHTML;
  }
  else if (typ_adresu == 'dostawa') {
    clear_form_style('wysylka_nazwisko_imie'); document.getElementById('wysylka_nazwisko_imie').value = document.getElementById('wysylka_nazwisko_'+i).innerHTML + ' ' + document.getElementById('wysylka_imie_'+i).innerHTML;
    clear_form_style('wysylka_adres'); document.getElementById('wysylka_adres').value = document.getElementById('wysylka_adres_'+i).innerHTML;
    clear_form_style('wysylka_kod'); document.getElementById('wysylka_kod').value = document.getElementById('wysylka_kod_'+i).innerHTML;
    clear_form_style('wysylka_miasto'); document.getElementById('wysylka_miasto').value = document.getElementById('wysylka_miasto_'+i).innerHTML;
  }
}

function set_waluta(id_waluty, kurs, symbol_l, symbol_p, podzial_dziesietny, podzial_tys) {
  document.getElementById('id_waluty').value = id_waluty;
  document.getElementById('kurs_waluty').value = kurs;
  document.getElementById('symbol_l').value = symbol_l;
  document.getElementById('symbol_p').value = symbol_p;
  document.getElementById('podzial_dziesietny').value = podzial_dziesietny;
  document.getElementById('podzial_tys').value = podzial_tys;
  document.getElementById('form_waluty').submit();
}

function set_jezyk(id_jezyka) {
  document.getElementById('lang').value = id_jezyka;
  document.getElementById('form_jezyki').submit();
}

function set_tpl(id_tpl) {
  document.getElementById('tpl').value = id_tpl;
  document.getElementById('form_tpl').submit();
}

function display_element(id, akcja) {
  switch (akcja) {
    case 'block': if (document.getElementById) {document.getElementById(id).style.display = 'block';}
                  else if (document.all) {document.all[id].style.display = 'block';}
                  break;
    case 'none':  if (document.getElementById) {document.getElementById(id).style.display = 'none';}
                  else if (document.all) {document.all[id].style.display = 'none';}
                  break;
	  default :     if (document.getElementById) {
	                  if (document.getElementById(id).style.display == 'block') {document.getElementById(id).style.display = 'none';}
	                  else {document.getElementById(id).style.display = 'block';}
	                }
	                else if (document.all) {
	                  if (document.all[id].style.display == 'block') {document.all[id].style.display = 'none';}
	                  else {document.all[id].style.display = 'block';}
                  }
	}
}

function komunikaty(komunikat, form) {
  if (komunikat) {alert(komunikat);}
  else {document.forms[form].submit();}
}

function sprawdz_znak(numeryczne, max_lenght, pole_value, pole_name) {
  // sposub użycia
  // onKeyUp="sprawdz_znak(true, 0, this.value, this.name)"

  var tmp=0;
  var i=0;
  var wynik='';
  str = new String();

  var dobrytext = /^[0-9]$/i;

  if (numeryczne) {
    str = pole_value;
    while (str.charAt(i)) {
      tmp = str.charAt(i);
      if (dobrytext.test(tmp)) {wynik = wynik + tmp;}
      i++;
    }
    str = wynik;
  }
  else {str = pole_value;}

  i=0; wynik='';

  if (max_lenght > 0) {
    for (j=0; i < max_lenght; i++) {
      tmp = str.charAt(i);
      wynik = wynik + tmp;
    }
    document.getElementById(pole_name).value = wynik;
  }
  else {
    document.getElementById(pole_name).value = str;
  }
}

function nowy_element(element_html, type, src, class_name, name, id, value, display) {
  var element = document.createElement(element_html);
  if (type) {element.type = type;}
  if (src) {element.setAttribute('src', src);}
  if (class_name) {element.className = class_name;}
  if (name) {element.name = name;}
  if (id) {element.id = id;}
  if (value) {element.value = value;}
  if (display) {element.style.display = display;}
  return element;
}

function sort_szukaj(form_name, by) {
  document.getElementById('s').value=by;
  document.getElementById(form_name).submit();
}



// --- globalne zmienne uzywane przez funkcję user_rodzaj_change() ---
  var activ_rodzaj = 'osoba';
  var p2_1, p2_2, p2_3, p3_1, p3_2, p3_3;
  var p7_1, p7_2, p7_3, p7_4, p7_5, p7_6, p8_1, p8_2, p8_3;
// -------------------------------------------------------------------

function user_rodzaj_change(zmien_na, dir_tpl) {
  
  // deklaracja pul formularza
  // np. parent_0 to pierwszy div trzymający grupe na ktorej się operuje.
  var parent_2=document.getElementById('pole_2');
  var parent_3=document.getElementById('pole_3');
  var parent_7=document.getElementById('pole_7').firstChild;
  var parent_8=document.getElementById('pole_8');
  var pole_imie=document.getElementById('imie');
  var pole_nazwisko=document.getElementById('nazwisko');
  var pole_nip=document.getElementById('nip');
  var pole_nazwafirmy=document.getElementById('nazwa_firmy');
  
  if (zmien_na=='firma' && activ_rodzaj=='osoba') { // zmiana na firme
    clear_form_style('imie'); // wyczyszczenie pola imie
    clear_form_style('nazwisko'); // wyczyszczenie pola nazwisko
    // usuniecie niepotrzebnych pul z diva i zapamiętanie ich w zmiennej
      p2_1 = parent_2.removeChild(document.getElementById('pole_wymagane_1')); 
      p2_2 = parent_2.removeChild(document.getElementById('imie_wymagane'));
      p2_3 = parent_2.removeChild(document.getElementById('id_info_img_2'));
      p3_1 = parent_3.removeChild(document.getElementById('pole_wymagane_2'));
      p3_2 = parent_3.removeChild(document.getElementById('nazwisko_wymagane'));
      p3_3 = parent_3.removeChild(document.getElementById('id_info_img_3'));
    // -----------------------------------------------------------------
    
    // wyczyszczenie zdarzeń dla usuniętych pul
      pole_imie.onkeydown = '';
      pole_nazwisko.onkeydown = '';
      pole_imie.onfocus = '';
      pole_nazwisko.onfocus = '';
    // ----------------------------------------
    
    // usunięcie filtra sprawdzającego dla nipu, po to żeby dodac pola do obsługi wymaganego pola
    // puźniej zostaną dodane spowrotem
      p7_4 = parent_7.removeChild(document.getElementById('nip_cosprawdz'));
      p7_5 = parent_7.removeChild(document.getElementById('info_pytajnik_3'));
      p7_6 = parent_7.removeChild(document.getElementById('nip_sprawdz'));
    // -------------------------------------------------------------------------------------------
    
    // utworzenie elementów do obsługi pul wymaganych nipu i nazwy firmy
      if (!p7_1) {p7_1 = nowy_element('input', 'hidden', false, false, 'pole_wymagane_1', 'pole_wymagane_1', 'nip', 'none');}
      if (!p7_2) {p7_2 = nowy_element('input', 'hidden', false, false, 'nip_wymagane', 'nip_wymagane', '0', 'none');}
      if (!p7_3) {p7_3 = nowy_element('img', false, 'template/' + dir_tpl + 'img/form/info_wymagane.gif', 'info_r', 'id_info_img_2', 'id_info_img_2', false);}
      
      if (!p8_1) {p8_1 = nowy_element('input', 'hidden', false, false, 'pole_wymagane_2', 'pole_wymagane_2', 'nazwa_firmy', 'none');}
      if (!p8_2) {p8_2 = nowy_element('input', 'hidden', false, false, 'nazwa_firmy_wymagane', 'nazwa_firmy_wymagane', '0', 'none');}
      if (!p8_3) {p8_3 = nowy_element('img', false, 'template/' + dir_tpl + 'img/form/info_wymagane.gif', 'info_r', 'id_info_img_3', 'id_info_img_3', false);}
    // -----------------------------------------------------------------
    
    // przypisanie odpowiednich zdarzeń do pul (przypisanie inną metodą w zależności od przeglądarki)
      if (navigator.appName == 'Microsoft Internet Explorer') { // dla MSIE
        pole_nip.onkeydown = ''; 
        pole_nip.onkeydown = function () {if (this.form.nip_wymagane.value == 1 || this.form.nip_sprawdz.value == 1){clear_form_style('nip');}}
        pole_nazwafirmy.onkeydown = function () {if (this.form.nazwa_firmy_wymagane.value==1){clear_form_style('nazwa_firmy');}};
        pole_nazwafirmy.onfocus = function () {clear_form_style('nazwa_firmy');};
        p7_3.onmouseover = function () {on_komentarz(this, event, USER_LIB_POLE_WYMAGANE_JS);}
        p8_3.onmouseover = function () {on_komentarz(this, event, USER_LIB_POLE_WYMAGANE_JS);}
      }
      else { // dla innych przeglądarek
        pole_nip.onkeydown = '';
        pole_nip.setAttribute('onkeydown', "if (this.form.nip_wymagane.value == 1 || this.form.nip_sprawdz.value == 1){clear_form_style('nip');}");
        pole_nazwafirmy.setAttribute('onkeydown', "if (this.form.nazwa_firmy_wymagane.value==1){clear_form_style('nazwa_firmy');}");
        pole_nazwafirmy.setAttribute('onfocus', "clear_form_style('nazwa_firmy')");
        p7_3.setAttribute('onmouseover', 'on_komentarz(this, event, \'' + USER_LIB_POLE_WYMAGANE_JS + '\')');
        p8_3.setAttribute('onmouseover', 'on_komentarz(this, event, \'' + USER_LIB_POLE_WYMAGANE_JS + '\')');
      }
    // ----------------------------------------------------------------------------------------------
    
    // dodanie potrzebnych pul utworzonych wcześniej do odpowiedniego diva
      parent_7.appendChild(p7_1); parent_7.appendChild(p7_2); parent_7.appendChild(p7_3);
      parent_7.appendChild(p7_4); parent_7.appendChild(p7_5); parent_7.appendChild(p7_6);
      parent_8.appendChild(p8_1); parent_8.appendChild(p8_2); parent_8.appendChild(p8_3);
    // -------------------------------------------------------------------
    
    activ_rodzaj='firma'; // zmiana zmiennej sterującej na aktualny stan
  }
  else if (zmien_na=='osoba' && activ_rodzaj=='firma') { // zmiana na osobę
    clear_form_style('nip'); // wyczyszczenie pola nip
    clear_form_style('nazwa_firmy'); // wyczyszczenie pola nazwa_firmy
    // usuniecie niepotrzebnych pul z diva i zapamiętanie ich w zmiennej
      p7_1 = parent_7.removeChild(document.getElementById('pole_wymagane_1'));
      p7_2 = parent_7.removeChild(document.getElementById('nip_wymagane'));
      p7_3 = parent_7.removeChild(document.getElementById('id_info_img_2'));
      p8_1 = parent_8.removeChild(document.getElementById('pole_wymagane_2'));
      p8_2 = parent_8.removeChild(document.getElementById('nazwa_firmy_wymagane'));
      p8_3 = parent_8.removeChild(document.getElementById('id_info_img_3'));
    // -----------------------------------------------------------------
    
    // wyczyszczenie zdarzeń dla usuniętych pul
      pole_nip.onkeydown = '';
      pole_nazwafirmy.onkeydown = '';
      pole_nazwafirmy.onfocus = '';
    // ----------------------------------------
    
    // przypisanie odpowiednich zdarzeń do pul (przypisanie inną metodą w zależności od przeglądarki)
      if (navigator.appName == 'Microsoft Internet Explorer') { // dla MSIE
        pole_imie.onkeydown = function () {if (this.form.imie_wymagane.value==1){clear_form_style('imie');}};
        pole_imie.onfocus = function () {clear_form_style('imie');};
        pole_nazwisko.onkeydown = function () {if (this.form.nazwisko_wymagane.value==1){clear_form_style('nazwisko');}};
        pole_nazwisko.onfocus = function () {clear_form_style('nazwisko');};
        pole_nip.onkeydown = function () {if (this.form.nip_sprawdz.value == 1){clear_form_style('nip');}}
      }
      else { // dla innych przeglądarek
        pole_imie.setAttribute('onkeydown', "if (this.form.imie_wymagane.value==1){clear_form_style('imie');}");
        pole_imie.setAttribute('onfocus', "clear_form_style('imie')");
        pole_nazwisko.setAttribute('onkeydown', "if (this.form.nazwisko_wymagane.value==1){clear_form_style('nazwisko');}");
        pole_nazwisko.setAttribute('onfocus', "clear_form_style('nazwisko')");
        pole_nip.setAttribute('onkeydown', "if (this.form.nip_wymagane.value==1){clear_form_style('nip');}");
      }
    // ----------------------------------------------------------------------------------------------
    
    // dodanie potrzebnych pul utworzonych wcześniej do odpowiedniego diva
      parent_2.appendChild(p2_1); parent_2.appendChild(p2_2); parent_2.appendChild(p2_3);
      parent_3.appendChild(p3_1); parent_3.appendChild(p3_2); parent_3.appendChild(p3_3);
    // -------------------------------------------------------------------
    
    activ_rodzaj='osoba'; // zmiana zmiennej sterującej na aktualny stan
  }
}

function PlnDrawRadioImg_byplug() {
	if (PlnPayTypeArray) {
		document.write('<div id="box_zbior_platnosci_pl">');
		for (var i=0; i<PlnPayTypeArray.length; i++) {
			document.write('<div class="box_radio"><input id="PlnRI' + i + '" type="radio" name="pay_type" value="' + PlnPayTypeArray[i].type + '"' + (PlnPayTypeArray[i].enable != 'true' ? ' disabled="disabled"' : '') + ' />');
			if (PlnPayTypeArray[i].enable=='true') {document.write('<a href="javascript:PlnSel(\'PlnRI' + i + '\')">');}
			document.write('<img src="' + PlnPayTypeArray[i].img + '" border="0" alt="' + PlnPayTypeArray[i].name + '" title="' + PlnPayTypeArray[i].name + '" onmouseover="on_komentarz(this,event,\'' + PlnPayTypeArray[i].name + '\')" />');
			if (PlnPayTypeArray[i].enable=='true') {document.write('</a>');}
			document.write('</div>');
		}
		document.write('</div>');
	}
}

function sprawdz_radio_platnosci_pl(form_name, text_alert) {
  var no_checked = true;
  for (var i=0; i<document.forms[form_name].pay_type.length; i++) {
    if (document.forms[form_name].pay_type[i].checked) {no_checked=false; break;}
  }
  if (no_checked) {alert(text_alert);}
  else {zmiana_akcji(form_name, 'zamowienie_platnosci_pl');}
}

function sprawdz_oswiadczenie(form_name) {
  if (document.getElementById('oswiadczenie').checked) {sprawdz(form_name, 'dane_kontakt');}
  else {document.getElementById('table_osw').className = 'negative';}
}

function max_znakow(pole, max) {
  pole.value = pole.value.substr(0,max);
  if (document.getElementById('zostalo_znakow')) {document.getElementById('zostalo_znakow').innerHTML = (max-pole.value.length);}
}

// ]]> -->
