function lookup(inputString) {
	if(inputString.length == 0) {
		// Hide the suggestion box.
		$('#suggestions').hide();
	} else {
		// Call the PHP file for getting tags from the database.
		$.post("lib/tag_rpc.php", {queryString: ""+inputString+""}, function(data){
		    if(data.length >0) {
		        $('#suggestions').show();
		        $('#autoSuggestionsList').html(data);
		    }
		});
	}
} // lookup

function fill(thisValue) {
	$('#inputString').val(thisValue);
	$('#suggestions').hide();
}	

function clearText(field){
    if (field.defaultValue == field.value) field.value = '';
    else if (field.value == '') field.value = field.defaultValue;
}

function addTag() {
// Get the tag name and content id from the input field.
var tagName = $('input.add_tag').val(); 
var contentId = $('input.content_id').val();
var userId = $('input.user_id').val();
jQuery.post('lib/rpc.php', {'func':'add_tag', 'tag':tagName, 'content_id':contentId, 'user_id':userId}, 
	function (data) {
		// update the list with the response
		jQuery('ul#tags').append("<li class='tag'>" + data + "</li>");
	});
$('input.add_tag').val('Add a new tag.');
}

$(document).ready(function() {

	// This is the code for the navigation menu
	// that enables the menu to follow us down the page.
    $('#navigation').css("position", "fixed");
    $('#navigation-content').css("display", "block");
/* 	$("div#content").css("padding-top", "5px"); */

    // This is the code for the navigation menu
    // that enables us to toggle the navigation on and off.
    $("a#toggle").click(function(){
		$("#navigation-content").slideToggle(500);
		$("#toggle_down").toggle(true);
		$(this).toggleClass("active"); 
		return false;
	});
	
	$("a#toggle_down").click(function(){
		$("#navigation-content").slideToggle(500);
		$("#toggle_down").toggle(false);
		$(this).toggleClass("active"); 
		return false;
	});
	
	$("input.send_invite").click(function() {
          var email = $("input.invite").val();
          $("span.status").html("Loading...");
          $.get('settings.php', $("form.page_asides").serialize(), function(data) {
               $("span.status").html(data);
               $("input.invite").val("");
          });
          return false;
     });
});






