set = function(field, val1, val2)
{
    if (field.value == val1) field.value = val2;
}







/* HILITE_INPUT: ADD EFFECT FOCUS/BLUR TO THE SPECIFIED ELEMENT
 * el: AN FORM ELEMENT
 * bgf: ONFOCUS BACKGROUND COLOR
 * bgb: ONBLUR BACKGROUND COLOR
 */
hilite_input = function( el, bgf, bgb ){
	if( !el ){ return; }
	if( !el.style ){ return; }
	v = ['text', 'password'];
	if( el.tagName == 'INPUT' && !in_array(el.type, v) ){ return; }
	switch(el.tagName){
		case 'TEXTAREA':
		case 'SELECT':
		case 'INPUT':
			addon_event( el, 'onfocus', function(){ el.style.backgroundColor = bgf; } );
			addon_event( el, 'onblur', function(){ el.style.backgroundColor = bgb; } );
			break;
		default: return;
	}
}

/* HILITE_FORM: ADD EFFECT FOCUS/BLUR TO THE SPECIFIED FORM
 * el: AN FORM
 * bgf: ONFOCUS BACKGROUND COLOR
 * bgb: ONBLUR BACKGROUND COLOR
 */
 hilite_form = function( el, bgf, bgb ){
 	if( !el ){ return; }
	if( el.tagName != 'FORM' ){ return; }
	for( i = 0; i < el.elements.length; i++){ hilite_input( el.elements[i], bgf, bgb ); }
}

/* HILITE_TABLE: HIGHLIGHTS TABLE ROWS IF CLASS ISN'T NOHILITE
 */
hilite_table = function( id, on, out ){
	if( !document.getElementById && !document.getElementsByTagName ){ return; }
	table = document.getElementById( id );
	if( !table ){ return; }
	rows = table.getElementsByTagName('tr');
	for( i = 0; i < rows.length; i++ ){
		r = rows[i];
		if( r.className != 'nohilite' ){
			overfunc = get_source(r.onmouseover, 'this.style.backgroundColor = "' + on + '";');
			r.onmouseover = overfunc;
			outfunc = get_source(r.onmouseout, 'this.style.backgroundColor = "' + out + '";');
			r.onmouseout = outfunc;
		}
	}
}


error = function(fld, message)
{
    alert(message);
    fld.focus();
    return false;
}

get_element = function(id)
{
    doc = arguments.length == 2? arguments[1] : document;
    
    if (document.getElementById) { return doc.getElementById(id) }
    else if (document.all) { return doc.all[id]; }
    else if (document.layers) { return doc.layers[id]; }
}

hide = function()
{
    els = arguments;

    for (i = 0; i < els.length; i++) {
        el = get_element(els[i]);
        if (el) el.style.display = 'none';
    }
}

show = function()
{
    els = arguments;

    for (i = 0; i < els.length; i++) {
        el = get_element(els[i]);
        if (el) el.style.display = 'block';
    }
}

