// PROMO ROTATOR
var PromoRotatorList = new Array( "promo-1", "promo-2", "promo-3", "promo-4", "promo-5"); // seznam ID "promo" objektu pro rotaci
var PromoRotatorSpeed = 7000;  // prodleva v ms mezi vymenou objektu
var PromoRotatorIndex = 0;
var PromoRotatorIndexPrev = 0;
var PromoRotatorTimer = null;

var PromoRotatorOpacityState = 0;    // aktualni hodnota Opacity animovane zmeny objektu
var PromoRotatorOpacityStep 	= 10;  // krok pro zmenu Opacity pri animovane vymene objektu
var PromoRotatorOpacitySpeed = 50;   // prodleva v ms mezi krokem se zmenou Opacity
var PromoRotatorOpacityTimer = null;


function StartPromoRotator()
{
  SetObjOpacity( document.getElementById(PromoRotatorList[PromoRotatorIndex]), 100);
  try {
    if (PromoRotatorTimer != null)
    {
      clearTimeout(PromoRotatorTimer);
      PromoRotatorTimer = null;
    }
  } catch(e) {
    PromoRotatorTimer = null;    
  }
  PromoRotatorTimer = setTimeout( "RotatePromoRotator()", PromoRotatorSpeed);
}


function RotatePromoRotator()
{
  PromoRotatorIndexPrev = PromoRotatorIndex;
  PromoRotatorIndex++;  
	if(PromoRotatorIndex == PromoRotatorList.length) PromoRotatorIndex = 0;
  ChangePromoRotator(false);
  PromoRotatorTimer = setTimeout( "RotatePromoRotator()", PromoRotatorSpeed);  
}

function ChangePromoRotator(SkipFade)
{
  document.getElementById(PromoRotatorList[PromoRotatorIndex]).style.visibility = "visible";
  document.getElementById(PromoRotatorList[PromoRotatorIndexPrev]).style.visibility = "visible";    
  if (false)
  {
    SetObjOpacity( document.getElementById(PromoRotatorList[PromoRotatorIndex]), 100);
    SetObjOpacity( document.getElementById(PromoRotatorList[PromoRotatorIndexPrev]), 0);
  } else {
    SetObjOpacity( document.getElementById(PromoRotatorList[PromoRotatorIndex]), PromoRotatorOpacityState);
    SetObjOpacity( document.getElementById(PromoRotatorList[PromoRotatorIndexPrev]), 100-PromoRotatorOpacityState);            
    if (PromoRotatorOpacityState < 100) 
    {
      PromoRotatorOpacityTimer = setTimeout( "ChangePromoRotator()", PromoRotatorOpacitySpeed);
      PromoRotatorOpacityState += PromoRotatorOpacityStep;
    } else {
      PromoRotatorOpacityState = 0;
      clearTimeout(PromoRotatorOpacityTimer);
      document.getElementById(PromoRotatorList[PromoRotatorIndexPrev]).style.visibility = "hidden";
    }        
  }  
}


function SetObjOpacity(oObj, opacity)
// @desc: nastavi pruhlednost objektu
// oObj = objekt, opacity = cislo 0-100 udavajici pruhlednost
{
	try	{
		oObj.style.opacity = (opacity / 100);
		oObj.style.MozOpacity = (opacity / 100);
		oObj.style.KhtmlOpacity = (opacity / 100);
		oObj.style.filter 	= "alpha(opacity=" + opacity + ")";
	} catch(e) {
		return;
	}
}
