			var req;
			
			function Initialize()
			{
			    try
			    {
			        req=new ActiveXObject("Msxml2.XMLHTTP");
			    }
			    catch(e)
			    {
			        try
			        {
			           req=new ActiveXObject("Microsoft.XMLHTTP");
			        }
			        catch(oc)
			        {
			           req=null;
			        }
			    }
			
			    if(!req&&typeof XMLHttpRequest!="undefined")
			    {
			        req=new XMLHttpRequest();
			    }
			
			}
			
			function SendQuery(key)
			{
				Initialize(); 
				var url="define/"+ encodeURIComponent(key);
			
				if(req!=null)
				{
					req.onreadystatechange = ProcessWordSearch;
					req.open("GET", url, true);
					req.send(null);
				}
			
		
			}
			
			function ProcessWordSearch()
			{
			    if (req.readyState == 4)
			        {
			        // only if "OK"
			            if (req.status == 200)
			            {
			                if(req.responseText=="") {
								hideDbar();
								showWOTD();
			                } else {
			                	showDbar();
			                    ShowDiv("word");
			                    $("#word").html(req.responseText);
								$("#word > a[rel*=facebox]").facebox();
			                }
			            }
						
			        }
			}
			//. i can has ajax n stuff.
			function Validate(user,pass) {

				Initialize();
				var url="/firmware/bin/login.php";
				var params = "action=Login&username=" + user + "&password=" + pass;
				if(req!=null) {
					//req.onreadystatechange = ProcessValidation;
					req.open("POST", url, true);
					req.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
					req.setRequestHeader("Content-length", params.length);
					req.setRequestHeader("Connection", "close");
					req.onreadystatechange = ValidateHandle;
					req.send(params);
				}

			}
			
			function ValidatePass(pass0,pass1,pass2) {
				Initialize();
				var url="/firmware/bin/passwd.php";
				var params = "password0=" + encodeURIComponent(pass0) + "&password1=" + encodeURIComponent(pass1) + "&password2=" + encodeURIComponent(pass2);
				
				if(req!=null) {
					//req.onreadystatechange = ProcessValidation;
					req.open("POST", url, true);
					req.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
					req.setRequestHeader("Content-length", params.length);
					req.setRequestHeader("Connection", "close");
					req.onreadystatechange = ValidateHandle;
					req.send(params);
				}
			}
			
			function ValidateAcct(fname, lname, email) {
				Initialize();
				var url="/firmware/bin/account-editor.php";
				var params = "fname=" + encodeURIComponent(fname) + "&lname=" + encodeURIComponent(lname) + "&email=" + encodeURIComponent(email);
				
				if(req!=null) {
					//req.onreadystatechange = ProcessValidation;
					req.open("POST", url, true);
					req.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
					req.setRequestHeader("Content-length", params.length);
					req.setRequestHeader("Connection", "close");
					req.onreadystatechange = ValidateHandle;
					req.send(params);
				}
			}
			
			
			function ValidateReg(user,pass1,pass2,fname,lname,email,security) {
				Initialize();
				var url="/firmware/bin/register.php";
				var params = "action=Create%20Account&username=" + user + "&password1=" + pass1 + "&password2=" + pass2 + "&fname=" + fname + "&lname=" + lname + "&email=" + email + "&security=" + security ;
				if(req!=null) {
					//req.onreadystatechange = ProcessValidation;
					req.open("POST", url, true);
					req.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
					req.setRequestHeader("Content-length", params.length);
					req.setRequestHeader("Connection", "close");
					req.onreadystatechange = ValidateHandle;
					req.send(params);
				}

			}
			
			function ValidateWord(word, type, def) {
				Initialize();
				var url="/firmware/bin/word.php";
				var params = "action=Add%20New%20Word&newword=" + encodeURIComponent(word) + "&type=" + encodeURIComponent(type) + "&def=" + encodeURIComponent(def);
				if(req!=null) {
					//req.onreadystatechange = ProcessValidation;
					req.open("POST", url, true);
					req.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
					req.setRequestHeader("Content-length", params.length);
					req.setRequestHeader("Connection", "close");
					req.onreadystatechange = ValidateHandle;
					req.send(params);
				}
			}
			
			function ValidateHandle() {
				if(req.readyState == 4 && req.status == 200) {
					var saywhat = req.responseText;
						if(saywhat == "WE WIN") { 
							location.href="http://www.thedictionary.com/";
						} else if(saywhat.match(/Please try again/)) {
							// heh.
							document.getElementById('security-thing').src = '/firmware/share/captcha-basic.php?' + (new Date()).getTime(); //. TODO change this path when moved
							document.getElementById('security').value = '';
							document.getElementById("status_td").innerHTML = saywhat;
							showStatusDiv();
						} else {
							document.getElementById("status_td").innerHTML = saywhat;
							$('#facebox .close_image').attr('src', '/js/facebox/closelabel.gif');
							showStatusDiv();
						}
						//. TODO: change this path when we move it back.
				} 
			}
			//. /i can has ajax n stuff
			
	
			
			function get(obj) {
			  var getstr = "";
			  for (i=0; i<obj.length; i++) {
				 if (obj[i].tagName == "INPUT") {
					if (obj[i].type == "hidden") {
						getstr += obj[i].name + "=" + obj[i].value + "&";
					}
					if (obj[i].type == "text") {
					   getstr += obj[i].name + "=" + obj[i].value + "&";
					}
					if (obj[i].type == "password") {
					   getstr += obj[i].name + "=" + encodeURIComponent(obj[i].value) + "&";
					}
				 }   
				
				if (obj[i].tagName == "TEXTAREA") {
						getstr += obj[i].name + "=" + obj[i].value + "&";
				}
			  }
			  return getstr;

		   }
							
			function redirect() {
				var r = setTimeout("location.href='http://www.thedictionary.com/'", 3000);
			}
			
			
			function ShowDiv(divid)
			{
			   if (document.layers) document.layers[divid].visibility="show";
			   else document.getElementById(divid).style.visibility="visible";
			}
			
			function HideDiv(divid)
			{
			   if (document.layers) document.layers[divid].visibility="hide";
			   else document.getElementById(divid).style.visibility="hidden";
			}
			
			function showDbar() {
				$("#dbar_popin").slideDown("slow");
			}
			
			function hideDbar() {
				$("#dbar_popin").slideUp("slow");
				
			}
			
			function showStatusDiv() {
			
				$("#status").attr('display', 'inline').slideDown("slow");
				//setTimeout(function() {$("#facebox").fadeOut();}, 2000);
					
			}
			
			function showWordPane(divid) {
				if(divid == "addNewWord") {
					$(divid).fadeIn("slow");
				} else if(divid == "editWord") {
					$(divid).fadeIn("slow");
				} else
					$(divid).fadeIn("slow");
			}

			function BodyLoad()
			{
			    ShowDiv("word");
			    document.getElementById("keyword").focus();
			}