var global_lists=new Array();

function List() 
{
	this.fade_length=1000;

	this.preload=Array();
	this.html=new Array();
	this.cur_item=0;
	this.selected_class='selected';	


	this.id='lit_'+global_lists.length;
	
	global_lists[global_lists.length]=this;
}

function Set(parameter,value)
{
	if(parameter=='fade_length')  		
		this.fade_length=value;
	if(parameter=='selected_class')  		
		this.selected_class=value;
	if(parameter=='curlink_id')  		
		this.curlink_id=value;
}

function AddItem(html) 
{
	this.html[this.html.length]=html;
}

function Display()
{
	document.write('<div id="'+this.id+'">'+this.html[0]+'</div>');  
	
}

function Preload(image)
{
  	var indx=this.preload.length;
	this.preload[indx]=new Image();
	this.preload[indx].src=image;	
}

function OnLoad()
{
  	jQuery('#'+this.curlink_id).addClass('selected');	  
}

function SwitchTo(index,cur_link)
{
	if(index>=this.html.length)  
		index=0;
		
	this.cur_item=index;

  	jQuery('#'+this.curlink_id).removeClass(this.selected_class);	  
  	this.curlink_id=cur_link;
  	jQuery('#'+this.curlink_id).addClass(this.selected_class);	  


	this.FadeOut(index)
}

function FadeOut(index)
{  
  	var ss=this;
	jQuery('#'+this.id).fadeOut(this.fade_length,function(){ss.FadeIn(index);});
}

function FadeIn(index)
{
  	var ss=this;
  	
  	if(index==this.cur_item)
  	{
	  	jQuery('#'+this.id).html(this.html[this.cur_item]);
		jQuery('#'+this.id).fadeIn(this.fade_length);  
	}
}


List.prototype.Preload=Preload;
List.prototype.AddItem=AddItem;
List.prototype.Display=Display;
List.prototype.OnLoad=OnLoad;
List.prototype.FadeOut=FadeOut;
List.prototype.FadeIn=FadeIn;
List.prototype.SwitchTo=SwitchTo;
List.prototype.Set=Set;




jQuery.noConflict();
jQuery(document).ready(function() 
{
	
	for(var i=0;i<global_lists.length;i++)
		global_lists[i].OnLoad();
});
