/*****************************************************************************************************/
/*                                                                                                   */
/*                                           'ANNOUNCERS CLASS'                                        */          
/*                                                                                                   */
/*****************************************************************************************************/

function ANNOUNCERS(){
	var JSObject = this;
	this.type = "announcers"; 
	
	this.DOMDoc; //document object from current window or thickbox window
	this.no_announcers;
	this.current_announcer = 0;
	
	this.container;
	
	
	/*****************************************************************************************************/
	/*                                                                                                   */
	/*                                      FUNCTION INIT                                                */          
	/*                                                                                                   */
	/*****************************************************************************************************/
	this.init = function(){
		
		this.no_announcers = $('div[id="announcerImage"]',this.DOMDoc).get().length;
		this.initAnnouncers();
	}
	
	
	/*****************************************************************************************************/
	/*                                                                                                   */
	/*                                      FUNCTION INIT ANNOUNCERS                                       */          
	/*                                                                                                   */
	/*****************************************************************************************************/
	this.initAnnouncers = function(){
		
		for (var i=0; i<this.no_announcers; i++){
			var a = $('a[id="announcerPage"]',this.DOMDoc).get(i);
			$(a).data('index',i);	
		}
		
		$('a[id="announcerPage"]',this.DOMDoc).each(function(){
			
			
			/*****************************************************************************************************/
			/*                                                                                                   */
			/*                                        BULLETS CLICK                                              */          
			/*                                                                                                   */
			/*****************************************************************************************************/
			$(this).mouseover(function(){
				
				var index = $(this).data('index');
				
				if (index == JSObject.current_announcer) return false;
				
				JSObject.newAnnouncer(index);
								
			});
		});
		
	}
	
	
	
	/*****************************************************************************************************/
	/*                                                                                                   */
	/*                                      FUNCTION NEW FEATURE                                         */          
	/*                                                                                                   */
	/*****************************************************************************************************/
	this.newAnnouncer = function(index){
		
		if (index == null){
			if (this.current_announcer+1 > JSObject.no_announcers-1) index = 0;
			else index = this.current_announcer+1;
		}
		
		//fade out current announcer
		var currentDiv = $("div[id='announcerImage']:eq("+JSObject.current_announcer+")",JSObject.DOMDoc);
		currentDiv.css('display','none');
		
		//fade in next announcer
		var nextDiv = $("div[id='announcerImage']:eq("+index+")",JSObject.DOMDoc);
		nextDiv.css('display','block');
		
		this.current_announcer = index;
		
		/*//fade out current announcer
		var currentDiv = $("div[id='announcerImage']:eq("+JSObject.current_announcer+")",JSObject.DOMDoc);
		currentDiv.animate({opacity:0},100,function(){currentDiv.css('display','none')});
		
		//fade in next announcer
		var nextDiv = $("div[id='announcerImage']:eq("+index+")",JSObject.DOMDoc);
		nextDiv.animate({opacity:0},1,function(){nextDiv.css('display','block'); JSObject.current_announcer = index;});
		nextDiv.animate({opacity:1, delay:1},100,function(){});*/
	}
	
}
