function getObject(id){
	return document.getElementById(id);
}

function isMozilla(){
	return(navigator.appName.indexOf("Netscape") != -1);
}

function isIE(){
	return(navigator.appName.indexOf("Internet Explorer") != -1);
}

function isMozilla4Plus(){
	if(!isMozilla()) return;
	var uAgent = navigator.userAgent;
	var vIndex = uAgent.indexOf("Firefox/");
	var v = uAgent.substring(vIndex);
	v = v.substring(v.lastIndexOf('/') + 1);
	v = v.substring(0, v.indexOf('.'));
	return(parseInt(v) > 3);
}

function fadeOut(e){
	fade(this.firstChild, true);
}

function fadeIn(e){
	fade(this.firstChild, false);
}

function fade (obj, out) {
	if(typeof(obj.style) == "undefined"){
		return;
	}
	if(typeof(obj.style.opacity) != "undefined"){
		obj.style.opacity = (out ? 0.5 : 1);
	}
	else{
		obj.style.filter = "alpha(opacity=" + (out ? "65" : "100") + ");";
	}

}

function addEvent(obj, whichevent, func){ 
	if (obj.addEventListener){ 
		obj.addEventListener(whichevent, function(e){obj[func](e);}, false);
	}
	else if(obj.attachEvent){ 
		obj.attachEvent("on" + whichevent, function(e){obj[func](e);});
	}
	else{ 
		var origFunc = obj["on" + whichevent];
		if ( origFunc ){
			obj["on" + whichevent] = function(e){origFunc(e);obj[func](e);};
		}
		else{
			obj["on" + whichevent] = obj[func];
		}
	} 
}

function setupEvents(containerId){ // containerId is the id of an object within which to look for links
	var thumbs = getObject(containerId);
	if(thumbs == null) return;
	
	var thumb_links = thumbs.getElementsByTagName("a");
	for(var i=0; i<thumb_links.length; i++){
		var obj = thumb_links[i];
		obj.onMouseOverFunc = fadeOut;
		addEvent(obj, "mouseover", "onMouseOverFunc");
		obj.onMouseOutFunc = fadeIn;
		addEvent(obj, "mouseout", "onMouseOutFunc");
	}
}
