var IE = document.all?true:false
	if (!IE) document.captureEvents(Event.MOUSEMOVE)

	// Set-up to use getMouseXY function onMouseMove
	document.onmousemove = getMouseXY;

	// Temporary variables to hold mouse x-y pos.s
	var tempX = 0
	var tempY = 0

   var offX=15;
   var offY=15;

var involved=new Array();
var donate=new Array();
var contact=new Array();
var captions=new Array();
captions[1]="DJ Skelton (Paradox Sports founder) and Pete Davis helping Vijay Viswanathan with his climbing rig. Photo: Devaki Murch";
captions[2]="Orlando from the Wounded Warriors Project, lowering off after climbing up the School Slab during No Barriers Festival 2007. Donner Lake, CA, in the background. Photo: Malcolm Daly";
captions[3]="Robb Kinbrough testing out various climbing feet during the No Barriers Festival 2007. Donner Lake, CA in the background.  Photo: Malcolm Daly";
captions[4]="Timmy O&#146;Neill, Paradox Sports founder, showing his happy face at dinner. Photo: Malcolm Daly";
captions[5]="(L-R) Aron Ralston (Director), Pete Davis and Chad Jukes hanging around at the Red River Gorge, KY. Photo: Malcolm Daly";
captions[6]="Keith Deutsch lowering off at the red River Gorge, KY. Photo: Malcolm Daly";
captions[7]="Happy kid at No Barriers Festival 2007. Photo: Malcolm Daly";
captions[8]="Happy cousins. Same accident, same injuries, same chairs. No Barriers Festival, 2007. Photo: Malcolm Daly";
captions[9]="Angel from the Wounded Warriors Project, steppin&#146; up during the No Barriers Festival, 2007. Photo: Malcolm Daly";
captions[10]="Warren MacDonald showing us how it&#146;s done during the No Barriers Festival, 2007. Photo: Malcolm Daly";
captions[11]= "Vijay Viswanathan, a paraplegic, enjoys a night on Lake Tahoe in a Sea Kayak.";
captions[12]= "Mark Wellman, Uber-gimp, grinding his way to the summit of Mt. Shasta on a Snow-Pod."; 
captions[13]= "One-arm Willie (Stewart) in the thick of Lava Falls at 25,000 cfs with a jury-rigged prosthetic after his broke."; 
captions[14]= "Paradox Sports"; 
captions[15]= "Vijay Viswanathan playing in the water. Photo: Malcolm Daly"; 
captions[16]= "Vijay Viswanathan streakin on his One Off. Photo: Malcolm Daly"; 
captions[17]= "Vijay Viswanathan pushes his One Off to the limit. Photo: Malcolm Daly";
captions[18]= "Quad bikes dominate in the Flatirons. Photo: Malcolm Daly"; 
var imgLoad	= new Image();
imgLoad.src=	"images/HomeBG/Home_BG1.jpg";
imgLoad.src=	"images/HomeBG/Home_BG2.jpg";
imgLoad.src=	"images/HomeBG/Home_BG3.jpg";
imgLoad.src=	"images/HomeBG/Home_BG4.jpg";
imgLoad.src=	"images/HomeBG/Home_BG5.jpg";
imgLoad.src=	"images/HomeBG/Home_BG6.jpg";
imgLoad.src=	"images/HomeBG/Home_BG7.jpg";
imgLoad.src=	"images/HomeBG/Home_BG8.jpg";
imgLoad.src=	"images/HomeBG/Home_BG9.jpg";
imgLoad.src=	"images/HomeBG/Home_BG10.jpg";
imgLoad.src=	"images/HomeBG/Home_BG11.jpg";
imgLoad.src=	"images/HomeBG/Home_BG12.jpg";
imgLoad.src=	"images/HomeBG/Home_BG13.jpg";
imgLoad.src=	"images/HomeBG/Home_BG14.jpg";
imgLoad.src=	"images/HomeBG/Home_BG15.jpg";
imgLoad.src=	"images/HomeBG/Home_BG16.jpg";
imgLoad.src=	"images/HomeBG/Home_BG17.jpg";
imgLoad.src=	"images/HomeBG/Home_BG18.jpg";

var cimages=new Array();
cimages[1]=		"images/HomeBG/Home_BG1.jpg";
cimages[2]=		"images/HomeBG/Home_BG2.jpg";
cimages[3]=		"images/HomeBG/Home_BG3.jpg";
cimages[4]=		"images/HomeBG/Home_BG4.jpg";
cimages[5]=		"images/HomeBG/Home_BG5.jpg";
cimages[6]=		"images/HomeBG/Home_BG6.jpg";
cimages[7]=		"images/HomeBG/Home_BG7.jpg";
cimages[8]=		"images/HomeBG/Home_BG8.jpg";
cimages[9]=		"images/HomeBG/Home_BG9.jpg";
cimages[10]=	"images/HomeBG/Home_BG10.jpg";
cimages[11]=	"images/HomeBG/Home_BG11.jpg";
cimages[12]=	"images/HomeBG/Home_BG12.jpg";
cimages[13]=	"images/HomeBG/Home_BG13.jpg";
cimages[14]=	"images/HomeBG/Home_BG14.jpg";
cimages[15]=	"images/HomeBG/Home_BG15.jpg";
cimages[16]=	"images/HomeBG/Home_BG16.jpg";
cimages[17]=	"images/HomeBG/Home_BG17.jpg";
cimages[18]=	"images/HomeBG/Home_BG18.jpg";

involved['off']="/images/Footer_PlusLeft.gif";
involved['on']="/images/Footer_MinusLeft.gif";

donate['off']="/images/FooterMiddlePlus.gif";
donate['on']="/images/FooterMiddleMinus.gif";

contact['off']="/images/FooterRightPlus.gif";
contact['on']="/images/FooterRightMinus.gif";

var minBG=1;
var maxBG=18;
/**
 * The following toggles the images on the slider drop downs
 */
 var involvedOff=true;
 var donateOff=true
 var contactOff=true;
var toggleSliderImg=function(id)
{

   var img=$(id);
   if(id=="involved_img")
   {
      if(involvedOff==false)
      {
      	img.src=involved['off'];
      	involvedOff=true;
      }
      else
      {
      	img.src=involved['on'];
      	involvedOff=false;
      }

   }
   else if(id=="donate_img")
   {
      if(donateOff==false)
      {
      	img.src=donate['off'];
      	donateOff=true;
      }
      else
      {
      	img.src=donate['on'];
      	donateOff=false;
      }
   }
   else if(id=="contact_img")
   {
      if(contactOff==false)
      {
      	img.src=contact['off'];
      	contactOff=true;
      }
      else
      {
      	img.src=contact['on'];
      	contactOff=false;
      }
   }
}
var tempBGImage="";
var showLoading=function()
{
	$('imageLoader').style.visibility="visible";
}
var hideLoading=function()
{
	$('imageLoader').style.visibility="hidden";
}
var currentIndex=Math.floor((Math.random() * (maxBG-minBG+1))+minBG);
var updateBG=function()
{
   //showLoading();
   if (currentIndex == 18)
   {
   	currentIndex = 1
   }
   else
   {
   	currentIndex++;
   }

   var img = new Image();
   img.src=cimages[currentIndex]
   
   img.onload=function(){var el=$('HomeBGTable');
    el.className="HomeBG"+currentIndex;}
    $('thumbnail_container').innerHTML=captions[currentIndex]+'&nbsp;&nbsp;<a href="javascript:;" onClick="closeBGInfo()">Close</a>';
    periodical.stop();
    periodical	= new PeriodicalExecuter(updateBG, 7);
    
}
var updateBGPosition=true;

var periodical	= new PeriodicalExecuter(updateBG, 7);

var showBGInfo=function()
{
    var offsetLeft=20;
    var offsetTop=-5;
    el=$('thumbnail_container');   
 
    if(updateBGPosition)
    {
 	/*	el.style.top=theY+offsetTop+"px";
		el.style.left=theX+offsetLeft+"px";
			
		updateBGPosition=false;
		*/
	}

	el.style.visibility="visible";
	
}
var closeBGInfo=function()
{
	
	$('thumbnail_container').style.visibility="hidden";
}



var theX=0;
var theY=0;
// Move the div based on the mouse pointer.
function getMouseXY(e) {

    	if (IE) { // grab the x-y pos.s if browser is IE
    	tempX = event.clientX + document.body.scrollLeft
    	tempY = event.clientY + document.body.scrollTop
  	 } else {  // grab the x-y pos.s if browser is NS
    	tempX = e.pageX
    	tempY = e.pageY
   }  
   // catch possible negative values in NS4
   if (tempX < 0){tempX = 0}
   if (tempY < 0){tempY = 0}  
   // show the position values in the form named Show
   // in the text fields named MouseX and MouseY
      //var el=document.getElementById('thumbnail_info');	   
      theX=parseFloat(tempX)
      theY=parseFloat(tempY)
     // $('position').innerHTML="X:"+theX+"  Y:"+theY;
      return true
   }

/**
 * The following creates the thumbnail preview for the gallery images
 *
 */
 var movePreview=true;
 var moveTop=0;
 var currentPic=0;
 function showPreview(id)
 {
    var el=$('thumbnailPreview');
    var elContainer=$('thumbnailHolder');
    if(moveTop==0)
    {
       var staticTop=findPos($('imageText'));
       moveTop=staticTop[1];
    }
    
    var coords=findPos($('thumb_'+id));
    var offsetLeft=0;
    var offsetTop=-73;
    if(movePreview)
    {
 		elContainer.style.top=moveTop+offsetTop+"px";
		elContainer.style.left=coords[0]+offsetLeft+"px";	
	    movePreview=false;
	   
	} 
	 var path='thumbs/prev_'+galleryImages[id];
	    
    el.innerHTML="<img src='"+path+"'>\n";
    el.style.display="inline";
	elContainer.style.display="block";	
 }
  
 function hidePreview()
 {
     var el=$('thumbnailPreview');
     var el2=$('thumbnailHolder');
     el.innerHTML="";
     el2.style.display="none";
     el.style.display="none";
	 movePreview=true;
 }
 
 
 
 function findPos(obj) {
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		curleft = obj.offsetLeft
		curtop = obj.offsetTop
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft
			curtop += obj.offsetTop
		}
	}
	return [curleft,curtop];
}
function changeImage(id,stop)
{
  if(stop)
     stopGallery();
  var theImage=$('main_image');
 // theImage.src='gallery/'+galleryImages[id];
  var imageText=$('imageText');
  swapfade(theImage,'gallery/'+galleryImages[id],1);
  imageText.innerHTML=galleryText[id];
  currentPic=id;
}

function nextImage(stop)
{
   var nextInd=0;
   if(currentPic>=galleryImages.length-1)
      nextInd=0;
   else
      nextInd=currentPic+1;
   
   changeImage(nextInd,stop);
}
function prevImage(stop)
{
   var prevInd=0;
   if(currentPic>0)
      prevInd=currentPic-1;
   else
   	  prevInd=galleryImages.length-1;
  changeImage(prevInd,stop);
}
var thePlayer=null;
function playGallery()
{
	nextImage();
   thePlayer=window.setInterval("nextImage(0)",3000);
}
function stopGallery()
{
	clearInterval(thePlayer);
}

var showCurrentTotal=function()
{
   var el=$('CurrentTotal');
   el.style.display="block";
}

