    function ajaxFunction()   {
       var xmlHttp = false;
       try {
          //Firefox, Opera 8.0+, Safari
          return xmlHttp=new XMLHttpRequest();
       } catch (error) {
          try {
             //Internet Explorer 6.0 o superior	
             return xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
          } catch (error) {
             try {
                //Internet Explorer 5.5 o superior		
                return xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
             } catch (error) {
                //Si no se pudo crear el objeto
                alert("Tu explorador no soporta AJAX!\n" + error );
                return  xmlHttp;
             }
         }
      }	     
    }   

    function changeAjax (url, elementoPadre, elementoHijo, xmlHttp) {	
    var element =  document.getElementById(elementoHijo);
    var valordepende = document.getElementById(elementoPadre);
       var x = valordepende.value
	   <!--alert (x);-->
	   if(x!="")   {
		   i=1;
		   if(url.indexOf('?') != -1) {
			   var fragment_url = url+'&Id='+x;
		   }else{
			   var fragment_url = url+'?Id='+x;
		   }
		   element.innerHTML = '<div align="center" class="jsvalidation" style="width:auto; height:auto;"> Cargando ... </div>';
		   xmlHttp.open("GET", fragment_url);
		   xmlHttp.onreadystatechange = function() {
		       if (xmlHttp.readyState == 4) {				   
					txt=unescape(xmlHttp.responseText);
					txt2=txt.replace(/\+/gi," ");
					element.innerHTML = txt2;	
					if(elementoHijo == "divMunicipios")   {					  
						ValidarComboMunicipio();			  				  
					}
					if(elementoHijo == "divAmigos")   {					  
						ValidarComboAmigos();			  				  
					}											   
			   }
		   }
		  xmlHttp.send(null);
		}
    }  


    function changeAjax02 (url, elementoPadre, elementoHijo, xmlHttp) {	
    var element =  document.getElementById(elementoHijo);
    //var valordepende = document.getElementById(elementoPadre);
       var x = elementoPadre;
	   <!--alert (x);-->
	   if(x!="")   {
		   i=1;
		   if(url.indexOf('?') != -1) {
			   var fragment_url = url+'&Id='+x;
		   }else{
			   var fragment_url = url+'?Id='+x;
		   }
		   element.innerHTML = '<div align="center" class="jsvalidation" style="width:auto; height:auto;"> Cargando ... </div>';
		   xmlHttp.open("GET", fragment_url);
		   xmlHttp.onreadystatechange = function() {
		       if (xmlHttp.readyState == 4) {				   
					txt=unescape(xmlHttp.responseText);
					txt2=txt.replace(/\+/gi," ");
					element.innerHTML = txt2;	
					if(elementoHijo == "divCorreo")   {					  
						attachValidation('correo','formulario');			  				  
					}
					if(elementoHijo == "divTelefono")   {					  
						attachValidation('telefonos','formulario');								  				  
					}
					if(elementoHijo == "divComentarioExtra")   {					  
						attachValidation('comentarioExtra','formulario');								  				  
					}																   
			   }
		   }
		  xmlHttp.send(null);
		}
    } 
    
function cambiarClase(id)   {
    xmlHttp2 = ajaxFunction();
    changeAjax02('includes/correo.php', id, 'divCorreo', xmlHttp2);
    xmlHttp3 = ajaxFunction();
    changeAjax02('includes/telefono.php',id, 'divTelefono', xmlHttp3);	
	if( id==1)	
		document.getElementById('labelCorreo').innerHTML='<font color="#c71444">*</font> Correo Electr&oacute;nico:';
	else
		document.getElementById('labelCorreo').innerHTML='Correo Electr&oacute;nico:';
	if(id==2)	
		document.getElementById('labelTelefono').innerHTML='<font color="#c71444">*</font> Debes proporcionar al menos un tel&eacute;fono';		
	else
		document.getElementById('labelTelefono').innerHTML='';
}

function comentarioExtra()   {
	var id = 1;
    xmlHttp4 = ajaxFunction();
    changeAjax02('includes/comentario.php', id, 'divComentarioExtra', xmlHttp4);	
	var linkComentario = document.getElementById('divLinkComentario');
	linkComentario.innerHTML='';
}  

function validaTelefono()   { 
	var telCasa = document.getElementById('telCasa').value;
	var celular = document.getElementById('celular').value;
	var telOficina = document.getElementById('telOficina').value;
	if(telCasa=="" && celular=="" && telOficina=="")   {
		document.getElementById('telefonos').value = '' ;	
	}	
	if(telCasa != "" )
		document.getElementById('telefonos').value = telCasa ;
	if(celular != "" )
		document.getElementById('telefonos').value = celular ;	
	if(telOficina != "" )
		document.getElementById('telefonos').value = telOficina ;	
	document.getElementById('telefonos').focus();
	document.getElementById('comentario').focus();				
}
