// JavaScript Document

function apagacampo(cmp, def)
{
	if (cmp.value==def)
		cmp.value = '';
}

function restorecampo(cmp, def)
{
	if (cmp.value=='')
	{
		cmp.value = def;
	}
}

var $j = jQuery.noConflict();

function mycarousel_initCallback(carousel) {
    
    $j('#mycarousel-next').bind('click', function() {
        carousel.next();
        return false;
    });
 
    $j('#mycarousel-prev').bind('click', function() {
        carousel.prev();
        return false;
    });
};

// Podcast player
jQuery(document).ready(function($) {	
	
	// Search
	$("input.searchbox").focus(function() {
		if (!$(this).hasClass("searchbox-active"))
		{
			$(this).addClass("searchbox-active");
		}
	});

	
	
	// Fancybox
	/* This is basic - uses default settings */
	
	$("a#single_image").fancybox();
	
	/* Using custom settings */
	
	$("a#inline").fancybox({
		'hideOnContentClick': true
	});

	/* Apply fancybox to multiple items */
	
	$("a.group").fancybox({
		'transitionIn'	:	'elastic',
		'transitionOut'	:	'elastic',
		'speedIn'		:	600, 
		'speedOut'		:	200, 
		'overlayShow'	:	true
	});
		
	// Podcast
	
	$(".podcast ul li").hover(
	function() {
		$("span", this).fadeIn('fast');
	}, 
	function() {
		$("span", this).fadeOut('fast');
	});
	
	$(".years strong").toggle (
		function() {
			$("+ul", $(this)).show('fast');
		},
		function() {
			$("+ul", $(this)).hide('fast');
		}
	);
	
	$("#coverpod").hover(
	function() {
		$(".controles").fadeIn('fast');
	});
	
	$(".controles").mouseleave(function() {
		$(".controles").fadeOut('fast');
	});
	
	$(".postagem .content object").each(function(index) {
		
		var largura = $(this).width();
		var altura = $(this).height();
		
		if (largura>570){
			
			altura = Math.round(570/largura*altura);
			$(this).css('width','570px');
			$(this).css('height',altura+'px');
		}
	});
	$(".postagem .content embed").each(function(index) {
		
		var largura = $(this).width();
		var altura = $(this).height();
		
		if (largura>570){
			altura = Math.round(570/largura*altura);
			$(this).css('width','570px');
			$(this).css('height',altura+'px');
		}
	});
	
	$(".postagem .content img").each(function(index) {
		
		var largura = $(this).width();
		var altura = $(this).height();
		
		if (largura>570)
		{
			$(this).addClass('img570');
		}
	});
	
	
 $('#mycarousel').jcarousel({
        vertical: true,
		animation: 200,
        initCallback: mycarousel_initCallback,
		buttonNextHTML: null,
        buttonPrevHTML: null,
        scroll: 1
    });
});


 
function popitup(url,param) {
	newwindow=window.open(url+'?param='+param,'podplay','height=200,width=400');
	if (window.focus) {newwindow.focus()}
	return false;
}
