// js.js (C) Jacek Kisyński - Vancouver, 2005-2007
//
// Provides functions:
//
// footer(color) - draws a footer with last modified etc.
// footer_start(color) - draws a footer (with last modified etc.) part before the counter
// footer_end() - draws a footer part after the counter
// menu(position, top) - draws menu
// link(name) - prints link to desired location

function footer(color){
  // <!-- vvvvvvvvvvvvvvv FOOTNOTE vvvvvvvvvvvvvvvvvvvv -->
  document.write('<tr><td class="footnote" align="right" height="20" colspan="2" style="background-color: ' + color + '">');
  document.write('&copy; ');
  if (Date.parse(document.lastModified) > 0){
    document.write('<a class="footnote" ' + "href='javascript:burn" + '("83 293 202 154 132 202 83 293 245 220 202 41 233 142 220 41 220 14",319,187)' + "'>Jacek Kisyński</a>&nbsp;&nbsp;" + document.lastModified);
  } else {
    document.write('<a class="footnote" ' + "href='javascript:burn" + '("83 293 202 154 132 202 83 293 245 220 202 41 233 142 220 41 220 14",319,187)' + "'>Jacek Kisyński</a>&nbsp;&nbsp;2008");
  }
  document.write('&nbsp;&nbsp;');
  document.write('</td></tr>');
  // <!-- ^^^^^^^^^^^^^^^ FOOTNOTE ^^^^^^^^^^^^^^^^^^^^ -->
}

function footer_start(color){
  // <!-- vvvvvvvvvvvvvvv FOOTNOTE vvvvvvvvvvvvvvvvvvvv -->
  document.write('<tr><td class="footnote" align="right" height="20" colspan="2" style="background-color: ' + color + '">');
  document.write('&copy; ');
  if (Date.parse(document.lastModified) > 0){
    document.write('<a class="footnote" ' + "href='javascript:burn" + '("83 293 202 154 132 202 83 293 245 220 202 41 233 142 220 41 220 14",319,187)' + "'>Jacek Kisyński</a>&nbsp;&nbsp;" + document.lastModified);
  } else {
    document.write('<a class="footnote" ' + "href='javascript:burn" + '("83 293 202 154 132 202 83 293 245 220 202 41 233 142 220 41 220 14",319,187)' + "'>Jacek Kisyński</a>&nbsp;&nbsp;2007");
  }
  document.write(',&nbsp;&nbsp;');
}

function footer_end(){
  document.write('visits since 08/08/2007&nbsp;&nbsp;');
  document.write('</td></tr>');
  // <!-- ^^^^^^^^^^^^^^^ FOOTNOTE ^^^^^^^^^^^^^^^^^^^^ -->
}

function menu(position, top) {
  // <!-- vvvvvvvvvvvvvvvv MENU vvvvvvvvvvvvvvvvvvvvvvv -->
  document.write('<table width="100%" height="100%" align="center" cellspacing ="4" cellpadding="4">');

  // MENU
  switch (position) {
    case "home page":
      menu_item("home page", "current", "");
      menu_item("research", "menu", "research.html");
      menu_item("teaching", "menu", "teaching.html");
      menu_item("personal", "menu", "personal.html");
      menu_item("links", "menu", "links.html");
      break;
    case "research":
      menu_item("home page", "menu", "index.html");
      menu_item("research", "current", "");
      menu_item("overview", "focus", "#overview");
      menu_item("publications", "focus", "#publications");
      menu_item("software", "focus", "#software");
      menu_item("teaching", "menu", "teaching.html");
      menu_item("personal", "menu", "personal.html");
      menu_item("links", "menu", "links.html");
      break;
    case "publication":
      menu_item("home page", "menu", "../../index.html");
      menu_item("research", "menu", "../../research.html");
      menu_item("overview", "submenu", "../../research.html#overview");
      menu_item("publications", "focus", "../../research.html#publications");
      menu_item("software", "submenu", "../../research.html#software");
      menu_item("teaching", "menu", "../../teaching.html");
      menu_item("personal", "menu", "../../personal.html");
      menu_item("links", "menu", "../../links.html");
      break;
    case "software":
      menu_item("home page", "menu", "../../index.html");
      menu_item("research", "menu", "../../research.html");
      menu_item("overview", "submenu", "../../research.html#overview");
      menu_item("publications", "submenu", "../../research.html#publications");
      menu_item("software", "focus", "../../research.html#software");
      menu_item("teaching", "menu", "../../teaching.html");
      menu_item("personal", "menu", "../../personal.html");
      menu_item("links", "menu", "../../links.html");
      break;
    case "teaching":
      menu_item("home page", "menu", "index.html");
      menu_item("research", "menu", "research.html");
      menu_item("teaching", "current", "teaching.html");
      menu_item("personal", "menu", "personal.html");
      menu_item("links", "menu", "links.html");
      break;
    case "personal":
      menu_item("home page", "menu", "index.html");
      menu_item("research", "menu", "research.html");
      menu_item("teaching", "menu", "teaching.html");
      menu_item("personal", "current", "");
      menu_item("formal", "focus", "#cv");      
      menu_item("informal", "focus", "#informal");
      menu_item("links", "menu", "links.html");
      break;
    case "links":
      menu_item("home page", "menu", "index.html");
      menu_item("research", "menu", "research.html");
      menu_item("teaching", "menu", "teaching.html");
      menu_item("personal", "menu", "personal.html");
      menu_item("links", "current", "");
      menu_item("people", "focus", "#people");
      menu_item("institutions", "focus", "#institutions");
      menu_item("AI conferences", "focus", "#conferences");
      break;
  }
  
  // FILLER
  document.write('<tr><td class="footnote" height="100%"></td></tr>');

  // TO THE TOP
  if (top == "true") {
    document.write('<tr><td class="menu" onclick="window.location.href=' + "'#top'" + '"onMouseOver="this.style.backgroundColor=' + "'AliceBlue';this.style.color='Blue';this.style.cursor='hand';" + '"onMouseOut="this.style.backgroundColor=' + "'White';this.style.color='Navy';" +'">&nbsp;back to the top</td></tr>');
  }
  document.write('</table>');
  // <!-- ^^^^^^^^^^^^^^^^ MENU ^^^^^^^^^^^^^^^^^^^^^^^ -->
}

function menu_item(name, state, address) {
  switch (state) {
    case "current":
      document.write('<tr><td class="current">&nbsp;' + name + '</td></tr>');
      break;
    case "menu":
      document.write('<tr><td class="menu" onclick="window.location.href=' + "'" + address + "'" + '"onMouseOver="this.style.backgroundColor=' + "'AliceBlue';this.style.color='Blue';this.style.cursor='hand';" + '"onMouseOut="this.style.backgroundColor=' + "'White';this.style.color='Navy';" + '">&nbsp;' + name + '</td></tr>');
      break;
    case "submenu":
      document.write('<tr><td class="menu" onclick="window.location.href=' + "'" + address + "'" + '"onMouseOver="this.style.backgroundColor=' + "'AliceBlue';this.style.color='Blue';this.style.cursor='hand';" + '"onMouseOut="this.style.backgroundColor=' + "'White';this.style.color='Navy';" + '">&nbsp;&nbsp;&nbsp;' + name + '</td></tr>');
      break;
    case "focus":
      document.write('<tr><td class="focus" onclick="window.location.href=' + "'" + address + "'" + '"onMouseOver="this.style.backgroundColor=' + "'AliceBlue';this.style.color='Blue';this.style.cursor='hand';" + '"onMouseOut="this.style.backgroundColor=' + "'LightSteelBlue';this.style.color='Navy';" + '">&nbsp;&nbsp;&nbsp;' + name + '</td></tr>');
      break;
  }
}

function link(name) {
  switch (name) {
    case "Peter_Carbonetto":
      document.write('<a class="main" href="http://www.cs.ubc.ca/~pcarbo" target="_top">Peter Carbonetto</a>');
      break;
    case "Giuseppe_Carenini":
      document.write('<a class="main" href="http://www.cs.ubc.ca/~carenini/" target="_top">Giuseppe Carenini</a>');
      break;
    case "Mike_Chiang":
      document.write('<a class="main" href="http://www.cs.ubc.ca/~mchc/" target="_top">Michael Chiang</a>');
      break;
    case "Cristina_Conati":
      document.write('<a class="main" href="http://www.cs.ubc.ca/~conati/" target="_top">Cristina Conati</a>');
      break;
    case "Nando_De_Freitas":
      document.write('<a class="main" href="http://www.cs.ubc.ca/~nando" target="_top">Nando de Freitas</a>');
      break;    
    case "Byron_Knoll":
      document.write('<a class="main" href="http://byronknoll.googlepages.com/" target="_top">Byron Knoll</a>');
      break;    
    case "Alan_Mackworth":
      document.write('<a class="main" href="http://www.cs.ubc.ca/~mack" target="_top">Alan Mackworth</a>');
      break;
    case "Jerzy_Mycka":
      document.write('<a class="main" href="http://hektor.umcs.lublin.pl/~jmycka/english.html" target="_top">Jerzy Mycka</a>');
      break;
    case "David_Poole":
      document.write('<a class="main" href="http://www.cs.ubc.ca/~poole" target="_top">David Poole</a>');
      break;
  }
}

