var restarea=6;      
var maxspeed=4;      
var maxwidth=1000;       
var startpos=0;      
var endofgallerymsg="<span>End of Gallery</span>";

function enlargeimage(path, optWidth, optHeight){ //function to enlarge image. Change as desired.
	var actualwidth934=typeof optWidth!="undefined" ? optWidth : "600px" //set 600px to default width
	var actualHeight=typeof optHeight!="undefined" ? optHeight : "500px" //set 500px to  default height
	var winattributes="width="+actualwidth934+",height="+actualHeight+",resizable=yes"
	window.open(path,"", winattributes)
}

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

var iedom934=document.all||document.getElementById, scrollspeed=0, movestate="", actualwidth934="", cross_scroll934, ns_scroll, statusdiv, loadedyes=0, lefttime, righttime;

function ietruebody(){
		return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body;
}

function creatediv(){
		statusdiv=document.createElement("div")
		statusdiv.setAttribute("id","statusdiv")
}

function positiondiv934(){
		var mainobjoffset=getposOffset934(crossmain934, "left"),
		menuheight=parseInt(crossmain934.offsetHeight),
		mainobjoffsetH=getposOffset934(crossmain934, "top");
		statusdiv.style.left=mainobjoffset+(menuwidth/2)-(statusdiv.offsetWidth/2)+"px";
		statusdiv.style.top=menuheight+mainobjoffsetH+"px";
}

function showhidediv934(what){
		if (endofgallerymsg!="") {
				positiondiv934();
				statusdiv.style.visibility=what;
		}
}

function getposOffset934(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 moveleft934(){
		if (loadedyes){
				movestate="left";
				if (iedom934&&parseInt(cross_scroll934.style.left)>(menuwidth-actualwidth934)){
						cross_scroll934.style.left=parseInt(cross_scroll934.style.left)-scrollspeed+"px";
						showhidediv934("hidden");
				}
				else
				showhidediv934("visible");
		}
		lefttime=setTimeout("moveleft934()",10);
}

function moveright934(){
		if (loadedyes){
				movestate="right";
				if (iedom934&&parseInt(cross_scroll934.style.left)<0){
						cross_scroll934.style.left=parseInt(cross_scroll934.style.left)+scrollspeed+"px";
						showhidediv934("hidden");
				}
				else
				showhidediv934("visible");
		}
		righttime=setTimeout("moveright934()",10);
}

function motionengine934(e){        
		var mainobjoffset=getposOffset934(crossmain934, "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-restarea)/2;
		var rightbound=(menuwidth+restarea)/2;                                              
		if (curposy>rightbound){
				scrollspeed=(curposy-rightbound)/((menuwidth-restarea)/2) * maxspeed;
				clearTimeout(righttime);
				if (movestate!="left") moveleft934();
		}           
		else if (curposy<(leftbound)){
				scrollspeed=(leftbound-curposy)/((menuwidth-restarea)/2) * maxspeed;
				clearTimeout(lefttime);
				if (movestate!="right") moveright934();
		}
		else
		scrollspeed=0;
}

function contains_ns6(a, b) {
		if (b!==null)
		while (b.parentNode)
		if ((b = b.parentNode) == a)
		return true;
		return false;
}

function stopmotion934(e){
		if (!window.opera||(window.opera&&e.relatedTarget!==null))
		if ((window.event&&!crossmain934.contains(event.toElement)) || (e && e.currentTarget && e.currentTarget!= e.relatedTarget && !contains_ns6(e.currentTarget, e.relatedTarget))){
		clearTimeout(lefttime);
		clearTimeout(righttime);
		movestate="";
		}
}

function fillup934(){
	if (iedom934){
		crossmain934=document.getElementById? document.getElementById("motioncontainer934") : document.all.motioncontainer934;
		if(typeof crossmain934.style.maxWidth!=="undefined")
		crossmain934.style.maxWidth=maxwidth+"px";
		menuwidth=crossmain934.offsetWidth;     
		cross_scroll934=document.getElementById? document.getElementById("motiongallery934") : document.all.motiongallery934;
		actualwidth934=document.getElementById? document.getElementById("trueContainer934").offsetWidth : document.all["trueContainer934"].offsetWidth;
		if (startpos)
		cross_scroll934.style.left=(menuwidth-actualwidth934)/startpos+"px";

		// mouseover for arrows
		moveLeft934 = 0;
		moveRight934 = 0;
		$("arrow-right934").onmouseover=function(e){                
				moveLeft934 = 1;            
				motionengine934(e);                                                                  
		};
		$("arrow-right934").onmouseout=function(e){             
				moveLeft934 = 0;              
				stopmotion934(e);                               
		};

		$("arrow-left934").onmouseover=function(e){             
				moveRight934 = 1;                           
				motionengine934(e);                                                  
		};
		$("arrow-left934").onmouseout=function(e){              
				moveRight934 = 0;                 
				stopmotion934(e);                           
		};
		// mouseover for arrows

		crossmain934.onmousemove=function(e){
		motionengine934(e);
		}

		crossmain934.onmouseout=function(e){
		stopmotion934(e);
		showhidediv934("hidden");
		}
	}
	loadedyes=1
	if (endofgallerymsg!=""){
	creatediv();
	positiondiv934();
	}
	if (document.body.filters)
	onresize()
}

window.addEvent('domready', function() {
	if($('motioncontainer934')) {
		fillup934();
	}
});

onresize=function(){
	if (typeof motioncontainer!=="undefined"&&motioncontainer.filters){
	motioncontainer.style.width="0";
	motioncontainer.style.width="";
	motioncontainer.style.width=Math.min(motioncontainer.offsetWidth, maxwidth)+"px";
	}
	menuwidth934=crossmain934.offsetWidth;
	cross_scroll934.style.left=startpos? (menuwidth-actualwidth934)/startpos+"px" : 0;
}
