/*jquery_header_func.js*/
var $_jq = jQuery;
$_jq(function() {
	var desc_h=$_jq('blockquote.description').height();
	var nav_bottom=parseInt(desc_h)+6;
 	$_jq('#nav').css({'display':'none'});		
	
	/*$_jq('#show-hide').text('Nascondi info');*/
	$_jq('#show-hide').attr('title','Nascondi info');
	
	$_jq('#show-hide').click(function() { 
			var ttl=$_jq(this).attr('title');
			if( ttl == 'Nascondi info'){
				$_jq('blockquote.description').css({'display':'none'});
				$_jq(this).css({'bottom':'0px'});
				$_jq(this).removeClass('nascondi-info');
				$_jq(this).addClass('mostra-info');
				$_jq(this).attr('title','Mostra info');
			}else if ( ttl == 'Mostra info'){
				$_jq('blockquote.description').css({'display':'block'});
				$_jq(this).removeClass('mostra-info');
				$_jq(this).addClass('nascondi-info');
				$_jq(this).attr('title','Nascondi info');
				$_jq(this).css({'bottom':nav_bottom+'px'});
			} else {
				$_jq(this).removeClass('mostra-info');
				$_jq(this).addClass('nascondi-info');
				$_jq(this).attr('title','Nascondi info');
				$_jq('blockquote.description').css({'display':'block'});
				$_jq(this).css({'bottom':nav_bottom+'px'});
			}			
		}
	);
	if($_jq('#show-hide').text() == 'Mostra info'){
		$_jq('blockquote.description').css({'background-color':'transparent','height':'0px'});
	}
	$_jq('#pause').click(function() { $_jq('#slides').cycle('pause'); return false; });
	$_jq('#play').click(function() { $_jq('#slides').cycle('resume'); return false; });
	  
	$_jq('#slideshow').hover(
		function() { 	
						
						$_jq('#controls').fadeIn(); 
						$_jq('#nav').fadeIn(); 
						$_jq('#show-hide').fadeIn(); 
						$_jq('.show-hide').fadeIn();
					},
		function() { 
						$_jq('#controls').fadeOut(); 
						$_jq('#nav').fadeOut(); 
						$_jq('#show-hide').fadeOut(); 
						$_jq('.show-hide').fadeOut();}
    );
   
	$_jq('#slides').cycle({
		fx:     'growY', //turnDown scrollVert scrollLeft
		speed:   1000,
		next:   '#next',
		prev:   '#prev',
		pager:  '#nav',
        pagerAnchorBuilder: function(idx, slide) {
			
            // return sel string for existing anchor
            return '#nav li:eq(' + (idx) + ') a';
        },
		pauseOnPagerHover: 1, // true to pause when hovering over pager link
		timeout: 6000,
		pause: true
		
    });
	
	
	
  	
	$_jq("a[rel^='lightbox']").prettyPhoto({
			animation_speed: 'normal', /* fast/slow/normal */
			slideshow: false, /* false OR interval time in ms */
			autoplay_slideshow: false, /* true/false */
			opacity: 0.80, /* Value between 0 and 1 */
			show_title: true, /* true/false */
			allow_resize: true, /* Resize the photos bigger than viewport. true/false */
			default_width: 500,
			default_height: 400,
			counter_separator_label: '/', /* The separator for the gallery counter 1 "of" 2 */
			theme: 'dark_rounded', /* light_rounded / dark_rounded / light_square / dark_square / facebook */
			hideflash: false, /* Hides all the flash object on a page, set to TRUE if flash appears over prettyPhoto */
			wmode: 'opaque', /* Set the flash wmode attribute */
			autoplay: true, /* Automatically start videos: True/False */
			modal: false, /* If set to true, only the close button will close the window */
			overlay_gallery: true, /* If set to true, a gallery will overlay the fullscreen image on mouse over */
			//keyboard_shortcuts: true, /* Set to false if you open forms inside prettyPhoto */
			//changepicturecallback: function(){}, /* Called everytime an item is shown/changed */
			//callback: function(){}, /* Called when prettyPhoto is closed */
			social_tools: false 
			
		});
		
	
	$_jq(".gallery a[rel^='lightbox']").prettyPhoto({
			animation_speed: 'normal', /* fast/slow/normal */
			slideshow: false, /* false OR interval time in ms */
			autoplay_slideshow: false, /* true/false */
			opacity: 0.80, /* Value between 0 and 1 */
			show_title: true, /* true/false */
			allow_resize: true, /* Resize the photos bigger than viewport. true/false */
			default_width: 500,
			default_height: 400,
			counter_separator_label: '/', /* The separator for the gallery counter 1 "of" 2 */
			theme: 'dark_rounded', /* light_rounded / dark_rounded / light_square / dark_square / facebook */
			hideflash: false, /* Hides all the flash object on a page, set to TRUE if flash appears over prettyPhoto */
			wmode: 'opaque', /* Set the flash wmode attribute */
			autoplay: true, /* Automatically start videos: True/False */
			modal: false, /* If set to true, only the close button will close the window */
			overlay_gallery: true, /* If set to true, a gallery will overlay the fullscreen image on mouse over */
			//keyboard_shortcuts: true, /* Set to false if you open forms inside prettyPhoto */
			//changepicturecallback: function(){}, /* Called everytime an item is shown/changed */
			//callback: function(){}, /* Called when prettyPhoto is closed */
			social_tools: false 
		});
	
	
	
	$_jq('#nav a[title]').tooltip({
		track: true, 
		delay: 0, 
		showURL: false, 
		showBody: " - ", 
		fade: 250 
	});
	$_jq('.tip[title]').tooltip({
		track: true, 
		delay: 0, 
		showURL: false, 
		showBody: " - ", 
		fade: 250 
	});
	
	$_jq('#text-to-search').focus(function(){
			$_jq('#search-label').addClass('hide-label');		
		}	
	);
	$_jq('#text-to-search').blur(function(){
			var text=$_jq(this).val();
			if(text == '' || text == 'undefined'){
				$_jq('#search-label').removeClass('hide-label');	
			}else{
				$_jq('#search-label').addClass('hide-label');
			}
				
		}	
	);	
	
});
