/*
function checkContact()
{
	var errors = "";
		
	if (document.forms["form-contact"]["contact-name"].value == "") {
		errors += "First Name(s)\n";
	}
	if (document.forms["form-contact"]["contact-lastname"].value == "") {
		errors += "Lastname\n";
	}
	
	if (!isValidEmail(document.forms["form-contact"]["contact-email"].value)) {
		errors += "Email\n";
	}
	if (document.forms["form-contact"]["contact-subject"].value == "") {
		errors += "Subject\n";
	}
	if (document.forms["form-contact"]["contact-message"].value == "") {
		errors += "Message\n";
	}
	if (errors == "") {
		document.forms["form-contact"].submit();
	} else {
		alert("Please review the following information:\n\n" + errors);
	}
	
}
*/
function checkUnsubscribe()
{
	var errors = "";
	
	if (!isValidEmail(document.forms["form-subscribe"]["member_email"].value)) {
		errors += "Email address\n";
	}
	if (errors == "") {
		document.forms["form-subscribe"].submit();
	} else {
		alert("Please review the following information:\n\n" + errors);
	}
	
}
function checkSubscribe()
{
	var errors = "";
		
	if (document.forms["form-subscribe"]["member_name"].value == "") {
		errors += "Name\n";
	}
	if (document.forms["form-subscribe"]["member_jobtitle"].value == "") {
		errors += "Job title\n";
	}
	if (document.forms["form-subscribe"]["member_company"].value == "") {
		errors += "Company\n";
	}
	if (!isValidEmail(document.forms["form-subscribe"]["member_email"].value)) {
		errors += "Email address\n";
	}
	if (errors == "") {
		document.forms["form-subscribe"].submit();
	} else {
		alert("Please review the following information:\n\n" + errors);
	}
	
}
function setTimerPage(page, delay) {
	setTimeout("location.href='" + page + "';", delay);
}

function changeAllCheckboxes(form,field) {
	if (document.forms[form][field].length) {
		for (i=0; i < document.forms[form][field].length; i++) {
			document.forms[form][field][i].checked = !document.forms[form][field][i].checked; 
		}
	} else {
		document.forms[form][field].checked = !document.forms[form][field].checked; 
	}
}

function popup(w,h,t,l,url,winName,status,toolBar,scrollBars,resizable) {
	if (scrollBars == undefined) scrollBars = "auto";
	if (resizable == undefined) resizable = "no";
  	var sWid = screen.width;
  	var sHi = screen.height;
	var wid = w;
	var hi = h;
	if ((t == 0) && (l == 0)) {
		var tp = (sHi/2)-(hi/2);
		var lft = (sWid/2)-(wid/2);
	} else {
		var tp = t;
		var lft = l;	
	}
	if (scroll && document.all && (navigator.userAgent.indexOf("Mac") > -1)) wid = wid+17;
	newwin=window.open(url,winName,"width=" + wid + ",height=" + hi + ",status=" + status + ",scrollbars=" + scrollBars + ",toolbar=" + toolBar + ",resizable=" + resizable + ", top = "+ tp +", left ="+ lft + ", screenX=" + lft +", screenY= "+tp);
	newwin.focus();
}

function isValidEmail(email) {
	var re = /^ *([a-z0-9_-]+\.)*[a-z0-9_-]+@(([a-z0-9-]+\.)+(com|net|org|mil|edu|gov|arpa|info|biz|inc|name|[a-z]{2})|[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}) *$/;
	return (re.test(email));
}

function isValidUsernamePassword(value) {
	re = /^\w+$/;
	return (re.test(value.toLowerCase()));
}

String.prototype.trim = function (){
	return this.replace(/(^\s+)/g, "").replace(/(\s+$)/g, "");
}