function ridimensiona_sfondo() 
{
    var iw = $('#sfondo img').attr('width');
    var ih = $('#sfondo img').attr('height');
    var rw = iw / ih;
    var rh = ih / iw;
    var w = $(window).width();
    var h = $(window).height();
	
    var sc = h * rw;
    if (sc >= w) {
        nh = h;
        nw = sc;
    } else {
        sc = w * rh;
        nh = sc;
        nw = w;
    }
	$('#sfondo img').css({height: nh, width: nw}); 
}

$(document).ready(function(){
 	ridimensiona_sfondo(); 
	
	// also adding (poached from admin-menu): Hover emulation for IE 6.
	if ($.browser.msie && parseInt(jQuery.browser.version) == 6) {
		$('#block-menu-menu-navigazione-primaria .menu>li').hover(function() {
			$(this).addClass('iehover');
		}, function() {
			$(this).removeClass('iehover');
		});
	}
	
	// also adding (poached from admin-menu): Delayed mouseout.
	$('#block-menu-menu-navigazione-primaria .menu>li').hover(function() {
		// Stop the timer.
		clearTimeout(this.sfTimer);
		// Display child lists.
		$('> ul', this).css({visibility: 'visible', display: 'block'})
		// Immediately hide nephew lists.
		.parent().siblings('li').children('ul').css({visibility: 'hidden', display: 'none'});
	}, function() {
		// Start the timer.
		var uls = $('> ul', this);
		this.sfTimer = setTimeout(function() {
		uls.css({visibility: 'hidden', display: 'none'});
	}, 600);
	}); 
});
$(window).resize(function(){ 
 	ridimensiona_sfondo();
});


// popup for footer credits link

var vcpopup = null;  
function popUp(strURL, strType, strHeight, strWidth) {  
 if (vcpopup != null && !vcpopup.closed)  
   vcpopup.close();  
 var strOptions="";  
 if (strType=="console")  
   strOptions="resizable,height="+  
     strHeight+",width="+strWidth;  
 if (strType=="fixed")  
   strOptions="status,height="+  
     strHeight+",width="+strWidth;  
 if (strType=="elastic")  
   strOptions="toolbar,menubar,scrollbars,"+  
     "resizable,location,height="+  
     strHeight+",width="+strWidth;  
 vcpopup = window.open(strURL, 'vcpopup', strOptions);  
 vcpopup.focus();  
}