// JavaScript Document// script by Pony Smith :: pony_smith@yahoo.com// initialize universal variables for cookie scriptscookie_name = "fontSize";var index; var num;// create array of font sizes .. these percentages are applied to the <body> font-size// all other font sizes are declared in 'em' and are inherited from the bodyvar sizes = new Array('68%','72%','76%','84%','92%','100%','108%');// function to change the size of the text// called from increase/decrease font size buttons// takes one argument 'inc' which is either 1 or -1 and advances the pointer in the sizes arrayfunction textSize(inc) {	// take the original number 'num' which is passed from or declared in the getCookie() script (triggered onLoad)	add = '(' + num + ') + (' + inc + ')';	// add the 'num' and 'inc' strings and evaluate them to get an integer	var arr = eval(add);	// if the integer is below the array minimum or above its maximum, set 'arr' to the min or max respectively	if(arr < 0) {		arr = 0;	}	if(arr > 7) {		arr = 7;	}	// redefine 'num' as 'arr'	// ensures that the function can work again, since it won't refresh and trigger getCookie() with each click	num = arr;	// retrieve the appropriate number from the array and set the <body> font-size to that percentage	document.getElementById('body').style.fontSize = sizes[arr];	// run the setCookie() script to make sure that the current font-size is stored for other pages and future visits	setCookie(arr);}// set cookie function .. called from within textSize()function setCookie(arrNum) {	// this checks to see if the new number matches the old one	// if so, the function ends .. if not, it sets 'index = -1' which means that 'document.cookie.indexOf(cookie_name)' has a value of -1 .. ie. it doesn't exist.	if(document.cookie != document.cookie) {		index = document.cookie.indexOf(cookie_name);	}	else {		index = -1;	}	// if the cookie does not match the new number called from textSize(), overwrite the cookie with the new number	if(index == -1) {		document.cookie = cookie_name + "=" + arrNum + "; path=/"	}}// retrieve cookie function .. called in <body onLoad>function getCookie() {	var splits = document.cookie.split(';');	// run through the various cookie entries to find the font size cookie	for(i=0; i<splits.length; i++) {		index = document.cookie.indexOf(cookie_name);		// check to see if cookie exists .. as long as 'index' does not equal -1, the cookie exists.		if(index != -1) {			// retrieve only the number			num = splits[i].substring(splits[i].indexOf('=')+1, splits[i].length);			// pull the corresponding value from the sizes array and set the <body> font-size to that percentage			document.getElementById('body').style.fontSize = sizes[num];		} else {			// if there is no cookie present, set '2' as a default font size			num = '2';			document.getElementById('body').style.fontSize = sizes[num];		}	}}// function to deobfuscate the email strings into mailto: links// the email strings should take the form of [address] [at] [host] [dot] [ext]// pass the string as the parameter when the function is called .. also, add the string between <noscript> tags//function mung(address) {	splits = address.split(' ');	mail_str = '';	for(i=0; i<splits.length; i++) {		strip_left = splits[i].replace(/\[/, '');		strip_right = strip_left.replace(/\]/, '');		switch(strip_right) {			case "at": str = '@'; break;			case "dot": str = '.'; break;			default: str = strip_right;		}		mail_str += str;	}	link_str = '<a href="mailto:' + mail_str + '">' + mail_str + '</a> ';	document.write(link_str);}// --------------------------------------------- DYNAMIC DROP DOWN LISTS -------------------------------------------- //// // functions for dynamic <select> boxes// this function is called from within the html (make sure the original dropdown is loaded before calling)// sets the global variables and clones the master <select> list(s) for later usefunction initDynBox(sBoxId, dBoxId) {	// make sure the appropriate JS are available	if(document.getElementById && document.getElementsByTagName) {		// set global variables for the static <select> box and the dynamic <select> box		sBox = document.getElementById(sBoxId);		dBox = document.getElementById(dBoxId);		// clone the dynamic <select> box		clone = dBox.cloneNode(true);		// create an array of all the cloned <option> tags		optClones = clone.getElementsByTagName('option');		populate();	}}// called onchange() of the static <select> boxfunction populate(selAll) {	// recall the global variables .. global variables are assigned as properties of 'window'	sBox = window.sBox;	dBox = window.dBox;	optClones = window.optClones;	// remove all <options> from the dynamic <select> box	while(dBox.length > 0) {		dBox.remove(0);	}	// set variable for the value of the chosen static item	selUnit = sBox.value;	// set a variable for the matching "class" attribute .. (ie. subunits belonging to unit 1 should have class="js_unit1")	subClass = 'js_parent' + eval(selUnit);	// loop through all <option> tags in the clone array	for(i=0; i<optClones.length; i++) {		// check to see if the class matches the one defined above or if it labeled as class='default'		if(optClones[i].className == subClass || optClones[i].className == 'default') {			// if it matches, add it to the dynamic <select> box			dBox.appendChild(optClones[i].cloneNode(true));		}	}}