$(document).ready(function(){
		$("#LogIn").submit(function(){
		//define a var to jail our form from asynchronously processing until all data has processed 
		if($.firstSubmit != false)
			{
				//hash our passwd
				var md5_passwd = hex_md5($("#LogIn").contents().find("input[name=vb_login_password]").val());
				//assign the hash value to the form field for later submission 
				$("#LogIn").contents().find("input[name=vb_LogIn_md5password]").val(md5_passwd);
				//do our ajax calls 
				$.ajax({
					type: "POST",
					cache: "false", 
					url: "/privatelounge/login/view/loginExternal.php",
					dataType: "text/xml",
					data: ({
					vb_login_username: $("#navbar_username").val(),
					vb_login_password: $("#LogIn").contents().find("input[name=vb_login_password]").val(),
					do_login: $("#LogIn").contents().find("input[name=do]").val(),
					forceredirect: $("#LogIn").contents().find("input[name=forceredirect]").val(),
					url: $("#LogIn").contents().find("input[name=url]").val(),
					cookieuser: $("#cb_cookieuser_navbar").val(),
					md5password: md5_passwd
					}),
					success: function(xml) {
						///define our callback function	
						addMessages(xml);
					}
				});
				return false;  
			}
			else
			{
				return true;
			}
		});
	});
	
function addMessages(xml) 
{
	if ($.browser.msie) 
	{
		var xmlDoc = new ActiveXObject("Microsoft.XMLDOM");  
		xmlDoc.loadXML(xml);  
		xml = xmlDoc;  
	}  
	//check our valid user authentication status
	if($("auth",xml).text() == true)
	{
		//unsure of why this form validation was a requirement previously but I'd hate to drop features.... 
		if (Spry.Widget.Form.validate($("#LogIn")))
		{
			//break our jail 
			$.firstSubmit = false; 
			$("#LogIn").submit();
		}
		else
		{
			//not sure how validation on this page could fail but we'll legacy this for good measure....
			$("#errorString").html("please complete the login form");
		}
	}	
	else 
	{
		//redirect our error string from standard error to our defined div.  
		//remain in jail, do not pass go, do not collect $200
		if ( $("auth",xml).text() != "" && $("auth",xml).text() != null && $("auth",xml).text())
		{
			$("#errorString").html($("auth",xml).text());
		}
	}
}  
