//  		CONTRAST
function contrast(num)
{
	var bloc1=document.getElementById('contrast_'+num);
	var bloc2=document.getElementById('normal_'+num);
	if(bloc1.style.display=='none')
	{
		bloc1.style.display='block';
		bloc2.style.display='none';
	}
	else
	{
		bloc2.style.display='block';
		bloc1.style.display='none';
	}
}
//			Read text
function readThisPage(url)
{
	readpage("http://wr.readspeaker.com/webreader/webreader.php?cid=f02dbbbce498fa70b21f26e5554e2480&amp;template=web_free&amp;title=readspeaker&amp;url"+escape('http://app.readspeaker.com/proreader/proreader.php?url='+url),1);
}
//  		FONT SIZE

var prefsLoaded = false;
var defaultFontSize =100;
var currentFontSize = defaultFontSize;

function revertStyles(){

	currentFontSize = defaultFontSize;
	changeFontSize(0);

}

function changeFontSize(sizeDifference){
	currentFontSize = parseInt(currentFontSize) + parseInt(sizeDifference * 5);

	if(currentFontSize > 220){
		currentFontSize = 220;
	}else if(currentFontSize < 60){
		currentFontSize = 60;
	}

	setFontSize(currentFontSize);
}

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 setUserOptions(){
	if(!prefsLoaded){

		cookie = readCookie("fontSize");
		currentFontSize = cookie ? cookie : defaultFontSize;
		setFontSize(currentFontSize);

		prefsLoaded = true;
	}

}
function saveSettings()
{
  createCookie("fontSize", currentFontSize, 365);
}

//  		TEXT ONLY

function textOnly(url)
{
	var result=window.open(url,"article", config='height=570, width=800, toolbar=no, menubar=no, scrollbars=no, resizable=yes, location=no, directories=no, status=no');
	if(result==false)
	{
		alert('There is a popup blocker');	
	}
}

//  		INIT

function initAccessibily()
{
	var css=document.createElement('link');
	css.setAttribute('href',document.getElementById('cssMakeMeAccessible').getAttribute('href'));
	css.setAttribute('rel','stylesheet');
	document.body.appendChild(css);
	setUserOptions();
}
window.addEventListener('load',initAccessibily,false);
window.addEventListener('unload',setUserOptions,false);

