function poptastic(type, url) {
if (type == 'disclaimer'){
  newwindow=window.open(url,'disclaimer','height=500,width=500,left=100,top=100,resizable=yes,scrollbars=yes,toolbar=no,status=no');
} else if (type == 'bbbonline'){
  newwindow=window.open(url,'bbbonline','height=500,width=500,left=100,top=100,resizable=yes,scrollbars=yes,toolbar=no,status=no');
} else {
  newwindow=window.open(url,'customer','height=375,width=475,left=100,top=100,resizable=no,scrollbars=no,toolbar=no,status=no');
}
  if (window.focus) {newwindow.focus()}
}

   function checkForm()
    {
        var temp;
        var re;
        if (document.SLForm.first_name.value == '') {
            alert("First Name field is empty!");
            return false;
        } else if (checkrepeat(document.SLForm.first_name.value, 2)) {
            alert("First Name field contains repetitive characters.");
            return false;
        } else if (document.SLForm.first_name.value.search(/\d+/)!= -1) {
            alert("First Name may not contain any numbers.");
            return false;
        }

        if (document.SLForm.last_name.value == '') {
            alert("Last Name field is empty!");
            return false;
        } else if (checkrepeat(document.SLForm.last_name.value, 2)) {
            alert("Last Name field contains repetitive characters.");
            return false;
        } else if (document.SLForm.last_name.value.search(/\d+/)!= -1) {
            alert("Last Name may not contain any numbers.");
            return false;
        }

        if (document.SLForm.street_address.value == '') {
            alert("Mailing Address field is empty!");
            return false;
        }

        if (document.SLForm.city.value == '') {
            alert("City field is empty!");
            return false;
        } else if (checkrepeat(document.SLForm.city.value, 2)) {
            alert("City field contains repetitive characters.");
            return false;
        }

        if (document.SLForm.zip.value == '') {
            alert("Zip Code field is empty!");
            return false;
        } else {
            temp = document.SLForm.zip.value;
            if (temp.search(/^[0-9]+$/) == -1) {
                alert("Zip format is not correct!");
                return false;
            }
        }

        if (document.SLForm.email_address.value == '') {
            alert("Email field is empty!");
            return false;
        } else {
        	document.SLForm.email_address.value = trim(document.SLForm.email_address.value);
            temp = document.SLForm.email_address.value;
            if (temp.search(/^([0-9a-zA-Z]([-.\w]*[0-9a-zA-Z])*@([0-9a-zA-Z][-\w]*[0-9a-zA-Z]\.)+[a-zA-Z]{2,9})$/i) == -1) {
                alert("Email format is not correct!");
                return false;
            }
        }

        if (document.SLForm.home_phone1.value == ''
            || document.SLForm.home_phone2.value == ''
            || document.SLForm.home_phone3.value == '')
        {
            alert("Home Phone field is empty!");
            return false;
        } else {
            temp = document.SLForm.home_phone1.value;
            if (temp.search(/^[0-9]{3}$/) == -1) {
                alert("Home Phone format is not correct!");
                return false;
            }
            temp = document.SLForm.home_phone2.value;
            if (temp.search(/^[0-9]{3}$/) == -1) {
                alert("Home Phone format is not correct!");
                return false;
            }
            temp = document.SLForm.home_phone3.value;
            if (temp.search(/^[0-9]{4}$/) == -1) {
                alert("Home Phone format is not correct!");
                return false;
            }
            document.SLForm.home_phone.value = document.SLForm.home_phone1.value + document.SLForm.home_phone2.value + document.SLForm.home_phone3.value;
            if (checkrepeat(document.SLForm.home_phone.value, 5)) {
            	alert("Home Phone contains repetitive characters.");
            	return false;
            }
        }
				
				if (isValidDate(parseInt(document.SLForm.day.value,10),
						parseInt(document.SLForm.month.value,10)-1,
						parseInt(document.SLForm.year.value,10))) {
						document.SLForm.field_1.value = document.SLForm.year.value + '-' + document.SLForm.month.value + '-' + document.SLForm.day.value;
				} else {
					alert("The birthdate needs to be in MM/DD/YYYY format!");
return false;
				}
        if (document.SLForm.field_2.value == '') {
            alert("Last College Attended field is empty!");
            return false;
        }

        if (document.SLForm.ssn1.value == ''
            && document.SLForm.ssn2.value == ''
            && document.SLForm.ssn3.value == '')
        {
            alert("Social Security Number field is empty!");
            return false;
        } else {
            temp = document.SLForm.ssn1.value;
            if (temp.search(/^[0-9]{3}$/) == -1) {
                alert("Social Security Number format is not correct!");
                return false;
            }
            temp = document.SLForm.ssn2.value;
            if (temp.search(/^[0-9]{2}$/) == -1) {
                alert("Social Security Number format is not correct!");
                return false;
            }
            temp = document.SLForm.ssn3.value;
            if (temp.search(/^[0-9]{4}$/) == -1) {
                alert("Social Security Number format is not correct!");
                return false;
            }
            document.SLForm.field_3.value = document.SLForm.ssn1.value + document.SLForm.ssn2.value + document.SLForm.ssn3.value;
            if (checkrepeat(document.SLForm.field_3.value, 5)) {
            	alert("Social Security contains repetitive characters.");
            	return false;
            }
        }
        if (document.SLForm.include_in_market.checked) {
            document.SLForm.include_in_market.value = 'Y';
        }  
        
        document.SLForm.autofill.value = "yes";
        return true;
    }
		
    function isValidDate(day,month,year){
    /*
    Purpose: return true if the date is valid, false otherwise
    
    Arguments: day integer representing day of month
    month integer representing month of year
    year integer representing year
    
    Variables: dteDate - date object
    
    */
    var dteDate;
    
    //set up a Date object based on the day, month and year arguments
    //javascript months start at 0 (0-11 instead of 1-12)
    dteDate=new Date(year,month,day);
    
    /*
    Javascript Dates are a little too forgiving and will change the date to a reasonable guess if it's invalid. We'll use this to our advantage by creating the date object and then comparing it to the details we put it. If the Date object is different, then it must have been an invalid date to start with...
    */
    return ((day==dteDate.getDate()) && (month==dteDate.getMonth()) && (year==dteDate.getFullYear()));
    }
function move2next_2(fielda, fieldb) {
  if (fielda.value.length == 2)
		fieldb.focus();
}
function move2next_3(fielda, fieldb) {
  if (fielda.value.length == 3)
		fieldb.focus();
}
function trim(str) {
  return str.replace(/^\s+|\s+$/g,"");
}
function checkrepeat(str, n) {
	for (var i = 0; i < str.length; i++) {
	  var j = 0;
	  for (j; j < n; j++) {
	    if(!(str.charAt(i)==str.charAt(i+j+1))) 
	      break;
	  }
	  if (j == n) return true;
	}
	return false;
}