// JavaScript Document
g_originalValue="";
g_originalColor="";
$(document).ready(function() {
	// gestion du champ de recherche	
	g_originalValue=$('#input_search').val();
	g_originalColor=$('#input_search').css('color');
	$('#input_search').focus(function() {
		if ($(this).val() == g_originalValue) {
			$(this).val('');
			$(this).css('color',"#000000");	
		}
	});
	$('#input_search').focusout(function() {
		if($(this).val()=="") {
			$(this).val(g_originalValue);
			$(this).css('color',g_originalColor);	
		}
	});	
});

 /**
 * As any property can match the query, we try to intelligently display properties that either matched or make
 * sense to display.
 * @param node
 */
function getText(node) {
    if (node.matchingProperties.length > 0) {
        var firstMatchingProperty = node.matchingProperties[0];
        return node[firstMatchingProperty];
    }
    if (node["jcr:title"] != null) {
        return node["jcr:title"];
    } else if (node["text"] != null) {
        return node["text"];
    } else if (node["j:nodename"] != null) {
        return node["j:nodename"];
    }
}

function format(result) {
    return getText(result["node"]);
}
