// JavaScript Document
// LEVEL G, LLC - http://www.levelg.com

//PARSE ALL LINK TAGS FOR A, A+, or A++
function changeFontSize(title) {
  var i, a, main;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
	  if (a.getAttribute("title") == 'A' || a.getAttribute("title") == 'A+' || a.getAttribute("title") == 'A++') {
    		if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) {
     	 		a.disabled = true;
      			if(a.getAttribute("title") == title) {
					a.disabled = false;
					createCookie("style", title, 365);//sets cookie
				}
    		}
	  }
  }
}

//RETURN SHEET ENABLED
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 null;
}

//SET DEFAULT
function getPreferredStyleSheet() {
	return ('A');
}

//SET TEXT OPTION HIGHLIGHTS
function textOptionHighlight(title) {
	var tempClass;
	if(title=='A++') {
		tempClass = 'textOptions_large';
	} else if(title=='A+') {
		tempClass = 'textOptions_medium';	
	} else if(title=='A') {
		tempClass = 'textOptions_small';	
	}
	document.getElementById("textOptions_small").className = "textOptions_small";
	document.getElementById("textOptions_medium").className = "textOptions_medium";
	document.getElementById("textOptions_large").className = "textOptions_large";
	document.getElementById(tempClass).className = "textOption_hit";
	changeFontSize(title);
}

//INITIALIZE, READ COOKIE
function initTextOptions() {
	var cookie = readCookie("style");
	var title = cookie ? cookie : getPreferredStyleSheet();
	changeFontSize(title);
	textOptionHighlight(title);
}