// Author: Dustin Diaz (http://www.dustindiaz.com)
// Author: J.Parker (http://create74.com)
// Author: ssai (hhtp://saistory.net)
// Author: nani (http://sangsangbox.net)
//
// Source: allblog.net (powered by blogcocktail.com)
//
// Last Update: 2006-11-25

var Utimeout = false;

// Main function
	function Ultimate(Utype,Umsgs,Uwidth,Uheight,Ubgcolor,Ubackground,Uspeed,Udelay,Ufirst,Ualign) {

		document.writeln('<div id="Ubox" style="position:relative; width:100%; height:'+Uheight+'px; overflow:hidden; background-image:url('+Ubackground+'); margin: 0px auto" onmouseover="Ustop(\'Utxt\');" onmouseout="Uresume();">')
		document.writeln('<div style="position:absolute; width:'+Uwidth+'px; height:'+Uheight+'px; clip:rect(0px '+Uwidth+'px '+Uheight+'px 0px); left:3px; top:0px">')

		if (Utype==0) {
			document.writeln('<div id="Utxt" style="color:'+Ubgcolor+';position:absolute; width:'+Uwidth+'px; left:0px; top:'+Uheight+'px; text-align:'+Ualign+';">')
			document.write(Umsgs[Ufirst]);
			Uscroll("Utxt",Umsgs,Uheight,Uspeed,Udelay,Ufirst);
			document.writeln('</div>')
		}

		document.writeln('</div>')
		document.writeln('</div>')
	}

// Moves
function Uscroll(IDdiv,Umsgs,Uheight,Uspeed,Udelay,Ufirst){
	ttxt=document.getElementById(IDdiv);
	Ustep=eval(Ufirst);

		ttxtTop = ttxt.style.top;
		ttxtTop = ttxtTop.substring(0,ttxtTop.length - 2);

	if (ttxtTop>0 && ttxtTop<=5){
		ttxt.style.top="0px";
		Utimeout = setTimeout("Uscroll('Utxt',Umsgs,Uheight,Uspeed,Udelay,Ustep)",Udelay);
		return;
	}
	else {
		if (ttxtTop >= Uheight*-1){
			ttxt.style.top = (ttxtTop - 5) + "px";
			Utimeout = setTimeout("Uscroll('Utxt',Umsgs,Uheight,Uspeed,Udelay,Ustep)",Uspeed);
			return;
		}
		else {
			ttxt.style.top=Uheight + "px";
			if (Ustep>=Umsgs.length-1)
				Ustep=0;
				else
				Ustep++;
			ttxt.innerHTML=Umsgs[Ustep];
			Uscroll("Utxt",Umsgs,Uheight,Uspeed,Udelay,Ustep);
		}
	}
}

// stoped
function Ustop(IDdiv) {
		if (Utimeout) {
			clearTimeout(Utimeout);
		}

		ttxt = document.getElementById(IDdiv);
		ttxt.style.top = 0 + "px";
	}

// restart
function Uresume() {
	Utimeout = setTimeout("Uscroll('Utxt',Umsgs,Uheight,Uspeed,Udelay,Ustep)",Udelay);
}
