$(document).ready(function() {
	//Bind the links to change the page...
	$('div#pager li a').livequery(function() {
		$(this).click(function() {
			updatePager($(this).attr('href'));
			return false;
		});
	});
	
	//Bind the select field to change the page...
	$('div#pager li select').livequery(function() {
		$(this).change(function() {
			updatePager($(this).val());
		});
	});
});

function updatePager(pageNumber) {
	//IE appends the site information to the href before it's passed into this function, strip it all off.
	if(pageNumber.indexOf('/') != -1)
		pageNumber = pageNumber.split('/')[4];
	//Update the pager...
	$('div#pager').load('/_shared/ajaxPaging.cfm?pageNum=' + pageNumber, {location: $("body").attr("id")}, function(data) {});
	
	//Update the listing div
	startRow = ((pageNumber - 1) * $('input#maxRows').val()) + 1;
	if($('div#' + $('input#ajaxLoadDiv').val()).size() > 0)
		$('div#' + $('input#ajaxLoadDiv').val()).load($('input#ajaxLoadPath').val() + '?startRow=' + startRow + '&maxRows=' + $('input#maxRows').val());
	else
		$('table#' + $('input#ajaxLoadDiv').val() + ' tbody').load($('input#ajaxLoadPath').val() + '?startRow=' + startRow + '&maxRows=' + $('input#maxRows').val());
}

function updatePagerOnly(pageNumber) {
	if(pageNumber === undefined)
		pageNumber = $('input#currentPage').val();
	//Update the pager...
	$('div#pager').load('/_shared/ajaxPaging.cfm?pageNum=' + pageNumber, {location: $("body").attr("id")}, function(data) {});
}
