var timeoutVar = null;

addLoadEvent(function(){document.getElementById('inp_ContactName').focus();});


function updateCaptcha ()
{
	var captchaCtrl = document.getElementById('nospaznImage');
	if (captchaCtrl != null) captchaCtrl.src='/_images/captcha/image.php?tt=' + (new Date().getTime());
	return false;
}

function updateErrorList(errorText)
{
	var errorListCtrl = document.getElementById('ErrorList');
	if (errorListCtrl){
		errorListCtrl.innerHTML = errorText;
		errorListCtrl.style.display = (errorText == '') ? 'none' : 'table-cell';
	}
}

function resetButtonClicked ()
{
	updateErrorList('');
	updateCaptcha();
	return true;
}

function sendButtonClicked ()
{
	var postVars = getFormPostVars('ContactInfo');
	if (postVars.length){
		postVars = 'fn=sendContactInfo&' + postVars;
		timeoutVar=setTimeout("dimControls('ContactInfoTable',timeoutVar)", 420);
		submitAjaxPostRequest('/Contact/index.php', sendButtonClickedCallback, postVars);
	}
	return false;
}

function sendButtonClickedCallback (requestText)
{
	undimControls('ContactInfoTable', timeoutVar);
	updateErrorList(requestText);
	if (requestText.length == 0)
	{
		alert('Your information has been submitted. Someone will be getting in touch with you shortly.')
		var securityCodeCtrl = document.getElementById('nospaznInput');
		if (securityCodeCtrl) securityCodeCtrl.value = '';
		checkAll('ContactInfo', 'COJ-', false);
		updateCaptcha ();
	}
}



