var form, labels;

function contactusInit() {
	var els, vals, i, j;
	
	form = document.forms[0];
	labels = buildLabelsObj(form);
		
	/* Company */	
	form.txbCompany.validators = [
		{
			validator: notBlankValidator,
			errorKey: "txbCompanyEmpty"
		}
	];
	
	/* First Name */
	form.txbFirst.validators = [
		{
			validator: notBlankValidator,
			errorKey: "txbFirstEmpty"
		}
	];
	
	/* Last Name */
	form.txbLast.validators = [
		{
			validator: notBlankValidator,
			errorKey: "txbLastEmpty"
		}
	];
	
	/* Email */
	form.txbEmail.validators = [
		{
			validator: notBlankValidator,
			errorKey: 'txbEmailEmpty'
		},
		{
			validator: emailValidator,
			errorKey: 'txbEmailInvalid'
		}
	];
	
	/* Instead of assigning the same errorHandler to each element manually */
	els = form.elements;
	for (i = 0; i < els.length; i++) {
		vals = els[i].validators;
		// els[i].setAttribute('autocomplete','off'); /* fix firefox exception: http://geekswithblogs.net/shahedul/archive/2006/08/14/87910.aspx */
		 
		if (vals) {
			for (j = 0; j < vals.length; j++) {
				vals[j].reset = resetHighlights;
				vals[j].errorHandler = displayAlertAndHightlightError;
			}
		}
	}
		
	form.onsubmit = componentValidation;
	
	var cancel = document.getElementById("btnCancel"); 
  if (cancel) 
    cancel.onclick = function() { resetMyForm(); return false; } ;
    
  if(typeof(contactUsInitFollowup)=="function") contactUsInitFollowup(); 
}

var contactUsInitFollowup;
if(typeof(window.onload)=="function") contactUsInitFollowup = window.onload;
window.onload = contactusInit;

/* addEvent(window, 'load', init); */
