//2005 version Sugar Hill javascript module
var aNumList = new Array(
"12323~Karen finds a friend",
"12326~I like a girl who isn't squeamish about creepy-crawlies",
"12327~Friday potluck and card game",
"12328~Getting the kitchen organized",
"12330~Dinner Hour calm before dancing up a storm",
"12332~Peaceful Lodgings",
"12335~Margeaux with daughter Mia, and Karen",
"12337~Canoes are always a part of this weekend",
"12338~I always like the way the evening sun shines through the trees",
"12341~Saturday Supper, beans and chiles. No wonder everyone is moving fast!",
"12342~Off into the Sunset",
"12343~Collecting dishes",
"12344~Healthy dessert is coming",
"12345~Someone has to taste the ice cream to make sure that the right flavors are in the right drums!",
"12346~The ice cream line, a study in chaos theory",
"12347~Fiddling around between supper and dance on Saturday night",
"12348~Making his point?",
"12350~Wide view of post-prandial relaxation",
"12351~Vivacious femmes and their procession of admirers",
"12352~Anyone else see the storm a-coming?",
"12354~Karen hold tight as the moist and cooling storm winds preceed the horizontal rain",
"12358~&quot;What storm?&quot;",
"12359~Swinging around while waiting for the caller",
"12361~Left Allemand as a substitute for a star, on the end",
"12363~Swinging in a variety of styles",
"12365~Long Lines, with some enthusiasm shown",
"12369~One band of many",
"12373~Eye-Ewe alumni? Just some cards playing a game.",
"12374~Those who don't dance take pictures of those who don't dance",
"12377~Your photographer in his typical shy attire",
"12393~The caller catches me as I try for candid shots",
"12396~Up on a chair, for the long view",
"12398~Under the porch watching the rain on the gravel drive is still a good place to hear the music",
"12402~Adult supervision is child's play compared to challenging some of our young Chess Sharks",
"12403~Do bass-er reflexes make for better music?",
"12406~How to learn this licks: Doing.",
"12409~What the Hey?",
"12410~Twirling skirts entering a promenade",
"12412~Worth seeing: This is south of Bloomington, IN on 231 at I-64 exit 57. <a href='http://www.drteds.com/'>www.drteds.com</a> Museum of Musical Marvels",
"12414~Dr. Ted has a warehouse full of musical memoribilia including player pianos, street organs, Nickelodeons, and so much more",
"12433~Before the iPod (and the record player) music was made by elaborate programmable gizmos that actually played the instruments in concert",
"12454~Almost home (shot through the dirty window of a moving car)",
"12456~St. Louis. Land of 20 mph (really!) Interstate-to-Interstate ramps, a new baseball stadium going up, and the old classic Arch-matching stadium (demolished in the winter of 2005)"
);

var strPrefix, iMaxImg, iCurrentImg, currentDoc, sourceDoc, imgWin;

function getImgUrl(iNum){
  var aLine = aNumList[iNum].split('~'); //num~cap to 2 place array
  return strPrefix + aLine[0];
}//getImgUrl

function caption(iNum){
  var aLine = aNumList[iNum].split('~'); //num~cap to 2 place array
  return aLine[1];
}//getImgUrl

function findIndex(strFile){ // sort of a complement of getImgUrl()
   var i, strMatch, retVal;
   retVal = 0;
   strMatch = strFile.substr(4, strFile.indexOf('.') - 4); //strip DCP
   for (i=0;i<aNumList.length;i++){
      if (strMatch == aNumList[i]){
         retVal = i;
      }
   }
   return retVal;
}//findIndex()

function wdoContents(i){ // fill currentDoc with image i
    var imgSrc = getImgUrl(i)+".JPG";
    var strCap = caption(i);

    with (currentDoc){
      open();
      write('<html><body><div align="center">');
      write('<a href="javascript:',sourceDoc, '.prevImg();">&lt;&lt; prev</a>');
      write(' -- <b>' + imgSrc + '</b> -- ');
      write('<a href="javascript:',sourceDoc, '.nextImg();">next &gt;&gt;</a>');
      writeln('<p>');
      writeln('<font size="+1">',strCap,'</font><br />');
      write(' <img src="',imgSrc,'" alt="',strCap,'" /><br />',strCap,'</p>');
      write('<p>Copy this link to send the picture to someone:<br />');
      write('<a href="http://www.DanKlarmann.com/SugarHill/2005/index.html#',imgSrc,'" target="_new">');
      write('http://www.DanKlarmann.com/SugarHill/2005/index.html#',imgSrc,'</a></p>');

      write('</div></body></html>');
      close();
      iCurrentImg = i;
    } //endwith
}//wdoContents

function fillWindow(i){ //frames version
  currentDoc = parent.SHWindow.document;
  sourceDoc = 'parent.main';
  wdoContents(i);
}//fillWindow

function showImg(imgNum){ // for fillWindow or showImg
   if (! imgWin){
      imgWin = window.open("", "SHWindow","resizable,scrollbars,status,height=450");
      if (navigator.appName.indexOf('Netscape') >= 0){ // Netscape browser
         imgWin.innerHeight=450;
      }
   } else if (!imgWin.document){
      imgWin = window.open("", "SHWindow","resizable,scrollbars,status,height=450");
      if (navigator.appName.indexOf('Netscape') >= 0){ // Netscape browser
         imgWin.innerHeight=450;
      }
   }

   imgWin.document.open();
   currentDoc = imgWin.document;
   sourceDoc = 'opener';
   wdoContents(imgNum); // fill the new/reused window
   imgWin.document.close();
//   imgWin.location.refresh;
   imgWin.focus();
}//showImg()

function closer(){ // for indexn: if opener closes, so does pop-up
  if (imgWin) {
    imgWin.close();
  }
}

function prevImg(){
  if (iCurrentImg > 0){
    wdoContents(iCurrentImg - 1);
  } else {
    alert("That's All Folks");
  }
}
function nextImg(){
  if (iCurrentImg < iMaxImg){
    wdoContents(iCurrentImg + 1);
  } else {
    alert("That's All Folks");
  }
}

function drawThumbs(){
    var popCode = '<a href="javascript:';
    if (window.name == 'main'){
      popCode += 'fillWindow('; //frames version
    } else {
      popCode += 'showImg('; //pop-up version
    }
    strPrefix = "DCP";
    iMaxImg = aNumList.length - 1;
    for (var i=0; i<= iMaxImg;i++){
      var url= getImgUrl(i);
      var imgsrc = url+"-t.jpg";
      url += ".jpg"

      document.write(popCode, i, ')" name="',url,'"><img src="',imgsrc,'" border="2" hspace="2" /></a> ');
    }// endfor
    if (parent.document.URL.indexOf('#') >= 0){// start with specific image
      // expecting ...#DCPxxxxx.jpg
      fillWindow(findIndex(parent.document.URL.substr( parent.document.URL.indexOf('#')+1)));
    }
}//drawThumbs()

