Peli_Pager = new function()
{
	
	this.updatePage = function(target)
	{
		var url;
		
		if (typeof target == 'object') {
			url = $(target).attr('href');
		} else {
			url = target;
		}
		
		if (jQuery.browser.msie) {
			var host = window.location.hostname;
			if (url.length <= 1) {
				url = '/index/index';
			}
			
			window.location = 'http://' + host + url + '#topMenu';
		} else {
			jQuery.get(url, {}, function(data) {
				$('#content').html(data);
				var pageNum = url.replace(/.*page\//, '');
				window.location.hash = '#p' + pageNum;
				window.scrollTo(0, $('#topMenu').offset().top);
			});
		}
		
		return false;
	};
	
	this.onLoad = function()
	{
		if (jQuery.browser.msie) {
			return;
		}
		
		var pageNum = window.location.hash.replace(/#p/, '');
			
		if (!pageNum || pageNum == 1) {
			return;
		}
		
		var pathname = window.location.pathname;
		if (pathname != '/') {
			pathname = pathname.replace(/\/$/, '');
		}
		
		this.updatePage(pathname + '/page/' + pageNum);
	}
	
}

