//--- field hints

function formHints(frm, activeColor, hintColor) {
	this.formular = frm;
	this.activeColor = activeColor;
	this.hintColor = hintColor;
	this.add = formHints_add;	
	this.init = formHints_show;      
	if (this.formular.onsubmit) {
		frmonsub = this.formular.onsubmit;
		this.formular.onsubmit = function() {frmonsub(); formHints_clear(frm);}
	} else {                
		this.formular.onsubmit = function() {formHints_clear(frm);}
	}
}       

function formHints_add(el, msg, activeColor, hintColor) {
	hcol = hintColor?hintColor:this.hintColor;
	acol = activeColor?activeColor:this.activeColor;
	if (typeof(el)!='object') {               
		var elm = this.formular.elements[el]?this.formular.elements[el]:document.getElementById(el);
		if (elm) {
			elm.onfocus = function() { formHints_clearHint(elm, msg, acol); }
			elm.onblur = function() { formHints_showHint(elm, msg, hcol); }
		}
	} else {
		var elm = el;
		elm.onfocus = function() { formHints_clearHint(elm, msg, acol); }
		elm.onblur = function() { formHints_showHint(elm, msg, hcol); }
	}                  
	formHints_showHint(elm, msg, hcol);
}

function formHints_showHint(h_el, h_val, h_col) {
	if (h_el.value == '') {
		h_el.value = h_val;     
		h_el.style.color = h_col;
	}
}

function formHints_clearHint(h_el, h_val, h_col) {
	if (h_el.value == h_val) {
		h_el.value = '';      
		h_el.style.color = h_col;
	}
}  

function formHints_show(frm) {
	for (i=0; i<frm.elements.length; i++) {
		if (frm.elements[i].onblur) {
			frm.elements[i].onblur();
		}
	}
}

function formHints_clear(frm) {
	for (i=0; i<frm.elements.length; i++) {
		if (frm.elements[i].onfocus) {      
			frm.elements[i].onfocus();
		}
	}
}