// JavaScript Document

function validateLogin(redirect)
{
	
	$.post("/bundles/ajaxLogin/ajax/ajax_data.php",   
	  { actionID : 1 , myharewood_username : document.getElementById("usernameField").value , myharewood_password : document.getElementById("passwordField").value } , 
	  function(data) 
	  {	
	  				document.getElementById("usernameField").value = "";
					document.getElementById("passwordField").value = "";
					
					if(redirect == 0)
					{
						if(data == "0")
						{
							document.getElementById("quickMsg").innerHTML = "<p>You are now Logged in</p>" ;			
						}
						else
						{
							document.getElementById("quickMsg").innerHTML = data ;	
						}
						
					}
					else
					{
						if(data == "0")
						{
							window.location = "/my-harewood";	
						}
						else if(data == "999")
						{
							window.location = "/my-harewood/my-profile";	
						}
						else
						{
							document.getElementById("loginErrorMsg").innerHTML = data ;
						}
					}
					
					
	 }, 
	  "html" 
	);
		
}


function validateQuickLogin(redirect)
{
	
	$.post("/bundles/ajaxLogin/ajax/ajax_data.php",   
	  { actionID : 1 , myharewood_username : document.getElementById("usernameFieldQuick").value , myharewood_password : document.getElementById("passwordFieldQuick").value } , 
	  function(data) 
	  {	
	  				document.getElementById("usernameFieldQuick").value = "";
					document.getElementById("passwordFieldQuick").value = "";
					
					if(redirect == 0)
					{
						if(data == "0")
						{
							document.getElementById("quickMsg").innerHTML = "<h2>You are now Logged in</h2>" ;			
						}
						else
						{
							document.getElementById("quickMsg").innerHTML = data ;	
						}
						
					}
					else
					{
						if(data == "0")
						{
							window.location = "/my-harewood";	
						}
						else if(data == "999")
						{
							window.location = "/my-harewood/my-profile";	
						}
						else
						{
							document.getElementById("loginErrorMsg").innerHTML = data ;
						}
					}
					
					
	 }, 
	  "html" 
	);
		
}




function clearLoginForm()
{
	//document.getElementById('loginForm').reset(); 
	
	//document.getElementById("usernameField").value = "";
	//document.getElementById("passwordField").value = "";

}


function logUserOut()
{
	
	$.post("/bundles/ajaxLogin/ajax/ajax_data.php",   
	  { actionID : 999 } , 
	  function(data) 
	  {	
	  				window.location = "/home";	
	  }, 
	  "html" 
	);
	
}

