function objetoAjax(){
        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 pedirDatos(){
        //donde se mostrará el resultado
        divResultado = document.getElementById('resultado');        
        nombre = document.frmwhois.txtdominio.value;
        ext = document.frmwhois.extension.value;        
        nom = nombre + "." + ext;        
        
        //instanciamos el objetoAjax
        ajax=objetoAjax();
        
		divResultado.innerHTML = "<img src='../hsimagenes/indicador.gif' border=0> Cargando..."        
        
        //usamos el medoto POST
        //archivo que realizará la operacion
		//datoscliente.php
        ajax.open("POST", "obtenerresultado.php",true);        
        ajax.onreadystatechange=function() {
                if (ajax.readyState==4) {
                        //mostrar resultados en esta capa
                        divResultado.innerHTML = ajax.responseText
                }
        }
        ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
        //enviando los valores
 ajax.send("dominio="+nom)
}


function pedirDatosComprarHosting(){
        //donde se mostrará el resultado
        divResultado = document.getElementById('resultadodominio');                
        
        total = document.frmwhois.hosting.length;        
        
        for ( w=0; w<total; w++)
        {
			if ( document.frmwhois.hosting[w].checked ) 
			{				
				valoractivo = document.frmwhois.hosting[w].value;				
				nombre = document.frmwhois.txtdominio[w].value;
				ext = document.frmwhois.extension[w].value; 				
				
				if(w==0)
				{
					document.frmwhois.txtdominio[1].value = document.frmwhois.txtdominio[w].value;
					document.frmwhois.txtdominio[2].value = document.frmwhois.txtdominio[w].value;
					
					document.frmwhois.extension[1].value = document.frmwhois.extension[w].value;
					document.frmwhois.extension[2].value = document.frmwhois.extension[w].value;
					
				}				
				if(w==1)
				{
					document.frmwhois.txtdominio[0].value = document.frmwhois.txtdominio[w].value;
					document.frmwhois.txtdominio[2].value = document.frmwhois.txtdominio[w].value;
					
					document.frmwhois.extension[0].value = document.frmwhois.extension[w].value;
					document.frmwhois.extension[2].value = document.frmwhois.extension[w].value;
				}
				if(w==2)
				{
					document.frmwhois.txtdominio[0].value = document.frmwhois.txtdominio[w].value;
					document.frmwhois.txtdominio[1].value = document.frmwhois.txtdominio[w].value;
					
					document.frmwhois.extension[0].value = document.frmwhois.extension[w].value;
					document.frmwhois.extension[1].value = document.frmwhois.extension[w].value;
				}
			}			

		}				
               
        nom = nombre + "." + ext;  
        codhost = document.frmwhois.codhostparajs.value;
        
        //instanciamos el objetoAjax
        ajax=objetoAjax();        
		divResultado.innerHTML = "<img src='../hsimagenes/indicador.gif' border=0> Cargando..."        
        
        //usamos el medoto POST
        //archivo que realizará la operacion
		//datoscliente.php
		urlenviar = "obtenerresultado.php?acciondominio=" + valoractivo + "&codhost=" + codhost + "&coddominio=" + ext;
        ajax.open("POST", urlenviar,true);        
        ajax.onreadystatechange=function() {
                if (ajax.readyState==4) {
                        //mostrar resultados en esta capa                        
                        smjHtml = ajax.responseText                        
                        flagExisteDom = smjHtml.charAt(0)
                        smjHtml = smjHtml.substring(1)                        
                        divResultado.innerHTML = smjHtml 
                        if(flagExisteDom == 1)                                                
                        {
                        	document.frmwhois.btn_search.style.display = 'none';
					        document.frmwhois.btn_submit.style.display = '';
                        }
                        if(flagExisteDom == 0)                                                
                        {
                        	document.frmwhois.btn_search.style.display = '';
					        document.frmwhois.btn_submit.style.display = 'none';
                        }
                        
                }
        }		
        ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
        //enviando los valores
        
        
        
 ajax.send("dominio="+nom)
}

