jQuery.noConflict();

jQuery(document).ready(function(){

/* menu top --start */
jQuery('.jq_menu .ul1liv_titolo a').click (function(){
	return false;
});
jQuery('.topmenu-design').css({'z-index':'999'});
jQuery('.topmenu-design li.jq_menu').mouseenter(function(){
	jQuery(this).find('.ul1liv_titolo a').addClass('selezionato');
	jQuery('.contenitore').hide();
	jQuery(this).find('.contenitore').css({'-moz-box-shadow':'0 7px 7px #333','-webkit-box-shadow':'0 7px 7px #333','box-shadow':'0 7px 7px #333','z-index':'999'}).show();
	return false;
});
jQuery('.topmenu-design li.jq_menu').mouseleave(function(){
jQuery('.topmenu-design .ul1liv_titolo a').removeClass('selezionato');
jQuery('.contenitore').hide();
});
/* menu top --end*/


/* box_banner_rotazione */
	if(jQuery('.box_banner_rotazione').length>0)
	{
		if (jQuery('.box_banner_rotazione .banner img:eq(0)').height())
		{
			jQuery('.box_banner_rotazione').height(jQuery('.box_banner_rotazione .banner img:eq(0)').height());
		}
	}
/* Tracking download files */	
	jQuery('.content-view-embed .class-file a').click(function(){
		/*		_gaq.push(['_trackPageview','/home'+jQuery(this).attr('href')]);  Tracking Pageview*/
				_gaq.push(['_trackEvent','Download Files',jQuery(this).attr('href')]); /* Tracking eventi Eventi */ 
				_gaq.push(['_link',jQuery(this).attr('href')]); /* Tracking Link */
				return true;
			});
	
/* Tracking click in home page */	
	jQuery('.current_node_id_2 #wrapper2 a').click(function(){
/*		_gaq.push(['_trackPageview','/home'+jQuery(this).attr('href')]);  Tracking Pageview*/
		_gaq.push(['_trackEvent','Click in home',jQuery(this).attr('href')]); /* Tracking eventi Eventi */ 
/*		_gaq.push(['_link','/home'+jQuery(this).attr('href')]); Tracking Link */
		return true;
	});
	
	
/* Gestione collocazioni - START */
	if (jQuery('.window_collocazioni').length>0)
	{
		jQuery('#odwt-icon-collocazioni').click(function(){
			if (jQuery('.window_collocazioni').hasClass('nascosto'))
				jQuery('.window_collocazioni').removeClass('nascosto');
			else
				jQuery('.window_collocazioni').addClass('nascosto');
			return false;
		});
	}
	else
	{
		jQuery('#odwt-icon-collocazioni').hide();
	}
/* Gestione collocazioni - END */
	
	// datepicker
	jQuery('.datepicker').datepicker();
	
	// orologio
	jQuery('.jclock').jclock();
	
	/* Ricerca interna folder_search_text */
	
	jQuery('.folder_news_search form').submit(function(){
		var searchword=jQuery(this).find('input[name=Word]:eq(0)').attr('value');
		var searchmonth=jQuery(this).find('select[name=Month]:eq(0)').attr('value');
		var searchyear=jQuery(this).find('select[name=Year]:eq(0)').attr('value');
		var searchdamonth=jQuery(this).find('select[name=daMonth]:eq(0)').attr('value');
		var searchdayear=jQuery(this).find('select[name=daYear]:eq(0)').attr('value');
		var searchamonth=jQuery(this).find('select[name=aMonth]:eq(0)').attr('value');
		var searchayear=jQuery(this).find('select[name=aYear]:eq(0)').attr('value');
		var searchsection=jQuery(this).find('select[name=Section]:eq(0)').attr('value');
		var url=jQuery(this).find('input[name=folder_search_url]:eq(0)').attr('value');
	
		if (searchword!=''){
			var url=url+'/(word)/'+escape(jQuery.trim(searchword));
		}
		if (searchmonth){
			url=url+'/(month)/'+escape(jQuery.trim(searchmonth));
		}
		if (searchyear){
			url=url+'/(year)/'+escape(jQuery.trim(searchyear));
		}
		if (searchdamonth){
			url=url+'/(damonth)/'+escape(jQuery.trim(searchdamonth));
		}
		if (searchdayear){
			url=url+'/(dayear)/'+escape(jQuery.trim(searchdayear));
		}
		if (searchamonth){
			url=url+'/(amonth)/'+escape(jQuery.trim(searchamonth));
		}
		if (searchayear){
			url=url+'/(ayear)/'+escape(jQuery.trim(searchayear));
		}
		if (searchsection){
			url=url+'/(section)/'+escape(jQuery.trim(searchsection));
		}		
		window.location.href=url;
		return false;
	});

	// Ricerca interna folder_search_text
	jQuery('.folder_search_text form').submit(function(){
		var searchtext=jQuery(this).find('input[name=SearchText]:eq(0)').attr('value');
		if (jQuery.trim(searchtext)!='')
		{
			var url=jQuery(this).find('input[name=folder_search_text_url]:eq(0)').attr('value')+'/(search)/'+escape(jQuery.trim(searchtext));
			window.location.href=url;
		}
		return false;
	}); //

	
	//Nasconde l'editoriale se vuoto
	jQuery('.no-edit').each(function(){
		jQuery(this).closest('.leftcol-position').addClass('width-0');
		jQuery(this).closest('.block-col').children('.rightcol-position').addClass('width-100');
	});
	
	// Chiusura voci Mappa del sito
	jQuery('.content-view-sitemap td h2').each(function(){
		if(jQuery(this).next().is('ul')){
			jQuery(this).css('cursor','pointer');
			jQuery(this).children('a').click();
			jQuery(this).next().hide();
			jQuery(this).toggle(function(){
				jQuery(this).next().show();
			},function(){
				jQuery(this).next().hide();
			});
		}
	});
	
	// fix PNG per IE6 [start]
	if (jQuery.browser.msie && jQuery.browser.version=='6.0') {
		jQuery("img[src$=png]").pngfix();
		//jQuery(".jq_box_selezionato").pngfix({sizingMethod:'scale'});
	}
	// fix PNG per IE6 [end]
	
});	
/* rotazione ticker home page */
function slide_top_news()
{
	if (jQuery('.feed_reader  ul li:eq(0)'))
	{
		last=jQuery('.feed_reader  ul li:visible')
		if (last.next('li').is(":hidden"))
		{
			last.slideUp();
			last.next('li').show("slow");
		}
		else
		{
			last.slideUp();
			jQuery('.feed_reader ul li:eq(0)').show("slow");		
		}
	}
}

/* rotazione banner home page */
function banner_rotazione_fade()
{
	if (jQuery('.box_banner_rotazione .banner'))
	{
		last=jQuery('.box_banner_rotazione .banner:visible')
		if (last.next('.banner').is(":hidden"))
		{
			last.fadeOut("slow");
			last.next('.banner').fadeIn("slow");
		}
		else
		{
			last.fadeOut("slow");
			jQuery('.box_banner_rotazione .banner:eq(0)').fadeIn("slow");		
		}
	}
}


