

  function loadLayout()
  {
    setBanner();
    setLayout();
    setColumnLayout();
    saveCookie();
  }
  
  
  function loadCookie()
  {
   // Try to load layout and columnLayout attributes from a cookie
    var cookies = document.cookie.split(';');
    for (var i = 0; i < cookies.length; i++)
    {
      // Get the cookie and trim leading whitespace
      var c = cookies[i];
      while (c.charAt(0) == ' ')
      {
        c = c.substring(1, c.length);
      }
      
      // Look for the variables
      if (c.indexOf("layout=") == 0)
      {
        layout = c.substring("layout=".length, c.length);
      }
      else if (c.indexOf("columnLayout=") == 0)
      {
        columnLayout = c.substring("columnLayout=".length, c.length);
      }
      else if (c.indexOf("bannerIndex=") == 0)
      {
        bannerIndex = c.substring(("bannerIndex=").length, c.length);
      }
    }
  }
  
  
  function saveCookie()
  {
    // Try and save layout and columnLayout attributes to a cookie
    var date = new Date();
    date.setTime(date.getTime() + (30*24*60*60*1000));
    var expires = "; expires=" + date.toGMTString();
    document.cookie = "layout="       + layout       + expires + "; path=/";
    document.cookie = "columnLayout=" + columnLayout + expires + "; path=/";
    document.cookie = "bannerIndex="  + bannerIndex  + expires + "; path=/";
  }
  
  
  function setBanner()
  {
    var newBanner = bannerDetails[bannerIndex];
    document.getElementById("bannerImage").src = "/resources/images/banners/" + site + "/" + newBanner[0];
    document.getElementById("bannerImage").alt = newBanner[2];
    document.getElementById("bannerCaption").innerHTML = "<a class=\"captionLink\" href=\"" + newBanner[1] + "\">" + newBanner[2] + "</a>";
  }
  
  
  function setLayout()
  {
    if (layout == 1)
    {
      document.getElementById("container").style.marginLeft = "auto";
      document.getElementById("container").style.marginRight = "auto";
      document.body.style.textAlign = "center";
    }
    else
    {
      document.getElementById("container").style.marginLeft = 0;
      document.getElementById("container").style.marginRight = 0;
      document.body.style.textAlign = "left";
    }
  }
  
  
  function setColumnLayout()
  {
    if (document.getElementById("columnContent"))
    {
      if (columnLayout == 1)
      {
        document.getElementById("columnContent").style.marginLeft = 0;
        document.getElementById("columnExtras").style.marginLeft  = 600;
      }
      else
      {
        document.getElementById("columnContent").style.marginLeft = 150;
        document.getElementById("columnExtras").style.marginLeft  = 0;
      }
    }
  }
  
  
  function changeBanner()
  {
    bannerIndex++;
    if (bannerIndex >= bannerLimit)
    {
      bannerIndex = 0;
    }
    setBanner();
    saveCookie();
  }
  
  
  function changeLayout()
  {
    if (layout == 1)
    {
      layout = 2;
    }
    else
    {
      layout = 1;
    }
    setLayout();
    saveCookie();
  }
  
  
  function changeColumnLayout()
  {
    if (columnLayout == 1)
    {
      columnLayout = 2;
    }
    else
    {
      columnLayout = 1;
    }
    setColumnLayout();
    saveCookie();
  }
  
  
  function setPseudoLinkOn(el_id, status_string)
  {
    document.getElementById(el_id).className = "pseudoLinkOn";
    window.status = status_string;
  }
  
  
  function setPseudoLinkOff(el_id)
  {
    document.getElementById(el_id).className = "pseudoLinkOff";
    window.status = "";
  }
  
  
