/* This script and many more are available free online at
The JavaScript Source!! http://javascript.internet.com
Created by: Robert Nyman | http://robertnyman.com/ */
function removeHTMLTags(strInputCode){
	/* 
		This line is optional, it replaces escaped brackets with real ones, 
		i.e. < is replaced with < and > is replaced with >
	*/	
 	strInputCode = strInputCode.replace(/&(lt|gt);/g, function (strMatch, p1){
	 	return (p1 == "lt")? "<" : ">";
	});

 	var strTagStrippedText = strInputCode.replace(/<\/?[^>]+(>|$)/g, "");
	return strTagStrippedText;
 	
}
// Use the alert below if you want to show

mediaCrew = function(){
	//input = removeHTMLTags( input );
	//input = jQuery.trim(input);
	var inputs;
	var $msgContainer;
	var current;
	var timer;
	var rate = 4000;
	this.start = function( input, msgContainer, linksContainer ){
		inputs = input.split('||');
		var lp;
		for (i in inputs){
			lp = inputs[i].lastIndexOf('-'); 
			if (lp != -1){
				inputs[i] = inputs[i].substring(0,lp-1)+'<span class="mpress_from">'+inputs[i].substring(lp)+'</span>';
			}
		}
		$msgContainer = $(msgContainer);
		current = 0;
		show( current );
		$(linksContainer).find('a').each(function(i){
			$(this).click(function(e){
				show(i);
				return false;
			});
		});
	};
	function timerFunc(){ 
		current++;
		if ( current >= inputs.length ) current = 0;
		$msgContainer.html( inputs[current] );
		setTimer();
	};
	function show(i){ 
		clearTimeout( timer );
		if ( i < 0  ||  i >= inputs.length ) i = 0;
		current = i;
		$msgContainer.html( inputs[i] );
		setTimer();
	};	
	function setTimer(){
		timer = setTimeout( timerFunc, rate);
	};
	
};
