// JavaScript for Forms

var GH_dateSep; // default date separator
if (GH_dateSep == "") GH_dateSep = "/";

function GH_submitForm(GH_this) {	
	if (GH_HTMLArea) {			
		for (var i=0; i<GH_HTMLArea.length; i++) {
			var html = GH_HTMLArea[i].getHTML();
			if (html == "<p />" || html == "<br />\n") html = "";
			GH_HTMLArea[i]._textArea.value = html;
		}
	}	
	if (GH_checkMyForm(GH_this))
		GH_this.submit();
}

function GH_isHTMLArea(input_object, object_type) {
	return (object_type == "TEXTAREA" && GH_HTMLArea && input_object.style && input_object.style.display && input_object.style.display == "none");
}

function GH_onError(form_object, input_object, object_type, error_message) {
	alert(error_message);									
	if (object_type == "RADIO" || object_type == "CHECKBOX") {
		if (input_object[0])
			input_object[0].focus();
		else
			input_object.focus();
	}	else if (!GH_isHTMLArea(input_object, object_type)) { 
		input_object.focus();  
	}  
	if (object_type == "TEXT" || object_type == "PASSWORD" || object_type == "TEXTAREA" || object_type == "FILE") {
		if (!GH_isHTMLArea(input_object, object_type))
			input_object.select();
	}
	return false;	
}

function GH_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 GH_checkemail(object_value) {
	if (object_value.length == 0)
		return true;
	
	if (!(object_value.indexOf("@") > -1 && object_value.indexOf(".") > -1))
		return false;    
	
	return true;
}
	
