function navMouseOver() {
	img = this.firstChild;
	src = img.src.split(".gif");
	newSrc = src[0]+"_on.gif";
	img.src = newSrc;
}

function navMouseOut() {
	img = this.firstChild;
	src = img.src.split("_on.gif");
	newSrc = src[0] +".gif";
	img.src = newSrc;
}

function registerSubnavRollovers() {
	element = document.getElementById('subnavigation');
	if (element) {
		ancs = element.getElementsByTagName("A");
		for (var i=0; i<ancs.length; i++) {
			if (ancs[i].firstChild.tagName && ancs[i].firstChild.tagName.toUpperCase() == "IMG") {
				if (ancs[i].className.indexOf("default") != -1) {
					ancs[i].onmouseover=navMouseOver;
					ancs[i].onmouseout=navMouseOut;
				}
			}

		}
	}
}

function registerResourceRollovers() {
	element = document.getElementById('resource-links');
	if (element) {
		ancs = element.getElementsByTagName("A");
		for (var i=0;i<ancs.length;i++) {
		
			ancs[i].onmouseover=navMouseOver;
			ancs[i].onmouseout=navMouseOut;
				
		}
	}
}

function EventUtils() {
	throw 'RuntimeException: EventUtils is a static utility class';
}

EventUtils.addEventListener = function(target,type,callback,captures) {
	if (target.addEventListener) {
		target.addEventListener(type,callback,captures);
	} else if (target.attachEvent) {
		target.attachEvent('on'+type,callback);
	} else {
		target['on'+type]=callback;
	}
}

EventUtils.hasClass = function(el,className) {
	var re = new RegExp('(?:^|\\s+)' + className + '(?:\\s+|$)');
//	return re.test(el['className']);
return false;
}

matchColumns=function(){ 

     var divs,contDivs,maxHeight,divHeight,d; 
     // get all <div> elements in the document 
     divs=document.getElementsByTagName('div'); 
     contDivs=[]; 
     // initialize maximum height value 
     maxHeight=0; 
     // iterate over all <div> elements in the document 
     for(var i=0;i<divs.length;i++){ 
          // make collection with <div> elements with class attribute 'container' 
          if(/\bcolumn\b/.test(divs[i].className)){ 
                d=divs[i]; 
                contDivs[contDivs.length]=d; 
                // determine height for <div> element 
                if(d.offsetHeight){ 
                     divHeight=d.offsetHeight; 					
                } 
                else if(d.style.pixelHeight){ 
                     divHeight=d.style.pixelHeight;					 
                } 
                // calculate maximum height 
                maxHeight=Math.max(maxHeight,divHeight); 
          } 
     } 
     // assign maximum height value to all of container <div> elements 
     for(var i=0;i<contDivs.length;i++){ 
          contDivs[i].style.height=maxHeight + "px"; 
     } 
}

function registerPhotoLinks() {
	var center=document.getElementById("center-column");
	if (center) {
		ancs = center.getElementsByTagName("A");
		for (var i=0; i<ancs.length; i++){
			if (ancs[i].className.indexOf("photo-link") != -1) {
				ancs[i].onclick=popUp;
				//EventUtils.addEventListener(ancs[i],'click',function() {return popUp();},true);
			}

		}
	}
}

function registerPopupLinks() {
	var col=document.getElementById("right-column");
	if (col) {
		ancs = col.getElementsByTagName("A");
		for (var i=0; i<ancs.length; i++){
			if (ancs[i].className.indexOf("popup-link") != -1) {
				ancs[i].onclick=popUp;
				//EventUtils.addEventListener(ancs[i],'click',function() {return popUp();},true);
			}
			

		}
	}
}

function registerPopups() {
	registerPhotoLinks();
	registerPopupLinks();
}


function popUp() {
	popUpWin = window.open(this.href,"popUp","scrolling=no,status=no,width=700,height=700,resizable=yes");
	popUpWin.focus();
	return false;
}

EventUtils.addEventListener(window,'load',registerResourceRollovers,true);
EventUtils.addEventListener(window,'load',registerSubnavRollovers,true);
EventUtils.addEventListener(window,'load',matchColumns,true);
EventUtils.addEventListener(window,'load',registerPopups,true);


function setMetaTagValue(name, value) {
   var found = 0;
   var metas = document.getElementsByTagName('meta');
   for (i = 0; i < metas.length; i++) {
     if (metas[i].getAttribute('name') == name) {
        metas[i].setAttribute('content',value);
        found = 1;
     }
   }

   if (found == 0) {
     var heads = document.getElementsByTagName('head');
     if (heads.length > 0) {
        var myMeta = document.createElement("meta");
        myMeta.setAttribute('name', name);
        myMeta.setAttribute('content',value);
        heads[0].appendChild(myMeta);
     }
   }
}

function getMetaTagValue(name) {
   var metas = document.getElementsByTagName('meta')
   for (i = 0; i < metas.length; i++) {
     if (metas[i].getAttribute('name') == name) {
        return metas[i].getAttribute('content');
     }
   }
}

