
function alertSize() {
	  var myWidth = 0, myHeight = 0;
	  if( typeof( window.innerWidth ) == 'number' ) {
	    //Non-IE
	    myWidth = window.innerWidth;
	    myHeight = window.innerHeight;
	  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
	    //IE 6+ in 'standards compliant mode'
	    myWidth = document.documentElement.clientWidth;
	    myHeight = document.documentElement.clientHeight;
	  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
	    //IE 4 compatible
	    myWidth = document.body.clientWidth;
	    myHeight = document.body.clientHeight;
	  }
	  
	  return [ myWidth, myHeight ];
	}


function showDlgBox(fade_val){
	
	if(fade_val > 0){
		
		var dim = alertSize();
		
		$('container').setStyle('display','none');
		
		$('dlgBoxSfondo').setStyle('background','#000');
		$('dlgBoxSfondo').setStyle('height',dim[1]);
		$('dlgBoxSfondo').setStyle('display','inline');
		$('dlgBoxContainer').setStyle('display','inline');
		
	}
	else{
		$('container').setStyle('display','');
		$('dlgBoxContainer').set('text','');
		$('dlgBoxSfondo').setStyle('display','none');
		$('dlgBoxContainer').setStyle('display','none');
	}
		
	$('dlgBoxSfondo').fade(fade_val);
}

function showImage(src,label,title){
	showDlgBox(.8);
	
	var w = 640;
	var h = 480;
	
	var ml = (w/2).toInt();
	var mt = (h/2).toInt();
	
	$('dlgBoxContainer').setStyles({
		'width': w,
		'height': h,
		'margin-top' : '-' + mt + 'px',
		'margin-left' : '-' + ml + 'px' 
	});
	
	$('dlgBoxContainer').set('text','');
	
	(new Element('a',{
		'class' : 'link',
		'href' : 'javascript:showDlgBox(0)',
		'html' : '<img src="' + src + '"><br /><br /><span style="padding:15px">' + title + ' - ' + label + '</span>',
		'title' : title + ' - ' + label
		})).inject($('dlgBoxContainer'));
	
}

function cambiaImg(path,i){
	$('img_descrizione').src = path;
	$('img_descrizione').ref = i;
}

function showBigImage(){
	showImage($('img_descrizione').src,'Foto ' + $('img_descrizione').ref,$('img_descrizione').alt)
}



