<!--

function get(id) {
        if (document.getElementById(id)) {
            return document.getElementById(id);
        }
    return false;
}

function checkInput(id, min) {
    input = get(id).value;
    if (input.length >= min) {
        return true;
    }
    return false;
}

function checkMail(id) {
    email = get(id).value;
	var filter  = /([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
    if (filter.test(email)) {
        return true;
    }
    return false;
}

function checkLength(id, idc) {
    var max = 300;
    if (get(id).value.length > max) {
        get(id).value = get(id).value.substring(0, max);
    }
    get(idc).innerHTML = max-get(id).value.length;
}

function skasuj_1(obj) {
    if(obj.value == "Wyszukiwarka")
    obj.value = "";
}

function wstaw_1(obj) {
    if(obj.value == "")
    obj.value = "Wyszukiwarka";
}

function onCheckbox(element, numer) {
    var i = 1;
    while (get(element+i)) {
        if (i != numer) {
            get(element+i).checked = false;
        }
        i++;
    }
    if (get(element+numer).checked == true) {
        get('kolor').value = get(element+numer).value;
    }
    else {
        get('kolor').value = '';
    }
}

function onCheckbox2(element, numer) {
    var i = 1;
    while (get(element+i)) {
        if (i != numer) {
            get(element+i).checked = false;
        }
        i++;
    }
    if (get(element+numer).checked == true) {
        get('id_oscieznicy').value = get(element+numer).value;
    }
    else {
        get('id_oscieznicy').value = '';
    }
}

function basename (path, suffix) {
    // Returns the filename component of the path  
    // 
    // version: 1006.1915
    // discuss at: http://phpjs.org/functions/basename    // +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   improved by: Ash Searle (http://hexmen.com/blog/)
    // +   improved by: Lincoln Ramsay
    // +   improved by: djmix
    // *     example 1: basename('/www/site/home.htm', '.htm');    // *     returns 1: 'home'
    // *     example 2: basename('ecra.php?p=1');
    // *     returns 2: 'ecra.php?p=1'
    var b = path.replace(/^.*[\/\\]/g, '');
        if (typeof(suffix) == 'string' && b.substr(b.length-suffix.length) == suffix) {
        b = b.substr(0, b.length-suffix.length);
    }
    return b;
}
function zmienTop() {
    var aktualne = 0;
    var biezace = basename(get('topsrc').src);
    for(var i=0; i<5; i++) {
	if (basename(topy[i]) == biezace) {
	    aktualne = i;
	}
    }
    if (aktualne+1 < 5) {
	get('topsrc').src = topy[aktualne+1];
    }
    else {
	get('topsrc').src = topy[0];
    }
    setTimeout('zmienTop()', 4000);
}

function pokazZakres(numer) {
    var id_oscieznicy = -1;
    if (get('oscieznice'+numer).checked == true) {
	id_oscieznicy = get('oscieznice'+numer).value;
    }
    ustawienia.location.href = '/ustawienia.php?opcja=zakres&id_produktu='+id_oscieznicy;
}

function removeAllOptions(selectbox) {
    var i;
    for(i=selectbox.options.length-1;i>=0;i--) {
        selectbox.remove(i);
    }
}

function addOption(selectbox, value, text ) {
    var optn = document.createElement("OPTION");
    optn.text = text;
    optn.value = value;
    selectbox.options.add(optn);
}
 function hideElement(elementId) {
 var heelement;
 if (parent.document.all)
 heelement = parent.document.all[elementId];
 else if (parent.document.getElementById)
 heelement = parent.document.getElementById(elementId);
 if (heelement && heelement.style)
 heelement.style.display = 'none';
 }
 
 function showElement(elementId) {
 var heelement;
 if (parent.document.all)
 heelement = parent.document.all[elementId];
 else if (parent.document.getElementById)
 heelement = parent.document.getElementById(elementId);
 if (heelement && heelement.style)
 heelement.style.display = '';
 }

function number_format(a, b, c, d) {
    a = Math.round(a * Math.pow(10, b)) / Math.pow(10, b);
    e = a + '';
    f = e.split('.');
    if (!f[0]) { f[0] = '0'; }
    if (!f[1]) { f[1] = ''; }
    if (f[1].length < b) { g = f[1]; for (i=f[1].length + 1; i <= b; i++) { g += '0'; } f[1] = g; }
    if(d != '' && f[0].length > 3) { h = f[0]; f[0] = ''; for(j = 3; j < h.length; j+=3) { i = h.slice(h.length - j, h.length - j + 3); f[0] = d + i +  f[0] + ''; } j = h.substr(0, (h.length % 3 == 0) ? 3 : (h.length % 3)); f[0] = j + f[0]; }
    c = (b <= 0) ? '' : c;
    return f[0] + c + f[1];
}

function checkFormZamowienie(form, submit, pokaz) {
    wynik = true;
    var info = new Array();
    var i = 0;
    
    if (!checkInput('imie', 1)) { wynik = false; if (pokaz == true) { info[i++] = '- imię'; } }
    if (!checkInput('nazwisko', 1)) { wynik = false; if (pokaz == true) { info[i++] = '- nazwisko'; } }
    if (!checkInput('email', 1)) { wynik = false; if (pokaz == true) { info[i++] = '- e-mail'; } }
    if (!checkInput('telefon', 1)) { wynik = false; if (pokaz == true) { info[i++] = '- telefon'; } }

    if (wynik == false && info.length > 0 && pokaz == true) {
        var napis = "Proszę poprawnie uzupełnić następujące pola: \n"+info.join("\n");
        alert(napis);
    }
    return wynik;
}

function checkFormZapytanie(form, submit, pokaz) {
    wynik = true;
    var info = new Array();
    var i = 0;
    
    if (!checkInput('imie', 1)) { wynik = false; if (pokaz == true) { info[i++] = '- imię'; } }
    if (!checkInput('nazwisko', 1)) { wynik = false; if (pokaz == true) { info[i++] = '- nazwisko'; } }
    if (!checkInput('email', 1)) { wynik = false; if (pokaz == true) { info[i++] = '- e-mail'; } }
    if (!checkInput('telefon', 1)) { wynik = false; if (pokaz == true) { info[i++] = '- telefon'; } }
    if (!checkInput('tresc', 1)) { wynik = false; if (pokaz == true) { info[i++] = '- treść zapytania'; } }

    if (wynik == false && info.length > 0 && pokaz == true) {
        var napis = "Proszę poprawnie uzupełnić następujące pola: \n"+info.join("\n");
        alert(napis);
    }
    return wynik;
}

function checkKeyCode(e) {
    var keycode;
    if (window.event) 
	keycode = window.event.keyCode;
    else if (e) 
	keycode = e.which;
    if (keycode==13) {
        return true;
    }
    return false;
}



//-->
