// JavaScript Document

var pf_scrollWidth=348;
var pf_scrollTimer;

function checkRightScroll() {
	area = document.getElementById('scrollArea');
	var sl=area.scrollLeft;
	var sw=area.scrollWidth;
	if ((sw-pf_scrollWidth)-sl<=0) {
		btn = document.getElementById('rightScrollBtn');
		btn.src="siteimages/template/arrow_none.gif";
		btn.style.cursor='';
	} else {
		btn = document.getElementById('rightScrollBtn');
		btn.src="siteimages/template/arrow_right.gif";
		btn.style.cursor='pointer';
	}
}

function checkLeftScroll() {
	area = document.getElementById('scrollArea');
	var sl=area.scrollLeft;
	var sw=area.scrollWidth;
	if (sl<=0) {
		btn = document.getElementById('leftScrollBtn');
		btn.src="siteimages/template/arrow_none.gif";
		btn.style.cursor='';
	
	} else {
		btn = document.getElementById('leftScrollBtn');
		btn.src="siteimages/template/arrow_left.gif";
		//rxSn(btn);
		btn.style.cursor='pointer';
	}
}

function pf_scrollRight() {	
	window.clearTimeout(pf_scrollTimer);
	scrollToThumb(1,1);
}

function pf_scrollLeft() {	
	window.clearTimeout(pf_scrollTimer);
	scrollToThumb(1,-1);
}

function scrollToThumb(init,direction) {
	area = document.getElementById('scrollArea');
	
	var leftToGo = area.scrollLeft % 116;
	var multiplier = 1;
	
	
	
	if (direction <=1) {
	if (leftToGo > 10) { multiplier = 3; }
	if (leftToGo > 50) { multiplier = 10;}
	var ltg=leftToGo;
	}
	
	if (direction >=1) {
	if (leftToGo > 0) { multiplier = 10; }
	if (leftToGo > 50) { multiplier = 3;}
	if (leftToGo > 90) { multiplier = 1; }
	
	var ltg = 116-(leftToGo);
	}
	

	
	//tr(area.scrollWidth-(area.scrollLeft+pf_scrollWidth)+' LTG= '+ltg);
	
	if ((area.scrollWidth-(area.scrollLeft+pf_scrollWidth)) % 116!=0 || init==1) {
		area.scrollLeft +=(direction*multiplier);
		
		
		
		pf_scrollTimer = window.setTimeout("scrollToThumb(0,"+direction+")",10);
	} else {
		checkRightScroll();
		checkLeftScroll();
		window.clearTimeout(pf_scrollTimer);
	}
	
	
	
}

function sm(thmb) {
	var newUrl = new String(thmb.src);
	newUrl = newUrl.replace('_sm','');
	//var  fx = new Spry.Effect.DoFade('mainImage', {duration: 0, from: 100, to: 0, toggle: false, finish: doSwap(newUrl)});
	//fx.start();
doSwap(newUrl);
}

function doSwap(newUrl) {
	document.getElementById('mainImage').src=newUrl;
}

function tr(msg) {
	//document.getElementById('tracer').innerHTML = msg;
}


