function getFormElementByName(formSource, elemName) {
	var i;
	for (i = 0; i < formSource.length; i++) {
		if (formSource.elements[i].name == elemName)
			return formSource.elements[i];
	}
	return null;
}

function focus_warn_field(obj) {
	obj.style.backgroundColor = '#FFDFDF';
	obj.focus();
	return false;
}

function unwarn_field(obj) {
	obj.style.backgroundColor = '#FFFFFF';
	return false;
}

function checkRequiredField( obj ) {
	if( obj.value )
		return true;
	else
		return focus_warn_field( obj );
}

function disableElement( obj ) {
	obj.disabled=1;
	
	return true;
}

function disable_field(field,disable){ //unified disable/enable handler
        if (disable){
                field.disabled = true;
                if (field.style){
                        if(field.type == 'text' || field.type == 'select-one' || field.type == 'password'){
                                field.style.backgroundColor = '#F0F0F0';
                                field.style.borderColor = '#CCCCCC';
                        }
                }
        }
		else{
                field.disabled = false;
                if (field.style){               
                        if(field.type == 'text' || field.type == 'select-one' || field.type == 'password'){             
                                field.style.backgroundColor = '#FFFFFF';
                                field.style.borderColor = '#999999';
                        }                               
                }                               
        }
}
