$(document).ready(function() {
	$(".thumb-video").scrollable();
	
	$(".thumb-video a").hover(function(){
		var title = $(this).attr("lang");
		$("#details").hide();
		$("#details").html("Titulo: "+title);
		$("#details").show();
	},function(){
		$("#details").hide();
	});
	
	$(".thumb-video a").live("click",function(e){
		e.preventDefault();
		var idVideo = $(this).attr("rel");
		var tipoVideo = $(this).attr("id");
		var html;
		
		$("#video-destacado").fadeOut("normal", function(){
			$(this).empty();
			switch(tipoVideo)
			{
				//YOUTUBE
				case '1': 
					html = '<object width="545" height="300"><param name="movie" value="http://www.youtube.com/v/'+idVideo+'&hl=es_ES&fs=1;" /></param><param name="allowFullScreen" value="true" /></param><param name="allowscriptaccess" value="always" /></param><param wmode="wmode" value="transparent"/></param><embed src="http://www.youtube.com/v/'+idVideo+'&hl=es_ES&fs=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="545" height="300" wmode="transparent"></embed></object>';
				break;
				
				//FACEBOOK
				case '2': 
					html = '<object width="545" height="300" ><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param wmode="wmode" value="transparent"/> </param><param name="movie" value="http://www.facebook.com/v/'+idVideo+'" /><embed src="http://www.facebook.com/v/'+idVideo+'" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true"width="545" height="300"  wmode="transparent"></embed></object>';
				break;
				
				//BLIPTV
				case '3': 
					html = '<embed src="http://blip.tv/play/'+idVideo+'" type="application/x-shockwave-flash" width="545" height="300" allowscriptaccess="always" allowfullscreen="true" wmode="transparent"></embed>';
				break;
				
				//MEGAVIDEO
				case '4': 
					html = '<object  width="545" height="300"><param name="movie" value="http://www.megavideo.com/v/'+idVideo+'"></param><param name="allowFullScreen" value="true"></param><embed src="http://www.megavideo.com/v/'+idVideo+'" type="application/x-shockwave-flash" allowfullscreen="true"  width="545" height="300"  wmode="transparent"></embed></object>';
				break;
				
				//VIMEO
				case '5': 
					html = '<object width="545" height="300"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id='+idVideo+'&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1" /><param wmode="wmode" value="transparent"/><embed src="http://vimeo.com/moogaloop.swf?clip_id='+idVideo+'&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="545" height="300" wmode="transparent"></embed></object>';
				break;
				
				/*default: 
				caption ="default";*/
			}
			
			$(this).html(html);
			$(this).fadeIn("fast");
			
			
			/*ACTUALIZO COMENTARIOS DE FACEBOOK*/
			window.fbAsyncInit = function() {
			FB.init({appId: '186198468074835', status: true, cookie: true,
					 xfbml: true});
			};
			(function() {
			var e = document.createElement('script');
			e.type = 'text/javascript';
			e.src = document.location.protocol +
			  '//connect.facebook.net/es_LA/all.js';
			e.async = true;
			document.getElementById('fb-root').appendChild(e);
			}());
			
			$(".commet").empty();
			$(".commet").html('<fb:comments xid="'+idVideo+'" numposts="6" width="543" css="http://www.grupolanoche.cl/css/.css"></fb:comments>');
			
		});

	}).filter(":first").click();
	
});
