var arrRotatorTimer = new Array;
var arrRotatorTimerSpeed = new Array;
var arrRotatorTimerIniSpeed = new Array;
var arrRotatorTip = new Array;
var arrRotatorTipOld = new Array;
var arrRotatorOpacityState = new Array;
var arrRotatorOpacityStep = new Array;
var arrRotatorOpacitySpeed = new Array;
var arrRotatorOpacityTimer = new Array;
var arrId = new Array;
var arrRotatorTipCount = new Array;
var arrRotatorOpacityS = new Array;

arrRotatorTimer[1] = null;
arrRotatorTimer[2] = null;
arrRotatorTimer[3] = null;
arrRotatorTimer[4] = null;
//arrRotatorTimerSpeed[1] = 7000;
//arrRotatorTimerSpeed[2] = 7000;
//arrRotatorTimerIniSpeed[1] = 7000;
//arrRotatorTimerIniSpeed[2] = 7000;
arrRotatorTip[1] = 0;
arrRotatorTip[2] = 0;
arrRotatorTip[3] = 0;
arrRotatorTip[4] = 0;
arrRotatorTipOld[1] = 0;
arrRotatorTipOld[2] = 0;
arrRotatorTipOld[3] = 0;
arrRotatorTipOld[4] = 0;
arrRotatorOpacityState[1] = 0;
arrRotatorOpacityState[2] = 0;
arrRotatorOpacityState[3] = 0;
arrRotatorOpacityState[4] = 0;
arrRotatorOpacityStep[1] = 2;
arrRotatorOpacityStep[2] = 2;
arrRotatorOpacityStep[3] = 2;
arrRotatorOpacityStep[4] = 2;
arrRotatorOpacitySpeed[1] = 20;
arrRotatorOpacitySpeed[2] = 20;
arrRotatorOpacitySpeed[3] = 20;
arrRotatorOpacitySpeed[4] = 20;
arrRotatorOpacityTimer[1] = null;
arrRotatorOpacityTimer[2] = null;
arrRotatorOpacityTimer[3] = null;
arrRotatorOpacityTimer[4] = null;
arrId[1] = "left-pillar-content-";
arrId[2] = "little-left-pillar-content-";
arrId[3] = "little-middle-pillar-content-";
arrId[4] = "little-right-pillar-content-";

function pillars() {

}

//----------------------------x = nazev prvku

function objGet(x) {

	if (Boolean(document.getElementById)) return document.getElementById(x);
	else if (Boolean(document.all)) return eval('document.all.'+x);
	else if (Boolean(document.ids)) return eval('document.ids.'+x);
	else return null;

}

function StopRotation() {
    clearTimeout(arrRotatorTimer[1]);
    clearTimeout(arrRotatorTimer[2]);
    clearTimeout(arrRotatorTimer[3]);
    clearTimeout(arrRotatorTimer[4]);
}

function StartTipRotator(type) {


    if (arrRotatorTip[type] > 0) {
        SetRotatorTipOpacity(objGet(arrId[type] + arrRotatorTip[type]), 100)
    } else {
        SetRotatorTipOpacity(objGet(arrId[type] + "0"), 100)
    }

    if (arrRotatorTimer[type] != null) {
        clearTimeout(arrRotatorTimer[type]);
        arrRotatorTimer[type] = null;
    }

    arrRotatorTimer[type] = setTimeout(function() { RotateTip(type) }, arrRotatorTimerIniSpeed[type]);
}
//**********************************************************************
function RotateTip(type) {

    arrRotatorTipOld[type] = arrRotatorTip[type];
    arrRotatorTip[type]++;
    if (arrRotatorTip[type] == arrRotatorTipCount[type]) { arrRotatorTip[type] = 0; }
    DisplayTip(arrRotatorTip[type], arrRotatorTipOld[type], arrRotatorTimerSpeed[type], false, type);
}
//**********************************************************************
function ShowPromoTipExact(which, newspeed, type) {
    arrRotatorTipOld[type] = arrRotatorTip[type];
    arrRotatorTip[type] = which;
    DisplayTip(arrRotatorTip[type], arrRotatorTipOld[type], arrRotatorTimerIniSpeed[type], true, type);
}
//**********************************************************************
function DisplayTip(nTip, oTip, oSpeed, newspeed, type) {

    var oTip2;

    clearTimeout(arrRotatorTimer[type]);
    arrRotatorTimer[type] = null;

    if (newspeed) {
        if (nTip != oTip) {

            arrRotatorOpacityStep[type] = 20;
            arrRotatorOpacitySpeed[type] = 15;
            arrRotatorOpacityState[type] = 0;
            if (oTip == 0) { oTip2 = arrRotatorTipCount[type] - 1 } else { oTip2 = oTip - 1 };

            if (arrRotatorOpacityTimer[type] != null) {
                clearTimeout(arrRotatorOpacityTimer[type]);
                arrRotatorOpacityTimer[type] = null

                if (getObjOpacity(objGet(arrId[type] + oTip2)) > 0) {
                    objGet(arrId[type] + oTip2).style.visibility = "hidden";
                    SetRotatorTipOpacity(objGet(arrId[type] + oTip2), 0);

                    objGet(arrId[type] + oTip).style.visibility = "visible";
                    SetRotatorTipOpacity(objGet(arrId[type] + oTip), 100);
                }
            }

            objGet(arrId[type] + nTip).style.visibility = "visible";
            ChangeTipOpacity(type);
        }
    } else {
        arrRotatorOpacityStep[type] = arrRotatorOpacityS[type];
        arrRotatorOpacitySpeed[type] = 1;

        objGet(arrId[type] + nTip).style.visibility = "visible";
        ChangeTipOpacity(type);
    }
    
    var ListerLinks;

    if (type == "1") {
        ListerLinks = objGet("left-pillar-bar").getElementsByTagName("A");
    }
    
    if (type == "2") {
        ListerLinks = objGet("little-left-pillar-bar").getElementsByTagName("A");
    }
    
    if (type == "3") {
        ListerLinks = objGet("little-middle-pillar-bar").getElementsByTagName("A");
    }
    
    if (type == "4") {
        ListerLinks = objGet("little-right-pillar-bar").getElementsByTagName("A");
    }

    ListerLinks[oTip].setAttribute("class", "");
    ListerLinks[oTip].setAttribute("className", "");
    ListerLinks[nTip].setAttribute("class", "act");
    ListerLinks[nTip].setAttribute("className", "act");

}

function ChangeTipOpacity(type) {

    clearTimeout(arrRotatorOpacityTimer[type]);
    arrRotatorOpacityTimer[type] = null;

    if (arrRotatorOpacityState[type] >= 100) {
        objGet(arrId[type] + arrRotatorTipOld[type]).style.visibility = "hidden";
        arrRotatorOpacityState[type] = 0;
        arrRotatorTimer[type] = setTimeout(function() { RotateTip(type) }, arrRotatorTimerSpeed[type]);
        return;
    }

    arrRotatorOpacityState[type] += arrRotatorOpacityStep[type];

    SetRotatorTipOpacity(objGet(arrId[type] + arrRotatorTipOld[type]), 100 - arrRotatorOpacityState[type])
    SetRotatorTipOpacity(objGet(arrId[type] + arrRotatorTip[type]), arrRotatorOpacityState[type])

    arrRotatorOpacityTimer[type] = setTimeout(function() { ChangeTipOpacity(type) }, arrRotatorOpacitySpeed[type]);
}

//**********************************************************************
function SetRotatorTipOpacity(oObj, opacity) {
    try {
        oObj.style.opacity = (opacity / 100);
        oObj.style.MozOpacity = (opacity / 100);
        oObj.style.KhtmlOpacity = (opacity / 100);
        oObj.style.filter = "alpha(opacity=" + opacity + ")";

        if (opacity == 100 && oObj.style.removeAttribute) {
            if (oObj.style.filter) {
                oObj.style.removeAttribute('filter');
            }
        }
    }
    catch (e) {
        return;
    }
}

function getObjOpacity(oObj) {
  

    test = oObj.style.opacity;
    if (!isNaN(test)){return test}
    
    test = oObj.style.MozOpacity;
    if (!isNaN(test)){return test}
    
    test = oObj.style.KhtmlOpacity;
    if (!isNaN(test)){return test}

    /*var test;
    try { test = oObj.style.opacity; }
    catch (e) { alert(test); }
    writemessage(test + '<br>');

    try { test = oObj.style.MozOpacity; }
    catch (e) { alert(test); }
    writemessage(test + '<br>');

    try { test = oObj.style.KhtmlOpacity; }
    catch (e) { alert(test); }
    writemessage(test + '<br>');*/
}

 /*
function writemessage(msg) {
    document.getElementById('huh').innerHTML += msg;
} 
*/



