// JavaScript Document

function consultarDestacado(event){
	var elClon =clonEfectos(this);
	new Effect.Parallel([
  		new Effect.Move(elClon, { sync: true, x: 150, y: -150, mode: 'relative' }), 
  		new Effect.Opacity(elClon,{sync: true, from: 0.8,to: 0  }),
			new Effect.Scale(elClon,150,{sync: true  })
		], { 
			 queue: { position: 'end',limit: 1, scope: 'destacados' },
			 duration: 0.8,
			 delay:0.1,
			 afterFinish:function(){document.location = $(elClon).down(".titDestacado").down("h2").down('a').readAttribute("href");$(elClon).remove();}
			 }
		);
	event.preventDefault();
}

function consultarNoticia(event){
	var elClon =clonEfectos(this,-10);
	elClon.addClassName("wrapEfectoNotHome");
	new Effect.Parallel([
  		new Effect.Opacity(elClon,{sync: true, from: 0.9,to: 0  }),
			new Effect.Scale(elClon,200,{sync: true,scaleFromCenter:true  })
		], { 
			 queue: { position: 'end',limit: 1, scope: 'noticias' },
			 duration: 0.8,
			 delay:0.1,
			 afterFinish:function(){document.location = $(elClon).down(".titNoticiaHome").down("h2").down('a').readAttribute("href");$(elClon).remove();}
			 }
		);
	event.preventDefault();
}



function addObserversHome(){
		
	/*DESTACADOS*/	
	var destNegros = $$('.contDestacadoNegro');
	destNegros.each(function(element){
		element.setStyle({cursor:"pointer"})
		element.observe('click', consultarDestacado);
	});
	var destGrises = $$('.contDestacadoGris');
	destGrises.each(function(element){
		element.setStyle({cursor:"pointer"})
		element.observe('click', consultarDestacado);
	});
	
	/*NOTICIAS*/
	var laNoticias = $$('.contNoticiaHome');
	laNoticias.each(function(element){
		element.setStyle({cursor:"pointer"});
		element.observe('click', consultarNoticia);
	});
}

Event.observe(window, 'load', addObserversHome);

