/***********************************************
* CMotion Image Gallery- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* Visit http://www.dynamicDrive.com for source code
* Last updated Mar 15th, 04'. Added "End of Gallery" message.
* This copyright notice must stay intact for legal use
***********************************************/

var restarea1=6 //1) width of the "neutral" area in the center of the gallery in px
var maxspeed1=7 //2) top scroll speed in pixels. Script auto creates a range from 0 to top speed.
var endofgallerymsg1="" //3) message to show at end of gallery. Enter "" to disable message.

function enlargeimage(path, optWidth, optHeight){ //function to enlarge image. Change as desired.
var actualwidth1=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="+actualwidth1+",height="+actualHeight+",resizable=yes"
window.open(path,"", winattributes)
}

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

var iedom1=document.all||document.getElementById
var scrollspeed1=0
var movestate1=""

var actualwidth1=''
var cross_scroll1, ns_scroll1
var loadedyes1=0

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

function creatediv1(){
statusdiv1=document.createElement("div")
statusdiv1.setAttribute("id","statusdiv1")
document.body.appendChild(statusdiv1)
statusdiv1=document.getElementById("statusdiv1")
statusdiv1.innerHTML=endofgallerymsg1
}

function positiondiv1(){
menuheight=parseInt(crossmain.offsetHeight)
mainobjoffsetH=getposOffset1(crossmain, "top")
statusdiv1.style.left=mainobjoffset+(menuwidth/2)-(statusdiv1.offsetWidth/2)+"px"
statusdiv1.style.top=menuheight+mainobjoffsetH+"px"
}

function showhidediv1(what){
if (endofgallerymsg1!="")
statusdiv1.style.visibility=what
}

function getposOffset1(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 moveleft1(){
if (loadedyes1){
movestate1="left"
if (iedom1&&parseInt(cross_scroll1.style.left)>(menuwidth-actualwidth1)){
cross_scroll1.style.left=parseInt(cross_scroll1.style.left)-scrollspeed1+"px"
showhidediv1("hidden")
}
else
showhidediv1("visible")
}
lefttime=setTimeout("moveleft1()",10)
}

function moveright1(){
if (loadedyes1){
movestate1="right"
if (iedom1&&parseInt(cross_scroll1.style.left)<0){
cross_scroll1.style.left=parseInt(cross_scroll1.style.left)+scrollspeed1+"px"
showhidediv1("hidden")
}
else
showhidediv1("visible")
}
righttime=setTimeout("moveright1()",10)
}

function motionengine1(e){
var dsocx=(window.pageXOffset)? pageXOffset: ietruebody1().scrollLeft;
var dsocy=(window.pageYOffset)? pageYOffset : ietruebody1().scrollTop;
var curposy=window.event? event.clientX : e.clientX? e.clientX: ""
curposy-=mainobjoffset-dsocx
var leftbound=(menuwidth-restarea1)/2
var rightbound=(menuwidth+restarea1)/2
if (curposy>rightbound){
scrollspeed1=(curposy-rightbound)/((menuwidth-restarea1)/2) * maxspeed1
if (window.righttime) clearTimeout(righttime)
if (movestate1!="left") moveleft1()
}
else if (curposy<leftbound){
scrollspeed1=(leftbound-curposy)/((menuwidth-restarea1)/2) * maxspeed1
if (window.lefttime) clearTimeout(lefttime)
if (movestate1!="right") moveright1()
}
else
scrollspeed1=0
}

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

function stopmotion1(e){
if ((window.event&&!crossmain.contains(event.toElement)) || (e && e.currentTarget && e.currentTarget!= e.relatedTarget && !contains_ns61(e.currentTarget, e.relatedTarget))){
if (window.lefttime) clearTimeout(lefttime)
if (window.righttime) clearTimeout(righttime)
movestate1=""
}
}

function fillup1(){
if (iedom1){
crossmain=document.getElementById? document.getElementById("motioncontainer1") : document.all.motioncontainer1
menuwidth=parseInt(crossmain.style.width)
mainobjoffset=getposOffset1(crossmain, "left")
cross_scroll1=document.getElementById? document.getElementById("motiongallery1") : document.all.motiongallery1
actualwidth1=document.all? cross_scroll1.offsetWidth : document.getElementById("trueContainer1").offsetWidth

crossmain.onmousemove=function(e){
motionengine1(e)
}

crossmain.onmouseout=function(e){
stopmotion1(e)
showhidediv1("hidden")
}
}
loadedyes1=1
if (endofgallerymsg1!=""){
creatediv1()
positiondiv1()
}
}
window.onload=fillup1
