/**********************************************
* 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 copydown notice must stay intact for legal use
***********************************************/

var restarea=6 //1) height of the "neutral" area in the center of the gallery in px
var maxspeed=7 //2) top scroll speed in pixels. Script auto creates a range from 0 to top speed.


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

var iedom=document.all||document.getElementById
var scrollspeed=0
var movestate=""

var actualheight=''
var cross_scroll, ns_scroll
var loadedyes=0

function showimage(url){
document.images.mainpic.src=url
return true
}

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

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


function moveup(){
if (loadedyes){
movestate="up"
if (iedom&&parseInt(cross_scroll.style.top)>(menuheight-actualheight)){
cross_scroll.style.top=parseInt(cross_scroll.style.top)-300+"px"
document.images.up_arrow.src="images/gallery/thumbs/up_arrow.gif"
document.images.down_arrow.src="images/gallery/thumbs/btm_arrow.gif"
}
if (iedom&&parseInt(cross_scroll.style.top)<=(menuheight-actualheight)){
document.images.up_arrow.src="images/gallery/thumbs/up_arrow.gif"
document.images.down_arrow.src="images/gallery/thumbs/down-arrow-dim.gif"
}
}
}

function movedown(){
if (loadedyes){
movestate="down"
if (iedom&&parseInt(cross_scroll.style.top)<0){
cross_scroll.style.top=parseInt(cross_scroll.style.top)+300+"px"
document.images.up_arrow.src="images/gallery/thumbs/up_arrow.gif"
document.images.down_arrow.src="images/gallery/thumbs/btm_arrow.gif"
}
if (iedom&&parseInt(cross_scroll.style.top)>=0){
document.images.up_arrow.src="images/gallery/thumbs/up-arrow-dim.gif"
document.images.down_arrow.src="images/gallery/thumbs/btm_arrow.gif"
}
}
}

function motionengine(e){
var dsocx=(window.pageXOffset)? pageXOffset: ietruebody().scrollLeft;
var dsocy=(window.pageYOffset)? pageYOffset : ietruebody().scrollTop;
var curposy=window.event? event.clientX : e.clientX? e.clientX: ""
curposy-=mainobjoffset-dsocx
var upbound=(menuheight-restarea)/2
var downbound=(menuheight+restarea)/2
if (curposy>downbound){
scrollspeed=(curposy-downbound)/((menuheight-restarea)/2) * maxspeed
if (window.downtime) clearTimeout(downtime)
if (movestate!="up") moveup()
}
else if (curposy<upbound){
scrollspeed=(upbound-curposy)/((menuheight-restarea)/2) * maxspeed
if (window.uptime) clearTimeout(uptime)
if (movestate!="down") movedown()
}
else
scrollspeed=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.uptime) clearTimeout(uptime)
if (window.downtime) clearTimeout(downtime)
movestate=""
}
}

function fillup(){
if (iedom){
crossmain=document.getElementById? document.getElementById("motioncontainer") : document.all.motioncontainer
menuheight=parseInt(crossmain.style.height)
mainobjoffset=getposOffset(crossmain, "up")
cross_scroll=document.getElementById? document.getElementById("motiongallery") : document.all.motiongallery
actualheight=document.all? cross_scroll.offsetHeight : document.getElementById("trueContainer").offsetHeight

crossmain.onmouseout=function(e){
stopmotion(e)
}
}
loadedyes=1
}
window.onload=fillup