/* funkce pro zmenu akci obchodu */
function change_article()
{
    //najdeme element se tridou akce
    var id = getElementsByClass('akce');
    //vytahmene si z tohoto elementu hodnotu tagu id
    id = id[0].id;
    //vypreparujeme cislo aktuality
    id = id.split('_');
    id = id[1];
    
    //zjistime kolik novinek je celkem
    var hiddens = getElementsByClass('hidden_article');
    var max_id = hiddens.length;
    
    //nastavime dalsi id aktuality
    var new_id = parseInt(id) + 1;
    
    //osetrime posun na neexistujici aktuality
    if(new_id < 0) new_id = max_id;
    if(new_id >= (max_id+1)) new_id = 0;
    
    //nyni skryjeme puvodni aktualitu   
    document.getElementById('action_'+id).className = 'hidden'
    
    //a zobrazime novou
    document.getElementById('action_'+new_id).className = 'akce'
    
    //a vratime false kvuli posunum na strance
    return false;
}

/* funkce pro automaticke posouvani aktualit */
function autoswitch_actions(time, stop)
{
    if(time == '') time = 10000;
    
    if(stop)
    {
        timer = clearTimeout(timer);
    }
    else
    {
        timer = setTimeout('change_article();autoswitch_actions('+time+');', time);
    }
}

/* funkce najde div pomoci nazvu class */
function getElementsByClass(searchClass,node,tag) {
    var classElements = new Array();
    if ( node == null )
        node = document;
    if ( tag == null )
        tag = '*';
    var els = node.getElementsByTagName(tag);
    var elsLen = els.length;
    var pattern = new RegExp("(^|\\s)"+searchClass+"(\\s|$)");
    for (i = 0, j = 0; i < elsLen; i++) {
        if ( pattern.test(els[i].className) ) {
            classElements[j] = els[i];
            j++;
        }
    }
    return classElements;
}