function reset_submit(){
	var form = document.form1;
	form.submitted.value = false;
}

function CheckForm(){

	//setCookie("oreo",1,1);
	var form = document.form1;
	
	// Check for multiple submits
	if (form.submitted.value == "true")
	{
		alert("Your submission is being processed. Please wait a moment for confirmation ...");
		pageTracker._trackPageview('/fortis-pest-control/waiting-for-server-response');
		return false;
	}
	
	
	if(Step1()) {
		if(Step2()) {
			//if(Step3()) { 
				form.submitted.value = true; 
				alert('just about to submit!');
				//formSubmitter('pass');
				return true; 
			} else { 
				return false; 
			//}
		}
 	}

	return false; 
}

function Step1() {
	var form = document.form1;
	//if(!checkSelect(form.elements["destination"],"a destination.")) { ShowStep('destination'); return false; }
	//if(!checkSelect(form.elements["session"],"a session.")) { ShowStep('session'); return false; }
return true; } 


function StepX() {
	var form = document.form1;
	var regexp = /[A-Z]{2,}/gi;
	if(document.getElementById('Step1').style.display == 'block') { document.getElementById('Step1').style.display = 'none'; document.getElementById('Step2').style.display = 'block'; return false; }
	if(!checkSelect(form.elements["highesteducation"],"year in school.")) { ShowStep('highesteducation'); return false; }
	if(!checkSelect(form.elements["state_of_institution"],"the state where you attend(ed) college.")) { ShowStep('state_of_institution'); return false; }
	if(!checkSelectDataMark(form.elements["institution"],"the institution you attend(ed).")) { ShowStep('institution'); return false; }	
	if(!checkSelect(form.elements["grade_point_average"],"your GPA.")) { ShowStep('grade_point_average'); return false; }
	pageTracker._trackPageview('/fortis-pest-control/step2-fortis');
return true;
}

function Step2() {
	var form = document.form1;
	if(document.getElementById('Step1').style.display == 'block') { document.getElementById('Step1').style.display = 'none'; document.getElementById('Step2').style.display = 'block'; return false; }

	// first_name
	var regexp = /[A-Z]{2,}/gi;
	if (form.first_name.value.search(regexp) == -1)
	{
		ShowStep('first_name');
		alert('Your first name must contain at least 2 characters.');
		pageTracker._trackPageview('/fortis-pest-control/step2/error/first-name-too-short');
		form.first_name.focus();
		return false;
	}

	var regexp = /[0-9\$\%\^\&\*\!\@\#\(\)\{\}\[\]\\\|\/\?\<\>\,\:\;\+\=\"]+/gi;
	if (form.first_name.value.search(regexp) != -1)
	{
		alert('Your first name must contain only characters.');
		pageTracker._trackPageview('/fortis-pest-control/step2/error/first-name-only-chars');
		ShowStep('first_name');
		form.first_name.focus();
		return false;
	}

	// last_name
	/*var regexp = /[A-Z]{2,}/gi;
	if (form.last_name.value.search(regexp) == -1)
	{
		alert('Your last name must contain at least 2 characters.');
		pageTracker._trackPageview('/fortis-pest-control/step2/error/last-name-too-short');
		ShowStep('last_name');
		form.last_name.focus();
		return false;
	}

	var regexp = /[0-9\$\%\^\&\*\!\@\#\(\)\{\}\[\]\\\|\/\?\<\>\,\:\;\+\=\"]+/gi;
	if (form.last_name.value.search(regexp) != -1)
	{
		alert('Your last name must contain only characters.');
		pageTracker._trackPageview('/fortis-pest-control/step2/error/last-name-only-chars');
		ShowStep('last_name');
		form.last_name.focus();
		return false;
	} */
	

/*	
	// Address validation
	if (form.address.value.length < 6)
	{
		alert("Your address must contain at least 6 characters.");
		pageTracker._trackPageview('/fortis-pest-control/step2/error/address-too-short');
		form.address.focus();
		return false;
	}

	var regexp = /\d+/gi;
	if (form.address.value.search(regexp) == -1)
	{
		alert('Your address must contain characters and numbers.');
		pageTracker._trackPageview('/fortis-pest-control/step2/error/address-chars-and-nums');
		form.address.focus();
		return false;
	}

	//var regexp = /[A-Z#,. -]+/gi;
	var regexp = /[A-Z]+/gi;
	if (form.address.value.search(regexp) == -1)
	{
		alert('Your address must contain characters and numbers.');
		pageTracker._trackPageview('/fortis-pest-control/step2/error/address-chars-and-nums');
		form.address.focus();
		return false;
	}
*/
	
	
/* var regexp = /[0-9\$\%\^\&\*\!\@\#\(\)\{\}\[\]\\\|\/\?\<\>\,\:\;\+\=\"]+/gi;
	if (form.city.value.search(regexp) != -1) {
		alert("Your city can only contain letters.");
		ShowStep('city');
		form.city.focus();
		return false;
	}
*/


var regexp = /[A-Z]{2,}/gi;
	if (form.city.value.search(regexp) == -1)
	{
		alert('Please provide a city so we can be sure that we\'re able to service your neighborhood.');
		ShowStep('city');
		form.city.focus();
		return false;
	}
	
if(!checkEmpty(form.elements["city"],"city"))return false;



// state
/* EGGERS -- Country validation not required for Fortis. 
var country = form.country.value;

var valid_usa = new Array("USA","usa","US","us","United States","United States of America","220","511", "1453");
var valid_can = new Array("CAN","can","CA","ca","Canada","341", "CANADA", "1454");
var valid_uk = new Array("UK","United Kingdom");
var valid_other = new Array("Other");

Array.prototype.indexOf=function(n){for(var i=0;i<this.length;i++){if(this[i]===n){return i;}}return -1;}

if (valid_usa.indexOf(country) != -1) {
	if(!checkSelect(form.elements["state"],"a state.")) { ShowStep('state'); return false; }
}
if (valid_can.indexOf(country) != -1) {
	if(!checkSelect(form.elements["state"],"a province.")) { ShowStep('state'); return false; }
}
if (valid_uk.indexOf(country) != -1) {
	if(!checkSelect(form.elements["UKcounty"],"a county.")) { ShowStep('state'); return false; }
}
if (valid_other.indexOf(country) != -1) {
	if(!checkSelect(form.elements["other"],"a province/county.")) { ShowStep('state'); return false; }
}
*/

function replaceAll(str,from,to) {
    var idx = str.indexOf(from);
    while (idx > -1) {
        str = str.replace(from,to); 
        idx = str.indexOf(from);
    }
    return str;
}

function checkZipForm(str) { //check usa zipcode format
	if('0123456789'.indexOf(str.charAt(0))<0) {return false;}
	if('0123456789'.indexOf(str.charAt(1))<0) {return false;}
	if('0123456789'.indexOf(str.charAt(2))<0) {return false;}
	if('0123456789'.indexOf(str.charAt(3))<0) {return false;}
	if('0123456789'.indexOf(str.charAt(4))<0) {return false;}	
	return true;	
}
function checkPostalForm(str) { //check can postalcode format
	//Letters and numbers alternate
	//Certain letters never occur(I AND O)
	//The first character is even more restricted as it designates region. Regions are(from east to west, then north): A,B,C,E,G,H,J,K,L,M,N,P,R,S,T,V,X,Y 
	if('ABCEGHJKLMNPRSTVXY'.indexOf(str.charAt(0))<0) {return false;}
	if('0123456789'.indexOf(str.charAt(1))<0) {return false;}
	if('ABCDEFGHJKLMNPQRSTUVWXYZ'.indexOf(str.charAt(2))<0) {return false;}
	if('0123456789'.indexOf(str.charAt(3))<0) {return false;}
	if('ABCDEFGHJKLMNPQRSTUVWXYZ'.indexOf(str.charAt(4))<0) {return false;}
	if('0123456789'.indexOf(str.charAt(5))<0) {return false;}
	return true;	
}


/* EGGERS -- no country or zip validation needed for Fortis.
var zip = form.zip; //zip
var zip_value = zip.value; //code value
var country = form.country.value;

var valid_usa = new Array("USA","usa","U.S.A","US","us","United States","United States of America","220","511");
var valid_can = new Array("CAN","can","CA","ca","Canada","341", "CANADA");


Array.prototype.indexOf=function(n){for(var i=0;i<this.length;i++){if(this[i]===n){return i;}}return -1;}

zip_value = replaceAll(zip_value," ","");
zip_value = replaceAll(zip_value,"-","");
zip_value = zip_value.toUpperCase();



if (valid_usa.indexOf(country) != -1 || valid_can.indexOf(country) != -1) { //code check for USA and CAN
	
	if ((zip_value.length < 5) || (zip_value.length > 6)) {		
		alert('Please enter a valid ZIP or Postal Code.');
		pageTracker._trackPageview('/fortis-pest-control/step2/error/zip');
		ShowStep('zip');
		zip.focus();
		return false;
	} else {
		if (zip_value.length == 5) { // usa zipcode
			if (valid_usa.indexOf(country) != -1) { 
				if (!checkZipForm(zip_value)) {
					alert('Please enter a valid ZIP Code.');
					pageTracker._trackPageview('/fortis-pest-control/step2/error/zip');
					ShowStep('zip');
					zip.focus();
					return false;
				}
			} else {
				alert('Please enter a valid Postal Code.');
				pageTracker._trackPageview('/fortis-pest-control/step2/error/zip');
				ShowStep('zip');
				zip.focus();
				return false;
			}
		}
		if (zip_value.length == 6) { // can postalcode
			if (valid_can.indexOf(country) != -1) {
				if (!checkPostalForm(zip_value)) {
					alert('Please enter a valid Postal Code.');
					pageTracker._trackPageview('/fortis-pest-control/step2/error/zip');
					ShowStep('zip');
					zip.focus();
					return false;
				}
			} else {
				alert('Please enter a valid Zip Code.');
				pageTracker._trackPageview('/fortis-pest-control/step2/error/zip');
				ShowStep('zip');
				zip.focus();
				return false;
			}
		}
	}
} else { //end USA / CAN if
	if (zip_value == '') {
			alert('Please enter a Zip Code.');
			pageTracker._trackPageview('/fortis-pest-control/step2/error/zip');
			ShowStep('zip');
			zip.focus();
			return false;
	}
}


	// Country validation
	if(!checkSelect(form.elements["country"],"country.")) { ShowStep('country'); return false; }
*/ 
	

/*
	// Email validation
	if (!emailCheck(form.email.value)) {		
		alert("Please enter a valid email address.");
		ShowStep('email');
		form.email.focus();
		return false;
	}
*/

	// Phone validation
	var phone = form.primary_phone;
	var phone_value = phone.value;

	// Check for proper length + digits	
	//var regexp = /^(\+\d)*\s*(\(\d{3}\)\s*)*\d{3}(-{0,1}|\s{0,1})\d{2}(-{0,1}|\s{0,1})\d{2}$/;
	//var regexp = /^[2-9]\d{2}\-\d{3}\-\d{4}|^\({1}[2-9]\d{2}\){1}\s?\d{3}\-\d{4}|^[2-9]\d{2}\s\d{3}\s\d{4}/;

	// http://www.geekpedia.com/code60_Validate-phone-number-using-RegEx-and-JavaScript.html ...
	// http://www.websina.com/bugzero/kb/regexp.html
	// http://www.smartwebby.com/DHTML/phone_no_validation.asp

	//var regexp = /^(\+\d)*\s*(\(\d{3}\)\s*)*\d{3}(-{0,1}|\s{0,1})\d{2}(-{0,1}|\s{0,1})\d{2}$/;
	//var regexp = /^((\+\d{1,3}(-| )?\(?\d\)?(-| )?\d{1,5})|(\(?\d{2,6}\)?))(-| )?(\d{3,4})(-| )?(\d{4})(( x| ext)\d{1,5}){0,1}$/;

	// EGGERS -- Commented out to avoid phone requirement for Fortis
	// Australia: 
	//		Mobile phone numbers begin with 04, followed by eight digits. e.g. 04yy yxx xxx
	//		Fixed line telephone numbers in Australia consist of the area code (two digits, starting with '0'), and an eight-digit local number
	//		http://en.wikipedia.org/wiki/Telephone_numbers_in_Australia
	// Canda:
	// Puerto Rico:
	//		
	// UK:
	//		Since 28 April 2001, almost all normal geographic numbers and most non-geographic numbers are 10 or 11 digits long.
	//		http://en.wikipedia.org/wiki/Telephone_numbers_in_the_United_Kingdom
	// USA:
	// 
	//var country = form.country.value;
	//var regexp = /^\(?(\d{3})\)?[- ]?(\d{3})[- ]?(\d{4})$/;
	
	// Simple 10-digit test ... strips out all common special chars, and then checks for 10 numbers.
	var phone_value_stripped = phone_value.replace(/[\(\)\.\-\ \,\+]/g, '');
	var regexp = /\d{10}/;
	
	//if (!regexp.test(phone_value)) {
	if (!phone_value_stripped.match(regexp)) {
		alert('Phone number must contain at least 10 digits.');
		pageTracker._trackPageview('/fortis-pest-control/step2/error/phone');
		ShowStep('primary_phone');
		phone.focus();
		return false;
 	}
	
	
	/*
	// Check for int'l area code
	var intl = pv1.substring(0, 1);
	if ((intl == 0) || (intl == 1))
	{
		alert("International area codes beginning with " + intl + " are not allowed.");
		ShowStep('dphone1');
		p1.focus();
		return false;
	}

	// Check for 911 area code
	if (pv1 == 911)
	{
		alert('Please provide a valid phone number.');
		ShowStep('dphone1');
		p1.focus();
		return false;
	}

	// Check area code for 3 consecutive digits
	var regexp = /(\d)\1{2}/gi;
	if (pv1.search(regexp) != -1)
	{
		alert('Please provide a valid phone number.');
		ShowStep('dphone1');
		p1.focus();
		return false;
	}
	// Check prefix for leading 0
	var intl = pv2.substring(0, 1);
	if (intl == 0 )
	{
		alert('Please provide a valid phone number.');
		ShowStep('dphone2');
		p2.focus();
		return false;
	}

	// Check for 911 or 555 prefix
	if ((pv2 == 911) || (pv2 == 555) || (pv2 == 123) || (pv2 == 456))
	{
		alert('Please provide a valid phone number.');
		ShowStep('dphone2');
		p2.focus();
		return false;
	}
	// Check for 0000 suffix
	if ((pv3 == 0000) || (pv3 == 4567) || (pv3 == 7890))
	{
		alert('Please provide a valid phone number.');
		ShowStep('dphone2');
		p3.focus();
		return false;
	}
	*/
	
	// Check for 6 consecutive digits
	var regexp2 = /(\d)\1{5}/ig;
	if (phone_value.search(regexp2) != -1)
	{
		alert('Please provide a valid phone number.');
		pageTracker._trackPageview('/fortis-pest-control/step2/error/phone');
		ShowStep('primary_phone');
		phone.focus();
	return false;
	}

	// Check for counting phone number
	if ((phone_value == 1234567890) || (phone_value == 2345678901) || (phone_value == 3456789012) || (phone_value == 4567890123) || (phone_value == 5678901234) || (phone_value == 6789012345) || (phone_value == 8901234567) || (phone_value == 9012345678))
	{
		alert('Please provide a valid phone number.');
		pageTracker._trackPageview('/fortis-pest-control/step2/error/phone');
		ShowStep('primary_phone');
		phone.focus();
		return false;
	}
	

	// Normalize phone data to YYXXX-XXXX-XXXX
    // Remove special chars
	phone_value = replaceAll(phone_value," ","");
	phone_value = replaceAll(phone_value,"(","");
	phone_value = replaceAll(phone_value,")","");
	phone_value = replaceAll(phone_value,"-","");
	phone_value = replaceAll(phone_value,"+","");

    // Create normalized string
	
	//phone_value = phone_value.substr(0,3) +  "-"  + phone_value.substr(3,3) + "-"  + phone_value.substr(6,4);	
	phone_value = phone_value.substr(0,phone_value.length-7) +  "-"  + phone_value.substr(phone_value.length-7,3) + "-"  + phone_value.substr(phone_value.length-4,4);
	
	
	// Now we set the value of the field object to our new string. :)
	phone.value=phone_value;
	formSubmitter('pass');
	return false; 
 
} 

var GSteps = 2;

var StepG1 = new Array('property_type','pest_type','comments');
//var StepG2 = new Array('highesteducation','state_of_institution','institution','areaofinterest','grade_point_average');
var StepG2 = new Array('first_name','last_name','address','city','state','state','zip','email','primary_phone');
/// - Groups - //
function getStepFromField(field) {
	for(i=1;i<GSteps+1;i++) {
		var fields = eval('StepG'+i);
		for(x=0;x<fields.length;x++) {
			if(field == fields[x]) {
				return 'Step'+i;
			}
		}
	}
}

function ShowStep(field) {
		var activate = getStepFromField(field);
		for(i=1;i<GSteps+1;i++) {
			if('Step'+i != activate) {
				document.getElementById('Step'+i).style.display = "none";
			} else {
				document.getElementById('Step'+i).style.display = "block";
			}
		}
}

function ShowFirstStep() {
		var activate = "Step1";
		for(i=1;i<GSteps+1;i++) {
			if('Step'+i != activate) {
				document.getElementById('Step'+i).style.display = "none";
			} else {
				document.getElementById('Step'+i).style.display = "block";
			}
		}
}

function initFormBlock() {
	var theme = document.form1.theme.value;
	if (theme != ""){
		//updateContent(theme);
		//var photoString = "photo-"+theme;
		//updatePhoto(photoString);
	} else {
		//updateContent('company');
		//updatePhoto('photo-company');
	}	
	for(i=2;i<GSteps+1;i++) {
		document.getElementById('Step'+i).style.display = "none";
	}
	ShowFirstStep();
}


// - Functions - //
function setCookie( name, value, expires, path, domain, secure ) 
{
// set time, it's in milliseconds
var today = new Date();
today.setTime( today.getTime() );


//if the expires variable is set, make the correct 
//expires time, the current script below will set 
//it for x number of days, to make it for hours, 
//delete * 24, for minutes, delete * 60 * 24

if ( expires )
{
expires = expires * 1000 * 60 * 60 * 24;
}
var expires_date = new Date( today.getTime() + (expires) );

document.cookie = name + "=" +escape( value ) +
( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) + 
( ( path ) ? ";path=" + path : "" ) + 
( ( domain ) ? ";domain=" + domain : "" ) +
( ( secure ) ? ";secure" : "" );
}

function getCookie(name) {
    var dc = document.cookie;
    var prefix = name + "=";
    var begin = dc.indexOf("; " + prefix);
    if (begin == -1) {
        begin = dc.indexOf(prefix);
        if (begin != 0) return null;
    } else {
        begin += 2;
    }
    var end = document.cookie.indexOf(";", begin);
    if (end == -1) {
        end = dc.length;
    }
    return unescape(dc.substring(begin + prefix.length, end));
}

function UpdatePrePop() {

	var form = document.form1;


	var fv_first_name = form.first_name.value;
	var fv_last_name = form.last_name.value;
	var fv_city = form.city.value;
	var fv_state = form.state.value;

	for(i=1;i<GSteps+1;i++) {
		if(fv_first_name != "") {
			sayIt(fv_first_name,'pp_first_name'+i);
		}
		if(fv_last_name != "") {
			sayIt(fv_last_name,'pp_last_name'+i);
		}
		if(fv_city != "") {
			var regexp = /[0-9\$\%\^\&\*\!\@\#\(\)\{\}\[\]\\\|\/\?\<\>\,\:\;\+\=\"\']+/gi;
			if (fv_city.search(regexp) == -1)
			{
				sayIt(fv_city,'pp_city'+i);
			}
		}
		if(fv_state != "-1") {
			sayIt(fv_state,'pp_state'+i);
		}
	}
}

function sayIt(txt, obj) {
	document.getElementById(obj).childNodes[0].nodeValue = txt;
}

function isDigit(c)
{   return ((c >= "0") && (c <= "9"))
}

function isInteger (s)

{   var i;

    if (isEmpty(s))
       if (isInteger.arguments.length == 1) return defaultEmptyOK;
       else return (isInteger.arguments[1] == true);

    // Search through string's characters one by one
    // until we find a non-numeric character.
    // When we do, return false; if we don't, return true.

    for (i = 0; i < s.length; i++)
    {
        // Check that current character is number.
        var c = s.charAt(i);

        if (!isDigit(c)) return false;
    }

    // All characters are numbers.
    return true;
}


// trimming a value
function trim(value) {
  var tmpstr = ltrim(value);

  return rtrim(tmpstr);
}

// left trim
function ltrim(value) {

  while (1) {
    if (value.substring(0,1) != " ")
      break;
    value = value.substring(1, value.length);
  }

  return value;
}

// right trim
function rtrim(value) {

  while (1) {
    if (value.substring(value.length - 1, value.length) != " ")
      break;
    value = value.substring(0, value.length - 1);
  }

  return value;
}


// For checking select boxes
function checkSelect(theField,s)
{
	var fieldValue = trim(theField.value);
	if (fieldValue=="null" || fieldValue=="0" || fieldValue=="" || fieldValue=="-1" || fieldValue=="-1|Select One") return warnEmptySelect(theField,s);
	else
	return true;
}
function checkSelectDataMark(theField,s)
{
	var fieldValue = trim(theField.value);
	if (fieldValue=="null" || fieldValue=="0" || fieldValue=="") return warnEmptySelect(theField,s);
	else
	return true;
}

function fr_checkSelect(theField,s)
{
	var fieldValue = trim(theField.value);
	if (fieldValue=="null" || fieldValue=="0" || fieldValue=="" || fieldValue=="-1" || fieldValue=="-1|Select One") return fr_warnEmptySelect(theField,s);
	else
	return true;
}

function checkSelectNoZero(theField,s)
{
	var fieldValue = trim(theField.value);
	if (fieldValue=="null" || fieldValue=="" || fieldValue=="-1" || fieldValue=="-1|Select One") return warnEmptySelect(theField,s);
	else
	return true;
}

function isString(a) {
    return typeof a == 'string';
}

function isEmpty(s)
{
	s=trim(s);
	return ((s == null) || (s.length == 0))
}

function warnEmptySelect (theField, s)
{
	theField.focus();
	alert("Please select " +s);
	pageTracker._trackPageview('/fortis-pest-control/step2/error/empty/'.s);
	return false;
}

function fr_warnEmptySelect (theField, s)
{
	theField.focus();
	alert("Veuillez selectionner " +s);
	return false;
}

function warnEmpty (theField, s)
{
	theField.focus();
	alert("Please enter " +s);
	pageTracker._trackPageview('/fortis-pest-control/step2/error/empty/'.s);
	return false;
}

function fr_warnEmpty (theField, s)
{
	theField.focus();
	alert("Veuillez indiquer " +s);
	return false;
}

function checkEmpty (theField, s)
{
   if(isEmpty(theField.value)) return warnEmpty (theField, s);
   else return true;
}

function fr_checkEmpty (theField, s)
{
   if(isEmpty(theField.value)) return fr_warnEmpty (theField, s);
   else return true;
}


function isWhitespace (s)
{   var i;

	var whitespace = " \t\n\r";
    // Is s empty?
    if (isEmpty(s)) return true;

    // Search through string's characters one by one
    // until we find a non-whitespace character.
    // When we do, return false; if we don't, return true.

    for (i = 0; i < s.length; i++)
    {
        // Check that current character isn't whitespace.
        var c = s.charAt(i);

        if (whitespace.indexOf(c) == -1) return false;
    }

    // All characters are whitespace.
    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) {
		pageTracker._trackPageview('/fortis-pest-control/step2/error/email');
		return false
	}
	var user=matchArray[1]
	var domain=matchArray[2]
	if (user.match(userPat)==null) {
		pageTracker._trackPageview('/fortis-pest-control/step2/error/email');
		return false
	}
	var IPArray=domain.match(ipDomainPat)
	if (IPArray!=null) {
		  for (var i=1;i<=4;i++) {
			if (IPArray[i]>255) {
				pageTracker._trackPageview('/fortis-pest-control/step2/error/email');
				return false
			}
		}
		return true
	}
	var domainArray=domain.match(domainPat)
	if (domainArray==null) {
		pageTracker._trackPageview('/fortis-pest-control/step2/error/email');
		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) {
		document.form1.email.focus()
		pageTracker._trackPageview('/fortis-pest-control/step2/error/email');
		return false
	}
	if (len<2) {
		pageTracker._trackPageview('/fortis-pest-control/step2/error/email');
		return false
	}
	return true;
}


function fr_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) {
		return false
	}
	var user=matchArray[1]
	var domain=matchArray[2]
	if (user.match(userPat)==null) {
		return false
	}
	var IPArray=domain.match(ipDomainPat)
	if (IPArray!=null) {
		  for (var i=1;i<=4;i++) {
			if (IPArray[i]>255) {
				return false
			}
		}
		return true
	}
	var domainArray=domain.match(domainPat)
	if (domainArray==null) {
		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) {
		document.form1.fr_email.focus()
		return false
	}
	if (len<2) {
	   return false
	}
	return true;
}
