/* Force first pic to become active.. we have stored the big image url into the thumbs name property (dirtty!!!!) */

/*var first = document.getElementById('productfoto1');
if(first)
{

	img = '/resizer/resize.php?h=300&img='+encodeURIComponent(first.name);
	doSwapImage(img,false);
}
*/

/* Scrolling stuff */

var time;

function doScrollLeft(vertical)
{
	if (parseInt($('#productScrollerSub').css('left'))+5 <= 0) {
		$('#productScrollerSub').css('left', parseInt($('#productScrollerSub').css('left'))+5);
 		time = setTimeout('doScrollLeft(' + vertical + ')',20);
	} else {
		doStopScroll();
	}
}

function doScrollRight(vertical)
{
	if (parseInt($('#productScrollerSub').css('left'))-5 >= -parseInt(($('#productScrollerSub > .scroller_img_wrap').length-9) * 90) ) {
		$('#productScrollerSub').css('left', parseInt($('#productScrollerSub').css('left'))-5);
 		time = setTimeout('doScrollRight(' + vertical + ')',20);
 	} else {
		doStopScroll();
	}
}

function doStopScroll()
{
	if(time) { clearTimeout(time); }
}

var timeWeb;

function doScrollLeftWeb(vertical)
{
	if (parseInt($('#imageScrollerSub').css('left'))+5 <= 0) {
		$('#imageScrollerSub').css('left', parseInt($('#imageScrollerSub').css('left'))+5);
 		timeWeb = setTimeout('doScrollLeftWeb(' + vertical + ')',20);
	} else {
		doStopScrollWeb();
	}
};

function doScrollRightWeb(vertical)
{	
	if (parseInt($('#imageScrollerSub').css('left'))-5 >= -parseInt(($('#imageScrollerSub > .scrollerimage_img_wrap').length-6) * 88) ) {
		$('#imageScrollerSub').css('left', parseInt($('#imageScrollerSub').css('left'))-5);
 		timeWeb = setTimeout('doScrollRightWeb(' + vertical + ')',20);
 	} else {
		doStopScrollWeb();
	}
};

function doStopScrollWeb()
{
	if(timeWeb) { clearTimeout(timeWeb); }
}


/* Swap image */
//function swapImage(src)
//{
//
//	src = '/resizer/resize.php?h=300&img='+encodeURIComponent(src);
//
//	/* Check if we need to do anything */
//	if(src != document.getElementById('productimagebig').src)
//	Effect.Fade('productimagebig',{duration: 0.2, afterFinish: function(){doSwapImage(src,true);}});
//
//}
//
//
//function doSwapImage(src,appear)
//{
////	if(appear) document.getElementById('productimagebig').display = 'none';
////
////	document.getElementById('productimagebig').src = src;
////
////	if(appear) 	Effect.Appear('productimagebig',{duration: 0.2});
//return true;
//}


