function checkForm(fname){
	var error = "";
	switch(fname){
		case 'anagr_search':
			if($('#search_cognome').val() == '' && $('#search_serv').val() == '' && $('#search_grp').val() == null)
				error = 'Selezionare un criterio per la ricerca';
			break;
	}
	
	if(error){
		$('#result_'+fname).html('<div class="alert alert-danger">'+error+'</div>');
		return false;	
	}
	
	return true;
}

function is_date(date){
	re = /^\d{1,2}\/\d{1,2}\/\d{4}$/; 
	if(date != '' && !date.match(re))
		return false; 
	return true;
}
function selXmlPop(destSelect,dataType, dataValue){
	var xml = false;
	selClear(destSelect);
	
	var $selectList = $(destSelect);
	$selectList.attr("disabled","disabled");	

	$('<span class="sel-loading" />').insertAfter($selectList);

	$.get('/xml/' + dataType + '/?v='+encodeURIComponent(dataValue),function(xml){
		
		if($(xml).find('content').size() == 0){
			$selectList.removeAttr("disabled");	
			$selectList.next('.sel-loading').remove();
		}else{
			$(xml).find('content').each(function(){			
				$(xml).find("row").each(function(){
					var value = $(this).attr("v");
					$selectList.append($("<option />").val(value).text($(this).text()));
				});
				$selectList.removeAttr("disabled");	
				$selectList.next('.sel-loading').remove();
			});
		}
	});
}
function selClear(id){
	$(id).find('option:not(:first)').remove();
}
