YPLocationIndex =
{
	curPage : 1,

	init : function()
	{
		Event.observe( $('prevLocationPage'), 'click', YPLocationIndex.handleClick );
		Event.observe( $('nextLocationPage'), 'click', YPLocationIndex.handleClick );
		
		$$('a.locationPageNav').each( function(o){
			
			Event.observe( o, 'click', YPLocationIndex.handleClick );
		});
	},
	
	handleClick : function(e)
	{
		var el = Event.element(e);
		
		switch (el.id)
		{
			case 'prevLocationPage':
				YPLocationIndex.selectPage (YPLocationIndex.curPage-1);
				break;
			case 'nextLocationPage':
				YPLocationIndex.selectPage (YPLocationIndex.curPage+1);
				break;
			default:
				YPLocationIndex.selectPage (parseInt(el.innerHTML));
				break;
		}
	},
	
	selectPage : function(i)
	{			
		if (i < 1 || i > parseInt($('totalPages').innerHTML))
		{	
			return;
		}
	
		var curPage = $('locationPage_' + (YPLocationIndex.curPage-1));
		var curNav = $('locationPageNav_' + YPLocationIndex.curPage);
		
		curPage.hide();
		curNav.removeClassName('selected');
		
		var nextPage = $('locationPage_' + (i - 1));
		var nextNav = $('locationPageNav_' + i);
		
		nextPage.show();
		nextNav.addClassName('selected');
		
		YPLocationIndex.curPage = i;
		$('curPage').update(i);
	}





}

Event.observe(window, 'load', YPLocationIndex.init);
