var defaultFontSize = defaultSize;
var currentFontSize = defaultFontSize;
//Reset font size
function revertStyles(){
	currentFontSize = defaultFontSize;
	changeFontSize(0);
}
//Change font size 
function changeFontSize(sizeDifference){
	currentFontSize = parseInt(currentFontSize) + parseInt(sizeDifference * 5);

	if(currentFontSize > rf_max){
		currentFontSize = rf_max;
	}else if(currentFontSize < rf_min){
		currentFontSize = rf_min;
	}

	setFontSize(currentFontSize);
};
//Set font size
function setFontSize(fontSize){
	var stObj = (document.getElementById) ? document.getElementById('content_area') : document.all('content_area');
	document.body.style.fontSize = fontSize + '%';
};

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 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;
};

function addEvent_Font(elm, evType, fn, useCapture)   
{   
	if (elm.addEventListener){   
     elm.addEventListener(evType, fn, useCapture);   
     return true;   
   } else if (elm.attachEvent){   
     var r = elm.attachEvent("on"+evType, fn);   
     return r;   
   } else {   
     alert("Handler could not be removed");   
   }   
}

function setUserOptions(){
	if(rf_is_save_state){
		cookie = readCookie("fontSize");
		currentFontSize = cookie ? cookie : defaultFontSize;
		setFontSize(currentFontSize);
	}
}
addEvent_Font(window,"load",setUserOptions);

function saveSettings()
{
	createCookie("fontSize", currentFontSize, 365);
}
addEvent_Font(window,"unload",saveSettings);


