// JavaScript Document

$(document).ready(function() {
	
	$("#link").click(function(){
		$("#link").select();
	});	
	
	$('.title-red, .title-gray').corner("top");
	$('div.inner-w').wrap('<div class="outer-gray"></div>');
	$('.inner-w').corner("round 6px").parent().css('padding', '3px');
	$('.outer-gray').corner("bottom 5px").corner("right 5px");
	
	if( !$(".containerPrograma, .bn").is(':animated') ){
		
		$('.containerPrograma, .bn').hover(function(){
			$(this).fadeTo(300,0.7);
		},function() {
			$(this).fadeTo(300,1);
		});
		
	}
	
	$('#btnPlayer').toggle(function() {
		$.post("/ajax_player1.php", { tipo:'str' }, function(retorno){
			$("#ppc").html(retorno);
			$('#btnPlayer').css('background-image','url(/images/IhdOn.png)');	
			$("#embed").click(function(){
				$("#embed").select();
			});
			$("#link").click(function(){
				$("#link").select();
			});			
		});
	}, function() {
		$.post("/ajax_player1.php", { tipo:'demand' }, function(retorno){
			$("#ppc").html(retorno);
			$('#btnPlayer').css('background-image','url(/images/IhdOff.png)');
			$("#embed").click(function(){
				$("#embed").select();
			});	
			$("#link").click(function(){
				$("#link").select();
			});
		});
	});
	
	jQuery('#mycarousel').jcarousel({
		scroll: 1,
		visible: 5
	});
	
	$('#mycarousel li').click(function() {
		var time = Trim($(this).find("span").html());
		var imagem = Trim($(this).find("img").attr('src'));
		$.post("/ajax_parts.php", { tempo:time, img:imagem }, function(retorno){
			$("#ppc").html(retorno);
			$("#embed").click(function(){
				$("#embed").select();
			});
			$("#link").click(function(){
				$("#link").select();
			});
		});
	});
	
	var div = $('#tituloTempo');
	
	$('#mycarousel li').hover(function(){
		$('#tituloTempo').html($(this).find("p").html());
		if( !$("#tituloTempo").is(':animated') ){
			$('#tituloTempo').fadeIn('fast');
		}
		$().mousemove(function(e){
		   div.css({
			  top: e.pageY + 5,
			  left: e.pageX + 5
		   });
		});
	},function() {
		$('#tituloTempo').hide();
	});
			
	$('#btnPlayer').hide();
	
	$('#playerContainer').hover(function(){
		$('#btnPlayer').fadeIn();
	},function() {
		$('#btnPlayer').fadeOut();
	});
	

	
});

$(window).ready(function() {
	jQuery('.cpp div').equalHeight();
	jQuery('#playerContainer, .logo-m').equalHeight();
});
