

function creaAjax2(){
         var objetoAjax2=false;
         try {
          /*Para navegadores distintos a internet explorer*/
          objetoAjax2 = new ActiveXObject("Msxml2.XMLHTTP");
         } catch (e) {
          try {
                   /*Para explorer*/
                   objetoAjax2 = new ActiveXObject("Microsoft.XMLHTTP");
                   }
                   catch (E) {
                   objetoAjax2 = false;
          }
         }

         if (!objetoAjax2 && typeof XMLHttpRequest!='undefined') {
          objetoAjax2 = new XMLHttpRequest();
         }
         return objetoAjax2;
}

function guardarValoracion(codProducto,valor) {
		var ajax=creaAjax2();
	    var to=document.getElementById('capaValora');
	    var spVal=document.getElementById('spValora');
		var nombre = document.getElementById("nombreCom").value;
		var email = document.getElementById("emailCom").value;
		var opinion = document.getElementById("opinionCom").value;
		var aceptaEmail = 0;
		if (document.getElementById("AceptaEmails").checked) {
			aceptaEmail = 1;
		}
		
		var valores = 'nombre='+nombre+'&email='+email+'&comentario='+opinion+'&valor='+valor+'&codProducto='+codProducto+'&aceptaEmail='+aceptaEmail;
		ajax.open ('POST', '/mactual/opiniones/guardarOpinion.jsp', true);
         ajax.onreadystatechange = function() {
         if (ajax.readyState==1) {
			
         }
         else if (ajax.readyState==4){
                   if(ajax.status==200)
                   {
                   		var listaCons = ajax.responseText;
                   		
                   		to.style.display='none';
                   		spVal.innerHTML= "<a class=\"fichaTexto\"><b>Su valoración se ha guardado y ser&aacute; publicada previa revisi&oacute;n. Gracias!</b><br></a>";
                   		document.getElementById("nombreCom").value = '';
                   		document.getElementById("emailCom").value = '';
                   		document.getElementById("opinionCom").value = '';
                        
                   } 
                   else if(ajax.status==404) {}
                        else{}
                      }
                  }
         ajax.setRequestHeader('Content-Type','application/x-www-form-urlencoded; charset=UTF-8');
         ajax.send(valores);
         
         return;

}


