
$("#mycarousel2 img.reflection").pngfix({sizingMethod: "scale"});

$(".textwidget dd").each(
	function() {$(this).html('<span><span><span>'+$(this).text()+'</span></span></span>').addClass('rounded');}
);

function fancybox_callbackOnStart() { myCarouselAutoBlock = true;  myCarousel.stopAuto(); }
function fancybox_callbackOnClose() { myCarouselAutoBlock = false; myCarousel.startAuto(); }

function fancybox2_callbackOnStart() {myCarousel2AutoBlock = true;myCarousel2.stopAuto();}
function fancybox2_callbackOnClose() {myCarousel2AutoBlock = false;myCarousel2.startAuto();}

function mycarousel_initCallback(carousel, state) {
	if (state == 'init') {
		myCarousel = carousel;
		if ($('#mycarousel .jcarousel-control').length > 0) {
			myCarouselPages = $('#mycarousel .jcarousel-control').children.length; // [0]
		}
	}
	myCarouselAutoBlock = false;
	$('#mycarousel').hover(
		function() {carousel.stopAuto();}, 
		function() {if ( !myCarouselAutoBlock ) carousel.startAuto();}
	);
	$('#mycarousel .jcarousel-control a').bind('click', function() {
		var scroll_to = 1+(parseInt($(this).text())-1)*3;
		carousel.scroll( scroll_to );
		return false;
	});
} 

function mycarousel2_initCallback(carousel,state) {
	if (state == 'init') myCarousel2 = carousel;
	myCarousel2AutoBlock = false;
	$('#mycarousel2').hover(
		function() {carousel.stopAuto();}, 
		function() {if ( !myCarousel2AutoBlock ) carousel.startAuto();}
	);
} 
	
function mycarousel_itemLoadCallback(carousel,action) {
	var page_no = Math.ceil(1+((carousel.first-1)/3));
	var active_id = '#jcarousel-control-'+page_no;
	$(active_id).siblings('.active').removeClass('active');
	$(active_id).addClass('active');
}

function mycarousel2_itemLoadCallback(carousel,action) {

	var new_center_id = '#mycarousel2 .jcarousel-item-'+(carousel.first+1);
	var new_first_id = '#mycarousel2 .jcarousel-item-'+(carousel.first);
	var new_third_id = '#mycarousel2 .jcarousel-item-'+(carousel.first+2);
	
	if ( typeof mycarousel2_itemLoadCallback.center_id != 'undefined' ) { 
		if ( mycarousel2_itemLoadCallback.center_id != new_center_id ) { 

			$(mycarousel2_itemLoadCallback.first_id).css({zIndex:''});
			$(mycarousel2_itemLoadCallback.third_id).css({zIndex:''});			
			$(mycarousel2_itemLoadCallback.center_id).animate({paddingTop:'10px',marginRight:'2px',marginLeft:'0',width:'61px',height:'108px'}).removeClass('active');

			$(mycarousel2_itemLoadCallback.center_id+' img.frame').animate({width:'51px',height:'37px'});
			$(mycarousel2_itemLoadCallback.center_id+' img.reflection').animate({width:'61px',height:'29px'});
			$(mycarousel2_itemLoadCallback.center_id+' span').animate({width:'61px',height:'29px'});
			
			
			mycarousel2_itemLoadCallback.center_id = new_center_id;
			mycarousel2_itemLoadCallback.first_id = new_first_id;
			mycarousel2_itemLoadCallback.third_id = new_third_id;
			
			$(mycarousel2_itemLoadCallback.first_id).css({zIndex:'5'});
			$(mycarousel2_itemLoadCallback.third_id).css({zIndex:'5'});			
			
			$(mycarousel2_itemLoadCallback.center_id).animate({paddingTop:'0',marginRight:'-12px',marginLeft:'-14px',width:'88px',height:'108px'}).addClass('active');

			$(mycarousel2_itemLoadCallback.center_id+' img.frame').animate({width:'78px',height:'57px'});
			$(mycarousel2_itemLoadCallback.center_id+' img.reflection').animate({width:'88px',height:'41px'});
			$(mycarousel2_itemLoadCallback.center_id+' span').animate({width:'88px',height:'41px'});
			
		}
	}
	else { 
		mycarousel2_itemLoadCallback.center_id = new_center_id;
		mycarousel2_itemLoadCallback.first_id = new_first_id;
		mycarousel2_itemLoadCallback.third_id = new_third_id;
		
		$(mycarousel2_itemLoadCallback.first_id).css({zIndex:'5'});
		$(mycarousel2_itemLoadCallback.third_id).css({zIndex:'5'});
		$(mycarousel2_itemLoadCallback.center_id).addClass('active');
		$(mycarousel2_itemLoadCallback.center_id).css({paddingTop:'0',marginRight:'-12px',marginLeft:'-14px',width:'88px',height:'108px'});
		$(mycarousel2_itemLoadCallback.center_id+' img.frame').css({width:'78px',height:'57px'});
		$(mycarousel2_itemLoadCallback.center_id+' img.reflection').css({width:'88px',height:'41px'});
		$(mycarousel2_itemLoadCallback.center_id+' span').css({width:'88px',height:'41px'});
	}
}

jQuery.fn.extend({ 
	disableSelection : function() { 
		this.each(function() { 
			this.onselectstart = function() { return false; }; 
			this.unselectable = "on"; 
			jQuery(this).css('-moz-user-select', 'none'); 
		}); 
	} 
}); 


$(document).ready(function() {  
	$("#mycarousel ul a").fancybox({
		'zoomOpacity': true,
		'overlayColor':'#000',
		'overlayOpacity':0.66,
		'zoomSpeedIn':500,
		'zoomSpeedOut':500,
		'callbackOnStart':fancybox_callbackOnStart,
		'callbackOnClose':fancybox_callbackOnClose
	}); 
	
	$("#mycarousel2 ul a").not("#noticias #mycarousel2 ul a").fancybox({
		'zoomOpacity': true,
		'zoomSpeedIn':500,
		'zoomSpeedOut':500,
		'overlayColor':'#000',
		'overlayOpacity':0.66,
		'frameWidth':480, 
		'frameHeight':380,
		'callbackOnStart':fancybox2_callbackOnStart,
		'callbackOnClose':fancybox2_callbackOnClose,
		'hideOnContentClick': false
	}); 
	
	jQuery('#mycarousel').jcarousel({
		scroll: 3,
		auto: 3,
		wrap: 'last',
		initCallback: mycarousel_initCallback,
		itemLoadCallback:  mycarousel_itemLoadCallback,
		buttonNextHTML: null,
		buttonPrevHTML: null,
		visible: 3
	});
	
	jQuery('#mycarousel2').jcarousel({
		scroll:1,
		auto:3,
		wrap:'last',
		initCallback:mycarousel2_initCallback,
		itemLoadCallback:{onBeforeAnimation:mycarousel2_itemLoadCallback} 
	}).disableSelection();
	
 
	$("#mycarousel2 ul a").easyTooltip({
		content:'play video', 
		xOffset:-87, 
		yOffset:-3, 
		tooltipId: 'toolip_play_video'
	});
	
	$("#mycarousel2 .jcarousel-prev").easyTooltip({
		content:'previous', 
		xOffset:-80,
		yOffset:-3, 
		tooltipId: 'toolip_prev_video'
	});
	
	$("#mycarousel2 .jcarousel-next").easyTooltip({
		content:'next', 
		xOffset:-15,//10
		yOffset:-20, //-3
		tooltipId: 'toolip_next_video'
	});
}); 

