//CERRAR TIPS
function tips(){
	$('#tips').toggle()
}

//SEGUIR ESCUCHANDO
$('#seguir_escuchando').live('click', function(){
	$('.segir_cont').toggle()
})

/*SEGUIR ESCUCHANOD MENU / CLIC*/
$('.segir_cont li').live('click', function(){
	var id = $(this).attr('id')
	var texto = $(this).text()
	$('#seguir_escuchando').attr('class', 'seguir_escuchando_cont '+id)
	$('#seguir_escuchando .texto').text(texto)
	$('.segir_cont li').removeClass('activo')
	$(this).addClass('activo')
})
//BUSCADOR*****************************************************************
$('#vBuscador').live('click', function(){
	$(this).toggleClass('activo')
	busquedaBorrar()
	if($(this).is('.activo')){
		$('#barra_progreso_cont').animate({top:-35},{duration:1000, easing: 'easeOutBounce'})
		$('#vBuscadorCont').animate({top:-20},{duration:1000, easing: 'easeOutBounce'})
	}else{
		$('#barra_progreso_cont').animate({top:0},{duration:1000, easing: 'easeOutBounce'})
		$('#vBuscadorCont').animate({top:12},{duration:1000, easing: 'easeOutBounce'})
		$('.switch_buscador_progreso').removeClass('activo')
		
	}
})
//COMPARTIR
$('#compartirvideo, .pop-compartir .cerrar').live('click', function(){
	compartircont = $('.pop-compartir-cont')
	compartircont.html('')
	compartircont.toggle()
	var continuidad = $('#continuidad').val()
	var lista = $('#playlist_y').val()
	var artista = $('.cont_info_video .nombre').val()
	var vid = $('#video_actual').val()
	if($(this).is(':visible')){
		$.post('/pop-compartir.php',{vid:vid, artista:artista, lista:lista} , function(d){
			compartircont.html(d)
		})
	}else{
		compartircont.html('')
	}
	return false;
})
//FAVORITOS
$('#vlike').live('click', function(){
	$(this).toggleClass('activo')
})
//FAVORITOS
$('#vfav').live('click', function(){
	$(this).toggleClass('activo')
	var vid = $('#video_actual').val();
	$.post('/infovideo.php',{editar:'fav',v:vid},function(d){})
})


function busquedaBorrar(){
	$('.buscador_cont input').val('').select()
	$('.VResultados_cont').hide()
	$('#VR_videos').html('')
	
}

//CANCELAR BUSQUEDA
$('.buscador_cont .cerrar').live('click', function(){
	$('#vBuscador').click()
 })
//CLICK VIDEO BUSQUEDA
$('#vBuscadorCont .divRes').live('click', function(){
	var id = $(this).attr('id')
	var tipo = id.substr(0,5)
	var nombreid = id.substr(6)
	var vid
	switch(tipo){
		case'video':
		vid = nombreid;
		cambia_continuidad(1)
			reproVideo(vid);
			busquedaBorrar();
			$('#vBuscador').click()
		break;
		case'artis':
		$.post('/infovideo.php', {buscar:'vid', nombre:nombreid}, function(rvid){
			vid = rvid;
			cambia_continuidad(1)
			reproVideo(vid);
			busquedaBorrar();
			$('#vBuscador').click()
		})
		
		break;
		case'radio':
		$.post('/infovideo.php', {buscar:'vid', nombre:nombreid}, function(rvid){
			vid = rvid;
			cambia_continuidad(2)
			reproVideo(vid);
			busquedaBorrar();
			$('#vBuscador').click()
		})
		break;
	}
	
	
})
$('#VResultados_Iniciocont .divRes').live('click', function(){
	var id = $(this).attr('id')
	var tipo = id.substr(0,5)
	var nombreid = id.substr(6)
	
	switch(tipo){
		case'video':
		window.location="/v/"+nombreid+"&c=1";
		break;
		case'artis':
		window.location="/artista/"+nombreid+"&c=1";
		break;
		case'radio':
		window.location="/artista/"+nombreid+"&c=2";
		break;
	}
	
})
//ETIQUETAS BUSQUEDAS
$('.VResultados_cont .etiqueta').live('click', function(){
	var id = $(this).attr('id')
	var etiq = id.substr(9)
	$('.muestra_resultados').hide()
	$('.VResultados_cont .etiqueta').removeClass('activo')
	$('#VR_'+etiq).toggle()
	$(this).addClass('activo')
	
})
///BUSCADOR
$('.buscador_cont input').live('keypress',function(e) {
	var valor = $(this).val()
	var valorL = valor.length
	var cantidad_resultados = 6;

	//SI ESCRIBIO ALGO
	if(valorL>0){
		$('.press_enter').show()
		if(valorL>35){
			$('.press_enter').hide()
		}else{
			$('.press_enter').show()
		}
		
		if(e.keyCode == 13) {
		if($(this).is('#entradaVideo')){
			padreResultado = $('.VResultados_cont')
			DivVideoResultados = $('#VR_videos')
			DivArtistaResultados = $('#VR_artistas')
			DivRadioResultados = $('#VR_radio')
			padreResultado.show()
			$('.press_enter').hide()
			$('.switch_buscador_progreso').addClass('activo')
			etiquetaCargandoVideo = $('.VResultados_cont #etiqueta_videos li')
			etiquetaCargandoArtista = $('.VResultados_cont #etiqueta_artistas li')
			etiquetaCargandoRadio = $('.VResultados_cont #etiqueta_radio li')
			
			
			textoArtist = $('#etiqueta_artistas')
		}else if($(this).is('#entradaInicio')){
			
			padreResultado = $('#VResultados_Iniciocont')
			$('.buscador_cont').addClass('activo')
			$('#contenido_con .contenido .buscador_cont .buscador_form_cont .seg_logo').show()
			DivVideoResultados = $('#VR_videos')
			DivArtistaResultados = $('#VR_artistas')
			DivRadioResultados = $('#VR_radio')
			padreResultado.show()
			$('.press_enter').hide()
			//$('.switch_buscador_progreso').addClass('activo')
			etiquetaCargandoVideo = $('.VResultados_cont #etiqueta_videos li')
			etiquetaCargandoArtista = $('.VResultados_cont #etiqueta_artistas li')
			etiquetaCargandoRadio = $('.VResultados_cont #etiqueta_radio li')
			
			
			var valor = $(this).val()
			var valorL = valor.length
			var cantidad_resultados = 20;
			textoArtist = $('#etiqueta_artistas')
		}
		
		
		etiquetaCargandoVideo.addClass('cargando')	
		etiquetaCargandoArtista.addClass('cargando')	
		etiquetaCargandoRadio.addClass('cargando')
			//VIDEOS*******************
			$.post('/infovideo.php', {buscar:'video', valor:valor, cantidad:cantidad_resultados}, function(resultado){
				DivVideoResultados.html('')
				$.each(resultado, function(i, item) {
					var foto = item['foto'];
					var nombre = corta_texto(item['nombre'], 35);
					var descripcion = corta_texto(item['descripcion'], 85);
					var vid = item['vid'];
					var claseAlternativa
					if(foto==''){claseAlternativa='errorRadio'}
					var Mostrar = plantillaBusqueda(nombre, descripcion, foto, vid, claseAlternativa,'video')
					
					DivVideoResultados.append(Mostrar)
					etiquetaCargandoVideo.removeClass('cargando')
				  });	
			},"json")
			
			//ARTISTA********************
			$.post('/infovideo.php', {buscar:'artista', valor:valor, cantidad:cantidad_resultados}, function(resultado){
				
				DivArtistaResultados.html('')
				$.each(resultado, function(i, item) {
					var foto = item['foto'];
					var nombre = corta_texto(item['nombre'], 35);
					var descripcion = '';
					var vid = item['vid'];
					var claseAlternativa
					if(foto==''){claseAlternativa='errorArtista'}
					
					var Mostrar = plantillaBusqueda(nombre, descripcion, foto, vid, claseAlternativa, 'artis')
					
					DivArtistaResultados.append(Mostrar)
					etiquetaCargandoArtista.removeClass('cargando')
				  });	
			},"json")
			//RADIO********************
			$.post('/infovideo.php', {buscar:'radio', valor:valor, cantidad:cantidad_resultados}, function(resultado){
				DivRadioResultados.html('')
				$.each(resultado, function(i, item) {
					var foto = '';
					var radio = item['radio'];
					var artista = '';
					var vid = item['vid'];
					var claseAlternativa
					if(foto==''){claseAlternativa='errorRadio'}
					
					var Mostrar = plantillaBusqueda(radio, artista, foto, vid, claseAlternativa, 'radio')
					
					DivRadioResultados.append(Mostrar)
					etiquetaCargandoRadio.removeClass('cargando')
				  });	
			},"json")
	
	}else{
/*		//sino el valor es menos de 2 caracteres /no mostrar resultados
		if(padreResultado){
		padreResultado.hide()
		}*/
	}
	}
	
})
function buscador(){
	padreResultado = $('#VResultados_Iniciocont')
	$('.buscador_cont').addClass('activo')
	$('#contenido_con .contenido .buscador_cont .buscador_form_cont .seg_logo').show()
	DivVideoResultados = $('#VR_videos')
	DivArtistaResultados = $('#VR_artistas')
	DivRadioResultados = $('#VR_radio')
	padreResultado.show()
	$('.press_enter').hide()
	//$('.switch_buscador_progreso').addClass('activo')
	etiquetaCargandoVideo = $('.VResultados_cont #etiqueta_videos li')
	etiquetaCargandoArtista = $('.VResultados_cont #etiqueta_artistas li')
	etiquetaCargandoRadio = $('.VResultados_cont #etiqueta_radio li')
	
	
	var valor = $('#entradaInicio').val()
	var valorL = valor.length
	var cantidad_resultados = 20;
	textoArtist = $('#etiqueta_artistas')
	etiquetaCargandoVideo.addClass('cargando')	
	etiquetaCargandoArtista.addClass('cargando')	
	etiquetaCargandoRadio.addClass('cargando')
	//VIDEOS*******************
	$.post('/infovideo.php', {buscar:'video', valor:valor, cantidad:cantidad_resultados}, function(resultado){
		DivVideoResultados.html('')
		$.each(resultado, function(i, item) {
			var foto = item['foto'];
			var nombre = corta_texto(item['nombre'], 35);
			var descripcion = corta_texto(item['descripcion'], 85);
			var vid = item['vid'];
			var claseAlternativa
			if(foto==''){claseAlternativa='errorRadio'}
			var Mostrar = plantillaBusqueda(nombre, descripcion, foto, vid, claseAlternativa,'video')
			
			DivVideoResultados.append(Mostrar)
			etiquetaCargandoVideo.removeClass('cargando')
		  });	
	},"json")
	
	//ARTISTA********************
	$.post('/infovideo.php', {buscar:'artista', valor:valor, cantidad:cantidad_resultados}, function(resultado){
		
		DivArtistaResultados.html('')
		$.each(resultado, function(i, item) {
			var foto = item['foto'];
			var nombre = corta_texto(item['nombre'], 35);
			var descripcion = '';
			var vid = item['vid'];
			var claseAlternativa
			if(foto==''){claseAlternativa='errorArtista'}
			
			var Mostrar = plantillaBusqueda(nombre, descripcion, foto, vid, claseAlternativa, 'artis')
			
			DivArtistaResultados.append(Mostrar)
			etiquetaCargandoArtista.removeClass('cargando')
		  });	
	},"json")
	//RADIO********************
	$.post('/infovideo.php', {buscar:'radio', valor:valor, cantidad:cantidad_resultados}, function(resultado){
		DivRadioResultados.html('')
		$.each(resultado, function(i, item) {
			var foto = '';
			var radio = item['radio'];
			var artista = item['art'];
			var vid = item['vid'];
			var claseAlternativa
			if(foto==''){claseAlternativa='errorRadio'}
			
			var Mostrar = plantillaBusqueda(radio, artista, foto, vid, claseAlternativa, 'radio')
			
			DivRadioResultados.append(Mostrar)
			etiquetaCargandoRadio.removeClass('cargando')
		  });	
	},"json")
}


function plantillaBusqueda(nombre, descripcion, foto, vid, claseAlternativa, tipo){
	var artradio = descripcion;
	if(foto!=''){
		foto = '<img src="'+foto+'" alt="" width="91" height="68" />';
	}else{
		foto = '';
	}
	var id;
	switch(tipo){
		case'video':
		id = vid;
		break;
		case'radio':
		id = artradio;
		descripcion = '';
		break;
		case'artis':
		id=nombre;
		break;
	}
	var plantilla = '<div class="divRes" id="'+tipo+'_'+id+'">'+
			'<div class="video_miniatura redondo '+claseAlternativa+' ">'+
			  '<div class="miniatura-img"><span class="tiempo"></span>'+foto+'</div>'+
			'</div>'+
			'<div class="detalles">'+
			  '<h1>'+nombre+'</h1>'+
			 ' <h2>'+descripcion+'</h2>'+
		   ' </div>'+
	   ' </div>';
	   
	   return plantilla;
}
//FIIN BUSCADOR**********/

///PLAY
$('.play, #vPlay').live('click', function(){
	$('.play, #vPlay').toggleClass('activo')
	if($(this).is('.activo')){
		playVideo();
		//var margen = -54;
	}else{
		pauseVideo()			
	}
})
///SIG
$('#vNext').live('click', function(){
		$('.ctrl-repro-pop.redondo .cont-barra-cargado .barra_progreso_repro, .ctrl-repro-pop.redondo .cont-barra-cargado.redondo .barra_cargado').hide()
		$('.cont-barra-cargado,.play, #vPlay').addClass('activo')
		pauseVideo();	
		cambia_video()
})

/*MUDO CLICK*/
$('#vVolumen').live('click',function(){
	if($(this).is('.activo')){
		unMuteVideo()
		$(this).removeClass('activo')
	}else{
		muteVideo()
		$(this).addClass('activo')
	}
})
//MOSTRAR REPRO
$('.video_cont').live('mouseover', function(){
	//$('.ctrl-repro-pop, .segir_cont').show()
})
$('.video_cont').live('mouseout', function(){
	//$('.ctrl-repro-pop, .segir_cont').hide()
})
//MOSTRAR CONTROLES DE VOL
$('#vVolumen').live('hover', function(){
	$('#vVolumen .vol_cont').toggle()
})


/***************************************************************/
      /*
       * Chromeless player has no controls.
       */
      
      // Update a particular HTML element with a new value
      function updateHTML(elmId, value) {
        document.getElementById(elmId).innerHTML = value;
      }
      
      // This function is called when an error is thrown by the player
      function onPlayerError(errorCode) {
        //alert("An error occured of type:" + errorCode);
		cambia_video();
      }
      
      // This function is called when the player changes state
      function onPlayerStateChange(newState) {
			
			/*finalizado*/
		  	if(newState == 0){
				/***/
			}
			/*iniciando-cargando*/
			else if(newState == -1){
				$('.cont-barra-cargado,.play, #vPlay').addClass('activo')
				$('.cont-barra-cargado .barra_progreso_repro').hide()
			}
			/*Iniciado - reproduciendo*/
			else if(newState==1){
				$('.play, #vPlay').addClass('activo')
				$('.cont-barra-cargado').removeClass('activo')
				$('.cont-barra-cargado .barra_progreso_repro').show()				
				
			}
			/*pausado*/
			else if(newState==2){
				$('.play, #vPlay').removeClass('activo')
				$('.cont-barra-cargado .barra_progreso_repro').show()
			}
			/*cargando buffering mientras esta reproduciendo*/
			else if(newState==3){
			}
      }
		  /*****************TIEMPO FORMATO 00:00 *******************/
		 function tiempoFormato(tiempo){
			  /*segundos*/
			  var seg =  (parseInt(tiempo));
			  /*Minutos*/
			  var minutos = parseInt((seg/60));
			 // if(minutos<10){minutos = '0'+minutos}
			  ///Copyrights bryan 
			  var segundos_de_los_minutos = minutos*60; 
			  var seg2 =  seg-segundos_de_los_minutos;

			  if(seg2 < 10){seg2 = '0'+seg2}
			  var valor = (minutos+':'+seg2);
			  return valor;
		 }
		/*************/

      
      // Display information about the current state of the player
      function updatePlayerInfo() {
        // Also check that at least one function exists since when IE unloads the
        // page, it will destroy the SWF before clearing the interval.
        if(ytplayer && ytplayer.getDuration) {
			var pdura = parseInt(ytplayer.getDuration())-4; 
			var pactu = parseInt(ytplayer.getCurrentTime());
			if(pactu>4 && pactu==pdura){
				cambia_video();	 
			}
			if(ytplayer.getDuration()>90){
				var restante = parseInt(ytplayer.getDuration())-parseInt(ytplayer.getCurrentTime());
				if(ytplayer.getCurrentTime()>=10 && ytplayer.getCurrentTime()<11){inicio_cancion();}
				if(restante<=25 && restante>24 ){fin_cancion();}
				if(ytplayer.getCurrentTime()>=50 && ytplayer.getCurrentTime()<51){mostrar_noticia();}
				if(restante<=70 && restante>69){mostrar_info_artista();}
			}
          updateHTML("videoDuration", tiempoFormato(ytplayer.getDuration()));
		  updateHTML("videoCurrentTime", tiempoFormato(ytplayer.getCurrentTime()));

		  $("#tiempoTranscurrido").val(ytplayer.getCurrentTime());
		  $("#tiempoTotalVideo").val(ytplayer.getDuration());
		  /*CARGADO*/
		  var cantCargado = ((ytplayer.getVideoBytesLoaded() / ytplayer.getVideoBytesTotal())*100)
          $('#videoCantCargado').css('width', cantCargado+'%')
		  
		  /*REPRODUCIDO*/
		  var cantRepro = ((ytplayer.getCurrentTime() / ytplayer.getDuration())*1000)
		  //cantRepro = cantRepro/100;
		$("#progreso_repro" ).slider({
			value:(cantRepro),
		});
		  		  
        }
      }
      
      // Allow the user to set the volume from 0-100
      function setVideoVolume(val) {
        var volume = val;
        if(isNaN(volume) || volume < 0 || volume > 100) {
          /*Sino esta entre 0 y 100*/
        }
        else if(ytplayer){
          ytplayer.setVolume(volume);
        }
      }
      function playVideo() {
        if (ytplayer) {
          ytplayer.playVideo();
        }
      }
      
      function pauseVideo() {
        if (ytplayer) {
          ytplayer.pauseVideo();
        }
      }
      
      function muteVideo() {
        if(ytplayer) {
          ytplayer.mute();
        }
      }
      
      function unMuteVideo() {
        if(ytplayer) {
          ytplayer.unMute();
        }
      }
	  //player.seekTo(seconds:1000, allowSeekAhead:10000);
      
      
      // This function is automatically called by the player once it loads
      function onYouTubePlayerReady(playerId) {
        var videoActual = $('#video_actual').val()
		ytplayer = document.getElementById("ytPlayer");
        // This causes the updatePlayerInfo function to be called every 250ms to
        // get fresh data from the player
        setInterval(updatePlayerInfo, 1000);
        updatePlayerInfo();
        ytplayer.addEventListener("onStateChange", "onPlayerStateChange");
        ytplayer.addEventListener("onError", "onPlayerError");
        //Load an initial video into the player
        ytplayer.loadVideoById(videoActual);
		muestro_info_video(videoActual)
		
      }
      
      // The "main method" of this sample. Called when someone clicks "Run".
      function loadPlayer() {
        // Lets Flash from another domain call JavaScript
        var params = { allowScriptAccess: "always", wmode:"transparent"}; 
        // The element id of the Flash embed
        var atts = { id: "ytPlayer" };
        // All of the magic handled by SWFObject (http://code.google.com/p/swfobject/)
        swfobject.embedSWF("http://www.youtube.com/apiplayer?" +
                           "version=3&enablejsapi=1&playerapiid=player1", 
                           "videoDiv", "1020", "600", "9", null, null, params, atts);
      }
      function _run() {
        loadPlayer();
      }
      google.setOnLoadCallback(_run);
	
	function cambia_video(){
		info_video_efecto(2)
		info_video_efecto(4)
		info_video_efecto(6)
		var myplaylist = $("#lista_propia").val();
		var cont = $("#continuidad").val();
		var playlist_act = $("#playlist_y").val();
		var v_actual;
		var siplaylist;
		
		if(cont == 4){
		v_actual = myplaylist;	
		}else{
		
		if(playlist_act && cont==3){
		v_actual = playlist_act;	
		siplaylist = true;
		}else{
		
		if(cont == 2 || cont==1){
		v_actual = $("#video_base").val(); 
		} else {
		v_actual = $("#video_actual").val();
		}
		
		}
		
		if(cont ==1){
		$("#muestra_bio").val('1');
		}else{
		$("#muestra_bio").val('0');
		} 
	
		$("#muestra_noticia").val('0');
		$("#muestra_info_fin").val('0');
		$("#muestra_info_inicio").val('0');

		if(cont == 3 && !siplaylist){
		v_actual = '';
		}
		
		}
		$.post('/next.php',{v:v_actual ,c:cont},function (d){
			if(ytplayer) {
				ytplayer.loadVideoById(d);
				$("#video_actual").val(d);
				muestro_info_video(d)
				$.post('/infovideo.php',{editar:'favconsulta',v:d},function(r){
					if(r==0){
					$('#vfav').removeClass('activo')	
					}else{  
					$('#vfav').addClass('activo')
					}
				})
			}
		});
		
	}
	
	function reproVideo(vid){
			info_video_efecto(2)
			info_video_efecto(4)
			info_video_efecto(6)
			var cont = $("#continuidad").val();
			if(cont ==1){
				$("#muestra_bio").val(1);
			}else{
				$("#muestra_bio").val(0);
			} 
			$("#muestra_noticia").val(0);
			$("#muestra_info_fin").val(0);
			$("#muestra_info_inicio").val(0);
			
			if(ytplayer) {
				ytplayer.loadVideoById(vid);
				$("#video_base").val(vid); 
				$("#video_actual").val(vid);
				muestro_info_video(vid)
			}
		}
	
	function cambia_continuidad(c){
		continuidadClass(c) 
		$("#continuidad").val(c);
		if(c==2 || c==1){
			var vidbase = $("#video_actual").val();
			$("#video_base").val(vidbase);	
		}
	}
	
	/*********EFECTO INFORMACION DE LA CANCION***********/
	function info_video_efecto(accion){
		//album miniatura
		albumMini = $('.video_cont .cont_info_video .album_miniatura');
		//album-nombre-artista
		AlNoArt = $('.video_cont .cont_info_video .artista, .video_cont .cont_info_video .nombre,.video_cont .cont_info_video .album');
		//Artista - album
		ArAl = $('.video_cont .cont_info_video .artista,.video_cont .cont_info_video .album');
		//album
		album = $('.video_cont .cont_info_video .album');
		//noticia slide
		notiSlide = $('.cont_info_video .noticia_slide');
		//noticia detalles
		notiDetalles = $('.cont_info_video .noticia_detalle');
		//bio imagen
		bioImg = $('.cont_info_video .bio_cont .miniatura_bio');
		//bio titulo
		bioTitulo = $('.cont_info_video .bio_cont .titulo');
		//bio detalle
		bioDetalle = $('.cont_info_video .bio_cont .cont_detalles');
		
		
		if(accion==1){//MOSTRAR INFOR VIDEO
			albumMini.animate({left:0},500);
			AlNoArt.animate({right:0,}, 500);
			ArAl.animate({top: 46,},300);
			album.animate({top:75,}, 300);
			var terminado = false;
			$.timer(10000, function(timer){
				if(!terminado){
				   info_video_efecto(2);
				   terminado=true;
				}else{
					timer.stop()
					terminado =false;
				}
			}) 
		}
		if(accion==2){//OCULTAR INFO VIDEO
			album.animate({top:46,}, 300)
			ArAl.animate({top: 5,},300)
			albumMini.animate({left:-150,},500)
			AlNoArt.animate({right:-860,}, 500)
		}
		if(accion==3){//MOSTRAR INFO NOTICIAS
			notiDetalles.animate({bottom:0},{duration:1000/*, easing: 'easeOutBounce'*/})
			notiSlide.animate({bottom:90},{duration:1000, easing: 'easeOutBounce'})
			$.timer(25000, function(timer){
				if(!terminado){
				   info_video_efecto(4);
				   terminado=true;
				}else{
					timer.stop()
					terminado =false;
				}
			}) 
		}
		if(accion==4){//OCULTAR INFO NOTICIAS
			notiDetalles.animate({bottom:-990},500)
			notiSlide.animate({bottom:-90},1000)
		}
		
		if(accion==5){//MOSTRAR BIO ARTISTA
			bioImg.animate({left:20},{duration:1000, easing:'easeOutBounce'});
			bioTitulo.animate({left:20},{duration:1000, easing:'easeOutBounce'});
			bioDetalle.animate({left:20},{duration:500, easing:'easeOutBounce'});
			
			var terminado = false;
			$.timer(25000, function(timer){
				if(!terminado){
				   info_video_efecto(6);
				   terminado=true;
				}else{
					timer.stop()
					terminado =false;
				}
			}) 
		}
		
		if(accion==6){//OCULTAR BIO ARTISTA
			bioImg.animate({left:-80},{duration:1000, easing:'easeOutBounce'});
			bioTitulo.animate({left:-503},{duration:1000, easing:'easeOutBounce'});
			bioDetalle.animate({left:-500},{duration:1000, easing:'easeOutBounce'});
		}
			
		
	}/*fin efecto video*/
	
	function inicio_cancion(){
		var ejecutado = $("#muestra_info_inicio").val();
		if(ejecutado == 0){
			info_video_efecto(1)
			$("#muestra_info_inicio").val(1);
		}
	}
	
	function fin_cancion(){
		//MOSTRAR INFO DE LA CANCION
		var ejecutado = $("#muestra_info_fin").val();
		if(ejecutado == 0){
			$("#muestra_info_fin").val(1);
			info_video_efecto(1)
		}
	}
	
	function mostrar_noticia(){
		//MOSTRAR NOTICIA
		var ejecutado = $("#muestra_noticia").val();
		if(ejecutado == 0){
			$("#muestra_noticia").val(1);
			info_video_efecto(3)
		}
	}
	
	function mostrar_info_artista(){
		//MOSTRAR BIOGRAFIA ARTISTA
		var ejecutado = $("#muestra_bio").val();
		if(ejecutado == 0){
			info_video_efecto(5)
			$("#muestra_bio").val(1);
		}
		
	}
	function muestro_info_video(vID){
				var d = vID;
				var wtfs;
				var playlist = $("#playlist_y").val();
				if(playlist == 'C7FBA3DE088AD441'){
					wtfs = '1';
				}else{
					wtfs = '0';
				}
					
				//INFO CANCION
				$.post('/infovideo.php',{info:'video', v:d},function (ivideo){
					//DIVS
					nombreEtiq = $('.video_cont .cont_info_video .nombre')
					artistaEtiq =  $('.video_cont .cont_info_video .artista')
					albumEtiq =$('.video_cont .cont_info_video .album')
					imgEtiq = $('.video_cont .cont_info_video .album_miniatura img')
					notiDetalles = $('.cont_info_video .noticia_detalle');
					//VALORES
					
					var nombre = ivideo['l1'];
					
					//si no hay info no hacer ni picha
					if(nombre){
						var nombre = corta_texto(nombre, 61);
						var artista = ivideo['l2']
						var album = ivideo['l3']
						var imagen = ivideo['imagen']
						if(album==''){albumEtiq.hide()}else{albumEtiq.show()}
						nombreEtiq.html(nombre)
						artistaEtiq.html(artista)
						albumEtiq.html(album)
						imgEtiq.attr('src', imagen)
						cambiar_tags(nombre+'-'+artista)
					}else{
						$("#muestra_info_inicio").val(1);
						$("#muestra_info_fin").val(1);
					}
				}, "json")
				//NOTICIA ARTISTA
				if(wtfs == '1'){
					$("#muestra_noticia").val(1);
				}else{
				$.post('/infovideo.php',{info:'noticia', v:d},function (nvideo){
					//DIVS
					notiTitulo = $('.cont_info_video .noticia_detalle h1');
					notiCont = $('.cont_info_video .noticia_detalle h2');
					notiImg = $('.cont_info_video .noticia_detalle .img_noticia img');
					//VALORES
					var titulo = nvideo['titulo']
					//si no hay noticias no mostrar ni picha
					if(titulo!=''){
						var contenido = nvideo['contenido']
						var imagen = nvideo['imagen']
						notiTitulo.html(titulo)
						notiCont.html(contenido)
						notiImg.attr('src', imagen)
					}else{
						$("#muestra_noticia").val(1);
					}
				}, "json")
				}
				//BIOGRAFIA ARTISTA
				if(wtfs == '1'){
					bioTitulo = $('.cont_info_video .bio_cont .titulo a');
					bioCont = $('.cont_info_video .bio_cont .cont_detalles');
					bioImg = $('.cont_info_video .bio_cont .miniatura_bio img');
					bioContTodo = $('.cont_info_video .bio_cont');
					if(bioCont==''){bioContTodo.hide()}else{bioContTodo.show()}
					link = $('.cont_info_video .bio_cont .titulo a');
					   
					var titulo = 'WDF show by MOX';
					var contenido = 'WDF show es un webshow creado por Mox (J.A. Romero) el cual consiste en mostrar videos virales, graciosos y raros de la internet. Es también un foro interactivo en el cual se publica una pregunta en Facebook para que sus seguidores se entretengan, interactúen y salgan en el programa. El show nace una madrugada de terror el 22 de Noviembre del 2009 y si no lo sabes… Ahora lo sabes…';
					var imagen = 'http://graph.facebook.com/moxwdf/picture?type=large';
					var url = 'https://www.facebook.com/wdfshow';
					bioTitulo.text(titulo)
					bioCont.html(corta_texto(contenido, 341))
					bioImg.attr('src', imagen)
					link.attr('href', url)
				}else{
				$.post('/infovideo.php',{info:'bio', v:d},function (bvideo){
					//DIVS
					bioTitulo = $('.cont_info_video .bio_cont .titulo a');
					bioCont = $('.cont_info_video .bio_cont .cont_detalles');
					bioImg = $('.cont_info_video .bio_cont .miniatura_bio img');
					bioContTodo = $('.cont_info_video .bio_cont');
					if(bioCont==''){bioContTodo.hide()}else{bioContTodo.show()}
					link = $('.cont_info_video .bio_cont .titulo a');
					//VALORES
					var titulo = bvideo['nombre']
					//si no hay biografia, no mostrar ni picha
					if(titulo!=''){
						var contenido = bvideo['biografia']
						var imagen = bvideo['imagen']
						var url = bvideo['url']
						bioTitulo.text(titulo)
						bioCont.html(corta_texto(contenido, 341))
						bioImg.attr('src', imagen)
						link.attr('href', url)
					}else{
						$("#muestra_bio").val(1);
					}
				}, "json")
				}
				
	}
	
	
	function corta_texto(texto, cantidad){
		if(texto){
		textoL = texto.length
		texto = texto.substr(0, cantidad)
		if(textoL > cantidad){
			texto = texto+'...';
		}
		}
		return texto;
		
	}
	
	function cambia_color(etiqueta, nuevoColor){
		var colorN = etiqueta.css("color")
		etiqueta
		.animate({color: nuevoColor}, 500)
		.animate({color: colorN}, 500)
		.animate({color: nuevoColor}, 500)
		.animate({color: colorN}, 500)
		.animate({color: nuevoColor}, 500)
		.animate({color: colorN}, 500);
	}
	
function continuidadClass(continuidad){
	var clase;
	var txt;
	switch(continuidad){
		case 1:
			clase = 'SmismoA';
			txt = 'Mismo artista';
		break;
		case 2:
			clase = 'SartSim';
			txt = 'Arts. similares';
		break;
		case 3:
			var txtrec = $('#nombre_y').val();
			clase = 'Srecomend';
			txt = txtrec;
		break;
	}
	
	$('#seguir_escuchando').attr('class', 'seguir_escuchando_cont '+clase)
	$('#seguir_escuchando .texto').text(txt)
}

function cambiar_tags(titulo){
	//$( 'title' ).html (titulo);
}
