//new member form validation
function isEmptyNM()
{
	if (document.memnew.fn.value == "" || document.memnew.fn.value ==null)
		{
		alert ("Please enter your first name.");
		document.memnew.fn.focus();
		return true;
		}
	if (document.memnew.ln.value == "" || document.memnew.ln.value ==null)
		{
		alert ("Please enter your last name.");
		document.memnew.ln.focus();
		return true;
		}
	if (document.memnew.email.value == "" || document.memnew.email.value ==null)
		{
		alert ("Please enter your email address.");
		document.memnew.email.focus();
		return true;
		}
	if (document.memnew.pw.value == "" || document.memnew.pw.value ==null)
		{
		alert ("Please enter your password.");
		document.memnew.pw.focus();
		return true;
		}
	if (document.memnew.pw2.value == "" || document.memnew.pw2.value ==null)
		{
		alert ("Please confirm your password.");
		document.memnew.pw2.focus();
		return true;
		}		
	if (document.memnew.pw2.value!=document.memnew.pw.value)
		{
		alert ("Your passwords do not match.");
		document.memnew.pw.focus();
		return true;
		}
	else
	{
	return false;
	}
}
//shipping address form validation
function isEmptySA()
{
	if (document.memnew.OFN.value == "" || document.memnew.OFN.value ==null)
		{
		alert ("Please enter the ship to first name.");
		document.memnew.OFN.focus();
		return true;
		}
	if (document.memnew.OLN.value == "" || document.memnew.OLN.value ==null)
		{
		alert ("Please enter  the ship to last name.");
		document.memnew.OLN.focus();
		return true;
		}
	if (document.memnew.OPP1.value == "" || document.memnew.OPP1.value ==null)
		{
		alert ("Please enter the ship to contact phone number area code.  We need this in case of an issue.");
		document.memnew.OPP1.focus();
		return true;
		}
	if (document.memnew.OPP2.value == "" || document.memnew.OPP2.value ==null)
		{
		alert ("Please enter the ship to contact phone number.  We need this in case of an issue.");
		document.memnew.OPP2.focus();
		return true;
		}
	if (document.memnew.OPP3.value == "" || document.memnew.OPP3.value ==null)
		{
		alert ("Please enter the ship to contact phone number.  We need this in case of an issue.");
		document.memnew.OPP3.focus();
		return true;
		}
	if (document.memnew.OSA1.value == "" || document.memnew.OSA1.value ==null)
		{
		alert ("Please enter the ship to address.");
		document.memnew.OSA1.focus();
		return true;
		}
	if (document.memnew.OSC.value == "" || document.memnew.OSC.value ==null)
		{
		alert ("Please enter the ship to city.");
		document.memnew.OSC.focus();
		return true;
		}
	if (document.memnew.OSZ.value == "" || document.memnew.OSZ.value ==null)
		{
		alert ("Please enter the ship to zip.");
		document.memnew.OSZ.focus();
		return true;
		}		
	else
	{
	return false;
	}
}


function isEmptyBA()
{
	if (document.memnew.NAME.value == "" || document.memnew.NAME.value ==null)
		{
		alert ("Please enter the billing name.");
		document.memnew.NAME.focus();
		return true;
		}
	if (document.memnew.ADDRESS.value == "" || document.memnew.ADDRESS.value ==null)
		{
		alert ("Please enter the billing address.");
		document.memnew.ADDRESS.focus();
		return true;
		}
	if (document.memnew.CITY.value == "" || document.memnew.CITY.value ==null)
		{
		alert ("Please enter the billing city.");
		document.memnew.CITY.focus();
		return true;
		}
	if (document.memnew.ZIP.value == "" || document.memnew.ZIP.value ==null)
		{
		alert ("Please enter the billing zip.");
		document.memnew.ZIP.focus();
		return true;
		}		
	else
	{
	return false;
	}
}


//make sure e-mail has an @ sign and a dot
function emailCheck() 
{
if 
(document.memnew.email.value.indexOf ('@',0) < 0 || document.memnew.email.value.indexOf ('.',0) < 0)
{
alert("Please enter a valid e-mail address.\nThe e-mail field requires an \"@\" and a \".\" be used.\n\nPlease re-enter your e-mail address.")
document.memnew.email.focus();
return true;
}
else
	{
	return false;
	}
}
//allow valid characters - error if character not in this list
function emailChars()
{
  var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzƒŠŒšœŸÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþ0123456789_-@.-";
	  var checkStr = document.memnew.email.value;
	  var allValid = true;
	  for (i = 0;  i < checkStr.length;  i++)
	  {
	    ch = checkStr.charAt(i);
	    for (j = 0;  j < checkOK.length;  j++)
	      if (ch == checkOK.charAt(j))
	        break;
	    if (j == checkOK.length)
	    {
	      allValid = false;
	      break;
	    }
	  }
	  if (!allValid)
	  {
	    alert("Please enter only letters, digits and \"@.-_\" characters in the \"email\" field.");
	    document.memnew.email.focus();
	    return true;
	  }
}
//check for strings of @. and .. - error if found
function moreEmail() 
{
if 
(document.memnew.email.value.indexOf ('@.',0) > 0 || document.memnew.email.value.indexOf ('..',0) > 0)
{
	alert("Please enter a valid e-mail address.")
	document.memnew.email.focus();
	return true;
}
else
	{
	return false;
	}
}
function checkEmail()
{
	var email = document.memnew.email.value
	if (email.length  > 1)
		{
			if (emailCheck() || emailChars() || moreEmail())
				{
					return true;
				}
			
			else
		{
		return false;
		}
	}
}


//Here is the batch form validation		
function validateNMForm()
{
		
	if (isEmptyNM())
		{
			return false;
		}
	if (checkEmail())
		{
			return false;
		}
	else
	{
	return true;
	}
}
		
function validateSAForm()
{
		
	if (isEmptySA())
		{
			return false;
		}
	else
	{
	return true;
	}
}
//validateBAForm		
function validateBAForm()
{
		
	if (isEmptyBA())
		{
			return false;
		}
	if (checkEmail())
		{
			return false;
		}
	else
	{
	return true;
	}
}
function upperMe(formname,formfield)
	{
		var field1 = eval( 'document.'+formname+'.'+formfield);
		s=field1.value.toUpperCase();
filteredValues = "^%_-|{}[]$&*()!,'<>?~`#";     // Characters stripped out
var i;
var returnString = "";
for (i = 0; i < s.length; i++) {  // Search through string and append to unfiltered values to returnString.
var c = s.charAt(i);
if (filteredValues.indexOf(c) == -1) returnString += c;
}
		field1.value= returnString;
}

function openBrWindow(theURL,winName,features) {
  window.open(theURL,winName,features);
  }
		
		function NewWindow(mypage, myname, w, h, scroll) {
var winl = (screen.width - w) / 2;
var wint = (screen.height - h) / 2;
winprops = 'height='+h+',width='+w+',top=0,left='+winl+',scrollbars='+scroll+',resizable'
win = window.open(mypage, myname, winprops)
if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
}
//
