function reviewPass(passfield,cpassfield) {
	if (lang == 'En') {
		pverText = 'Your password must contain at least six characters, including at least one letter and one number.';
	}
	else {
		pverText = 'Tu contraseña debe tener como mínimo seis caracteres incluyendo al menos una letra y un número.';
	}

	var pswd = trim(passfield.value);
	var confirmpswd = trim(cpassfield.value);
	checkPswdAlias1(pswd);
	document.getElementById('tt_content').innerHTML = pverText;
}

function checkPswdAlias1(pswd)
{
	if(pswd == "")
	{
		if (lang == 'En') {
		pverText = 'The password field is mandatory. You must choose a password you can remember every time you need to sign in in the future.';
		}
		else {
		pverText = 'El campo de la contraseña es requerida. Escoge una contraseña que puedas recordar cada vez que quieras ingresar.';
		}
	}
	else
	{
		if(pswd.length < 6 || pswd.length >24)
		{
			if (lang == 'En') {
			pverText = 'Your password must be at least 6 characters long. Please enter additional characters.';
			}
			else {
			pverText = 'Tu contraseña debe tener seis caracteres como mínimo. Por favor, entra los caracteres adicionales.';
			}
		}
		else if(!checkWord(pswd))
		{
			if (lang == 'En') {
			pverText = 'That password contains invalid characters. You may use letters and/or numbers, but "ñ," accents and spaces are not allowed.';
			}
			else {
			pverText = 'La contraseña contiene caracteres inválidos. Puedes usar letras y números solamente. La “ñ”, acentos y espacios no son permitidos.';
			}
		}
		else if(!checkPswd(pswd))
		{
			if (lang == 'En') {
			pverText = 'That password is not valid. Your password must include at least one letter and one number.';
			}
			else {
			pverText = 'La contraseña no es válida. Tu contraseña debe incluir al menos una letra y un número.';
			}
		}
		else {
			if (lang == 'En') {
			pverText = 'The password you have entered is valid!';
			}
			else {
			pverText = '¡La contraseña que has ingresado es válida!';
			}
		}

	}
}
   
function doTheyMatch(x,y) {
	if (y == 'pass') { if (lang == 'En') { var fieldName = 'password'; } else { var fieldName = 'contraseña'; } }
	else { if (lang == 'En') { var fieldName = 'e-mail address'; } else { var fieldName = 'dirección de correo electrónico '; } }
	var field2 = document.getElementById(y);
	if (x.value != field2.value) {
		if (lang == 'En') {
		document.getElementById('tt_content').innerHTML = 'The ' + fieldName + ' you entered does not match the one you entered above.';
		}
		else {
		document.getElementById('tt_content').innerHTML = 'La ' + fieldName + ' que ingresaste no coincide con el que pusiste arriba.';
		}
	}
	else {
		if (lang == 'En') {
		document.getElementById('tt_content').innerHTML = 'The ' + fieldName + ' you entered matches!';
		}
		else {
		document.getElementById('tt_content').innerHTML = 'La ' + fieldName + ' que ingresaste coincide!';
		}
	}
}

var ttObj = false;
var ttObj_iframe = false;

var tt_MSIE = false;
if(navigator.userAgent.indexOf('MSIE')>=0)tt_MSIE=true;

function showtt(externalFile,inputObj,lang)
{
	if(!ttObj)	/* tt div not created yet ? */
	{
		ttObj = document.createElement('DIV');
		ttObj.style.position = 'absolute';
		ttObj.id = 'ttObj';		
		document.body.appendChild(ttObj);

		var leftDiv = document.createElement('DIV');	/* Create arrow div */
		leftDiv.className='tt_arrow';
		leftDiv.id = 'tt_arrow';
		ttObj.appendChild(leftDiv);
		
		var contentDiv = document.createElement('DIV'); /* Create tt content div */
		contentDiv.className = 'tt_content';
		ttObj.appendChild(contentDiv);
		contentDiv.id = 'tt_content';
		
		if(tt_MSIE){	/* Create iframe object for MSIE in order to make the tt cover select boxes */
			ttObj_iframe = document.createElement('<IFRAME frameborder="0">');
			ttObj_iframe.style.position = 'absolute';
			ttObj_iframe.border='0';
			ttObj_iframe.frameborder=0;
			ttObj_iframe.style.backgroundColor='#FFF';
			ttObj_iframe.src = 'about:blank';
			contentDiv.appendChild(ttObj_iframe);
			ttObj_iframe.style.left = '0px';
			ttObj_iframe.style.top = '0px';
		}

			
	}
	// Find position of tt
	ttObj.style.display='block';
	
	if (externalFile == 'pverText') {
		var ttHTML = pverText;
	}
	else {
	for (j=0; j < ttContent.length; j++) {
		if (ttContent[j] == externalFile) {
			var ttHTML = ttContent[j+1];
			break;
		}
	}
	}
	
	document.getElementById('tt_content').innerHTML = ttHTML;
	//loadContent('tt_content',externalFile);
	if(tt_MSIE){
		ttObj_iframe.style.width = ttObj.clientWidth + 'px';
		ttObj_iframe.style.height = ttObj.clientHeight + 'px';
	}

	positiontt(inputObj);
}

function positiontt(inputObj)
{
	var leftPos = (tt_getLeftPos(inputObj) + inputObj.offsetWidth);
	var topPos = tt_getTopPos(inputObj);
	
	/*
	var rightedge=tt_MSIE? document.body.clientWidth-leftPos : window.innerWidth-leftPos
	var bottomedge=tt_MSIE? document.body.clientHeight-topPos : window.innerHeight-topPos
	*/
	var ttWidth = document.getElementById('tt_content').offsetWidth +  document.getElementById('tt_arrow').offsetWidth; 
	// Dropping this reposition for now because of flickering
	//var offset = ttWidth - rightedge; 
	//if(offset>0)leftPos = Math.max(0,leftPos - offset - 5);
	
	ttObj.style.left = leftPos + 'px';
	ttObj.style.top = topPos + 'px';	
	
	
}

function conditionalhidett() {
	if(ttObj) { hidett(); }
}

function hidett()
{
	ttObj.style.display='none';
}

function tt_getTopPos(inputObj)
{		
  var returnValue = inputObj.offsetTop;
  while((inputObj = inputObj.offsetParent) != null){
  	if(inputObj.tagName!='HTML')returnValue += inputObj.offsetTop;
  }
  return returnValue;
}

function tt_getLeftPos(inputObj)
{
  var returnValue = inputObj.offsetLeft;
  while((inputObj = inputObj.offsetParent) != null){
  	if(inputObj.tagName!='HTML')returnValue += inputObj.offsetLeft;
  }
  return returnValue;
}

function setURL() {
	var nickVal = document.getElementById('nick').value;
	if (nickVal != '') {
		document.getElementById('mpurl').innerHTML = nickVal;
	}
	else {
		document.getElementById('mpurl').innerHTML = '[tu nickname]';
	}
}

function reviewNick() {
 
        if (invalidRegAlias1(trim(document.getElementById('nick').value))) {
               if (window.nickTimeout) { window.clearTimeout(window.nickTimeout); }
               if(document.getElementById('nick').value.length < 6 || document.getElementById('nick').value.length >24) {
                       if (lang == 'En') {
                       document.getElementById('nickavail').innerHTML = '<div class="nna">Your nickname must be six characters or longer.</div>';
                       }
                       else {
                       document.getElementById('nickavail').innerHTML = '<div class="nna">Tu nickname debe ser de seis caracteres o más.</div>';
                       }
               }
               else {
                       if (lang == 'En') {
                       document.getElementById('nickavail').innerHTML = '<div class="nna">Your nickname cannot contain accents or other special characters.</div>';
                       }
                       else {
                       document.getElementById('nickavail').innerHTML = '<div class="nna">Tu nickname no puede contener acentos u otros caracteres especiales.</div>';
                       }
               }
        }
        else {
               if (window.nickTimeout) { window.clearTimeout(window.nickTimeout); }
                       if (lang == 'En') {
                       document.getElementById('nickavail').innerHTML = '<div class="nna"><em>Checking nickname...</em></div>';
                       }
                       else {
                       document.getElementById('nickavail').innerHTML = '<div class="nna"><em>Verificando nickname...</em></div>';
                       }
 
               window.nickTimeout = window.setTimeout('checkNick();', 3000);
        }
}

function checkNick()
{
        var req = null;
 
        //document.ajax.nick.value="Started...";
 
        // code for Mozilla, etc.
        if(window.XMLHttpRequest)
               req = new XMLHttpRequest();
        // code for IE
        else if (window.ActiveXObject)
               req  = new ActiveXObject("Microsoft.XMLHTTP");
 
 
    if(req != null)
        {
               req.onreadystatechange = function()
               {
                       //document.ajax.nick.value="Wait server...";
                       if(req.readyState == 4)
                       {
                               if(req.status == 200)
                               {
                                      if(req.responseText == "0")
                                       {
                                              if (lang == 'En') {
                                              document.getElementById('nickavail').innerHTML = '<div class="na">That nickname is available.</div>';
                                              }
                                              else {
                                              document.getElementById('nickavail').innerHTML = '<div class="na">Ese nickname está disponible.</div>';
                                              }
                                      }
                                      else if(req.responseText == "1")
                                              if (lang == 'En') {
                                              document.getElementById('nickavail').innerHTML = '<div class="nna">That nickname is not available.</div>';
                                              }
                                              else {
                                              document.getElementById('nickavail').innerHTML = '<div class="nna">Ese nickname no está disponible.</div>';
                                              }
                                      else
                                      {
                                              if (lang == 'En') {
                                              document.getElementById('nickavail').innerHTML = '<div class="nna">We could not determine whether that nickname is available.</div>';
                                              }
                                              else {
                                              document.getElementById('nickavail').innerHTML = '<div class="nna">No pudimos determinar si el nickname está disponible.</div>';
                                              }
                                      }
                               }
                               else
                               {
                                              if (lang == 'En') {
                                              document.getElementById('nickavail').innerHTML = '<div class="nna">We could not determine whether that nickname is available.</div>';
                                              }
                                              else {
                                              document.getElementById('nickavail').innerHTML = '<div class="nna">No pudimos determinar si el nickname está disponible.</div>';
                                              }
                               }
                       }
               };
               //req.open("GET", "data.xml", true);
               var url = "/membershipservices/check_aliasname.jhtml?alias=" + trim(document.getElementById("nick").value);
               req.open("GET", url, true);
 
               req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
               req.send(null);
        }
        else
        {
               alert("Your browser does not support XMLHTTP.");
        }
 
}

function invalidRegAlias1(alias)
  {
	if(alias == "")
		return true;
	else
	{
	   if(alias.length < 6 || alias.length >24)
	   	return true;	
	   else if(isSpecialWordInAlias(alias))
	   	return true;	
	   else if(!checkWord(alias))
	   	return true;
	}
   	return false;
  }

function trim(argvalue)
{
      var tmpstr = ltrim(argvalue);
      return rtrim(tmpstr);
}

function ltrim(argvalue)
{
      while (1) {
	 if (argvalue.substring(0, 1) != " ")
	    break;
	 argvalue = argvalue.substring(1, argvalue.length);
      }
      return argvalue;
}

function rtrim(argvalue)
{
      while (1) {
	 if (argvalue.substring(argvalue.length - 1, argvalue.length) != " ")
	    break;
	 argvalue = argvalue.substring(0, argvalue.length - 1);
      }
      return argvalue;
}

function  checkWord(strName)
{
	var alphabets="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
	var lowerName
	var temp
	if(strName=="")
	{
	  return false;
	}
	lowerName = strName.toLowerCase();
	for(loopcount=0;loopcount<strName.length;loopcount++)
	{
	  temp=lowerName.substring(loopcount,loopcount+1)

	  if(alphabets.indexOf(temp)==-1)
	  {
	    return false;
	  }
	}
	return true;
}

function clearToBlack(x,y) {
	x.style.color = '#000';
	if (lang == 'En') {
		if (y == 'Nombre') {
			y = 'First Name';
		}
		else if (y == 'Apellido') {
			y = 'Last Name';
		}
	}
	if (x.value == y) {
		x.value = '';
	}
}

function toggleState() {
	if ((document.getElementById('countryId').options[document.getElementById('countryId').options.selectedIndex].value != '223') && (document.getElementById('countryId').options[document.getElementById('countryId').options.selectedIndex].value != '172')) {
		document.getElementById('zip').style.display = 'none';
		document.getElementById('ciuest').style.display = 'block';
	}
	else {
		document.getElementById('ciuest').style.display = 'none';
		document.getElementById('zip').style.display = 'block';	
	}
}

function toggleMP() { return false; }
function setRead() { return false; }
