var tmp=get_cookie ("bodytextsize");
if (tmp)
{
	var bodytextsize=tmp-0;
}
else
{
	var bodytextsize=70;
}

jQuery.noConflict();

jQuery(document).ready(function(){

	// Dimensione Testo
	jQuery('body:eq(0)').css({fontSize:''+bodytextsize+'%'});
	document.cookie = "bodytextsize="+bodytextsize+"";
	jQuery('.voce_top_languages a:eq(0)').click(function(){
		if (jQuery('#languages:eq(0)').css('display')=='block')
		{
			jQuery('#languages:eq(0)').css({display:'none'});
		}
		else
		{
			jQuery('#languages:eq(0)').css({display:'block'});
		}
		
	});
	
	/* Predisposizione immagini con preview per imageZoom */
	jQuery('.content-show a').each(function(){
		cartina=jQuery(this).closest('.content-show').prev('.content-hide');
		link=cartina.children('a').attr('href');
		cartina.remove();
		testo=jQuery (this).html();
		jQuery(this).replaceWith('<a class="popup" href="'+link+'">'+testo+'</a>');
	});

	/* ImageZoom */
	jQuery(document.body).imageZoom();
	
	// Line delle folder senza link e contenuto nascosto
	jQuery('.content-view-children-nolink .titolo-line').addClass('noline');
	jQuery('.content-view-children-nolink .titolo-line').next('.attribute-short').addClass('hide');
	jQuery('.content-view-children-nolink .titolo-line a').each(function(){
		html=jQuery(this).html();
		jQuery(this).replaceWith('<a href="#">'+html+'</a>');
	});
	jQuery('.content-view-children-nolink .titolo-line a').click(function(){
		if (jQuery(this).closest('.titolo-line').next('.attribute-short').hasClass('hide')){
			jQuery(this).closest('.titolo-line').removeClass('noline');
			jQuery(this).closest('.titolo-line').next('.attribute-short').removeClass('hide');
		}else{
			jQuery(this).closest('.titolo-line').addClass('noline');
			jQuery(this).closest('.titolo-line').next('.attribute-short').addClass('hide');
		}
		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;
	}); //
	
});	

// dimensione testo
function textsize(incremento)
{
	var minTextSize=60;
	var maxTextSize=120;
	bodytextsize=bodytextsize-0+((incremento-0)*10);
	if (bodytextsize<minTextSize)
	{
		bodytextsize=minTextSize;
	}
	if (bodytextsize>maxTextSize)
	{
		bodytextsize=maxTextSize;
	}
	jQuery('body:eq(0)').css({fontSize:''+bodytextsize+'%'});
	document.cookie = "bodytextsize="+bodytextsize+"";
}

// cookie
function get_cookie ( cookie_name )
{
  var results = document.cookie.match ( '(^|;) ?' + cookie_name + '=([^;]*)(;|$)' );

  if ( results )
    return ( unescape ( results[2] ) );
  else
    return null;
}
