window.addEvent('domready', function() {
	var anima = 0;
	$('d_vehiculos').setOpacity(0)			
	$$('.vehiculo img').setOpacity(.5);
	$$('.vehiculo img').addEvents({
        mouseenter: function(){
			this.morph({
    	        'opacity':  '1',
				'border-color':	'#FCD04B'
            });
		},
        mouseleave: function(){
			this.morph({
				'opacity':  '.5',
				'border-color':	'#333'
			});
        }
    });	
	
	//Llamado ajax
	var myRequest = new Request(
	{
		method: 'post', 
		url: 'php_fc/vehiculo.php',
		onSuccess: function(responseText, responseXML){
			$('d_vehiculos').innerHTML = responseText;
			//Aplica Galería
			var nS1 = new noobSlide({
				interval: 2000,
				box: $('box1'),
				items: $$('#box1 span'),
				size: 460,
				autoPlay: false,
				addButtons: {
					previous: $('anterior'),
					next: $('siguiente')
				}
			});
		}		
	});

	//Reune Thumbnails
	var rThumb = new Fx.Morph('thumbs', {
		duration: 500, 
		transition: Fx.Transitions.Sine.easeOut,
		onComplete: function(){
			$('d_vehiculos').morph({
				'opacity':  1,
				'height':	600
			});
			anima = 1;
			myRequest.send('vehiculo='+vehiculo);	

		}
	});
 
	$$('.vehiculo img').addEvents({
        click: function(){			
			vehiculo = this.getProperty('title');
			if (anima == 0) {
				rThumb.start({
					'width': [400]
				});
			}else{
				$('d_vehiculos').highlight('#444');
				$('d_vehiculos').innerHTML = "<p>Cargando...</p> ";
				myRequest.send('vehiculo='+vehiculo);
			}
			
		}
    });
	
});