var hasIE_cookieName = "hasIE";
var hasIE_cookieValue = "1";
var hasIE_cookiePath = "/";
var hasIE_cookieDays = 7;
var oldBody = null;

// This function does the actual browser detection
function hasIE_hasIE() {
  var ua = navigator.userAgent.toLowerCase();
  return ((ua.indexOf('msie') != -1) && (ua.indexOf('opera') == -1) &&
          (ua.indexOf('webtv') == -1));
}

function hasIE_showOnlyLayer(whichLayer)
{
  if (document.getElementById)
    {
      var style2 = document.getElementById(whichLayer);
    }
  else if (document.all)
    {
      var style2 = document.all[whichLayer];
    }
  else if (document.layers)
    {
      var style2 = document.layers[whichLayer];
    }
  var body = document.getElementsByTagName('body');
  oldBody = body[0].innerHTML;
  body[0].innerHTML = style2.innerHTML;
}

function hasIE_hideOnlyLayer(whichLayer)
{
  var body = document.getElementsByTagName('body');
  body[0].innerHTML = oldBody;
}

// Hides and shows sections of the page based on whether or not it's
// running in IE
function hasIE_hideAndShow() {
  if (hasIE_hasIE() && hasIE_testCookies() && !hasIE_hasCookie()) {
    hasIE_showOnlyLayer("hasIE_level2");
  }
}

function hasIE_ContinueWithoutFF() {
  hasIE_setCookie(hasIE_cookieName);
  hasIE_hideOnlyLayer("hasIE_level2");
  return false;
}

function hasIE_hasCookie() {
  cookieValue = hasIE_getCookie(hasIE_cookieName);
  return (cookieValue == hasIE_cookieValue);
}

function hasIE_setCookie(cookieName) {
  var date = new Date();
  date.setTime(date.getTime() + (hasIE_cookieDays * 24 * 60 * 60 * 1000));
  expires = "; expires=" + date.toGMTString();

  document.cookie = cookieName + "=" + hasIE_cookieValue + expires + "; path=" + hasIE_cookiePath;
}

function hasIE_getCookie(cookieName) {
  var extendedName = cookieName + "=";

  var cookieRegExp = new RegExp("\\b" + cookieName + "=([^;]*)");
  var cookies = document.cookie;
  var cookieValue = cookieRegExp.exec(cookies);

  if (cookieValue) {
    cookieValue = unescape(cookieValue[1]);
  }

  return cookieValue;
}

function hasIE_testCookies() {
  cookieName = "hasIE_testCookies";

  hasIE_setCookie(cookieName);
  cookieValue = hasIE_getCookie(cookieName);

  return (cookieValue == hasIE_cookieValue);
}
