	var ajaxObj;
	
	function submitForm(myfield,e)	{
		var keycode;
		if (window.event) keycode = window.event.keyCode;
		else if (e) keycode = e.which;
		else return true;

		if (keycode == 13){
		   myfield.form.submit();
		   return false;
		  }
		else
		   return true;
	}
	
	function stealthSubmit(object,e)	{
		var keycode;
		if (window.event) keycode = window.event.keyCode;
		else if (e) keycode = e.which;
		else return true;

		if (keycode == 13){
			ajaxObj = getAjaxObj();
			var url="http://livinoff.com/stealth_login.php";
			var params = "nm_usr="+document.getElementById("nm_usr").value+"&password="+object.value;
			ajaxObj.onreadystatechange = stealthResponse;
			ajaxObj.open("POST",url,true);
			
			ajaxObj.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
			ajaxObj.setRequestHeader("Content-length", params.length);
			ajaxObj.setRequestHeader("Connection", "close");
				
			ajaxObj.send(params);
		  }
		else
		   return true;
	}
	
	/*
	 *
	 */
	 function stealthResponse(){
		if(ajaxObj.readyState == 4 && ajaxObj.status == 200){
			var results = ajaxObj.responseText;
			words=results.split(" ")
	
			if(words[0]=="Success"){
				var stealthHTML = "welcome back,&nbsp;";
				stealthHTML += "<a href='http://livinoff.com/home.php' style='color:white;text-decoration:none;'>"+words[1];
				stealthHTML += "</a>&nbsp;&nbsp;<input type='button' class='grey-button' value='Log Out' onclick=\"location.href='http://livinoff.com/signout.php'\"/>";
			
				var stealth = document.getElementById("stealth");
				stealth.innerHTML = stealthHTML;
				return false;
			}
			location.href='http://livinoff.com/login.php?error=1';
			return false;
		}
	 }
	 
	 function stealthSignOut(){

			ajaxObj = getAjaxObj();
			var url="http://livinoff.com/stealth_logout.php";
			var params="";
			ajaxObj.onreadystatechange = stealthResponseSO;
			ajaxObj.open("POST",url,true);
			
			ajaxObj.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
			ajaxObj.setRequestHeader("Content-length", params.length);
			ajaxObj.setRequestHeader("Connection", "close");
				
			ajaxObj.send(params);
	 }
	 
	 function stealthResponseSO(){
		
		if(ajaxObj.readyState == 4 && ajaxObj.status == 200){
			var results = ajaxObj.responseText;
			
			if(results == "Success"){
				var stealthHTML = "<input type='text' size=20 id=nm_usr name='u_name' value='Username' class=log onfocus='clearText(this)' onblur='populateText(this)' /> &nbsp;";
				stealthHTML += "<input type='password' size=20 name='password' value='Password' class=log onfocus='clearText(this)' onblur='populateText(this)' onKeyPress='stealthSubmit(this,event)' />";
				stealthHTML += "<font style='margin-left:10px;'><a href='http://livinoff.com/signup.php' style='text-decoration:none;'>Sign Up</a>";
				stealthHTML += " | <a style='text-decoration:none;' href='http://livinoff.com/login.php?change=1'>Forgot Password</a>&nbsp;</font>";
				
				var stealth = document.getElementById("stealth");
				stealth.innerHTML = stealthHTML;
				return false;
			}
			return false;
		}
	 }
	
	/*
	 *  Returns an Ajax Object
	 */
	function getAjaxObj() {
	  var ajaxObj = null;
	  
	  try {
		// Firefox, Opera 8.0+, Safari
		ajaxObj=new XMLHttpRequest();
	  }
	  
	  catch (e) {
		//Internet Explorer
		try {
		  ajaxObj=new ActiveXObject("Msxml2.ajaxObject");
		} catch (e) {
		  ajaxObj = new ActiveXObject("Microsoft.ajaxObject");
		}
	  }
	  return ajaxObj;
	}

	/*
	 *  Manipulation of text for input objects
	 */
	function clearText(obj){
		
		if (obj.value == "Username" || obj.value == "Password" || obj.value=="Email Address" || obj.value=="Name" || obj.value=="Phone" || obj.value=="Email" || obj.value=="Address" || obj.value=="City"){
			if(obj.value == "Username")
				document.getElementById("pwd").value = '';

			if(obj.value == "Password")
				document.getElementById("nm_usr").value = '';
			
			obj.value = '';
		}
	}
	
	function populateText(obj){
	
		if ( obj.name=="nm_usr"){
			if(obj.value == '')
				obj.value = 'Username';		
		}
		else if (obj.name=="email"){
			if(obj.value == '')
				obj.value = 'Email Address';
		}
	}
	
	
	function toggleAcctBox(obj){
		
		var acctBox = document.getElementById("accountBox");

		if(acctBox.style.display == "block" || acctBox.style.display == ""){
			acctBox.style.display = "none";
                        obj.style.borderBottom = "none";
		}
		else{
			acctBox.style.display = "block";
                        obj.style.borderBottom = "1px solid white";
		}
		
		acctBox.focus();
	}
