var voto=0;
var tipo=new Array('Deficiente','Regular','Bueno','Muy Bueno','Excelente');
function cargar(n,nivel){
	var tempimg;
	if (voto==0){
		for (i=2;i<6;i++){
			tempimg=document.getElementById('est'+i);
			tempimg.src=nivel+'starno.gif';
		}
		for (i=2;i<=n;i++){
			tempimg=document.getElementById('est'+i);
			tempimg.src=nivel+'starsi.gif';
		}
		document.getElementById('mensaje').innerHTML=tipo[n-1];;
	}
}
function seleccion(n,nivel,logueado){
if (logueado=='no'){
	location.href='/Entrada_al_sistema.htm';
}else{
	if (voto==0){
		for (i=2;i<6;i++){
				tempimg=document.getElementById('est'+i);
				tempimg.src=nivel+'starno.gif';
		}
		for (i=2;i<=n;i++){
				tempimg=document.getElementById('est'+i);
				tempimg.src=nivel+'starsi.gif';
		}
		document.getElementById('mensaje').innerHTML=tipo[n-1];
		document.getElementById('calif').value=n;
		document.getElementById('textoCalifica').style.display='inline';
	}else { document.getElementById('mensaje').innerHTML='Su calificación ya fue enviada'; }
}
}
function creaAjax(){
         var objetoAjax=false;
         try {
          /*Para navegadores distintos a internet explorer*/
          objetoAjax = new ActiveXObject("Msxml2.XMLHTTP");
         } catch (e) {
          try {
                   /*Para explorer*/
                   objetoAjax = new ActiveXObject("Microsoft.XMLHTTP");
                   }
                   catch (E) {
                   objetoAjax = false;
          }
         }

         if (!objetoAjax && typeof XMLHttpRequest!='undefined') {
          objetoAjax = new XMLHttpRequest();
         }
         return objetoAjax;
}
 function FAjax (url,capa,valores,metodo,tipo)
{
	if (tipo=='formulario1'){
		if (document.Fcal.comenta.value==''){
			alert('Debe escribir un comentario');
			return;
		}
	}
          var ajax=creaAjax();
          var capaContenedora = document.getElementById(capa);

/*Creamos y ejecutamos la instancia si el metodo elegido es POST*/
if(metodo.toUpperCase()=='POST'){
         ajax.open ('POST', url, true);
         ajax.onreadystatechange = function() {
         if (ajax.readyState==1) {
                          capaContenedora.innerHTML="<img src='/img/img-ajax.gif'>";
         }
         else if (ajax.readyState==4){
                   if(ajax.status==200)
                   {       
						voto=1; 
                        document.getElementById(capa).innerHTML=ajax.responseText;
                   }
                   else if(ajax.status==404)
                                             {

                            capaContenedora.innerHTML = "La direccion no existe";
                                             }
                           else
                                             {
                            capaContenedora.innerHTML = "Error: ".ajax.status;
                                             }
                                    }
                  }
         ajax.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
         ajax.send(valores);
         return;
}
/*Creamos y ejecutamos la instancia si el metodo elegido es GET*/
if (metodo.toUpperCase()=='GET'){

         ajax.open ('GET', url, true);
         ajax.onreadystatechange = function() {
         if (ajax.readyState==1) {
                                      capaContenedora.innerHTML="<img src='/img/img-ajax.gif'>";
         }
         else if (ajax.readyState==4){
                   if(ajax.status==200){
                                             document.getElementById(capa).innerHTML=ajax.responseText;
                   }
                   else if(ajax.status==404)
                                             {

                            capaContenedora.innerHTML = "La direccion no existe";
                                             }
                                             else
                                             {
                            capaContenedora.innerHTML = "Error: ".ajax.status;
                                             }
                                    }
                  }
         ajax.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
         ajax.send(null);
         return
}
}

function cargarTodos(id,tipo){
	FAjax('CRM/prg/ajaxComentarios.php','masComentarios','id='+id+'&tipo='+tipo,'post','comentarios');
} 



