<!-- Begin

function validateFree()
{
	var temp, test;
	if(!anyChecked("agree"))
	{
		alert("To continue, you must read and agree to the Terms of Use.");
		return false;
	}
	if(!validateText("company", "Company/Gov. Agency Name")) return false;
	if(!validateText("contact", "Contact Name")) return false;
	if(!validateText("email", "e-Mail address")) return false;
	if(!validateText("workphone", "Work Phone Number"))	return false;
	if(!validateNonBlank("macaddress", "MAC Address", 12, 12)) return false;
	if(!validateAlt("osid", "Program Version"))	return false;

	return true;
}
function validateNonFree()
{
	if(!validateCert(document.getElementById("certcode"),"Registration Code")) return false;
	if(!validateNumber("numusers", "Number of concurrent users required", 1, 100)) return false;
	if(!validateAlt("needocr", "Will you require the OCR server program")) return false;
	if(!validateAlt("needsupp", "Will you require a one year support and upgrade contract")) return false;
	if(document.getElementById("needsuppyes").checked && !validateAlt("autoext", "Will you require automatic extension to your support contract"))	return false;
	return true;
}
function doValidation(form)
{
	var rs = validateFree();
	if(rs && action == 'purchase') rs = validateNonFree();

	if(rs)
	{
		form.action = (action == "purchase"? "https": "http") + "://the-repository.net/cgi-bin/rep/freetrialreq";
		actor.name = "action";
		actor.value = action;
	}
	return rs;
}
function calculate()
{
	var elt=document.getElementById("totalcost");
	var cert=document.getElementById("certcode").value;
	elt.value = "";
	elt.size = 10;
	elt.style.visibility = "visible";
	document.getElementById("ocrcost").value = "";
	document.getElementById("suppcost").value = "";
	document.getElementById("usercost").value = "";


	var nm=parseInt(document.getElementById("numusers").value);
	if(isNaN(nm) || nm < 1)	nm = 0;
	if (nm > 100)
	{
		elt.style.visibility = "hidden";
		elt.size = 1;	
		document.getElementById("visible_salestax").value = "Contact us for quote on > 100 users";
		return;	
	}

	var tot = (nm>50? 50*300+(nm-50)*200: nm*300);
	document.getElementById("usercost").value = tot;
	var needOcr = (anyChecked("needocr") && document.getElementById("needocryes").checked); 
	if(needOcr)
	{
		tot += 800;
		document.getElementById("ocrcost").value = "800";
	}

	var tax = (state == "98" || state == "99"? tot*(taxRate/100): 0);
	var taxStr = asString(tax, 2);
	//alert ("state="+state+",tax="+tax+",taxStr="+taxStr);

	if(anyChecked("needsupp") && document.getElementById("needsuppyes").checked)
	{
		var incr = (nm>2? 45*nm: 100)+(needOcr? 120: 0);
		if (cert != "") incr /= 2;
		document.getElementById("suppcost").value = incr;
		tot += incr;
	}
	tot = tot+tax;

	elt.value = asString(tot, 2);
	document.getElementById("visible_salestax").value = (tax<=0? "": " incl $"+taxStr+ " sales tax @ "+taxRate+"%");	
	document.getElementById("salestax").value = taxStr;	
}

// end -->

