var xmlHttp;
function ajaxFunction(archivo,funcionx){

  try{
    // Firefox, Opera 8.0+, Safari
    xmlHttp=new XMLHttpRequest();
    }
  catch (e){
    // Internet Explorer
    try{
      xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
      }
    catch (e){
      try{
        xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
        }
      catch (e){
        alert("Your browser does not support AJAX!");
        return false;
        }
      }
    }
    xmlHttp.onreadystatechange=funcionx;
    xmlHttp.open("GET",archivo,true);
    xmlHttp.send(null);
  }
  
function crear_opcion(valor) { 
	var nueva_opcion = document.createElement("option"); 
	var texto = document.createTextNode(valor.childNodes[0].data); 
	nueva_opcion.setAttribute("value",valor.getAttribute("id")); 
	nueva_opcion.appendChild(texto); //Adiciona o texto a OPTION.
	return nueva_opcion; // Retorna a nova OPTION.
}

function cmb(){
  if(xmlHttp.readyState==4){	
    var result = xmlHttp.responseXML;
    var valores = result.getElementsByTagName("nombre");
    var campo=document.getElementById('campo').value;
    document.getElementById(campo).innerHTML = "";
    // Agregando Opcion en blanco al combo
		var nueva_opcion = document.createElement("option");    
		var texto = document.createTextNode("Selecciona ...");		
		nueva_opcion.setAttribute("value","0"); 
		nueva_opcion.appendChild(texto);
		document.getElementById(campo).appendChild(nueva_opcion);
		// -----------------------------------		
    for (var i = 0; i < valores.length; i++) {
    	nueva_opcion = crear_opcion(valores[i]);
    	document.getElementById(campo).appendChild(nueva_opcion);
    }
    
  }
  
  if(xmlHttp.readyState==3){	
    var campo=document.getElementById('campo').value;
    document.getElementById(campo).innerHTML = "";    
  }  
  
  if(xmlHttp.readyState==2){	
    var campo=document.getElementById('campo').value;
    document.getElementById(campo).innerHTML = "";    
  }    
  
  if(xmlHttp.readyState==1){	
    var campo=document.getElementById('campo').value;
    document.getElementById(campo).innerHTML = "";    
  }    
   
}   

function txt(){
  if(xmlHttp.readyState==4){
        var result = xmlHttp.responseText;
        document.getElementById('tt').innerHTML = result; 
        //document.getElementById('capa').innerHTML = "Terminao";        
  }
  if(xmlHttp.readyState==3){
        document.getElementById('tt').innerHTML = "";        
        //document.getElementById('capa').innerHTML = "En proceso";  
  }
  
 /* if(xmlHttp.readyState==1){
        document.getElementById('tt').innerHTML = "";        
        document.getElementById('capa').innerHTML = "En proceso";  
  }*/  
  /*if(xmlHttp.readyState==2){
        document.getElementById('tt').innerHTML = "";        
        document.getElementById('capa').innerHTML = "En proceso";  
  } */   

}   

function txt2(){
  if(xmlHttp.readyState==4){
        var result = xmlHttp.responseText;
        //document.getElementById('tabla2').innerHTML = result;  
        ajaxFunction('comboasesores.php?id=' + document.forma.idempresa[document.forma.idempresa.selectedIndex].value,cmb2);      
        //document.getElementById('tabla3').innerHTML = "";
  }
  if(xmlHttp.readyState==3){
        //document.getElementById('tabla2').innerHTML = "";
        //document.getElementById('tabla3').innerHTML = "";        
  }
}   

function txt3(){
  if(xmlHttp.readyState==4){
        var result = xmlHttp.responseText;
        document.getElementById('tabla3').innerHTML = result;  
  }
  if(xmlHttp.readyState==3){
        document.getElementById('tabla3').innerHTML = "";        
  }
}   


function cmb2(){
  if(xmlHttp.readyState==4){	
    var result = xmlHttp.responseXML;
    var valores = result.getElementsByTagName("nombre");
    var campo=document.getElementById('campo2').value;
    document.getElementById(campo).innerHTML = "";
    // Agregando Opcion en blanco al combo
		var nueva_opcion = document.createElement("option");    

		var texto = document.createTextNode("Selecciona ...");		
		nueva_opcion.setAttribute("value","0"); 
		nueva_opcion.appendChild(texto);
		document.getElementById(campo).appendChild(nueva_opcion);
		// -----------------------------------		
    for (var i = 0; i < valores.length; i++) {
    	nueva_opcion = crear_opcion(valores[i]);
    	document.getElementById(campo).appendChild(nueva_opcion);
    }
    
  }
  
  if(xmlHttp.readyState==3){	
    var campo=document.getElementById('campo2').value;
    document.getElementById(campo).innerHTML = "";    
  }  
  
  if(xmlHttp.readyState==2){	
    var campo=document.getElementById('campo2').value;
    document.getElementById(campo).innerHTML = "";    
  }    
  
  if(xmlHttp.readyState==1){	
    var campo=document.getElementById('campo2').value;
    document.getElementById(campo).innerHTML = "";    
  }   
   
}   

function txt22(){

  if(xmlHttp.readyState==4){
        var result = xmlHttp.responseText;
        document.getElementById('enviar_amigo').innerHTML = result; 
  }
  if(xmlHttp.readyState==3){
        document.getElementById('enviar_amigo').innerHTML = "";          
  }  
}   

function txt23(){
  if(xmlHttp.readyState==4){
        var result = xmlHttp.responseText;
        document.getElementById('alerta').innerHTML = result; 
  }
  if(xmlHttp.readyState==3){
        document.getElementById('alerta').innerHTML = "";          
  }  
}   

function enviapropiedad(){
  if(xmlHttp.readyState==4){
        var result = xmlHttp.responseText;
        document.getElementById('info').innerHTML = result; 
  }
  if(xmlHttp.readyState==3){
        document.getElementById('info').innerHTML = "";          
  }  
}   


function txt4(){
  if(xmlHttp.readyState==4){
        var result = xmlHttp.responseText;
        document.getElementById('tablaref1').innerHTML = result;  
  }
  if(xmlHttp.readyState==3){
        document.getElementById('tablaref1').innerHTML = "";        
  }
} 

function txt5(){
  if(xmlHttp.readyState==4){
        var result = xmlHttp.responseText;
        document.getElementById('tablaref2').innerHTML = result;  
  }
  if(xmlHttp.readyState==3){
        document.getElementById('tablaref2').innerHTML = "";        
  }
} 

function cmb5(){
  if(xmlHttp.readyState==4){	
    var result = xmlHttp.responseXML;
    var valores = result.getElementsByTagName("nombre");
    var campo=document.getElementById('cc1').value;
    document.getElementById(campo).innerHTML = "";
    // Agregando Opcion en blanco al combo
		var nueva_opcion = document.createElement("option");    
		var texto = document.createTextNode("[Elige un estado]");		
		nueva_opcion.setAttribute("value","0"); 
		nueva_opcion.appendChild(texto);
		document.getElementById(campo).appendChild(nueva_opcion);
		// -----------------------------------		
    for (var i = 0; i < valores.length; i++) {
    	nueva_opcion = crear_opcion(valores[i]);
    	document.getElementById(campo).appendChild(nueva_opcion);
    }
  }      
/*  if(xmlHttp.readyState==3){	
    var campo=document.getElementById('cc2').value;
    document.getElementById(campo).innerHTML = "";    

    var campo=document.getElementById('cc3').value;
    document.getElementById(campo).innerHTML = "";        
  }  
  
  if(xmlHttp.readyState==2){	
    var campo=document.getElementById('cc2').value;
    document.getElementById(campo).innerHTML = "";    

    var campo=document.getElementById('cc3').value;
    document.getElementById(campo).innerHTML = "";        
  }    
  
  if(xmlHttp.readyState==1){	
    var campo=document.getElementById('cc2').value;
    document.getElementById(campo).innerHTML = "";    

    var campo=document.getElementById('cc3').value;
    document.getElementById(campo).innerHTML = "";        
  }    */
  
}   

function cmb6(){
  if(xmlHttp.readyState==4){	
    var result = xmlHttp.responseXML;
    var valores = result.getElementsByTagName("nombre");
    var campo=document.getElementById('cc2').value;
    document.getElementById(campo).innerHTML = "";
    // Agregando Opcion en blanco al combo
		var nueva_opcion = document.createElement("option");    
		var texto = document.createTextNode("[Municipio] ... opcional");		
		nueva_opcion.setAttribute("value","0"); 
		nueva_opcion.appendChild(texto);
		document.getElementById(campo).appendChild(nueva_opcion);
		// -----------------------------------		
    for (var i = 0; i < valores.length; i++) {
    	nueva_opcion = crear_opcion(valores[i]);
    	document.getElementById(campo).appendChild(nueva_opcion);
    }
    
  }  
/*  if(xmlHttp.readyState==3){	
    var campo=document.getElementById('cc3').value;
    document.getElementById(campo).innerHTML = "";        
  }  
  
  if(xmlHttp.readyState==2){	
    var campo=document.getElementById('cc3').value;
    document.getElementById(campo).innerHTML = "";        
  }    
  
  if(xmlHttp.readyState==1){	
    var campo=document.getElementById('cc3').value;
    document.getElementById(campo).innerHTML = "";        
  }      */
   
}

function cmb7(){
  if(xmlHttp.readyState==4){	
    var result = xmlHttp.responseXML;
    var valores = result.getElementsByTagName("nombre");
    var campo=document.getElementById('cc3').value;
    document.getElementById(campo).innerHTML = "";
    // Agregando Opcion en blanco al combo
		var nueva_opcion = document.createElement("option");    
		var texto = document.createTextNode("[Colonia] ... opcional");		
		nueva_opcion.setAttribute("value","0"); 
		nueva_opcion.appendChild(texto);
		document.getElementById(campo).appendChild(nueva_opcion);
		// -----------------------------------		
    for (var i = 0; i < valores.length; i++) {
    	nueva_opcion = crear_opcion(valores[i]);
    	document.getElementById(campo).appendChild(nueva_opcion);
    }
    
  }   
   
}

function cmb5i(){
  if(xmlHttp.readyState==4){	
    var result = xmlHttp.responseXML;
    var valores = result.getElementsByTagName("nombre");
    var campo=document.getElementById('cc1').value;
    document.getElementById(campo).innerHTML = "";
    // Agregando Opcion en blanco al combo
		var nueva_opcion = document.createElement("option");    
		var texto = document.createTextNode("[Choose a state]");		
		nueva_opcion.setAttribute("value","0"); 
		nueva_opcion.appendChild(texto);
		document.getElementById(campo).appendChild(nueva_opcion);
		// -----------------------------------		
    for (var i = 0; i < valores.length; i++) {
    	nueva_opcion = crear_opcion(valores[i]);
    	document.getElementById(campo).appendChild(nueva_opcion);
    }
  }      
/*  if(xmlHttp.readyState==3){	
    var campo=document.getElementById('cc2').value;
    document.getElementById(campo).innerHTML = "";    

    var campo=document.getElementById('cc3').value;
    document.getElementById(campo).innerHTML = "";        
  }  
  
  if(xmlHttp.readyState==2){	
    var campo=document.getElementById('cc2').value;
    document.getElementById(campo).innerHTML = "";    

    var campo=document.getElementById('cc3').value;
    document.getElementById(campo).innerHTML = "";        
  }    
  
  if(xmlHttp.readyState==1){	
    var campo=document.getElementById('cc2').value;
    document.getElementById(campo).innerHTML = "";    

    var campo=document.getElementById('cc3').value;
    document.getElementById(campo).innerHTML = "";        
  }    */
  
}   

function cmb6i(){
  if(xmlHttp.readyState==4){	
    var result = xmlHttp.responseXML;
    var valores = result.getElementsByTagName("nombre");
    var campo=document.getElementById('cc2').value;
    document.getElementById(campo).innerHTML = "";
    // Agregando Opcion en blanco al combo
		var nueva_opcion = document.createElement("option");    
		var texto = document.createTextNode("[Choose a city]... optional");		
		nueva_opcion.setAttribute("value","0"); 
		nueva_opcion.appendChild(texto);
		document.getElementById(campo).appendChild(nueva_opcion);
		// -----------------------------------		
    for (var i = 0; i < valores.length; i++) {
    	nueva_opcion = crear_opcion(valores[i]);
    	document.getElementById(campo).appendChild(nueva_opcion);
    }
    
  }  
/*  if(xmlHttp.readyState==3){	
    var campo=document.getElementById('cc3').value;
    document.getElementById(campo).innerHTML = "";        
  }  
  
  if(xmlHttp.readyState==2){	
    var campo=document.getElementById('cc3').value;
    document.getElementById(campo).innerHTML = "";        
  }    
  
  if(xmlHttp.readyState==1){	
    var campo=document.getElementById('cc3').value;
    document.getElementById(campo).innerHTML = "";        
  }      */
   
}

function cmb7i(){
  if(xmlHttp.readyState==4){	
    var result = xmlHttp.responseXML;
    var valores = result.getElementsByTagName("nombre");
    var campo=document.getElementById('cc3').value;
    document.getElementById(campo).innerHTML = "";
    // Agregando Opcion en blanco al combo
		var nueva_opcion = document.createElement("option");    
		var texto = document.createTextNode("[Choose a neighborhood]... optional");		
		nueva_opcion.setAttribute("value","0"); 
		nueva_opcion.appendChild(texto);
		document.getElementById(campo).appendChild(nueva_opcion);
		// -----------------------------------		
    for (var i = 0; i < valores.length; i++) {
    	nueva_opcion = crear_opcion(valores[i]);
    	document.getElementById(campo).appendChild(nueva_opcion);
    }
    
  }   


   
}// JavaScript Document

function listadobusqueda(){
  if(xmlHttp.readyState==4){
        var result = xmlHttp.responseText;
        document.getElementById('listadobusqueda').innerHTML = result;  
  }

  if(xmlHttp.readyState==2){
        document.getElementById('listadobusqueda').innerHTML = "<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0' width='120' height='130'><param name='movie' value='swf/loading.swf' /><param name='quality' value='high' /><embed src='swf/loading.swf' quality='high' pluginspage='http://www.macromedia.com/go/getflashplayer' type='application/x-shockwave-flash' width='120' height='130'></embed></object>"; 
  }  

 
} 
