
/***********************************************
* OO_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
* Object Oriented update 9/19/06
***********************************************/

// With:

/***********************************************
* Thumbnail Viewer III modified from
* Ultimate Fade-In Slideshow (v1.5) & Thumbnail Viewer II:
* both © Dynamic Drive (http://www.dynamicdrive.com)
* modified by jscheuer1 in http://www.dynamicdrive.com/forums
* This notice MUST stay intact for legal use
* Visit http://www.dynamicdrive.com/ for this script and 100s more.
***********************************************/

// Combination Modifications by jscheuer1 6/30/07

 // Set message to show at end of gallery(s). Enter "" to disable message.
var endofgallerymsg="";


var dynimages=new Array()
dynimages.usespace=0;
dynimages.capid='cap1';
//SET IMAGE PATHS. Extend or contract array as needed
//"Thumnail for Gallery", "Large Image", "optional_link", "optional_target"
//link and target are for large image
dynimages[0]=["BushThumb (66 of 104).jpg", "Bushmasters (66 of 104).jpg", "", "", "Bushmasters Guyana", "A benab at Surama Village Eco Lodge. Surama has a population of about 250 Amerindians of the Macushi tribe. <br> The food was simple but good & the benabs were clean with ensuite shower and toilet."]
dynimages[1]=["BushThumb (4 of 104).jpg", "Bushmasters (4 of 104).jpg", "", "", "Bushmasters Guyana", "Dan lounging in a hammock on the upper floor of the main benab building. Loved the hammocks."] 
dynimages[2]=["BushThumb (7 of 104).jpg", "Bushmasters (7 of 104).jpg", "", "", "Bushmasters Guyana", "Getting water means navigating a quagmire of mud at Bushmasters Training Camp."] 
dynimages[3]=["BushThumb (23 of 104).jpg", "Bushmasters (23 of 104).jpg", "", "", "Bushmasters Guyana", "Obi Wan holding forth with one of his many tall tales and campfire stories."] 
dynimages[4]=["BushThumb (27 of 104).jpg", "Bushmasters (27 of 104).jpg", "", "", "Bushmasters Guyana", "One of our spectacular rainforest bathrooms. <br> You could film one of those Rainforest Flowers shampoo ads here."] 
dynimages[5]=["BushThumb (33 of 104).jpg", "Bushmasters (33 of 104).jpg", "", "", "Bushmasters Guyana", "A natural waterfall shower."] 
dynimages[6]=["BushThumb (34 of 104).jpg", "Bushmasters (34 of 104).jpg", "", "", "Bushmasters Guyana", "The water is refreshingly cold. <br> Dan pretending its not, cos he's hard, innit?"] 
dynimages[7]=["BushThumb (35 of 104).jpg", "Bushmasters (35 of 104).jpg", "", "", "Bushmasters Guyana", "Ally enjoying a dip."] 
dynimages[8]=["BushThumb (37 of 104).jpg", "Bushmasters (37 of 104).jpg", "", "", "Bushmasters Guyana", "Harold finding where we are on the map."] 
dynimages[9]=["BushThumb (44 of 104).jpg", "Bushmasters (44 of 104).jpg", "", "", "Bushmasters Guyana", "Time for a swim."] 
dynimages[10]=["BushThumb (45 of 104).jpg", "Bushmasters (45 of 104).jpg", "", "", "Bushmasters Guyana", "Relaxing in the sun."] 
dynimages[11]=["BushThumb (46 of 104).jpg", "Bushmasters (46 of 104).jpg", "", "", "Bushmasters Guyana", "Amanda torturing Obi Wan's wonky finger (accompanied by much face-pulling, wincing and grunting)."] 
dynimages[12]=["BushThumb (47 of 104).jpg", "Bushmasters (47 of 104).jpg", "", "", "Bushmasters Guyana", "Amanda doing her new-age pressure point thing on Fran."] 
dynimages[13]=["BushThumb (52 of 104).jpg", "Bushmasters (52 of 104).jpg", "", "", "Bushmasters Guyana", "Ally having a kip."] 
dynimages[14]=["BushThumb (51 of 104).jpg", "Bushmasters (51 of 104).jpg", "", "", "Bushmasters Guyana", "R & R on the Rocks."] 


var fadebgcolor="white"

////NO need to edit beyond here/////////////


function displayarea(theimages, fadewidth, fadeheight, borderwidth){
if(!displayarea.fadearray){
displayarea.fadearray=new Array() //array to cache displayarea instances
displayarea.fadeclear=new Array() //array to cache corresponding clearinterval pointers
}
this.flag=1
this.capid=theimages.capid;
this.dom=(document.getElementById) //modern dom browsers
this.iebrowser=document.all
this.pausecheck=0
this.degree=10 //initial opacity degree (10%)
this.curimageindex=0
this.nextimageindex=1
displayarea.fadearray[displayarea.fadearray.length]=this
this.slideshowid=displayarea.fadearray.length-1
this.canvasbase="canvas"+this.slideshowid
this.curcanvas=this.canvasbase+"_0"
this.theimages=theimages
this.imageborder=parseInt(borderwidth)
this.postimages=new Array() //preload images
for (p=0;p<theimages.length;p++){
this.postimages[p]=new Image()
this.postimages[p].src=theimages[p][1]
}

var fadewidth=fadewidth+this.imageborder*2
var fadeheight=fadeheight+this.imageborder*2

if (this.iebrowser&&this.dom||this.dom) {//if IE5+ or modern browsers (ie: Firefox)
var opacity_string=document.body.filters? 'filter:progid:DXImageTransform.Microsoft.alpha(opacity=100);' : typeof document.body.style.opacity=='string'? 'opacity:1;' : typeof document.body.style.MozOpacity=='string'? '-moz-opacity:1;' : typeof document.body.style.KhtmlOpacity=='string'? '-khtml-opacity:1;' : '';
document.write('<div id="master'+this.slideshowid+'" style="position:relative;width:'+fadewidth+'px;height:'+fadeheight+'px;overflow:hidden;"><div id="'+this.canvasbase+'_0" style="position:absolute;width:'+fadewidth+'px;height:'+fadeheight+'px;top:0;left:0;'+opacity_string+'background-color:'+fadebgcolor+'"></div><div id="'+this.canvasbase+'_1" style="position:absolute;width:'+fadewidth+'px;height:'+fadeheight+'px;top:0;left:0;'+opacity_string+'background-color:'+fadebgcolor+'"></div></div>');
if(this.capid){
document.write('<div id="'+this.capid+'">'+(theimages[0][5]? theimages[0][5] : '&nbsp;')+'</div>');
this.caparea=document.getElementById(this.capid);
}
}
else
document.write('<div><img name="defaultslide'+this.slideshowid+'" src="'+this.postimages[0].src+'"></div>')

if (this.iebrowser&&this.dom||this.dom) //if IE5+ or modern browsers such as Firefox
this.startit()
else{
this.curimageindex++
setInterval("displayarea.fadearray["+this.slideshowid+"].rotateimage()", 100)
}
}

function fadepic(obj){
if (obj.degree<100){
obj.degree+=5
if (obj.tempobj.filters&&obj.tempobj.filters[0]){
if (typeof obj.tempobj.filters[0].opacity=="number") //if IE6+
obj.tempobj.filters[0].opacity=obj.degree
else //else if IE5.5-
obj.tempobj.style.filter="alpha(opacity="+obj.degree+")"
}
else if (obj.tempobj.style.MozOpacity)
obj.tempobj.style.MozOpacity=obj.degree/101
else if (obj.tempobj.style.KhtmlOpacity)
obj.tempobj.style.KhtmlOpacity=obj.degree/100
else if (obj.tempobj.style.opacity&&!obj.tempobj.filters)
obj.tempobj.style.opacity=obj.degree/101
}
else{
clearInterval(displayarea.fadeclear[obj.slideshowid])
obj.pausecheck=obj.flag=1;
}
}

displayarea.prototype.populateslide=function(picobj, picindex){
var slideHTML=""
if (this.theimages[picindex][2]!="") //if associated link exists for image
slideHTML='<a href="'+this.theimages[picindex][2]+'" target="'+this.theimages[picindex][3]+'">'
slideHTML+='<img src="'+this.postimages[picindex].src+'" border="'+this.imageborder+'px">'
if (this.theimages[picindex][2]!="") //if associated link exists for image
slideHTML+='</a>'
picobj.innerHTML=slideHTML
}


displayarea.prototype.rotateimage=function(){
var cacheobj=this
if (this.pausecheck==1)
setTimeout(function(){cacheobj.rotateimage()}, 100)
else if (this.iebrowser&&this.dom||this.dom){
this.resetit()
var crossobj=this.tempobj=this.iebrowser? this.iebrowser[this.curcanvas] : document.getElementById(this.curcanvas)
crossobj.style.zIndex++
displayarea.fadeclear[this.slideshowid]=setInterval("fadepic(displayarea.fadearray["+this.slideshowid+"])",50)
this.curcanvas=(this.curcanvas==this.canvasbase+"_0")? this.canvasbase+"_1" : this.canvasbase+"_0"
}
else{
var ns4imgobj=document.images['defaultslide'+this.slideshowid]
ns4imgobj.src=this.postimages[this.curimageindex].src
}
this.curimageindex=(this.curimageindex<this.postimages.length-1)? this.curimageindex+1 : 0
}

displayarea.prototype.resetit=function(){
this.degree=10
var crossobj=this.iebrowser? this.iebrowser[this.curcanvas] : document.getElementById(this.curcanvas)
if (crossobj.filters&&crossobj.filters[0]){
if (typeof crossobj.filters[0].opacity=="number") //if IE6+
crossobj.filters(0).opacity=this.degree
else //else if IE5.5-
crossobj.style.filter="alpha(opacity="+this.degree+")"
}
else if (crossobj.style.MozOpacity)
crossobj.style.MozOpacity=this.degree/101
else if (crossobj.style.KhtmlOpacity)
crossobj.style.KhtmlOpacity=this.degree/100
else if (crossobj.style.opacity&&!crossobj.filters)
crossobj.style.opacity=this.degree/101
}


displayarea.prototype.startit=function(){
var crossobj=this.iebrowser? this.iebrowser[this.curcanvas] : document.getElementById(this.curcanvas)
this.populateslide(crossobj, this.curimageindex)
var cacheobj=this
this.rotateimage()
}

function switchFade(iNum, slideId){
var slideIdNum
if (typeof slideId=='number')
slideIdNum=slideId
else
for (var i_tem = 0; i_tem < displayarea.fadearray.length; i_tem++)
if (displayarea.fadearray[i_tem].theimages==slideId)
slideIdNum=i_tem
if (displayarea.fadearray[slideIdNum].flag){
clearInterval(displayarea.fadearray[slideIdNum].wait)
displayarea.fadearray[slideIdNum].flag=0
clearInterval(displayarea.fadeclear[slideIdNum])
displayarea.fadearray[slideIdNum].pausecheck=0
displayarea.fadearray[slideIdNum].nextimageindex=iNum
displayarea.fadearray[slideIdNum].nextcanvas=(displayarea.fadearray[slideIdNum].curcanvas==displayarea.fadearray[slideIdNum].canvasbase+"_0")? displayarea.fadearray[slideIdNum].canvasbase+"_0" : displayarea.fadearray[slideIdNum].canvasbase+"_1"
displayarea.fadearray[slideIdNum].tempobj=document.all? document.all[displayarea.fadearray[slideIdNum].nextcanvas] : document.getElementById(displayarea.fadearray[slideIdNum].nextcanvas)
displayarea.fadearray[slideIdNum].populateslide(displayarea.fadearray[slideIdNum].tempobj, displayarea.fadearray[slideIdNum].nextimageindex)
setTimeout("displayarea.fadearray["+slideIdNum+"].rotateimage()", 100)
if(displayarea.fadearray[slideIdNum].caparea)
displayarea.fadearray[slideIdNum].caparea.innerHTML=displayarea.fadearray[slideIdNum].theimages[iNum][5]? displayarea.fadearray[slideIdNum].theimages[iNum][5] : '&nbsp;';
}
else{
clearInterval(displayarea.fadearray[slideIdNum].wait)
displayarea.fadearray[slideIdNum].wait=setInterval("switchFade("+iNum+", "+slideIdNum+");", 100)
}
}

function cmotiongallery(gallery, rest, maxs, maxw, startp, width, height, c){
this.iedom=document.all||document.getElementById;
if(!cmotiongallery.cgals)
cmotiongallery.cgals=[];
if(!this.iedom)
return;
this.galid=cmotiongallery.cgals.length;
cmotiongallery.cgals[cmotiongallery.cgals.length]=this;
this.gallery=[];
this.dgallery=gallery
for (var i = 0; i < gallery.length; i++)
this.gallery[i]='<a href="javascript:view('+[i+1]+')" onclick="switchFade('+i+', cmotiongallery.cgals['+this.galid+'].dgallery);return false;"><img src="'+gallery[i][0]+'" title="'+(gallery[i][4]? gallery[i][4] : '')+'"border="1"></a>';
this.usespace=gallery.usespace? ' ' : '';
this.width=/%/.test(width)? width : parseInt(width)+'px';
this.height=height;
this.c=c? 'margin:0 auto;' : '';
this.loadedyes=0;
this.movestate='';
this.scrollspeed=0;
this.rest=rest;
this.maxs=maxs;
this.maxw=maxw;
this.startpos=startp;

for (var i_tem = 0; i_tem < this.gallery.length; i_tem++)
this.gallery[i_tem]=!/on[cC]lick/.test(this.gallery[i_tem])? this.gallery[i_tem].replace(/href="#"/, 'href="#" onclick="return false;"') : this.gallery[i_tem];

document.write('<div class="motioncontainer" id="motioncontainer'+this.galid+'" style="'+this.c+'width:'+this.width+';height:'+this.height+'px;position:relative;left:0;top:0;overflow:hidden;">\n'+
'<div id="motiongallery'+this.galid+'" style="position:absolute;left:0;top:0;white-space: nowrap;">\n'+
'\n'+
'<nobr id="trueContainer'+this.galid+'">'+this.gallery.join(this.usespace)+'<\/nobr>\n'+
'\n'+
'<\/div>\n'+
'<\/div>')
this.fillup();
}

function ietruebody(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body;
}

cmotiongallery.prototype.creatediv=function(){
this.statusdiv=document.createElement("div")
this.statusdiv.setAttribute("id","statusdiv"+this.galid)
this.statusdiv.className="statusdiv";
document.body.appendChild(this.statusdiv)
this.statusdiv=document.getElementById("statusdiv"+this.galid)
this.statusdiv.innerHTML=endofgallerymsg
}

cmotiongallery.prototype.positiondiv=function(){
this.mainobjoffset=getposOffset(this.crossmain, "left"),
this.menuheight=parseInt(this.crossmain.offsetHeight),
this.mainobjoffsetH=getposOffset(this.crossmain, "top");
this.statusdiv.style.left=this.mainobjoffset+(this.menuwidth/2)-(this.statusdiv.offsetWidth/2)+"px";
this.statusdiv.style.top=this.menuheight+this.mainobjoffsetH+"px";
}

cmotiongallery.prototype.showhidediv=function(what){
if (endofgallerymsg!="") {
this.positiondiv();
this.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;
}


cmotiongallery.prototype.moveleft=function(){
if (this.loadedyes){
this.movestate="left";
if (this.iedom&&parseInt(this.cross_scroll.style.left)>(this.menuwidth-this.actualwidth)){
this.cross_scroll.style.left=parseInt(this.cross_scroll.style.left)-this.scrollspeed+"px";
this.showhidediv("hidden");
}
else
this.showhidediv("visible");
}
this.lefttime=setTimeout("cmotiongallery.cgals["+this.galid+"].moveleft()",10);
}

cmotiongallery.prototype.moveright=function(){
if (this.loadedyes){
this.movestate="right";
if (this.iedom&&parseInt(this.cross_scroll.style.left)<0){
this.cross_scroll.style.left=parseInt(this.cross_scroll.style.left)+this.scrollspeed+"px";
this.showhidediv("hidden");
}
else
this.showhidediv("visible");
}
this.righttime=setTimeout("cmotiongallery.cgals["+this.galid+"].moveright()",10);
}

cmotiongallery.prototype.motionengine=function(e){
this.mainobjoffset=getposOffset(this.crossmain, "left"),
dsocx=(window.pageXOffset)? pageXOffset: ietruebody().scrollLeft,
dsocy=(window.pageYOffset)? pageYOffset : ietruebody().scrollTop,
curposy=window.event? event.clientX : e.clientX? e.clientX: "";
curposy-=this.mainobjoffset-dsocx;
this.leftbound=(this.menuwidth-this.rest)/2;
this.rightbound=(this.menuwidth+this.rest)/2;
if (curposy>this.rightbound){
this.scrollspeed=(curposy-this.rightbound)/((this.menuwidth-this.rest)/2) * this.maxs;
clearTimeout(this.righttime);
if (this.movestate!="left") this.moveleft();
}
else if (curposy<this.leftbound){
this.scrollspeed=(this.leftbound-curposy)/((this.menuwidth-this.rest)/2) * this.maxs;
clearTimeout(this.lefttime);
if (this.movestate!="right") this.moveright();
}
else
this.scrollspeed=0;
}

function contains_ns6(a, b) {
if (b!==null)
while (b.parentNode)
if ((b = b.parentNode) == a)
return true;
return false;
}

cmotiongallery.prototype.stopmotion=function(e){
if (!window.opera||(window.opera&&e.relatedTarget!==null))
if ((window.event&&!this.crossmain.contains(event.toElement)) || (e && e.currentTarget && e.currentTarget!= e.relatedTarget && !contains_ns6(e.currentTarget, e.relatedTarget))){
clearTimeout(this.lefttime);
clearTimeout(this.righttime);
this.movestate="";
}
}

cmotiongallery.prototype.fillup=function(){
if (this.iedom){
this.crossmain=document.getElementById? document.getElementById("motioncontainer"+this.galid) : document.all["motioncontainer"+this.galid];
if(typeof this.crossmain.style.maxWidth!=='undefined')
this.crossmain.style.maxWidth=this.maxw+'px';
this.menuwidth=this.crossmain.offsetWidth;
this.cross_scroll=document.getElementById? document.getElementById("motiongallery"+this.galid) : document.all["motiongallery"+this.galid];
this.loading=document.getElementsByTagName? document.getElementById('trueContainer'+this.galid).getElementsByTagName('img') : document.all['trueContainer'+this.galid].all.tags('img');
for (var i_tem = 0; i_tem < this.loading.length; i_tem++)
if(typeof this.loading[i_tem].complete=='boolean'&&this.loading[i_tem].complete==false){
setTimeout("cmotiongallery.cgals["+this.galid+"].fillup()", 500);
return;
}
this.actualwidth=document.getElementById? document.getElementById("trueContainer"+this.galid).offsetWidth : document.all['trueContainer'+this.galid].offsetWidth;
if (this.startpos)
this.cross_scroll.style.left=(this.menuwidth-this.actualwidth)/this.startpos+'px';
this.crossmain.onmousemove=new Function("e", "cmotiongallery.cgals["+this.galid+"].motionengine(e)");

this.crossmain.onmouseout=new Function("e", "cmotiongallery.cgals["+this.galid+"].stopmotion(e);cmotiongallery.cgals["+this.galid+"].showhidediv('hidden')");
}
this.loadedyes=1
if (endofgallerymsg!=""){
this.creatediv();
this.positiondiv();
}
}


function cmotionresize(){
for (var i_tem = 0; i_tem < cmotiongallery.cgals.length; i_tem++){
if (document.all&&document.all['motioncontainer'+i_tem]&&document.all['motioncontainer'+i_tem].filters){
document.all['motioncontainer'+i_tem].style.width="0";
document.all['motioncontainer'+i_tem].style.width=cmotiongallery.cgals[i_tem].width;
document.all['motioncontainer'+i_tem].style.width=Math.min(document.all['motioncontainer'+i_tem].offsetWidth, cmotiongallery.cgals[i_tem].maxw)+'px';
}
cmotiongallery.cgals[i_tem].menuwidth=cmotiongallery.cgals[i_tem].crossmain.offsetWidth;

cmotiongallery.cgals[i_tem].cross_scroll.style.left=cmotiongallery.cgals[i_tem].startpos? (cmotiongallery.cgals[i_tem].menuwidth-cmotiongallery.cgals[i_tem].actualwidth)/cmotiongallery.cgals[i_tem].startpos+'px' : 0;
}
}

if ( typeof window.addEventListener != "undefined" )
    window.addEventListener( "resize", cmotionresize, false );
else if ( typeof window.attachEvent != "undefined" )
    window.attachEvent( "onresize", cmotionresize );
else {
    if ( window.onresize != null ) {
        var oldOnresize = window.onresize;
        window.onresize = function ( e ) {
            oldOnresize( e );
            cmotionresize();
        };
    }
    else
        window.onresize = cmotionresize;
}