var isIE = (navigator.appName == "Microsoft Internet Explorer") ? 1 : 0;// Tells us if the browser is Internet Explorer or something else

// This function determines the left Pixel setting of the main menu table.
function getLeft() {
  // The left setting of the table will be the width of the window minus half the width of the table
  // because the table is centered.

  var winWidth = document.body.clientWidth;
  var tableWidth = (isIE) ? document.getElementById("mainTable").offsetWidth : document.getElementById("mainTable").childNodes[1].offsetWidth;
  var leftPix = (winWidth/2) - (tableWidth/2);

  // We don't want the menu layer going off the page.
  // We use 1 instead of 0 because the table is always 1 pixel away from the edge if the
  // width of the window is smaller than the width of the table. This is due to the table border
  if(leftPix < 1) { leftPix = 1; }
  else { leftPix -= 4; } // I'm not sure why, be we need to subtract 4 pixels from the number to get the DIV in the right place.
  return leftPix;
}

//----------------------------------------------------------------------------------------------------------
// This function counts the number of words in a string
function countWords(str) {
  if(str == "") { return 0; }
  else {
    var tempArray = str.split(/\s+/g);
    return tempArray.length;
  }
}

//----------------------------------------------------------------------------------------------------------
//These functions deal with cookies  (used for displaying announcements on the conference pages)
function createCookie(name,value,days) {
  if(days) {
    var date = new Date();
    date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
    var expires = "; expires=" + date.toGMTString();
  } else var expires = "";

  document.cookie = name + "=" + value + expires + "; path=/";
}

function readCookie(name) {
  var nameEQ = name + "=";
  var ca = document.cookie.split(';');
  for(var i = 0; i < ca.length; i++) {
    var c = ca[i];
    while (c.charAt(0) == ' ') c = c.substring(1,c.length);
    if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
  }

  return null;
}

function eraseCookie(name) {
  createCookie(name,"",-1);
}
