
/*
function txtFieldInit() {
	try {
		var inputs = document.getElementsByTagName('input');
		for (var i = 0; i < inputs.length; i++) {
			if (inputs[i].attributes.getNamedItem('type').value == 'text') {
				if( inputs[i].addEventListener ) {
					inputs[i].addEventListener('focus', txtFieldFocus, false);
					inputs[i].addEventListener('blur', txtFieldBlur, false);
				} else if( oWin.attachEvent ) {
					inputs[i].attachEvent('onfocus', txtFieldFocus);
					inputs[i].attachEvent('onblur', txtFieldBlur);
				}
			}
		}
	} catch (e) {}
}*/

function txtFieldFocus() {
	this.className = 'txtFieldFocus';
}

function txtFieldBlur() {
	this.className = 'txtField';
}

function validateForm() {
	
	var errors = new Array();
	
	if (document.getElementById('txtName').value.length < 2) {
		errors.push('Du må fylle inn navn');
		document.getElementById('txtName').className = 'txtFieldError';
	}
	if (document.getElementById('txtPhone').value.length < 5) {
		errors.push('Du må fylle inn telefonnummer');
		document.getElementById('txtPhone').className = 'txtFieldError';
	}
	if (document.getElementById('txtEmail').value.length < 6) {
		errors.push('Du må fylle inn e-postadresse');
		document.getElementById('txtEmail').className = 'txtFieldError';
	}
	
	if (errors.length) {
		alert("- " + errors.join("\n- "));
		return false;
	}
	
	return true;
	
}

var oWin = window;
if( oWin.addEventListener ) {
	oWin.addEventListener('load', txtFieldInit, false);
} else if( oWin.attachEvent ) {
	oWin.attachEvent('onload', txtFieldInit);
}
