function swapStyle(that,style) {
	that.className=style;
}

var popUpWin=0;
function popUpWindow(URLStr, winWidth, winHeight) {
  if(popUpWin) {
    if(!popUpWin.closed) popUpWin.close();
  }
	winTop = ((screen.availHeight/2) - (winHeight/2)) - 25;
	winLeft = (screen.availWidth/2) - (winWidth/2);
  popUpWin = open(URLStr, 'popUpWin', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbar=no,resizable=no,copyhistory=no,width='+winWidth+',height='+winHeight+',left='+winLeft+', top='+winTop+',screenX='+winLeft+',screenY='+winTop+'');
}

function checkForm(that) {
	var errmsg = '';
	if (that.name.value.length < 1) {
		errmsg += '-> Enter your name\n';
	}
	if (that.email.value.length < 1) {
		errmsg += '-> Enter your e-mail address\n';
	}
	if (!isValidEmail(that.email.value)) {
		errmsg += '-> Enter a valid e-mail address\n';
	}
	if (that.comments.value.length < 1) {
		errmsg += '-> Enter a message\n';
	}
	if (errmsg > '') {
		alert('Oops...please go back and fix the following errors:\n\n'+errmsg);
		return false;
	} else {
		return true;
	}
}

function isValidEmail(address) {
	if (address != '' && address.search) {
		if (address.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1) {
	  	return true;
		} else {
			return false;
	  }
	} else {
		return true;
	}
}
