window.onload = init;

function init()
{
	
	start();
}



function showImage(id)
{
	var str= document.getElementById(id).src;
	document.getElementById(id).style.display="block";
	
	if (!(document.getElementById('MainImage') == null)) {
		document.getElementById('MainImage').src = str.replace("/thumb_", "/");
	}
}

function showMe(id)
{
	hideAllPhotos();
	document.getElementById(id).style.display="block";
}

function hideAllPhotos()
{
	i=0;
	id=0;
	
	do
	{
		document.getElementById(id).style.display="hide";
		i++;
		id = i;
	} while (document.getElementById(id));	
}

function getImageCount()
{
	i=0;
	id=0;
	
	do
	{
		i++;
		id = i;
	} while (document.getElementById(id));
	
	return i;
}

var clipTop = 0;
var clipLeft = 0;
var clipWidth = 570;
var clipRight = 530;
var clipBottom = 85;
var topper = 0;
var leftie = 25;
var lyrheight = 0;
var lyrwidth = 0;
var time,amount,theTime,theHeight,DHTML;

function start()
{
	
	DHTML = (document.getElementById || document.all || document.layers)
	
	if (!DHTML) return;
		
	var x = new getObj("thumbBox");
	if (document.layers)
	{
	
		lyrheight = x.style.clip.bottom;
		lyrheight += 85;
		lyrwidth = x.style.clip.right;
		//alert(lyrwidth);
		lyrwidth += 100;
		x.style.clip.top = clipTop;
		x.style.clip.left = 0;
		x.style.clip.right = clipWidth;
		x.style.clip.bottom = clipBottom;
		
	}
	else if (document.getElementById || document.all)
	{
		lyrheight = x.obj.offsetHeight;
		//lyrwidth = x.obj.offsetWidth;
		var total = getImageCount();
		lyrwidth = total * 106;
		//alert(lyrwidth);
		var clipstring = 'rect(0,'+(lyrwidth)+'px,'+clipBottom+'px,'+clipLeft+'px)';
		x.style.clip = clipstring;
		
	}
	showImage(0)
}

function scrollayer(layername,amt,tim)
{
	if (!DHTML) return;
	thelayer = new getObj(layername);
	if (!thelayer) return;
	amount = amt;
	theTime = tim;
	realscroll();
}

function realscroll()
{
	if (!DHTML) return;
	clipLeft += amount;
	clipRight += amount;
	leftie -= amount;
	
	if ((clipLeft < 0) || (clipRight > (lyrwidth)))
	{
		clipLeft -= amount;
		clipRight -= amount;
		leftie += amount;
		return;
	}
	
	if (document.getElementById || document.all)
	{
		clipstring = 'rect(0,'+clipRight+'px,85,'+clipLeft+'px)';
		thelayer.style.clip = clipstring;
		thelayer.style.left = leftie + 'px';
	}
	else if (document.layers)
	{
		thelayer.style.clip.left = clipLeft;
		thelayer.style.clip.right = clipRight;
		thelayer.style.left = leftie;
	}
	time = setTimeout('realscroll()',theTime);
}

function stopScroll()
{
	if (time) clearTimeout(time);
}

function getObj(name)
{
  if (document.getElementById)
  {
  	this.obj = document.getElementById(name);
	this.style = document.getElementById(name).style;
  }
  else if (document.all)
  {
	this.obj = document.all[name];
	this.style = document.all[name].style;
  }
  else if (document.layers)
  {
   	this.obj = document.layers[name];
   	this.style = document.layers[name];
  }
}
