/***********************************************
* 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 restareaA=1 //1) width of the "neutral" area in the center of the gallery in px
var maxspeedA=5 //2) top scroll speed in pixels. Script auto creates a range from 0 to top speed.
var endofgallerymsgA="<span style='font-size: 11px'></span>" //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 actualWidthA=typeof optWidth!="undefined" ? optWidth : "498px" //set 600px to default width
var actualHeightA=typeof optHeight!="undefined" ? optHeight : "501px" //set 500px to  default height
var winattributesA="width="+actualWidthA+",height="+actualHeightA+",resizable=yes"
window.open(path,"", winattributesA)
}

////NO NEED TO EDIT BELOW THIS LINE////////////

var iedomA=document.all||document.getElementById
var scrollspeedA=0
var movestateA=""

var actualwidthA=''
var cross_scrollA, ns_scrollA
var loadedyesA=0

function ietruebody(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function creatediv(){
statusdiv=document.createElement("div")
statusdiv.setAttribute("id","statusdiv")
document.body.appendChild(statusdiv)
statusdiv=document.getElementById("statusdiv")
statusdiv.innerHTML=endofgallerymsgA
}

function positiondiv(){
menuheight=parseInt(crossmain.offsetHeight)
mainobjoffsetH=getposOffset(crossmain, "top")
statusdiv.style.left=mainobjoffset+(menuwidth/2)-(statusdiv.offsetWidth/2)+"px"
statusdiv.style.top=menuheight+mainobjoffsetH+"px"
}

function showhidediv(what){
if (endofgallerymsgA!="")
statusdiv.style.visibility=what
}

function getposOffset(what, offsettype){
var totaloffsetA=(offsettype=="left")? what.offsetLeft: what.offsetTop;
var parentElA=what.offsetParent;
while (parentElA!=null){
totaloffsetA=(offsettype=="left")? totaloffsetA+parentElA.offsetLeft : totaloffsetA+parentElA.offsetTop;
parentElA=parentElA.offsetParent;
}
return totaloffsetA;
}


function moveleft(){
if (loadedyesA){
movestateA="left"
if (iedomA&&parseInt(cross_scrollA.style.left)>(menuwidth-actualwidthA)){
cross_scrollA.style.left=parseInt(cross_scrollA.style.left)-scrollspeedA+"px"
showhidediv("hidden")
}
else
showhidediv("visible")
}
lefttime=setTimeout("moveleft()",10)
}

function moveright(){
if (loadedyesA){
movestateA="right"
if (iedomA&&parseInt(cross_scrollA.style.left)<0){
cross_scrollA.style.left=parseInt(cross_scrollA.style.left)+scrollspeedA+"px"
showhidediv("hidden")
}
else
showhidediv("visible")
}
righttime=setTimeout("moveright()",10)
}

function motionengine(e){
var dsocxA=(window.pageXOffset)? pageXOffset: ietruebody().scrollLeft;
var dsocyA=(window.pageYOffset)? pageYOffset : ietruebody().scrollTop;
var curposy=window.event? event.clientX : e.clientX? e.clientX: ""
curposy-=mainobjoffset-dsocxA
var leftboundA=(menuwidth-restareaA)/2
var rightboundA=(menuwidth+restareaA)/2
if (curposy>rightboundA){
scrollspeedA=(curposy-rightboundA)/((menuwidth-restareaA)/2) * maxspeedA
if (window.righttime) clearTimeout(righttime)
if (movestateA!="left") moveleft()
}
else if (curposy<leftboundA){
scrollspeedA=(leftboundA-curposy)/((menuwidth-restareaA)/2) * maxspeedA
if (window.lefttime) clearTimeout(lefttime)
if (movestateA!="right") moveright()
}
else
scrollspeedA=0
}

function contains_ns6(a, b) {
while (b.parentNode)
if ((b = b.parentNode) == a)
return true;
return false;
}

function stopmotion(e){
if ((window.event&&!crossmain.contains(event.toElement)) || (e && e.currentTarget && e.currentTarget!= e.relatedTarget && !contains_ns6(e.currentTarget, e.relatedTarget))){
if (window.lefttime) clearTimeout(lefttime)
if (window.righttime) clearTimeout(righttime)
movestateA=""
}
}

function fillup(){
if (iedomA){
crossmain=document.getElementById? document.getElementById("motioncontainerA") : document.all.motioncontainer
menuwidth=parseInt(crossmain.style.width)
mainobjoffset=getposOffset(crossmain, "left")
cross_scrollA=document.getElementById? document.getElementById("motiongalleryA") : document.all.motiongallery
actualwidthA=document.all? cross_scrollA.offsetWidth : document.getElementById("trueContainer").offsetWidth

crossmain.onmousemove=function(e){
motionengine(e)
}

crossmain.onmouseout=function(e){
stopmotion(e)
showhidediv("hidden")
}
}
loadedyesA=1
if (endofgallerymsgA!=""){
creatediv()
positiondiv()
}
}
window.onload=fillup
