var xmlHttp
function emails()
{
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	  {
	  alert ("ERROR Your browser does not support AJAX!");
	  return;
	  }
	var email = document.form1.email.value;
	if (email=="")
	  {
	  alert ("Please enter a valid email address, so that we may send you the price quote you've requested!");
	  return;
	  }
	var client = document.form1.client.value;
	var phone = document.form1.phone.value;
	var biztype = document.form1.biztype.value;
	var state = document.form1.state.value;
	var fein = document.form1.fein.value;
	var scorp = document.form1.scorp.value;
	var expedite = document.form1.expedite.value;
	var shipping = document.form1.shipping.value;
	var total = document.form1.total.value;
	var time = document.form1.time.value; 
	var tag = document.form1.tag.value;
	var svcids = document.form1.svcids.value;
	var url="emails.php";
	url=url+"?tag="+tag;
	url=url+"&biztype="+biztype;
	url=url+"&state="+state;
	url=url+"&fein="+fein;
	url=url+"&scorp="+scorp;
	url=url+"&expedite="+expedite;
	url=url+"&shipping="+shipping;
	url=url+"&total="+total;
	url=url+"&time="+time;
	url=url+"&tag="+tag;
	url=url+"&email="+email;	
	url=url+"&svcids="+svcids;	
	url=url+"&client="+client;	
	url=url+"&phone="+phone;
	url=url+"&sid="+Math.random();
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
	document.form1.svcids.value = svcids;
	alert ("Your price quote has been emailed. Thank you for your interest in our services!");
	return;
}
function okHint()
{
	var biztype = document.form1.biztype.value;
	var state = document.form1.state.value;
	var fein = document.form1.fein.value;
	var scorp = document.form1.scorp.value;
	var expedite = document.form1.expedite.value;
	var shipping = document.form1.shipping.value;
	var showhint = showHint(biztype,state,fein,scorp,expedite,shipping);
}

function showHint(biztype,state,fein,scorp,expedite,shipping)
{
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
  {
  alert ("ERROR Your browser does not support AJAX!");
  return;
  } 
var url="gethint.php";
url=url+"?biztype="+biztype;
url=url+"&state="+state;
url=url+"&fein="+fein;
url=url+"&scorp="+scorp;
url=url+"&expedite="+expedite;
url=url+"&shipping="+shipping;
url=url+"&sid="+Math.random();
xmlHttp.onreadystatechange=stateChanged;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
}

function stateChanged() 
{ 
if (xmlHttp.readyState==4)
{
str=xmlHttp.responseText;
var hints = str.split(",");
var total = parseFloat(0);
var time = parseFloat(0);
if (hints[0]){var cost1 = hints[0];}else var cost1 = 0;
if (hints[1]){var time1 = hints[1];}else var time1 = 0;
if (hints[2]){var price1 = hints[2];}else var price1 = 0;
if (hints[3]){var cost2 = hints[3];}else var cost2 = 0;
if (hints[4]){var time2 = hints[4];}else var time2 = 0;
if (hints[5]){var price2 = hints[5];}else var price2 = 0;
if (hints[6]){var cost3 = hints[6];}else var cost3 = 0;
if (hints[7]){var time3 = hints[7];}else var time3 = 0;
if (hints[8]){var price3 = hints[8];}else var price3 = 0;
if (hints[9]){var cost4 = hints[9];}else var cost4 = 0;
if (hints[10]){var time4= hints[10];}else var time4 = 0;
if (hints[11]){var price4 = hints[11];}else var price4 = 0;
if (hints[12]){var cost5 = hints[12];}else var cost5 = 0;
if (hints[13]){var time5 = hints[13];}else var time5 = 0;
if (hints[14]){var price5 = hints[14];}else var price5 = 0;
var timetxt;
total = parseFloat(cost1) + parseFloat(price1) + parseFloat(cost2) + parseFloat(price2) + parseFloat(cost3) + parseFloat(price3) + parseFloat(cost4) + parseFloat(price4) + parseFloat(cost5) + parseFloat(price5);
time = parseFloat(time1) + parseFloat(time2) + parseFloat(time3) + parseFloat(time4) + parseFloat(time5);

var p1 = parseFloat(price1) + parseFloat(cost1);
var p2 = parseFloat(price2) + parseFloat(cost2);
var p3 = parseFloat(price3) + parseFloat(cost3);
var p4 = parseFloat(price4) + parseFloat(cost4);
var p5 = parseFloat(price5) + parseFloat(cost5);
document.form1.p1.value = fix(p1);
document.form1.p2.value = fix(p2);
document.form1.p3.value = fix(p3);
document.form1.p4.value = fix(p4);
document.form1.p5.value = fix(p5);

document.form1.total.value = fix(total);
if (time < 1)
{
	time = 1;
}
timetxt = time + " days";
document.form1.time.value = timetxt;
}
}

function fix(num) {
 string = "" + num;
 if (string.indexOf('.') == -1)
  return string + '.00';
 seperation = string.length - string.indexOf('.');
 if (seperation > 3)
  return string.substring(0,string.length-seperation+3);
 else if (seperation == 2)
  return string + '0';
 return string;
}

function GetXmlHttpObject()
{
var xmlHttp=null;
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
  }
return xmlHttp;
}

function start()
{
	validity = true;
	if (document.form1.state.selectedIndex == 0)
	{
			validity = false;
			alert('You must select your state');
			document.form1.state.focus();
			return validity;
	}
	if ((document.form1.biztype.selectedIndex == 0)&&(document.form1.fein.selectedIndex == 0)&&(document.form1.scorp.selectedIndex == 0)&&(document.form1.biztype.selectedIndex == 0))
	{
			validity = false;
			alert('You must select a service');
			document.form1.biztype.focus();
			return validity;
	}
	if (validity) {
		var biztype = document.form1.biztype.value;
		var state = document.form1.state.value;
		var fein = document.form1.fein.value;
		var scorp = document.form1.scorp.value;
		var expedite = document.form1.expedite.value;
		var shipping = document.form1.shipping.value;
		var varsvcids = state + ',' + biztype + ',' + expedite + ',' + shipping + ',' + fein + ',' + scorp + ',' + 0;
		document.form1.svcids.value = varsvcids;
 		return validity;
	}
}
function start2()
{
	var startval = start();
	if (startval == true)
	{
		document.form1.submit();
	}
}