/***********************************************
* 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 restarea3=6 //1) width of the "neutral" area in the center of the gallery in px
var maxspeed3=7 //2) top scroll speed in pixels. Script auto creates a range from 0 to top speed.
var endofgallerymsg3="" //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 actualwidth3=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="+actualwidth3+",height="+actualHeight+",resizable=yes"
window.open(path,"", winattributes)
}

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

var iedom3=document.all||document.getElementById
var scrollspeed3=0
var movestate3=""

var actualwidth3=''
var cross_scroll3, ns_scroll3
var loadedyes3=0

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

function creatediv3(){
statusdiv3=document.createElement("div")
statusdiv3.setAttribute("id","statusdiv3")
document.body.appendChild(statusdiv3)
statusdiv3=document.getElementById("statusdiv3")
statusdiv3.innerHTML=endofgallerymsg3
}

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

function showhidediv3(what){
if (endofgallerymsg3!="")
statusdiv3.style.visibility=what
}

function getposOffset3(what, offsettype){
var totaloffset=(offsettype=="left")? what.offsetLeft: what.offsetTop;
var parentE3=what.offsetParent;
while (parentE3!=null){
totaloffset=(offsettype=="left")? totaloffset+parentE3.offsetLeft : totaloffset+parentE3.offsetTop;
parentE3=parentE3.offsetParent;
}
return totaloffset;
}


function moveleft3(){
if (loadedyes3){
movestate3="left"
if (iedom3&&parseInt(cross_scroll3.style.left)>(menuwidth-actualwidth3)){
cross_scroll3.style.left=parseInt(cross_scroll3.style.left)-scrollspeed3+"px"
showhidediv3("hidden")
}
else
showhidediv3("visible")
}
lefttime=setTimeout("moveleft3()",10)
}

function moveright3(){
if (loadedyes3){
movestate3="right"
if (iedom3&&parseInt(cross_scroll3.style.left)<0){
cross_scroll3.style.left=parseInt(cross_scroll3.style.left)+scrollspeed3+"px"
showhidediv3("hidden")
}
else
showhidediv3("visible")
}
righttime=setTimeout("moveright3()",10)
}

function motionengine3(e){
var dsocx=(window.pageXOffset)? pageXOffset: ietruebody3().scrollLeft;
var dsocy=(window.pageYOffset)? pageYOffset : ietruebody3().scrollTop;
var curposy=window.event? event.clientX : e.clientX? e.clientX: ""
curposy-=mainobjoffset-dsocx
var leftbound=(menuwidth-restarea3)/2
var rightbound=(menuwidth+restarea3)/2
if (curposy>rightbound){
scrollspeed3=(curposy-rightbound)/((menuwidth-restarea3)/2) * maxspeed3
if (window.righttime) clearTimeout(righttime)
if (movestate3!="left") moveleft3()
}
else if (curposy<leftbound){
scrollspeed3=(leftbound-curposy)/((menuwidth-restarea3)/2) * maxspeed3
if (window.lefttime) clearTimeout(lefttime)
if (movestate3!="right") moveright3()
}
else
scrollspeed3=0
}

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

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

function fillup3(){
if (iedom3){
crossmain=document.getElementById? document.getElementById("motioncontainer3") : document.all.motioncontainer3
menuwidth=parseInt(crossmain.style.width)
mainobjoffset=getposOffset3(crossmain, "left")
cross_scroll3=document.getElementById? document.getElementById("motiongallery3") : document.all.motiongallery3
actualwidth3=document.all? cross_scroll3.offsetWidth : document.getElementById("trueContainer3").offsetWidth

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

crossmain.onmouseout=function(e){
stopmotion3(e)
showhidediv3("hidden")
}
}
loadedyes3=1
if (endofgallerymsg3!=""){
creatediv3()
positiondiv3()
}
}
window.onload=fillup3
