/** JavaScript responsible for activating the appropriate stylesheet.** @last_modified 030816* @author alistapart.com (modified and commented by Paul Hitz)*//** Enable the specified stylesheet and disable all others (except the persistant stylesheet).*/function setActiveStyleSheet(title){  var i, a, main;  //Walk through every link tag in the page.  for(i = 0; (a = document.getElementsByTagName("link")[i]); i++)  {    //Check if the current link tag links to a stylesheet with a title (i.e. a preferred or alternate stylesheet).    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title"))    {      a.disabled = true;      //Enable the stylesheet if it is the one we are searching for.      if(a.getAttribute("title") == title)      {        a.disabled = false;      }    }  }  //Set the style in the cookie.  createCookie(title);}/** Gets the name of the current active stylesheet.*/function getActiveStyleSheet(){  var i, a;  for(i = 0; (a = document.getElementsByTagName("link")[i]); i++)  {    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title") && !a.disabled)    {      return a.getAttribute("title");    }  }  return null;}/** Return the title of the preferred stylesheet. * I.e. The stylesheet that should be used by default.*/function getPreferredStyleSheet(){  var i, a;  for(i = 0; (a = document.getElementsByTagName("link")[i]); i++)  {    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("rel").indexOf("alt") == -1 && a.getAttribute("title"))    {      return a.getAttribute("title");    }  }  return null;}/** Create a cookie containing the stylesheets to use. Lasts 5 years.*/function createCookie(style){  var date = new Date();  date.setTime(date.getTime() + (3600 * 24 * 365 * 5));  var expires = "expires="+date.toGMTString();  document.cookie = "fontsize=" + style +"; "+ 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;}/** Retrieve the cookie and enable the appropriate stylesheet.*/window.onload = function(e) {  var cookie = readCookie("fontsize");  var title = cookie ? cookie : getPreferredStyleSheet();  setActiveStyleSheet(title);}var cookie = readCookie("fontsize");var title = cookie ? cookie : getPreferredStyleSheet();setActiveStyleSheet(title);