// JavaScript Document

    function getHTTPObject() 
	 {
        var xmlhttp;
        /*@cc_on
        @if (@_jscript_version >= 5)
        try {
		  xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
        } catch (e) {
        try {
           xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
        }catch (E) {
           xmlhttp = false;
           }
        }
        @else
           xmlhttp = false;
        @end @*/
        if (!xmlhttp && typeof XMLHttpRequest != 'undefined') 
		{
           try { xmlhttp = new XMLHttpRequest(); } catch (e) { xmlhttp = false; } 
        }
        return xmlhttp;
     }
     
	 function ajax(op) 
	 {
		iniciaAjax();
		var d = document.form1;
	    var url = "../ajax/funcionesOpinion.jsp?";
		var valores = "";
		opcion = op;		
		switch(Number(opcion))		  
		{
			case 1: 
				valores = "arg0="+opcion; 
			break;
			case 2: 
				valores = "arg0="+opcion+"&arg1="+d.cveEstado.value; 
			break;
			case 3: 
				valores = "arg0="+opcion+"&arg1="+d.nombre.value+"&arg2="+d.correo.value+"&arg3="+d.calle.value+"&arg4="+d.colonia.value+"&arg5="+d.delegacion.value+"&arg6="+d.codigoPostal.value+"&arg7="+d.cveEstado.value+"&arg8="+d.cveMunicipio.value+"&arg9="+d.asunto.value+"&arg10="+transformaCadena(d.mensaje.value); 
			break;
		}
		http.open("GET", url + valores, true);		
        http.onreadystatechange = handleHttpResponse;
        http.send();
     }
	 
	 function handleHttpResponse() 
	 {
	    var respuesta, i, valores;
		var d = document.form1;
	    if(http.readyState == 4) 
		{
		   switch(Number(opcion))
		   {		   
		      	case 1:
			        respuesta = http.responseText;	
			        document.getElementById("idNuevaOpinion").innerHTML=respuesta;
			        document.getElementById("idNuevaOpinion").style.display="inline";
				break;
		      	case 2:
			           respuesta = http.responseText.split("%");		
	                   i = 0;
	                   valores = "";
		               document.getElementById("cveMunicipio").options.length = 0;
						while(i<respuesta.length)
		               	{
		                  valores = respuesta[i].split("&");	
		                  if(valores[1]!=undefined)
			                 document.getElementById("cveMunicipio").options[i] = new Option(Trim(valores[1]),Trim(valores[0]));		
		                  i++;
   		               	}	
	                   document.getElementById("cveMunicipio").options[0].selected = true;
				break;
				case 3:
			        respuesta = http.responseText;	
			        if(Trim(respuesta)!="0"){
			        	//alert("Información Almacenada Exitosamente");
			      	  	document.getElementById("idNuevaOpinion").innerHTML=mensajeAgradecimiento();
			     	   	document.getElementById("idNuevaOpinion").style.display="inline";
			        }else
			        	alert("Error al Almacenar la Información");
				break;
		   }		   
		terminaAjax();
		}
     }

	 var http = getHTTPObject(); // We create the HTTP Object
	 var opcion = 0;
	 var busqueda = 0;