// ********************************************************************************************
//	 Scrip que contiene las funciones necesarias para el slideshow y otros eventos con Ajax
//	Created by J.v.C Versión 4.4
// ********************************************************************************************
var mySlideShow;
		window.addEvent('domready',function(){
		// -----------------------------------------
		// Efectos para el menú principal
		// -----------------------------------------
		$$('#menu a').each(function(el) {
		//fx
		var fx = new Fx.Tween(el,{
			duration: 600,
			link: 'cancel'
		});		
		//css & events
		el.setStyle('background-position','-20px 35px').addEvents({
			'mouseenter': function(e) {
				e.stop();
				fx.start('background-position','-20px 94px');
			},
			'mouseleave': function(e) {
				e.stop();
				fx.start('background-position','-20px 35px');
			}
		});
		});
		// ----------------------------------------------
		// Slide Show ---------------------------------
		// ----------------------------------------------
		
	// instance with a few options
		mySlideShow = new SlideShow('slides',{
		delay: 9000,
		autoplay: true
	});
	// the rest of the demo showing how to control the instance
	//var toggled = [$('show'), $('showNext'), $('showPrevious'), $('showIndex')];

	$('showNext').addEvent('click',function(){
		mySlideShow.showNext();
	});
	
	$('showPrevious').addEvent('click',function(){
		mySlideShow.showPrevious();
	});

		//Efectos para los botones
		$('feed').set('opacity',0.8);
		
		$('feed').addEvents({
    		mouseover: function(){
        	//this.set('opacity', 1.0);
		var myFx = new Fx.Tween('feed');
		myFx.start('opacity', 0.5, 1.0);

   		 },
    		mouseout: function(){
        	var myFx = new Fx.Tween('feed');
		myFx.start('opacity', 1.0, 0.8);
   		 }
		});

		$('facebook').set('opacity',0.8);
		$('facebook').addEvents({
    		mouseover: function(){
        	//this.set('opacity', 1.0);
		var myFx = new Fx.Tween('facebook');
		myFx.start('opacity', 0.5, 1.0);

   		 },
    		mouseout: function(){
        	var myFx = new Fx.Tween('facebook');
		myFx.start('opacity', 1.0, 0.8);
   		 }
		});

		$('twitter').set('opacity',0.9);
		$('twitter').addEvents({
    		mouseover: function(){
        	//this.set('opacity', 1.0);
		var myFx = new Fx.Tween('twitter');
		myFx.start('opacity', 0.5, 1.0);

   		 },
    		mouseout: function(){
        	var myFx = new Fx.Tween('twitter');
		myFx.start('opacity', 1.0, 0.8);
   		 }
		});
		//Buscador
		$('buscadorimagenes').set('value', "Buscar imagenes...");
		$('buscadorimagenes').addEvent('click', function(){ $('buscadorimagenes').set('value', '');});
		$('buscadorimagenes').addEvent('blur', function(){ $('buscadorimagenes').set('value', "Buscar imagenes...");});
		
		//-------------------------
		// Cargar comentarios
		//-------------------------
		new Request.HTML({
      		url: 'lastcomments.php',
		method: 'get',

      		onRequest: function(){
      		$('cargar_comments').set('html', '<img  style="margin-top:10px; margin-left:50%; " src="../../imagenes/loading/spinner.gif"/>');
      		},

      		onComplete: function(response){
         	$('cargar_comments').empty().adopt(response);
      		}

    		}).send();

		// ----------------
		// Top Imagenes
		// -------------------
	new Request.HTML({
      	url: 'topimages.php',
	method: 'get',

      onRequest: function(){
      	$('cargar_top').set('html', '<img  style="margin-top:10px; margin-left:50%; " src="../../imagenes/loading/spinner.gif"/>');
      },

      onComplete: function(response){
         $('cargar_top').empty().adopt(response);
      }

    }).send('action=topdescargas');
		
	
	$('orden_downloads').addEvent('click', function(event){
    		event.stop();
		new Request.HTML({
      			url: 'topimages.php',
			method: 'get',

      			onRequest: function(){
      			$('cargar_top').set('html', '<img  style="margin-top:10px; margin-left:50%; " src="../../imagenes/loading/spinner.gif"/>');
      			},

      			onComplete: function(response){
         		$('cargar_top').empty().adopt(response);
      			}

    		}).send('action=topdescargas');

		 });
	$('orden_visitas').addEvent('click', function(event){
    		event.stop();
		new Request.HTML({
      			url: 'topimages.php',
			method: 'get',

      			onRequest: function(){
      			$('cargar_top').set('html', '<img  style="margin-top:10px; margin-left:50%; " src="../../imagenes/loading/spinner.gif"/>');
      			},

      			onComplete: function(response){
         		$('cargar_top').empty().adopt(response);
      			}

    		}).send('action=topvisitas');

		 });
	$('slides').setStyle('display', 'block');
	$('orden_rating').addEvent('click', function(event){
    		event.stop();
		new Request.HTML({
      			url: 'topimages.php',
			method: 'get',
      			onRequest: function(){
      			$('cargar_top').set('html', '<img  style="margin-top:10px; margin-left:50%; " src="../../imagenes/loading/spinner.gif"/>');
      			},
      			onComplete: function(response){
         		$('cargar_top').empty().adopt(response);
      			}

    		}).send('action=toprating');

		 });	




});//Fin de mootols	

