window.addEvent('domready', function() {
	init_ajax();
});
window.addEvent('load', function() {
	slide();
});
	

function slide() 
{
	slide = $('reel').getFirst();
	speed = 1;
	setInterval(function(){
		currItem = slide.getFirst();
		newML = parseInt(currItem.getStyle('marginLeft')) - speed;
		maxML = currItem.getSize().size.x * -1;
		currItem.setStyle('marginLeft', newML);
		if (newML <= maxML)	
		{
			slide.appendChild(currItem);
			currItem.setStyle('marginLeft',0);
		}
	}, 30);
}

function init_ajax()
{
	$$('#menu li').each(function(li) {
		//url = li.className;
		a = li.getFirst();
		url = a.href.replace('http://' + location.host + '/','');
		if (url.indexOf('http://') != -1)
		{
			a.addEvent('click', function(e){
				e = new Event(e).stop();
				window.open(e.target.href);
			});
		}
		else
		{
			a.href = '#' + url;
			a.addEvent('click', switch_page.bindWithEvent(a, url));
		}
	});
	if (location.hash.trim() != "")	switch_page('',location.hash.substr(1));
}

function switch_page(e, url)
{
	var page_switch = new Ajax('ajax/' + url, {
		method:'get',
		update: $('content'),
		onComplete: function() {
			$('container').className = url;
		}
	}).request();
}
