// JavaScript Document


// ================================================================
// IMM091804: Javascript to handle installation estimate calculator
// ----------------------------------------------------------------


function checkNumeric()
{
	// Restrict Countertop area sq. ft. to numbers only
	sKC = new String(event.keyCode);
	sVK = new String("8,9,18,35,36,37,39,46,48,49,50,51,52,53,54,55,56,57,96,97,98,99,100,101,102,103,104,105");
	event.returnValue = (sVK.indexOf(sKC) > -1 ? true : false);
}

function recalcEstimate()
{
	oFrm = document.forms["rateCalc"];
	dEst = Number(oFrm.area.value) * 66.0;
	dEst += (oFrm.cutoutsink.checked == true ? 275.0 : 0.0);
	dEst += (oFrm.cooktop.checked == true ? 150.0 : 0.0);
	dEst += (oFrm.holes.checked == true ? 50.0 : 0.0);
	oFrm.total.value = String(dEst);
}

function consume()
{
	// Restrict final total field to tabbing only
	sKC = new String(event.keyCode);
	event.returnValue = (sKC == "9" ? true : false);
}


// ================================================================

// ================================================================
// IMM091804: Javscript for Contact Us form validation
// ----------------------------------------------------------------
function checkContact()
{
	oFrm = document.forms[1];
	if (oFrm.refer.selectedIndex == 0)
	{
		alert("Please specify how you heard about us.");
		oFrm.refer.focus();
		return false;
	}

	sNme = new String(oFrm.name.value);
	if (sNme.length == 0)
	{
		alert("Please provide your full name before submitting the form.");
		oFrm.name.select();
		return false;
	}

	sPhn = new String(oFrm.phone.value);
	sTel = new String("");
	for (idx = 0; idx < sPhn.length; idx++ )
		if ("0123456789".indexOf(sPhn.substr(idx,1)) > -1)
			sTel += sPhn.substr(idx,1);

	if (sTel.length < 10)
	{
		alert("Please provide a valid telephone number, including area code.");
		oFrm.phone.select();
		return false;
	}

	sCmt = new String(oFrm.comments.value);
	if (sCmt.length == 0)
	{
		alert("Please describe your question or comment before submitting the form.");
		oFrm.comments.select();
		return false;
	}

	return true;
}
// ================================================================
