var NewsTicker = {

	/**
	 * set some properties...
	 */
	"ticking": null, 
	"current_id": null, 
	"current_index": null, 
	"available": [], 
	"timeout_animation": 500, 
	"timeout_tick": 5000, 

	/**
	 * function move()
	 *
	 *	manually move to next strip
	 *
	 * @param int $id (target strip ID)
	 */
	"move": function(id) {
	
		/**
		 * disable automatic ticking if running
		 */
		if (this.ticking != null) {
		 	clearTimeout(this.ticking);
		 	this.ticking = null;
		}

		/**
		 * tick
		 */
		this.tick(id);
	}, 

	/**
	 * function tick()
	 *
	 *	switch stripes with opacity animation
	 *
	 * @param int $id (target strip ID)
	 */
	"tick": function(id) {

		/**
		 * if something is displayed, hide it (we will set display to none for
		 * MSIE, in all other browsers we can use opacity animation)
		 */
		if (this.current_id != null && id != this.current_id) {
			if ("\v" == "v") {
				$("#nt_" + this.current_id).css("display", "none");
			} else {
				$("#nt_" + this.current_id).animate({opacity: 0}, this.timeout_animation);
			}
		}

		/**
		 * display selected strip, animate for non-MSIE browsers
		 */
		$("#nt_" + id).css("display", "block");
		if ("\v" != "v") $("#nt_" + id).animate({opacity: 1}, this.timeout_animation);

		/**
		 * set currently displayed strip to selected one
		 */
		this.current_id = id;
	}, 

	/**
	 * function autotick()
	 *
	 *	determine next item to display and automatically update
	 */
	"autotick": function() {

		/**
		 * determine key of next strip from array
		 */
		if (this.current_id != null) {
			this.current_index++;
			if (!this.available[this.current_index]) this.current_index = 1;
		} else {
			this.current_index = 1;
		}

		/**
		 * move to next strip
		 */
		this.move(this.available[this.current_index]);		

		/**
		 * call self, set autotick to true
		 */
		this.ticking = setTimeout("NewsTicker.autotick();", this.timeout_tick);
	}
}

