function f_obj(obj) {
	return document.getElementById ? document.getElementById(obj) : document.all ? document.all[obj] : eval("document." + obj);
} 

try {
	ajax = new ActiveXObject("Microsoft.XMLHTTP");
} catch(e) {
	try{
		ajax = new ActiveXObject("Msxml2.XMLHTTP");
	} catch(ex) {
		try{
			ajax = new XMLHttpRequest();
		} catch(exc) {
			ajax = null;
		}
	}
}

function valida_email(oemail) {
	var invalid = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/;
	if (oemail.value.length <= 5 || invalid.test(oemail.value) == false) {
		alert(" * Verifique o campo de e-mail");
		return false;
	}
	return true;
}

function check_marcado(form_campo) {
	for (i=0; i<form_campo.length; i++) {
		if (form_campo[i].checked) {
			return form_campo[i].value;
		}
	}
}

function exec_ajx(parametros, destino, obj_resposta, obj_foco, obj_extra, executa) {
	if (ajax) {
		ajax.open("POST", destino, true);
		ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		ajax.setRequestHeader("Cache-Control", "no-store, no-cache, must-revalidate");
		ajax.setRequestHeader("Cache-Control", "post-check=0, pre-check=0");
		ajax.setRequestHeader("Pragma", "no-cache");
		ajax.onreadystatechange = function() {
			if(ajax.readyState == 1 && obj_resposta != '')
				obj_resposta.innerHTML = "Aguarde...!";
				if(ajax.readyState == 4) {
					if(ajax.responseText.substr(0,4) != 'ERRO') 
						if (obj_resposta != '')
							obj_resposta.innerHTML = ajax.responseText;
						else {
							if (ajax.responseText != '')
								alert(ajax.responseText);
							if (executa != '')
								eval(executa);
						}
					else
						alert(ajax.responseText.substr(4,ajax.responseText.length));
					if (obj_foco != '')
						obj_foco.focus();
				}
			};
		ajax.send(parametros);
	}
}

function mantemnews(objeto) {
	if (valida_email(objeto.email)) {
		objeto.enviar.setAttribute("disabled","disabled");
		exec_ajx('opcao='+check_marcado(objeto.opcao)+'&email='+objeto.email.value,
				 'http://labo.cfjl.com.br/SCU/news.php',
				 '',
				 objeto.email,
				 objeto,
				 'obj_extra.email.value="";obj_extra.enviar.removeAttribute("disabled")');
		objeto.email.value = 'Aguarde...';
		objeto.email.style.backgroundColor = '#FFFFFF';
	} else {
		objeto.email.focus();
		objeto.email.style.backgroundColor = '#FFFFCC';
	}
	return false;
}