/**************************************************************************************/
//MOSTRAR PESTAŅAS FICHA SERIE

function showTabFitxa(tab){
	$('.pestanyaScrollContent').animate({"top": 0}, 0);
	
	$("#"+tab).parent().children("li").each(function(index){
		$(this).addClass("off");
	});
	
	$("#"+tab).removeClass("off");
	
	
	$("#"+tab).parent().parent().find(".scrollContent").each(function(index){
		if($(this).hasClass('pestanyaOff')){
			$(this).removeClass("pestanyaOff");
			
			checkTabScroll();
		}
		else{
			$(this).addClass("pestanyaOff");
		}
	});
	
}

/**************************************************************************************/
//SCROLL PESTAŅAS FICHA SERIE

function checkScroll(){
	if($('.pestanyaScrollContent').height() > $('.pestanyaScrollHolder').height()){
		$('.pestanyaScrollDown').bind('click', function(){
			scrollDown($('.pestanyaScrollContent'));
		});
		
		$('.pestanyaScrollUp').bind('click', function(){
			scrollUp($('.pestanyaScrollContent'));
		});
		
		$('.pestanyaScrollButtonsHolder').show();
	}
	else{
		$('.pestanyaScrollButtonsHolder').hide();
	}
}

function checkTabScroll(){
	if($('.pestanyaScrollContent').height() > $('.pestanyaScrollHolder').height()){
		$('.pestanyaScrollButtonsHolder').show();
	}
	else{
		$('.pestanyaScrollButtonsHolder').hide();
	}
}

function scrollDown(element){
	destinoY = element.position().top + element.parent().height();
	
	if(destinoY > 0){
		destinoY = 0;
	}
	
	element.animate({"top": destinoY}, "slow");
}

function scrollUp(element){
	destinoY = element.position().top - element.parent().height();
	
	if(destinoY + element.height() < element.parent().height()){
		destinoY = element.parent().height() - element.height();
	}
	
	element.animate({"top": destinoY}, "slow");
}

/**************************************************************************************/
//TOOLTIP LISTA SERIES

function checkToolTips(){
	
	currentMouseOver = "void";
	
	$('.tooltipS3Link').bind('mouseover', function(){
		
		myFakeId = $(this).position().left + "_" + $(this).position().top;
		
		if(currentMouseOver != myFakeId){
			currentMouseOver = myFakeId;
			//alert('Mostrar');
			
			realXFix = ($("html").width() - $("body").width())/2;
			
			$(this).prepend('<div class="tooltipS3"><h1>' + $(this).find("a").attr("title") + '</h1><div class="img"><a href="' + $(this).find("a").attr("href") + '"><img src="' + $(this).find("img").attr("src") + '" width="100%" height="100%" border="0" /></a></div></div>');
			
			destinoY = $(this).position().top - ($(".tooltipS3").height() - $(this).height())/2;	
			//destinoY = $(this).position().top - $(".tooltipS3").height();	
			destinoX = $(this).position().left + ($(this).width()/2) - ($(".tooltipS3").width()/2) - realXFix;
					
			$(".tooltipS3").css("top",destinoY + 10);
			$(".tooltipS3").css("left",destinoX);
			$(".tooltipS3").css("z-index","999");
			$(".tooltipS3").css("opacity","0");
			
			$(".tooltipS3").animate({opacity: 0.9,top: destinoY}, 250);
			
			
			$('.tooltipS3').bind('mouseout', function(){
				currentMouseOver = "void";
				$(".tooltipS3").remove();
			});
			
		}
		
	});
}


//$(document).ready(function(){
						   
	/**************************************************************************************/
	//REESCRIBIR COMPORTAMIENTO MOUSEOVER BAULA VIDEOS
	/**
	if ($(".columnBaulaDoble").length != 0){
		
		//////////
		
		itemNumber = 0;
		columnNumber = 0;
		jQuery.each($(".item"), function() {
		  itemNumber++;
			
			if(columnNumber == 4){
				$(this).css("margin-right","0px");
				columnNumber = 0;
			}
			if(itemNumber < 4){
				$(this).css("margin-bottom","5px");
			}
			if(itemNumber >= 8){
				itemNumber = 0;
			}
	   });
		
		$(".SSG .prev").css("top","30px");
		$(".SSG .next").css("top","85px");
		
		$(".categoria1 .news_items .container .item").mouseover(
			function(){
				//$(this).find(".desc_fl").css("display", "block");
				titolh2=$(this).find(".desc_fl h2").text();
				if(titolh2!=''&titolh2!=undefined&titolh2!=" "){
					$('#overtit_fl span').text(titolh2);
					$('#overtit_fl').css("display","block");
					$('#overtit_fl').css("position","absolute");
					elem=$(this).get(0);
					twidth=$("#overtit_fl").get(0).clientWidth;
					$('#overtit_fl').css("width","auto");
					if(twidth>270){
						$("#overtit_fl span").css("white-space","normal").css("width","270px");
						if(270+elem.parentNode.offsetLeft+elem.offsetLeft+40>415){
							$("#overtit_fl").addClass("overtit_fl_l").removeClass("overtit_fl_r");
							$('#overtit_fl').css("left",elem.parentNode.parentNode.offsetLeft+elem.offsetLeft-175+"px");
						}else{
							$("#overtit_fl").addClass("overtit_fl_r").removeClass("overtit_fl_l");
							$('#overtit_fl').css("left",elem.parentNode.parentNode.offsetLeft+elem.offsetLeft+40+"px");
						}
					}else{
						if(twidth+elem.parentNode.offsetLeft+elem.offsetLeft+40>415){
							$("#overtit_fl").addClass("overtit_fl_l").removeClass("overtit_fl_r");
							$('#overtit_fl').css("left",elem.parentNode.parentNode.offsetLeft+elem.offsetLeft-twidth+105+"px");
						}else{
							$("#overtit_fl").addClass("overtit_fl_r").removeClass("overtit_fl_l");
							$('#overtit_fl').css("left",elem.parentNode.parentNode.offsetLeft+elem.offsetLeft+40+"px");
						}
						$('#overtit_fl').css("top",elem.parentNode.parentNode.parentNode.parentNode.offsetTop+elem.offsetTop+58+"px");
					}
				}
			}
		);
	}
	else{
		$(".SSG .prev").css("top","26px");
		$(".SSG .next").css("top","26px");
	}

});
*/
