<!-- Image Swap Functions 
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
//-->

<!-- ImageReady Preload Script (locations.psd) -->
function newImage(arg) {
	if (document.images) {
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
}

function changeImages() {
	if (document.images && (preloadFlag == true)) {
		for (var i=0; i<changeImages.arguments.length; i+=2) {
			document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
		}
	}
}

var preloadFlag = false;
function preloadImages() {
	if (document.images) {
		map_ia_map_over = newImage("images/locations/map-ia_map_over.gif");
		map_ks_map_over = newImage("images/locations/map-ks_map_over.gif");
		map_ks_map_active = newImage("images/locations/map-ks_map_active.gif");
		map_la_map_over = newImage("images/locations/map-la_map_over.gif");
		map_mo_map_over = newImage("images/locations/map-mo_map_over.gif");
		map_mo_map_active = newImage("images/locations/map-mo_map_active.gif");
		map_ne_map_over = newImage("images/locations/map-ne_map_over.gif");
		map_ne_map_active = newImage("images/locations/map-ne_map_active.gif");
		map_ok_map_over = newImage("images/locations/map-ok_map_over.gif");
		map_ok_map_active = newImage("images/locations/map-ok_map_active.gif");
		map_tx_map_over = newImage("images/locations/map-tx_map_over.gif");
		map_tx_map_active = newImage("images/locations/map-tx_map_active.gif");
		map_ar_map_over = newImage("images/locations/map-ar_map_over.gif");
		map_nm_map_over = newImage("images/locations/map-nm_map_over.gif");
		preloadFlag = true;
	}
}
<!-- End Preload Script -->

/*-- Map Functionality >> START ----------------------------------------*/
function hideState() {
	document.getElementById("stateInfoWrapper").className = "hide";
	document.getElementById("makeSelection").className = "show";
	document.getElementById("map").innerHTML = "<img src='images/locations/map.gif' alt='' name='map' width='417' height='304' border='0' usemap='#map_Map' href='#' />";
}
function showState(whoClicked) {
	var locState = whoClicked;
	document.getElementById("makeSelection").className = "hide";
	document.getElementById("stateInfoWrapper").className = "show";
	if (locState != '') {
		if (locState == "AR") {
			document.getElementById("stateName").innerHTML = "ARKANSAS";
			document.getElementById("stateInfo").innerHTML = "Choose a location from the map on the left for more info.";
			document.getElementById("map").innerHTML = "<img src='images/locations/map-ar_map_active.gif' alt='' name='Map_AR' width='417' height='304' border='0' usemap='#Map_AR' href='#' />";
		}
		// IOWA currently has no pop-up map //
		else if (locState == "IA") {
			document.getElementById("stateName").innerHTML = "IOWA";
			document.getElementById("stateInfo").innerHTML = 
			"<div><h4>Sales Representative</h4>" +
			"	<div id='indent'><strong>Brady Pryor</strong><br />(785)267-1996<br /><a href='mailto:brady.pryor@ashgroveresources.com'>brady.pryor@ashgroveresources.com</a></div>" +
			"</div>";
		}
		else if (locState == "KS") {
			document.getElementById("stateName").innerHTML = "KANSAS";
			document.getElementById("stateInfo").innerHTML = "Choose a location from the map on the left for more info.";
			document.getElementById("map").innerHTML = "<img src='images/locations/map-ks_map_active.gif' alt='' name='Map_KS' width='417' height='304' border='0' usemap='#Map_KS' href='#' />";
		}
		// LOUISIANA currently has no pop-up map //
		else if (locState == "LA") {
			document.getElementById("stateName").innerHTML = "LOUISIANA";
			document.getElementById("stateInfo").innerHTML = 
			"<div><h4>Geotechnical Sales Representatives</h4>" +
			"	<div id='indent'><strong>Bruce Schwan</strong><br />(479)719-4081<br /><a href='mailto:bruce.schwan@ashgroveresources.com'>bruce.schwan@ashgroveresources.com</a></div>" +
			"</div>";
		}
		// MISSOURI currently has no pop-up map //
		else if (locState == "MO") {
			document.getElementById("stateName").innerHTML = "MISSOURI";
			document.getElementById("stateInfo").innerHTML = 
			"<div><h4>Ash Grove Cement Sales Representatives</h4>" +
			"	<div id='indent'><strong>Bob Brooks - Southwest Missouri</strong><br />(417)437-4816<br /><a href='mailto:bob.brooks@ashgrove.com'>bob.brooks@ashgrove.com</a></div>" +
			"	<div id='indent'><strong>Jay Raccuglia - Northwest Missouri</strong><br />(913)915-0357<br /><a href='mailto:jay.raccuglia@ashgrove.com'>jay.raccuglia@ashgrove.com</a></div>" +
			"</div>" +
			"<br />" +
			"<div><h4>Geotechnical Sales Representatives</h4>" +
			"	<div id='indent'><strong>Gary Dukewits</strong><br />(785)608-5188<br /><a href='mailto:gary.dukewits@ashgroveresources.com'>gary.dukewits@ashgroveresources.com</a></div>" +
			"</div>";
		}
		else if (locState == "NE") {
			document.getElementById("stateName").innerHTML = "NEBRASKA";
			document.getElementById("stateInfo").innerHTML = "Choose a location from the map on the left for more info.";
			document.getElementById("map").innerHTML = "<img src='images/locations/map-ne_map_active.gif' alt='' name='Map_NE' width='417' height='304' border='0' usemap='#Map_NE' href='#' />";
		}
		else if (locState == "NM") {
			document.getElementById("stateName").innerHTML = "NEW MEXICO";
			document.getElementById("stateInfo").innerHTML = "I still need the locations layout to build this map (see KS)";
		}
		else if (locState == "OK") {
			document.getElementById("stateName").innerHTML = "OKLAHOMA";
			document.getElementById("stateInfo").innerHTML = "Choose a location from the map on the left for more info.";
			document.getElementById("map").innerHTML = "<img src='images/locations/map-ok_map_active.gif' alt='' name='Map_OK' width='417' height='304' border='0' usemap='#Map_OK' href='#' />";
		}
		else if (locState == "TX") {
			document.getElementById("stateName").innerHTML = "TEXAS";
			document.getElementById("stateInfo").innerHTML = "Choose a location from the map on the left for more info.";
			document.getElementById("map").innerHTML = "<img src='images/locations/map-tx_map_active.gif' alt='' name='Map_TX' width='417' height='304' border='0' usemap='#Map_TX' href='#' />";
		}
	}
	else  {
		alert('Data not found!');
	}
}

function showCity(whoClicked) {
	var locCity = whoClicked;
	if (locCity != '') {
		//== KANSAS ==//
		if (locCity == "Bonner") {
			document.getElementById("stateInfo").innerHTML = 
			"<div><h4>Bonner Springs, KS</h4>" + 
			"	<div id='indent'><strong>Loring Terminal - Fly Ash</strong></div>" +
			"</div>" +
			"<br />" +
			"<div><h4>Ash Grove Cement Sales Representatives</h4>" +
			"	<div id='indent'><strong>Jay Raccuglia</strong><br />(913)915-0357<br /><a href='mailto:jay.raccuglia@ashgrove.com'>jay.raccuglia@ashgrove.com</a></div>" +
			"</div>";
		}
		else if (locCity == "Chanute") {
			document.getElementById("stateInfo").innerHTML = 
			"<div><h4>Chanute, KS</h4>" + 
			"	<div id='indent'><strong>Ash Grove Cement Plant<br />Terminal - Fly Ash<br />Plant - Ash Grove Durabase&reg;</strong></div>" +
			"</div>" +
			"<br />" +
			"<div><h4>Ash Grove Cement Sales Representatives</h4>" +
			"	<div id='indent'><strong>Bob Brooks - Southeast Kansas</strong><br />(417)437-4816<br /><a href='mailto:bob.brooks@ashgrove.com'>bob.brooks@ashgrove.com</a></div>" +
			"	<div id='indent'><strong>Eric Trytten - South Central Kansas</strong><br />(316)250-5400<br /><a href='mailto:eric.trytten@ashgrove.com'>eric.trytten@ashgrove.com</a></div>" +
			"</div>" +
			"<br />" +
			"<div><h4>Geotechnical Sales Representatives</h4>" +
			"	<div id='indent'><strong>Gary Dukewits</strong><br />(785)608-5188<br /><a href='mailto:gary.dukewits@ashgroveresources.com'>gary.dukewits@ashgroveresources.com</a></div>" +
			"</div>";
		}
		else if (locCity == "Edwardsville") {
			document.getElementById("stateInfo").innerHTML = 
			"<div><h4>Edwardsville, KS</h4>" + 
			"	<div id='indent'><strong>L.G. Everist Terminal - Fly Ash</strong></div>" +
			"</div>" +
			"<br />" +
			"<div><h4>Ash Grove Cement Sales Representatives</h4>" +
			"	<div id='indent'><strong>Jay Raccuglia</strong><br />(913)915-0357<br /><a href='mailto:jay.raccuglia@ashgrove.com'>jay.raccuglia@ashgrove.com</a></div>" +
			"</div>";
		}
		else if (locCity == "StMarys") {
			document.getElementById("stateInfo").innerHTML = 
			"<div><h4>ST Marys, KS</h4>" + 
			"	<div id='indent'><strong>Jeffrey Energy Center - Fly Ash</strong></div>" +
			"</div>" +
			"<br />" +
			"<div><h4>Ash Grove Cement Sales Representatives</h4>" +
			"	<div id='indent'><strong>David Abell - Northern Kansas</strong><br />(785)822-5382<br /><a href='mailto:david.abell@ashgrove.com'>david.abell@ashgrove.com</a></div>" +
			"	<div id='indent'><strong>Eric Trytten - Southern Kansas</strong><br />(316)250-5400<br /><a href='mailto:eric.trytten@ashgrove.com'>eric.trytten@ashgrove.com</a></div>" +
			"</div>" +
			"<br />" +
			"<div><h4>Geotechnical Sales Representatives</h4>" +
			"	<div id='indent'><strong>Tom Stringer</strong><br />(785)633-7872<br /><a href='mailto:tom.stringer@ashgroveresources.com'>tom.stringer@ashgroveresources.com</a></div>" +
			"</div>";
		}
		else if (locCity == "Tecumseh") {
			document.getElementById("stateInfo").innerHTML = 
			"<div><h4>Tecumseh, KS</h4>" + 
			"	<div id='indent'><strong>Tecumseh Energy Center - Fly Ash</strong></div>" +
			"</div>" +
			"<br />" +
			"<div><h4>Sales Representative</h4>" +
			"	<div id='indent'><strong>Brady Pryor</strong><br />(785)267-1996<br /><a href='mailto:brady.pryor@ashgroveresources.com'>brady.pryor@ashgroveresources.com</a></div>" +
			"</div>";
		}
		//== NEBRASKA ==//
		else if (locCity == "NebraskaCity") {
			document.getElementById("stateInfo").innerHTML = 
			"<div><h4>Nebraska City, NE</h4>" + 
			"	<div id='indent'><strong>Nebraska City - Fly Ash</strong></div>" +
			"</div>" +
			"<br />" +
			"<div><h4>Sales Representative</h4>" +
			"	<div id='indent'><strong>Brady Pryor</strong><br />(785)267-1996<br /><a href='mailto:brady.pryor@ashgroveresources.com'>brady.pryor@ashgroveresources.com</a></div>" +
			"</div>";
		}
		//== OKLAHOMA ==//
		else if (locCity == "OklahomaCity") {
			document.getElementById("stateInfo").innerHTML = 
			"<div><h4>Oklahoma City, OK</h4>" + 
			"	<div id='indent'><strong>Oklahoma City Terminal - Fly Ash</strong></div>" +
			"</div>" +
			"<br />" +
			"<div><h4>Ash Grove Cement Sales Representatives</h4>" +
			"	<div id='indent'><strong>Jared Ryker</strong><br />(405)255-6584<br /><a href='mailto:jared.ryker@ashgrove.com'>jared.ryker@ashgrove.com</a></div>" +
			"</div>";
		}
		else if (locCity == "Panama") {
			document.getElementById("stateInfo").innerHTML = 
			"<div><h4>Panama, OK</h4>" + 
			"	<div id='indent'><strong>AES Shady Point - Fluidized Bed Ash</strong></div>" +
			"</div>" +
			"<br />" +
			"<div><h4>Geotechnical Sales Representatives</h4>" +
			"	<div id='indent'><strong>Bruce Schwan</strong><br />(479)719-4081<br /><a href='mailto:bruce.schwan@ashgroveresources.com'>bruce.schwan@ashgroveresources.com</a></div>" +
			"</div>";
		}
		//== ARKANSAS ==//
		else if (locCity == "Foreman") {
			document.getElementById("stateInfo").innerHTML = 
			"<div><h4>Foreman, AR</h4>" + 
			"	<div id='indent'><strong>Ash Grove Cement Plant<br />Plant - Ash Grove Durabase&reg;</strong></div>" +
			"</div>" +
			"<br />" +
			"<div><h4>Geotechnical Sales Representatives</h4>" +
			"	<div id='indent'><strong>Bruce Schwan</strong><br />(479)719-4081<br /><a href='mailto:bruce.schwan@ashgroveresources.com'>bruce.schwan@ashgroveresources.com</a></div>" +
			"</div>";
		}
		//== TEXAS ==//
		else if (locCity == "Midlothian") {
			document.getElementById("stateInfo").innerHTML = 
			"<div><h4>Midlothian, TX</h4>" + 
			"	<div id='indent'><strong>Ash Grove Cement Plant<br /> Plant - Ash Grove Durabase&reg;</strong></div>" +
			"</div>" +
			"<br />" +
			"<div><h4>Geotechnical Sales Representatives</h4>" +
			"	<div id='indent'><strong>Bill Mogridge</strong><br />(817)734-8568<br /><a href='mailto:bill.mogridge@ashgroveresources.com'>bill.mogridge@ashgroveresources.com</a></div>" +
			"</div>";
		}
		
	}
	else  {
		alert('Data not found!');
	}
}
/*-- Map Functionality >> END ----------------------------------------*/


/*-- "Did You Know" Random Display >> START ----------------------------------------*/
function didYouKnow()
{
	quotes=new Array()
		
	quotes[0]=	'<div id=random>Both Class C Fly Ash and Ash Grove Durabase® are effective in reducing the moisture content of soils to levels suitable to achieve proper compaction. They can reduce the moisture content of soils by up to thirty percent (30%) and sometimes even more. Both can accomplish this in just a few hours?</div>'
	quotes[1]=	'<div id=random>Coal-fired power plants produce Fly Ash as a by product of the combustion process. The Fly Ash consists of the inorganic matter present in the coal that has been fused (melted) during the combustion of the coal, solidified while suspended in the exhaust gases and collected from the combustion air-stream as it exits the power plant?</div>'
	quotes[2]=	'<div id=random>Stabilization with Class C Fly Ash or Ash Grove Durabase® can be a cost effective solution for stabilizing even poor quality aggregates?</div>'
	quotes[3]=	'<div id=random>Stabilization of pavement subgrade with either Class C Fly Ash or Ash Grove Durabase® can provide a significant increase in strength within a stabilized section?</div>'
	quotes[4]=	'<div id=random>This past year Ash Grove Resources saw a 22% increase in the sales of our products making Ash Grove Resources, LLC a leader in the construction material industry throughout the Midwest?</div>'
	quotes[5]=	'<div id=random>Ash Grove Resources supplies the industry with Fly Ash out of the AES Shady Point plant located in Panama, Oklahoma. We are looking forward to working with you and satisfying your Fly Ash needs out of this location. Please contact Rene Thompson, Dispatcher at 918-721-5711 or Bruce Schwan, Sr. Sales Representative at 479-719-4081.</div>'
	
	whichquote=Math.floor(Math.random()*(quotes.length))
	document.write(quotes[whichquote])
}
/*-- "Did You Know" Random Display >> END ----------------------------------------*/

/*-- Contact Form Validation >> START -------------------*/
function  contactValid(val, id) {
	//Get the values from the Calculation Tool
	var one = document.contact1.elements[0].value;
	var two = document.contact1.elements[1].value;
	//Check that required values were submitted
	if ( one == null || one == "" || two == null || two == "" ){
		if ( one == null || one == "" ){
			document.getElementById("error1").innerHTML = "(Name) is required.";
			document.getElementById("error1").className = "show";
		}
		else {
			document.getElementById("error1").className = "hide";
		}
		if ( two == null || two == "" ){
			document.getElementById("error2").innerHTML = "(Email) is required.";
			document.getElementById("error2").className = "show";
		}
		else {
			document.getElementById("error2").className = "hide";
		}
		return false
	}
	else {
		document.contact1.submit();
	}

	return
}
/*-- Conatact Form Validation >> END ---------------------------*/

/*-- Quotation Request Form Validation >> START -------------------*/
// Radio Button (group) Validation
function valButton(btn) {
    var cnt = -1;
    for (var i=btn.length-1; i > -1; i--) {
        if (btn[i].checked) {cnt = i; i = -1;}
    }
    if (cnt > -1) return btn[cnt].value;
    else return null;
}

// Form Validation
function  quoteValid(val, id) {
	//Get the values from the Quotation Request Form
	/*var one = document.quotation.elements[0].value;
	var two = document.quotation.elements[1].value;
	var three = document.quotation.elements[2].value;
	var four = document.quotation.elements[3].value;
	var five = document.quotation.elements[4].value;
	var six = document.quotation.elements[5].value;
	var seven = document.quotation.elements[6].value;
	var eight = document.quotation.elements[7].value;
	var nine = document.quotation.elements[8].value;
	var ten = document.quotation.elements[9].value;
	var eleven = document.quotation.elements[10].value;
	var twelve = document.quotation.elements[11].value;
	var thirteen = document.quotation.elements[12].value;
	var fourteen = document.quotation.elements[13].value;
	var fifteen = document.quotation.elements[14].value;
	var sixteen = document.quotation.elements[15].value;*/
	
	var one = document.getElementById("name").value;
	var two = document.getElementById("jtitle").value;
	var three = document.getElementById("company").value;
	var four = document.getElementById("address").value;
	var five = document.getElementById("city").value;
	var six = document.getElementById("state").value;
	var seven = document.getElementById("zip").value;
	var eight = document.getElementById("work_phone").value;
	var nine = document.getElementById("fax").value;
	var ten = document.getElementById("email").value;
	//var eleven = document.getElementById("job_type").value;
	var eleven = valButton(document.quotation.job_type);
	var twelve = document.getElementById("job_name").value;
	var thirteen = document.getElementById("job_loc").value;
	var fourteen = document.getElementById("job_startDate").value;
	var fifteen = document.getElementById("job_tons").value;
	var sixteen = document.getElementById("comments").value;
	
	//Check that required values were submitted
	if ( one == null || one == "" || three == null || three == "" || five == null || five == "" || six == null || six == "" || eight == null || eight == "" || ten == null || ten == "" || eleven == null || eleven == "" || twelve == null || twelve == "" || thirteen == null || thirteen == "" || fourteen == null || fourteen == "" || fifteen == null || fifteen == "" ){
		if ( one == null || one == "" ){
			document.getElementById("error").innerHTML = "(Name) is required.";
			document.getElementById("error").className = "show";
			return false
		}
		else {
			document.getElementById("error").className = "hide";
		}
		if ( three == null || three == "" ){
			document.getElementById("error").innerHTML = "(Company) is required.";
			document.getElementById("error").className = "show";
			return false
		}
		else {
			document.getElementById("error").className = "hide";
		}
		if ( five == null || five == "" ){
			document.getElementById("error").innerHTML = "(City) is required.";
			document.getElementById("error").className = "show";
			return false
		}
		else {
			document.getElementById("error").className = "hide";
		}
		if ( six == null || six == "" ){
			document.getElementById("error").innerHTML = "(State) is required.";
			document.getElementById("error").className = "show";
			return false
		}
		else {
			document.getElementById("error").className = "hide";
		}
		if ( eight == null || eight == "" ){
			document.getElementById("error").innerHTML = "(Work Phone) is required.";
			document.getElementById("error").className = "show";
			return false
		}
		else {
			document.getElementById("error").className = "hide";
		}
		if ( ten == null || ten == "" ){
			document.getElementById("error").innerHTML = "(Email) is required.";
			document.getElementById("error").className = "show";
			return false
		}
		else {
			document.getElementById("error").className = "hide";
		}
		if ( eleven == null || eleven == "" ){
			document.getElementById("error").innerHTML = "(Job Type) is required.";
			document.getElementById("error").className = "show";
			return false
		}
		else {
			document.getElementById("error").className = "hide";
		}
		if ( twelve == null || twelve == "" ){
			document.getElementById("error").innerHTML = "(Job Name) is required.";
			document.getElementById("error").className = "show";
			return false
		}
		else {
			document.getElementById("error").className = "hide";
		}
		if ( thirteen == null || thirteen == "" ){
			document.getElementById("error").innerHTML = "(Job Location) is required.";
			document.getElementById("error").className = "show";
			return false
		}
		else {
			document.getElementById("error").className = "hide";
		}
		if ( fourteen == null || fourteen == "" ){
			document.getElementById("error").innerHTML = "(Estimated Start Date) is required.";
			document.getElementById("error").className = "show";
			return false
		}
		else {
			document.getElementById("error").className = "hide";
		}
		if ( fifteen == null || fifteen == "" ){
			document.getElementById("error").innerHTML = "(Estimated Tons) is required.";
			document.getElementById("error").className = "show";
			return false
		}
		else {
			document.getElementById("error").className = "hide";
		}
		//alert("generic error1 - " + eleven);
		return false
	}
	else {
		document.quotation.submit();
	}
	//alert("generic error2");
	return
}
/*-- Quotation Request Form Validation >> END ---------------------------*/

/*-- Caluctations Form Validation/Formula >> START -------------*/
function calcValid(val , id) {
	if(isNaN(val)) {
		document.getElementById("errors").innerHTML = "Not a valid number!";
		document.getElementById(id).style.backgroundColor="yellow";
		document.getElementById("text").className = "hide";
	}
	else {
		document.getElementById("errors").innerHTML = "&nbsp;";
		document.getElementById(id).style.backgroundColor="white";
		var negative = val.indexOf('-')+1;
		if (negative > 0) {
			val.toString();
			val = val.replace("-","");
			val = parseInt(val);
			document.getElementById("errors").innerHTML = "Negative values are not permitted. <br />The (-) has been removed.";
			document.getElementById(id).value = val;
			document.getElementById("text").className = "hide";
		}
		else {
			
		}
	}
}

function  calculate() {
	//Get the values from the Calculation Tool
	var one = document.calcForm1.elements[0].value;
	var two = document.calcForm1.elements[1].value;
	var three = document.calcForm1.elements[2].value;
	var four = document.calcForm1.elements[3].value;
	//Check that values entered are valid numeric values
	if ( one == null || one == "" || two == null || two == "" || three == null || three == "" || four == null || four == "" ) {
		document.getElementById("errors").innerHTML = "<h3>ALL FIELDS ARE REQUIRED</h3>Please correct the appropriate field(s) in the form to the left by entering a valid positive number.";
		document.getElementById("text").className = "hide";
		return;
	}
	else {
		if ( isNaN(one) || isNaN(two) || isNaN(three) || isNaN(four) ){
			document.getElementById("errors").innerHTML = "Please correct the appropriate field(s) in the form to the left by entering a valid positive number.";
			document.getElementById("text").className = "hide";
			return;
		}
		else {
			if (four <= 0 || four >= 100) {
				document.getElementById("errors").innerHTML = "The value entered in the percentage field must be a number between 1 and 99.";
				document.getElementById("text").className = "hide";
			return;
			}
			else {
				//Apply appropiate formula
				var thickness = two / 12;
				var finalThickness = thickness.toFixed(2);
				//alert(finalThickness);
				var percent = parseFloat(four);
				percent = percent.toFixed(2);
				percent = percent/100;
				//alert(percent);
				var prod = (one * finalThickness * three * percent)/2000;
				prod = prod.toFixed(2);
				//alert(prod);
				prod = Math.round(prod);
			
				//Format Thousands with commas
				function formatTonnage(num) {
					num = num.toString().replace(/\$|\,/g,'');
					if(isNaN(num))
					num = "0";
					sign = (num == (num = Math.abs(num)));
					num = Math.floor(num*100+0.50000000001);
					//cents = num%100;
					num = Math.floor(num/100).toString();
					for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
					num = num.substring(0,num.length-(4*i+3))+','+
					num.substring(num.length-(4*i+3));
					return (((sign)?'':'-') + num);
				}
			}
		
			document.getElementById("finalVal").innerHTML = formatTonnage(prod) + " tons";
			document.getElementById("text").className = "show";
		}
	}
}
/*-- Caluctations Form Validation/Formula >> END --------------------------------*/