var email=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
var num=/^\d{1,3}$/
var url=/^(https?|ftp):\/\/.*\..+$/i
var empty=/.+/

function closeopen(i){
	if($(("info"+i+"_q")).style.fontWeight=="bold"){
		/* Closed*/
		$(("info"+i+"_q")).style.fontWeight="normal";
		$(("info"+i+"_l")).style.display="none";
		$(("info"+i+"_a")).style.display="block";
	}else{
		$(("info"+i+"_q")).style.fontWeight="bold";
		$(("info"+i+"_l")).style.display="inline-block";
		$(("info"+i+"_a")).style.display="none";
	}
	return false;
}
function closepopup(){
	self.close()
}
function popup(link,title){
	var width  = 728;
	var height = 468;
	var left   = (screen.width  - width)/2;
	var top    = (screen.height - height)/2;
	window.open(link,'',"menubar=no,width="+width+",height="+height+",top="+top+",left="+left+",toolbar=no");
}
function popup2(link,title){
	var width  = 748;
	var height = 568;
	var left   = (screen.width  - width)/2;
	var top    = 100;
	window.open(link,'',"menubar=no,width="+width+",height="+height+",top="+top+",left="+left+",scrollbars=yes");
}
function $(e){
	return document.getElementById(e)
}
function validate_contact(){
	var err=''
	if(!empty.test($("fname").value))
		err+="Enter your first name.\r\n"
	if(!empty.test($("lname").value))
		err+="Enter your last name.\r\n"
	if(!email.test($("email").value))
		err+="Enter a valid email address.\r\n"
	if(err!=''){
		alert(err)
		return false
	}
	return true
}
function validate_sponsor(){
	var err=''
	if(!empty.test($("orgname").value))
		err+="Enter your organizations name.\r\n"
	if(!empty.test($("rname").value))
		err+="Enter your representative name.\r\n"
	if(!empty.test($("pname").value))
		err+="Enter your position in the organization.\r\n"
	if(!email.test($("email").value))
		err+="Enter a valid email address.\r\n"
	if(!empty.test($("phone").value))
		err+="Enter your phone number.\r\n"
	if(err!=''){
		alert(err)
		return false
	}
	return true
}
sfHover = function() {
	var sfEls = document.getElementById("nav").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);

function init(){
	if(document.getElementsByTagName){
		var anchors=document.getElementsByTagName("a")
		for(var i=0;i<anchors.length;i++)
			if(anchors[i].getAttribute("rel")=="external")
				anchors[i].target="_blank";
	}
	var i;
	if($("frmcontact")){
		$("frmcontact").onsubmit=function(){
			return validate_contact()
		}
	}
	if($("frmjoin")){
		$("frmjoin").onsubmit=function(){
			return validate_contact()
		}
	}
	if($("frmsponsor")){
		$("frmsponsor").onsubmit=function(){
			return validate_sponsor()
		}
	}
	if($("frmspeaker")){
		$("frmspeaker").onsubmit=function(){
			return validate_sponsor()
		}
	}
}
window.onload=init
