// JavaScript Document

var ban_rot = 0;


jQuery(document).ready(function(){
	
	$("#banner1").show();
	
	
	$(".rollover").hover(
	 function()
	 {
	  this.src = this.src.replace("_off","_on");
	 },
	 function()
	 {
	  this.src = this.src.replace("_on","_off");
	 }
	);
	
function rotate_banner(){
		
	$("#banner"+ban_rot).fadeOut("slow");
		
		if (ban_rot<2){
			
			ban_rot++;
		}else{
			ban_rot	=	0;
		}
		
		$("#banner"+ban_rot).fadeIn("slow");
		
		
	}	

$("#btn_noticia_der").click(function() {
	
	$("#banner"+ban_rot).fadeOut("slow");
	
			if (ban_rot<2){
					
					ban_rot++;
				}else{
					ban_rot	=	0;
				}
				
	$("#banner"+ban_rot).fadeIn("slow");
  
  
});

$("#btn_noticia_izq").click(function() {
	
	$("#banner"+ban_rot).fadeOut("slow");
	
			if (ban_rot>0){
					
					ban_rot--;
				}else{
					ban_rot	=	3;
				}
				
	$("#banner"+ban_rot).fadeIn("slow");
  
  
});

$('#mycarousel').jcarousel();
	
	window.setInterval(
    function () {        
				rotate_banner();
			},
			4000
		);


 $('.submenu_c').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+ $(this).height()+30) + "px" } );
		 $(this).css("background","url(/images/fondo_menu_hover.jpg) repeat-x");
		
		 
		 
      },
      function(e)
      {
         $("#menu_"+$(this).attr('id')).css({display: "none"});
		 $(this).css("background","none");
		
      }
   );


  $('.desplegable').hover(function(e)
      {
		$(this).css({display: "block"});
		
		$("#"+$(this).attr('title')).css("background","url(/images/fondo_menu_hover.jpg) repeat-x");
		//$("#"+$(this).attr('title')).css("background","none");
		
      },
      function(e)
      {
		$(this).css({display: "none"});
		
		$("#"+$(this).attr('title')).css("background","none");
		  
	  }
   );
   
 $("a[rel=galeria]").fancybox({
				'transitionIn'		: 'elastic',
				'transitionOut'		: 'elastic',
				'titlePosition' 	: 'outside',
				'showNavArrows'		: 'true',
				'overlayOpacity'	: .80,
				'titleFormat'		: function(title, currentArray, currentIndex, currentOpts) {
					return '<span id="fancybox-title-over">Image ' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? ' &nbsp; ' + title : '') + '</span>';
				}
	});  
  
  
  $('#slider_img').cycle({ 
    fx:    'fade', 
    speed:  2500 
 });
 $('#slider_img2').cycle({ 
    fx:    'fade', 
    speed:  4000 
 });
  $('.slider_igold').cycle({ 
    fx:    'fade', 
    speed:  2000 
 });
 
 $("#slider").easySlider({
		auto: true,
        controlsShow: false,
        speed: 2000,
        pause: 5000,
        continuous: true

	});
	
	$('.banner_principal_d').cycle({ 
    fx:    'fade', 
    speed:  3000
 });
	
	
	  
	  $('.btn_siguiente').click(function() {
	  $('.listaoculto').toggle('slow', function() {
		// Animation complete.
	  });
	  
	});
	
	$('.roll_noticias').vTicker({
   speed: 300,
   pause: 3000,
   showItems: 1,
   animation: 'fade',
   mousePause: false,
   height: 0,
   direction: 'up'
});

});




