function GroupStepOne(form){
     if (form.group_business_type.value.length == 0) {
		alert("Please enter the business type.");
		return false;
	}
	if (form.deductible.value.length == 0) {
		alert("Please enter the desired deductible.");
		return false;
	}
	if (form.copay.value.length == 0) {
		alert("Please enter the desired copay.");
		return false;
	}
	if (form.number_of_employees.value.length == 0) {
		alert("Please enter the number of employees.");
		return false;
	}
	if (isNaN(parseInt(form.number_of_employees.value))) {
		alert("The number of employees contains illegal characters.");
		return false;
	}

	var coverages = "";
	for(var i=0; i<10; i++){
		var e = document.getElementById("coverage_type_item_"+i);
		if(e!=null && e.checked){
			if(coverages.length>0)
				coverages += ", ";
			coverages += e.value;
			form.coverage_type.value = coverages;
		}
	}

	return true;
}



function GroupStepTwo(form){

	form.redirect.value="http://www.quotefinancial.com/exit/thanks-group.jsp?address_1_zip="+form.address_1_zip.value+"&first_name="+form.first_name.value;
	if (form.first_name.value==""){
		alert("Please enter your first name.");
		return false;
	}
	if (form.last_name.value==""){
		alert("Please enter your last name.");
		return false;
	}
	if (form.group_company.value==""){
		alert("Please enter company name.");
		return false;
	}
	if (form.address_1_street1.value==""){
		alert("Please enter the address.");
		return false;
	}
	if (form.address_1_city.value==""){
		alert("Please select the city.");
		return false;
	}
	if (form.address_1_state.value==""){
		alert("Please select the state.");
		return false;
	}
	if (form.address_1_zip.value==""){
		alert("Please enter the zip code.");
		return false;
	}
	if (form.phone.value.length == 0) {
		alert("Please enter the phone number.");
		return false;
	}
	var stripped = form.phone.value.replace(/[\(\)\.\-\ ]/g, '');
        //strip out acceptable non-numeric characters
        if (isNaN(parseInt(stripped))) {
        alert("Please enter a valid Day Phone Number.");
        return false;
        }
        if (!(stripped.length == 10)) {
         alert("The Day Phone Number is the wrong length.\nMake sure you included an area code.\n");
         return false;
        }
    var stripped = form.phone2.value.replace(/[\(\)\.\-\ ]/g, '');
        //strip out acceptable non-numeric characters
        if (isNaN(parseInt(stripped))) {
        alert("Please enter a valid Evening Phone Number.");
        return false;
        }
        if (!(stripped.length == 10)) {
         alert("The Evening phone number is the wrong length.\nMake sure you included an area code.\n");
         return false;
        }
	if (!emailCheck(form.email.value)) {
		return false;
	}

	return true;
}

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("Email address seems incorrect (check @ and .'s)")
    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("The username of the email address doesn't seem to be valid.")
       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("Destination IP address is invalid!")
     return false
        }
       }
       return true
   }
   // Domain is symbolic name
   var domainArray=domain.match(domainPat)
   if (domainArray==null) {
    alert("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 must end in a three-letter domain, or two letter country.")
      return false
   }
   // Make sure there's a host name preceding the domain.
   if (len<2) {
      var errStr="This address is missing a hostname!"
      alert(errStr)
      return false
   }
   // If we've gotten this far, everything's valid!
   return true;
   }


function getElement(e)
{
	var temp;
	if (document.all && !document.getElementById) {  //IE4
		 temp = eval('document.all.' + e);
	}
	else if (document.layers) {  //NS4
		temp = eval('document.' + e);
	}
	else if (document.getElementById) {  //IE5 and NS6
		temp = document.getElementById(e);
	}
	return temp;
}

function makePopUp(whereTo, winWidth, winHeight) 
{
  remote = window.open("","remotewin","width="+winWidth+",height="+winHeight+",menubar=0,toolbar=no,scrollbars=yes");
  remote.location.href = whereTo; 
  remote.focus();
}