/*
	getElementsByClass - algorithm by Dustin Diaz, shortened by Pawel Knapik
*/
function getElementsByClass(s,n,t) {  // class, node, tag
	var c=[], e=(n?n:document).getElementsByTagName(t?t:'*'),r=new RegExp("(^|\\s)"+s+"(\\s|$)");
	for (var i=0,j=e.length;i<j;i++) r.test(e[i].className)?c.push(e[i]):''; return c }
	
/*
	$() based on prototype.js dollar function idea, optimized by Pawel Knapik.
*/
function $(){var r=[],a=arguments;for(var i=0,j=a.length;i<j;i++){(typeof a[i]=='string')?(r.push(document.getElementById(a[i]))):(r.push(a[i]))}
return(r.length==1)?r[0]:r}


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


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

// functions by jonathan gala: www.jongala.com

function isBlank(val) {
	if(val==null){return true;}
	var b = /\S/;
	var match = b.test(val);
	return !match;
}


function checkemail(email) {
	/* This RegExp requires an address of the form xxx@xxx.xxx where xxx is one or more alphanumeric characters.  The last xxx can't have any numbers.  */
	var address= /[a-zA-Z0-9._%-]+@[a-zA-Z0-9._%-]+\.[a-zA-Z]{2,4}/;
	var match = address.test(email);
	return match;
}

function checkphone(num) {
	/* This functionjust strips non-digits, and checks to see that there are at least 10 numbers left over */
	x = num.replace(/[\D]*/g,"");
	if (x.length<10) {
		return false;
	} else {
		return true;
	}
}


function msg(s,c) {	c?$('msgbox').innerHTML+= " -- " + s:$('msgbox').innerHTML=s;};



function IEHoverPseudo() {
	var navItems = document.getElementById("mainnav").getElementsByTagName("li");
	
	for (var i=0; i<navItems.length; i++) {
		if(navItems[i].className == "menuparent") {
			navItems[i].onmouseover=function() { this.className += " over"; }
			navItems[i].onmouseout=function() { this.className = "menuparent"; }
		}
	}

}
//window.onload = IEHoverPseudo;
addLoadEvent(IEHoverPseudo);