// JavaScript Document
String.prototype.trim = function() {
	return this.replace(/^\s+|\s+$/g,"");
}
String.prototype.ltrim = function() {
	return this.replace(/^\s+/,"");
}
String.prototype.rtrim = function() {
	return this.replace(/\s+$/,"");
}

function form_validate(form_obj) {
	
	var result = false;
	var msg = "";
	for ( i = 0 ; i < form_obj.elements.length ; i++ ) {
		var obj = form_obj.elements[i];
		switch ( obj.type ) {
			case "password":
			case "text":
			case "textarea":
				var classnames = obj.className;
				classnames = classnames.split(" ");
				for ( j = 0 ; j < classnames.length ; j++ ) {
					if ( classnames[j] == "require" ) {
							if ( obj.value.trim() == "" ) {
								msg += "\n"+obj.title;	
							}
							break;
					}
				}
				break;
			case "radio":
			case "checkbox":
				var classnames = obj.className;
				classnames = classnames.split(" ");
				for ( j = 0 ; j < classnames.length ; j++ ) {
					if ( classnames[j] == "require" ) {
							var ch_obj = document.getElementsByName(obj.name);
							var check = false;
							for ( ch_i = 0 ; ch_i < ch_obj.length ; ch_i++ ) {
								if ( ch_obj[ch_i].checked ) {
									check = true;
									break;
								}
							}
							if ( !check ) {
								msg += "\n"+obj.title;	
							}
							break;
					}
				}
				break;
		}
	}
	if ( msg.trim().length > 0 ) {
		result = false;
		alert(msg);
	}else
		result = true;
	return result;
}
