function devValorRB(radioButton) {
	var rb = '';
	for(i = 0; i < radioButton.length; i++) {
		if (radioButton[i].checked) {
			rb = radioButton[i].value;
		}
	}
	return rb;
}

function campoVacio(campo, mensaje) {
	if (campo.type == 'checkbox') {
		if (!campo.checked) {
			campo.focus();
			alert (mensaje);
			return true;
		}
	} else if (campo.length != undefined) {
		if (devValorRB(campo) == '') {
			campo[0].focus();
			alert (mensaje);
			return true;
		}
	} else if (campo.value != undefined) {
		if (campo.value == '') {
			campo.focus();
			alert (mensaje);
			return true;
		}
	}
	return false;
}

function print_r(elemento) {
	var cad='';
	if (elemento != undefined) {
		if (elemento.length == undefined || elemento.type == 'select-one') {
			for (var x in elemento) {
				if (elemento[x] != undefined) {
					cad += x + " = " + elemento[x] + "\n";
				}
			}
		} else {
			for (i = 1; i < elemento.length; i++) {
				if (elemento[i].name != undefined) {
					cad += elemento[i].name + " = " + elemento[i].value + "\n";
				}
			}
		}
	}
	alert(cad);
}

function sonDistintos (campo1, campo2, mensaje) {
	if (campo1.value != campo2.value) {
		campo2.focus();
		alert (mensaje);
		return true;
	}
	return false;
}

function confirmar (mensaje, url) {
	if (confirm (mensaje)) {
		document.location = url;
	}
}