function correo_valido(campo) {
	var mail = campo.value;
	if (!isRFC822ValidEmail(mail)) {
		alert("Por favor escriba nuevamente su direcci\u00f3n de email revisando que est\u00e9 correctamente escrita.");
		campo.focus();
		return false;
	}
	else {
		return true; 
	}
}
function isRFC822ValidEmail(sEmail) {
	var sQtext = '[^\\x0d\\x22\\x5c\\x80-\\xff]';
	var sDtext = '[^\\x0d\\x5b-\\x5d\\x80-\\xff]';
	var sAtom = '[^\\x00-\\x20\\x22\\x28\\x29\\x2c\\x2e\\x3a-\\x3c\\x3e\\x40\\x5b-\\x5d\\x7f-\\xff]+';
	var sQuotedPair = '\\x5c[\\x00-\\x7f]';
	var sDomainLiteral = '\\x5b(' + sDtext + '|' + sQuotedPair + ')*\\x5d';
	var sQuotedString = '\\x22(' + sQtext + '|' + sQuotedPair + ')*\\x22';
	var sDomain_ref = sAtom;
	var sSubDomain = '(' + sDomain_ref + '|' + sDomainLiteral + ')';
	var sWord = '(' + sAtom + '|' + sQuotedString + ')';
	// var sDomain = sSubDomain + '\\x2e' + sSubDomain + '*';
	var sDomain = sSubDomain + '(\\x2e' + sSubDomain + ')*';
	//-- Si la ultima parte del dominio (por ejemplo "algo.com.a") tiene una sola letra no anda!
	var sLocalPart = sWord + '(\\x2e' + sWord + ')*';
	var sAddrSpec = sLocalPart + '\\x40' + sDomain; // complete RFC822 email address spec
	var sValidEmail = '^' + sAddrSpec + '$'; // as whole string
	var reValidEmail = new RegExp(sValidEmail);
	if (reValidEmail.test(sEmail)) {
		return true;
	}
	return false;
}
function verificar_formulario(form){
	var mail = correo_valido(form.destinatario_email);
	if(!mail){
		form.destinatario_email.focus();
		return false;
	}
	_gaq.push(['_trackEvent', 'instantanews', 'suscripcion', 'suscripcion instantanews']);
 	
	return mail;
}
function escribeNuevoValor(txt,defecto){
	if(txt.value==defecto) {
		txt.value="";
		txt.style.color="000000";
	}
}
function escribeDefectoValor(txt,defecto){
	if(txt.value=="") {
		txt.value=defecto;
		txt.style.color="AAAAAA";
	}
}

function jsAjax(){
    var xmlhttp=false;
    try{
        xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
    }catch(e){
        try{
            xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
        }catch(E){
            xmlhttp = false;
        }
    }

    if(!xmlhttp && typeof XMLHttpRequest!='undefined'){
        xmlhttp = new XMLHttpRequest();
    }
    return xmlhttp;
}



function verificarAjax() {
	ajax = jsAjax();
	ajax.open('GET', 'verificar_datos.php?accion=verificar_ajax&login='+$('#usuario').val(), false);                             
    ajax.send(null);
    return ajax.responseText;
}
