/* YouAre.com */

function newAjax() {
  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 resetPassword() {
  var mail = new String(document.getElementById('email').value);
  if(document.getElementById('email').value.length > 3) {
    expreg = new RegExp(/^[a-z0-9._-]+@[a-z0-9.-]{2,}[.][a-z]{2,3}$/);
    if(expreg.test(mail)!=null) {
      try {
        ajax = new newAjax();
        ajax.open("POST", "/account/reset_password", true);
        document.getElementById('try').innerHTML = '<div style="text-align:center; padding-top:16px;"><img src="/i/home-load.gif" alt="Loading" /></div>';
        ajax.onreadystatechange = function() {
          if (ajax.readyState == 4) {
            document.getElementById('try').innerHTML = ajax.responseText;
          }
        }
        ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
        ajax.send("m="+mail);
      } catch (E) {
        ajax = false;
      }
    }
  }
}

window.addEventListener('load', function() {if (document.location.href.match(/\/reset_password/)) $('input#password').focus(); }, true);
window.addEventListener('load', function() {if (document.location.href.match(/\/login/)) $('input#login_user').focus(); }, true);
