function echeck(str) {

	var at="@"
	var dot="."
	var lat=str.indexOf(at)
	var lstr=str.length
	var ldot=str.indexOf(dot)
	if (str.indexOf(at)==-1){
	   alert("Please enter a valid email address")
	   return false
	}

	if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
	   alert("Please enter a valid email address")
	   return false
	}

	if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		alert("Please enter a valid email address")
		return false
	}

	 if (str.indexOf(at,(lat+1))!=-1){
		alert("Please enter a valid email address")
		return false
	 }

	 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		alert("Please enter a valid email address")
		return false
	 }

	 if (str.indexOf(dot,(lat+2))==-1){
		alert("Please enter a valid email address")
		return false
	 }
	
	 if (str.indexOf(" ")!=-1){
		alert("Please enter a valid email address")
		return false
	 }

	 return true					
}

function validateEmail(theForm) {
	var emailID=theForm.elements['email']
	
	if ((emailID.value==null)||(emailID.value=="")){
		alert("Please enter a valid email address")
		emailID.focus()
		return false
	}
	if (echeck(emailID.value)==false){
		//emailID.value=""
		emailID.focus()
		return false
	}
	return true
}
 
 
function checkRegistration(theForm) {
	returnValue=true;
	
		if (theForm.elements['firstName'].value.length<1) {
			alert("Please enter your first name");
			theForm.elements['firstName'].focus();
			returnValue=false;
		}
		if (theForm.elements['lastName'].value.length<1) {
			alert("Please enter your last name");
			theForm.elements['lastName'].focus();
			returnValue=false;
		}
		/*if (theForm.elements['address'].value.length<1) {
			alert("Please enter your address");
			theForm.elements['address'].focus();
			returnValue=false;
		}
		if (theForm.elements['city'].value.length<1) {
			alert("Please enter your city");
			theForm.elements['city'].focus();
			returnValue=false;
		}
		if (theForm.elements['state'].value.length<1) {
			alert("Please enter your state");
			theForm.elements['state'].focus();
			returnValue=false;
		}
		if (theForm.elements['zip'].value.length<1) {
			alert("Please enter your zip code");
			theForm.elements['zip'].focus();
			returnValue=false;
		}*/
 		return validateEmail(document.forms[0]);
		return returnValue;
}

function checkFriend(theForm) {
	returnValue=true;
	
		if (theForm.elements['yourname'].value.length<1) {
			alert("Please enter your name");
			theForm.elements['yourname'].focus();
			returnValue=false;
		}
		if (theForm.elements['youremail'].value.length<1) {
			alert("Please enter your email address");
			theForm.elements['youremail'].focus();
			returnValue=false;
		}
		if (theForm.elements['friendname'].value.length<1) {
			alert("Please enter your friend's name");
			theForm.elements['friendname'].focus();
			returnValue=false;
		}
		if (theForm.elements['friendemail'].value.length<1) {
			alert("Please enter your friend's email address");
			theForm.elements['friendemail'].focus();
			returnValue=false;
		}
 		//return validateEmail(document.forms[0]);
		return returnValue;
}

function checkGmum(theForm) {
	returnValue=true;
	
		var chk = theForm.elements['level[]'];
		var oneischecked = false;
		for (i = 0; i < chk.length; i++) {
		   if (chk[i].checked) {
		       oneischecked = true;
		       break;
		   }
		}
		var chk2 = theForm.elements['howdo[]'];
		var oneischecked2 = false;
		for (i = 0; i < chk2.length; i++) {
		   if (chk2[i].checked) {
		       oneischecked2 = true;
		       break;
		   }
		}
	
		if (theForm.elements['firstname'].value.length<1) {
			alert("Please enter your first name");
			theForm.elements['firstname'].focus();
			returnValue=false;
		}
		else if (theForm.elements['lastname'].value.length<1) {
			alert("Please enter your last name");
			theForm.elements['lastname'].focus();
			returnValue=false;
		}
		else if (theForm.elements['email'].value.length<1) {
			alert("Please enter your email address");
			theForm.elements['email'].focus();
			returnValue=false;
		}
		else if (theForm.elements['phone'].value.length<1) {
			alert("Please enter your primary phone number");
			theForm.elements['phone'].focus();
			returnValue=false;
		}
		else if (theForm.elements['address'].value.length<1) {
			alert("Please enter your address");
			theForm.elements['address'].focus();
			returnValue=false;
		}
		else if (theForm.elements['city'].value.length<1) {
			alert("Please enter your city");
			theForm.elements['city'].focus();
			returnValue=false;
		}
		else if (theForm.elements['state'].value.length<1) {
			alert("Please enter your state");
			theForm.elements['state'].focus();
			returnValue=false;
		}
		else if (theForm.elements['zip'].value.length<5) {
			alert("Please enter your zip code");
			theForm.elements['zip'].focus();
			returnValue=false;
		}
		
		else if (!oneischecked) {
			alert("Please choose your level of gMum interest");
			returnValue=false;
		}
		else if (theForm.elements['child1_name'].value.length<1) {
			alert("Please enter your child's name");
			theForm.elements['child1_name'].focus();
			returnValue=false;
		}		
		else if ((theForm.elements['month'].value == '-1') || (theForm.elements['day'].value == '-1') || (theForm.elements['year'].value == '-1')) {
			alert("Please enter your child's date of birth");
			theForm.elements['month'].focus();
			returnValue=false;
		}
		
		else if (!oneischecked2) {
			alert("Please please let us know how you use gDiapers");
			returnValue=false;
		}
		return returnValue;
}

function checkGmumPromo(theForm) {
	returnValue=true;	
		if (theForm.elements['firstname'].value.length<1) {
			alert("Please enter your first name");
			theForm.elements['firstname'].focus();
			returnValue=false;
		}
		else if (theForm.elements['lastname'].value.length<1) {
			alert("Please enter your last name");
			theForm.elements['lastname'].focus();
			returnValue=false;
		}
		else if (theForm.elements['email'].value.length<1) {
			alert("Please enter your email address");
			theForm.elements['email'].focus();
			returnValue=false;
		}
		else if (!theForm.elements['accept'].checked) {
			alert("You must agree to the legal terms");
			returnValue=false;
		}
		return returnValue;
}

function jump(x) {
  location.href="/"+x+"";
}

//THESE ARE FUNCTIONS FOR THE MAPS POPUP ON THE STORE LOCATIONS PAGE. ADDED 09/18/06 EJH
function mapWin() {
		w = 590
		h = 600
		ztop = zleft = 0;
		if (screen) {
		zleft = (screen.width / 2) - (w / 2);
		ztop = (screen.height / 2) - (h / 2);
		}
		var strFeatures="toolbar=no,status=no,menubar=no,location=no";
		strFeatures=strFeatures+",scrollbars=yes,resizable=yes,";
		strFeatures=strFeatures+"height="+h+",width="+w+",top="+ztop+",left="+zleft;

		newWin = window.open("/maps/index.php","opening",strFeatures);

 		newWin.focus();
}

function validate()
{
    elem = document.getElementById('q');
    if(elem.value.replace(/^\s*|\s*$/g,"") == '')
    {
        alert('You must enter your address in the Address field');
        return false;
    }
    else
    {
        return true;
    }
}
//END MAPS