
//////////////////////////////////////////////////////////
// initial setup scripts and utility scripts
//////////////////////////////////////////////////////////

function setupOnLoad()
{
   // perform any necessary tasks on page load
   
   // if a color input parameter is specified, then set the color scheme to that color
   if(existsParameterKey("color"))
   {
      changeColorTheme(getParameterValue("color"));
   }
   else
   {
      // if a cookie specifying the last color theme used is present, then set the color
      // theme accordingly
      var color = getCookie("pageColorTheme");
      if(color != null)
      {
         changeColorTheme(color);
      }
      else
      {
         // no cookie specified; just do the default color
         changeColorTheme(-1);
      }
   }
   
   // expand any sections that were previously left expanded
   /*
   var doExpand = getCookie("expandResearchInterests");
   if(doExpand != null)
   {
      toggleExpansion("rsrch_int");
   }
   doExpand = getCookie("expandCourses");
   if(doExpand != null)
   {
      toggleExpansion("courses");
   }
   */
   var doExpand = getCookie("expandOtherStuff");
   if(doExpand != null)
   {
      toggleExpansion("other_stuff");
   }
   
   // activate any secret codes that were previously entered
   var code = getCookie("secretCode1");
   if(code == "1")
   {
      activateCode(1, "no");
   }
   code = getCookie("secretCode2");
   if(code == "1")
   {
      activateCode(2, "no");
   }
   code = getCookie("secretCode3");
   if(code == "1")
   {
      activateCode(3, "no");
   }
   code = getCookie("secretCode4");
   if(code == "1")
   {
      activateCode(4, "no");
   }
   code = getCookie("secretCode5");
   if(code == "1")
   {
      activateCode(5, "no");
   }
   code = getCookie("secretCode6");
   if(code == "1")
   {
      activateCode(6, "no");
   }
   code = getCookie("secretCode7");
   if(code == "1")
   {
      activateCode(7, "no");
   }
   code = getCookie("secretCode8");
   if(code == "1")
   {
      activateCode(8, "no");
   }
   
   // set the secret code visibility to 'hidden' in the "personal interests" section
   setCodeInfoVisibility("hidden");
   
   // Special check: if we're supposed to jump to other stuff, then do it again
   // here, now that we've expanded to section (otherwise, we jump there BEFORE
   // expanding the section, and it therefore looks like it jumps to a weird place).
   if(window.location.hash == "#other_stuff_anchor")
   {
      window.location.hash = "#other_stuff_anchor";
   }
}

function existsParameterKey(key)
{
   // return true or false, depending upon whether the address of this page includes
   // "key=..." as part of the parameter string.
   
   var query = window.location.search;
   
   // Skip the leading ?, which should always be there (but be careful anyway)
   if (query.substring(0, 1) == '?')
   {
      query = query.substring(1);
   }
   var data = query.split(/=|&/);
   // scan all input parameters to see if the specified one is included

   for (i = 0; i < data.length; i+=2)
   {
      if(data[i] == key)
      {
         return true;
      }
   }
   return false;
}

function getParameterValue(key)
{
   // ASSUME that "key=..." exists as a parameter in the parameter string, then
   // return the value associated with that key.
   
   var query = window.location.search;
   // Skip the leading ?, which should always be there (but be careful anyway)
   if (query.substring(0, 1) == '?')
   {
      query = query.substring(1);
   }
   var data = query.split(/=|&/);
   
   // scan all input parameters to see if the specified one is included

   for (i = 0; i < data.length; i+=2)
   {
      if(data[i] == key)
      {
         return data[i+1];
      }
   }
   
   return null;
}

function existsParameterKeyVal(key, value)
{
   // return true or false, depending upon whether the address of this page includes
   // "key=value" as part of the parameter string.
   
   var query = window.location.search;
   // Skip the leading ?, which should always be there (but be careful anyway)
   if (query.substring(0, 1) == '?')
   {
      query = query.substring(1);
   }
   var data = query.split(/=|&/);
   
   // scan all input parameters to see if the specified one is included

   for (i = 0; i < data.length; i+=2)
   {
      if(data[i] == key && data[i+1] == value)
      {
         return true;
      }
   }
   return false;
}

///////////////////////////////////////////
// secret code to activate link functions
///////////////////////////////////////////

var currColorSave;
var notifyIterationsToDo;
var colorCodeArray = new Array("-1", "0", "1", "2", "3");
var doneCodeEnteredNotify = true;
var currColorIndex = 0;
var currentCode = "";
var showCodeInfo = 0;

function toggleShowCodeInfo()
{
   var block = document.getElementById("toggleShowCodeInfoButton");
   block.bgColor = "#888888";
   
   if(showCodeInfo == 0)
   {
      showCodeInfo = 1;
      setCodeInfoVisibility("visible");
   }
   else
   {
      showCodeInfo = 0;
      setCodeInfoVisibility("hidden");
   }
   
   setTimeout("changeBackShowCodeInfoButtonColor()", 100);
}

function setCodeInfoVisibility(visibilityType)
{
   var block = document.getElementById("pizzaConfirmed");
   block.style.visibility = visibilityType;
   block = document.getElementById("pizzaCode");
   block.style.visibility = visibilityType;
   block = document.getElementById("cartoonsConfirmed");
   block.style.visibility = visibilityType;
   block = document.getElementById("cartoonsCode");
   block.style.visibility = visibilityType;
   block = document.getElementById("videoGamesConfirmed");
   block.style.visibility = visibilityType;
   block = document.getElementById("videoGamesCode");
   block.style.visibility = visibilityType;
   block = document.getElementById("disneylandConfirmed");
   block.style.visibility = visibilityType;
   block = document.getElementById("disneylandCode");
   block.style.visibility = visibilityType;
   block = document.getElementById("comicsConfirmed");
   block.style.visibility = visibilityType;
   block = document.getElementById("comicsCode");
   block.style.visibility = visibilityType;
   block = document.getElementById("moviesConfirmed");
   block.style.visibility = visibilityType;
   block = document.getElementById("moviesCode");
   block.style.visibility = visibilityType;
   block = document.getElementById("birdsConfirmed");
   block.style.visibility = visibilityType;
   block = document.getElementById("birdsCode");
   block.style.visibility = visibilityType;
   block = document.getElementById("rainyDaysConfirmed");
   block.style.visibility = visibilityType;
   block = document.getElementById("rainyDaysCode");
   block.style.visibility = visibilityType;
   
   block = document.getElementById("releaseCodes");
   block.style.visibility = visibilityType;
   block = document.getElementById("releaseCodesPlaceholder");
   block.style.visibility = visibilityType;
}

function changeBackShowCodeInfoButtonColor()
{
   var block = document.getElementById("toggleShowCodeInfoButton");
   block.bgColor = "#000000";
}



function rollover_pic(overOrOut, img_name, img_src)
{  
   document[img_name].src = img_src;

   if(!doneCodeEnteredNotify)
   {
      return;
   }
   
   if(overOrOut == "over")
   {
      if(img_name == "pizza_pic")
      {
         currentCode += "1";
      }
      else if(img_name == "cartoon_pic")
      {
         currentCode += "2";
      }
      else if(img_name == "video_game_pic")
      {
         currentCode += "3";
      }
      else if(img_name == "disneyland_pic")
      {
         currentCode += "4";
      }
      else if(img_name == "comics_pic")
      {
         currentCode += "5";
      }
      else if(img_name == "movie_pic")
      {
         currentCode += "6";
      }
      else if(img_name == "bird_pic")
      {
         currentCode += "7";
      }
      else if(img_name == "rain_pic")
      {
         currentCode += "8";
      }
   }
      
   if(currentCode.length > 14)
   {
      currentCode = currentCode.substring(1);
   }
   
   if(currentCode.length > 14)
   {
      currentCode = "";
   }
   
   // Check if a secret code was entered.
   var enteredCode = 0;
   if(currentCode == "51267348732651")
   {
      // Secret code successfully entered!  Activate the message and links.
      activateCode(1, "yes");
   }
   else if(currentCode == "621567348732" || currentCode.substring(1) == "621567348732" ||
           currentCode.substring(2) == "621567348732")
   {
      // Secret code successfully entered!  Activate the message and links.
      activateCode(2, "yes");
   }
   else if(currentCode == "734876215623" || currentCode.substring(1) == "734876215623" ||
           currentCode.substring(2) == "734876215623")
   {
      // Secret code successfully entered!  Activate the message and links.
      activateCode(3, "yes");
   }
   else if(currentCode == "84376215623784")
   {
      // Secret code successfully entered!  Activate the message and links.
      activateCode(4, "yes");
   }
   else if(currentCode == "123487651265" || currentCode.substring(1) == "123487651265" ||
           currentCode.substring(2) == "123487651265")
   {
      // Secret code successfully entered!  Activate the message and links.
      activateCode(5, "yes");
   }
   else if(currentCode == "265123784376" || currentCode.substring(1) == "265123784376" ||
           currentCode.substring(2) == "265123784376")
   {
      // Secret code successfully entered!  Activate the message and links.
      activateCode(6, "yes");
   }
   else if(currentCode == "378432651267" || currentCode.substring(1) == "378432651267" ||
           currentCode.substring(2) == "378432651267")
   {
      // Secret code successfully entered!  Activate the message and links.
      activateCode(7, "yes");
   }
   else if(currentCode == "432156784378" || currentCode.substring(1) == "432156784378" ||
           currentCode.substring(2) == "432156784378")
   {
      // Secret code successfully entered!  Activate the message and links.
      activateCode(8, "yes");
   }

}

function activateCode(codeNum, doNotify)
{
   var enteredCode = 0;
   
   if(codeNum == 1)
   {
      setCookie("secretCode1", 1, 1000);
      
      activateCodeMessage("pizza");
      
      var linkObject = document.getElementById("pizzaLink");
      linkObject.setAttribute("href","pizza.html");
      
      enteredCode = 1;
   }
   else if(codeNum == 2)
   {
      setCookie("secretCode2", 1, 1000);
      
      activateCodeMessage("cartoons");
      
      var linkObject = document.getElementById("cartoonsLink");
      linkObject.setAttribute("href","cartoons.html");
      
      enteredCode = 1;
   }
   else if(codeNum == 3)
   {
      setCookie("secretCode3", 1, 1000);
      
      activateCodeMessage("videoGames");
      
      var linkObject = document.getElementById("videoGamesLink");
      linkObject.setAttribute("href","video_games.html");
      
      enteredCode = 1;
   }
   else if(codeNum == 4)
   {
      setCookie("secretCode4", 1, 1000);
      
      activateCodeMessage("disneyland");
      
      var linkObject = document.getElementById("disneylandLink");
      linkObject.setAttribute("href","disneyland.html");
      
      enteredCode = 1;
   }
   else if(codeNum == 5)
   {
      setCookie("secretCode5", 1, 1000);
      
      activateCodeMessage("comics");
      
      var linkObject = document.getElementById("comicsLink");
      linkObject.setAttribute("href","comics.html");
      
      enteredCode = 1;
   }
   else if(codeNum == 6)
   {
      setCookie("secretCode6", 1, 1000);
      
      activateCodeMessage("movies");
      
      var linkObject = document.getElementById("moviesLink");
      linkObject.setAttribute("href","movies.html");
      
      enteredCode = 1;
   }
   else if(codeNum == 7)
   {
      setCookie("secretCode7", 1, 1000);
      
      activateCodeMessage("birds");
      
      var linkObject = document.getElementById("birdsLink");
      linkObject.setAttribute("href","birds.html");
      
      enteredCode = 1;
   }
   else if(codeNum == 8)
   {
      setCookie("secretCode8", 1, 1000);
      
      activateCodeMessage("rainyDays");
      
      var linkObject = document.getElementById("rainyDaysLink");
      linkObject.setAttribute("href","rainy_days.html");
      
      enteredCode = 1;
   }
   
      
   if(enteredCode == 1)
   {
      // reset the current code
      currentCode = "";
      
      // ensure the button to release the codes is visible
      var block = document.getElementById("releaseCodesPlaceholder");
      block.style.display = "none";
      block = document.getElementById("releaseCodes");
      block.style.display = "block";
      
      if(doNotify == "yes")
      {
         // initialize the page color changes to last for a couple seconds, so the user
         // can easily tell that something "good" happened
      
         // save the current color theme
         currColorSave = getCookie("pageColorTheme");
         if(currColorSave == null)
         {
            // no cookie specified; just do the default color
            currColorSave = "-1";
         }
      
         notifyIterationsToDo = 20;
         doneCodeEnteredNotify = false;
         codeEnteredNotify();
      }
   }
}

function releaseCodes()
{
   var block = document.getElementById("pizzaConfirmed");
   block.style.display = "none";
   block = document.getElementById("pizzaCode");
   block.style.display = "block";
   block = document.getElementById("pizzaLink");
   block.removeAttribute("href");
   
   block = document.getElementById("cartoonsConfirmed");
   block.style.display = "none";
   block = document.getElementById("cartoonsCode");
   block.style.display = "block";
   block = document.getElementById("cartoonsLink");
   block.removeAttribute("href");
   
   block = document.getElementById("videoGamesConfirmed");
   block.style.display = "none";
   block = document.getElementById("videoGamesCode");
   block.style.display = "block";
   block = document.getElementById("videoGamesLink");
   block.removeAttribute("href");
   
   block = document.getElementById("disneylandConfirmed");
   block.style.display = "none";
   block = document.getElementById("disneylandCode");
   block.style.display = "block";
   block = document.getElementById("disneylandLink");
   block.removeAttribute("href");
   
   block = document.getElementById("comicsConfirmed");
   block.style.display = "none";
   block = document.getElementById("comicsCode");
   block.style.display = "block";
   block = document.getElementById("comicsLink");
   block.removeAttribute("href");
   
   block = document.getElementById("moviesConfirmed");
   block.style.display = "none";
   block = document.getElementById("moviesCode");
   block.style.display = "block";
   block = document.getElementById("moviesLink");
   block.removeAttribute("href");
   
   block = document.getElementById("birdsConfirmed");
   block.style.display = "none";
   block = document.getElementById("birdsCode");
   block.style.display = "block";
   block = document.getElementById("birdsLink");
   block.removeAttribute("href");
   
   block = document.getElementById("rainyDaysConfirmed");
   block.style.display = "none";
   block = document.getElementById("rainyDaysCode");
   block.style.display = "block";
   block = document.getElementById("rainyDaysLink");
   block.removeAttribute("href");
      
   var block = document.getElementById("releaseCodes");
   block.style.display = "none";
   block = document.getElementById("releaseCodesPlaceholder");
   block.style.display = "block";
   
   deleteCookie("secretCode1");
   deleteCookie("secretCode2");
   deleteCookie("secretCode3");
   deleteCookie("secretCode4");
   deleteCookie("secretCode5");
   deleteCookie("secretCode6");
   deleteCookie("secretCode7");
   deleteCookie("secretCode8");
}

function codeEnteredNotify()
{
   if(notifyIterationsToDo > 0)
   {
      notifyIterationsToDo--;
      changeColorTheme(colorCodeArray[currColorIndex]);
      currColorIndex++;
      if(currColorIndex >= colorCodeArray.length)
      {
         currColorIndex = 0;
      }
      setTimeout("codeEnteredNotify()", 50);
   }
   else
   {
      changeColorTheme(currColorSave);
      doneCodeEnteredNotify = true;
   }
}

/////////////////////////////
// game functions
/////////////////////////////

var colorArray = new Array("00","11","22","33","44","55","66","77","88","99","AA","BB","CC","DD","EE","FF");

var baseR;
var baseG;
var baseB;

var playR;
var playG;
var playB;

var startedPlaying;

function gameButtonClick()
{
   if(!document.getElementsByTagName)
   {
      return;
   }
   
   // change the game button color to show something happened when it was clicked
   var gameButton = document.getElementById("gameButton");
   gameButton.bgColor = "#888888";
   setTimeout("resetGame()", 100);
}

function resetGame()
{
   if(!document.getElementsByTagName)
   {
      return;
   }
   
   // ensure the game win block is hidden
   var gameWinBlock = document.getElementById("gameWinBlock");
   gameWinBlock.style.visibility = "hidden";
   
   // put the game button back to the original color
   var gameButton = document.getElementById("gameButton");
   gameButton.bgColor = "#000000";
   
   // initialize the base block with a random color
   baseR = Math.floor((colorArray.length)*Math.random())
   baseG = Math.floor((colorArray.length)*Math.random())
   baseB = Math.floor((colorArray.length)*Math.random())
   
   // initialize the play block
   playR = 0;
   playG = 0;
   playB = 0;
   
   var baseBlock = document.getElementById("gameBaseBlock");
   baseBlock.bgColor = "#" + colorArray[baseR] + colorArray[baseG] + colorArray[baseB];
   
   var playBlock = document.getElementById("gamePlayBlock");
   playBlock.bgColor = "#" + colorArray[playR] + colorArray[playG] + colorArray[playB];
   
   startedPlaying = 1;
}

function gamePlayBlockModify(color, direction)
{
   if(!document.getElementsByTagName)
   {
      return;
   }
   
   if(startedPlaying != 1)
   {
      return;
   }
   
   if(color==0 && direction==0)
   {
      // red plus
      var button = document.getElementById("redPlus");
      if(playR == colorArray.length-1)
      {
         button.bgColor="#000000";
      }
      else
      {
         button.bgColor="#FF8888";
      }
   }
   else if(color==1 && direction==0)
   {
      // green plus
      var button = document.getElementById("greenPlus");
      if(playG == colorArray.length-1)
      {
         button.bgColor="#000000";
      }
      else
      {
         button.bgColor="#88FF88";
      }
   }
   else if(color==2 && direction==0)
   {
      // blue plus
      var button = document.getElementById("bluePlus");
      if(playB == colorArray.length-1)
      {
         button.bgColor="#000000";
      }
      else
      {
         button.bgColor="#8888FF";
      }
   }
   else if(color==0 && direction==1)
   {
      // red minus
      var button = document.getElementById("redMinus");
      if(playR == 0)
      {
         button.bgColor="#000000";
      }
      else
      {
         button.bgColor="#FF8888";
      }
   }
   else if(color==1 && direction==1)
   {
      // green minus
      var button = document.getElementById("greenMinus");
      if(playG == 0)
      {
         button.bgColor="#000000";
      }
      else
      {
         button.bgColor="#88FF88";
      }
   }
   else if(color==2 && direction==1)
   {
      // blue minus
      var button = document.getElementById("blueMinus");
      if(playB == 0)
      {
         button.bgColor="#000000";
      }
      else
      {
         button.bgColor="#8888FF";
      }
   }
   
   setTimeout("doPlayBlockModify(" + color + "," + direction + ")", 100);
}

function doPlayBlockModify(color, direction)
{
   if(!document.getElementsByTagName)
   {
      return;
   }
   
   if(color==0 && direction==0)
   {
      // red plus
      var button = document.getElementById("redPlus");
      button.bgColor="#FF0000";
      playR++;
      if(playR >= colorArray.length)
      {
         playR = colorArray.length-1;
      }
   }
   else if(color==1 && direction==0)
   {
      // green plus
      var button = document.getElementById("greenPlus");
      button.bgColor="#00FF00";
      playG++;
      if(playG >= colorArray.length)
      {
         playG = colorArray.length-1;
      }
   }
   else if(color==2 && direction==0)
   {
      // blue plus
      var button = document.getElementById("bluePlus");
      button.bgColor="#0000FF";
      playB++;
      if(playB >= colorArray.length)
      {
         playB = colorArray.length-1;
      }
   }
   else if(color==0 && direction==1)
   {
      // red minus
      var button = document.getElementById("redMinus");
      button.bgColor="#FF0000";
      playR--;
      if(playR < 0)
      {
         playR = 0;
      }
   }
   else if(color==1 && direction==1)
   {
      // green minus
      var button = document.getElementById("greenMinus");
      button.bgColor="#00FF00";
      playG--;
      if(playG < 0)
      {
         playG = 0;
      }
   }
   else if(color==2 && direction==1)
   {
      // blue minus
      var button = document.getElementById("blueMinus");
      button.bgColor="#0000FF";
      playB--;
      if(playB < 0)
      {
         playB = 0;
      }
   }
   
   var playBlock = document.getElementById("gamePlayBlock");
   playBlock.bgColor = "#" + colorArray[playR] + colorArray[playG] + colorArray[playB];
   
   if(baseR == playR && baseG == playG && baseB == playB)
   {
      // game win!
      startedPlaying = 0;
      
      // make the game win block visible
      var gameWinBlock = document.getElementById("gameWinBlock");
      gameWinBlock.style.visibility = "visible";
   }
}



/////////////////////////////////////////
// functions to change the color theme
/////////////////////////////////////////
function changeColorTheme(color)
{
   // set the specified color in the cookie
   setCookie("pageColorTheme", color, 1000);
   
   if(!document.getElementsByTagName)
   {
      return;
   }
   
   // process the color scheme
   var table1 = document.getElementById("biography");
   var table2 = document.getElementById("education");
   var table3 = document.getElementById("research");
   var table4 = document.getElementById("publications");
   //var table5 = document.getElementById("internships");
   //var table6 = document.getElementById("courses");
   var table7 = document.getElementById("interests");
   var table8 = document.getElementById("question");
   var table9 = document.getElementById("extra");
   var tables = new Array(table1, table2, table3, table4, /*table5, table6,*/ table7, table8, table9);
   
   var placeholder = document.getElementById("placeholderTableCell");
   
   if(color==-1)
   {
      // white (default) color theme
      document.bgColor = "#FFFFFF";
      placeholder.bgColor = "#FFFFFF";
      changeTablesColor(tables, "#9999FF");
   }
   else if(color==0)
   {
      // blue (default) theme
      document.bgColor = "#CCFFFF";
      placeholder.bgColor = "#CCFFFF";
      changeTablesColor(tables, "#6699FF");
   }
   else if(color==1)
   {
      // red theme
      document.bgColor = "#FAAFBA";
      placeholder.bgColor = "#FAAFBA";
      changeTablesColor(tables, "#DD0000");
   }
   else if(color==2)
   {
      // green theme
      document.bgColor = "#CCFFCC";
      placeholder.bgColor = "#CCFFCC";
      changeTablesColor(tables, "#00CC00");
   }
   else if(color==3)
   {
      // yellow theme
      document.bgColor = "#FFFF99";
      placeholder.bgColor = "#FFFF99";
      changeTablesColor(tables, "#FFCC00");
   }
}

function changeTablesColor(tables, color)
{
   for(i = 0; i < tables.length; i++)
   {
      tables[i].bgColor = color;
   }
}



/////////////////////////////////////
// functions to process cookie stuff
/////////////////////////////////////

// code for processing cookies, taken from http://www.echoecho.com/jscookies02.htm

function getCookie(cookieName)
{
   if (document.cookie.length > 0)
   {
      // at least one cookie exists -- see if the specified one is present!
      begin = document.cookie.indexOf(cookieName + "=");
      if(begin != -1 &&
        (begin == 0 || document.cookie.charAt(begin-1) == ';' || (begin >= 2 && document.cookie.charAt(begin-2) == ';')))
      {
         // the specified cookie exists!  So return its value

         begin += cookieName.length+1;
         end = document.cookie.indexOf(";", begin);
         if (end==-1)
         {
            end = document.cookie.length;
         }
         
         // ensure the string is regular ASCII and not URL-encoded (e.g., %20's)
         return unescape(document.cookie.substring(begin, end));
      }
   }
   
   // at this point, the specified cookie was not set.  Return null to indicate this
   return null;
}

function setCookie(cookieName, cookieValue, expiredays)
{
   // Three variables are used to set the new cookie.
   // The name of the cookie, the value to be stored,
   // and finally the number of days until the cookie expires.

   var ExpireDate = new Date();
   ExpireDate.setTime(ExpireDate.getTime() + (expiredays * 24 * 3600 * 1000));

   // ensure that the value of the cookie is escaped to be URL-encoded
   document.cookie = cookieName + "=" + escape(cookieValue) +
   ((expiredays == null) ? "" : "; expires=" + ExpireDate.toGMTString());
}

function deleteCookie(cookieName)
{
   // The function simply checks to see if the cookie is set.
   // If so, the cookie is deleted by setting its expiration date to be in the past

   if (getCookie(cookieName))
   {
      document.cookie = cookieName + "=" + "; expires=Thu, 01-Jan-70 00:00:01 GMT";
   }
}


////////////////////////////////////////////
// functions to expand/collapse paragraphs
////////////////////////////////////////////

function activateCodeMessage(codeType)
{
   if(codeType == "pizza")
   {
      var block = document.getElementById("pizzaCode");
      block.style.display = "none";
      block = document.getElementById("pizzaConfirmed");
      block.style.display = "block";
   }
   else if(codeType == "cartoons")
   {
      var block = document.getElementById("cartoonsCode");
      block.style.display = "none";
      block = document.getElementById("cartoonsConfirmed");
      block.style.display = "block";
   }
   else if(codeType == "videoGames")
   {
      var block = document.getElementById("videoGamesCode");
      block.style.display = "none";
      block = document.getElementById("videoGamesConfirmed");
      block.style.display = "block";
   }
   else if(codeType == "disneyland")
   {
      var block = document.getElementById("disneylandCode");
      block.style.display = "none";
      block = document.getElementById("disneylandConfirmed");
      block.style.display = "block";
   }
   else if(codeType == "comics")
   {
      var block = document.getElementById("comicsCode");
      block.style.display = "none";
      block = document.getElementById("comicsConfirmed");
      block.style.display = "block";
   }
   else if(codeType == "movies")
   {
      var block = document.getElementById("moviesCode");
      block.style.display = "none";
      block = document.getElementById("moviesConfirmed");
      block.style.display = "block";
   }
   else if(codeType == "birds")
   {
      var block = document.getElementById("birdsCode");
      block.style.display = "none";
      block = document.getElementById("birdsConfirmed");
      block.style.display = "block";
   }
   else if(codeType == "rainyDays")
   {
      var block = document.getElementById("rainyDaysCode");
      block.style.display = "none";
      block = document.getElementById("rainyDaysConfirmed");
      block.style.display = "block";
   }
}


// this code adapted from http://www.webdeveloper.com/forum/showthread.php?t=77389

function toggleExpansion(typeOfExpansion)
{
	var condensed = document.getElementById(typeOfExpansion + "_condensed");
	if(!condensed) return;

	var expanded = document.getElementById(typeOfExpansion + "_expanded");
	if(!expanded) return;
	
	var link = document.getElementById(typeOfExpansion + "_expand_link");
	if(!link) return;
	
	if(condensed.style.display == "none")
	{
		condensed.style.display = "block";
		
		/*
		if(typeOfExpansion == "rsrch_int")
		{
		   link.innerHTML = "<b>view details</b>";
		   deleteCookie("expandResearchInterests");
		}
		else if(typeOfExpansion == "courses")
		{
		   link.innerHTML = "<b>view full list</b>";
		   deleteCookie("expandCourses");
		}
		*/
		if(typeOfExpansion == "other_stuff")
		{
		   link.innerHTML = "<b>view other stuff</b>";
		   deleteCookie("expandOtherStuff");
		}
	}
	else
	{
		condensed.style.display = "none";
	}
	
	if(expanded.style.display == "none")
	{
		expanded.style.display = "block";
		
		/*
		if(typeOfExpansion == "rsrch_int")
		{
		   link.innerHTML = "<b>hide details</b>";
		   setCookie("expandResearchInterests", 1, 1000);
		}
		else if(typeOfExpansion == "courses")
		{
		   link.innerHTML = "<b>view partial list</b>";
		   setCookie("expandCourses", 1, 1000);
		}
		*/
		if(typeOfExpansion == "other_stuff")
		{
		   link.innerHTML = "<b>hide other stuff</b>";
		   setCookie("expandOtherStuff", 1, 1000);
		}
	}
	else
	{
		expanded.style.display = "none";
	}

}


