function _hookLists()
{
	$('*[list=horizontal]').each(function(){
		widget = $(this);
		$(widget).attr('page', '1');
		contents = $(widget).find('.contents');
		items = $(contents).find('.list li>div');
		lis = $(contents).find('.list li');
		$(items).width($(items).width());
		$(this).find('.list').width(($(items).outerWidth(true) * $(items).length) + 5);

		$(contents).width($(widget).width() - ($(widget).children('.arrowLeft').width() + $(widget).children('.arrowRight').width()));
		perpage = Math.floor($(contents).width() / $(items).outerWidth(true));
		var newWidth = $(items).outerWidth(true) * perpage;
		if (!isNaN(newWidth)) {
			$(contents).width(newWidth);
		}
		pages = (window.mainpage == 1) ? lis.length : Math.ceil($(items).length / perpage);
		//console.log('pages var: '+pages);
		var contentMargin = Math.round( (widget.width() - $(contents).width()) / 2);
                if (window.mainpage == 1) {
                        //we are on the main TK page. Need to make a couple of adjustments
						pages = lis.length;
						$(contents).css({marginLeft: contentMargin+'px'});
						$('.arrowRight').css('margin-top', '-345px');
		}
		$(widget).children('.arrowLeft').addClass('noArrow');
		if (pages > 1)
		{
			$(widget).children('.arrowRight').removeClass('noArrow');
		}
	});
	$('*[list=horizontal] .arrowLeft').unbind().click(function(){
		widget = $(this).parents('*[list=horizontal]');
		contents = $(widget).find('.contents');
		items = $(contents).find('.list li>div');
		lis = $(contents).find('.list li');
		
		perpage = Math.round($(contents).width() / $(items).outerWidth(true));
		page = parseInt(($(widget).attr('page'))?$(widget).attr('page'):0);
		pages = (window.mainpage == 1) ? lis.length : Math.ceil($(items).length / perpage);
		
		var contentMargin = Math.round( (widget.width() - $(contents).width()) / 2);
		
		var divDiff =  $(contents).find('.list li:first').width() - ($(items).outerWidth(true) * perpage);
		
		if (divDiff < 1) divDiff = 0;
		

		if (page > 1)
		{
			$(widget).attr('page', (page - 1));
			$(contents).find('.list').animate({
				'left':'+='+(($(contents).find('.list li>div').outerWidth(true) * perpage) + divDiff)+'px'
			}, 1000);

			$(this).parents('*[list=horizontal]').children('.arrowRight').removeClass('noArrow');
		}
		if ((page - 1) <= 1) {
			$(this).addClass('noArrow');
		}
		else {
			$(this).removeClass('noArrow');
		}
	});
	$('*[list=horizontal] .arrowRight').unbind().click(function(){
		widget = $(this).parents('*[list=horizontal]');
		contents = $(widget).find('.contents');
		items = $(contents).find('.list li>div');
		lis = $(contents).find('.list li');
		
		perpage = Math.round($(contents).width() / $(items).outerWidth(true));
		page = parseInt(($(widget).attr('page'))?$(widget).attr('page'):0);
		pages = (window.mainpage == 1) ? lis.length : Math.ceil($(items).length / perpage);
		var contentMargin = Math.round( (widget.width() - $(contents).width()) / 2);
		
		var divDiff =  $(contents).find('.list li:first').width() - ($(items).outerWidth(true) * perpage);
		
		if (divDiff < 1) divDiff = 0;
		
		if (page < pages)
		{
			$(widget).attr('page', (page + 1));
			$(contents).find('.list').animate({
				'left':'-='+(($(contents).find('.list li>div').outerWidth(true) * perpage) + divDiff)+'px'
			}, 1000);

			$(this).parents('*[list=horizontal]').children('.arrowLeft').removeClass('noArrow');
		}

		if ((page + 1) >= pages) {
			$(this).addClass('noArrow');
		}
		else {
			$(this).removeClass('noArrow');
		}
	});
}

function _hookListsOLD()
{
	$('*[list=verticle]').each(function(){
		widget = $(this);
		$(widget).attr('page', '1');
		contents = $(widget).find('.contents');
		items = $(contents).find('.list li');
		$(items).height($(items).height());

		perpage = Math.round($(contents).height() / $(items).height());
		$(contents).height($(items).height() * perpage);
		pages = Math.round($(items).length / (perpage - 1));

		$(widget).children('.arrowUp').addClass('noArrow');
		if (pages > 1)
		{
			$(widget).children('.arrowDown').removeClass('noArrow');
		}
	});
	$('*[list=verticle] .arrowUp').click(function(){
		widget = $(this).parents('*[list=verticle]');
		contents = $(widget).find('.contents');
		items = $(contents).find('.list li');

		perpage = Math.round($(contents).height() / $(items).height());
		page = parseInt(($(widget).attr('page'))?$(widget).attr('page'):0);
		pages = Math.round($(items).length / (perpage - 1));

		if (page > 1)
		{
			$(widget).attr('page', (page - 1));
			$(contents).find('.list').animate({
				'top':'+='+($(contents).find('.list li').height() * (perpage - 1))+'px'
			}, 1000);

			$(this).parents('*[list=verticle]').children('.arrowDown').removeClass('noArrow');
		}
		if ((page - 1) <= 1) {
			$(this).addClass('noArrow');
		}
		else {
			$(this).removeClass('noArrow');
		}
	});
	$('*[list=verticle] .arrowDown').click(function(){
		widget = $(this).parents('*[list=verticle]');
		contents = $(widget).find('.contents');
		items = $(contents).find('.list li');

		perpage = Math.floor($(contents).height() / $(items).height());
		page = parseInt(($(widget).attr('page'))?$(widget).attr('page'):0);
		pages = Math.round($(items).length / (perpage - 1));

		if (page < pages)
		{
			$(widget).attr('page', (page + 1));
			$(contents).find('.list').animate({
				'top':'-='+($(contents).find('.list li').height() * (perpage - 1))+'px'
			}, 1000);

			$(this).parents('*[list=verticle]').children('.arrowUp').removeClass('noArrow');
		}

		if ((page + 1) >= pages) {
			$(this).addClass('noArrow');
		}
		else {
			$(this).removeClass('noArrow');
		}
	});

	$('*[list=horizontal]').each(function(){
		widget = $(this);
		$(widget).attr('page', '1');
		contents = $(widget).find('.contents');
		items = $(contents).find('.list li');
		$(items).width($(items).width());

		perpage = Math.floor($(contents).width() / $(items).width());
		$(contents).width($(items).width() * perpage);
		pages = Math.round($(items).length / (perpage - 1));

		$(widget).children('.arrowLeft').addClass('noArrow');
		if (pages > 1)
		{
			$(widget).children('.arrowRight').removeClass('noArrow');
		}
	});
	$('*[list=horizontal] .arrowLeft').click(function(){
		widget = $(this).parents('*[list=horizontal]');
		contents = $(widget).find('.contents');
		items = $(contents).find('.list li');

		perpage = Math.round($(contents).width() / $(items).width());
		page = parseInt(($(widget).attr('page'))?$(widget).attr('page'):0);
		pages = Math.round($(items).length / (perpage - 1));

		if (page > 1)
		{
			$(widget).attr('page', (page - 1));
			$(contents).find('.list').animate({
				'left':'+='+($(contents).find('.list li').width() * (perpage - 1))+'px'
			}, 1000);

			$(this).parents('*[list=horizontal]').children('.arrowRight').removeClass('noArrow');
		}
		if ((page - 1) <= 1) {
			$(this).addClass('noArrow');
		}
		else {
			$(this).removeClass('noArrow');
		}
	});
	$('*[list=horizontal] .arrowRight').click(function(){
		widget = $(this).parents('*[list=horizontal]');
		contents = $(widget).find('.contents');
		items = $(contents).find('.list li');

		perpage = Math.round($(contents).width() / $(items).width());
		page = parseInt(($(widget).attr('page'))?$(widget).attr('page'):0);
		pages = Math.round($(items).length / (perpage - 1));

		if (page < pages)
		{
			$(widget).attr('page', (page + 1));
			$(contents).find('.list').animate({
				'left':'-='+($(contents).find('.list li').width() * (perpage - 1))+'px'
			}, 1000);

			$(this).parents('*[list=horizontal]').children('.arrowLeft').removeClass('noArrow');
		}

		if ((page + 1) >= pages) {
			$(this).addClass('noArrow');
		}
		else {
			$(this).removeClass('noArrow');
		}
	});
}

