
		
$(document).ready(function() {

	$('.cargando-g').Centrar().fadeIn(); //.css({'display':'block'});
	//$('#vM').Centrar();
	
	$('video').FullSize();
	
	// VIDEO CONTROLS
	
	$('.pause').live('click', function() {
		$('#vM').fadeIn().html('paused');
		$('#video').trigger('pause');
		
		// GOOGLE ANALYTICS
		//pageTracker._trackEvent('video', 'pause', document.location );
		_gaq.push(['_trackEvent', 'video', 'pause', document.location]);
		
		})
		
	$('.play').live('click', function() {
		$('#vM').fadeOut('fast');
		$('#video').trigger('play');
		
		// GOOGLE ANALYTICS
		//pageTracker._trackEvent('video', 'play', document.location );
		_gaq.push(['_trackEvent', 'video', 'play', document.location]);
		
		})
	
	
	$('#video').bind('loadstart', function(){
	 	$('.cargando-g').fadeOut();
	 	
	 	})
	
	$('#video').bind('canplay', function(){
		$('#vM').fadeOut('fast');
		$('.js-pp').fadeIn('fast');
		});
	
	$('#video').bind('timeupdate', function(){
		$('.js-metaVideo').html((this.currentTime).toFixed(3) + ' / '+(this.duration).toFixed(3)+' seg');
		});
	
	
	$('#video').bind('ended', function(){
		$(this).trigger('play');
		//alert('fin');
		});
	
	$('#video').bind('error', function(){
		document.reload();
		});
		
	
	$('#video').bind('play', function(){
		$('.js-pp').html('<a class="pause" href="#">pause</a>');
		});
	
	$('#video').bind('pause', function(){
		$('.js-pp').html('<a class="play" href="#">play</a>');
		});
	
	
	$('#video').bind('waiting', function(){
		$('#vM').fadeIn('fast').html('waiting …');
		$('#video').trigger('pause');
		});
	
	$('#video').bind('stalled', function(){
		$('#vM').fadeIn('fast').html('stalled …');
		$('#video').trigger('pause');
		});
	
	$('#video').bind('playing', function(){
		$('#vM').fadeOut('fast');
		$('.js-pp').html('<a class="pause" href="#">pause</a>');
		});
		
	
	// FIN VIDEO CONTROLS
	
	$('#badbrowser').Centrar();
	
	// cargar la imagen del fondo
	if($('#ifondo').is('img')) {
		$.cacheImage($('#ifondo').attr('src') ,{
			load : function (e) {
				// colocar la imagen
				$('.cargando-g').fadeOut();
				$('#ifondo').cjObjectScaler({
					method: 'fill', 
					fade: 800
					});
				
				},
			error : function() {
				//cerrar();
				$('.cargando-g').hide();
				alert('defecto en la ruta de la imagen');
				}
			});
		}
	
	// RESIZE BROWSER
	
	$(window).resize(function () {
		
		$('#ifondo, img.pomada').delay(800).cjObjectScaler({fade:800});
		$('.cargando-g').Centrar();
		$('.cargando').Centrar();
		});
	
	});
