$(document).ready(function() {
	$("a.finn_button").mouseover(highlight).mouseout(restore);
	
	if (typeof enable_delete_shortcut != "undefined") {
		if (enable_delete_shortcut) {
			$("a.finn_button[title=Modifica]").each(function() {
				if (!$(this).parents('#commands').length) {
					var url = this.href.replace('modify', 'deleteconfirm');
					$(this).after(' <a href="' + url + '" title="Elimina" class="finn_button"><img border="0" src="/finn_images/delete_off.gif" alt="Modifica" class="finn_button_image"/></a>');
					$("a.finn_button[href=" + url + "]").mouseover(highlight).mouseout(restore);
				}
			});
		}
	}
	
	$("input.inlinesubmit, input.pulsub, .assocform input").mouseover(function() {
		$(this).css({color:'#106034', backgroundColor:'#ddd'});
	}).mouseout(function() {
		$(this).css({color:'#fff', backgroundColor:'#106034'});
	});
	
	$('#login_form').submit(function() {
		if ($('#username').val() && $('#password').val()) {
			return true;
		}
		return false;
	});
	
	// personalizzazioni specifiche per Agenda Venezia
	$('#finnform_evento #finn_el_dal select').change(function() {
		var name = ($(this).attr('name')).replace('dal', 'al');
		$('#finn_el_al select[name=' + name + ']').val($(this).val());
	});
	$('#finnform_evento #finn_el_ora_inizio select').change(function() {
		$('#finn_el_ora_fine select').val($(this).val());
	});
});


function highlight() {
	var myImg = $(this).children("img").attr("src");
	
	if(myImg != undefined){
		myImg = myImg.replace("_off", "_on");
		$(this).children("img").attr("src", myImg);
	}
}

function restore() {
	var myImg = $(this).children("img").attr("src");
	
	if(myImg != undefined){
		myImg = myImg.replace("_on", "_off");
		$(this).children("img").attr("src", myImg);
	}
}
