
/***********************************************
* Conveyor belt slideshow script-  Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/


//Specify the slider's width (in pixels)
var sliderwidth="280px"
//Specify the slider's height
var sliderheight="140px"
//Specify the slider's slide speed (larger is faster 1-10)
var slidespeed=1;
var slidespeedf=2;
//Specify the slider's direction 0 for left 1 for right
var slideDirect=1;
//Allow reverse? 0 for no 1 for yes
var allowReverse=1;

//configure background color:
slidebgcolor="#EAEAEA";
var crossmain;
//Specify the slider's images
var leftrightslide=new Array();
var finalslide='';


//Specify gap between each image (use HTML):
var imagegap="&nbsp;";

//Specify pixels gap between each slideshow rotation (use integer):
var slideshowgap=1;


////NO NEED TO EDIT BELOW THIS LINE////////////

var copyspeed=slidespeed,crossmain;

var iedom=document.all||document.getElementById
if (iedom)
//document.write('<span id="temp" style="visibility:hidden;position:absolute;top:-100px;left:-9000px">'+leftrightslide+'</span>')
var actualwidth=''
var cross_slide, ns_slide
function call_scroll(src)
	{
	//alert (123);
	//return;
	scrollingSrc = src;
	if (window.addEventListener)
		window.addEventListener('DOMMouseScroll', wheel, false);
	else
		window.onmousewheel = document.onmousewheel = wheel;
	}
function remove_scroll()
	{
	if (window.addEventListener)
		window.removeEventListener('DOMMouseScroll', wheel, false);
	else
		window.onmousewheel = document.onmousewheel = '';
	}
		

function setSlidingImages()
	{
	//alert (123);
	//return;
	initScroll("scrollarea1","scroltopimg1","scrolbotimg1");
	initScroll("scrollarea2","scroltopimg2","scrolbotimg2");
	initScroll("scrollarea3","scroltopimg3","scrolbotimg3");	
	child = document.getElementById("gallery").childNodes;
	t = 0;
	for(i=0;i<child.length;i++)
		{
		if(child[i].innerHTML != undefined)	
			{
			leftrightslide[t++]= "<a href='"+child[i].href+"'>"+child[i].innerHTML+"</a>";
			}
		}
	leftrightslide='<nobr>'+leftrightslide.join(imagegap)+'</nobr>';
	//slideshowgap = (t-1)*5;
	fillup();
	}
	
function fillup(){
	
	//return;
	if (iedom){
		crossmain=document.getElementById? document.getElementById("crm") : document.all.motioncontainer;
		menuwidth=crossmain.offsetWidth;
		cross_slide=document.getElementById? document.getElementById("test2") : document.all.test2
		cross_slide2=document.getElementById? document.getElementById("test3") : document.all.test3
		cross_slide.innerHTML=cross_slide2.innerHTML=leftrightslide
		actualwidth=document.all? cross_slide.offsetWidth : document.getElementById("temp").offsetWidth
		cross_slide2.style.left=actualwidth+slideshowgap+"px"
		}
	else if (document.layers){
		ns_slide=document.ns_slidemenu.document.ns_slidemenu2
		ns_slide2=document.ns_slidemenu.document.ns_slidemenu3
		ns_slide.document.write(leftrightslide)
		ns_slide.document.close()
		actualwidth=ns_slide.document.width
		ns_slide2.left=actualwidth+slideshowgap
		ns_slide2.document.write(leftrightslide)
		ns_slide2.document.close()
		}
	lefttime=slideDirect? setInterval("slideright()",20) : setInterval("slideleft()",20)
	}
	
window.onload=setSlidingImages

function slideright(){
	if (iedom){
	if (parseInt(cross_slide.style.left)<(actualwidth+8))
	cross_slide.style.left=parseInt(cross_slide.style.left)+copyspeed+"px"
	else
	cross_slide.style.left=parseInt(cross_slide2.style.left)+(actualwidth+slideshowgap)*(-1)+"px"
	
	if (parseInt(cross_slide2.style.left)<(actualwidth+8))
	cross_slide2.style.left=parseInt(cross_slide2.style.left)+copyspeed+"px"
	else
	cross_slide2.style.left=parseInt(cross_slide.style.left)+(actualwidth+slideshowgap)*(-1)+"px"
		
	}
else if (document.layers){
	if (ns_slide.left<(actualwidth+8))
	ns_slide.left+=copyspeed
	else
	ns_slide.left=ns_slide2.left+(actualwidth+slideshowgap)*(-1)
	
	if (ns_slide2.left<(actualwidth+8))
	ns_slide2.left+=copyspeed
	else
	ns_slide2.left=ns_slide.left+(actualwidth+slideshowgap)*(-1)
	}
}

function slideleft(){
	if (iedom){
		if (parseInt(cross_slide.style.left)>(actualwidth*(-1)+8))
		cross_slide.style.left=parseInt(cross_slide.style.left)-copyspeed+"px"
		else
		cross_slide.style.left=parseInt(cross_slide2.style.left)+actualwidth+slideshowgap+"px"
		
		if (parseInt(cross_slide2.style.left)>(actualwidth*(-1)+8))
		cross_slide2.style.left=parseInt(cross_slide2.style.left)-copyspeed+"px"
		else
		cross_slide2.style.left=parseInt(cross_slide.style.left)+actualwidth+slideshowgap+"px"
	}
	else if (document.layers){
		if (ns_slide.left>(actualwidth*(-1)+8))
		ns_slide.left-=copyspeed
		else
		ns_slide.left=ns_slide2.left+actualwidth+slideshowgap
		
		if (ns_slide2.left>(actualwidth*(-1)+8))
		ns_slide2.left-=copyspeed
		else
		ns_slide2.left=ns_slide.left+actualwidth+slideshowgap
		}
}
function ietruebody(){
	
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body;
}
function getposOffset(what, offsettype){
	var totaloffset=(offsettype=="left")? what.offsetLeft: what.offsetTop;
	var parentEl=what.offsetParent;
	while (parentEl!=null){
	totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
	parentEl=parentEl.offsetParent;
	}
	return totaloffset;
	}
function motionengine(e){
	
	var mainobjoffset=getposOffset(crossmain, "left"),
	dsocx=(window.pageXOffset)? pageXOffset: ietruebody().scrollLeft,
	dsocy=(window.pageYOffset)? pageYOffset : ietruebody().scrollTop,
	curposy=window.event? event.clientX : e.clientX? e.clientX: "";
	curposy-=mainobjoffset-dsocx;
	var leftbound=(menuwidth)/2;
	var rightbound=(menuwidth)/2;
	if(menuwidth-curposy>420)
		{
		clearInterval(lefttime);
		//copyspeed=slidespeedf;
		lefttime = setInterval("slideright()",20);
		}
	else
		{
		clearInterval(lefttime);
		//copyspeed=slidespeedf;
		lefttime = setInterval("slideleft()",20);
		}
	/*
	if (curposy>rightbound){
		alert();
		}
	else if (curposy<leftbound){
		
		}
	*/
}
function reverseSlide(e){
	//copyspeed=slidespeedf;
	motionengine(e);
	/*
	clearInterval(lefttime)
	slideDirect=slideDirect? 0 : 1
	lefttime=slideDirect? setInterval("slideright()",30) : setInterval("slideleft()",30)
	*/
}

