// JavaScript Document
var WROOT;

function init(){
	sombraResize();
	if($.browser.msie){
		if(parseInt($.browser.version) < 8){
			$(".IE").slideDown(400);
		}else{$(".IE").remove();}
		$("#site_content").show();
	}
	else{$(".IE").remove();$("#site_content").fadeIn();}
	//Menu principal
	$("#site_MainMenu .submenu").parent().hover(
		function(){
			$(".submenu",this).stop(true, true).slideDown(200);		
		},function(){
			if($.browser.msie){$(".submenu",this).stop(true, true).hide();}
			else{$(".submenu",this).stop(true, true).fadeOut(200);}			
		});
	$("#site_MainMenu ul > li").hover(
			function(){
				if($.browser.msie){$('.focus',this).stop(true,true).show()}
				else{$('.focus',this).stop(true,true).fadeIn(150);}
				
			},function(){
				if($.browser.msie){$('.focus',this).stop(true,true).hide();}
				else{$('.focus',this).stop(true,true).fadeOut(400);}
	});
		
	if($(".promotorsPlati").length){
		$(".promotorsPlati .prpl:first").addClass("active").fadeIn(200);
		setInterval("slidePromotors();",5000);	
	}
	changeBackgroundHeader();
	setInterval('changeBackgroundHeader()',10000);
}

function changeBackgroundHeader(){
	var tmpNum = 0;
	while(tmpNum < 1){tmpNum = Math.round(Math.random()*29);}
	$("#site_header").css("background","#000 url("+WROOT+"img/headers/"+tmpNum+".jpg)");
}

function slidePromotors(){
	$(".promotorsPlati .prpl.active").fadeOut(400,function(){
		$(this).removeClass("active");
		if($(this).next().children("a").length){
			$(this).next().addClass("active").fadeIn(250);
		}else{$(".promotorsPlati .prpl:first").addClass("active").fadeIn(250);}
	});
	
}

function sombraResize(){
	$("#site_content_rShadow").height(parseInt($("#site_contentDiv").height())+222);
}

function fbs_click() {
	var u=location.href;
	var t=document.title;
	window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(u)+'&t='+encodeURIComponent(t),'sharer','toolbar=0,status=0,width=626,height=436');
	return false;
}

function initTemporadaEstable(){
	$(".temporadaLlistaResum tr:odd").addClass("fondo")	
}

function temporadaVeureResum(){
	$(".temporadaLlista").fadeOut(150,function(){
		sombraResize();
		$(".temporadaLlistaResum").fadeIn(100);
	});
	$(".resum").hide();
	$(".resum2").show();
	
}
function temporadaVeureNormal(){
	$(".temporadaLlistaResum").fadeOut(150,function(){
		setTimeout("sombraResize()",50);
		$(".temporadaLlista").fadeIn(100);
	});
	$(".resum2").hide();
	$(".resum").show();	
	
}
function verificarLogin(){
	var user = $("#usuari");	
	var pass = $("#pass");
	
	if(user.length < 4){return false;}
	else if(pass.lengt < 4){return false;}
	else {return true;}
}

function onYouTubePlayerReady(playerId) {
		$("#myytplayer")[0].addEventListener("onStateChange", "onytplayerStateChange");
	}
function onytplayerStateChange(newState) {
	if(newState == "0"){ window.location = WROOT+'?home';}
}

function activarHD(){
	$('#vhd').hide();
	$('#vdf').show();
	$('#myytplayer')[0].setPlaybackQuality('hd720')
}

function desactivarHD(){
	$('#vdf').hide();
	$('#vhd').show();		
	$('#myytplayer')[0].setPlaybackQuality('medium')
}
