$(document).ready(function(){
	
	var SEARCH_DEFAULT = "Search fridayforward";
	$("#searchQuery").attr("value", SEARCH_DEFAULT);
	
	// categories toggle
	$("#categories-toggle").click(function() {
		//alert("!" + $("#categoriesToggle").html());
		
		if ($("#categories-toggle").html() == "list") {
			$("#categories-toggle").html("cloud");
			$("#categories-toggle").attr({"title":"Display categories cloud"});
			$("#categories-cloud").fadeOut("fast", displayCategoriesList);
		} else {
			$("#categories-toggle").html("list");
			$("#categories-toggle").attr({"title":"Display categories list"});
			$("#categories-list").fadeOut("fast", displayCategoriesCloud);
		}
		
		return false;
	});
	
	// search
	$("#searchQuery").mousedown(function() {
		if ($(this).attr("value") == SEARCH_DEFAULT) $(this).attr("value", "");
		$(this).focus();
		$(this).css({color: "#000"});
	});
	$("#searchQuery").blur(function() {
		if ($(this).attr("value") == "") $(this).attr("value", SEARCH_DEFAULT);
		$(this).css({color: "#999"});
	});
	
	$("#searchButton").click(function() {
		window.location = "/?s=" + $("#searchQuery").attr("value");
	});
	
});

function displayCategoriesList() {
	$("#categories-list").fadeIn("fast");
}
function displayCategoriesCloud() {
	$("#categories-cloud").fadeIn("fast");
}