//*********************************************************************************************
//									Base User Functions
//*********************************************************************************************

function register() {
	var Rusername 			= document.getElementById('Rusername').value;
	var Rpassword 			= document.getElementById('Rpassword').value;
	var Rconfirmpassword 	= document.getElementById('Rconfirmpassword').value;
	var Rfirstname 			= document.getElementById('Rfirstname').value;
	var Rlastname 			= document.getElementById('Rlastname').value;

	$.ajax({
		method: "get",url: "/ajax/ajax_register.php",data: '&Rusername=' + Rusername + "&Rpassword=" + Rpassword + "&Rconfirmpassword=" + Rconfirmpassword + "&Rfirstname=" + Rfirstname + "&Rlastname=" + Rlastname,
		beforeSend: function(){$("#registerBox").html('Loading...');},
		success: function(html){
			$("#registerBox").html(html);
		}
	});
}

function login() {
	var username 			= document.getElementById('username').value;
	var password 			= document.getElementById('password').value;

	$.ajax({
		method: "get",url: "/ajax/ajax_login.php",data: '&username=' + username + "&password=" + password,
		beforeSend: function(){$("#loginBox").html('Loading...');},
		success: function(html){
			$("#loginBox").html(html);
		}
	});
}

function logout() {
	$.ajax({
		method: "get",url: "/ajax/ajax_logout.php",
		beforeSend: function(){$("#loginStatus").html('');},
		success: function(html){
			$("#loginStatus").html(html);
		}
	});
}

//*********************************************************************************************
//									Friend Functions
//*********************************************************************************************
function friendRequest(userId) {
	$.ajax({
		method: "get",url: "/ajax/ajax_friendRequest.php", data: "userId=" + userId,
		beforeSend: function(){$("#friendRequestReturn").html('Loading...');},
		success: function(html){
			$("#friendRequestReturn").html(html);
		}
	});
}

function sendFriendRequest(userId) {
	$.ajax({
		method: "get",url: "/ajax/ajax_friendRequest.php", data: "sendRequest=true&userId=" + userId,
		beforeSend: function(){$("#friendRequestReturn").html('Loading...');},
		success: function(html){
			$("#friendRequestReturn").html(html);
		}
	});	
}

function checkFriendRequests(){
	$.ajax({
		method: "get",url: "/ajax/ajax_friendRequest.php", data: "checkRequests=true",
		beforeSend: function(){$("#friendText").html('Loading...');},
		success: function(html){
			$("#friendText").html(html);
		}
	});	
}

function openFriends() {
	$.ajax({
		method: "get",url: "/ajax/ajax_friends.php",
		beforeSend: function(){$("#friendsContainer").html('');},
		success: function(html){
			$("#friendsContainer").html(html);
		}
	});	
}

function acceptRequest(friendId) {
	$.ajax({
		method: "get",url: "/ajax/ajax_friendRequest.php", data: "mode=acceptRequest&friendId=" + friendId,
		beforeSend: function(){$("#friendsContainer").html('');},
		success: function(html){
			$.ajax({
				method: "get",url: "/ajax/ajax_friends.php",
				beforeSend: function(){$("#friendsContainer").html('');},
				success: function(html){
					$("#friendsContainer").html(html);
					hs.close('friendRequestContainer');
				}
			});
		}
	});	
}

function rejectRequest(requestId) {
	
}
