// JavaScript Document
	var use_debug = false;

	function debug(){
		if( use_debug && window.console && window.console.log ) console.log(arguments);
	}

	// on DOM ready
	jQuery(document).ready(function (){
		jQuery(".marquee").marquee({
			loop: -1
			// this callback runs when the marquee is initialized
			, init: function (jQuerymarquee, options){
				debug("init", arguments);

				// shows how we can change the options at runtime
				if( jQuerymarquee.is("#marquee2") ) options.yScroll = "bottom";
			}
			// this callback runs before a marquee is shown
			, beforeshow: function (jQuerymarquee, jQueryli){
				debug("beforeshow", arguments);

				// check to see if we have an author in the message (used in #marquee6)
				var jQueryauthor = jQueryli.find(".author");
				// move author from the item marquee-author layer and then fade it in
				if( jQueryauthor.length ){
					jQuery("#marquee-author").html("<span style='display:none;'>" + jQueryauthor.html() + "</span>").find("> span").fadeIn(850);
				}
			}
			// this callback runs when a has fully scrolled into view (from either top or bottom)
			, show: function (){
				debug("show", arguments);
			}
			// this callback runs when a after message has being shown
			, aftershow: function (jQuerymarquee, jQueryli){
				debug("aftershow", arguments);

				// find the author
				var jQueryauthor = jQueryli.find(".author");
				// hide the author
				if( jQueryauthor.length ) jQuery("#marquee-author").find("> span").fadeOut(250);
			}
		});
	});
	
	var iNewMessageCount = 0;
	
	function addMessage(selector){
		// increase counter
		iNewMessageCount++;

		// append a new message to the marquee scrolling list
		var jQueryul = jQuery(selector).append("<li>New message #" + iNewMessageCount + "</li>");
		// update the marquee
		jQueryul.marquee("update");
	}
	
	function pause(selector){
		jQuery(selector).marquee('pause');
	}
	
	function resume(selector){
		jQuery(selector).marquee('resume');
	}
