/***************************
* Toggle font size functions 
*/


//Returns an array of child nodes from the passed in element that all have the passed in class name's (specific areas on page to affect only)

function getElementsByID(theNode, header, contentfooter, footer, newscontent, onlinepoll, paginate, contentwrapper) {

	var cArray = [];
	var cArrayLoc = 0;
		
	function doTree(theNode) {
		if (theNode.id == header || theNode.id == contentfooter || theNode.id == footer || theNode.id == newscontent || theNode.id == onlinepoll || theNode.id == paginate || theNode.id == contentwrapper) {
			  cArray[cArrayLoc] = theNode;
			  cArrayLoc++;
		}
		for (var i=0, len=theNode.childNodes.length; i<len; i++) {
			  doTree(theNode.childNodes[i]);
		}
	}
		
	doTree(theNode);
	return cArray;
}

//assume user is not already on large text
var fontSize = 0;
var fontTracker = new Array();
fontTracker [0] = [0, "1em"];
fontTracker [1] = [1, "1.10em"];
fontTracker [2] = [2, "1.20em"];


//Uses array to update all child nodes of element
function toggleFontSmall() {

	var fontSizeToggle = getElementsByID(document.getElementById("container"), "header", "content-footer", "footer", "newscontent", "online-poll", "paginate", "content-wrapper");
	
	if (!fontSizeToggle) {
		return;
	}

	if(fontSize > 0) {
		for (var i = 0; i < fontSizeToggle.length; i++) {
			fontSizeToggle[i].style.fontSize = fontTracker[fontSize-1][1];
		}
		fontSize = fontSize - 1;
	}
}


//Uses array to update all child nodes of element
function toggleFontLarge() {

	var fontSizeToggle = getElementsByID(document.getElementById("container"), "header", "content-footer", "footer", "newscontent", "online-poll", "paginate", "content-wrapper");
	
	if (!fontSizeToggle) {
		return;
	}

	if(fontSize < 8) {
		for (var i = 0; i < fontSizeToggle.length; i++) {
			fontSizeToggle[i].style.fontSize = fontTracker[fontSize+1][1];
		}
		fontSize = fontSize + 1;
	}
}






//Additional function for getting url variables into javascript
function getURLVar(urlVarName) {
   //divide the URL in half at the '?'
   var urlHalves = String(document.location).split('?');
   var urlVarValue = '';
   if(urlHalves[1]){
      //load all the name/value pairs into an array
      var urlVars = urlHalves[1].split('&');
      //loop over the list, and find the specified url variable
      for(i=0; i<=(urlVars.length); i++){
         if(urlVars[i]){
             //load the name/value pair into an array
           var urlVarPair = urlVars[i].split('=');
            if (urlVarPair[0] && urlVarPair[0] == urlVarName) {
               //I found a variable that matches, load it's value into the return variable
               urlVarValue = urlVarPair[1];
            }
         }
      }
   }
   var q = urlVarValue;
   q = q.substring(0,q.length);
   for(i=0; i<20; i++){
      q = q.replace(/%20/, " ");
      q = q.replace(/%E2%80%93/, "-");
   }
   return q;   
}




function popUp(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=650,height=670,left = 515,top = 190');");
}