var theCost="";
var service="";

function calcLine(serviceType) {
	service=serviceType;
	if (serviceType=="Underground") {
		document.getElementById("extras").style.display="";
	}
	else if (serviceType=="Overhead") {
		document.getElementById("extras").style.display="none";
	}
	return service;
}

function calcIt() { 
	var theDistance=Math.floor(document.getElementById('distance').value);
	var service=document.getElementById('service');
	var serviceType=service.options[service.selectedIndex].value;
	var estText="Your Ballpark Estimate is: $"
	if (serviceType=="Overhead") { 
			if ((theDistance !="") && (theDistance <= 150))	{	
			 	theCost=4450;
			 	document.getElementById('errDistance').innerHTML=estText+theCost;
			 	
			 } 
				else if ((theDistance > 150) && (theDistance <= 300)) { 
				 	theCost=6800;
						document.getElementById('errDistance').innerHTML=estText+theCost;
		
				 } 
				else if ((theDistance > 300) && (theDistance <= 500 )) { 
				 	theCost=8430;
					document.getElementById('errDistance').innerHTML=estText+theCost;
	
				} 
				else if ((theDistance > 500) && (theDistance <= 750 )) { 
				 	theCost=10070;
					document.getElementById('errDistance').innerHTML=estText+theCost;
	
				} 
		 		else if ((theDistance > 750 ) && (theDistance <= 1000 )) { 
				 	theCost=11850;
					document.getElementById('errDistance').innerHTML=estText+theCost;
							
				}
				else if ((theDistance=="") || (theDistance > 1000)) {
					document.getElementById('distance').focus();
					document.getElementById('errDistance').innerHTML="Please enter a value greater than 0 and less than 1000."
				}
		}
		else if (serviceType=="Underground") {		
		var radioButtons = document.getElementsByName("facility");
			for (var x = 0; x < radioButtons.length; x++) {
				if (radioButtons[x].checked) {
				 var theFacility=radioButtons[x].value;
			 	}
			}
				if ((theDistance !="") && (theDistance <= 150))	{	
				if (theFacility=='pole') {
		     		 theCost=2500;
		      		}
		    	if (theFacility=='cabinet') {
		      		theCost=3200;
		      		}
		    	if (theFacility=='pole_trans') {
		      		theCost=2500;
		      		}
		    	if (theFacility=='pad_trans') {
		      		theCost=2500;
			 		}
			 document.getElementById('errDistance').innerHTML=estText+theCost;
			 } 
				else if ((theDistance > 150) && (theDistance <= 300)) { 
				if (theFacility=='pole') {
		      		theCost=5980;
		      		}
		    	if (theFacility=='pole_trans') {
		      		theCost=5980;
		      		}
		    	if (theFacility=='cabinet') {
		      		theCost=4040;
		     		} 
		   		 if (theFacility=='pad_trans') {
		      		theCost=4040;
					}
				document.getElementById('errDistance').innerHTML=estText+theCost;
				 } 
				else if ((theDistance > 300) && (theDistance <= 500 )) { 
				if (theFacility=='pole') {
		      		theCost=6770;
		      		}
		    	if (theFacility=='pole_trans') {
		      		theCost=6770;
		      		}
		    	if (theFacility=='cabinet') {
		      		theCost=4830;
		      		}
		    	if (theFacility=='pad_trans') {
		      		theCost=4830;
				 	}
				document.getElementById('errDistance').innerHTML=estText+theCost;
				} 
				else if ((theDistance > 500) && (theDistance <= 750 )) { 
				if (theFacility=='pole') {
		      		theCost=7830;
		      		}
		    	if (theFacility=='pole_trans') {
		     		 theCost=7830;
		      		}
		    	if (theFacility=='cabinet') {
		     		theCost=5890;
		  			}
		    	if (theFacility=='pad_trans') {
		      		theCost=5890;
				 	}	
				document.getElementById('errDistance').innerHTML=estText+theCost;
				} 
		 		else if ((theDistance > 750 ) && (theDistance <= 1000 )) { 
		 		 if (theFacility=='pole') {
		      		theCost=11280;
		      		}
		    	 if (theFacility=='pole_trans') {
		      		theCost=11280;
		      		}
		    	 if (theFacility=='cabinet') {
		      		theCost=9340;
		      		}
		    	if (theFacility=='pad_trans') {
		      		theCost=9340;
		      		}
				document.getElementById('errDistance').innerHTML="Your Ballpark Estimate is: $".theCost;		
				}
				else if ((theDistance=="") || (theDistance > 1000)) {
					document.getElementById('distance').focus();
					document.getElementById('errDistance').innerHTML="Please enter a value greater than 0 and less than 1000."
				}	
		 }
		}