// JavaScript Document
$(document).ready(function()
	{
	$('#carregant').css({'width':$(this).width()+'px'});
	$('#carregant').css({'height':$(this).height()+'px'});
	$('#carregant').css({'opacity':'0.8'});
	$('#carregant_texte').css({'margin':'auto'});
	$('#carregant').fadeIn(500);
	
	// Scroll Contingut
	$('a[href*=#]').click(function() 
		{
		if(location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) 
			{
			var $target = $(this.hash);
			$target = $target.length && $target || $('[name=' + this.hash.slice(1) +']');
			if($target.length) 
				{
				var targetOffset = $target.offset().top;
				$('html,body').animate({scrollTop: targetOffset}, 1000);
				return false;
				}
			}
		});
	
	$('img').click(function() 
		{
		var id = $(this).attr("id");
		var avatar_type = id.substr(0, 35);
		var argento_type = id.substr(0, 42);
	
		if(avatar_type == 'mueble-juvenil-avatar-ambiente-foto') zoom(id, 'avatar');
		if(argento_type == 'armarios-dormitorios-argento-ambiente-foto') zoom(id, 'argento');
		});
	
	$('#fondo_negro').click(function()
		{
		$('#visor').fadeOut("slow");
		$('#fondo_negro').fadeOut("slow");
		$('#imatge').attr("src", "imatges/load.gif");
		});
	
	$('#close').click(function()
		{
		$('#visor').fadeOut("slow");
		$('#fondo_negro').fadeOut("slow");
		$('#imatge').attr("src", "imatges/pixel_blanc.jpg");
		});
	
	// Reubicar Imatges al Inici
	reubicarImatgesInici();
	
	// Menu Avatar
	$('#avatar-link').click(function()
		{
		$('#avatar-menu-1').slideDown("slow");
		$('#avatar-menu-2').slideDown("slow");
		$('#avatar-menu-3').slideDown("slow");
		$('#avatar-menu-4').slideDown("slow");
		return false;
		});
	
	$('#menu a').not('#avatar-link').not('#avatar-menu a').click(function()
		{
		$('#avatar-menu-1').slideUp("slow");
		$('#avatar-menu-2').slideUp("slow");
		$('#avatar-menu-3').slideUp("slow");
		$('#avatar-menu-4').slideUp("slow");
		return false;
		});
	
	// Menu Argento
	$('#argento-link').click(function()
		{
		$('#argento-menu-1').slideDown("slow");
		$('#argento-menu-2').slideDown("slow");
		$('#argento-menu-3').slideDown("slow");
		$('#argento-menu-4').slideDown("slow");
		return false;
		});
	
	$('#menu a').not('#argento-link').not('#argento-menu a').click(function()
		{
		$('#argento-menu-1').slideUp("slow");
		$('#argento-menu-2').slideUp("slow");
		$('#argento-menu-3').slideUp("slow");
		$('#argento-menu-4').slideUp("slow");
		return false;
		});
	
	$('#idiomes img').click(function()
		{
		var id = $(this).attr("id");
		canvi_idioma(id);
		});
	
	$(window).bind("load", function()
		{ 
	    lliberar();
		canvi_idioma('es');
		});
	
	$('.check').click(function()
		{
		if($(this).html() == "X")
			{
			$(this).html("");
			$(this).parent().find(":checkbox").removeAttr("checked");
			}
		else
			{
			$(this).html("X");
			$(this).parent().find(":checkbox").attr("checked","checked");
			}
		});
	
	$('.radio-1').click(function()
		{
		$(this).parent().find(":radio").attr("checked","checked");
		$('td#radio-list-1 li div').html("");
		$(this).html("O");
		$('.radio-1').dropShadow({left: 2, top: 2, opacity: 0.8, blur: 1});
		});
	
	$('.radio-2').click(function()
		{
		$(this).parent().find(":radio").attr("checked","checked");
		$('td#radio-list-2 li div').html("");
		$(this).html("O");
		$('.radio-2').dropShadow({left: 2, top: 2, opacity: 0.8, blur: 1});
		});
	
	$('#enviar').click(function()
		{
		mail();
		$('#enviar').css({'display':'none'});
		$("#enviar").removeShadow();
		});
	
	$('#mail-container-tancar').click(function()
		{
		$('#mail-container').fadeOut(500);	
		$('#enviar').css({'display':'inherit'});
		$("#enviar").dropShadow({left: 2, top: 2, opacity: 0.8, blur: 1});
		});
	
	$('#bombilla').click(function()
		{
		$('#colors').fadeIn(500);
		});
	
	$('#tancar_colors').click(function()
		{
		$('#colors').fadeOut(500);
		});
	
	$('#aviso_legal_link').click(function()
		{
		$('#aviso_legal').fadeIn(500);
		});
	
	$('#aviso_legal_tancar').click(function()
		{
		$('#aviso_legal').fadeOut(500);
		});
	
	$('#descargas').click(function()
		{
		$('#descargas_cuadro').fadeIn(500);	
		});
	
	$('#descargas_tancar').click(function()
		{
		$('#descargas_cuadro').fadeOut(500);
		});
	
	$('.texto-sombra').dropShadow({left: 2, top: 2, opacity: 0.8, blur: 1});
	$('.texto-sombra-blanca').dropShadow({left: 2, top: 2, opacity: 0.8, blur: 1, color: "white"});
	$('.check').dropShadow({left: 2, top: 2, opacity: 0.8, blur: 1});
	$('.radio-1').dropShadow({left: 2, top: 2, opacity: 0.8, blur: 1});
	$('.radio-2').dropShadow({left: 2, top: 2, opacity: 0.8, blur: 1});
	$(".input_text_contacte").dropShadow({left: 2, top: 2, opacity: 0.8, blur: 1});
	$("#enviar").dropShadow({left: 2, top: 2, opacity: 0.8, blur: 1});
	});