$(function(){
	
	// START SLIDESHOW header
	$('.animazione').cycle({fx:'fade'});
	// END SLIDESHOW header
	
	
	
	// START galleria fotografica
	var onMouseOutOpacity = 0.67;
	$('#miniature ul.thumbs li').css('opacity', onMouseOutOpacity)
		.hover(
			function () {
				$(this).not('.selected').fadeTo('fast', 1.0);
			}, 
			function () {
				$(this).not('.selected').fadeTo('fast', onMouseOutOpacity);
			}
		);
	
	$(document).ready(function() {
		var gallery = $('.galleria').galleriffic('#miniature', {
			delay:                  2000,
			numThumbs:              5,
			preloadAhead:           10,
			enableTopPager:         true,
			enableBottomPager:      true,
			imageContainerSel:      '#slideshow',
			controlsContainerSel:   '#controlliSlide',
			captionContainerSel:    '#testoSlide',
			loadingContainerSel:    '#loading',
			renderSSControls:       true,
			renderNavControls:      true,
			playLinkText:           'Avvia slideshow',
			pauseLinkText:          'Pausa slideshow',
			prevLinkText:           'Precedente',
			nextLinkText:           'Successiva',
			nextPageLinkText:       'avanti&nbsp;&rsaquo;',
			prevPageLinkText:       '&lsaquo;&nbsp;indietro',
			enableHistory:          true,
			autoStart:              false,
			onChange:function(prevIndex, nextIndex) {
				$('#miniature ul.thumbs').children()
					.eq(prevIndex).fadeTo('fast', onMouseOutOpacity).end()
					.eq(nextIndex).fadeTo('fast', 1.0);
			},
			onTransitionOut:function(callback) {
				//$('#testoSlide').fadeTo('fast', 0.0);
				$('#slideshow').fadeTo('fast', 0.0, callback);
			},
			onTransitionIn:function() {
				$('#slideshow').fadeTo('fast', 1.0);
				//$('#testoSlide').fadeTo('fast', 1.0);
			},
			onPageTransitionOut:function(callback) {
				$('#miniature ul.thumbs').fadeTo('fast', 0.0, callback);
			},
			onPageTransitionIn:function() {
				$('#miniature ul.thumbs').fadeTo('fast', 1.0);
			}

		});
	});
	// END galleria fotografica
	
	
// 	 $('#campoRichiesto').wTooltip({
// 	 						content:"Campo obbligatorio", fadeIn: 600, fadeOut: "slow", 
// 	 						style: { border: "1px solid #ccc", background: "#fff", color: "#666", fontWeight: "bold"}
// 	 					});
	
		
	// Accordion
	$('#rivenditori').accordion({ header:"div.titolo", collapsible:true, autoHeight:false });
	
	// Tabs
// 	$('#tabs').tabs();
// 	
// 	
// 	// Dialog			
// 	$('#dialog').dialog({
// 		autoOpen: false,
// 		width: 600,
// 		buttons: {
// 			"Ok": function() { 
// 				$(this).dialog("close"); 
// 			}, 
// 			"Cancel": function() { 
// 				$(this).dialog("close"); 
// 			} 
// 		}
// 	});
// 		
// 	// Dialog Link
// 	$('#dialog_link').click(function(){
// 		$('#dialog').dialog('open');
// 		return false;
// 	});
// 	
// 	// Datepicker
// 	$('#date').datepicker({
// 		changeMonth:true, 
// 		changeYear:true, 
// 		showButtonPanel:true, 
// 		dayNamesMin: ['Do', 'Lu', 'Ma', 'Me', 'Gi', 'Ve', 'Sa'], 
// 		monthNamesShort: ['Gen','Feb','Mar','Apr','Mag','Giu','Lug','Ago','Set','Ott','Nov','Dec'], 
// 		currentText:'Oggi', 
// 		closeText: 'Chiudi', 
// 		dateFormat:'dd/mm/yy', 
// 		showOn:'button', 
// // 		buttonImage:'images/calendar.gif', 
// 		buttonImageOnly:false, 
// 		yearRange:'-100:+100'
// 	});
// 
// 		
// 	// Slider
// 	$('#slider').slider({
// 		range: true,
// 		values: [17, 67]
// 	});
// 		
// 	// Progressbar
// 	$('#progressbar').progressbar({
// 		value: 20 
// 	});
// 		
// 	//hover states on the static widgets
// 	$('#dialog_link, ul#icons li').hover(
// 		function() { $(this).addClass('ui-state-hover'); }, 
// 		function() { $(this).removeClass('ui-state-hover'); }
// 	);
});


