window.addEvent('domready', function(){			
	var lista = $$( 'a.noticiaenlace' );	
	lista.each( function( elemento ) {
		var fx = new Fx.Styles( elemento , { duration : 200 , wait : false } );

		elemento.addEvent( 'mouseenter' , function() {
			fx.start( { color : '#ffffff' } );
		});

		elemento.addEvent( 'mouseleave' , function() {
			fx.start( { color : '#cccccc' } );
		});	
	});
	
	var lista = $$( 'a[destacadoid]' );
	lista.each( function( enlace ) {
		enlace.addEvent( 'click' , function(e) {
			e = new Event(e);
			cargarDestacado( enlace.getProperty( 'destacadoid' ) );
			e.stop();
		});
	});
	
/*
	var lista = $$('#victorPeliculas img.proximamente');	
	lista.each( function( imagen ) {
		var fx = new Fx.Styles( imagen , { duration : 200 , wait : false } );
		
		if( ( lista.length == 4 ) && ( lista.indexOf( imagen ) == 2 ) ) {
			new Element( 'br' ).injectBefore( imagen );
		};
		
		var tamano = imagen.getCoordinates();
		
		imagen.setProperty( 'ancho' , tamano.width);
		imagen.setProperty( 'alto' , tamano.height);
		
		imagen.addEvent( 'mouseenter' , function() {
			//fx.start( {
				//'width' : this.getProperty( 'ancho' ).toInt() + 10,
				//'height' : this.getProperty( 'alto' ).toInt() + 10
				this.effect('opacity', {duration: 500}).start(1,0.5);
			//});
		});

		imagen.addEvent( 'mouseleave' , function() {
			//fx.start( {
				//'width' : this.getProperty( 'ancho' ).toInt(),
				//'height' : this.getProperty( 'alto' ).toInt()
				this.effect('opacity', {duration: 500}).start(0.5,1);
			//});
		});

	});
*/
	
	startCallback();	
});

function cargarDestacado( id )
{
	var url = 'ajax/destacado.asp?id=' + id;
	
	var request = new Json.Remote( url , {
		onComplete : function( destacado ) {
			if( destacado == undefined )
				return;
			$('destacadosImagen').src = destacado.Fotogrande.substring(3);
			$('destacadosTitulo').innerHTML = destacado.Titulo;
			$('destacadosTexto').innerHTML = destacado.Descripcion;

			if( destacado.url != '')
				{
					$('destacadosEnlace').href = destacado.url;
					$('destacadosEnlace').target = destacado.urlTarget;
					$('destacadosEnlace').setStyle( 'display' , '' );
				}
			else
				{
					$('destacadosEnlace').setStyle( 'display' , 'none' );
				};
			
			switch (destacado.TipoVideo)
			{
				case '0': //none
					$('destacadoVideo').innerHTML = '';
					break;
				case '1': //personalizado
					$('destacadoVideo').innerHTML = '<a href="' + destacado.Video + '" target="_blank">Pulse aquí para ver el trailer en una ventana nueva</a>';
					break;
				case '2': //youtube
					$('destacadoVideo').innerHTML = '<object width="425" height="350"><param name="movie" value="http://www.youtube.com/v=' + destacado.Video + '" /><param name="wmode" value="transparent"/><embed src="http://www.youtube.com/v/' + destacado.Video + '" type="application/x-shockwave-flash" wmode="transparent" width="425" height="350"></embed>  </object>';
					break;
				case '3'://google
					$('destacadoVideo').innerHTML = '<embed style="width:400px; height:326px;" id="VideoPlayback" type="application/x-shockwave-flash" src="http://video.google.com/googleplayer.swf?docId=' + destacado.Video + '&hl=es" flashvars=""> </embed>';
					break;
			}
			var lista = $$( 'a[destacadoid]' );

			lista.each( function( enlace ) {
				if( enlace.getProperty( 'destacadoid' ) == id )
					enlace.setProperty( 'class' , 'foto3' )
				else
					enlace.setProperty( 'class' , 'foto2' );
			});
			
		}
	}).send();
}