function addEvent( obj, type, fn )
{
	if (obj.addEventListener)
		obj.addEventListener( type, fn, false );
	else if (obj.attachEvent)
	{
		obj["e"+type+fn] = fn;
		obj[type+fn] = function() { obj["e"+type+fn]( window.event ); }
		obj.attachEvent( "on"+type, obj[type+fn] );
	}
}

function removeEvent( obj, type, fn )
{
	if (obj.removeEventListener)
		obj.removeEventListener( type, fn, false );
	else if (obj.detachEvent)
	{
		obj.detachEvent( "on"+type, obj[type+fn] );
		obj[type+fn] = null;
		obj["e"+type+fn] = null;
	}
}

addEvent(window, 'load', getLinks);


//Web Links Page
function viewLinks(e) {
	list = e.parentNode.parentNode;
	listElements = list.getElementsByTagName('dd');
	for(i = 0; i < listElements.length; i++) {
		if(listElements[i].style.display == "none")
			listElements[i].style.display = "block";
		else
			listElements[i].style.display = "none";
	}
	if(e.className.match("view"))
		e.className = "LinkCategory close";
	else if(e.className.match("close"))
		e.className = "LinkCategory view";
}


function getLinks() {
	if (document.getElementById('Links')) {
		var links = document.getElementById('Links').getElementsByTagName('a');
		for (var i = 0; i < links.length; i++) {
    		if (links[i].className.match("LinkCategory")) {
				// Attach function to onclick event
				links[i].className = "LinkCategory view";
				links[i].onclick = function() {
		        	viewLinks(this);
					return false;
      			}
			}
		}
		var answers = document.getElementById('Links').getElementsByTagName('dd');
		for(i=0; i<answers.length; i++) {
			answers[i].style.display = "none";
		}
	}
}

function collapseAllLinks() {
	if (document.getElementById) {
		var links = document.getElementsByTagName('a');
		for (var i = 0; i < links.length; i++) {
    		if (links[i].className.match("LinkCategory")) {
				links[i].className = "LinkCategory view";
				list = links[i].parentNode.parentNode;
				listElements = list.getElementsByTagName('dd');
				for(j = 0; j < listElements.length; j++)
					listElements[j].style.display = "none";
			}
		}
	}
}

function expandAllLinks() {
	if (document.getElementById) {
		var links = document.getElementsByTagName('a');
		for (var i = 0; i < links.length; i++) {
    		if (links[i].className.match("LinkCategory")) {
				links[i].className = "LinkCategory close";
				list = links[i].parentNode.parentNode;
				listElements = list.getElementsByTagName('dd');
				for(j = 0; j < listElements.length; j++)
					listElements[j].style.display = "block";
			}
		}
	}
}

//popup window for large images
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

//show pic/bio and set link classes on people page 
function showPic(whichpic) {
  document.getElementById('descbox').style.visibility= 'visible';
  var source = whichpic.getAttribute("href");
   var placeholder = document.getElementById("placeholder");
   
   if(source.substring(source.lastIndexOf('/')) != "/")
   {
    placeholder.style.display = "block";
    placeholder.setAttribute("src",source);
   }
   else
    placeholder.style.display = "none";
    
   var text = whichpic.getAttribute("test");
   var description = document.getElementById("description"); description.firstChild.nodeValue = text;

   if(description)
    if( typeof description.innerHTML!='undefined' )
     description.innerHTML=text;
    else 
     description.firstChild.nodeValue = text.replace(/<br>/ig,' ');
  }
  
  function clearSelectedLink()
{
    var elements = getElementsByClass('selected');
    
    for (var i=0; i < elements.length; i++)
            elements[i].className = '';
            
    return true;    
}

function setSelectedLink(link)
{
    link.className = 'selected';       
    return true;    
}

function getElementsByClass(searchClass,node,tag) {
	var classElements = new Array();
	if ( node == null )
		node = document;
	if ( tag == null )
		tag = '*';
	var els = node.getElementsByTagName(tag);
	var elsLen = els.length;
	var pattern = new RegExp('(^|\\s)'+searchClass+'(\\s|$)');
	for (i = 0, j = 0; i < elsLen; i++) {
		if ( pattern.test(els[i].className) ) {
			classElements[j] = els[i];
			j++;
		}
	}
	return classElements;
}

window.onload = function() {
	//P7_equalCols2(0,'lefthalf','DIV','righthalf','DIV');
	//P7_equalCols2(0,'content','DIV','sidebar','DIV');
	P7_equalCols2(0,'content','P','sidebar','P')
	stopLoadNotice();
}

function stopLoadNotice(){
	var loadingNotice = document.getElementById('loadingNotice');
	if(loadingNotice != null)
	{
		loadingNotice.style.display = 'none';
	}
}

/* 
  ------------------------------------------------
  PVII Equal CSS Columns scripts -Version 2
  Copyright (c) 2005 Project Seven Development
  www.projectseven.com
  Version: 2.1.0
  ------------------------------------------------
*/
function P7_colH2(){ //v2.1.0 by PVII-www.projectseven.com
 var i,oh,h=0,tg,el,np,dA=document.p7eqc,an=document.p7eqa;if(dA&&dA.length){
 for(i=1;i<dA.length;i+=2){dA[i+1].style.paddingBottom='';}for(i=1;i<dA.length;i+=2){
 oh=dA[i].offsetHeight;h=(oh>h)?oh:h;}for(i=1;i<dA.length;i+=2){oh=dA[i].offsetHeight;
 if(oh<h){np=h-oh;if(!an&&dA[0]==1){P7_eqA2(dA[i+1].id,0,np);}else{
 dA[i+1].style.paddingBottom=np+"px";}}}document.p7eqa=1;
 document.p7eqth=document.body.offsetHeight;
 document.p7eqtw=document.body.offsetWidth;}
}
function P7_eqT2(){ //v2.1.0 by PVII-www.projectseven.com
 if(document.p7eqth!=document.body.offsetHeight||document.p7eqtw!=document.body.offsetWidth){P7_colH2();}
}
function P7_equalCols2(){ //v2.1.0 by PVII-www.projectseven.com
 var c,e,el;if(document.getElementById){document.p7eqc=new Array();
 document.p7eqc[0]=arguments[0];for(i=1;i<arguments.length;i+=2){el=null;
 c=document.getElementById(arguments[i]);if(c){e=c.getElementsByTagName(arguments[i+1]);
 if(e){el=e[e.length-1];if(!el.id){el.id="p7eq"+i;}}}if(c&&el){
 document.p7eqc[document.p7eqc.length]=c;document.p7eqc[document.p7eqc.length]=el}}
 setInterval("P7_eqT2()",10);}
}
function P7_eqA2(el,p,pt){ //v2.1.0 by PVII-www.projectseven.com
 var sp=10,inc=20,g=document.getElementById(el);np=(p>=pt)?pt:p;
 g.style.paddingBottom=np+"px";if(np<pt){np+=inc;
 setTimeout("P7_eqA2('"+el+"',"+np+","+pt+")",sp);}
}
