function lookupLostCode() {
	var postedString = 'email='+document.getElementById("lostcode-email").value;
	postedString = postedString.replace(/\+/g, '%2B');
	ajaxReq('/lostcode/xlookup/', "lostcode-progress", postedString);
}

function lostCodeLookupDone(response) {
	document.getElementById("lostcode-status").innerText = valueForTag(response, "statustext");
}



function addEvent(obj, evType, fn, useCapture){
  if (obj.addEventListener){
    obj.addEventListener(evType, fn, useCapture);
    return true;
  } else if (obj.attachEvent){
    var r = obj.attachEvent("on"+evType, fn);
    return r;
  }
}

var LOSTCODE_PLACEHOLDER = "john@doe.com";

function initLostCode() {
	if (!document.getElementById)
		return;
	var lostCodeField = document.getElementById('lostcode-email');
	addEvent(lostCodeField, 'focus', focusLostCode, false);
	addEvent(lostCodeField, 'blur',  blurLostCode, false);
    lostCodeField.removeAttribute('class', 'focus');
	if (lostCodeField.value=='') lostCodeField.value = LOSTCODE_PLACEHOLDER;
}

function focusLostCode() {
	if (this.value==LOSTCODE_PLACEHOLDER) {
		this.value = '';
		this.setAttribute('class', 'focus');
	}
}

function blurLostCode() {
	if (this.value=='') {
		this.value = LOSTCODE_PLACEHOLDER;
		this.removeAttribute('class', 'focus');
	}
}

addEvent(window, 'load', initLostCode, false);
