var $j = jQuery.noConflict();
var si;
var c;
var u;
var w;
var f=5;

function scrollRight() {
	var px = u.css('left').split('px');
	px = Number(px[0]);
	if(px > (w*-1)) {
		var newpx = px-(1*f)+'px';
		u.css('left', newpx);
	}
	else {
		clearInterval(si);
	}
}

function scrollLeft() {
	var px = u.css('left').split('px');
	px = Number(px[0]);
	if(px < 0) {
		var newpx = px+(1*f)+'px';
		u.css('left', newpx);
	}
	else {
		clearInterval(si);
	}
}

var uInnerWidth = 0;

function updateUInnerWidth(i, el) {
	uInnerWidth += ($j(el).attr('width')+20);
}

$j(document).ready(
	function() {
		c = $j('#product_nav');
		u = $j('#product_nav_list', c);
		
		$j('#product_nav_list > li > a > img').each(updateUInnerWidth);
		
		w = uInnerWidth - c.outerWidth();
		
		//w = $j('#product_nav_list > li').length*(50+20) - c.outerWidth();
		
		$j('#right').click(
			function() {
				return false;
			}
		);
		
		$j('#left').click(
			function() {
				return false;
			}
		);
		
		$j('#right').mouseover(
			function() {
				si = setInterval(scrollRight, 10);
			}
		);
		$j('#right').mouseout(
			function() {
				clearInterval(si);
			}
		);
		$j('#left').mouseover(
			function() {
				si = setInterval(scrollLeft, 10);
			}
		);
		$j('#left').mouseout(
			function() {
				clearInterval(si);
			}
		);
	}
);