var Theme = new Class
({
	initialize: function()
	{
		this.contentDiv = 'content_html';
	},
	
	DomReady: function()
	{
		$$('.menu_item').each(function(item){
			item.addEvent('mousemove', function(e){
				var itemX = item.getPosition().x;
				var itemWidth = item.getSize().x;
				item.setStyle('background-position',[e.page.x - itemX - 58,-27]);
			});
			
			item.addEvent('mouseout', function(e){
				item.setStyle('background-position',[0,0]);
			});
		});
		
		this.LinkAnim();
	},
	
	LoadStart: function()
	{
		document.id('loading').setStyle('visibility','visible');
	},
	
	LoadComplete: function(tree,elements,html,js)
	{
		document.id(this.contentDiv).set('html',html);
		document.id('loading').setStyle('visibility','hidden');
		
		this.LinkAnim();
	},
	
	LoadFailure: function()
	{
		document.id(this.contentDiv).set('html','<h2>Connection Failed</h2><p>Could not connect to the server.  Please try again later.</p>');
		document.id('loading').setStyle('visibility','hidden');
	},
	
	LinkAnim: function()
	{
		document.id('content_html').getElements('a').each(function(a)
		{
			if(a.getParent('p') != null || a.getParent('li') != null || a.getParent('span') != null)
			{
				var morph = new Fx.Morph(a,{ 'duration':'300', link:'cancel' });
				a.addEvents(
				{
					'mouseenter' : function() 
					{ 
						morph.start(
						{ 
							'border-bottom-color':'#338cc6',
							'color':'#7bbde8'
						}); 
					},
					
					'mouseleave' : function() 
					{ 
						morph.start(
						{ 
							'border-bottom-color':'#080808',
							'color':'#0065b0'
						}); 
					}
				});
			}
		});
	}
});