/*-------------------------------------------------------------------------------
	Execute the following functions when the document has fully loaded
-------------------------------------------------------------------------------*/

addLoadEvent(function() {
	ValidateForm();
	ValidateEmailForm();
	EmailInput();
	inputLinkHover();
});


/*-------------------------------------------------------------------------------
	Validate the registration form upon submit
-------------------------------------------------------------------------------*/

function ValidateForm() {
	
	var form = $('searchForm');
	
	if (!form) return;
	form.onsubmit = function () {
		if (trim($('inputCompany')).value == '' && trim($('inputLocation')).value == '') {
			alert('Please enter your search term');
			$('inputCompany').focus();
			return false;
		}
		return true;
	}
}

function ValidateEmailForm() {
	var form = $('statusUnknown_emailForm');
	if (!form) return;
	form.onsubmit = function () {
		if (!ValidateSubstance($('email'),'Please enter your email address'))	return false;
		if (!ValidateEmail($('email'))) return false;
		return true;
	}
}

function EmailInput() {
	var form = $('statusUnknown_emailForm');
	if (!form) return;
	
	if ($('email').value == 'Your email address here') {
		$('email').onclick = function () {
			$('email').value = '';
		}
	}
}

function inputLinkHover() {
	var inputs = document.getElementsByTagName('input');

	for (var i = 0; i < inputs.length; i++) {
		if (hasClass(inputs[i], 'inputLink')) {

			inputs[i].onmouseover = function () {
				addClass(this, 'inputLinkHover');
			};

			inputs[i].onmouseout = function () {
				removeClass(this, 'inputLinkHover');
			};
		}
	}
}

