		$(function() {

		// Select all links with lightbox class
		$('a.lightbox').lightBox(); 
        $('label.pre').labelOver('over');
		$("#tabs").tabs();


				
				
		    $('#slideshow').cycle({
		    	speed:  'slow', 
		    	timeout: 7000, 
		        pager:      '#nav',
		        pagerEvent: 'mouseover',
		    	next:   '#next2', 
		    	prev:   '#prev2' 
		    });
		});

$(document).ready( function()
{
   PEPS.rollover.init();
});

PEPS = {};

PEPS.rollover = 
{
   init: function()
   {
      this.preload();
      
      $(".ro").hover(
         function () { $(this).attr( 'src', PEPS.rollover.newimage($(this).attr('src')) ); }, 
         function () { $(this).attr( 'src', PEPS.rollover.oldimage($(this).attr('src')) ); }
      );
   },

   preload: function()
   {
      $(window).bind('load', function() {
         $('.ro').each( function( key, elm ) { $('<img>').attr( 'src', PEPS.rollover.newimage( $(this).attr('src') ) ); });
      });
   },
   
   newimage: function( src )
   { 
      return src.substring( 0, src.search(/(\.[a-z]+)$/) ) + '_o' + src.match(/(\.[a-z]+)$/)[0]; 
   },

   oldimage: function( src )
   { 
      return src.replace(/_o\./, '.'); 
   }
};


    $(function(){
      $(".myMenu").buildMenu(
      {
        template:"/js/menuVoices.html",
        additionalData:"pippo=1",
        menuWidth:200,
        openOnRight:false,
        menuSelector: ".menuContainer",
        iconPath:"ico/",
        hasImages:true,
        fadeInTime:100,
        fadeOutTime:300,
        adjustLeft:2,
        minZindex:"auto",
        adjustTop:60,
        shadow:true,
        openOnClick:false,
        closeOnMouseOut:true,
        closeAfter:1000
      });

      $(document).buildContextualMenu(
      {
        template:"/js/menuVoices.html",
        menuWidth:200,
        overflow:2,
        menuSelector: ".menuContainer",
        iconPath:"ico/",
        hasImages:false,
        fadeInTime:100,
        fadeOutTime:100,
        adjustLeft:0,
        adjustTop:0,
        closeOnMouseOut:false,
        onContextualMenu:function(){}, //params: o,e
        shadow:true
      });

    }
            );

    //this function get the id of the element that fires the context menu.
    function testForContextMenu(el){
      if (!el) el= $.mbMenu.lastContextMenuEl;
      alert("the ID of the element is:   "+$(el).attr("id"));
    }


function change(what) {
    var value = what.options[what.selectedIndex].id;

  		$('#slider').html('<p><img src="/images/loadingAnimation.gif" width="208" height="13" /></p>');

		$("#slider").load("/products/selector/selectorloop-" + value + ".asp", function() {

		$('.pic').click(function() {
			var ProdID =  $(this).attr("id").replace("picid-", "");
			ViewPre(ProdID);
		});		


        var hide = false;
        $(".pic").hover(function(){
            if (hide) clearTimeout(hide);

			var TheID =  $(this).attr("id").replace("picid-", "");

            $("#desc-" + TheID).fadeIn();
        }, function() {
            hide = setTimeout(function() {
				$(".details").fadeOut("slow");
			}, 1);
        });

    });

}

    $(document).ready(function() {



		$('.pic').click(function() {
			var ProdID =  $(this).attr("id").replace("picid-", "");
			ViewPre(ProdID);
		});		


        var hide = false;
        $(".pic").hover(function(){
            if (hide) clearTimeout(hide);

			var TheID =  $(this).attr("id").replace("picid-", "");

            $("#desc-" + TheID).fadeIn();
        }, function() {
            hide = setTimeout(function() {
				$(".details").fadeOut("slow");
			}, 1);
        });

    });




    function ViewPre(ProdID){



  		$('#selectorprods').html('<p><img src="/images/loadingAnimation.gif" width="208" height="13" /></p>');

		$("#selectorprods").load("/products/selector/previews/" + ProdID + ".asp", function(){ 

		}).dialog({
			title: "Preview ",
			autoOpen: false,
			bgiframe: false,
			width: 620,
			height: 390,
			modal: true
			}).dialog('open');

    };
