/***********************************************
* CMotion Image Gallery- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* Visit http://www.dynamicDrive.com for source code
* This copyright notice must stay intact for legal use
* Modified for autowidth and optional starting positions in
* http://www.dynamicdrive.com/forums/showthread.php?t=11839 by jschuer1 8/5/06
***********************************************/

 //1) Set width of the "neutral" area in the center of the gallery.
var restarea=6;
 //2) Set top scroll speed in pixels. Script auto creates a range from 0 to top speed.
var maxspeed=2;
 //3) Set to maximum width for gallery - must be less than the actual length of the image train.
var maxwidth=1000;
 //4) Set to 1 for left start, 0 for right, 2 for center.
var startpos=0;
 //5) Set message to show at end of gallery. Enter "" to disable message.
var endofgallerymsg='<span style="font-size: 11px;">End of Gallery</span>';

function 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 iedom=document.all||document.getElementById, scrollspeed=0, movestate='', actualwidth='', cross_scroll, ns_scroll, statusdiv, loadedyes=0, lefttime, righttime;

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=endofgallerymsg
}

function positiondiv(){
var mainobjoffset=getposOffset(crossmain, "left"),
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 (endofgallerymsg!="") {
positiondiv();
statusdiv.style.visibility=what;
}
}

function 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 motionengine(e){
var mainobjoffset=getposOffset(crossmain, "left"),
dsocx=(window.pageXOffset)? pageXOffset: ietruebody().scrollLeft,
dsocy=(window.pageYOffset)? pageYOffset : ietruebody().scrollTop,
curposy=window.event? event.clientX : e.clientX? e.clientX: "";
curposy-=mainobjoffset-dsocx;
var leftbound=(menuwidth-restarea)/2;
var rightbound=(menuwidth+restarea)/2;
if (curposy>rightbound){
scrollspeed=(curposy-rightbound)/((menuwidth-restarea)/2) * maxspeed;
clearTimeout(righttime);
if (movestate!="left") moveleft();
}
else if (curposy<leftbound){
scrollspeed=(leftbound-curposy)/((menuwidth-restarea)/2) * maxspeed;
clearTimeout(lefttime);
if (movestate!="right") moveright();
}
else
scrollspeed=0;
}

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

function stopmotion(e){
if (!window.opera||(window.opera&&e.relatedTarget!==null))
if ((window.event&&!crossmain.contains(event.toElement)) || (e && e.currentTarget && e.currentTarget!= e.relatedTarget && !contains_ns6(e.currentTarget, e.relatedTarget))){
clearTimeout(lefttime);
clearTimeout(righttime);
movestate="";
}
}

function fillup(){
if (iedom){
crossmain=document.getElementById? document.getElementById("motioncontainer") : document.all.motioncontainer;
if(typeof crossmain.style.maxWidth!=='undefined')
crossmain.style.maxWidth=maxwidth+'px';
menuwidth=crossmain.offsetWidth;
cross_scroll=document.getElementById? document.getElementById("motiongallery") : document.all.motiongallery;
actualwidth=document.getElementById? document.getElementById("trueContainer").offsetWidth : document.all['trueContainer'].offsetWidth;
if (startpos)
cross_scroll.style.left=(menuwidth-actualwidth)/startpos+'px';
/*crossmain.onmouseout=function(e){
stopmotion(e);
showhidediv("hidden");
}*/
}
loadedyes=1
if (endofgallerymsg!=""){
creatediv();
positiondiv();
}
if (document.body.filters)
onresize(); 
}


onresize=function(){
if (typeof motioncontainer!=='undefined'&&motioncontainer.filters){
motioncontainer.style.width="0";
motioncontainer.style.width="";
motioncontainer.style.width=Math.min(motioncontainer.offsetWidth, maxwidth)+'px';
}
menuwidth=crossmain.offsetWidth;
cross_scroll.style.left=startpos? (menuwidth-actualwidth)/startpos+'px' : 0;
}




function moveleft(){
if (loadedyes){
movestate="left";
if (iedom&&parseInt(cross_scroll.style.left)>(menuwidth-actualwidth)){
cross_scroll.style.left=parseInt(cross_scroll.style.left)-scrollspeed+"px";
showhidediv("hidden");
}
else
showhidediv("visible");
}
lefttime=setTimeout("moveleft()",10);
}
function moveright(){		
if (loadedyes){
movestate="right";
if (iedom&&parseInt(cross_scroll.style.left)<0){
cross_scroll.style.left=parseInt(cross_scroll.style.left)+scrollspeed+"px";
showhidediv("hidden");
}
else
showhidediv("visible");
}
righttime=setTimeout("moveright()",10);
}





/***********************************************
* CMotion Image Gallery- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* Visit http://www.dynamicDrive.com for source code
* This copyright notice must stay intact for legal use
* Modified for autowidth and optional starting positions in
* http://www.dynamicdrive.com/forums/showthread.php?t=11839 by jschuer1 8/5/06
***********************************************/

 //1) Set width of the "neutral" area in the center of the gallery.
var restarea1=6;
 //2) Set top scroll speed in pixels. Script auto creates a range from 0 to top speed.
var maxspeed1=2;
 //3) Set to maximum width for gallery - must be less than the actual length of the image train.
var maxwidth1=1000;
 //4) Set to 1 for left start, 0 for right, 2 for center.
var startpos1=0;
 //5) Set message to show at end of gallery. Enter "" to disable message.
var endofgallerymsg1='<span style="font-size: 11px;">End of Gallery</span>';

function enlargeimage1(path1, optWidth1, optHeight1){ //function to enlarge image. Change as desired.
var actualWidth1=typeof optWidth1!="undefined" ? optWidth1 : "600px" //set 600px to default width
var actualHeight1=typeof optHeight1!="undefined" ? optHeight1 : "500px" //set 500px to  default height
var winattributes1="width="+actualWidth1+",height="+actualHeight1+",resizable=yes"
window.open(path1,"", winattributes1)
}

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

var iedom1=document.all||document.getElementById, scrollspeed1=0, movestate1='', actualwidth1='', cross_scroll1, ns_scroll1, statusdiv1, loadedyes1=0, lefttime1, righttime1;

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

function creatediv1(){
statusdiv1=document.createElement("div")
statusdiv1.setAttribute("id","statusdiv1")
document.body.appendChild(statusdiv1)
statusdiv1=document.getElementById("statusdiv1")
statusdiv1.innerHTML=endofgallerymsg1
}

function positiondiv1(){
var mainobjoffset1=getposOffset1(crossmain1, "left"),
menuheight1=parseInt(crossmain1.offsetHeight),
mainobjoffsetH1=getposOffset1(crossmain1, "top");
statusdiv1.style.left=mainobjoffset1+(menuwidth1/2)-(statusdiv1.offsetWidth/2)+"px";
statusdiv1.style.top=menuheight1+mainobjoffsetH1+"px";
}

function showhidediv1(what1){
if (endofgallerymsg1!="") {
positiondiv1();
statusdiv1.style.visibility=what1;
}
}

function getposOffset1(what, offsettype1){	
var totaloffset1=(offsettype1=="left")? what.offsetLeft: what.offsetTop;
var parentEl1=what.offsetParent;
while (parentEl1!=null){
totaloffset1=(offsettype1=="left")? totaloffset1+parentEl1.offsetLeft : totaloffset1+parentEl1.offsetTop;
parentEl1=parentEl1.offsetParent;
}
return totaloffset1;
}



function motionengine1(e1){
var mainobjoffset1=getposOffset1(crossmain1, "left"),
dsocx1=(window.pageXOffset)? pageXOffset: ietruebody1().scrollLeft,
dsocy1=(window.pageYOffset)? pageYOffset : ietruebody1().scrollTop,
curposy1=window.event? event.clientX : e1.clientX? e1.clientX: "";
curposy1-=mainobjoffset1-dsocx1;
var leftbound1=(menuwidth1-restarea1)/2;
var rightbound1=(menuwidth1+restarea1)/2;
if (curposy1>rightbound1){
scrollspeed1=(curposy1-rightbound1)/((menuwidth1-restarea1)/2) * maxspeed1;
clearTimeout(righttime1);
if (movestate1!="left") moveleft1();
}
else if (curposy1<leftbound1){
scrollspeed1=(leftbound1-curposy1)/((menuwidth1-restarea1)/2) * maxspeed1;
clearTimeout(lefttime1);
if (movestate1!="right") moveright1();
}
else
scrollspeed1=0;
}

function contains_ns61(a1, b1) {
if (b1!==null)
while (b1.parentNode)
if ((b1 = b1.parentNode) == a1)
return true;
return false;
}

function stopmotion1(e1){
if (!window.opera||(window.opera&&e1.relatedTarget!==null))
if ((window.event&&!crossmain1.contains(event.toElement)) || (e1 && e1.currentTarget && e1.currentTarget!= e1.relatedTarget && !contains_ns61(e1.currentTarget, e1.relatedTarget))){
clearTimeout(lefttime1);
clearTimeout(righttime1);
movestate1="";
}
}

function fillup1(){
if (iedom1){
crossmain1=document.getElementById? document.getElementById("motioncontainer1") : document.all.motioncontainer1;
if(typeof crossmain1.style.maxWidth!=='undefined')
crossmain1.style.maxWidth=maxwidth1+'px';
menuwidth1=crossmain1.offsetWidth;
cross_scroll1=document.getElementById? document.getElementById("motiongallery1") : document.all.motiongallery1;
actualwidth1=document.getElementById? document.getElementById("trueContainer1").offsetWidth : document.all['trueContainer1'].offsetWidth;
if (startpos1)
cross_scroll1.style.left=(menuwidth1-actualwidth1)/startpos1+'px';
/*crossmain1.onmouseout=function(e){
stopmotion(e);
showhidediv1("hidden");
}*/
}
loadedyes1=1
if (endofgallerymsg1!=""){
creatediv1();
positiondiv1();
}
if (document.body.filters)
onresize1()
}
/*window.onload=fillup1;*/


onresize1=function(){
if (typeof motioncontainer1!=='undefined'&&motioncontainer1.filters){
motioncontainer1.style.width="0";
motioncontainer1.style.width="";
motioncontainer1.style.width=Math.min(motioncontainer1.offsetWidth, maxwidth1)+'px';
}
menuwidth1=crossmain1.offsetWidth;
cross_scroll1.style.left=startpos1? (menuwidth1-actualwidth1)/startpos1+'px' : 0;
}




function moveleft1(){
if (loadedyes1){
movestate1="left";
if (iedom1&&parseInt(cross_scroll1.style.left)>(menuwidth1-actualwidth1)){
cross_scroll1.style.left=parseInt(cross_scroll1.style.left)-scrollspeed1+"px";
showhidediv1("hidden");
}
else
showhidediv1("visible");
}
lefttime1=setTimeout("moveleft1()",10);
}
function moveright1(){		
if (loadedyes1){
movestate1="right";
if (iedom1&&parseInt(cross_scroll1.style.left)<0){
cross_scroll1.style.left=parseInt(cross_scroll1.style.left)+scrollspeed1+"px";
showhidediv1("hidden");
}
else
showhidediv1("visible");
}
righttime1=setTimeout("moveright1()",10);
}


