function addLoadEvent(func) {
	var oldonload = window.onload;
	if (typeof window.onload != 'function') {
		window.onload = func;
	} else {
		window.onload = function() {
			oldonload();
			func();
		}
	}
}

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 getChildrenByTagName(root_element, tag) {
  var kids = root_element.childNodes

  var kids_w_tag = new Array()
  
  for (var i=0; i<kids.length; i++)
    if (kids.item(i).tagName == tag.toUpperCase())
      kids_w_tag.push(kids.item(i))
      
  return kids_w_tag
}

var swapClass = "swapTitle";
function toggleSwapText() {
	var inputBoxes = getElementsByClass(swapClass,null,null);
	for (var i=0; i<inputBoxes.length; i++) {
		var inputBox = inputBoxes[i];
		inputBox.title = inputBox.value;
		inputBox.onfocus = function() {
			if (this.value == this.title) {
				this.value = "";
				this.className = this.className.replace(swapClass, "");
			}
		}
		inputBox.onblur = function() {
			if (this.value == "") {
				this.value = this.title;
				this.className += " " + swapClass;
			}
		}
	}
}
addLoadEvent(toggleSwapText);

function setupQuickLoc() {
	if (document.getElementById("quickloc")) {
		var inputBox = document.getElementById("quickloc").getElementsByTagName("input")[0];
		inputBox.onkeypress = function(evt) {
			var charCode = event.keyCode;
			if (this.value.length <= 5) {
				if (charCode <= 57 && charCode != 32) return true;
			} else {
				if (charCode <= 46) return true;
			}
			return false;
		}
	}
}
addLoadEvent(setupQuickLoc);

function MM_findObj(n, d) { //v4.01
var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
if(!x && d.getElementById) x=d.getElementById(n); return x;
}


