    var bDebug = false;
    var pageBoxHeightOrig = 1520;
    var pageBoxHeightExpanded = 1870;
    var scrollIdeal = 100;
    var slideTime = 3000;
    var videoScroll = 300;
    var photoIdx = 0;
    var showIdx = 0;
    var numPhotos = 0;
    var currentNum = 1;
    var numSlides = 0;
    var bigVideoIdx = 0;
    var bigVideoWidth = 640;
    var bigVideoHeight = 480;
    var videoControlsHeight = 13;
    var photosAllLoaded = false;
    
    var maxVidIdx = 3;
    
    var videos = new Array();
    videos[0] = "rond_point";
    
    var aSlideshows = new Array();
    aSlideshows[0] = new Object();
    aSlideshows[0].name = "cruise";
    aSlideshows[0].title = "Pacific Jewel, Nov. 2010 - Apr. 2011"
    aSlideshows[0].maxIndex = 10;
    aSlideshows[1] = new Object();
    aSlideshows[1].name = "france";
    aSlideshows[1].title = "South Of France, May 2010 - Sept. 2010"
    aSlideshows[1].maxIndex = 7;
    aSlideshows[2] = new Object();
    aSlideshows[2].name = "meribel";
    aSlideshows[2].title = "The French Alps, Dec. 2009 - Apr. 2010"
    aSlideshows[2].maxIndex = 19;

    
    
    
    function init() {
      setTimeout("doInit()",500);
      
    }
      
    function doInit() {
      // load stuff regardless of page you land on so when you go to vids its ready
      //if (document.getElementById("vid0")) {
        
       // highlightNavItem();
        debug('init');
        countPhotos();
        loadPhoto();
      //}
      //var endDiv = document.getElementById("end");
      //alert(endDiv.style.scrollTop);
      //document.getElementById("pageBoxHeight").style.height = endDiv.style.top;
    }
     /*
    function highlightNavItem() {
      var loc = document.location.href;
      var aLoc = loc.split("/");
      var l = aLoc.length-1;
      var filename = aLoc[l];
      var name = "nav" + filename.replace(".shtml","");
      alert(name);
      var nitem = document.getElementById(nitem);
      nitem.style.display="none";
    }
    */
    
    function countPhotos()  {
      for (i=0; i<aSlideshows.length; i++)  {
         numPhotos = numPhotos + aSlideshows[i].maxIndex + 1;
      }
    }
    
    function loadPhoto()  {
      var url = "photos/" + aSlideshows[showIdx].name + photoIdx + ".jpg";
      debug('Requesting photo ' + url); 
      var progress = document.getElementById("progress");
      progress.innerHTML = "Loading slideshow photos... " + currentNum + " of " + numPhotos;
      ajaxRequest(url);
    }
    
    function preloadVideosNew() {
      photosAllLoaded = true;
      var url = "video/" + videos[0] + ".MOV";
      debug("loading videos new "  + url);
      var progress = document.getElementById("progress");
      progress.innerHTML = "Loading video";
      ajaxRequest(url);
    }
    
    function ajaxRequest(url)	{ 
    	if (window.XMLHttpRequest) {
    		  xmlHttp=new XMLHttpRequest();
    	}
    	else if (window.ActiveXObject)  {
    		try {
    			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP")
    		}
    		catch(e) {
    			 xmlHttp=new ActiveXObject("Microsoft.XMLHTTP")
    		}
    	}
    	xmlHttp.open("GET", url, true);
    	xmlHttp.onreadystatechange = stateChanged;
    	xmlHttp.send(null); 
    }
    
    
    function stateChanged()	{
      var progress = document.getElementById("progress");
      //progress.innerHTML = xmlHttp.readyState;
      debug(xmlHttp.readyState);
      if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") { 
    		debug(xmlHttp.status + ' ' + xmlHttp.statusText);
        if (xmlHttp.status == 200 && xmlHttp.statusText == "OK") {
          currentNum++;
          debug('loaded');
          if (!photosAllLoaded)  {
            loadNextPhoto();	
          }
    		}
    	} 
    }
    
    function loadNextPhoto()  {
      photoIdx++;
      if (typeof aSlideshows[showIdx] == "undefined")   {
        //finished photos
        //preloadVideosNew();
        hideProgress();
      }
      else  {
        if (photoIdx > aSlideshows[showIdx].maxIndex)  {
           photoIdx = 0;
           showIdx++; 
           if (typeof aSlideshows[showIdx] == "undefined")   {
              //finished photos
              //preloadVideosNew();
              hideProgress();
           }
           else {
              loadPhoto();
           }
        }
        else  {
          loadPhoto();
        }
      }
    }
    
    function hideProgress() {
      var progress = document.getElementById("progress");
      progress.style.display = "none";
    }
    
    
    function preloadVideos()  {
      var progress = document.getElementById("progress");
      progress.innerHTML = "Loading videos";
      debug ('loading videos');
      for (n=0; n<videos.length; n++) {
        preloadVideo(n);
      }
      progress.style.display = "none";
    }        
       
    function preloadVideo(n)  {
      debug(n);
      var vwidth = 160;
      var vheight = 133;
      if (n==bigVideoIdx) {
        vwidth = bigVideoWidth;
        vheight = bigVideoHeight + videoControlsHeight;
      }
      
      var divName = "vid" + n;
      var imgName = "vidThumb" + n;
      var vidPath = "video/" + videos[n] + ".MOV" ;
      var imgToRemove = document.getElementById(imgName);
      var objectTag = "<OBJECT id=\"QTPlayer1\" CLASSID=\"clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B\" WIDTH=\"" + vwidth + "\" HEIGHT=\"" + vheight + "\" CODEBASE=\"http://www.apple.com/qtactivex/qtplugin.cab\">" ;
      objectTag += "<PARAM name=\"SRC\" VALUE=\"" + vidPath + "\">";
      objectTag += "<PARAM name=\"AUTOPLAY\" VALUE=\"false\">";
      objectTag += "<PARAM name=\"CONTROLLER\" VALUE=\"true\">";
      objectTag += "<PARAM name=\"LOOP\" VALUE=\"false\">";
      objectTag += "<PARAM name=\"SCALE\" VALUE=\"1\"> ";
      objectTag += "<EMBED SRC=\"" + vidPath + "\" WIDTH=\"" + vwidth + "\" HEIGHT=\"" + vheight + "\" AUTOPLAY=\"false\" CONTROLLER=\"true\" LOOP=\"false\" SCALE=\"1\" PLUGINSPAGE=\"http://www.apple.com/quicktime/download/\">  ";
      objectTag += "</EMBED>";
      objectTag += "</OBJECT>";
      if (typeof imgToRemove != 'undefined')  {
        if (imgToRemove)  {
          imgToRemove.parentNode.removeChild(imgToRemove);
        }
      }
      //alert('objectTag');
      document.getElementById(divName).innerHTML = objectTag;
    }
    
    var lastClicked = 0;
    
    function bigPic(id) { 
      var num = parseInt(id.replace('thumb',''));
      lastClicked = num;
      var showName = aSlideshows[num].name;
      numSlides = aSlideshows[num].maxIndex + 1;
      debug(id + ' ' + num + ' ' + showName);
      var picPath = "photos/" + showName + "0.jpg";
      var bigImg = document.getElementById("bigImg");
      var picDiv = document.getElementById("bigPic");
      document.getElementById("pageBoxHeight").style.height = pageBoxHeightExpanded;
      var currentY = document.body.scrollTop;
      var startY=Math.ceil(currentY/10);
      if (startY < scrollIdeal) {
        for (i=startY; i<scrollIdeal; i++)  {
          var scrollY = (i+1)*10;
          setTimeout("scrollPos(" + scrollY + ")",10);
        }
      }
      if (startY > scrollIdeal) {
        for (i=startY; i>scrollIdeal; i--)  {
          var scrollY = (i-1)*10;
          setTimeout("scrollPos(" + scrollY + ")",10);
        }
      }
      setTimeout("scrollPos(" + scrollIdeal*10 + ")",10);
      bigImg.src = picPath;
      picTitle(num, 0);
      picDiv.style.display="block";
      setTimeout("rotateSlides(" + num + "," + 0 + ")",slideTime);
    }
     
    function picTitle(showNum, picNum) {
      var closeBigPic = document.getElementById("closeBigPic");
      picNum++;
      closeBigPic.innerHTML = "&nbsp;Click to close : " + aSlideshows[showNum].title + ". " + picNum + " of " + numSlides;
    }
     
    function rotateSlides(num, idx)  {
      debug("rotating " + num + " " + idx);
      var bigImg = document.getElementById("bigImg");
      var picDiv = document.getElementById("bigPic");
      if (picDiv.style.display != "block") {
        debug ("div is hidden - finishing");
        return;
      }
      //stops rotating pics if another show clicked while div still open
      if (lastClicked != num) {
        debug ("finishing thread for pic " + num);
        return;
      }
      var showName = aSlideshows[num].name;
      var nextIdx = idx+1;
      if (nextIdx > aSlideshows[num].maxIndex)  {
        nextIdx = 0;
      }
      //debug(nextIdx);
      var picPath = "photos/" + showName + nextIdx + ".jpg";
      debug(picPath);
      bigImg.src = picPath;
      picTitle(num, nextIdx);
      setTimeout("rotateSlides(" + num + "," + nextIdx + ")",slideTime);
    }
   
    
    function scrollPos(scrollY)  {
        document.body.scrollTop = scrollY;
    }
    
    function closeBigPic()  {
      var picDiv = document.getElementById("bigPic");
      var currentY = document.body.scrollTop;
      var startY=Math.floor(currentY/10);
      if (startY < scrollIdeal) {
        for (i=startY; i<scrollIdeal; i++)  {
          var scrollY = (i+1)*10;
          setTimeout("scrollPos(" + scrollY + ")",10);
        }
      }
      if (startY > scrollIdeal) {
        for (i=startY; i>scrollIdeal; i--)  {
          var scrollY = (i-1)*10;
          setTimeout("scrollPos(" + scrollY + ")",10);
        }
      }
      setTimeout("scrollPos(" + scrollIdeal*10 + ")",10); 
      picDiv.style.display="none";
      document.getElementById("pageBoxHeight").style.height = pageBoxHeightOrig;
    }
    
    function playtrack(filename)	{
	   document.getElementById("playerFrame").src = "mp3/" + filename + ".m3u";
    }
    
    function playLive(n)  {
      var playdiv = document.getElementById("playDiv");
      if (n)  { 
        playdiv.style.display = "block" ;
      }
      else  {
         playdiv.style.display = "none";
      }
    }
    
    function goLive(n)  {
      document.location.href = "feedback.shtml";
    }
    
    function showSub()  {
      document.getElementById("liveSubNav").style.display = "block";
    }
    
    function hideSub()  {
      document.getElementById("liveSubNav").style.display = "none";
    }
    
    function playVid(id)  {
      var num = id.replace('videothumb','');
      var i = parseInt(num);
      for (j=0; j<=maxVidIdx; j++)  {
        var divName = "vid" + j;
        var labelName = "vidLabel" + j;
        var vidDiv = document.getElementById(divName);
        var labelDiv = document.getElementById(labelName);
        //alert(divName + " " + labelName);
        if (j==i)  {
          //alert(j + " " + i + "equal"); 
          vidDiv.style.display = "block";
          labelDiv.style.display = "block";
        } else  {
          //alert(j + " " + i + "unequal");
          vidDiv.style.display = "none";
          labelDiv.style.display = "none";
        }
      }
      scrollPos(videoScroll); 
    }
    
    function debug(str)  {
      if (bDebug)  {
        alert(str);
      }
    }
