
var numFrases;
var fraseActual=1;
$(document).ready(function() {
 	numFrases = $(".farseHoreca").length;
  	if(numFrases>1){
		setInterval('canviFrase()', 4000);	
	}
	$('.sharePopUp').click(function(event) {
		event.preventDefault();
		var url = $(this).attr('href');
		//alert(url);
	  	//startPopUp(url, 600,400,true);
		window.open(url, "Compartir", 'width=600,height=400,toolbar=0,resizable=1,scrollbars=yes,location=no');
	});
	$('.linkLegal').click(function(event) {
		event.preventDefault();
		var url = $(this).attr('href');
		//alert(url);
	  	//startPopUp(url, 600,400,true);
		window.open(url, "Legal", 'width=400,height=600,toolbar=0,resizable=1,scrollbars=yes,location=no');
	});
});



function newsletter(){
		startPopUp('popUp-newsletter.php', 370, 530, true);
}
	
function cambioPonente(element){
	document.location.href = "brand-activation-space.html?"+element.value;	
}

function ampliarTexto(){
	$(".reduce").fadeTo(1, 1);	
	var mida = $(".text p").css("font-size");	
	if(mida.slice(-2)=="px"){
		mida=mida.slice(0, mida.length-2);	
	}
	if(mida<18){
		mida++;
		$(".text p").css("font-size", mida+"px");
	}else{
		$(".zoom").fadeTo(1, 0.4);
	}
}

function reducirTexto(){
	$(".zoom").fadeTo(1, 1);	
	var mida = $(".text p").css("font-size");	
	if(mida.slice(-2)=="px"){
		mida=mida.slice(0, mida.length-2);	
	}
	if(mida>8){
		mida--;
		$(".text p").css("font-size", mida+"px");
	}else{
		$(".reduce").fadeTo(1, 0.4);	
	}
}

function showPrint(id){
	startPopUp('popUp-ponencia.php?id='+id, 700, 500, true);
}


function canviFrase(){
	$("#frase"+fraseActual).fadeTo(300, 0, function(){
		$("#frase"+fraseActual).hide();
		fraseActual++;
		if(fraseActual>numFrases	){ fraseActual=1; }
		$("#frase"+fraseActual).fadeTo(300, 1); 
	});
}


function compartirEmail(url){
	startPopUp('popUp-email.php?url='+url, 370, 470, true);
}
function enviarCV(id){
	startPopUp('popUp-trabaja.php?id='+id, 370, 470, true);
}
function verContacto(){
	startPopUp('popUp-contacto.php', 575, 500, true);
}


var quantesFotos=0;
var fotoActual=0;
function iniciarFotos(quantes){
	$("#fletxaLeft").fadeTo(1,0.4);
	quantesFotos = quantes;
}

function moveFotoRight(){
	if(fotoActual<quantesFotos-1){
		$("#fletxaLeft").fadeTo(1,1);
		fotoActual++;
		left=-fotoActual*380;
		$("#fotos").stop().animate({"left": left },{duration:500, easing:"easeOutExpo"});
		if(fotoActual==quantesFotos-1){
			$("#fletxaRight").fadeTo(1,0.4);
		}
	}
}
function moveFotoLeft(){
	if(fotoActual>0){
		$("#fletxaRight").fadeTo(1,1);
		fotoActual--;
		left=-fotoActual*380;
		$("#fotos").stop().animate({"left": left },{duration:500, easing:"easeOutExpo"});
		if(fotoActual==0){
			$("#fletxaLeft").fadeTo(1,0.4);
		}
	}
}

function showVideo(){
	$("#fotoBtn").html('<a href="javascript:showFotos();">FOTOS</a>');
	$("#flashBtn").html('<a href="javascript:showFlash();">FLASH</a>');
	$("#videoBtn").html('<span>VÍDEO</span>');
	
	$("#fotoGallery").hide();
	$("#flashGallery").hide();
	$("#videoGallery").show();
}
function showFotos(){
	$("#videoBtn").html('<a href="javascript:showVideo();">VÍDEO</a>');
	$("#flashBtn").html('<a href="javascript:showFlash();">FLASH</a>');
	$("#fotoBtn").html('<span>FOTOS</span>');
	
	$("#fotoGallery").show();
	$("#flashGallery").hide();
	$("#videoGallery").hide();
}

function showFlash(){
	$("#videoBtn").html('<a href="javascript:showVideo();">VÍDEO</a>');
	$("#fotoBtn").html('<a href="javascript:showFotos();">FOTOS</a>');
	$("#flashBtn").html('<span>FLASH</span>');
	
	$("#fotoGallery").hide();
	$("#flashGallery").show();
	$("#videoGallery").hide();
}
function showPrintNew(id){
	startPopUp('popUp-new.php?id='+id, 700, 500, true);
}

function inBuscar(quin){
	if(quin.value=='Buscar'){
		quin.value="";	
	}
}
function foraBuscar(quin){
	if(quin.value==''){
		quin.value="Buscar";	
	}
}
