/*
*/
var leagues;

Event.observe(window, 'load', function () { leagues=new Leagues();}, false);

function Leagues()
{
	this.totalItems=0;
	this.items=null;
	
	
	// 0 = stand
	// 1 = speelweek
	this.view=0;
	
	
	this.itemSearch="league_1";
	
	this.getLeagues();
}

Leagues.prototype.setView=function(view)
{
	this.view=view;
}

Leagues.prototype.toggle=function()
{
	this.show(this.itemSearch);
}


Leagues.prototype.show=function(itemSearch)
{
	this.itemSearch=itemSearch;
		
	var standDiv=null;
		
	if(this.view==0)
	{
		standDiv=$("stand_1");
		itemSearch="stand_" + itemSearch;
	} else {
		standDiv=$("stand_2");
		itemSearch="speelweek_" + itemSearch;		
	}
	
	if(standDiv)
	{
		var childItems=$(standDiv).immediateDescendants();
		
				
		childItems.each(function(item)
			{
				itemDiv=$(item);
				if(itemSearch == itemDiv.id)
				{
					item.style.display="block";
				} else {
					
					item.style.display="none";
				}
			}
		);
		
	}
	

}


Leagues.prototype.getLeagues=function()
{
	if(this.items=document.getElementsByClassName('leagueLogo'))
	{
		this.items.each(function(item)
			{
				item.onclick=function()
				{
					leagues.show(this.rel);
				}
			}
		);
	}
}