function SearchByTitle (title)
{
	$('.noRecordFound').hide();
	$('.emptyField').hide();
	$('#searchResult').html("");
	
	if (title.length <= 2)
	{
		$('#alertSearchTitle').show();
	}
	else
	{
		$('#alertSearchTitle').hide();
		$.ajax({
			type: "POST",
			beforeSend: startLoading("searchResult"),
			url: "/projectSearch.php",
			data: "title="+title,
			dataType: "html",
			complete: function (data){
				stopLoading("searchResult");
				if (data.responseText.length > 0)
				{
					$('#searchResult').html(data.responseText);
				}
				else
				{
					$('.noRecordFound').show();
				}
			}
		});	
	}
}

function AdvancedSearch ()
{
	/*
	dataValues = "";
	if ($("#categoryId").val().lenght > 0)
		dataValues += 
	*/
	$('#alertSearchTitle').hide();
	$('#searchResult').html("");
	$('.noRecordFound').hide();
	$('.emptyField').hide();
	
	countInput = 0;
	countEmpty = 0;
	$("#advancedResearch *").each(function(index, el) {
		if ( el.type == 'text' || el.type == 'checkbox' || el.type == 'textarea' || el.type == 'select-one' ) {
			countInput++;
			if ($(el).val() == '') {
				countEmpty++;
			}
			else if ($(el).val() == '0' &&  el.type == 'select-one') {
				countEmpty++;
			}
		}
	});
	
	if (countInput == countEmpty)
	{
		$('.emptyField').show();
	}
	else
	{
		$.ajax({
			type: "POST",
			beforeSend: startLoading("searchResult"),
			url: "/projectSearch.php",
			data: "categoryId="+$("#categoryId").val()+"&tipoprogetto_wpl="+$("#tipoprogetto_wpl").val()+"&settore_wpl="+$("#settore_wpl").val()+"&anno_wpl="+$("#anno_wpl").val(),
			dataType: "html",
			complete: function (data){
				stopLoading("searchResult");
				if (data.responseText.length > 0)
				{
					$('#searchResult').html(data.responseText);
				}
				else
				{
					$('.noRecordFound').show();
				}
			}
		});	
	}
}
