//check for empty str
function clsGB_ErrObj () {
	this.blnNoErrors = true;
	
	//classes for the err div elements.
	this.ErrEl_error_class = 'formerror';
	this.ErrEl_noerror_class = 'formnoerror';

	//classes for the form fields.
	this.txt_error_class = 'texterror';
	this.txt_noerror_class = 'text';

	//classes for the form fields.
	this.txtarea_error_class = 'textareaerror';
	this.txtarea_noerror_class = 'textarea';

	//classes for the form fields.
	this.select_error_class = 'selecterror';
	this.select_noerror_class = 'select';
	
	this.noErr_HTMLstring = '<img src="images/blank.gif" width="1" height="1" />';

}


function clsGB_ErrObj.prototype.c_GBemptyTxt(strFormEl, strErrEl, strErrTxt) {
	with (this) {
		form.elements(strFormEl).value = this.Trim(form.elements(strFormEl).value);
		if (form.elements(strFormEl).value == '') {
			document.getElementById(strErrEl).className = this.ErrEl_error_class;
			document.getElementById(strErrEl).innerHTML = strErrTxt;
			form.elements(strFormEl).className = this.txt_error_class;
			this.blnNoErrors = false;
		} else {
			document.getElementById(strErrEl).className = this.ErrEl_noerror_class;
			document.getElementById(strErrEl).innerHTML = this.noErr_HTMLstring;
			form.elements(strFormEl).className = this.txt_noerror_class;
		}
	}
}

function clsGB_ErrObj.prototype.c_GBemptyTxtArea(strFormEl, strErrEl, strErrTxt) {
	with (this) {
		form.elements(strFormEl).value = this.Trim(form.elements(strFormEl).value);
		if (form.elements(strFormEl).value == '') {
			document.getElementById(strErrEl).className = this.ErrEl_error_class;
			document.getElementById(strErrEl).innerHTML = strErrTxt;
			form.elements(strFormEl).className = this.txtarea_error_class;
			this.blnNoErrors = false;
		} else {
			document.getElementById(strErrEl).className = this.ErrEl_noerror_class;
			document.getElementById(strErrEl).innerHTML = this.noErr_HTMLstring;
			form.elements(strFormEl).className = this.txtarea_noerror_class;
		}
	}
}

function clsGB_ErrObj.prototype.c_GBemptyCbo(strFormEl, strErrEl, strErrTxt) {
	with (this) {
		
		if (form.elements(strFormEl).options[form.elements(strFormEl).selectedIndex].value == '') {
			document.getElementById(strErrEl).className = this.ErrEl_error_class;
			document.getElementById(strErrEl).innerHTML = strErrTxt;
			form.elements(strFormEl).className = this.select_error_class;
			this.blnNoErrors = false;
		} else {
			document.getElementById(strErrEl).className = this.ErrEl_noerror_class;
			document.getElementById(strErrEl).innerHTML = this.noErr_HTMLstring;
			form.elements(strFormEl).className = this.select_noerror_class;
		}
	}
}

//check for email addr
function clsGB_ErrObj.prototype.c_GBemailAddr(strFormEl, strErrEl, strErrTxt) {
	with (this) {
		form.elements(strFormEl).value = this.Trim(form.elements(strFormEl).value);
		
		var strFilter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i

		if (!strFilter.test(form.elements(strFormEl).value)) {
			document.getElementById(strErrEl).className = this.ErrEl_error_class;
			document.getElementById(strErrEl).innerHTML = strErrTxt;
			form.elements(strFormEl).className = this.txt_error_class;
			this.blnNoErrors = false;
		} else {
			document.getElementById(strErrEl).className = this.ErrEl_noerror_class;
			document.getElementById(strErrEl).innerHTML = this.noErr_HTMLstring;
			form.elements(strFormEl).className = this.txt_noerror_class;
		}
	}
}


/*TRIM FUNCTIONS*/
function clsGB_ErrObj.prototype.LTrim(str) {
	var strWhitespace = new String(" \t\n\r");
	var s = new String(str);
	
	if (strWhitespace.indexOf(s.charAt(0)) != -1) {
		var j=0, i = s.length;
		while (j < i && strWhitespace.indexOf(s.charAt(j)) != -1)
			j++;
		s = s.substring(j, i);
	}
	return s;
}

function clsGB_ErrObj.prototype.RTrim(str) {
	var strWhitespace = new String(" \t\n\r");
	var s = new String(str);
	
	if (strWhitespace.indexOf(s.charAt(s.length-1)) != -1) {
		var i = s.length - 1;
		while (i >= 0 && strWhitespace.indexOf(s.charAt(i)) != -1)
			i--;
		s = s.substring(0, i+1);
	}
	return s;
}

function clsGB_ErrObj.prototype.Trim(str) {
	with (this) {
		return this.RTrim(this.LTrim(str));
	}
}