function onError(form_object, input_object, object_type, errorfld) {
	//alert(error_message);
	lbl=document.getElementById(errorfld);
	//lbl.class='error_fld';
	lbl.style.color='#FF9797';
	SetFocus(input_object);
	return false;	
}

function resetLbl(errorfld) {
	lbl=document.getElementById(errorfld);
	lbl.style.color='#666666';
	return true;	
}
function SetFocus(input_object) {
	if (!input_object || !input_object.type)
		return;
	var type = input_object.type;	 			
	if (type == "radio" || type == "checkbox") {
		if (input_object[0])
			input_object[0].focus();
		else
			input_object.focus();
	}	
	
	if (type == "text" || type == "password" || type == "textarea" || type == "file") {
		//if (!ew_IsHiddenTextArea(input_object))
			input_object.select();
	}
}

function hasValue(obj, obj_type) {
	if (obj_type == "TEXT" || obj_type == "PASSWORD" || obj_type == "TEXTAREA" || obj_type == "FILE")	{
		if (obj.value.length == 0) 
			return false;		
		else 
			return true;
	}	else if (obj_type == "SELECT") {
		if (obj.type != "select-multiple" && obj.selectedIndex == 0)
			return false;
		else if (obj.type == "select-multiple" && obj.selectedIndex == -1)
			return false;
		else
			return true;
	}	else if (obj_type == "RADIO" || obj_type == "CHECKBOX")	{
		if (obj[0]) {
			for (i=0; i < obj.length; i++) {
				if (obj[i].checked)
					return true;
			}
		} else {
			return (obj.checked);
		}
		return false;	
	}
}

function checkEmail(object_value) {
	if (object_value.length == 0)
		return false;
	
	if (!(object_value.indexOf("@") > -1 && object_value.indexOf(".") > -1))
		return false;    
	
	return true;
}

function checkForm(ContactForm) {

if (ContactForm.name && !hasValue(ContactForm.name, "TEXT")) {
	if (!onError(ContactForm, ContactForm.fname, "TEXT", "lblFname")) 
		return false;
}else{
	resetLbl('lblFname');
}

if (ContactForm.email && !hasValue(ContactForm.email, "TEXT")) {
	if (!onError(ContactForm, ContactForm.email, "TEXT", "lblEmail"))
		return false;
}else{
	resetLbl('lblEmail');
}

if (ContactForm.email && !checkEmail(ContactForm.email.value)) {
	if (!onError(ContactForm, ContactForm.email, "TEXT", "lblEmail"))
		return false;
}else{
	resetLbl('lblEmail');
}


if (ContactForm.city && !hasValue(ContactForm.city, "TEXT")) {
	if (!onError(ContactForm, ContactForm.city, "TEXT", "lblCity"))
		return false;
}else{
	resetLbl('lblCity');
}

if (ContactForm.country && !hasValue(ContactForm.country, "TEXT")) {
	if (!onError(ContactForm, ContactForm.country, "TEXT", "lblCountry"))
		return false;
}else{
	resetLbl('lblCountry');
}

if (ContactForm.phone && !hasValue(ContactForm.phone, "TEXT")) {
	if (!onError(ContactForm, ContactForm.phone, "TEXT", "lblPhone"))
		return false;
}else{
	resetLbl('lblPhone');
}

if (ContactForm.message && !hasValue(ContactForm.message, "TEXT")) {
	if (!onError(ContactForm, ContactForm.message, "TEXT", "lblMessage"))
		return false;
}else{
	resetLbl('lblMessage');
}


}

