var SENDMAIL_SERVICE="/sendmail/";
function AOLSendMail(formName){var form=$(formName);
var sentcallback=null;
var errorcallback=null;
var datatoappend=null;
var beforesendcallback=null;
if(form.tagName.toLowerCase()=="form"){form.onEvent("submit",function(e){stopDefaultEvent(e);
initSend()
})
}else{if(form.tagName.toLowerCase()=="input"){form.onEvent("click",function(e){stopDefaultEvent(e);
initSend()
})
}}this.send=function(){initSend()
};
this.onMessageSent=function(callback){sentcallback=callback
};
this.onError=function(callback){errorcallback=callback
};
this.setDataToAppend=function(data){datatoappend=data
};
this.onBeforeSend=function(cb){beforesendcallback=cb
};
function initSend(){if($("captcha_response")){sendMail()
}else{post(function(rs){if(rs.error=="NO_ERROR"){sendMail()
}else{if(rs.error=="CAPTCHA_RESPONSE"||rs.error=="TOKEN_INVALID"||rs.error=="CAPTCHA_MISSING"){showCaptcha()
}else{if(errorcallback){errorcallback(rs)
}}}},"validateUser=1")
}}function sendMail(){if(beforesendcallback){beforesendcallback()
}var to=$("sendmail_to").value;
var subject=$("sendmail_subject").value;
var body=$("sendmail_body").value;
if(datatoappend!=null){body+=datatoappend
}var data="sendmail_to="+to+"&sendmail_subject="+subject+"&sendmail_body="+body;
if($("captcha_response")){data+="&captcha_response="+$("captcha_response").value
}post(function(rs){if(rs.error=="CAPTCHA_RESPONSE"){$("captcha_image").setAttribute("src","/sendmail/captcha-image?"+Math.random())
}if(rs.error=="NO_ERROR"){if(sentcallback){sentcallback()
}}else{if(errorcallback){errorcallback(rs)
}}},data)
}function showCaptcha(){if($("captcha_image")==null){var container=$("captcha");
var captcha=document.createElement("img");
captcha.setAttribute("src","/sendmail/captcha-image?"+Math.random());
captcha.setAttribute("id","captcha_image");
container.appendChild(captcha);
var label=document.createElement("label");
label.style.width="100%";
var text=document.createTextNode("Please enter the letters that appear in the image above");
var input=document.createElement("input");
input.setAttribute("type","text");
input.setAttribute("name","captcha_response");
input.setAttribute("id","captcha_response");
label.appendChild(text);
label.appendChild(input);
container.appendChild(document.createElement("br"));
container.appendChild(label)
}}var XMLHttpFactories=[function(){return new XMLHttpRequest()
},function(){return new ActiveXObject("Msxml2.XMLHTTP")
},function(){return new ActiveXObject("Msxml3.XMLHTTP")
},function(){return new ActiveXObject("Microsoft.XMLHTTP")
}];
function createXMLHTTPObject(){var xmlhttp=false;
for(var i=0;
i<XMLHttpFactories.length;
i++){try{xmlhttp=XMLHttpFactories[i]()
}catch(e){continue
}break
}return xmlhttp
}function post(callback,params){var req=createXMLHTTPObject();
req.open("POST",SENDMAIL_SERVICE+"sendmail",true);
req.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
req.onreadystatechange=function(){if(req.readyState==4){if(callback){var results=eval("("+req.responseText+")");
callback(results)
}}};
req.send(params)
}function $(id){var _elem=null;
if(typeof id=="string"){_elem=document.getElementById(id)
}else{_elem=id
}if(_elem){_elem.onEvent=function(event,fn){if(this.addEventListener){this.addEventListener(event,fn,false)
}else{if(this.attachEvent){this.attachEvent("on"+event,fn)
}}}
}return _elem
}function stopDefaultEvent(event){if(event){if(event.preventDefault){event.preventDefault();
event.stopPropagation()
}else{event.returnValue=false;
event.cancelBubble=true
}}}};
