// JavaScript Document

// global variable for special characters validator
var iChars = "!@#$%^&*()+=-[]\\\';,/{}|\":<>?`~";

// 	Topsoil:
//	1 ton cover 120 sq ft @ 2" deep
//	Chart up to 10 tons for homeowners or multiple for calc
//  Note: TS stands for TopSoil (Equine Blends, Ball Diamond and Green Roof are all same calculation)

function TScalculate(TSsqFt,TSdepth) {
	document.getElementById('TSalert').innerHTML = '';
	if (TSsqFt < 20){
		document.getElementById('TSalert').innerHTML = '<br />20 Sq. Ft. Minimum';
		document.TScalc.sqft.value = '20';
		document.TScalc.total.value = '';
		return false;
	}
	for (var i = 0; i < document.TScalc.sqft.value.length; i++) {
		if (iChars.indexOf(document.TScalc.sqft.value.charAt(i)) != -1) {
			document.getElementById('TSalert').innerHTML = '<br />Please remove any commas or special characters';
			document.TScalc.total.value = '';
			return false;
		}
    }

var TSton = TSsqFt * TSdepth;
var TStotal = Math.round(TSton*Math.pow(10,1))/Math.pow(10,1);
document.TScalc.total.value = TStotal;
document.getElementById('TSquote').innerHTML = '<form action="contact.php" method="get"><input name="material" type="hidden" value="Topsoil" /><input type="hidden" name="amount" value="' + TStotal + '" /><input type="submit" value="Request Pricing" id="button" /></form>';
return false
}


//	End Topsoil


// 	Equine Blends:
//	1 ton cover 120 sq ft @ 2" deep
//  Note: EB stands for Equine Blends (Equine Blends, Ball Diamond and Green Roof are all same calculation)

function EBcalculate(EBsqFt,EBdepth) {
	document.getElementById('EBalert').innerHTML = '';
	if (EBsqFt < 20){
		document.getElementById('EBalert').innerHTML = '<br />20 Sq. Ft. Minimum';
		document.EBcalc.sqft.value = '20';
		document.EBcalc.total.value = '';
		return false;
	}
	for (var i = 0; i < document.EBcalc.sqft.value.length; i++) {
		if (iChars.indexOf(document.EBcalc.sqft.value.charAt(i)) != -1) {
			document.getElementById('EBalert').innerHTML = '<br />Please remove any commas or special characters';
			document.EBcalc.total.value = '';
			return false;
		}
    }

var EBton = EBsqFt * EBdepth;
var EBtotal = Math.round(EBton*Math.pow(10,1))/Math.pow(10,1);
document.EBcalc.total.value = EBtotal;
document.getElementById('EBquote').innerHTML = '<form action="contact.php" method="get"><input name="material" type="hidden" value="Equine_Blends" /><input type="hidden" name="amount" value="' + EBtotal + '" /><input type="submit" value="Request Pricing" id="button" /></form>';
return false
}

//	End Equine Blends

// 	Ball Diamond:
//	1 ton cover 120 sq ft @ 2" deep
//  Note: BD stands for Ball Diamond (Equine Blends, Ball Diamond and Green Roof are all same calculation)

function BDcalculate(BDsqFt,BDdepth) {
	document.getElementById('BDalert').innerHTML = '';
	if (BDsqFt < 20){
		document.getElementById('BDalert').innerHTML = '<br />20 Sq. Ft. Minimum';
		document.BDcalc.sqft.value = '20';
		document.BDcalc.total.value = '';
		return false;
	}
	for (var i = 0; i < document.BDcalc.sqft.value.length; i++) {
		if (iChars.indexOf(document.BDcalc.sqft.value.charAt(i)) != -1) {
			document.getElementById('BDalert').innerHTML = '<br />Please remove any commas or special characters';
			document.BDcalc.total.value = '';
			return false;
		}
    }

var BDton = BDsqFt * BDdepth;
var BDtotal = Math.round(BDton*Math.pow(10,1))/Math.pow(10,1);
document.BDcalc.total.value = BDtotal;
document.getElementById('BDquote').innerHTML = '<form action="contact.php" method="get"><input name="material" type="hidden" value="Ball_Diamond" /><input type="hidden" name="amount" value="' + BDtotal + '" /><input type="submit" value="Request Pricing" id="button" /></form>';
return false
}

//	End Ball Diamond

// 	Green Roof:
//	1 ton cover 120 sq ft @ 2" deep
//  Note: GR stands for Green Roof (Equine Blends, Ball Diamond and Green Roof are all same calculation)

function GRFcalculate(GRFsqFt,GRFdepth) {
	document.getElementById('GRFalert').innerHTML = '';
	if (GRFsqFt < 20){
		document.getElementById('GRFalert').innerHTML = '<br />20 Sq. Ft. Minimum';
		document.GRFcalc.sqft.value = '20';
		document.GRFcalc.total.value = '';
		return false;
	}
	for (var i = 0; i < document.GRFcalc.sqft.value.length; i++) {
		if (iChars.indexOf(document.GRFcalc.sqft.value.charAt(i)) != -1) {
			document.getElementById('GRFalert').innerHTML = '<br />Please remove any commas or special characters';
			document.GRFcalc.total.value = '';
			return false;
		}
    }

var GRFton = GRFsqFt * GRFdepth;
var GRFtotal = Math.round(GRFton*Math.pow(10,1))/Math.pow(10,1);
document.GRFcalc.total.value = GRFtotal;
document.getElementById('GRFquote').innerHTML = '<form action="contact.php" method="get"><input name="material" type="hidden" value="Green_Roof" /><input type="hidden" name="amount" value="' + GRFtotal + '" /><input type="submit" value="Request Pricing" id="button" /></form>';
return false
}

//	End Green Roof


//	Mulch
//	1 cubic yard covers 100sq ft 3" deep
//  Note: MU stands for MUlch

function MUcalculate(MUsqFt) {
	document.getElementById('MUalert').innerHTML = '';
	if (MUsqFt < 10){
		document.getElementById('MUalert').innerHTML = '<br />10 Sq. Ft. Minimum';
		document.MUcalc.sqft.value = '10';
		document.MUcalc.total.value = '';
		return false;
	}
	for (var i = 0; i < document.MUcalc.sqft.value.length; i++) {
		if (iChars.indexOf(document.MUcalc.sqft.value.charAt(i)) != -1) {
			document.getElementById('MUalert').innerHTML = '<br />Please remove any commas or special characters';
			document.MUcalc.total.value = '';
			return false;
		}
    }

var MUyards = MUsqFt * .01;
var MUtotal = Math.round(MUyards*Math.pow(10,1))/Math.pow(10,1);
document.MUcalc.total.value = MUtotal;
document.getElementById('MUquote').innerHTML = '<form action="contact.php" method="get"><input name="material" type="hidden" value="Mulch" /><input type="hidden" name="amount" value="' + MUtotal + '" /><input type="submit" value="Request Pricing" id="button" /></form>';
return false
}

//	End Mulch
	
	
	
//	Greens Mix
//	50 tons per 1000 sq ft gives 12" for new construction
//	25 tons per 1000 sq ft for 6"
//  Note: GM stands for Greens Mix

function GMcalculate(GMsqFt,GMdepth) {
	document.getElementById('GMalert').innerHTML = '';
	if (GMsqFt < 10){
		document.getElementById('GMalert').innerHTML = '<br />10 Sq. Ft. Minimum';
		document.GMcalc.sqft.value = '10';
		document.GMcalc.total.value = '';
		return false;
	}
	for (var i = 0; i < document.GMcalc.sqft.value.length; i++) {
		if (iChars.indexOf(document.GMcalc.sqft.value.charAt(i)) != -1) {
			document.getElementById('GMalert').innerHTML = '<br />Please remove any commas or special characters';
			document.GMcalc.total.value = '';
			return false;
		}
    }

var GMton = GMsqFt * GMdepth;
var GMtotal = Math.round(GMton*Math.pow(10,1))/Math.pow(10,1);
document.GMcalc.total.value = GMtotal;
document.getElementById('GMquote').innerHTML = '<form action="contact.php" method="get"><input name="material" type="hidden" value="Greens_Mix" /><input type="hidden" name="amount" value="' + GMtotal + '" /><input type="submit" value="Request Pricing" id="button" /></form>';
return false
}

//	End Greens Mix



// 	Tee Mix
//	Tee Mix 17 tons per 1000 sq ft for 4" depth
//	Tee Mix 25.5 tons per 1000 sq ft for 6" depth
//  Note: TM stands for Tee Mix

function TMcalculate(TMsqFt,TMdepth) {
	document.getElementById('TMalert').innerHTML = '';
	if (TMsqFt < 10){
		document.getElementById('TMalert').innerHTML = '<br />10 Sq. Ft. Minimum';
		document.TMcalc.sqft.value = '10';
		document.TMcalc.total.value = '';
		return false;
	}
	for (var i = 0; i < document.TMcalc.sqft.value.length; i++) {
		if (iChars.indexOf(document.TMcalc.sqft.value.charAt(i)) != -1) {
			document.getElementById('TMalert').innerHTML = '<br />Please remove any commas or special characters';
			document.TMcalc.total.value = '';
			return false;
		}
    }

var TMton = TMsqFt * TMdepth;
var TMtotal = Math.round(TMton*Math.pow(10,1))/Math.pow(10,1);
document.TMcalc.total.value = TMtotal;
document.getElementById('TMquote').innerHTML = '<form action="contact.php" method="get"><input name="material" type="hidden" value="Tee_Mix" /><input type="hidden" name="amount" value="' + TMtotal + '" /><input type="submit" value="Request Pricing" id="button" /></form>';
return false
}

//	End Tee Mix



//	Gravel
//	Gravel is 17 tons per 1000 sq ft for 4"
//  Note: GR stands for Gravel

function GRcalculate(GRsqFt) {
	document.getElementById('GRalert').innerHTML = '';
	if (GRsqFt < 10){
		document.getElementById('GRalert').innerHTML = '<br />10 Sq. Ft. Minimum';
		document.GRcalc.sqft.value = '10';
		document.GRcalc.total.value = '';
		return false;
	}
	for (var i = 0; i < document.GRcalc.sqft.value.length; i++) {
		if (iChars.indexOf(document.GRcalc.sqft.value.charAt(i)) != -1) {
			document.getElementById('GRalert').innerHTML = '<br />Please remove any commas or special characters';
			document.GRcalc.total.value = '';
			return false;
		}
    }
	
var GRton = GRsqFt * .017;
var GRtotal = Math.round(GRton*Math.pow(10,1))/Math.pow(10,1);
document.GRcalc.total.value = GRtotal;
document.getElementById('GRquote').innerHTML = '<form action="contact.php" method="get"><input name="material" type="hidden" value="Bridge_Gravel_and_Stone" /><input type="hidden" name="amount" value="' + GRtotal + '" /><input type="submit" value="Request Pricing" id="button" /></form>';
return false
}

//	End Gravel



//  Bunker Sand
//	Bunker Sand is 16.7 tons per 1000sq ft for 4" depth
//	Bunker Sand is 25 tons per 1000sq ft for 6" depth
//	Bunker Sand is 33 tons per 1000sq ft for 8" depth
//  Note: BU stands for Bunker Sand

function BUcalculate(BUsqFt,BUdepth) {
	document.getElementById('BUalert').innerHTML = '';
	if (BUsqFt < 10){
		document.getElementById('BUalert').innerHTML = '<br />10 Sq. Ft. Minimum';
		document.BUcalc.sqft.value = '10';
		document.BUcalc.total.value = '';
		return false;
	}
	for (var i = 0; i < document.BUcalc.sqft.value.length; i++) {
		if (iChars.indexOf(document.BUcalc.sqft.value.charAt(i)) != -1) {
			document.getElementById('BUalert').innerHTML = '<br />Please remove any commas or special characters';
			document.BUcalc.total.value = '';
			return false;
		}
    }

	
var BUton = BUsqFt * BUdepth;
var BUtotal = Math.round(BUton*Math.pow(10,1))/Math.pow(10,1);
document.BUcalc.total.value = BUtotal;
document.getElementById('BUquote').innerHTML = '<form action="contact.php" method="get"><input name="material" type="hidden" value="Bunker_Sand" /><input type="hidden" name="amount" value="' + BUtotal + '" /><input type="submit" value="Request Pricing" id="button" /></form>';
return false;
}

// 	End Bunker Sand
