var isNetscape = false;
var isIE = false;
var isWhoKnows = false;

//This determines which browser the user is using
if (parseInt(navigator.appVersion) >= 4) {
  if(navigator.appName == "Netscape") {
    isNetscape = true;
  }else if (navigator.appName == "Microsoft Internet Explorer"){
    isIE = true;
  }else {
    isWhoKnows = true;
  }
}

//This stuff captures the events of the user
if(isNetscape) {
	document.captureEvents(Event.KEYUP);
}
document.onkeyup = checkValue



function checkValue(evt){
  var theButtonPressed;
  if (isNetscape) {
	//if(evt.target.type == "text"){
		//--> you can specify which type of element
		//    you want this to trigger for
	//if(evt.target.name == "myText"){
		//--> or you can specify the actual name of
		//    the element
		theButtonPressed = evt.which;
	//}
  }else if(isIE) {
	//if (window.event.srcElement.type == "text") {
		//--> same as above, but for IE
		theButtonPressed = window.event.keyCode;
	//}
  }else if(isWhoKnows) {
	//alert("Please hit the submit button to process form");
  }

  if (theButtonPressed == 13) {
	window.form.submit();
  }
}


function DomainCheck (DomainObj) {

/* Paso el valor del objeto                                */
var emailStr = DomainObj.value
/* The following pattern is used to check if the entered e-mail address
   fits the user@domain format.  It also is used to separate the username
   from the domain. */
var emailPat=/^(.+)$/
/* The following string represents the pattern for matching all special
   characters.  We don't want to allow special characters in the address. 
   These characters include ( ) < > @ , ; : \ " . [ ]    */
var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]"
/* The following string represents the range of characters allowed in a 
   username or domainname.  It really states which chars aren't allowed. */
var validChars="\[^\\s" + specialChars + "\]"

/* The following string represents an atom (basically a series of
   non-special characters.) */
var atom=validChars + '+'

/* The following pattern describes the structure of a normal symbolic
   domain, as opposed to ipDomainPat, shown above. */
var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$")


var domain=emailStr



// Domain is symbolic name
var domainArray=domain.match(domainPat)
if (domainArray==null) {
	alert("El dominio contiene caracteres inválidos.")
	DomainObj.focus();
    return false
}

/* domain name seems valid, but now make sure that it ends in a
   three-letter word (like com, edu, gov) or a two-letter word,
   representing country (uk, nl), and that there's a hostname preceding 
   the domain or country. */


if (domain.indexOf(".")<0)
{
	alert("El dominio debe constar por lo menos de \ndos partes separadas por un punto(.)")
	DomainObj.focus();
    return false
}


/* Now we need to break up the domain to get a count of how many atoms
   it consists of. */
var atomPat=new RegExp(atom,"g")
var domArr=domain.match(atomPat)
var len=domArr.length
if (domArr[domArr.length-1].length<2 || 
    domArr[domArr.length-1].length>3) {
   // the address must end in a two letter or three letter word.
   alert("El dominio debe terminar una referencia al pais de dos letras (.ar, .uy, .us),\n o a un dominio de tres (.org, .com, .mil)  ")
   DomainObj.focus();
   return false
}

if (document.all["dominio"])
{

	if (domain.substr(0,3)=="www" || domain.substr(0,3)=="WWW")
	{
		Len = domain.length - 4
	
		domain = domain.substr(4,Len)
	}

document.all["dominio"].value="www."+domain

}

// If we've gotten this far, everything's valid!
return true;
}
//  End -->

