function attivita2()
{
	$('#tipo_attivita2').load('/ajax/'
			, { 
			     'type': 'catalogo'
			   , 'value' : $('#tipo_attivita option:selected').val()
			   , 'opt' : tipoAttivita2
			  }
			/*, function() {
				$('#tipo_attivita').change()
			  }*/
			);	  
}

function fullscreenPopup ( url ) {
	/*var w = window.screen.availWidth;
 	var h = window.screen.availHeight;
 	w -= 10;
 	h -= 30;*/
 	fullscreenWin = window.open(url,'window',
									'toolbar=0,' +
									'menubar=0,' +
									'location=0,' +
									'directories=0,' +
									'status=0,' +
									'resizable=1,' +
									'scrollbars=0,' +
									'top=0,' +
									'left=0,' +
									'width=930,height=600');
}

function fullscreen() {

	var url = $(this).attr('href');
	fullscreenPopup(url);
	return false;

}

$(document).ready(function() {

	// gestione barra STAGE
	if ($("#iStage").length > 0) {
		var hStage  = $("#iStage").height();
		var cssBt   = { position: "absolute"
					  , display: "none"
					  , top: hStage + "px"
					  , left: "22px"
					  , cursor: "pointer"
					  };
		var cssTxt  = { position: "absolute"
					  , display: "none"
					  , top: hStage + "px"
					  , left: "50px"
					  , fontSize: "9px"
					  };
		var imgOut  = '/skinAdmin/entigo/widgets/ico-stage.gif';
		var imgOver = '/skinAdmin/entigo/widgets/ico-stage2.gif';
		var htmlImg = '<img src="' + imgOut + '" width="20" height="14" alt="apri/chiudi stage" id="btStage" />';
		var htmlTxt = '<p id="btStageTxt">&lt; Stage</p>';

		$("#iStage").css("top", "-" + hStage + "px");
		$("#iStage").css("z-index", "500");
		$(".iStageDx").after(htmlImg);
		$("#btStage").css(cssBt).fadeIn("slow");
		$(".iStageDx").after(htmlTxt);
		$("#btStageTxt").css(cssTxt).fadeIn(500).fadeOut(2000);

		$("#btStage").click(function() {
			if ($("#iStage").css("top") == '0px') {
				$("#iStage").animate({top: "-" + hStage + "px"}, 500);
				$(this).attr("src", imgOut);
			} else {
				$("#iStage").animate({top: "0px"}, 300);
				$(this).attr("src", imgOver);
			}
		});
	};

	// gestione IMG HOVER
	$(".icsmMouseOver").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));
		});
		$(this).mouseout(function() {
			$(this).attr('src',src);
		});
	});
	
	$('#tipo_attivita').change(function() { attivita2(); } )
	if ($('#tipo_attivita option:selected').val()) {
		attivita2();
	};
	
	$('#privacyPopup').click(fullscreen);
	
});