function $(n) {return document.getElementById(n);}

var buttons = new Array();
var Timer;
var FIRST_ELEMENT, TIME_DELAY;

function random_val() {
    // modulo przez ilosc elementow w tablicy adress
    return Math.round(Math.round(Math.random()*10)) % 7;
}

adress = new Array();
adress["#strony-internetowe"]	= 0;
adress["#hosting"]           	= 1;
adress["#domeny"]          		= 2;
adress["#e-mail"]          		= 3;
adress["#sklepy-internetowe"]   = 4;
adress["#materialy-reklamowe"]  = 5;
adress["#programy"]   			= 6;

function menu_on_main() {
    var nr, item, tmp_tag;
    var main_obj        = $("tabsMenu");
    var main_obj_length = $("tabsMenu").getElementsByTagName("li").length;

    for (item = 0; item < main_obj_length ; ++ item) {
        if ( $("tabsMenu").getElementsByTagName("li")[item].getElementsByTagName("a").length ) {
                tmp_tag = $("tabsMenu").getElementsByTagName("li")[item].getElementsByTagName("a")[0];
                nr      = tmp_tag.id.match(/[\d]+$/);

                if ($("content" + nr)) {
                    buttons[parseInt(nr)] = new menu_btn(nr, tmp_tag.id);
                }
        }
    }

    if (location.hash && ! isNaN(adress[location.hash])) {
        FIRST_ELEMENT = adress[location.hash];
    }
    if (! FIRST_ELEMENT && isNaN(FIRST_ELEMENT)) {
        buttons[0].activation();
    }
    else if (! isNaN(FIRST_ELEMENT) && buttons[FIRST_ELEMENT] instanceof menu_btn) {
        buttons[FIRST_ELEMENT].activation();
    }
    else if (/^[\d]+$/.test(FIRST_ELEMENT) && buttons[parseInt(FIRST_ELEMENT)] instanceof menu_btn) {
        buttons[parseInt(FIRST_ELEMENT)].activation();
    }
    else if(isNaN(FIRST_ELEMENT) && buttons[parseInt(FIRST_ELEMENT.match(/[\d]+$/))] instanceof menu_btn) {
        buttons[parseInt(FIRST_ELEMENT.match(/[\d]+$/))].activation();
    }
    else {
        buttons[0].activation();
    }
    if (isNaN (TIME_DELAY) && /^[\d]+$/.test(TIME_DELAY)) {
        TIME_DELAY = parseInt(TIME_DELAY);
    }
    else if(TIME_DELAY < 0 || TIME_DELAY > 5000) {
        TIME_DELAY = 400;
    }
    else if (! TIME_DELAY && isNaN (TIME_DELAY) ) {
        TIME_DELAY = 400;
    }

}