// JavaScript Document
function ValidateForm()
{
	// Turn off validation for development
	// return true;
	
	if (IsEmpty(document.fSCAT_order.sName.value) || 
		IsEmpty(document.fSCAT_order.sPhone.value) ||
		IsEmpty(document.fSCAT_order.sEmail.value) ||
		IsEmpty(document.fSCAT_order.sAddress.value) ||
		IsEmpty(document.fSCAT_order.sDate.value) ||
		document.fSCAT_order.sOS.selectedIndex == 0
	)
	{
		alert("The General information fields at the top of the page must all be completed\n" +
			"before submitting an order. Please complete the missing information and \n" +
			"submit the order again.");
		return false;
	}
	if (!IsValidEmail(document.fSCAT_order.sEmail.value))
	{
		alert("The email address provided is not valid. Please provide a valid email address\n" +
			"and then submit the order again.");
		return false;
	}
	if (!document.fSCAT_order.bTerms.checked)
	{
		alert("You must agree to the Terms and Conditions before submitting an order.\n" +
			"To do this simply click the Terms and Conditions checkbox, and then submit\n" +
			"the order again.");
		return false;
	}
	
	return true;
}
function SubmitOrder()
{
	if (!ValidateForm())
		return false;
	
	return true;
}

function UpdateField(sField, sValue)
{
	var domObj = new GetDomObj(sField);
	domObj.obj.innerHTML = "$" + sValue;
}
function UpdateTotal()
{
	var iTotal = GetTotalCost();
	UpdateField("sTotal", iTotal);
	document.fSCAT_order.sTotalHidden.value = "$" + iTotal;
}
function GetTotalCost()
{
	return 150 +
		((document.fSCAT_order.sBackup.checked) ? 80 : 0) + 
		((document.fSCAT_order.sPest.checked) ? 80 : 0) + 
		((document.fSCAT_order.sVirus.checked) ? 80 : 0) + 
		((document.fSCAT_order.sFirewall.checked) ? 80 : 0) + 
		((document.fSCAT_order.sSecCopy.checked) ? 120 : 0) +
		((document.fSCAT_order.sCDWriter.checked) ? 120 : 0) +
		((document.fSCAT_order.sRAM.checked) ? 125 : 0) +
		((document.fSCAT_order.sHDD.checked) ? 175 : 0) +
		((document.fSCAT_order.sCourierTo.checked) ? 10 : 0) +
		((document.fSCAT_order.sCourierFrom.checked) ? 10 : 0);
}
function GetCDWriterCost()
{
	return ((document.fSCAT_order.sCDWriterSelect.selectedIndex == 0) ? 75 : 180);
}
function GetRAMCost()
{
	return ((document.fSCAT_order.sRAMSelect.selectedIndex == 0) ? 75 : 
		((document.fSCAT_order.sRAMSelect.selectedIndex == 1) ? 85 : 125));
}
function GetHDDCost()
{
	return ((document.fSCAT_order.sHDDSelect.selectedIndex == 0) ? 125 : 175);
}
