function getCookie(cookie_name)
{
  var alto_jscookie = document.cookie;
  var cookie_arr = alto_jscookie.split(";");
  for(var j=0; j < cookie_arr.length; j++) 
  {
    if(cookie_arr[j].split('=')[0] == cookie_name) // Cookie found
    {
      return unescape(cookie_arr[j].split('=')[1]);
    }
  }
  return false; // not found!
}




function getFontSizeCookie()
{
  if(getCookie('font_size'))
    return getCookie('font_size');
  else
    return false;
}

function setFontSizeCookie(size)
{
  size = Math.round(size * 100) /100;
  //set cookie date to one year
  var c_date = new Date();
  c_date = new Date(c_date.getTime() + 1000 * 3600 * 24 * 365);
  document.cookie = 'font_size=' + size +'; expires=' + c_date.toGMTString() + ';path=/';
}


function getCurrentFontSize()
{
  var cur_fsize = document.getElementById('content_container').style.fontSize;
  cur_fsize = cur_fsize.split("em")[0];
  cur_fsize = Math.round(cur_fsize * 100) /100;

  return cur_fsize;
}

function loadFontSize()
{
  if(getFontSizeCookie()!=false)
  {
    try
    {
      //alert(getFontSizeCookie());
      document.getElementById('content_container').style.fontSize = getFontSizeCookie() + 'em';
    }
    catch(e) {};
  }
}



function increaseFontSize(maximum_size)
{
  if(!isNaN(maximum_size) && parseFloat(getCurrentFontSize()) < maximum_size)
  {
    var newFontSize = parseFloat(getCurrentFontSize()) * 1.1;
    document.getElementById('content_container').style.fontSize = newFontSize + "em";
    setFontSizeCookie(newFontSize);
  }
}

function decreaseFontSize(minimum_size)
{
  if(!isNaN(minimum_size) && parseFloat(getCurrentFontSize()) > minimum_size)
  {
    var newFontSize = parseFloat(getCurrentFontSize()) / 1.1;
    document.getElementById('content_container').style.fontSize = newFontSize + "em";
    setFontSizeCookie(newFontSize);
  }
}

function standardFontSize(standardSize, mTyp)
{
  document.getElementById('content_container').style.fontSize = standardSize + 'em';
  setFontSizeCookie(standardSize);
}
