$(document).ready(function(){
	$("#testo-grande").click(function () {
		$('#testo').attr('className', 'testo-grande');
	});
	$("#testo-medio").click(function () {
		$('#testo').attr('className', 'testo-medio');
	});
	$("#testo-piccolo").click(function () {
		$('#testo').attr('className', 'testo-piccolo');
	});
	
	if (!defer_cluetip) {
		$('a.notainfo').cluetip({cluetipClass: 'notainfo', activation: 'click', local:true, cursor: 'help', sticky: true, closePosition: 'title', closeText: '<img src="http://www.reteambiente.it/img/common/note/nota_close.png" alt="chiudi">'});
		$('a.notaufficiale').cluetip({cluetipClass: 'notaufficiale', activation: 'click', local:true, cursor: 'pointer', sticky: true, closePosition: 'title', closeText: '<img src="http://www.reteambiente.it/img/common/note/nota_close.png" alt="chiudi">'});
		$('a.notaredazionale').cluetip({cluetipClass: 'notaredazionale', activation: 'click', local:true, cursor: 'pointer', sticky: true, closePosition: 'title', closeText: '<img src="http://www.reteambiente.it/img/common/note/nota_close.png" alt="chiudi">'});
	}


	$("#srchfd").autocomplete('/ajax/_parole_chiave.php', {
		multiple: true,
		matchContains: true,
		formatResult: formatResult
	});

	$("#srchfd").focus( function() {
		if ($(this).val()=='cerca nel sito') {
			$(this).val('');
			$(this).removeClass('dimmed');
			$('#clearsearch').css('visibility', 'visible');
		}
	});

	$("#srchfd").blur( function() {
		if ($(this).val()=='') {
			$(this).val('cerca nel sito');
			$(this).addClass('dimmed');
			$('#clearsearch').css('visibility', 'hidden');
		}		
	});

	$("#clearsearch").click( function() {
			$("#srchfd").val('cerca nel sito');
			$("#srchfd").addClass('dimmed');
	});

	function formatResult(row) {
		return '{'+row[0]+'}';
	}

});

function toggle(id) {
	if ($('#'+id).css('display') == 'block') {
		$('#'+id).css('display', 'none');
	} else {
		$('#'+id).css('display', 'block');
	}
}



function docluetip(myid) {
	if (defer_cluetip) $('#'+myid).cluetip({cluetipClass: 'notaredazionale', activation: 'click', local:true, cursor: 'pointer', sticky: true, closePosition: 'title', closeText: '<img src="http://www.reteambiente.it/img/common/note/nota_close.png" alt="chiudi">'});
}
