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

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

var iedom2=document.all||document.getElementById
var scrollspeed2=0
var movestate2=""

var actualwidth2=''
var cross_scroll2, ns_scroll2
var loadedyes2=0

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

function creatediv2(){
statusdiv2=document.createElement("div")
statusdiv2.setAttribute("id","statusdiv2")
document.body.appendChild(statusdiv2)
statusdiv2=document.getElementById("statusdiv2")
statusdiv2.innerHTML=endofgallerymsg2
}

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

function showhidediv2(what){
if (endofgallerymsg2!="")
statusdiv2.style.visibility=what
}

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


function moveleft2(){
if (loadedyes2){
movestate2="left"
if (iedom2&&parseInt(cross_scroll2.style.left)>(menuwidth-actualwidth2)){
cross_scroll2.style.left=parseInt(cross_scroll2.style.left)-scrollspeed2+"px"
showhidediv2("hidden")
}
else
showhidediv2("visible")
}
lefttime=setTimeout("moveleft2()",10)
}

function moveright2(){
if (loadedyes2){
movestate2="right"
if (iedom2&&parseInt(cross_scroll2.style.left)<0){
cross_scroll2.style.left=parseInt(cross_scroll2.style.left)+scrollspeed2+"px"
showhidediv2("hidden")
}
else
showhidediv2("visible")
}
righttime=setTimeout("moveright2()",10)
}

function motionengine2(e){
var dsocx=(window.pageXOffset)? pageXOffset: ietruebody2().scrollLeft;
var dsocy=(window.pageYOffset)? pageYOffset : ietruebody2().scrollTop;
var curposy=window.event? event.clientX : e.clientX? e.clientX: ""
curposy-=mainobjoffset-dsocx
var leftbound=(menuwidth-restarea2)/2
var rightbound=(menuwidth+restarea2)/2
if (curposy>rightbound){
scrollspeed2=(curposy-rightbound)/((menuwidth-restarea2)/2) * maxspeed2
if (window.righttime) clearTimeout(righttime)
if (movestate2!="left") moveleft2()
}
else if (curposy<leftbound){
scrollspeed2=(leftbound-curposy)/((menuwidth-restarea2)/2) * maxspeed2
if (window.lefttime) clearTimeout(lefttime)
if (movestate2!="right") moveright2()
}
else
scrollspeed2=0
}

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

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

function fillup2(){
if (iedom2){
crossmain=document.getElementById? document.getElementById("motioncontainer2") : document.all.motioncontainer2
menuwidth=parseInt(crossmain.style.width)
mainobjoffset=getposOffset2(crossmain, "left")
cross_scroll2=document.getElementById? document.getElementById("motiongallery2") : document.all.motiongallery2
actualwidth2=document.all? cross_scroll2.offsetWidth : document.getElementById("trueContainer2").offsetWidth

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

crossmain.onmouseout=function(e){
stopmotion2(e)
showhidediv2("hidden")
}
}
loadedyes2=1
if (endofgallerymsg2!=""){
creatediv2()
positiondiv2()
}
}
window.onload=fillup2
