// JavaScript Document

	
function input_focus(fieldid, state, type) {
	
		if (state == "active") {
			document.getElementById(fieldid).setAttribute("class", type+"-active");
		}else{
			document.getElementById(fieldid).setAttribute("class", type);
		}
	
	}

function ContactFormValidation (sFieldIDs) {
	var i;
	var arrFields = sFieldIDs.split(":");
	var currField;
	var borderstyle = "1px solid #000000";
	var bgcolorstyle = "#759DA9";
	var bSubmitForm = true;
	var email= /^[\w-\.]+\@[\w\.-]+\.[a-zA-Z]{2,4}$/;
	
	for (i = 0; i < arrFields.length; i++) {
		// Get form field reference
		currField = document.getElementById(arrFields[i]);
		
		// Check for null in the case of a non existing html element
		if (currField != null) {
			// Set fields style to default
			SetBorderStyle(currField, "default");
			
			// If field is empty then set the style to red background and border
			if (currField.name.toLowerCase() == "email" && (!(email.test(currField.value)))) {
				SetBorderStyle(currField, "error");
				bSubmitForm = false;
			}
			else if (currField.value == "") {
				SetBorderStyle(currField, "error");
				bSubmitForm = false;
			}
		}
	}
	return bSubmitForm;
}
function SetBorderStyle(fldFormField, fDefaultOrError){
	if (fDefaultOrError.toLowerCase() == "error") {
		borderstyle = "1px solid #ea172a";
		bgcolorstyle = "#ffc0c0";
	}
	else if (fDefaultOrError.toLowerCase() == "default") {
		borderstyle = "1px solid #a7a6aa";
		bgcolorstyle = "#FFFFFF";
	}
	
	fldFormField.style.border = borderstyle;
	fldFormField.style.background = bgcolorstyle;
}

function input_focus(fieldid, state, type) {
	
		if (state == "active") {
			document.getElementById(fieldid).setAttribute("class", type+"-active");
		}else{
			document.getElementById(fieldid).setAttribute("class", type);
		}
	
	}
	
sfHover = function() {
	if (!document.getElementById("nav")) return false;
	var sfEls = document.getElementById("nav").getElementsByTagName("li");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);

