var Pixelhaus = {
	panelDelay: null,
	lastClicked: null,
	
	changedPanel: function ( clicked )
	{
		clearTimeout (this.panelDelay);
		this.lastClicked = clicked;
		this.panelDelay = setTimeout ("Pixelhaus.advancePanel()", 10000);
	},
	
	advancePanel: function ()
	{
		if ( this.lastClicked.next().length == 0 )
		{
			nextClick = this.lastClicked.parent().find("li:first-child");
		}
		else
		{
			nextClick = this.lastClicked.next();
		}
		
		nextClick.click();
	}
};

$(function()
{
	$("#panels div").width (parseInt ($("#panel-container").width()));
	$("#panels").width (parseInt ($("#panel-container").width()) * $("#panels div").length);
	
	$("#panel-selector li").click (function()
	{
		$("#panel-selector li").removeClass ("selected");
		$(this).addClass ("selected");

		$("#panel-container").scrollTo ($(this).find ("a").attr ("href"), 800);
		
		Pixelhaus.changedPanel ($(this));
		
		return false;
	}).first().click();
});
