//
// last updated Dec 5, 2005
//

//from http://www.dustindiaz.com/top-ten-javascript/

function addEvent(elm, evType, fn, useCapture)
{ 	// cross-browser event handling for IE5+, NS6+, 
	// and Mozilla/Gecko
	if(elm.addEventListener)
	{
		elm.addEventListener(evType, fn, useCapture);
		return true;
	} 
	else if (elm.attachEvent)
	{
		var r = elm.attachEvent('on' + evType, fn);
		return r;
	} else { elm['on' + evType] = fn; }
}

function cancelClick() {return false;}

function getElementsByClassName(node, classname)
{
    var a = [];
    var re = new RegExp('(^| )'+classname+'( |$)');
    var els = node.getElementsByTagName("*");
    for(var i=0,j=els.length; i<j; i++)
        if(re.test(els[i].className))a.push(els[i]);
    return a;
}



//a simple way to add events to trigger after the page has loaded. 
function addLoadEvent(func) {
	var oldonload = window.onload;
	if (typeof window.onload != 'function') {
		window.onload = func;
	}
	else {
		window.onload = function() {
			oldonload();
			func();
		}
	}
}
//Of course another method is to simply assign multiple event listeners to the window by using addEvent() as described in number 10 as follows:
//addEvent(window,'load',func1,false);
//addEvent(window,'load',func2,false);
//addEvent(window,'load',func3,false);



//basic functionality of showing and hiding.
function toggle(obj){
	var el = document.getElementById(obj);
	if ( el.style.display != 'none' ) {
		el.style.display = 'none';
	}
	else{
		el.style.display = '';
	}
}


// This function should work fairly well on relatively small lists of items. For a larger array, a binary search function may be more appropriate.
// usage element.inArray('search term')
Array.prototype.inArray = function (value)
// Returns true if the passed value is found in the
// array.  Returns false if it is not.
{
	var i;
	for (i=0; i < this.length; i++) {
		// Matches identical (===), not just similar (==).
		if (this[i] === value) {
			return true;
		}
	}
	return false;
};








/*
document.onload = document.onload; setTimeout("||fatLink||()", 1);
function fatLink()
{
	if (document.getElementById)
	{
		var currentPage = document.location;
		for(i=0 ; i<document.links.length ; i++)
		{
			if(document.links[i].href==||currentPage||)
			{
			document.links[i].style.fontWeight = 'bold';
			}
		}
	}
}
*/

