//if (document.all){ document.onselectstart=new Function ('return false'); }
function validar_formulario() {
	var error = 0;
	function algoritmo(elemento) {
		var aElm=document.body.getElementsByTagName(elemento);
		for(var i=0; i<aElm.length; i++) {
			if(aElm[i].className=='obligatorio') {
				if ( aElm[i].value == '' ) {
					aElm[i].style.backgroundColor = 'red';
					aElm[i].setAttribute('onclick', 'this.style.backgroundColor=\'#CCCCCC;\'');
					error = 1;
				}
			}
		}
	}
	algoritmo('input');
	//algoritmo('textarea');
	algoritmo('select');
	if ( error == 1 ) { alert('Por favor, rellena los campos requeridos que faltan (con el fondo rojo)'); }
	else { document.forms[0].submit(); }
}