
function init() {var reqTemp;if (window.XMLHttpRequest) {reqTemp = new XMLHttpRequest();if (reqTemp.overrideMimeType) {reqTemp.overrideMimeType('text/xml');}} else if (window.ActiveXObject) {try {reqTemp = new ActiveXObject("Msxml2.XMLHTTP");} catch (e) {try {reqTemp = new ActiveXObject("Microsoft.XMLHTTP");} catch (e) {}}}var url = "../../../../AppServlet";reqTemp.open("POST", url, true);reqTemp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");return reqTemp;}//init

function sinAcentos(texto){
        var rExps=[ /[\xC0-\xC4]/g, /[\xE0-\xE4]/g,
        /[\xC8-\xCB]/g, /[\xE8-\xEB]/g,
        /[\xCC-\xCF]/g, /[\xEC-\xEF]/g,
        /[\xD2-\xD6]/g, /[\xF2-\xF6]/g,
        /[\xD9-\xDC]/g, /[\xF9-\xFC]/g,
        /[\xD1]/g, /[\xF1]/g, /[\x26]/g, /[\x25]/g ];

        var repChar=['A','a','E','e','I','i','O','o','U','u','###','###','###-#', '###-##'];
        for(var i=0; i<rExps.length; i++){
                texto= texto.replace(rExps[i],repChar[i]);
        }
        return texto
}//sinAcentos

        	function echeck(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   alert("La direccion de Email no parece correcta. Favor de revisar e intentar de nuevo.");
		   return false;
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("La direccion de Email no parece correcta. Favor de revisar e intentar de nuevo.");
		   return false;
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("La direccion de Email no parece correcta. Favor de revisar e intentar de nuevo.");
		    return false;
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("La direccion de Email no parece correcta. Favor de revisar e intentar de nuevo.");
		    return false;
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("La direccion de Email no parece correcta. Favor de revisar e intentar de nuevo.");
		    return false;
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("La direccion de Email no parece correcta. Favor de revisar e intentar de nuevo.");
		    return false;
		 }

		 if (str.indexOf(" ")!=-1){
		    alert("La direccion de Email no parece correcta. Favor de revisar e intentar de nuevo.");
		    return false;
		 }

 		 return true;
	}//echeck


function EnviaComentario(){
        var txtNombreContacto = document.getElementById("txtNombreContacto");
        var txtEMailContacto = document.getElementById("txtEMailContacto");
        var txtAsuntoContacto = document.getElementById("txtAsuntoContacto");
        var txtComentarioContacto = document.getElementById("txtComentarioContacto");
        if (echeck(txtEMailContacto.value)==false){
                return;
        }
        if (txtComentarioContacto.value==""){
                alert("Por favor introduzca los comentarios.");
                return;
        }

        var reqMail = init();
        reqMail.send("EnviaComentario="+ sinAcentos(txtNombreContacto.value.toUpperCase()) + "@@@" + txtEMailContacto.value + "@@@" + sinAcentos(txtAsuntoContacto.value.toUpperCase()) + "@@@" + sinAcentos(txtComentarioContacto.value.toUpperCase()) + "@@@false@@@");
        
        alert("Muchas gracias por sus comentarios!");
        txtAsuntoContacto.value='';
        txtComentarioContacto.value='';
}
