// JavaScript Document

jQuery(document).ready(function() {
	
	$("a[rel=example_group]").fancybox({
				'transitionIn'		: 'elastic',
				'transitionOut'		: 'elastic',
				'titlePosition' 	: 'outside',
				'titleFormat'       : function(title, currentArray, currentIndex, currentOpts) {
				    return '<span id="fancybox-title-over">'+title +" ("+  (currentIndex + 5) + ' / ' + currentArray.length + ') </span>';
				}
	});
			
	
	$(".rollover").hover(
	 function()
	 {
	src =this.src.replace("_off","_on");	   
	   
	   $(this).stop().animate({
		opacity: .5
		}, "slow");
		
		
		
	    $(this).attr("src",src);
		
		$(this).animate({
		opacity: 1
		}, "slow");
			  
	 },
	 function()
	 {
	  this.src = this.src.replace("_on","_off");
	 }
	);
	
 $('#productos').hover(

      function(e)
      {
		  
		var p = $(this);
		var position = p.position();
		   
		
         $("#menu_"+$(this).attr('id')).css({display: "block"});
		 $("#menu_"+$(this).attr('id')).css( { "left": (position.left ) + "px", "top":(position.top+ $('#productos').height()-3) + "px" } );
		 
      },
      function(e)
      {
         $("#menu_"+$(this).attr('id')).css({display: "none"});
      }
   );
   
   
    $('.desplegable').hover(function(e)
      {
		$(this).css({display: "block"});
		
		src = $("#"+$(this).attr('title')+" img").attr('src').replace("_off","_on");
		$("#"+$(this).attr('title')+" img").attr("src",src);
		
      },
      function(e)
      {
		$(this).css({display: "none"});
		src = $("#"+$(this).attr('title')+" img").attr('src').replace("_on","_off");
		$("#"+$(this).attr('title')+" img").attr("src",src);
		  
	  }
   );
	
});
