//--Check namespaces
if (typeof Widget == "undefined") {
  var Widget = new Object();
}
//----Check namespaces
Widget.Rotator = function(actionsListContainer, actionBigImageContainer, delay){
  this.actionsListContainer = document.getElementById(actionsListContainer);
	this.delay = delay;
  this.actionBigImage = document.getElementById(actionBigImageContainer);
	if(!(this.actionsListContainer || this.actionBigImage)){ return false; }
  this.actionBigImageStyle = this.actionBigImage.style;
  this.constantCss = this.actionBigImageStyle.cssText;
  this.rotationTimer = null;
  this.currentAction = null;
  this.actionsList = null;
  this.currentActionIndex = 0;
  this.init();
};
Widget.Rotator.prototype.init = function(){
    this.actionsList = this.actionsListContainer.getElementsByTagName("a");
    if (!this.actionsList.length){ return false; }
    this.currentActionIndex = 0;
    var i;
    var thisObj = this;
    for(i=0; i<this.actionsList.length; i++){  
			this.actionsList[i].index = i;
			if(this.actionsList[i].className == "cur"){
				this.currentAction = this.actionsList[i];
			}
      this.actionsList[i].onmouseover = function(){
        thisObj.stopRotation(); 
        thisObj.showAction(this);
      };
      this.actionsList[i].onmouseout = function(){
        thisObj.startRotation(this.index); 
      };
    }
    this.actionBigImage.onmouseover = function(){
        thisObj.stopRotation(); 
    };
    this.actionBigImage.onmouseout = function(){
        thisObj.startRotation(thisObj.currentActionIndex); 
      };
		this.actionBigImage.onclick = function(){
				window.location.href = thisObj.currentAction.href;
		};
    this.startRotation();
};
Widget.Rotator.prototype.showAction = function(item){
    if (this.currentAction) {
      this.currentAction.className = "";
    }
    item.className = "cur";
		this.actionBigImageStyle.cssText = this.constantCss+";"+item.rel;
    this.currentAction = item;
};
Widget.Rotator.prototype.startRotation = function(fromIndex){
    this.currentActionIndex = (fromIndex && fromIndex < this.actionsList.length) ? fromIndex : 0;
    var thisObj = this;
    this.rotationTimer = setInterval(function(){
      thisObj.showAction(thisObj.actionsList[thisObj.currentActionIndex]);
      thisObj.currentActionIndex++;
      if (thisObj.currentActionIndex == thisObj.actionsList.length) {
        thisObj.currentActionIndex = 0;
      }
    }, this.delay * 1000);
};
Widget.Rotator.prototype.stopRotation = function(){
    clearInterval(this.rotationTimer);
    this.rotationTimer = null;
};
