/*
Tento javascriptový kód je můj vlastní.
Pokud ho chcete použít je šířen pod licencí:
Uveďte autora-Neužívejte dílo komerčně-Zachovejte licenci 3.0 Česko
http://creativecommons.org/licenses/by-nc-sa/3.0/cz/
Jaroslav "Rajmund" Hutař
*/
raja = new fce();
function fce() {
    this.rotate = function (id, uhel) {  
        document.getElementById(id).style.WebkitTransform="rotate("+uhel+"deg)";
        document.getElementById(id).style.MozTransform="rotate("+uhel+"deg)";
        document.getElementById(id).style.OTransform="rotate("+uhel+"deg)";
        }
     this.bubble_down = function(pole){
        var x,newn;
        n=pole.length;
        while (n > 1) {
            newn=0;
            for (i=0;i<(n-1);i++){
                if (pole[i]<pole[i+1]) {
                    x=pole[i];
                    pole[i]=pole[i+1];
                    pole[i+1]=x;
                    newn=i;
                    }
                }
            n=newn+1;
            }
        }
    this.bubble_up = function(pole){
        var x,newn;
        n=pole.length;
        while (n > 1) {
            newn=0;
            for (i=0;i<(n-1);i++){
                if (pole[i]>pole[i+1]) {
                    x=pole[i];
                    pole[i]=pole[i+1];
                    pole[i+1]=x;
                    newn=i;
                    }
                }
            n=newn+1;
            }
        }
    this.array = function(pole){
        var vys="";
        n=pole.length;
        for (i=0;i<n;i++){
            if (i!=n) vys+=pole[i]+" ";
            else vys+=pole[i]; 
            }
        return vys;
        }
    this.remove = function remove(pole,prvek){
        for (i=0;i<=pole.length-1;i++) {
            if (prvek==pole[i]) smaz=i;
            }
        p1 = pole.slice(0,smaz);
        p2 = pole.slice(smaz+1,pole.length); 
        p3 = p1.concat(p2);
        return p3;           
    }
    this.isinarray = function isinarray(pole,prvek){
        var obsahuje=false;
        var i=0;
        while (i<=pole.length) {
            if (prvek==pole[i]) obsahuje=true;
            i++;
            }
        return obsahuje;           
    }
    this.zobraz_vic = function zobraz_vic(id){
        element = document.getElementById(id).style;
        element.display = (element.display == "block") ? "none" : "block";
    }                          
}
function trim(stringToTrim) {
	return stringToTrim.replace(/^\s+|\s+$/g,"");
}
function strtr(str, from, to) {
    var fr = '',
        i = 0,
        j = 0,
        lenStr = 0,
        lenFrom = 0,
        tmpStrictForIn = false,
        fromTypeStr = '',
        toTypeStr = '',
        istr = '';
    var tmpFrom = [];
    var tmpTo = [];
    var ret = '';
    var match = false;
 
    // Received replace_pairs?
    // Convert to normal from->to chars
    if (typeof from === 'object') {
        tmpStrictForIn = this.ini_set('phpjs.strictForIn', false); // Not thread-safe; temporarily set to true
        from = this.krsort(from);
        this.ini_set('phpjs.strictForIn', tmpStrictForIn);
 
        for (fr in from) {
            if (from.hasOwnProperty(fr)) {
                tmpFrom.push(fr);
                tmpTo.push(from[fr]);
            }
        }
 
        from = tmpFrom;
        to = tmpTo;
    }
 
    // Walk through subject and replace chars when needed
    lenStr = str.length;
    lenFrom = from.length;
    fromTypeStr = typeof from === 'string';
    toTypeStr = typeof to === 'string';
 
    for (i = 0; i < lenStr; i++) {
        match = false;
        if (fromTypeStr) {
            istr = str.charAt(i);
            for (j = 0; j < lenFrom; j++) {
                if (istr == from.charAt(j)) {
                    match = true;
                    break;
                }
            }
        } else {
            for (j = 0; j < lenFrom; j++) {
                if (str.substr(i, from[j].length) == from[j]) {
                    match = true;
                    // Fast forward
                    i = (i + from[j].length) - 1;
                    break;
                }
            }
        }
        if (match) {
            ret += toTypeStr ? to.charAt(j) : to[j];
        } else {
            ret += str.charAt(i);
        }
    }
 
    return ret;
}
function countdown(do_kdy){
var ted=new Date();
var date_now=Math.floor(ted.getTime()/1000);
zbyva=(do_kdy-(date_now))/(60*60*24);
zbyva_cele_dny=Math.floor(zbyva);
zbyva-=zbyva_cele_dny;
zbyva*=24;
zbyva_cele_hodiny=Math.floor(zbyva);
zbyva-=zbyva_cele_hodiny;
zbyva*=60;
zbyva_cele_minuty=Math.floor(zbyva);
zbyva-=zbyva_cele_minuty;
zbyva*=60;
zbyva_cele_sekundy=Math.round(zbyva);

vysledek="";
if (zbyva_cele_dny>4) vysledek+=zbyva_cele_dny+" dní ";
else if (zbyva_cele_dny>1) vysledek+=zbyva_cele_dny+" dny ";
else if (zbyva_cele_dny==1) vysledek+=zbyva_cele_dny+" den ";
else if (zbyva_cele_dny==0) vysledek+="";
else vysledek+=zbyva_cele_dny+" dní ";

if (zbyva_cele_hodiny>4) vysledek+=zbyva_cele_hodiny+" hodin ";
else if (zbyva_cele_hodiny>1) vysledek+=zbyva_cele_hodiny+" hodiny ";
else if (zbyva_cele_hodiny==1) vysledek+=zbyva_cele_hodiny+" hodina ";
else if (zbyva_cele_hodiny==0) vysledek+="";
else vysledek+=zbyva_cele_hodiny+" hodin ";

if (zbyva_cele_minuty>4) vysledek+=zbyva_cele_minuty+" minut ";
else if (zbyva_cele_minuty>1) vysledek+=zbyva_cele_minuty+" minuty ";
else if (zbyva_cele_minuty==1) vysledek+=zbyva_cele_minuty+" minuta ";
else if (zbyva_cele_minuty==0) vysledek+="";
else vysledek+=zbyva_cele_minuty+" minut ";

if (zbyva_cele_sekundy>4) vysledek+=zbyva_cele_sekundy+" sekund";
else if (zbyva_cele_sekundy>1) vysledek+=zbyva_cele_sekundy+" sekundy";
else if (zbyva_cele_sekundy==1) vysledek+=zbyva_cele_sekundy+" sekunda";
else if (zbyva_cele_sekundy==0) vysledek+="";
else vysledek+=zbyva_cele_sekundy+" sekund";

alert(vysledek);
document.getElementById("countdown").innerHTML=vysledek;
} 
