/***********************************************
* 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 restarea4=6 //1) width of the "neutral" area in the center of the gallery in px
var maxspeed4=7 //2) top scroll speed in pixels. Script auto creates a range from 0 to top speed.
var endofgallerymsg4="" //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 actualwidth4=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="+actualwidth4+",height="+actualHeight+",resizable=yes"
window.open(path,"", winattributes)
}

////NO NEED TO EDIT BELOW THIS LINE////////////

var iedom4=document.all||document.getElementById
var scrollspeed4=0
var movestate4=""

var actualwidth4=''
var cross_scroll4, ns_scroll4
var loadedyes4=0

function ietruebody4(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function creatediv4(){
statusdiv4=document.createElement("div")
statusdiv4.setAttribute("id","statusdiv4")
document.body.appendChild(statusdiv4)
statusdiv4=document.getElementById("statusdiv4")
statusdiv4.innerHTML=endofgallerymsg4
}

function positiondiv4(){
menuheight=parseInt(crossmain.offsetHeight)
mainobjoffsetH=getposOffset4(crossmain, "top")
statusdiv4.style.left=mainobjoffset+(menuwidth/2)-(statusdiv4.offsetWidth/2)+"px"
statusdiv4.style.top=menuheight+mainobjoffsetH+"px"
}

function showhidediv4(what){
if (endofgallerymsg4!="")
statusdiv4.style.visibility=what
}

function getposOffset4(what, offsettype){
var totaloffset=(offsettype=="left")? what.offsetLeft: what.offsetTop;
var parentE4=what.offsetParent;
while (parentE4!=null){
totaloffset=(offsettype=="left")? totaloffset+parentE4.offsetLeft : totaloffset+parentE4.offsetTop;
parentE4=parentE4.offsetParent;
}
return totaloffset;
}


function moveleft4(){
if (loadedyes4){
movestate4="left"
if (iedom4&&parseInt(cross_scroll4.style.left)>(menuwidth-actualwidth4)){
cross_scroll4.style.left=parseInt(cross_scroll4.style.left)-scrollspeed4+"px"
showhidediv4("hidden")
}
else
showhidediv4("visible")
}
lefttime=setTimeout("moveleft4()",10)
}

function moveright4(){
if (loadedyes4){
movestate4="right"
if (iedom4&&parseInt(cross_scroll4.style.left)<0){
cross_scroll4.style.left=parseInt(cross_scroll4.style.left)+scrollspeed4+"px"
showhidediv4("hidden")
}
else
showhidediv4("visible")
}
righttime=setTimeout("moveright4()",10)
}

function motionengine4(e){
var dsocx=(window.pageXOffset)? pageXOffset: ietruebody4().scrollLeft;
var dsocy=(window.pageYOffset)? pageYOffset : ietruebody4().scrollTop;
var curposy=window.event? event.clientX : e.clientX? e.clientX: ""
curposy-=mainobjoffset-dsocx
var leftbound=(menuwidth-restarea4)/2
var rightbound=(menuwidth+restarea4)/2
if (curposy>rightbound){
scrollspeed4=(curposy-rightbound)/((menuwidth-restarea4)/2) * maxspeed4
if (window.righttime) clearTimeout(righttime)
if (movestate4!="left") moveleft4()
}
else if (curposy<leftbound){
scrollspeed4=(leftbound-curposy)/((menuwidth-restarea4)/2) * maxspeed4
if (window.lefttime) clearTimeout(lefttime)
if (movestate4!="right") moveright4()
}
else
scrollspeed4=0
}

function contains_ns64(a, b) {
while (b.parentNode)
if ((b = b.parentNode) == a)
return true;
return false;
}

function stopmotion4(e){
if ((window.event&&!crossmain.contains(event.toElement)) || (e && e.currentTarget && e.currentTarget!= e.relatedTarget && !contains_ns64(e.currentTarget, e.relatedTarget))){
if (window.lefttime) clearTimeout(lefttime)
if (window.righttime) clearTimeout(righttime)
movestate4=""
}
}

function fillup4(){
if (iedom4){
crossmain=document.getElementById? document.getElementById("motioncontainer4") : document.all.motioncontainer4
menuwidth=parseInt(crossmain.style.width)
mainobjoffset=getposOffset4(crossmain, "left")
cross_scroll4=document.getElementById? document.getElementById("motiongallery4") : document.all.motiongallery4
actualwidth4=document.all? cross_scroll4.offsetWidth : document.getElementById("trueContainer4").offsetWidth

crossmain.onmousemove=function(e){
motionengine4(e)
}

crossmain.onmouseout=function(e){
stopmotion4(e)
showhidediv4("hidden")
}
}
loadedyes4=1
if (endofgallerymsg4!=""){
creatediv4()
positiondiv4()
}
}
window.onload=fillup4
