

//defino el objeto ajax.
var http = nuevoAjax();
var http1 = nuevoAjax();
function createRequestObject() {
	
	var xmlhttp;
	try {
  	xmlhttp=new ActiveXObject("Msxml2.XMLHTTP");
  }
  catch(e) {
    try {
    	xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
    catch(e) {
    	xmlhttp=null;
    }
  }
  if(!xmlhttp&&typeof XMLHttpRequest!="undefined") {
  	xmlhttp=new XMLHttpRequest();
  }
	return  xmlhttp;
}
function nuevoAjax(){
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 getTipologia(){ 
  try{   
     cadenaFormulario="ctg="+document.getElementById("cbCategoria").value;
     http.open("POST","getTipologia.php", true); 
     http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=ISO-8859-1'); 
     http.onreadystatechange = function () { 
       if (http.readyState == 4) {
           	 response=unescape(http.responseText);
             response=response.replace(/\+/gi," ");
             document.getElementById("cpTipologia").innerHTML=response;   
             getPotencia();
       } 
    } 
    http.send(cadenaFormulario); 
  }

  catch(e){
    alert('Se ha producido un error.'+e.description);
  }
	finally{}
}
function getPotencia(){ 
  try{   
    try{
     cadenaFormulario="tip="+document.getElementById("cbTipologia").value;
	}catch(a){
	 cadenaFormulario="tip=''";
	}
     http1.open("POST","getPotencia.php", true); 
     http1.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=ISO-8859-1'); 
     http1.onreadystatechange = function () { 
       if (http1.readyState == 4) {
           	 response=unescape(http1.responseText);
             response=response.replace(/\+/gi," ");
             document.getElementById("cpPotencia").innerHTML=response;       
       } 
    } 
    http1.send(cadenaFormulario); 
  }

  catch(e){
    alert('Se ha producido un error: '+e.description);
  }
	finally{}
}
