// JavaScript Document for Newman's Own Pet Food
<!--
function confirmLink(theID)
{
	is_ok = confirm('Are you sure you want to delete this location?');
	if (is_ok) {
		self.location.href='edit_list.php?id='+ theID +'&rm=1'
		return true;
	} else {
		return  false;
	}
	 
}
function changeDropDown(theForm)
{
	x = theForm.options[theForm.selectedIndex].value;
	if (x != '') {self.location = 'store_list.php?state='+x;}
}
function MM_jumpMenu(targ,selObj,restore){ //v3.0
  	eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  	if (restore) selObj.selectedIndex=0;
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  	window.open(theURL,winName,features);
}

function emailCheck (emailStr) {
	
	var emailPat=/^(.+)@(.+)$/
	var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]"
	var validChars="\[^\\s" + specialChars + "\]"
	var quotedUser="(\"[^\"]*\")"
	var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/
	var atom=validChars + '+'
	var word="(" + atom + "|" + quotedUser + ")"
	var userPat=new RegExp("^" + word + "(\\." + word + ")*$")
	var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$")
	var matchArray=emailStr.match(emailPat)
	
	if (matchArray==null) {
		alert("We're sorry, but your E-mail address seems incorrect. (a common mistake is having @'s and .'s in the wrong place)")
		return false
	}
	
	var user=matchArray[1]
	var domain=matchArray[2]
	
	// See if "user" is valid 
	if (user.match(userPat)==null) {
		// user is not valid
		alert("We're sorry, but the username portion of your E-mail address seems incorrect. Please re-enter the email address.")
		return false
	}
	
	var IPArray=domain.match(ipDomainPat)
	if (IPArray!=null) {
		// this is an IP address
		  for (var i=1;i<=4;i++) {
			if (IPArray[i]>255) {
				alert("We're sorry, but the destination IP address in the Email address you supplied is invalid.  Please enter a new email destination IP or domain.")
			return false
			}
		}
		return true
	}
	
	var domainArray=domain.match(domainPat)
	if (domainArray==null) {
		alert("We're sorry, but your E-mail address seems incorrect. The domain name doesn't seem to be valid.")
		return false
	}
	
	var atomPat=new RegExp(atom,"g")
	var domArr=domain.match(atomPat)
	var len=domArr.length
	if (domArr[domArr.length-1].length<2 || 
		domArr[domArr.length-1].length>3) {
	   // the address must end in a two letter or three letter word.
	   alert("The email address you supply must end in a three-letter domain, or a two letter country abbreviation.")
	   return false
	}
	
	if (len<2) {
	   var errStr="We're sorry, but your E-mail address seems incorrect. The address is missing a hostname!"
	   alert(errStr)
	   return false
	}
	
	return true;
	
}

//-->