function _form_validate()
{
	var i, j, k;
	var toValidate = getElementsByTagAndClassName('form', 'formtovalidate');
	var els;
	var ret;
	ret = true;
	for (i = 0; i < toValidate.length; i++)
	{
		els = getElementsByTagAndClassName('input', 'required', toValidate[i]);
		for (j = 0; j < els.length; j++)
		{
			if (els[j].value.length <= 0)
			{
				ret = false;
				setNodeAttribute(els[j], 'style', 'margin: 0px; border: 2px solid #da3d3d;');
				connect(els[j], 'onblur', function(){
					if (this.value.length > 0)
					{
						setNodeAttribute(this, 'style', 'margin: 1px; border: 1px solid #ccc;');
					}else{
						setNodeAttribute(this, 'style', 'margin: 0px; border: 2px solid #da3d3d;');
					}
				});
			}else
			{
				setNodeAttribute(els[j], 'style', 'margin: 1px; border: 1px solid #ccc;');
			}
		}
		els = getElementsByTagAndClassName('input', 'wasRequired', toValidate[i]);
		for (j = 0; j < els.length; j++)
		{
			setNodeAttribute(els[j], 'style', 'margin: 1px; border: 1px solid #ccc;');
			disconnectAll(els[j], 'onblur');
		}
	}

	if (!ret)
	{
		els = getElementsByTagAndClassName('div', 'formSubmitErrorMessage');
		for (i = 0; i < els.length; i++)
		{
			els[i].innerHTML = 'There was a problem processing your form.<br />Please correct the indicated fields and resubmit.';
		}
	}
	return ret;
}

addLoadEvent(function(){
	if ($('other_text') && $('referral1'))
	{
		$('other_text').disabled = 'disabled';
		setStyle('other_text', {'font-style': 'italic'});
		$('other_text').value = '< Other >';
		connect($('referral1'), 'onchange', function(){
			if (this.options[this.selectedIndex].value == 'Other' || this.options[this.selectedIndex].value == 'Internet - Other search engine/website link')
			{
				setStyle('other_text', {'font-style': ''});
				$('other_text').value = '';
				$('other_text').disabled = '';
			}
			else
			{
				setStyle('other_text', {'font-style': 'italic'});
				$('other_text').value = '< Other >';
				$('other_text').disabled = 'disabled';
			}
		});
	}
});

addLoadEvent(function(){
	if ($('InformationRequestSteelENotes') && $('emailAddress'))
	{
		if ($('conditionalEmailRequired'))
		{
			setStyle('conditionalEmailRequired', {'display': 'inline'});
		}

		connect('InformationRequestSteelENotes', 'onclick', function(){
			if (this.checked)
				setNodeAttribute('emailAddress', 'class', 'required');
			else
				setNodeAttribute('emailAddress', 'class', 'wasRequired');
		});

	}
});

