// Dean Edwards/Matthias Miller/John Resig

function init() {
	// quit if this function has already been called
	if (arguments.callee.done) return;

	// flag this function so we don't do the same thing twice
	arguments.callee.done = true;

	// kill the timer
	if (_timer) clearInterval(_timer);

	// do stuff
	prep();
};

/* for Mozilla/Opera9 */
if (document.addEventListener) {
	document.addEventListener("DOMContentLoaded", init, false);
}

/* DO NOT DELETE THIS BLOCK!!! */
/* for Internet Explorer */
/*@cc_on @*/
/*@if (@_win32)
	document.write("<script id=__ie_onload defer src=//:><\/script>");
	var script = document.getElementById("__ie_onload");
	script.onreadystatechange = function() {
		if (this.readyState == "complete") {
			init(); // call the onload handler
		}
	};
/*@end @*/

/* for Safari */
if (/WebKit/i.test(navigator.userAgent)) { // sniff
	var _timer = setInterval(function() {
		if (/loaded|complete/.test(document.readyState)) {
			init(); // call the onload handler
		}
	}, 10);
}

/* for other browsers */
window.onload = init;

function prep() {
	initializeFontSize();
	initPopupLinks();
}

function setCookie(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 = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function getCookie(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 eraseCookie(name) {
	setCookie(name,"",-1);
}

//sees if Alert cookie is set
function getCookieBool(cookieName)
{
  noAlert= getCookie(cookieName);
  if(noAlert!=null && noAlert=='true')
  {
	return true;
   }
   else
   {
     return false;
   }
}	


function getElementsByClassName(oElm, strTagName, strClassName){
    var arrElements = (strTagName == "*" && oElm.all)? oElm.all :
        oElm.getElementsByTagName(strTagName);
    var arrReturnElements = new Array();
    strClassName = strClassName.replace(/\-/g, "\\-");
    var oRegExp = new RegExp("(^|\\s)" + strClassName + "(\\s|$)");
    var oElement;
    for(var i=0; i<arrElements.length; i++){
        oElement = arrElements[i];     
        if(oRegExp.test(oElement.className)){
            arrReturnElements.push(oElement);
        }   
    }
    return (arrReturnElements)
}




function setFontSize(size) {
	var fontMax = 82.5;
	var fontMin = 42.5;
	var fontsize=document.body.style.fontSize;
	var currentTime = new Date();
	if(size == 'decrease') {
		if(fontsize) {
			fontsize=parseFloat(fontsize.replace("%","")) - 10;
			if (fontsize<fontMin) {
				fontsize=fontMin;
			}
		}
		else {
			fontsize=52.5;
		}
		document.body.style.fontSize = fontsize +"%";
	}
	else {
		if(fontsize) {
			fontsize=parseFloat(fontsize.replace("%","")) + 10;
			if (fontsize>fontMax) {
				fontsize=fontMax;
			}
		}
		else {
			fontsize=72.5;
		}
		document.body.style.fontSize = fontsize +"%";
	}
	setCookie('fontSize',fontsize,'');
}


function initializeFontSize() {
	var fontsize = getCookie('fontSize');
	if (fontsize) {
		document.body.style.fontSize = fontsize + "%";
	}
}





function initPopupLinks()
{
  if (!document.getElementsByTagName) return true;
  var pageLinks = document.getElementsByTagName("a");
  for (var i = 0; i < pageLinks.length; i++) 
  {
    if (((pageLinks[i].className != null) && 
         (pageLinks[i].className != "")) ||
        ((pageLinks[i].parentNode.className != null) && 
         (pageLinks[i].parentNode.className != "")))
    {
      var linkClass = " " + pageLinks[i].className + " ";
      if ((linkClass == "  ") && (pageLinks[i].parentNode.className != ""))
      {
        linkClass = " " + pageLinks[i].parentNode.className + " ";
      }
      for (var theKey in popupLinkConfig) 
      {
        if (linkClass.indexOf(" " + theKey + " ") > -1)
        {
          if ((pageLinks[i].target == "") || (pageLinks[i].target == null))
          {
            pageLinks[i].target = (popupLinkConfig[theKey][0] != "") ? popupLinkConfig[theKey][0] : theKey;
          }
          pageLinks[i].settings = popupLinkConfig[theKey][1];
          pageLinks[i].onclick = popUp;
        }
      }
    }
  }
  return true;
}

function popUp()
{
  newWin = window.open(this.href, this.target, this.settings);
  newWin.focus();
  return false;
}


var popupLinkConfig = new Array;
// Delete/copy/modify the following lines to configure your popup windows.
popupLinkConfig["popup"] = new Array ( "", "width=350,height=450,scrollbar=yes,menubar=no");





function initPressReleaseDivs()
{
	var ecArray = getElementsByClassName(document.getElementById('expandableContent'),'div','expandableContentNode');
	for(i=0;i<ecArray.length;i++)
	{
		var eclArray = getElementsByClassName(ecArray[i],'div','expandableContentLink');
		for(j=0;j<eclArray.length;j++)
		{
			var eclaArray = getElementsByClassName(eclArray[j],'a','active');
			for(k=0;k<eclaArray.length;k++)
			{
				if(eclaArray[k].className=='active')
				{
					eclaArray[k].className='';
				}
			}
		}
		var ecbArray = getElementsByClassName(ecArray[i],'div','expandableContentBody');
		for(l=0;l<ecbArray.length;l++)
		{
			if (ecbArray[l].style.display == 'block' || ecbArray[l].style.display == '')
			{
				ecbArray[l].style.display = 'none';
			}
		}
	}
}

function togglePressReleaseDiv(contentID,linkID)
{
	bodyNode = document.getElementById(contentID);
	linkNode = document.getElementById(linkID);
   if (bodyNode.style.display == 'block' || bodyNode.style.display == '')
   {
      bodyNode.style.display = 'none';
      linkNode.className=''
   }
   else
   {
      bodyNode.style.display = 'block';
      linkNode.className='active' 
   }
   return false;
}







function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      if (oldonload) {
        oldonload();
      }
      func();
    }
  }
}

function setNav(id)
{
	document.getElementById(id).className="active";
}
