<!--

if(navigator.appName == "Netscape") {
	function resizeIframe(x){try{x.scrolling='no',x.style.height=x.contentWindow.document.body.offsetHeight+'px'}catch(x){}}
}

function f1() {
    get('f1').style.display='block';
    get('f2').style.display='none';
    get('f3').style.display='none';
    get('m1').className='pokaz2';
    get('m2').className='pokaz2a';
    get('m3').className='pokaz2a';

}

function f2() {
    get('f1').style.display='none';
    get('f2').style.display='block';
    get('f3').style.display='none';
    get('m1').className='pokaz2a';
    get('m2').className='pokaz2';
    get('m3').className='pokaz2a';
}

function f3() {
    get('f1').style.display='none';
    get('f2').style.display='none';
    get('f3').style.display='block';
    get('m1').className='pokaz2a';
    get('m2').className='pokaz2a';
    get('m3').className='pokaz2';
}

function get(id) {
        if (document.getElementById(id)) {
            return document.getElementById(id);
        }
    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 checkInput(id, min) {
    input = get(id).value;
    if (input.length >= min) {
        return true;
    }
    return false;
}

function checkCheckbox(id) {
    checkbox = get(id);
    if (checkbox.checked == false) {
        return false;
    }
    return true;
}

function skasuj_1(obj) {
    if(obj.value == "login")
    obj.value = "";
}
function wstaw_1(obj) {
    if(obj.value == "")
    obj.value = "login";
}

function skasuj_2(obj) {
    if(obj.value == "password")
    obj.value = "";
}
function wstaw_2(obj) {
    if(obj.value == "")
    obj.value = "password";
}

function skasuj_3(obj) {
    if(obj.value == "e-mail")
    obj.value = "";
}
function wstaw_3(obj) {
    if(obj.value == "")
    obj.value = "e-mail";
}

function checkForm(form, submit, pokaz) {
    wynik = true;
    var info = new Array();
    var i = 0;
    
    if (!checkInput('firma', 1)) { wynik = false; if (pokaz == true) { info[i++] = '- firma'; } }
    if (!checkInput('adres', 1)) { wynik = false; if (pokaz == true) { info[i++] = '- adres'; } }
    if (!checkInput('kod', 1)) { wynik = false; if (pokaz == true) { info[i++] = '- kod'; } }
    if (!checkInput('miasto', 1)) { wynik = false; if (pokaz == true) { info[i++] = '- miasto'; } }
    if (!checkMail('email')) { wynik = false; if (pokaz == true) { info[i++] = '- e-mail'; } }
    if (!checkInput('telefon', 1)) { wynik = false; if (pokaz == true) { info[i++] = '- telefon'; } }
    if (!checkInput('faktura_nip', 1)) { wynik = false; if (pokaz == true) { info[i++] = '- NIP';} }
    
    if (!checkCheckbox('jakwyzej1')) {
        if (!checkInput('faktura_firma', 1)) { wynik = false; if (pokaz == true) { info[i++] = '- nazwę firmy';} }
        if (!checkInput('faktura_adres', 1)) { wynik = false; if (pokaz == true) { info[i++] = '- adres firmy';} }
        if (!checkInput('faktura_kod', 1)) { wynik = false; if (pokaz == true) { info[i++] = '- kod pocztowy firmy';} }
        if (!checkInput('faktura_miasto', 1)) { wynik = false; if (pokaz == true) { info[i++] = '- miasto firmy';} }
    }
    if (!checkCheckbox('jakwyzej2') && !checkCheckbox('jakwyzej3')) {
        if (!checkInput('wysylka_firma', 1)) { wynik = false; if (pokaz == true) { info[i++] = '- nazwę firmy lub Twoje dane - do wysyłki';} }
        if (!checkInput('wysylka_adres', 1)) { wynik = false; if (pokaz == true) { info[i++] = '- adres - do wysyłki';} }
        if (!checkInput('wysylka_kod', 1)) { wynik = false; if (pokaz == true) { info[i++] = '- kod pocztowy - do wysyłki';} }
        if (!checkInput('wysylka_miasto', 1)) { wynik = false; if (pokaz == true) { info[i++] = '- miasto - do wysyłki';} }
    }
    if (!checkCheckbox('regulamin')) { wynik = false; if (pokaz == true) { info[i++] = 'Zapoznaj się z regulaminem serwisu.'; } }
    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 zmienPolaJakWyzej1() {
    if (get('jakwyzej1').checked) {
        get('faktura_firma').readOnly = true;
        get('faktura_adres').readOnly = true;
        get('faktura_kod').readOnly = true;
        get('faktura_miasto').readOnly = true;
        get('faktura_firma_text').className='txt-disabled';
        get('faktura_adres_text').className='txt-disabled';
        get('faktura_kod_text').className='txt-disabled';
        get('faktura_firma').value = '';
        get('faktura_adres').value = '';
        get('faktura_kod').value = '';
        get('faktura_miasto').value = '';
        zgasFakture();
    }
    else {
        get('faktura_firma').readOnly = false;
        get('faktura_adres').readOnly = false;
        get('faktura_kod').readOnly = false;
        get('faktura_miasto').readOnly = false;
        get('faktura_firma_text').className='txt';
        get('faktura_adres_text').className='txt';
        get('faktura_kod_text').className='txt';
        zapalFakture();
    }
}

function zmienPolaJakWyzej2(numer) {
    if (numer == 2) {
        get('jakwyzej3').checked = false;
    }
    else if (numer == 3) {
        get('jakwyzej2').checked = false;
    }
    

    if ((get('jakwyzej2').checked) || (get('jakwyzej3').checked)) {
        get('wysylka_firma').readOnly = true;
        get('wysylka_adres').readOnly = true;
        get('wysylka_kod').readOnly = true;
        get('wysylka_miasto').readOnly = true;
        get('wysylka_firma_text').className='txt-disabled';
        get('wysylka_adres_text').className='txt-disabled';
        get('wysylka_kod_text').className='txt-disabled';
        get('wysylka_firma').value = '';
        get('wysylka_adres').value = '';
        get('wysylka_kod').value = '';
        get('wysylka_miasto').value = '';
        if (get('jakwyzej2').checked) {
            get('zgodny_z_rejestracja').className='txt';
            get('zgodny_z_faktura').className='txt-disabled';
       }
       else { 
            get('zgodny_z_rejestracja').className='txt-disabled';
            get('zgodny_z_faktura').className='txt';
       }
       zgasWysylke();
    }
    else {
        get('wysylka_firma').readOnly = false;
        get('wysylka_adres').readOnly = false;
        get('wysylka_kod').readOnly = false;
        get('wysylka_miasto').readOnly = false;
        get('wysylka_firma_text').className='txt';
        get('wysylka_adres_text').className='txt';
        get('wysylka_kod_text').className='txt';
        get('zgodny_z_rejestracja').className='txt-disabled';
        get('zgodny_z_faktura').className='txt-disabled';
        zapalWysylke();
    }
}

function zgasFakture() {
     get('jakwyzej1_txt').className='txt';
     get('faktura_firma').style.backgroundColor = '#CCCCCC';
     get('faktura_adres').style.backgroundColor = '#CCCCCC';
     get('faktura_kod').style.backgroundColor = '#CCCCCC';
     get('faktura_miasto').style.backgroundColor = '#CCCCCC';
}

function zapalFakture() {
     get('jakwyzej1_txt').className='txt-disabled';
     get('faktura_firma').style.backgroundColor = '#FFFFFF';
     get('faktura_adres').style.backgroundColor = '#FFFFFF';
     get('faktura_kod').style.backgroundColor = '#FFFFFF';
     get('faktura_miasto').style.backgroundColor = '#FFFFFF';
}

function zgasWysylke() {
     get('wysylka_firma').style.backgroundColor = '#CCCCCC';
     get('wysylka_adres').style.backgroundColor = '#CCCCCC';
     get('wysylka_kod').style.backgroundColor = '#CCCCCC';
     get('wysylka_miasto').style.backgroundColor = '#CCCCCC';
}

function zapalWysylke() {
     get('wysylka_firma').style.backgroundColor = '#FFFFFF';
     get('wysylka_adres').style.backgroundColor = '#FFFFFF';
     get('wysylka_kod').style.backgroundColor = '#FFFFFF';
     get('wysylka_miasto').style.backgroundColor = '#FFFFFF';
}

function pokazLicytacja(url) {
    parent.content_produkt.location.href = url;
}

function pokazAukcje(url) {
    parent.content_aukcje.location.href = url;
}
function pokazStatus(url) {
    parent.content_status.location.href = url;
}

function numbersonly(element, e, dec) {
    var key;
    var keychar;
    if (window.event)
        key = window.event.keyCode;
    else if (e)
        key = e.which;
    else
        return true;
    keychar = String.fromCharCode(key);

    if ((key==null) || (key==0) || (key==8) || (key==9) || (key==13) || (key==27) ) {
        return true;
    }
    // float
    if (dec == true) {
        if ((("0123456789\.").indexOf(keychar) > -1) && (keychar != '.' || element.value.indexOf('.') <= -1)) {
            return true;
        }
    }
    else if ((("0123456789").indexOf(keychar) > -1)) {
        return true;
    }

    return false;
}

function pokazStatusDiv(id) {
    var typ = '';
    if (id == 'aukcje_wszystkie') { typ = ''; get('aukcje_wszystkie').className = 'pokaz2b-static'; } else { get('aukcje_wszystkie').className = 'pokaz2-static'; }
    if (id == 'aukcje_moje') { typ = 'moje'; get('aukcje_moje').className = 'pokaz2b-static'; } else { get('aukcje_moje').className = 'pokaz2-static'; }
    if (id == 'aukcje_obserwowane') { typ = 'obserwowane';get('aukcje_obserwowane').className = 'pokaz2b-static'; } else { get('aukcje_obserwowane').className = 'pokaz2-static'; }
    if (id == 'aukcje_archiwalne') { typ = 'archiwum';get('aukcje_archiwalne').className = 'pokaz2b-static'; } else { get('aukcje_archiwalne').className = 'pokaz2-static'; }
    if (id == 'aukcje_platnosci') { typ = 'platnosci';get('aukcje_platnosci').className = 'pokaz2b-static'; } else { get('aukcje_platnosci').className = 'pokaz2-static'; }
    if (id == 'aukcje_zakonczone') { typ = 'zakonczone';get('aukcje_zakonczone').className = 'pokaz2b-static'; } else { get('aukcje_zakonczone').className = 'pokaz2-static'; }
    
    
    pokazAukcje('content_aukcje.php?typ='+typ+'');
}

function pokazWybrana(id) {
    var i = 1;
    while(get('tr'+i)) {
        if (i == id) {
            get('tr'+i).className='wybrana';
        }
        else {
            get('tr'+i).className="zgaszone";
        }
        i++;
    }
    
}

/*
function pokazWybrana(id) {
    var i = 1;
    while(get('tr'+i)) {
        if (i == id) {
            get('tr'+i).classNameOld=get('tr'+i).className;
            get('tr'+i).className='wybrana';
        }
        i++;
    }
    i = 1;
    while(get('tr'+i)) {
        if (i != id && get('tr'+i).className == 'wybrana') {
            if (get('tr'+i).classNameOld == 'zapalone') {
                get('tr'+i).className="zgaszone";
            }
            else {
                get('tr'+i).className=get('tr'+i).classNameOld;
            }
        }
        i++;
    }
}
*/

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 checkKeyCode(e) {
        var keycode;
        if (window.event)
                keycode = window.event.keyCode;
        else if (e)
                keycode = e.which;
        if (keycode==13) {
        return true;
    }
    return false;
}

function zmienZdjecie(zdjecie, id_aukcji, numer) {
    get('zdjecie1').className = 'numerki';
    get('zdjecie2').className = 'numerki';
    get('zdjecie3').className = 'numerki';
    get('zdjecie4').className = 'numerki';
    get('zdjecie'+numer).className = 'numerki-red';
    get('zdjecie').src = zdjecie;
    window.ustawienia.location.href = 'ustawienia.php?opcja=zdjecia&id='+id_aukcji+'&numer='+numer;
}

// -->
