//####################################################################################
// StringUrlSlid Class
function StringUrlSlid(text, url)
{
	// properties
	this.Text = text;
	this.Url  = url;
	
	// Public : GetLink
	this.GetLink = function(index){
		return this.SubStringText(index);
	}
	
	// Private : SubString
	this.SubStringText = function(length){
		return this.Text.substring(0,length);
	}
	
	// internal : Write
	this.Write = function(Element, length){
		if( length == 0 ) return;
		
		Element.innerHTML = this.GetLink(length);
		if( this.Text.length != length ){
			Element.href = this.Url;
			Element.innerHTML += ( length % 2 )? "-" : "_";
		}
	}
}

//####################################################################################
// StringUrlSlidCollection Class
function StringUrlSlidCollection(ElementID)
{
	// properties
	this.Items = new Array();
	this.SelectedIndex = 0;
	this.CharacterDelay = 50;		// in MilliSecond private
	this.ItemDelay		= 5000;		// in MilliSecond private
	this.TimeDelay = this.CharacterDelay;
	this.AssociatedElement = document.all[ElementID];	// private
	this._currentCharacterIndex = 0;					// private

	// public : Add
	this.Add = function(Text, Url){
		this.Items[this.Items.length] = new StringUrlSlid(Text,Url);
	}
	
	// Public : Slid
	this.Slid = function(){
		if( this.Items.length == 0 ) return;
		
		if( !this.SlidCurrentItem() ){
			this.Move();
			this.TimeDelay = this.ItemDelay;
		}
		else
			this.TimeDelay = this.CharacterDelay;

	}

	// Private : SlidCurrentItem
	this.SlidCurrentItem = function(){
		var selectedItem = this.Items[this.SelectedIndex];

		if( this._currentCharacterIndex <= selectedItem.Text.length  )
			selectedItem.Write(this.AssociatedElement, this._currentCharacterIndex++);
		else{
			this._currentCharacterIndex = 0;
			return false;
		}
		
		return true;
	}

	// Private : Move
	this.Move = function(){
		if( this.SelectedIndex < this.Items.length-1 )
			this.SelectedIndex++;
		else
			this.SelectedIndex = 0;
	}
	

}