// JavaScript Document

function validar() {
	document.formsimple.dominio.value = document.formsimple.dominio.value.toLowerCase();
	var checkOK = "abcdefghijklmnopqrstuvwxyz-0123456789";
    
	var checkStr = document.formsimple.dominio.value;
	var allValid = true;
	var dominio;
	//Aqui obtengo el dato del dominio ingresado

      dominio=checkStr.split(".");
	  checkStr=dominio[0];

	  if (checkStr.length ==0)
         {
		alert("Ingrese el nombre de un dominio para la búsqueda.");
		document.formsimple.dominio.focus();
		return (false);
		 }
	  

	//*******************************************
	for (i = 0; i < checkStr.length; i++) {
		ch = checkStr.charAt(i);
		ch2 = checkStr.charAt(i+1);
		
		if ((ch == "-") && (ch2 == "-"))
		{  
		    allValid = false;
			break; 
		}
		
		for (j = 0; j < checkOK.length; j++)
			if (ch == checkOK.charAt(j))
				break;
		if ((i == 0 || i == (checkStr.length-1)) && ch == "-") {
			allValid = false;
			break; 
		}		
		
		if (j == checkOK.length) {
			allValid = false;
			break;
		}
	}
	if (!allValid) {
		alert("Usted ha ingresado caracteres no válidos en el nombre del dominio o \n Digite solo el nombre del dominio sin la extensión (ej: .com.ec)");
		document.formsimple.dominio.focus();
		return (false);
	}
	return (true);
}

function validareng() {
	document.formsimple.dominio.value = document.formsimple.dominio.value.toLowerCase();
	var checkOK = "abcdefghijklmnopqrstuvwxyz-0123456789";
    
	var checkStr = document.formsimple.dominio.value;
	var allValid = true;
	var dominio;
	//Aqui obtengo el dato del dominio ingresado

      dominio=checkStr.split(".");
	  checkStr=dominio[0];

	  if (checkStr.length ==0)
         {
		alert("Enter a domain name for whois search.");
		document.formsimple.dominio.focus();
		return (false);
		 }
	  

	//*******************************************
	for (i = 0; i < checkStr.length; i++) {
		ch = checkStr.charAt(i);
		ch2 = checkStr.charAt(i+1);
		
		if ((ch == "-") && (ch2 == "-"))
		{  
		    allValid = false;
			break; 
		}
		
		for (j = 0; j < checkOK.length; j++)
			if (ch == checkOK.charAt(j))
				break;
		if ((i == 0 || i == (checkStr.length-1)) && ch == "-") {
			allValid = false;
			break; 
		}		
		
		if (j == checkOK.length) {
			allValid = false;
			break;
		}
	}
	if (!allValid) {
		alert("Invalid characters entered in the domain name or Enter name only without extension (ex: .com.ec)");
		document.formsimple.dominio.focus();
		return (false);
	}
		return (true);
}

function Espanol() {
var respuesta = true;
retorna = validar();
 if (!retorna)
	     {
	     respuesta = false;
         }
 else {
        document.forms(0).action = "http://www.nic.ec/reg/paso2.asp";
		document.forms(0).method="post";
        document.forms(0).submit();  
        respuesta = true; 
      }
  return respuesta
}

function Eng() {
var respuesta = true;
retorna = validareng();
 if (!retorna)
	     {
	     respuesta = false;
         }
 else {
        document.forms(0).action = "http://www.nic.ec/reg/eng/paso2.asp";
        document.forms(0).method="post";
        document.forms(0).submit();  
        respuesta = true; 
      }
  return respuesta
}      

function Inicio()
	{
		document.formsimple.dominio.focus();
		return (false);
	}

