
		
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;
}

function externalLinks() { 
	if (!document.getElementsByTagName) return; 
	var anchors = document.getElementsByTagName("a"); 
	for (var i=0; i<anchors.length; i++) { 
		var anchor = anchors[i]; 
		if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "external") anchor.target = "_blank"; 
	} 
}

function addClass(theClass) {
	if (this.className != '') {
		this.className += ' ' + theClass;
	} else {
		this.className = theClass;
	}
}

function inArray(needle) {
	for (var i=0; i < this.length; i++) {
		if (this[i] === needle) {
			return i;
		}
	}
return false;
}

function footnoteLinks(containerID,targetID) {
	if (!document.getElementById || !document.getElementsByTagName || !document.createElement) return false;
	if (!document.getElementById(containerID) || !document.getElementById(targetID)) return false;
	var container = document.getElementById(containerID);
	var target = document.getElementById(targetID);
	var div = document.createElement('div');
	div.setAttribute("id",'footnotes'); 
	var h2 = document.createElement('h2');
	var h2_txt = document.createTextNode('Links');
	h2.appendChild(h2_txt);
	var coll = container.getElementsByTagName('*');
	var ol = document.createElement('ol');
	var myArr = [];
	var thisLink;
	var num = 1;
	for (var i=0; i<coll.length; i++) {
		var thisClass = coll[i].className;
		if ( (coll[i].getAttribute('href') || coll[i].getAttribute('cite')) && (thisClass == '' || thisClass.indexOf('ignore') == -1)) {
			thisLink = coll[i].getAttribute('href') ? coll[i].href : coll[i].cite;
			var note = document.createElement('sup');
			addClass.apply(note,['screen_hide']);
			var note_txt;
			var j = inArray.apply(myArr,[thisLink]);
			if ( j || j===0 ) {
				note_txt = document.createTextNode(j+1);
			} else {
				var li = document.createElement('li');
				var li_txt = document.createTextNode(thisLink);
				li.appendChild(li_txt);
				ol.appendChild(li);
				myArr.push(thisLink);
				note_txt = document.createTextNode(num);
				num++;
			}
			note.appendChild(note_txt);
			if (coll[i].tagName.toLowerCase() == 'blockquote') {
				var lastChild = lastChildContainingText.apply(coll[i]);
				lastChild.appendChild(note);
			} else {
				coll[i].parentNode.insertBefore(note, coll[i].nextSibling);
			}
		}
	}
	
	div.appendChild(h2);
	div.appendChild(ol);
	target.appendChild(div);
	
	addClass.apply(document.getElementsByTagName('html')[0],['noted']);
	return true;
}

numberFormat = function (number) {
	var minusPosition = new Number();
	var minus = new String();
	var decimal = new String();
	var whole = new String();
	var outputWhole = new String();
	var char = new String();	
	number = number.toString();
	minusPosition = number.indexOf('-');
	if (minusPosition!==-1) {
		minus = number.substr(minusPosition,minusPosition+1);
		number = number.substr(1,number.length);
	}
	
	if (number.length>0) {
		splitNumber = number.split('.');
		decimal = splitNumber[1];
		whole = splitNumber[0];
		for (i = 0; i < whole.length; i++) {
			char = whole.substr((whole.length)-(i+1),1);
			if (i%3==0 && i!=0) {
				outputWhole = ','+outputWhole;
			}
			outputWhole = char+outputWhole;
		}
		if (decimal) {
			if (decimal.length == 0) {
				decimal = '00';
			}
			if (decimal.length < 2) {
				decimal = decimal+'0';
			}
		} else {
			decimal = '00';
		}
		return minus+outputWhole+'.'+decimal;
	} else {
		return '0.00';
	}
	
}

function openWindow(winURL,winName,w,h,winSpecs) {
	popup = window.open(winURL, winName, "Width=" + w + ",Height=" + h + "," + winSpecs);
	var x = (screen.width-w)/2;
	var y = (screen.height-h)/2;
	popup.moveTo(x,y);
	popup.focus();
}