var BottomMenu =
{
	positions: [165, 232, 340, 497, 629],
	init: function()
	{
		this.defaultPosition = 0;
		
		this.pointer = document.getElementById('bottom-menu-pointer');
		
		var eventsButton = document.getElementById('bottom-menu-events-button');
		var socialButton = document.getElementById('bottom-menu-social-button');
		var programButton = document.getElementById('bottom-menu-program-button');
		var speakersButton = document.getElementById('bottom-menu-speakers-button');
		
		if(eventsButton.className.indexOf('selected') != -1)
		{
			this.defaultPosition = 1;
		};
		if(socialButton.className.indexOf('selected') != -1)
		{
			this.defaultPosition = 2;
		};
		if(programButton.className.indexOf('selected') != -1)
		{
			this.defaultPosition = 3;
		};
		if(speakersButton.className.indexOf('selected') != -1)
		{
			this.defaultPosition = 4;
		};
		this.currentOffset = this.positions[this.defaultPosition];
		this.targetOffset = this.currentOffset;
		
		eventsButton.onmouseover = function()
		{
			BottomMenu.goTo(1);
		};
		socialButton.onmouseover = function()
		{
			BottomMenu.goTo(2);
		};
		programButton.onmouseover = function()
		{
			BottomMenu.goTo(3);
		};
		speakersButton.onmouseover = function()
		{
			BottomMenu.goTo(4);
		};
		eventsButton.onmouseout =
		socialButton.onmouseout =
		programButton.onmouseout =
		speakersButton.onmouseout = function()
		{
			BottomMenu.goTo(BottomMenu.defaultPosition);
		};
		setInterval(function(){ BottomMenu.animate(); }, 1000 / 25);
	},
	goTo: function(position)
	{
		this.targetOffset = this.positions[position];
	},
	animate: function()
	{
		this.currentOffset += (this.targetOffset - this.currentOffset) / 8;
		this.pointer.style.left = String(Math.round(this.currentOffset)) + 'px';
	}
};

var LeftMenu =
{
	init: function()
	{
		var homeButton = document.getElementById('left-menu-home-button');
		var aboutButton = document.getElementById('left-menu-about-button');
		var teamButton = document.getElementById('left-menu-team-button');
		var contactButton = document.getElementById('left-menu-contact-button');
		var eventsButton = document.getElementById('left-menu-events-button');
		var socialButton = document.getElementById('left-menu-social-button');
		var programButton = document.getElementById('left-menu-program-button');
		var speakersButton = document.getElementById('left-menu-speakers-button');
		var resourcesButton = document.getElementById('left-menu-resources-button');
		
		homeButton.onmouseover =
		aboutButton.onmouseover =
		teamButton.onmouseover =
		contactButton.onmouseover =
		resourcesButton.onmouseover = function()
		{
			BottomMenu.goTo(0);
		};
		eventsButton.onmouseover = function()
		{
			BottomMenu.goTo(1);
		};
		socialButton.onmouseover = function()
		{
			BottomMenu.goTo(2);
		};
		programButton.onmouseover = function()
		{
			BottomMenu.goTo(3);
		};
		speakersButton.onmouseover = function()
		{
			BottomMenu.goTo(4);
		};
		
		homeButton.onmouseout =
		aboutButton.onmouseout =
		teamButton.onmouseout =
		contactButton.onmouseout =
		eventsButton.onmouseout =
		socialButton.onmouseout =
		programButton.onmouseout =
		speakersButton.onmouseout =
		resourcesButton.onmouseout = function()
		{
			BottomMenu.goTo(BottomMenu.defaultPosition);
		};
		
		/*var anchors = document.getElementById('left-menu').getElementsByTagName('a');
		for(var i = 0; i < anchors.length; i++)
		{
			anchors[i].onmousedown = function()
			{
				this.className += ' active';
			}
			anchors[i].onmouseup = function()
			{
				this.className = this.className.replace(/(^|\s)active($|\s)/g, '');
			}
		}*/
	}
};

window.onload = function()
{
	BottomMenu.init();
	LeftMenu.init();
};
