/*
 * Rich HTML Ticker- by JavaScript Kit (http://www.javascriptkit.com)
 * Freeware. Created Sept 13th, 08'
 * This credit must stay intact for use
 *
 * Modified by Tim Molderez
 */

var richhtmlticker={

rotate:function(config){
	if (config.$ticker.get(0)._hoverstate=="over"){
		setTimeout(function(){richhtmlticker.rotate(config)}, config.rotatespeed)
	}
	else{
		config.$messages.eq(config.currentmsg).fadeOut(config.animateduration, function(){
			config.currentmsg=(config.currentmsg<config.$messages.length-1)? config.currentmsg+1 : 0
			config.$messages.eq(config.currentmsg).fadeIn(config.animateduration, function(){
				setTimeout(function(){richhtmlticker.rotate(config)}, config.rotatespeed)
			})
		})
	}
},

setupticker:function(config){
	config.$messages=config.$ticker.find('div.'+config.msgclass).hide()
	config.currentmsg=0
	config.$messages.hide().eq(config.currentmsg).fadeIn(config.animateduration)
	if (config.$messages.length > 1) { // Only set up the news ticker to fade in/out between messages if there's more than one message
		setTimeout(function(){richhtmlticker.rotate(config)}, config.rotatespeed)
	}
},

define:function(config){
  jQuery(document).ready(function($){
		config.$ticker=$('#'+config.id)
		if (config.$ticker.length==0)
			return
		config.$ticker.css({overflow:'hidden'}).hover(
			function(){this._hoverstate="over"},
			function(){this._hoverstate="out"}
		)
		richhtmlticker.setupticker(config)
	})
}

} //end richhtmlticker object


//////////// Declare instance of Rich HTML Ticker (invoked when page has loaded): ///////////////////////////

richhtmlticker.define({
	id: "newsTicker", //main ticker DIV id
	msgclass: "newsItem", //CSS class of DIVs containing each ticker message
	rotatespeed: 3000, //pause in milliseconds between rotation
	animateduration: 1000 //duration of fade animation in milliseconds 
})
