goFast = false;
goRight = true;

hcWidth = 0;

nProductos = 0;
arrayProductos = '';

function intval(v) {
	v = parseInt(v);
	return isNaN(v) ? 0 : v;
}

function myLoad(){

	resetCarrusel();
	$('#hcLoading').hide();
	$('#hcBtnRight').hover(
		function(){
			goFast = true;
			goRight = true;
		},
		function(){
			goFast = false;
		}
	);
	$('#hcBtnLeft').hover(
		function(){
			goFast = true;
			goRight = false;
		},
		function(){
			goFast = false;
		}
	);
	goCarrusel();
}

function resetCarrusel(){
	$('#hcProductos img').each(function(){
		hcWidth += $(this).width() + 4;
	});
	$('#hcProductos').css('width', hcWidth+'px')
}

function goCarrusel(){
	pos = intval($("#hcProductos").css("left"));
	vel = goFast ? 15 : 2;
	if(goRight){
		if((hcWidth + pos) > 398){
			$("#hcProductos").animate({left:pos-vel}, 'fast' ,'linear', goCarrusel);
		}
		else{
			goRight = false;
			setTimeout('goCarrusel()',3000);
		}		
	}
	else{
		if(pos < 0){
			$("#hcProductos").animate({left:pos+vel}, 'fast' ,'linear', goCarrusel);
		}
		else{
			goRight = true;
			setTimeout('goCarrusel()',3000);
		}
	}
	
}
