/* betasights.net javascript functions 
	compiled by john archdeacon 2008/9
*/

function openBannerPop () {
var w = window.open("bannerPopup.html", "bannerPopup", "width=500, height=150, status=no, resizable=no, menubar=no, scrollbars=no, toolbar=no");
}
function closeBannerPop() {
w.close();
}
function check_sub() {
  var sub = "<?php echo $subscriber; ?>";
  if(sub != "y") {
    alert("Newsletters are for Members only. Please either Login or Register, above.");
    return false;
  }
}

function emailValidator(elem, helperMsg){
	var emailExp = /^[\w\-\.\+]+\@[a-zA-Z0-9\.\-]+\.[a-zA-z0-9]{2,4}$/;
	if(elem.value.match(emailExp)){
		return true;
	}else{
		alert(helperMsg);
		elem.focus();
		return false;
	}
}

function validate_form(thisform)
{
	with (thisform)
	{
	if (validate_email(email,"Not a valid e-mail address!")==false)
		{email.focus();return false;}
	if (validate_required(subtext,"Please enter some text!")==false)
	  {subtext.focus();return false;}
	}
}

function validate_email(field,alerttxt)
{
	with (field)
	{
	apos=value.indexOf("@");
	dotpos=value.lastIndexOf(".");
	if (apos<1||dotpos-apos<2) 
	  {alert(alerttxt);return false;}
	else {return true;}
	}
}
function validate_required(field,alerttxt)
{
	with (field)
	{
	if (value==null||value=="")
	  {alert(alerttxt);return false;}
	else {return true}
	}
}
