$(document).ready(function(){

	/* Tooltip */
	$(".dialeg img").each(function(){
			var element=$(this);
			$(this).tooltip({
				tip:'#tooltip',
				effect: 'fade',
				direction: "down",
				delay: 300,
				position: 'top center',
				onBeforeShow: function(){
					$('#tooltip').html("<div class='ins'><p class='cont'>"+$(element).data("title")+"</p></div>");
					if ($.browser.msie && $.browser.version <= 7) {
						$('#tooltip').css('width','200px');
					}
					else {
						$('#tooltip').css('width','auto');
						if ($('#tooltip').width()>200) {
							$('#tooltip').css('width','200px');
							$('#tooltip p.cont').css('text-align','left');
						} else {
							$('#tooltip').css('width','auto');
						}
					}
				}
			});
		});

	/* Mostrar text en un input tipus password */
	$(".input").focusin(function() {
		$(this).css('background',$(this).parent().css('background-color'));
		$(this).focus();
	}).focusout(function(){
		if ($(this).val()=='') {
			$(this).css('background','transparent');
		}
	});

	/* Fake per explorer */
	$(".input span").click(function(){
		$("input",$(this)).focusin();
	});

	//sempre al carregar han d'estar biuts */
	$("#dalt .input").val('');


		$("#areas li, #mes li").not('.actiu').mouseenter(function(){
		  $(this).animate({opacity:0.7}, 100);
		}).mouseleave(function(){
			$(this).animate({opacity:1},100);
		});

		$("#apartats li").not('.actiu').mouseenter(function(){
		  $(this).animate({opacity:0.7}, 100);
		}).mouseleave(function(){
			$(this).animate({opacity:1},100);
		});


	$("a.gal").fancybox({
		'speedIn'		:	600,
		'speedOut'		:	200,
		'padding'	: 10,
		'margin'	:0,
		'hideOnOverlay':true,
		'overlayShow'	:	true,
		/*'centerOnScroll':true,*/
		'overlayOpacity'	:	0.3,
		'titlePosition' : 'over'
	});

	$("a.video").fancybox({
		'hideOnContentClick': false,
		'width':560,
		'height':330,
		'padding':1,
		'overlayShow':true
	});

	$(".plegable .titol2 a").click(function(){
		if ($(this).parents(".plegable").hasClass('desplegat')) {
			$(this).parents(".plegable").find('ul').slideUp()
			$(this).parents(".plegable").removeClass('desplegat');
		}else {
			$(this).parents(".plegable").find('ul').slideDown()
			$(this).parents(".plegable").addClass('desplegat');
		}

	});
});


