jQuery.noConflict();
function megaHoverOver(){
	jQuery(this).find(".sub").stop().fadeTo('fast', 1).show();
		
	//Calculate width of all ul's
	(function() { 
		jQuery.fn.calcSubWidth = function() {
			rowWidth = 0;
			//Calculate row
			jQuery(this).find("ul").each(function() {					
				rowWidth += jQuery(this).width(); 
			});	
		};
	})(jQuery); 
	
	if ( jQuery(this).find(".row").length > 0 ) { //If row exists...
		var biggestRow = 0;	
		//Calculate each row
		jQuery(this).find(".row").each(function() {							   
			jQuery(this).calcSubWidth();
			//Find biggest row
			if(rowWidth > biggestRow) {
				biggestRow = rowWidth;
			}
		});
		//Set width
		jQuery(this).find(".sub").css({'width' :biggestRow});
		jQuery(this).find(".row:last").css({'margin':'0'});
		
	} else { //If row does not exist...
		
		jQuery(this).calcSubWidth();
		//Set Width
		jQuery(this).find(".sub").css({'width' : rowWidth});
		
	}
}
function megaHoverOut(){ 
  jQuery(this).find(".sub").stop().fadeTo('fast', 0, function() {
	  jQuery(this).hide(); 
  });
}
var config = {    
	 sensitivity: 2, // number = sensitivity threshold (must be 1 or higher)    
	 interval: 100, // number = milliseconds for onMouseOver polling interval    
	 over: megaHoverOver, // function = onMouseOver callback (REQUIRED)    
	 timeout: 500, // number = milliseconds delay before onMouseOut    
	 out: megaHoverOut // function = onMouseOut callback (REQUIRED)    
};
/**/
function bannerEventos_initCallback(carousel)
{
	jQuery('#bannerEventos .jcarousel-control a').bind('click', function() {
	  carousel.scroll(jQuery.jcarousel.intval(jQuery(this).text()));
	  return false;
    });
    /*jQuery('#bannerEventos-next').bind('click', function() {
	  carousel.next();
	  return false;
    });

    jQuery('#bannerEventos-prev').bind('click', function() {
	  carousel.prev();
	  return false;
    });*/
};
function simples_initCallback(carousel)
{
	// Disable autoscrolling if the user clicks the prev or next button.
	carousel.buttonNext.bind('click', function() {
		carousel.startAuto(0);
	});
	
	carousel.buttonPrev.bind('click', function() {
		carousel.startAuto(0);
	});
	
	// Pause autoscrolling if the user moves with the cursor over the clip.
	carousel.clip.hover(function() {
		carousel.stopAuto();
	}, function() {
		carousel.startAuto();
	});
};
jQuery(document).ready(function ($) {
	$('*').each(function() {
		if ($(this).css('float') !== 'none') {
			$(this).css('display', 'inline');
		}
	});
	/*$("a").click(function(event) {
		event.preventDefault();
	});*/
	$("#componenteTVOAB").tabs();
	$("ul#topnav li .sub").css({'opacity':'0'});
	$("ul#topnav li").hoverIntent(config);
	$("#bannerEventos ul").jcarousel({
		scroll: 1,
		auto: 7,
		wrap: 'last',
		initCallback: bannerEventos_initCallback,
		// This tells jCarousel NOT to autobuild prev/next buttons
		buttonNextHTML: null,
		buttonPrevHTML: null
	});
	$(".carouselUm").jcarousel({
		scroll: 1,
		auto: 1,
		wrap: 'last',
		initCallback: simples_initCallback
	});
	$(".carouselDois").jcarousel({
		scroll: 1,
		auto: 3,
		wrap: 'last',
		initCallback: simples_initCallback
	});
	$(".carouselTres").jcarousel({
		scroll: 1,
		auto: 5,
		wrap: 'last',
		initCallback: simples_initCallback
	});
	$(".carouselQuatro").jcarousel({
		scroll: 1,
		auto: 5,
		wrap: 'last',
		initCallback: simples_initCallback
	});
	/*Painéis*/
	window.api = $("#flowpanes").scrollable({
		clickable: false,
		size: 1,
		loop: true
	}).circular().navigator(".navigator").mousewheel().autoscroll({ 
		autoplay: true,
		interval: 3000,
		api: true
	});
	$("input.pausa").click(function(){
		api.pause();
	});	
	jQuery(".maskVideo109x72").css("visibility", "hidden");
});

jQuery(window).load(function() {
	jQuery(".maskVideo109x72").each(
		function(){
			if(jQuery("img", this).length > 0){
				var width = jQuery("img", this).width();
				var height = jQuery("img", this).height();
				
				if(isNaN(width) || isNaN(height)){
					return;
				}else{
					jQuery(this).css("width", width + "px");
					jQuery(this).css("height", height + "px");
				}
			}else{
				jQuery(this).removeClass("maskVideo109x72");
			}
		}
	);
	jQuery(".maskVideo109x72, #tvOabDF, .assistaTambem .imagem").css("visibility", "");
});
