/***********************************************
* CMotion Image Gallery II- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* Visit http://www.dynamicDrive.com for source code
* Modified by jscheuer1 for vertical orientation, at http://www.dynamicDrive.com/forums
***********************************************/

var v_restarea=6 //1) width of the "neutral" area in the center of the gallery in px
var v_maxpseed=5 //2) top scroll speed in pixels. Script auto creates a range from 0 to top speed.
var v_endofgallerymsg="" //3) message to show at end of gallery. Enter "" to disable message.

function v_enlargeimage(path, optWidth, optHeight){ //function to enlarge image. Change as desired.
var actualWidth=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="+actualWidth+",height="+actualHeight+",resizable=yes"
window.open(path,"", winattributes)
}

////NO NEED TO EDIT BELOW THIS LINE////////////

var v_iedom=document.all||document.getElementById
var v_scrollspeed=0
var v_movestate=""

var v_actualheight=''
var v_cross_scroll
var v_loadedyes=0

function v_ietruebody(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function v_creatediv(){
v_statusdiv=document.createElement("div")
v_statusdiv.setAttribute("id","v_statusdiv")
document.body.appendChild(v_statusdiv)
v_statusdiv=document.getElementById("v_statusdiv")
v_statusdiv.innerHTML=v_endofgallerymsg
}

function v_positiondiv(){
v_menuwidth=parseInt(v_crossmain.offsetWidth)
v_mainobjoffsetW=v_getposOffset(v_crossmain, "left")
v_statusdiv.style.left=v_mainobjoffsetW+(v_menuwidth/2)-(v_statusdiv.offsetWidth/2)+"px"
v_statusdiv.style.top=menu_height+v_mainobjoffset+10+"px"
}

function v_showhidediv(what){
if (v_endofgallerymsg!="")
v_statusdiv.style.visibility=what
}

function v_getposOffset(what, offsettype){
var totaloffset=(offsettype=="left")? what.offsetLeft: what.offsetTop;
var parentEl=what.offsetParent;
while (parentEl!=null){
totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
parentEl=parentEl.offsetParent;
}
return totaloffset;
}


function v_moveup(){
if (v_loadedyes){
v_movestate="up"
if (v_iedom&&parseInt(v_cross_scroll.style.top)>(menu_height-v_actualheight)){
v_cross_scroll.style.top=parseInt(v_cross_scroll.style.top)-v_scrollspeed+"px"
v_showhidediv("hidden")
}
else
v_showhidediv("visible")
}
uptime=setTimeout("v_moveup()",10)
}

function v_movedown(){
if (v_loadedyes){
v_movestate="down"
if (v_iedom&&parseInt(v_cross_scroll.style.top)<0){
v_cross_scroll.style.top=parseInt(v_cross_scroll.style.top)+v_scrollspeed+"px"
v_showhidediv("hidden")
}
else
v_showhidediv("visible")
}
downtime=setTimeout("v_movedown()",10)
}

function v_motionengine(e){
var dsocx=(window.pageXOffset)? pageXOffset: v_ietruebody().scrollLeft;
var dsocy=(window.pageYOffset)? pageYOffset : v_ietruebody().scrollTop;
var curposy=window.event? event.clientY : e.clientY? e.clientY: ""
curposy-=v_mainobjoffset-dsocy
var leftbound=(menu_height-v_restarea)/2
var rightbound=(menu_height+v_restarea)/2
if (curposy>rightbound){
v_scrollspeed=(curposy-rightbound)/((menu_height-v_restarea)/2) * v_maxpseed
if (window.downtime) clearTimeout(downtime)
if (v_movestate!="up") v_moveup()
}
else if (curposy<leftbound){
v_scrollspeed=(leftbound-curposy)/((menu_height-v_restarea)/2) * v_maxpseed
if (window.uptime) clearTimeout(uptime)
if (v_movestate!="down") v_movedown()
}
else
v_scrollspeed=0
}

function v_contains_ns6(a, b) {
while (b.parentNode)
if ((b = b.parentNode) == a)
return true;
return false;
}

function v_stopmotion(e){
if ((window.event&&!v_crossmain.contains(event.toElement)) || (e && e.currentTarget && e.currentTarget!= e.relatedTarget && !v_contains_ns6(e.currentTarget, e.relatedTarget))){
if (window.downtime) clearTimeout(downtime)
if (window.uptime) clearTimeout(uptime)
v_movestate=""
}
}

function v_fillup(){

if (v_iedom){
v_crossmain=document.getElementById? document.getElementById("motioncontainer") : document.all.motioncontainer
menu_height=parseInt(v_crossmain.style.height)
v_mainobjoffset=v_getposOffset(v_crossmain, "top")
v_cross_scroll=document.getElementById? document.getElementById("motiongallery") : document.all.motiongallery
v_actualheight=v_cross_scroll.offsetHeight

v_crossmain.onmousemove=function(e){
v_motionengine(e)
}

v_crossmain.onmouseout=function(e){
v_stopmotion(e)
v_showhidediv("hidden")
}
}
if (window.opera){
v_cross_scroll.style.top=menu_height-v_actualheight+'px'
setTimeout('v_cross_scroll.style.top=0', 10)
}
v_loadedyes=1
if (v_endofgallerymsg!=""){
v_creatediv()
v_positiondiv()
}
}

window.onload=v_fillup;
