function toggleStyle(newStyle) {
    //active = getActiveStyleSheet();

    switch (newStyle) {
    case 'med_text' : 
      setActiveStyleSheet('med_text');
      changeFontColor('med_text','sm_text','lrg_text');
      break;
    case 'lrg_text' : 
      setActiveStyleSheet('lrg_text');
      changeFontColor('lrg_text','med_text','sm_text');
      break;
    case 'sm_text':
        setActiveStyleSheet('sm_text');
        changeFontColor('sm_text','med_text','lrg_text');
        break;
    default:
         setActiveStyleSheet('sm_text');
         changeFontColor('sm_text','med_text','lrg_text');
         break;
  }
}

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 expires = "";
  document.cookie = name+"="+value+expires+"; path=/";
 
}

function changeFontColor(curAct, notAct1, notAct2){
    document.getElementById(curAct).className = "disabled";
    document.getElementById(notAct1).className = "";
    document.getElementById(notAct2).className = "";
}

function setActiveStyleSheet(title) {
  var i, a, main;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) {
a.disabled = true;
       if(a.getAttribute("title") == title) a.disabled = false; 
    }
  }
}

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 'sm_text';
}


function getPreferredStyleSheet() {
  return ('sm_text');
}

function textstyleLoad() {
  var cookie = Cookie.get("textstyle");
  var title = cookie ? cookie : getPreferredStyleSheet();

  setActiveStyleSheet(title);
  var theElem = document.getElementById(title);
  if(theElem)
      theElem.className = "disabled";  
}

function textstyleUnload() {
  var title = getActiveStyleSheet();
  createCookie('textstyle',title,365);
}

   
Event.observe(window, 'load', textstyleLoad);
Event.observe(window, 'unload', textstyleUnload);