function emailTest() {
var email_pattern = /^(\w|-)+\@([a-zA-Z0-9]|-)+\.(\w|\.)+/;
var email_pattern2 = /^(\w|-)+\.(\w|\.)+\@([a-zA-Z0-9]|-)+\.(\w|\.)+/;
var email_address = document.form.sender.value;
var start = email_address.indexOf("@") + 1;
var checkString = email_address.substring(start,email_address.length);
var duplicate = checkString.indexOf("@");
	if (duplicate >= 0) {
		alert("You may only enter one email address.");
		document.form.sender.focus(); }
var email_result;
email_result = email_pattern.exec(document.form.sender.value);
var email_result2;
email_result2 = email_pattern2.exec(document.form.sender.value);
	if (email_result) {
	}
	else if (email_result2) {
	}
	else  {
		alert("Please enter a valid email address."); }
}

function validateForm() {
if (document.form.phone.value == "") {
	alert("Please enter the phone number you would like Internet service connected to.");
	document.form.phone.focus();
	return false; }
else if (document.form.billingname.value == "") {
	alert("Please enter your name.");
	document.form.billingname.focus();
	return false; }
else if (document.form.serviceaddress.value == "") {
	alert("Please enter the address where you would like your Internet service connected.");
	document.form.serviceaddress.focus();
	return false; }
else if (document.form.city.value == "") {
	alert("Please enter the city of your service address.");
	document.form.city.focus();
	return false; }
else if (document.form.state.value == "") {
	alert("Please enter the state of your service address.");
	document.form.state.focus();
	return false; }
else if (document.form.zip.value == "") {
	alert("Please enter the zip code of your service address.");
	document.form.zip.focus();
	return false; }
if (document.form.sender.value == "") {
	alert("Please enter your current email address.");
	document.form.sender.focus();
	return false; }
else { return true; }
}

//phone
var n;
var p;
var p1;
function ValidatePhone() {
p=p1.value
if(p.length==3) {
	//d10=p.indexOf('(')
	pp=p;
	d4=p.indexOf('(')
	d5=p.indexOf(')')
	if(d4==-1) {
		pp="("+pp; }
	if(d5==-1) {
		pp=pp+")"; }
	//pp="("+pp+")";
	document.form.phone.value="";
	document.form.phone.value=pp; }
if(p.length>3) {
	d1=p.indexOf('(')
	d2=p.indexOf(')')
	if (d2==-1) {
		l30=p.length;
		p30=p.substring(0,4);
		//alert(p30);
		p30=p30+")"
		p31=p.substring(4,l30);
		pp=p30+p31;
		//alert(p31);
		document.form.phone.value="";
		document.form.phone.value=pp; }
	}
if(p.length>5) {
	p11=p.substring(d1+1,d2);
	if(p11.length>3) {
	p12=p11;
	l12=p12.length;
	l15=p.length
	//l12=l12-3
	p13=p11.substring(0,3);
	p14=p11.substring(3,l12);
	p15=p.substring(d2+1,l15);
	document.form.phone.value="";
	pp="("+p13+")"+p14+p15;
	document.form.phone.value=pp;
	//obj1.value="";
	//obj1.value=pp; 
	}
	l16=p.length;
	p16=p.substring(d2+1,l16);
	l17=p16.length;
	if(l17>3&&p16.indexOf('-')==-1) {
		p17=p.substring(d2+1,d2+4);
		p18=p.substring(d2+4,l16);
		p19=p.substring(0,d2+1);
		//alert(p19);
	pp=p19+p17+"-"+p18;
	document.form.phone.value="";
	document.form.phone.value=pp;
	//obj1.value="";
	//obj1.value=pp;
	}
}
//}
setTimeout(ValidatePhone,100) }
function getIt(m) {
n=m.name;
//p1=document.forms[0].elements[n]
p1=m
ValidatePhone() }
function testphone(obj1) {
p=obj1.value
//alert(p)
p=p.replace("(","")
p=p.replace(")","")
p=p.replace("-","")
p=p.replace("-","")
//alert(isNaN(p))
if (isNaN(p)==true) {
alert("Check phone");
return false; }
}
//end phone

//phone2
var b;
var c;
var c1;
function ValidatePhone2() {
c=c1.value
if(c.length==3) {
	//e10=c.indexOf('(')
	cc=c;
	e4=c.indexOf('(')
	e5=c.indexOf(')')
	if(e4==-1) {
		cc="("+cc; }
	if(e5==-1) {
		cc=cc+")"; }
	//cc="("+cc+")";
	document.form.phone2.value="";
	document.form.phone2.value=cc; }
if(c.length>3) {
	e1=c.indexOf('(')
	e2=c.indexOf(')')
	if (e2==-1) {
		l30=c.length;
		c30=c.substring(0,4);
		//alert(c30);
		c30=c30+")"
		c31=c.substring(4,l30);
		cc=c30+c31;
		//alert(c31);
		document.form.phone2.value="";
		document.form.phone2.value=cc; }
	}
if(c.length>5) {
	c11=c.substring(e1+1,e2);
	if(c11.length>3) {
	c12=c11;
	l12=c12.length;
	l15=c.length
	//l12=l12-3
	c13=c11.substring(0,3);
	c14=c11.substring(3,l12);
	c15=c.substring(e2+1,l15);
	document.form.phone2.value="";
	cc="("+c13+")"+c14+c15;
	document.form.phone2.value=cc;
	//obj1.value="";
	//obj1.value=cc; 
	}
	l16=c.length;
	c16=c.substring(e2+1,l16);
	l17=c16.length;
	if(l17>3&&c16.indexOf('-')==-1) {
		c17=c.substring(e2+1,e2+4);
		c18=c.substring(e2+4,l16);
		c19=c.substring(0,e2+1);
		//alert(c19);
	cc=c19+c17+"-"+c18;
	document.form.phone2.value="";
	document.form.phone2.value=cc;
	//obj1.value="";
	//obj1.value=cc;
	}
}
//}
setTimeout(ValidatePhone2,100) }
function getIt2(m) {
b=m.name;
//c1=document.forms[0].elements[b]
c1=m
ValidatePhone2() }
function testphone(obj1) {
c=obj1.value
//alert(c)
c=c.replace("(","")
c=c.replace(")","")
c=c.replace("-","")
c=c.replace("-","")
//alert(isNaN(c))
if (isNaN(c)==true) {
alert("Check phone");
return false; }
}
//end phone2

function populatePricing() {
if ((document.form.plan.options[document.form.plan.selectedIndex].value) == "Starter Dial-Up") {
	document.form.pricing.value = "$9.95 monthly"; }
if ((document.form.plan.options[document.form.plan.selectedIndex].value) == "Standard Dial-Up") {
	document.form.pricing.value = "$21.95 monthly"; }
if ((document.form.plan.options[document.form.plan.selectedIndex].value) == "Enhanced Dial-Up") {
	document.form.pricing.value = "$24.95 monthly"; }
if ((document.form.plan.options[document.form.plan.selectedIndex].value) == "Starter DSL") {
	document.form.pricing.value = "$34.95 monthly"; }
if ((document.form.plan.options[document.form.plan.selectedIndex].value) == "Standard DSL") {
	document.form.pricing.value = "$44.95 monthly"; }
if ((document.form.plan.options[document.form.plan.selectedIndex].value) == "Premium DSL") {
	document.form.pricing.value = "$79.95 monthly"; }
}

function setExchange() {
// 207 - 377 CST
if ((document.form3.NPA2.value == "207") && ((document.form3.Exchange2.value == "268") || (document.form3.Exchange2.value == "293") || (document.form3.Exchange2.value == "377") || (document.form3.Exchange2.value == "395") || (document.form3.Exchange2.value == "524") || (document.form3.Exchange2.value == "933"))) {
	((document.form3.NPA.value = "207") && (document.form3.Exchange.value = "377")); }

// 207 - 642 FPNE ME
else if ((document.form3.NPA2.value == "207") && ((document.form3.Exchange2.value == "342") || (document.form3.Exchange2.value == "365") || (document.form3.Exchange2.value == "382") || (document.form3.Exchange2.value == "398") || (document.form3.Exchange2.value == "444") || (document.form3.Exchange2.value == "445") || (document.form3.Exchange2.value == "452") || (document.form3.Exchange2.value == "463") || (document.form3.Exchange2.value == "528") || (document.form3.Exchange2.value == "547") || (document.form3.Exchange2.value == "567") || (document.form3.Exchange2.value == "589") || (document.form3.Exchange2.value == "627") || (document.form3.Exchange2.value == "637") || (document.form3.Exchange2.value == "642") || (document.form3.Exchange2.value == "655") || (document.form3.Exchange2.value == "675") || (document.form3.Exchange2.value == "693") || (document.form3.Exchange2.value == "697") || (document.form3.Exchange2.value == "722") || (document.form3.Exchange2.value == "736") || (document.form3.Exchange2.value == "738") || (document.form3.Exchange2.value == "757") || (document.form3.Exchange2.value == "765") || (document.form3.Exchange2.value == "787") || (document.form3.Exchange2.value == "834") || (document.form3.Exchange2.value == "845") || (document.form3.Exchange2.value == "923") || (document.form3.Exchange2.value == "925") || (document.form3.Exchange2.value == "935") || (document.form3.Exchange2.value == "946") || (document.form3.Exchange2.value == "968") || (document.form3.Exchange2.value == "993") || (document.form3.Exchange2.value == "998"))) {
	((document.form3.NPA.value = "207") && (document.form3.Exchange.value = "642")); }

// 603 - 694 FPNE NH
else if ((document.form3.NPA2.value == "603") && ((document.form3.Exchange2.value == "694") || (document.form3.Exchange2.value == "939"))) {
	((document.form3.NPA.value = "603") && (document.form3.Exchange.value = "694")); }
	
// 802 - 584 FPNE VT
else if ((document.form3.NPA2.value == "802") && ((document.form3.Exchange2.value == "326") || (document.form3.Exchange2.value == "426") || (document.form3.Exchange2.value == "429") || (document.form3.Exchange2.value == "563") || (document.form3.Exchange2.value == "584") || (document.form3.Exchange2.value == "592") || (document.form3.Exchange2.value == "796") || (document.form3.Exchange2.value == "928"))) {
	((document.form3.NPA.value = "802") && (document.form3.Exchange.value = "584")); }

// all else
else { ((document.form3.NPA.value = document.form3.NPA2.value) && (document.form3.Exchange.value = document.form3.Exchange2.value)) }
}