	function performLoginAction()
	{
				$.ajax( {
				   type: "POST",
				   url:"/login.php",
				   data: {l:"1",u:$('#lusername').val(),p:$('#lpassword').val()},
				   dataType:"text json",
				   success:	function(json){
						var response = $.parseJSON(json);
						if ( response.success == 'true' )
						{
							top.location.href=response.url;							
						}
						else
						{
							alert("Error signing in, please recheck your username and password and try again.");
						}
					},
			    	error:function(msg){
						var response = msg;
						alert("Error Logging in, please recheck username and password and try again.");
			   		} 
			 } );				
	}
	
	function performLogoutAction()
	{
			$.ajax( {
				   type: "POST",
				   url:"/login.php", 
				   dataType:"text json",
				   data: { doLogout:"true" },
				   success: function(json){
					   var response = $.parseJSON(json);
					   if ( response.success == 'true' )
					   {						 
						top.location.href ="/index.php";
					   }
				 	}
			} );
	}
				



	function performRegisterOption()
	{	     
		if ( $('#loginRegisterButton').attr('value') == "Registering" )
			option = "Register";
		else
			option = "Cancel";
		
		if ( option == "Register" )
		{	 
			if ( $('#ruser').value == "" )
			{
				alert('Please enter a username');
				return;
			}
			pvalue=$('#rpass').attr('value');
			p2value=$('#rcpass').attr('value');
			if ( pvalue == null || 
                 pvalue == "" || 
				 p2value == null || 
				 p2value == ""  
				 )
			{
				alert('Please enter a Password and a confirmation Password.');
				return;			
			}
			if ( !(pvalue ==  p2value ) )
			{
				alert('Your password and confirmation password do not match.');
				return;			
			
			}
			if ( $('#emailInputBox').attr("value") == null )
			{
				alert("Please enter an email address.");
				return;
			}
			
			$('#loginRegisterButton').attr('value',"Register");
			$.ajax( {
				   type: "POST",
				   url:"/registerHandler.php", 
				   data: $('#registerDetailsForm').serialize()+"&lr=R",
				   dataType:"json",
				   success: function(json){
					var response = json.success;
					if ( response == "true" )
					{							
						alert('Successfully Registered');
						top.location.href ="/index.php";
					}
					else
					{
						alert( response + " " + json.message );
					}
						
				 }
	//			onFailure: function(){ alert('Something went wrong...'); } 
			} );

		}
		else if ( option == "Cancel" )
		{
			$('#registerCancelButton').attr('value',"Cancel");
			//MakeRegisterFormHidden( true );
		}
	}
// JavaScript Document

