
var direction = 0;	
var tNailSize = 134;
var cur_location = 0;
var next_loaction =0;
var moveFlag = 'stop';
var move_increments = 5; //px to move with each step
var slideWidth = "10000"; //set in init
var maxSlideLeftPosition = 0;

function startSlide(e)
	{
		if(document.all)e = event;
		var id = this.id;
		if(this.id=='arrow_right'){
			moveFlag = 'right';
		}
		if(this.id=='arrow_left'){
			moveFlag = 'left';
		}
	}
	
	function releaseSlide()
	{
				moveFlag = 'stop';
				var msg = (maxSlideLeftPosition * -1) + " " + cur_location;

	}
		
	function gallerySlide()
	{   
			if(moveFlag != 'stop'){
				if(	moveFlag == 'right' && (maxSlideLeftPosition * -1) < cur_location)	{
				 var step = cur_location  - move_increments;
				 document.getElementById('theImages').style.left = step +'px';
				 cur_location = step;
				}
				if(	moveFlag == 'left' && cur_location < 0 )	{
				 var step = cur_location  + move_increments;
				 document.getElementById('theImages').style.left = step +'px';
				 cur_location = step;
				}
			}
			 setTimeout('gallerySlide()',20);
	}
	
	
	function initSlideShow()
	{

		document.getElementById('arrow_left').onmousemove = startSlide;
		document.getElementById('arrow_left').onmouseout = releaseSlide;
		document.getElementById('arrow_right').onmousemove = startSlide;
		document.getElementById('arrow_right').onmouseout = releaseSlide;
		
		imageGalleryObj = document.getElementById('theImages');
	  imageGalleryObj = document.getElementById('theImages');
		var slideshowImages = imageGalleryObj.getElementsByTagName('IMG');
		slideWidth = (slideshowImages.length +1) * (tNailSize + slideshowImages[0].style.paddingLeft)  ;
   	document.getElementById('theImages').style.width = slideWidth +"px";
   	maxSlideLeftPosition = document.getElementById('theImages').offsetWidth - (tNailSize * 3) ;
		gallerySlide( );
	}

	function showPreview(imagePath,imageIndex){
		if(displayWaitMessage){
			document.getElementById('waitMessage').style.display='inline';
		}

		document.getElementById('main').style.background	= "url(" + imagePath + ")";
	}
	
	
	//addOnload(initSlideShow)

	window.onload = initSlideShow;
