// Check the form before submitting

var toldAboutScm = false

function CheckCtrl(obj,ok)
{
	if (obj.value=="")
	{
		if (!ok) obj.focus
		obj.style.backgroundColor = '#ffff80'
		return false
	}
	else
	{
		obj.style.backgroundColor = '#ffffff'
		return true
	}
}

function CheckForm ()
{
	ok = true
	if (!CheckCtrl(document.frmDownload.name, ok)) ok = false
	if (!CheckCtrl(document.frmDownload.title, ok)) ok = false
	if (!CheckCtrl(document.frmDownload.company, ok)) ok = false
	if (!CheckCtrl(document.frmDownload.address1, ok)) ok = false
	if (!CheckCtrl(document.frmDownload.city, ok)) ok = false
	if (!CheckCtrl(document.frmDownload.state, ok)) ok = false
	if (!CheckCtrl(document.frmDownload.postcode, ok)) ok = false
	if (!CheckCtrl(document.frmDownload.country, ok)) ok = false
	if (!CheckCtrl(document.frmDownload.email, ok)) ok = false
	if (!CheckCtrl(document.frmDownload.phone, ok)) ok = false
	if (!CheckCtrl(document.frmDownload.foundby, ok)) ok = false
	if (!CheckCtrl(document.frmDownload.current, ok)) ok = false
	if (!CheckCtrl(document.frmDownload.interest, ok)) ok = false
	if (!CheckCtrl(document.frmDownload.timescale, ok)) ok = false

	if (document.frmDownload.title.value == "Other")
	{
		if (!CheckCtrl(document.frmDownload.othertitle, ok)) ok = false
	}
	if (document.frmDownload.foundby.value == "Other" || document.frmDownload.foundby.value == "Search Engine")
	{
		if (!CheckCtrl(document.frmDownload.otherfoundby, ok)) ok = false
	}
	if (document.frmDownload.current.value == "Other")
	{
		if (!CheckCtrl(document.frmDownload.othercurrent, ok)) ok = false
	}
	if (document.frmDownload.timescale.value == "Other")
	{
		if (!CheckCtrl(document.frmDownload.othertimescale, ok)) ok = false
	}
	
	if (!ok)
	{
		alert('Please provide the missing details\nin the highlighted boxes.')
	}

	if (!toldAboutScm && document.frmDownload.interest.value == "Only Schematics")
	{
		sMsg =        "You have indicated that you are only interested in Schematic Capture.\n\n"
		sMsg = sMsg + "Please note that the Pulsonix demo download is a working demonstration\n"
		sMsg = sMsg + "of the full Pulsonix product, and not an unlimited Schematic Capture\n"
		sMsg = sMsg + "product (the 'Free Schematic' option was discontinued some time ago).\n\n" 	
		sMsg = sMsg + "You may of course still continue with the download if you wish, for\n"
		sMsg = sMsg + "example to evaluate the product before purchasing, or for 'small'\n"
		sMsg = sMsg + "designs of up to 100 pins."
		alert(sMsg)
		toldAboutScm = true
	}
	return ok
}

