$(document).ready(function() {

	// Gestione target blank links con doctype strict
	// This is how it works:
	// <a href="http://www.tripwiremagazine.com/" rel="external">tripwiremagazine.com</a>
	$('a[rel="external"]').click(function(){
		this.target = "_blank";
	});
	
	//Apre in nuova finestra
	$(".tBlankAll").click(function() {
		var url = $(this).attr('href');
		window.open(url);
		return false;
    });

	// gestione IMG HOVER
	$(".mHover").each(function() {
		var src = $(this).attr('src');
		var extension = src.substring(src.lastIndexOf('.'), src.length);
		$(this).mouseover(function() {
			$(this).attr('src', src.replace(extension,'-on' + extension));
		}).mouseout(function() {
			$(this).attr('src', src);
		});
	});

	// Hide the messages box after a while.
	$('.messages:not(.fixed)').delay(8000).fadeOut();
	
	// Expand/hide submenus of the main menu for users with javascript enabled.
	$('#main-menu li.level1.normal ul').hide();
	$('#main-menu li.level1.normal').mouseenter(function() {
		$(this).find('ul').show();
	});
	$('#main-menu li.level1.normal').mouseleave(function() {
		$(this).find('ul').fadeOut(500);
	});
	
});

/* Funzione per la gestione del confim javascript */
function confirmJs(element, strConfirm) {
	form = $(element).parents("form");	
	if (confirm(strConfirm)) {
		form.submit();		
	}
	return false;
}

/* Corrisponde alla funzione ucfirst del PHP */
function ucfirst(str) {
	var f = str.charAt(0).toUpperCase();
	return f + str.substr(1);
}
