﻿// JScript File
var calloutDiv;
var popupDiv;
var arrowDiv;
var FixedErrorMessage = false;
var PasswordHintShowing = false;
function findPos(obj) 
{
	var curleft = curtop = 0;
	if(obj != null)
	{
	    if (obj.offsetParent) 
	    {
		    curleft = obj.offsetLeft
		    curtop = obj.offsetTop
		    while (obj = obj.offsetParent) 
		    {
			    curleft += obj.offsetLeft
			    curtop += obj.offsetTop
		    }
	    }
	}
	return [curleft,curtop];
}
function Bounds(x,y,w,h)
{
   this.x = x;
   this.y = y;
   this.h = h;
   this.w = w;
}
function ShowError(ctl,msg,msg2)
{
   var bnds = findLocation(ctl);
   //alert(ctl);
   ShowPO(bnds);
   var ErrorDivID = document.getElementById("DivErrorText");
   //alert(ErrorDivID);
   if (ErrorDivID != null)
   {
      var errHTML = '';
      if (msg != null)
         errHTML = '<div class="clsPopupText1">' + msg + '</div>';
      if (msg2 != null)
         errHTML += '<div class="clsPopupText2">' + msg2 + '</div>';
      ErrorDivID.innerHTML += errHTML;
   }
}
function ShowPWDHint()
{
   var pwd = document.getElementById("txtpassword");
   ShowHint(pwd,'Hint: Make your password more secure', 
            '- Use letters and numbers<br/>- Use special characters (e.g., @)<br/>- Mix lower and uppercase');
   PasswordHintShowing = true;
}
function ShowHint(ctl,msg,msg2)
{
   var bnds = findLocation(ctl);
   ShowPO(bnds);
   var ErrorDivID = document.getElementById("DivErrorText");
   if (ErrorDivID != null)
   {
      var errHTML = '';
      if (msg != null)
         errHTML = '<div class="clsPopupHint1">' + msg + '</div>';
      if (msg2 != null)
         errHTML += '<div class="clsPopupText2">' + msg2 + '</div>';
      ErrorDivID.innerHTML += errHTML;
   }
}
function ShowPO(bnds)
{
   if (calloutDiv == null)
   {
      CreatePO(bnds);
   }
   else
   {
      var id = document.getElementById("DivErrorText");
      if (id != null)
         id.innerHTML = '';
      SetCalloutPosition(bnds);
      calloutDiv.style.display = 'block';
   }
}
function HidePO()
{
   if (calloutDiv != null)
      calloutDiv.style.display = 'none';
}
function SetCalloutPosition(bnds)
{
   var popupX =  bnds.x + bnds.w -15;
   if (popupX < 0)
      popupX = 0;
   calloutDiv.style.left = popupX + 'px';
   var popupY = bnds.y - 48 + bnds.h/2;
   if (popupY < 0)
       popupY = 0;
   calloutDiv.style.top = popupY + 'px';
   if(FixedErrorMessage)
   {
      calloutDiv.style.position = 'fixed';
   }
}
function CreatePO(bndsin)
{
   var bnds;
   if (bndsin == null)
      return;
   bnds = bndsin;
   var innerDiv = document.createElement("div");
   innerDiv.id = 'DivErrorText';
   innerDiv.className = 'clsPopupInnerDiv';
   //alert("created");
   var arrowDiv = document.createElement("div");
   if(is.ie6 || is.ie55)
   {
        arrowDiv.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='../images/pop_pointer_left.png', sizing='scale'); z-index:3";
       arrowDiv.className = 'clsie6ErrorArrow';
   }
   else
   {
       arrowDiv.className = 'clsErrorArrow';
   }
   arrowDiv.id = 'arrowDiv';
   calloutDiv = document.createElement("div");
   calloutDiv.id = 'calloutdiv';
   calloutDiv.className = 'clsPopupDiv';
   calloutDiv.style.display = 'block';
   calloutDiv.style.border = 'none';
   SetCalloutPosition(bnds);
   calloutDiv.style.zIndex = 100009;
   var topDiv = document.createElement("div");
   
   calloutDiv.appendChild(topDiv);
   var botDiv = document.createElement("div");
   
   calloutDiv.appendChild(botDiv);
   var leftDiv  = document.createElement("div");
   var rightDiv = document.createElement("div");
   if(is.ie6 || is.ie55)
   {
       rightDiv.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='../images/pop_warn_right.png', sizing='scale'); z-index:3";
       rightDiv.className = 'clsie6PopupRight';
   }
   else
   {
       rightDiv.className = 'clsPopupRight';
   }
   if(is.ie6 || is.ie55)
   {
       leftDiv.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='../images/pop_warn_left.png', sizing='scale'); z-index:3";
       leftDiv.className = 'clsie6PopupLeft';
   }
   else
   {
       leftDiv.className = 'clsPopupLeft';
   }
   if(is.ie6 || is.ie55)
   {
       topDiv.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='../images/pop_warn_top.png', sizing='scale'); z-index:3";
       topDiv.className = 'clsie6PopupTop';
   }
   else
   {
       topDiv.className = 'clsPopupTop';
   }
   if(is.ie6 || is.ie55)
   {
       botDiv.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='../images/pop_warn_bottom.png', sizing='scale'); z-index:3";
       botDiv.className = 'clsie6PopupBottom';
   }
   else
   {
       botDiv.className = 'clsPopupBottom';
   }
   
   
   
   calloutDiv.appendChild(leftDiv);
   calloutDiv.appendChild(rightDiv);
   calloutDiv.appendChild(arrowDiv);
   calloutDiv.appendChild(innerDiv);
   if (is.ie7)
   {
      //leftDiv.style.top = '15px';
      //rightDiv.style.top = '15px';
      //innerDiv.style.top = '15px';
      innerDiv.style.width = '242px';
   }
   hookupdiv = document.getElementById("dynHookup");
   if (hookupdiv != null)
   {
      document.body.insertBefore(calloutDiv, hookupdiv);
   }
   else
   {
      calloutDiv = null;
   }
}
function getClientBounds() 
{
   var clientWidth;
   var clientHeight;

   if (is.ie6 || is.ie7)
   {
       clientWidth = document.documentElement.clientWidth;
       clientHeight = document.documentElement.clientHeight;
   }
   else
      if (is.safari)
      {
          clientWidth = window.innerWidth;
          clientHeight = window.innerHeight;
      }
      else
         if (is.opera)
         {
             clientWidth = Math.min(window.innerWidth, document.body.clientWidth);
             clientHeight = Math.min(window.innerHeight, document.body.clientHeight);
         }
         else
         {
             clientWidth = Math.min(window.innerWidth, document.documentElement.clientWidth);
             clientHeight = Math.min(window.innerHeight, document.documentElement.clientHeight);
         }
   return new Bounds(0, 0, clientWidth, clientHeight);
}

function findLocation(element)
{
    if(element != null)
    {
       var p = findPos(element);
       var w = (element.style.width != "" ? parseInt(element.style.width.replace("px","")) : element.scrollWidth);
       var h = (element.style.height != "" ? parseInt(element.style.height.replace("px","")) : element.scrollHeight);
       //var w = element.scrollWidth;
       //var h = element.scrollHeight;
       return new Bounds(p[0],p[1],w,h);
    }
    else
    {
       return new Bounds(0,0,0,0);
    }
}

function ValidateEmailAddress(box,dis)
{
    if(box != null)
    {
       var addr = box.value;
       if (addr != null && addr.length > 0)
       {
          if (!ValidateEmailAddress2(box))
          {
              box.style.color = "red";
              ShowError(box,'Not a valid email address','We’re sorry, this is not the correct format for an email address.');
              if (dis == null)
                 DisableButtons();
              else
              {
                 if (dis == 'L')
                    EnableLoginButton();
              }
          }
          else
          {
             box.style.color = "#363636";
             if (dis == null)
             {
                ValidateConfirmEmailAddress(document.getElementById('txtEmailConfirm'));
             }
          }
       }
   }
}
function ValidateEmailAddress2(box)
{
    if(box == null)
        return true;
    var addr = box.value;
    if (addr != null && addr.length > 0)
    {
        if (!isEmailAddr(addr))
        {
            return false;
        }
        return true;
    }
    return false;
}
function ValidateConfirmEmailAddress(box)
{
   var V = ValidateConfirmEmailAddress2(box);
   switch (V)
   {
      case -1:
         break;
      case 0:
         box.style.color = "#363636";
         ValidateSignUpPage2();
         break;
      case 1:
         box.style.color = "red";
         ShowError(box,'Not a valid email address','We’re sorry, this is not the correct format for an email address.');
         DisableButtons();
         break;
      case 2:
         box.style.color = "red";
         ShowError(box,'Please ensure that your email addresses match.','');
         DisableButtons();
         break;
   }
}
// return 0, OK, 1 bad address, 2 no match, -1 empty
function ValidateConfirmEmailAddress2(box)
{
    if(box == null)
        return 0;
   var caddr = box.value;
   if (caddr != null && caddr.length > 0)
   {
      if (!isEmailAddr(caddr))
      {
          return 1;
      }
      var addrp =document.getElementById('txtEmail');
      if (addrp != null)
      {
         var addr = addrp.value;
         if (addr == null || addr != caddr)
         {
            return 2;
         }
      }
      else
      {
         return -1;
      }
      return 0;
   }
   return -1;
}
function ValidateEmailAddressP(box)
{
   var addr = box.value;
   if (addr != null && addr.length > 0)
   {
      if (!ValidateEmailAddress2(box))
      {
          box.style.color = "red";
          ShowError(box,'Not a valid email address','We’re sorry, this is not the correct format for an email address.');
      }
      else
      {
         box.style.color = "#363636";
         ValidateConfirmEmailAddressP(theConfirmEmailBox);
      }
   }
}
function ValidateConfirmEmailAddressP(box)
{
   var caddr = box.value;
   if (caddr != null && caddr.length > 0)
   {
      if (!isEmailAddr(caddr))
      {
          box.style.color = "red";
          ShowError(box,'Not a valid email address','We’re sorry, this is not the correct format for an email address.');
      }
      else
      {
          box.style.color = "#363636";
      }
      if (theEmailBox != null)
      {
         var addr = theEmailBox.value;
         if (addr == null || addr != caddr)
         {
            box.style.color = "red";
            ShowError(box,'Please ensure that your email addresses match.','');
         }
         else
         {
            box.style.color = "#363636";
         }
      }
   }
}
function ValidateSignUpPage1()
{
   if (ValidateEmailAddress2(document.getElementById('txtEmail')))
   {
      if (ValidateConfirmEmailAddress2(document.getElementById('txtEmailConfirm'))==0)
      {
         ValidateSignUpPage2();
      }
   }
}
function ValidateSignUpPage2()
{
   var cbxTerms;
   cbxTerms = document.getElementById('cbxTerms');
   if (cbxTerms != null)
   {
      if (cbxTerms.checked)
      {
         var sn = document.getElementById('txtScreenName');
         if (sn != null && sn.value.length > 0)
         {
            var sntxt = sn.value;
            if (isScreenNameValid(sntxt))
            {   
               if (ValidatePasswords2())
               {
                  if (NoReds()) {
                      submit1.disabled = false;
                      submit2.disabled = false;
                      submit1.style.cursor = 'pointer';
                      submit2.style.cursor = 'pointer';
                      submit1.src = 'images/buttonB_SignUp.gif';
                      submit2.src = 'images/buttonB_SignUpCreateProfile.gif';
                      return;
                  }
               }
            }
         }
      }
   }
   DisableButtons();
}

function NoReds() {
    var hasRed = false;
    var txtEmail = document.getElementById("txtEmail");
    var txtEmailConfirm = document.getElementById("txtEmailConfirm");
    var txtScreenName = document.getElementById("txtScreenName");
    var txtpassword = document.getElementById("txtpassword");
    var txtpasswordConfirm = document.getElementById("txtpasswordConfirm");
    if(txtEmail != null)
        hasRed = txtEmail.style.color != "red";
        
    if(!hasRed && txtEmailConfirm != null)
        hasRed = txtEmailConfirm.style.color != "red";
        
    if(!hasRed && txtScreenName != null)
        hasRed = txtScreenName.style.color != "red";
        
    if(!hasRed && txtpassword != null)
        hasRed = txtpassword.style.color != "red";
        
    if(!hasRed && txtpasswordConfirm != null)
        hasRed = txtpasswordConfirm.style.color != "red";
    
   return hasRed;
}

function ValidateScreenName()
{
   var ctl = document.getElementById('txtScreenName');
   if (ctl != null && ctl.value != null)
   if (isScreenNameValid(ctl.value))
      return;
   ctl.style.color = "red";
   ShowError(ctl,'Screen Name is not valid!',
                 'Screen must not contain any of these characters: <span style="font-weight:bold; font-size:13px;"> = ; / # ? : </span>');
}
function ValidateStationName()
{
   var ctl = document.getElementById('txbStationName');
   if (ctl != null && ctl.value != null)
   if (isScreenNameValid(ctl.value))
    {
        if(InvalidStationName)
        {
            HidePO();
            InvalidStationName = false;
        }
    }
    else
    {
        ShowError(ctl,'Invalid Characters',
        'The characters: [<span style="font-weight:bold; font-size:13px;"> = ; / # ? : </span>] are not allowed in a station name.  Please try choosing another name.');
        InvalidStationName = true;
    }
}
function DisableButtons()
{
   submit1.disabled = true;
   submit2.disabled = true;   
   submit1.style.cursor = 'default';
   submit2.style.cursor = 'default';
   submit1.src = 'images/buttonB_SignUp_inactive.gif';
   submit2.src = 'images/buttonB_SignUpCreateProfile_inactive.gif';
}
function ValidatePasswords()
{
   var pwd = document.getElementById('txtpassword');
   var pwd2 = document.getElementById('txtpasswordConfirm');
   if (pwd != null && pwd2 != null && pwd.value.length > 0)
   {
      if (pwd.value != pwd2.value)
      {
         if (pwd2.value.length > 0)
            PWDMatchError(pwd2);
         DisableButtons();
         return false;
      }
      else
      {
         ValidateSignUpPage1();
         pwd2.style.color = '#363636';
         pwd.style.color = '#363636';
         return true;
      }
   }
   DisableButtons();
   return false;
}

function ValidatePasswords2()
{
   var pwd = document.getElementById('txtpassword');
   var pwd2 = document.getElementById('txtpasswordConfirm');
   if (pwd != null && pwd2 != null && pwd.value.length > 0)
   {
      if (pwd.value != pwd2.value)
      {
         return false;
      }
      else
      {
         return PWDStrongEnough(SetPWDStrength(pwd));
      }
   }
   return false;
}
function ShowInUsePopUp()
{
   if (ErrorMsg1.length > 0)
   {
      if (ErrorMsg2.length > 0) {
         box.style.color = "red";
         ShowError(document.getElementById('txtEmail'),ErrorMsg1,ErrorMsg2);
      } else {
         box.style.color = "red";
         ShowError(document.getElementById('txtEmail'),ErrorMsg1,'');
      }
   }
   else
   {
      if (ErrorMsg2.length > 0)
      {
         box.style.color = "red";
         ShowError(document.getElementById('txtScreenName'),ErrorMsg2,'');
      }
   }
}
function ShowCaptchaError()
{
    ShowError(document.getElementById('recaptcha_response_field_2'),"Recaptcha Error","Type the words shown in the image into these boxes.");
}

function LoginErrorPopUp()
{
   if (ErrorMsg1.length > 0)
   {
      if (ErrorMsg2.length > 0)
      {
         var MessageAncore = document.getElementById('ErrorAncore');
         if(MessageAncore == null)
         {
            MessageAncore = document.getElementById('txtEmail');
         }
         ShowError(MessageAncore,ErrorMsg1,ErrorMsg2);
      }
      else
      {
         ShowError(document.getElementById('txtEmail'),ErrorMsg1,'');
      }
   }
   else
   {
      if (ErrorMsg2.length > 0)
         ShowError(document.getElementById('txtPassword'),ErrorMsg2,'');
   }
}
function EnableLoginButton()
{
   var em = document.getElementById('txtEmail');
   var pw = document.getElementById('txtPassword');
   var btn = document.getElementById('imgLogin');
   if (em != null && em.value.length > 0 && isEmailAddr(em.value))
   {
      if (pw != null && pw.value.length > 0)
      {
         btn.src = 'images/buttonB_Login.gif';
         btn.style.cursor = 'pointer';
         btn.disabled = false;
         return;
      }
   }
   btn.src = 'images/buttonB_Login_inactive.gif';
   btn.style.cursor = 'default';
   btn.disabled = true;
}

function ForgotPasswordEmailErrorPopUp()
{
   if (ErrorMsg1.length > 0)
   {
      ShowError(document.getElementById(TextBoxEmailClientID),ErrorMsg1,ErrorMsg2);
   }
}

function ChangePasswordsValidation1(vx)
{
   var pwd = document.getElementById('txtpassword');
   var pwd2 = document.getElementById('txtpasswordConfirm');
   var pwdstrength =  SetPWDStrength(pwd);
   if (pwd != null && pwd2 != null)
   {
      if (pwdstrength == '' || pwdstrength == 'none' || (pwdstrength == 'weak'))
      {
         pwd.style.color = "red";
         ShowError(pwd,'Please check your password.', 'Your new password must be at least 6 characters and contain no spaces.');
         EnableSubmit(false,vx);
         return false;
      }
      if (pwd.value != pwd2.value)
      {
          if(pwd2.value.length > 0)
             PWDMatchError(pwd2);
          EnableSubmit(false,vx);
          return false;
       }
       if (vx == null)
       {
          var newPassword = document.getElementById(newPasswordClientID);
          newPassword.value = pwd.value;
       }
       EnableSubmit(OldPasswordSet(),vx);
       pwd2.style.color = '#363636';
       pwd.style.color = '#363636';
       return true;
   }
   EnableSubmit(false,vx);
   return false;
}
function ChangePasswordsValidation2(vx)
{
   var pwd = document.getElementById('txtpassword');
   var pwd2 = document.getElementById('txtpasswordConfirm');
   var ChangePasswordButton = document.getElementById(ChangePasswordButtonClientID);
   var newPassword = document.getElementById(newPasswordClientID);
   var pwdstrength =  SetPWDStrength(pwd);
   if (pwd != null && pwd2 != null)
   {
      if (pwdstrength == '' || pwdstrength == 'none' || (pwdstrength == 'weak'))
      {
         ShowError(pwd,'Please check your password.', 'Your new password must be at least 6 characters and contain no spaces.');
         ChangePasswordButton.disabled = true;
         return false;
      }
      if (pwd.value != pwd2.value)
      {
          PWDMatchError(pwd2);
          EnableSubmit(false,vx);
          return false;
       }
       newPassword.value = pwd.value;
       EnableSubmit(OldPasswordSet(),vx);
       pwd2.style.color = '#363636';
       pwd.style.color = '#363636';
       return true;
   }
   EnableSubmit(false,vx);
   return false;
}

function ChangePasswordsValidation3(vx)
{
   var pwd = document.getElementById('txtpassword');
   var pwd2 = document.getElementById('txtpasswordConfirm');
   var ChangePasswordButton = document.getElementById(ChangePasswordButtonClientID);
   var newPassword = document.getElementById(newPasswordClientID);
   var pwdstrength =  SetPWDStrength(pwd);
   if (pwd != null && pwd2 != null)
   {
      if (pwd.value == pwd2.value && (pwdstrength == "medium" || pwdstrength == "strong" || pwdstrength == "best"))
      {
          newPassword.value = pwd.value;
          EnableSubmit(OldPasswordSet(),vx);
          pwd2.style.color = '#363636';
          pwd.style.color = '#363636';
          return true;
       }
   }
   EnableSubmit(false,vx);
   return false;
}

function EnableSubmit(f,vx)
{
   if (vx)
   {
      if (!f)
         DisableButtons();
      return;
   }
   var ChangePasswordButton = document.getElementById(ChangePasswordButtonClientID);
   if (f)
   {
       ChangePasswordButton.disabled = false;
       ChangePasswordButton.style.cursor = 'pointer';
       ChangePasswordButton.src = 'images/buttonB_Submit.gif';
   }
   else
   {
       ChangePasswordButton.disabled = true;
       ChangePasswordButton.style.cursor = 'default';
       ChangePasswordButton.src = 'images/buttonB_Submit_inactive.gif';
   }
}
function PWDMatchError(pwd)
{
    pwd.style.color = "red";
    ShowError(pwd,'Your passwords do not match.', 'Please try again.');
}
function ValidateSendPassEmailAddress(box)
{
    if(box != null)
    {
       var addr = box.value;
       if (addr != null && addr.length > 0)
       {
          if (!ValidateEmailAddress2(box))
          {
              ShowError(box,'Not a valid email address','We’re sorry, this is not the correct format for an email address.');
              if ( sendPassBtn != null)
              {
                  sendPassBtn.disabled = true;
                  sendPassBtn.style.cursor = 'default';
                  sendPassBtn.src = 'images/button_submit.gif';
              }
          }
          else
          {
            if ( sendPassBtn != null)
            {
                  sendPassBtn.disabled = false;
                  sendPassBtn.style.cursor = 'pointer';
                  sendPassBtn.src = 'images/button_submit.gif';
                  HidePO();
            }
         }
       }
       else
       {
            if ( sendPassBtn != null)
            {
                  sendPassBtn.disabled = true;
                  sendPassBtn.style.cursor = 'default';
                  sendPassBtn.src = 'images/button_submit.gif';
            }
       }
   }
}

function NoMatchOldPassErrorPopUp()
{
    var ChangePasswordButton = document.getElementById(ChangePasswordButtonClientID);
    if (ErrorMsg2.length > 0)
    {
         ShowError(document.getElementById('txtpasswordOld'),ErrorMsg1,ErrorMsg2);
         ChangePasswordButton.disabled = true;
    }
}

function OldPasswordSet()
{
   var rv = false;
   var opw = document.getElementById('txtpasswordOld');
   if (opw == null)
      return true;
   if (opw.value.length > 0)
      rv = true;
   return rv;
}

function DoLogin(e)
{
    var LoginBtn = document.getElementById('imgLogin');
    if(LoginBtn.disabled == false)
    {
        oEvent = (window.event) ? window.event : e;
        if (oEvent.keyCode == 13)
        {
            oEvent.returnValue=false; 
            oEvent.cancel = true;
            var LoginForm = document.getElementById('aspnetForm');
            LoginForm.submit();
            return;
        }
    }
}
function PWDStrongEnough(str)
{
   if (str == 'medium' || str == 'strong' || str == 'best')
      return true;
   return false;
}
function CheckHint()
{
    var pwd = document.getElementById('txtpassword');
    var pwdStrength =  SetPWDStrength(pwd);
    if(pwdStrength == 'best' || pwdStrength == 'strong')
    {
        HidePO();
    }
    else
    {
        ShowPWDHint();
    }
}
function SetPWDStrength(box)
{
   var pwdStrength = '';
   if (box != null)
   {
      if (box.value)
      {
         var pwd = box.value;
         var pwdl = pwd.length;
         var nb = NumBlanks(pwd);
         if (pwdl == 0 || nb > 0)
         {
            pwdStrength = 'none';
         }
         else
         {
            if (pwdl < 6)
            {
               pwdStrength = 'weak';
            }
         }
         if (pwdStrength == '')
         {
            pwdStrength = 'weak';
            var nCaps = NumCaps(pwd);
            var nLC = NumLC(pwd);
            var nDigits = NumDigits(pwd);
            var nSpecial = pwdl - nCaps - nLC - nDigits;
            if (nSpecial < 0) nSpecial = 0;
            if (nDigits == pwdl || nCaps == pwdl || nLC == pwdl)
            {
               pwdStrength = 'medium';
            }
            if (nCaps > 0 && nLC > 0)
               pwdStrength = 'strong';
            if (nDigits > 0 && (nLC + nCaps) > 0)
               pwdStrength = 'strong';
            if (nSpecial > 0 && (nCaps + nDigits + nLC) > 0)
               pwdStrength = 'strong';
            if (nDigits > 0 && nCaps > 0 && nLC > 0 && ((nDigits + nCaps + nLC) < pwdl))
               pwdStrength = 'best';
         }
      }
   }
    SetStrengthImages(pwdStrength);
    if(PasswordHintShowing)
    {
        switch(pwdStrength)
        {
            case 'strong':
            case 'best':
                HidePO();
                box.style.color = "#363636";
                break;
            default:
                //ShowPWDHint();
                break;
        }
    }
    return pwdStrength;
}
function SetStrengthImages(strength)
{
   var ax = 0;
   var strengths = "weak,medium,strong,best";
   var strengthColors = "red,orange,blue,green";
   
   var images = new Array();
   images["weak"] = 'images/strength_grey_weak.gif';
   images["medium"] = 'images/strength_grey_medium.gif';
   images["strong"] = 'images/strength_grey_strong.gif';
   images["best"] = 'images/strength_grey_best.gif';
   images[strength] = 'images/strength_black_' + strength + '.gif';
   var astrengths = strengths.split(",");
   var astrengthColors = strengthColors.split(",");
   var imgpath = 'images/strength_black.gif';
   if (!(strength == "none" || strength == ""))
   {   
      ax = 0;
      while (ax < 4)
      {
         var sIndex = ax++;
         var st = astrengths[sIndex];
         var stColor = astrengthColors[sIndex];
         //alert(stColor);
         if (st == strength)
         {
            images[st] = 'images/strength_' + stColor + '_' + strength + '.gif';
            break;
         }
        images[st] = 'images/strength_' + stColor + '.gif';;
      }
   }
   ax = 0;
   while (ax < 4)
   {
      var st = astrengths[ax++];
      var I = document.getElementById('img' + st);
      if (I != null)
      {
         I.src = images[st];
      }
   }
}

function NumDigits(s)
{
   var rv = 0;
   if (typeof s == "string")
   {
      var l = s.length;
      var x = 0;
      while (x < l)
      {
         var c = s.charCodeAt(x++);
         if (c >= 48 && c <= 57)
            rv++;
      }
   }
   return rv;
}
function NumCaps(s)
{
   var rv = 0;
   if (typeof s == "string")
   {
      var l = s.length;
      var x = 0;
      while (x < l)
      {
         var c = s.charCodeAt(x++);
         if (c >= 65 && c <= 90)
            rv++;
      }
   }
   return rv;
}
function NumLC(s)
{
   var rv = 0;
   if (typeof s == "string")
   {
      var l = s.length;
      var x = 0;
      while (x < l)
      {
         var c = s.charCodeAt(x++);
         if (c >= 97 && c <= 122)
            rv++;
      }
   }
   return rv;
}
function NumBlanks(s)
{
// REALLY NUMBER OF JUNK CHARACTERS, either blank, control or non-ascii.
   var rv = 0;
   if (typeof s == "string")
   {
      var l = s.length;
      var x = 0;
      while (x < l)
      {
         var c = s.charCodeAt(x++);
         if (c <= 32 || c > 126)
            rv++;
      }
   }
   return rv;
}

var t;
var keeptesting = true
function CheckEnableLoginButton()
{
    var btn = document.getElementById('imgLogin');
    if(btn.disabled == true)
    {
        t=setTimeout("CheckFields()",200);  
    }
}
function CheckFields()
{
    EnableLoginButton();
    CheckEnableLoginButton()
}
function PageLoadCheckEnableLoginButton()
{
        t=setTimeout("CheckFields()",1000);  
}
var emailbox;
function CheckEnablePasswordButton(obj)
{
    emailbox = obj
    t=setTimeout("CheckForgotPasswordField()",5000);  
}
function ResetPasswordButton()
{
    clearTimeout(t);
    HidePO();
}
function CheckForgotPasswordField()
{
    ValidateSendPassEmailAddress(emailbox)
}
var CheckForNewEmail = false;
function CheckNewEmail()
{
    var EmailConfirmTr = document.getElementById('EmailConfirmTr');
    if(theEmailBox.value == orginalEmail)
    {
        //EmailConfirmTr.style.display = 'none';
        EmailConfirmTr.style.visibility = 'hidden';
        theConfirmEmailBox.value = orginalEmail;
        CheckForNewEmail = false;
    }
    else
    {
        //EmailConfirmTr.style.display = '';
        EmailConfirmTr.style.visibility = '';
        theConfirmEmailBox.value = '';
        CheckForNewEmail = true;
        theEmailBox.style.color = "#363636";
    }    
}
var ibtSaveButton;
function ValidateEmail_Succeeded_Callback(result) {
    if (!result) {
        ShowError(valField,'This email address has already been registered.','');
        valField.style.color = "red";
    } else {
        valField.style.color = "#363636";
    }
    if(ibtSaveButton != null)
        EnableSaveButton();
}

function ValidateEmail_Failed_Callback() {
    //
}

function CheckLoadEmailField()
{
    var emailbox = document.getElementById(TextBoxEmailClientID);
    ValidateSendPassEmailAddress(emailbox);
}
var TagLineTimer
var oTagLineBox
function CheckTagLine(tagLineBox)
{
    clearTimeout(TagLineTimer);
    oTagLineBox = tagLineBox;
    var TagLineTest = document.getElementById('TagLineTest');
    TagLineTest.innerHTML = "Personal Tagline: " + tagLineBox.value;
    if(TagLineTest.offsetHeight > 35 || TagLineTest.offsetWidth > 352)
    {
        ShowError(tagLineBox,'Too Long','You have exceeded the character limit for this field.');
        TagLineTimer = setTimeout("TruncateTagline()",DisplayErrorTime * 1000);  
    }
    else
    {
        HidePO();
    }
    EnableSaveButton();
}
function TruncateTagline()
{
    var TagLineTest = document.getElementById('TagLineTest');
    while(TagLineTest.offsetHeight > 35 || TagLineTest.offsetWidth > 352)
    {
        oTagLineBox.value = oTagLineBox.value.substring(0,oTagLineBox.value.length - 1);
        TagLineTest.innerHTML = "Personal Tagline: " + oTagLineBox.value;
    }
    HidePO();
    EnableSaveButton();
}
function AddAnotherFindMe()
{
    if(AddAnotherActive)
    {
        var FindMeAtTbl = document.getElementById('FindMeAtTbl');
        var TotalRows = document.getElementById('TotalRows');
        var newRow, textBoxCell, RemoveButtonCell;
        if (FindMeAtTbl != null)
        {
            var FindMeID = FindMeAtTbl.rows.length + 1;
            newRow = FindMeAtTbl.insertRow(FindMeAtTbl.rows.length);
            textBoxCell = newRow.insertCell(0);
            RemoveButtonCell = newRow.insertCell(1);
            RemoveButtonCell.style.verticalalign = 'middle';
            RemoveButtonCell.style.paddingleft = '2px';
            var removeID = "imgRemoveFindMeAt"+FindMeID;
            var FindMeAtTextID = "txtFindMeAt"+FindMeID;
            newRow.id = "trFindMeAt"+FindMeID;
            textBoxCell.innerHTML = "<input type='Text' name='" + FindMeAtTextID + "' id='" + FindMeAtTextID + "' onkeyup=\"CheckAddAnotherLink();\" onblur=\"CheckAddAnotherLink();\" onmouseout=\"CheckAddAnotherLink();\" class=\"formText arial font12 darkBlue\" style=\"width:324px;\">";
            RemoveButtonCell.innerHTML = " <img onclick=\"RemoveFindMeAt(this)\" id='" + removeID + "' src='images/button_x_out.gif' Width='16' Height='16' alt='Remove' title='Remove' onmouseover=\"findMeRemoveButtonOver(this)\" onmouseout=\"findMeRemoveButtonOut(this)\" />";
            RemoveButtonCell.style.paddingLeft = "2px";
            CheckAddAnotherLink();
            TotalRows.value = FindMeID;
            
            if(visibleRows == 3 || FindMeID == 2)
            {
                var rows = FindMeAtTbl.getElementsByTagName('tr');
                for(iRows = 0; iRows < rows.length; iRows++)
                {
                    if(rows[iRows].style.display == '')
                    {
	                    var RemoveButton = document.getElementById(rows[iRows].id.replace("trFindMeAt","imgRemoveFindMeAt"));
	                    if(RemoveButton.alt == "Clear")
	                    {
                            RemoveButton.alt = "Remove";
                            RemoveButton.title = "Remove";
                        }
                    }
                }
            }
        }
    }
}
function findMeRemoveButtonOver(button)
{
    button.src=button.src.replace('out','over');
}
function findMeRemoveButtonOut(button)
{
    button.src=button.src.replace('over','out');
}
function findMeRemoveButtonInactiveOver(button)
{
    button.src = '/images/button_x_inactiveover.gif';
}
function findMeRemoveButtonInactiveOut(button)
{
    button.src = '/images/button_x_inactiveout.gif';
}
var AddAnotherActive = false;
var visibleRows = 0;
function CheckAddAnotherLink()
{
    AddAnotherActive = true;
    var AddAnotherFindMe = document.getElementById('AddAnotherFindMe');
    var FindMeAtTbl = document.getElementById('FindMeAtTbl');
    var rows = FindMeAtTbl.getElementsByTagName('tr');
    var LastTrID = '';
    visibleRows = 0;
    for (var row=0; row<rows.length;row++) 
    {
        if(rows[row].style.display == '')
        {
            var txBArray = rows[row].getElementsByTagName('input');
            for (var itxb=0; itxb<txBArray.length;itxb++) 
            {
                if(txBArray[itxb].value == '')
                {
                    AddAnotherActive = false;
                }
            }
            if(AddAnotherActive)
            {
                var RemoveButton = document.getElementById(rows[row].id.replace("trFindMeAt","imgRemoveFindMeAt"));
                RemoveButton.src = '/images/button_x_out.gif';
            }
        }
        else
        {
            visibleRows++;
            LastTrID = rows[row].id;
        }
    }
    if(!AddAnotherActive)
    {
        AddAnotherFindMe.className = "DeactivatedLink"
        if(visibleRows == 3)
        {
            var RemoveButton = document.getElementById(LastTrID.replace("trFindMeAt","imgRemoveFindMeAt"));
            RemoveButton.src = '/images/button_x_inactiveout.gif';
        }
    }
    else
    {
        AddAnotherFindMe.className = "AddFindMeAtLink";
    }
}
function EnableEnterButton()
{
   var em = document.getElementById('txbBetaEmail');
   var pw = document.getElementById('txbInvitationCode');
   var btn = document.getElementById(ibtEnterBeta);
   if(btn != null)
   {
       if (em != null && em.value.length > 0 && isEmailAddr(em.value))
       {
          if (pw != null && pw.value.length > 0)
          {
             btn.src = 'images/buttonB_Enter.gif';
             btn.style.cursor = 'pointer';
             btn.disabled = false;
             return;
          }
       }
       btn.src = 'images/buttonB_Enter_inactive.gif';
       btn.style.cursor = 'default';
       btn.disabled = true;
   }
}
var theEmailBox;
var theConfirmEmailBox;
function EnableSaveButton()
{
    var blDisableSaveButton = false;
    if(theEmailBox != null)
    {
        blDisableSaveButton = theEmailBox.style.color == "red";
    }
    if(!blDisableSaveButton && theConfirmEmailBox != null)
    {
        blDisableSaveButton = theConfirmEmailBox.style.color == "red";
    }
    if(!blDisableSaveButton && theConfirmEmailBox != null)
    {
        blDisableSaveButton = theConfirmEmailBox.value == "";
    }
    if(!blDisableSaveButton && calloutDiv != null)
    {
        blDisableSaveButton = calloutDiv.style.display != 'none';
    }
    if(blDisableSaveButton)
    {
        ibtSaveButton.src = 'images/buttonB_Save_inactive.gif';
        ibtSaveButton.style.cursor = 'default';
        ibtSaveButton.disabled = true;
        return;
    }
    ibtSaveButton.src = 'images/buttonB_Save.gif';
    ibtSaveButton.style.cursor = 'pointer';
    ibtSaveButton.disabled = false;
}