function attachHover() {
   jQuery('.ui-state-default').hover(

      function() { jQuery(this).addClass('ui-state-hover'); },
      function() { jQuery(this).removeClass('ui-state-hover'); }
				);
   //			.mousedown(function () { jQuery(this).addClass('ui-state-active'); })
   //				.mouseup(function () { jQuery(this).removeClass('ui-state-active'); })
   //				.mouseout(function () { jQuery(this).removeClass('ui-state-active'); })
};

function go(url) {
   location.href = url;
}
function ViewDialog(box) {
   jQuery(box).dialog({
      modal: true,
      resizable: false,
      height: 'auto',
      width:'auto',
      buttons: {
         "Ok": function () {
            jQuery(this).dialog("close");
         }
      }
   });
}

function GalleryStart(testodettagli) {
      var _corrente=0;
      jQuery(".gallery:first [rel^='galleria']").weboltgallery({ hasdettagli: false, navlength: 830, itemWidth: 57, navciclo: false, autoplay_slideshow: false, theme: "leverplan", allow_resize: false, openmodal: false, testo_dettagli: testodettagli });
      if (window.location.hash.length == 0) {
         jQuery(".gallery div a.immaginegrande:first").click();
      }
      else {
         _corrente = "#id_" + window.location.hash.substring(1);

         jQuery(_corrente).click();
      }

      // jQuery(window.location).bind(
		// "change",
		// function (objEvent, objData) {
		   // _corrente = "#id_" + objData.currentHash;
// //		   if (jQuery('.pp_pic_holder').css('display') != "block") //se  visible non e esegue la chiamata
// //		   {
// //		      jQuery("#galleria").scrollTop();
// //		      //	        jQuery("#containerabaco").css("visibility", "hidden").css("display", "none");
// //		      jQuery(_corrente).click();
// //		   }
		// });
   }

/** --- slide immagini e testi --- **/

(function($){
    $.fn.extend({
        //Passaggio della variabile options alla funzione
        slideShow: function(options){
            //Setta i valori di default
            var defaults = {
                speed: 2000,
                interval: 500,
            }
            //Fonde i valori di default con le opzioni passate
            var options = $.extend(defaults, options);

            var $testi = $('p', $(this));
			//$testi.before('<div id="testi">');
			//$testi.after('</div>');
            $testi.wrapAll(document.createElement("DIV"));
            return this.each(function(){
                var o = options;
                var obj = $(this);
                var testi = $('#testi');
                setInterval(function(){
                    slideSwitch(obj, o.speed);
                }, eval(o.interval+o.speed));
            });
        }
    });

     $.fn.extend({
         //Passaggio della variabile options alla funzione
         slideShowTxt: function(options){
             //Setta i valori di default
             var defaults = {
                 speed: 2000,
                 interval: 2000,
             }
             //Fonde i valori di default con le opzioni passate
             var options = $.extend(defaults, options);

             var $testi = $('p', $(this));
 			//$testi.before('<div id="testi">');
 			//$testi.after('</div>');
             $testi.wrapAll(document.createElement("DIV"));
             return this.each(function(){
                 var o = options;
                 var obj = $(this);
                 var testi = $('#testi');
                 setInterval(function(){
                     slideSwitchTxt(obj, o.speed);
                 }, eval(o.interval+o.speed));
             });
         }
     });

	function slideSwitch(obj, speed){
		var $active = $('IMG.active', obj);
		if ($active.length == 0) {
			$active = $('IMG:last', obj);
		}
			var $next = $active.next().length ? $active.next() : $('IMG:first', obj);

			$active.animate({opacity: 0.0}, speed/2)
			$next.css({
			    opacity: 0.0
			}).addClass('active').animate({
			    opacity: 1.0
			}, speed/2, function(){
			    $active.removeClass('active');
			});
	}

	function slideSwitchTxt(obj, speed){
		var $activeTxt = $('P.active', obj);
		if ($activeTxt.length == 0) {
		    $activeTxt = $('P:last', obj);
		}
			var $nextTxt = $activeTxt.next().length ? $activeTxt.next() : $('P:first', obj);

			$activeTxt.animate({
		 	   opacity: 0.0
			}, speed/2);

			$nextTxt.css({
			    opacity: 0.0
			}).addClass('active').animate({
			    opacity: 1.0
			}, speed/2, function(){
		    	$activeTxt.removeClass('active');
			});
	}
})(jQuery);
