function walidacjaDodaj(form)
{
    if(form.nick.value.length==0)
    {
        alert('Musisz podać nick');
        return false;
    }
    else if(form.tresc.value.length==0)
    {
        alert('Musisz podać treść opinii.');
        return false;
    }

    return true;
}

function zmienStrone(numer)
{
    var i=1;
    while(document.getElementById('strona'+i))
    {
        //alert('jazyju');
        if(numer==i) 
            {
                document.getElementById('strona'+i).style.display='block';
                document.getElementById('link'+i).style.fontWeight ='bold';
                document.getElementById('link'+i).style.textDecoration ='underline';
            }

        else 
        {
            document.getElementById('strona'+i).style.display='none';
            document.getElementById('link'+i).style.fontWeight ='normal';
            document.getElementById('link'+i).style.textDecoration ='none';
        }

        i++;
    }

    return false;
}

function wali(form)
{
    if(form.zapoznalem.checked) return true;
    else
    {
        alert('Musisz zaakceptować regulamin sklepu internetowego Piętrus.pl');
        return false;
    }
}

function isThousands(position) {
    if (Math.floor(position/3)*3==position) return true;
    return false;
};

function formatMoney (theNumber,theCurrency,theThousands,theDecimal) {
    var theDecimalDigits =
    Math.round((theNumber*100)-(Math.floor(theNumber)*100));
    theDecimalDigits= ""+ (theDecimalDigits + "0").substring(0,2);
    theNumber = ""+Math.floor(theNumber);
    var theOutput = theCurrency;
    for (x=0; x<theNumber.length; x++) {
        theOutput += theNumber.substring(x,x+1);
        if (isThousands(theNumber.length-x-1) && (theNumber.length-x-1
            !=0)) {
            theOutput += theThousands;
        };
    };
    theOutput += theDecimal + theDecimalDigits;
    return theOutput;
};

function zmianaCeny(id)
{
    document.getElementById('koszt2').innerHTML=formatMoney(parseFloat(document.getElementById('kosztuju'+id).innerHTML).toFixed(2),'',' ',',');
    var liczba=parseFloat(document.getElementById('kosztuju'+id).innerHTML)+parseFloat(document.getElementById('koszt1').innerHTML);
    liczba=liczba.toFixed(2);
    document.getElementById('suma').innerHTML=formatMoney(liczba,'',' ',',');
}
