thisSpotlight = null;
__rotatetime = 80; // * 0,1 sec
	
	function Spotlight(sso) {
		this._sso = sso;
		this._test = 'test';
		this._active = 1;
		this._pause = false;
		thisSpotlight = this;
	}

	Spotlight.prototype.draw = function() {
				
		// Create the Spotlight Bar
		
		$("#spotlight").append('<div id="spotlight_bar">Spotlight</div>');
		$("#spotlight_bar").append('<ul>');
		
		for (i=this._sso.item.length;i>0;i--) {
			
			$("#spotlight_bar").append('<li id="spotlight_item'+i+'" class="spotlight_button">'+i+'</li>');

			$("#spotlight_item"+i).mouseover(function(){
				this.style.backgroundImage="url('"+rootUrl+"img/gfx/blue_block.gif')";
				this.style.color="#ffffff";
			});
			$("#spotlight_item"+i).mouseout(function(){
				this.style.backgroundImage="none";
				this.style.color="#000000";
			});
			$("#spotlight_item"+i).click(function(){
				thisSpotlight.swap(this.id);
			});
			
		}
		$("#spotlight_bar").append('</ul>');
	
		$("#spotlight").append('<div id="spotlight_field"></div>');
		
		for (i=1;i<this._sso.item.length+1;i++) {
			
			$("#spotlight_field").append('<div id="spotlight_field'+i+'" style="z-index:'+ (this._sso.item.length-i+1) +'" class="spotlight_spot"></div>');
			$("#spotlight_field"+i).append('<p class="spotlight_title">'+this._sso.item[i-1].title+'</p>');
			//id="spotlight_field'+i+'"
			$("#spotlight_field"+i).append('<div id="spotlight_block'+i+'" class="spotlight_block"></div>');
			$("#spotlight_block"+i).css("background-image","url("+this._sso.item[i-1].imgurl+")");			
			
			$("#spotlight_block"+i).append('<div class="spotlight_text">'+this._sso.item[i-1].text+'</div');
			
			$("#spotlight_block"+i).mouseover(function(){
				thisSpotlight._pause = true;
			});
			$("#spotlight_block"+i).mouseout(function(){
				thisSpotlight._pause = false;
				__spotlightcounter = 0;
			});			
			_href = this._sso.item[i-1].href;
			$("#spotlight_block"+i).click(function(){
				thisSpotlight.link(this.id);
			});
		}
		
		this.setActive(1);
	}
	
	Spotlight.prototype.setActive = function(obj) {
		
		// Reset
		$("#spotlight_item"+this._active).mouseout(function(){
			this.style.backgroundImage="none";
			this.style.color="#000000";
		});
		$("#spotlight_item"+this._active).css("background-image","none");
		$("#spotlight_item"+this._active).css("color","#000000");
		
		// Set
		$("#spotlight_item"+obj).mouseout(function(){
			this.style.backgroundImage="url('"+rootUrl+"img/gfx/blue_block.gif')";
			this.style.color="#ffffff";
		});
		$("#spotlight_item"+obj).css("background-image","url('"+rootUrl+"img/gfx/blue_block.gif')");
		$("#spotlight_item"+obj).css("color","#ffffff");
		
		if (this._active != obj) {
		
			$("#spotlight_field"+this._active).fadeOut(500);
			$("#spotlight_field"+obj).fadeIn(500);
		
		}
		
		this._active = obj;
		
	}
	
	Spotlight.prototype.getNextActive = function() {
		if ( (this._active+1) > this._sso.item.length ) {
			return 1;
		} else {
			return this._active+1;
		}
	}

	Spotlight.prototype.start = function() {
			this._slide_interval = setInterval(thisSpotlight.rotate,100);
	}
	
	__spotlightcounter = 0;
	Spotlight.prototype.rotate = function() {
		if (thisSpotlight._pause != true) {
			__spotlightcounter ++;
			if (__spotlightcounter > __rotatetime) {
				_s = thisSpotlight.getNextActive();
				thisSpotlight.setActive(_s);
				__spotlightcounter = 0;
			}
		}
	}	
	
	Spotlight.prototype.link = function(link) {
		//alert(link);
		for (i=1;i<this._sso.item.length+1;i++) {
			if("spotlight_block"+i == link) {
				window.location = thisSpotlight._sso.item[i-1].href;
			}
		}
	}
	
	Spotlight.prototype.swap = function(link) {
		//alert(link);
		for (i=1;i<this._sso.item.length+1;i++) {
			if("spotlight_item"+i == link) {
				thisSpotlight.setActive(i);
				__spotlightcounter = 0;
			}
		}
	}
