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 var expires = "";
  var cookieString = name+"="+value+";path=/;"+expires+";domain=.etbu.edu";
  //var cookieString = name+"="+value+";"+expires+";domain=.etbu.edu";
  document.cookie = cookieString;
  //console.log("Cookie Created : "+cookieString);
  
}
 
function readCookie(name) {
  var nameEQ = name + "=";
  //console.log(document.cookie);
  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 changeFontSize(newSize)
{
	
	var leftCol = document.getElementById('leftCol').style;
	var navCol  = document.getElementById('rightColumNavigation').style;
	var header  = document.getElementById('pageHead').style;
	var button1 = document.getElementById('fontSize1').style;
	var button2 = document.getElementById('fontSize2').style;
	var button3 = document.getElementById('fontSize3').style;
	var fancyNav;
	if(document.getElementById('fancyNav')!=null)
		fancyNav= document.getElementById('fancyNav').style;
	var currSize = leftCol.fontSize;
	var bgColor = '#e4e9f0';
	var highLightColor = '#ece3cb'

	
	leftCol.fontSize = newSize+'em';
	leftCol.lineHeight = 'normal';
	navCol.fontSize = newSize+'em';
	navCol.lineHeight = 'normal';
	header.fontSize = '22px';
	header.lineHeight = 'normal';
	
	if(document.getElementById('fancyNav')!=null)
		fancyNav.fontSize = '12px';
	
	switch(newSize)
	{
		case 1:
		case '1.1':
		default:
			button1.backgroundColor = highLightColor;
			button2.backgroundColor = bgColor;
			button3.backgroundColor = bgColor;
		break;
		case 1.5:
		case '1.5':
			button1.backgroundColor = bgColor;
			button2.backgroundColor = highLightColor;
			button3.backgroundColor = bgColor;
		break;
		case 2:
		case '2':
			button1.backgroundColor = bgColor;
			button2.backgroundColor = bgColor;
			button3.backgroundColor = highLightColor;
		break;
		
	}
	
	createCookie("fontSize", newSize, 365);
	readCookie("fontSize");
	
}


function initFontSize()
{
	//alert('ready');
	if(storedSize = readCookie("fontSize"))
		changeFontSize(storedSize);
}

