// JavaScript Document
/** Background-Position Animations
 * @author Alexander Farkas
 * v. 1.02
 */
(function($) {
	$.extend($.fx.step,{
	    backgroundPosition: function(fx) {
            if (fx.state === 0 && typeof fx.end == 'string') {
                var start = $.curCSS(fx.elem,'backgroundPosition');
                start = toArray(start);
                fx.start = [start[0],start[2]];
                var end = toArray(fx.end);
                fx.end = [end[0],end[2]];
                fx.unit = [end[1],end[3]];
			}
            var nowPosX = [];
            nowPosX[0] = ((fx.end[0] - fx.start[0]) * fx.pos) + fx.start[0] + fx.unit[0];
            nowPosX[1] = ((fx.end[1] - fx.start[1]) * fx.pos) + fx.start[1] + fx.unit[1];           
            fx.elem.style.backgroundPosition = nowPosX[0]+' '+nowPosX[1];
            
           function toArray(strg){
               strg = strg.replace(/left|top/g,'0px');
               strg = strg.replace(/right|bottom/g,'100%');
               strg = strg.replace(/([0-9\.]+)(\s|\)|$)/g,"$1px$2");
               var res = strg.match(/(-?[0-9\.]+)(px|\%|em|pt)\s(-?[0-9\.]+)(px|\%|em|pt)/);
               return [parseFloat(res[1],10),res[2],parseFloat(res[3],10),res[4]];
           }
        }
	});
})(jQuery);

// Delay Plugin for jQuery
// - http://www.evanbot.com
// - © 2008 Evan Byrne

jQuery.fn.delay = function(time,func){
	this.each(function(){
		setTimeout(func,time);
	});
	
	return this;
};

//--Funcion apoyo a abrir enlaces 4 nivel --- function img_4level(item3menu)
function apoyo_img_4level(nombre_item_apoyo, img_totales_apoyo, leyenda_apoyo)
{
	var nombre_item=nombre_item_apoyo;
	$('.box_img_internas').replaceWith("<div id='visor_img_2' class='box_img_internas'><div id='selector_imagenes'><span id='select_img_prev' class='flechas' onclick='cambia_imagen("+nombre_item_apoyo+", "+img_totales_apoyo+", -1);'><img src='img/img_carrousel_prev.png' width='23' height='24' /></span><span id='txt_img' style='margin-bottom:0'>1 / "+img_totales_apoyo+"</span><span id='select_img_next' class='flechas' onclick='cambia_imagen("+nombre_item_apoyo+", "+img_totales_apoyo+", 1);'><img src='img/img_carrousel_next.png' width='23' height='24' /></span></div></div>");
	var nueva_img="url(img/"+nombre_item_apoyo+"_1.jpg)";
	var segunda_img="url(img/"+nombre_item_apoyo+"_2.jpg)";
	$('#img_segundo_plano').css('background-image',nueva_img);
	$('#img_segundo_plano').css('background-image',segunda_img);
	$('#visor_img_2').css({opacity:"0"});
	$('#visor_img_2').css('background-image',nueva_img);					
	$('#visor_img_2').animate({opacity:"1"}, 1500);
	top_leyenda(leyenda_apoyo);
	imagen_actual=1;//Se inicializa la vble globalmente
	
	$('#box_detalle').css({marginRight:"-210px"});
}
//--Fin Funcion apoyo a abrir enlaces 4 nivel --- function img_4level(item3menu)
//-----------------------------function ESCONDER MENUS
function esconder_menus()
{//desactivo el click en el boton de inicio

		$('#bot_open_menu').css({opacity:'0',left:'-25px'});
		esconder_menus_shw();
		

}
function esconder_menus_shw()
{//desactivo el click en el boton de inicio

		//$('#bot_open_menu').css({opacity:'0',left:'-25px'});
		//Fin desactivacion bot inicio
		$('#menu01').stop().animate({left:"-200px"}, {duration:1000});
		$('#box_menus div.menu_nivel_2').animate({opacity:"0", width:"0"},{duration:500, complete:function()
			{
				//Animacion BG de los enlaces
				$('#box_menus a')
					.css( {backgroundPosition: "-150px 0"} )
					.mouseover(function()
						{
							$(this).stop().animate({backgroundPosition:"(-40px 0)"}, {duration:600})
						})
					.mouseout(function()
						{
							$(this).stop().animate({backgroundPosition:"(-150px 0)"}, {duration:400, complete:function()
								{
									$(this).css({backgroundPosition: "-150px 0"});
								}});
						
						});//Fin animac fondo enlaces
				
				//Y restauro el nivel2
				$('#box_menus div.menu_nivel_2').css({left:"-400px", opacity:"1"});
				//Fin restauracion nivel2
			
				var posicion_menu01=$('#menu01').position();
				if(posicion_menu01.left<=-130)//Controlo q el menu01 se haya escondido para mostrar el bot_open
				{	
					$('#bot_open_menu').animate({opacity:"0.8", left:"0"}, 150, "easeOutQuart");
				}else{
					//Si el menu01 no se ha escondido, no se muestra el bot_open
					$('#bot_open_menu').css({opacity:'0',left:'-25px'});
				}
			}});	
		
		//Y para los niveles 3

		$('#box_menus div.menu_nivel_3').animate({opacity:"0", width:"0"},{duration:500, complete:function()
			{
				//Animacion BG de los enlaces
				$('#box_menus a')
					.css( {backgroundPosition: "-150px 0"} )
					.mouseover(function()
					{
						$(this).stop().animate({backgroundPosition:"(-40px 0)"}, {duration:600})
					})
					.mouseout(function()
					{
						$(this).stop().animate({backgroundPosition:"(-150px 0)"}, {duration:400, complete:function()
						{
							$(this).css({backgroundPosition: "-150px 0"});
						}});
						
					});//Fin animac fondo enlaces
				//Restauramos el nivel 3, una vez ya se ha escondido
				$('#box_menus div.menu_nivel_3').css({left:"-400px", opacity:"1"});
				/////_____________REVISAR!!!!!!!!!!!!!!!! PArece que esto no esta haciendo nada
				
			}});

		$('#img_segundo_plano').focus();//Es para enviar el focus al div invisible

}
//---------------------------------------------------------------------------------------fin func esconder menus

//--Funcion showrooms 
function showrooms(nombre_item_apoyo, img_totales_apoyo, leyenda_apoyo)
{
	var nombre_item=nombre_item_apoyo;
	$('.box_img_internas').replaceWith("<div id='visor_img_2' class='box_img_internas'><div id='selector_imagenes'><span id='select_img_prev' class='flechas' onclick='cambia_imagen_showroom("+nombre_item_apoyo+", "+img_totales_apoyo+", -1);'><img src='img/img_carrousel_prev.png' width='23' height='24' /></span><span id='txt_img' style='margin-bottom:0'>1 / "+img_totales_apoyo+"</span><span id='select_img_next' class='flechas' onclick='cambia_imagen_showroom("+nombre_item_apoyo+", "+img_totales_apoyo+", 1);'><img src='img/img_carrousel_next.png' width='23' height='24' /></span></div></div>");
	
	var nueva_img="url(img/"+nombre_item_apoyo+"_1.jpg)";
	var segunda_img="url(img/"+nombre_item_apoyo+"_2.jpg)";
	$('#img_segundo_plano').css('background-image',nueva_img);
	$('#img_segundo_plano').css('background-image',segunda_img);
	$('#visor_img_2').css({opacity:"0"});
	$('#visor_img_2').css('background-image',nueva_img);	
	$('#visor_img_2').animate({opacity:"1"}, 1500);
	top_leyenda(leyenda_apoyo);
		
	imagen_actual=1;//Se inicializa la vble globalmente
}
//--Fin Funcion showrooms 

//--Funcion showrooms2 
function showrooms_2(nombre_item_apoyo, img_totales_apoyo, leyenda_apoyo)
{
	var nombre_item=nombre_item_apoyo;
	//$('.box_img_internas').replaceWith("<div id='visor_img_2' class='box_img_internas'><div id='selector_imagenes'><span id='select_img_prev' class='flechas' onclick='cambia_imagen_showroom("+nombre_item_apoyo+", "+img_totales_apoyo+", -1);'><img src='img/img_carrousel_prev.png' width='23' height='24' /></span><span id='txt_img' style='margin-bottom:0'>1 / "+img_totales_apoyo+"</span><span id='select_img_next' class='flechas' onclick='cambia_imagen_showroom("+nombre_item_apoyo+", "+img_totales_apoyo+", 1);'><img src='img/img_carrousel_next.png' width='23' height='24' /></span></div></div>");
	$('.box_img_internas').replaceWith("<div id='visor_img_2' class='box_img_internas'></div>");
	var nueva_img="url(img/"+nombre_item_apoyo+"_1.jpg)";
	//var segunda_img="url(img/"+nombre_item_apoyo+"_2.jpg)";
	//$('#img_segundo_plano').css('background-image',nueva_img);
	//$('#img_segundo_plano').css('background-image',segunda_img);
	$('#visor_img_2').css({opacity:"0"});
	$('#visor_img_2').css('background-image',nueva_img);					
	$('#visor_img_2').animate({opacity:"1"}, 1500);
	top_leyenda(leyenda_apoyo);
	imagen_actual=1;//Se inicializa la vble globalmente
}
//--Fin Funcion showrooms2 

//-----------------------Cargando las imagenes de las tiendas
function carga_img_tienda_consecutivas(nombre_imgs, num_images_tienda,t){
	if(t<=num_images_tienda)
		{
			t++;
			var nombre_imagen="img/"+nombre_imgs+"_"+t+".jpg";
			$('#img_segundo_plano').load(nombre_imagen, function()
			{
				carga_img_tienda_consecutivas(nombre_imgs, num_images_tienda,t);
			});
		}
	
}
	

function carga_img_tienda(nombre_imgs, num_images_tienda){
	var t=1;
	var nombre_imagen="img/"+nombre_imgs+"_"+t+".jpg";
	$('#img_segundo_plano').load(nombre_imagen, function()
	{
		carga_img_tienda_consecutivas(nombre_imgs, num_images_tienda,1);
	});
}

//----------------------- FIN Cargando las imagenes de las tiendas



//--------------------------------Funcion Abrir y cerrar Box derecha

function iniciar_box_dcha_tienda_start(tienda)
{
	$('.box_img_internas').replaceWith("<div id='visor_img_2' class='box_img_internas'></div>");
	var nueva_img="url(img/"+tienda+"_shw_1.jpg)";
	$('#visor_img_2').css({width:"710px"});
	$('#visor_img_2').css({float:"left"});
	$('#visor_img_2').css({opacity:"0"});
	$('#visor_img_2').css('background-image',nueva_img);
	$('#visor_img_2').animate({opacity:"1"}, 1500);
}
function hover_botones_tiendas(tienda_num)
{
	//if(bot_tienda!=0){
		$('#botones_tiendas a').css({backgroundPosition: '0 0'});
		$('#bot_tienda_'+tienda_num).css({backgroundPosition: '0 -62px'});
		bot_tienda=tienda_num;
		for(var k=1;k<5;k++)
		{
			if(bot_tienda!=k)
			{
				$('#bot_tienda_'+k).hover(
					function(){
				  	$(this).css({backgroundPosition:"0 -62px"});
				  },
					function(){				
				 	 $(this).css({backgroundPosition:"0 0"});
				  });
			}else{
				$('#bot_tienda_'+k).hover(
					function(){
				  	$(this).css({backgroundPosition:"0 -62px"});
				  },
					function(){				
				  	$(this).css({backgroundPosition:"0 -62px"});
				  });
			}
		}
	//}
	bot_tienda=0;
		
}

function iniciar_box_dcha_tienda(tienda)
{
	$('#box_open_detalle').remove();
	esconder_menus_shw();

	if(tienda=="molteni")//---------------SI MOLTENI
	{

		$('#top_left_leyenda').html('');
		datos="<p>Calle de Castell&oacute;, 7- 28001 <strong>Madrid</strong></p><p>Tel: 91 575 74 05 - Fax: 91 576 84 35</p><p>email: <a href='mailto:molteni@conceptodr.com' class='link_gris'>molteni@conceptodr.com</a><br/>web: <a href='http://www.molteni.it' target='_blank' class='link_gris'>www.molteni.it</a></p><ul id='iconos_tienda'><li class='iconos_1'><div class='leyenda_icono_tienda'>estudio</div></li><li class='iconos'>+</li><li class='iconos_2'><div class='leyenda_icono_tienda'>tienda</div></li><li class='iconos'>+</li><li class='iconos_3'><div class='leyenda_icono_tienda'>showroom</div></li></ul><div class='clear'></div>";
		hover_botones_tiendas(4);		
	
 		if( $('#datos_tienda').attr('id') != 'datos_tienda' )//Si no exite todavia el elemento en DOM
		{
			$("#botones_tiendas").after("<div id='datos_tienda'>"+datos+"</div>");
		}else{
			$('#datos_tienda').html(datos);
		}
		
		$('#box_detalle').animate({marginRight:"0"}, 800, "swing", function()
		{
			iniciar_box_dcha_tienda_start(tienda);
			//Marco enlace como vble para actual_mapa()
			enlace_html_mapa_tienda="http://maps.google.es/maps/ms?ie=UTF8&hl=es&msa=0&ll=40.423126,-3.681858&spn=0.005407,0.009645&z=17&msid=114758129774169013132.00047416cb4b4f672df17";
			html_mapa_tienda="<div id='ver_mapa_tienda'><a href='"+enlace_html_mapa_tienda+"' rel='gmap' target='_blank'><img src='img/icon_ver_mapa_tienda.png'/></a><a href='"+enlace_html_mapa_tienda+"' class='ver_mapa' rel='gmap' target='_blank'>ver mapa</a></div>";
			
			var datos_txt_tienda=html_mapa_tienda+"<p id='msg_0'>&quot;La casa alberga un d&iacute;a so&ntilde;ando, la casa protege el so&ntilde;ador, la casa le permite a uno so&ntilde;ar en paz&quot;</p><p class='cita'>&nbsp;<br/><i>&nbsp;</i></p><p class='ver_show'><span id='txt_ver_show'>ver showroom</span> <img src='img/ver_showroom.gif'/></p>";
			if( $('#txt_tienda').attr('id') != 'txt_tienda' )//Si no exite todavia el elemento en DOM
			{
				$('#box_detalle').append("<div id='txt_tienda'>"+datos_txt_tienda+"</div>");
			}else{
				$('#txt_tienda').html(datos_txt_tienda);//Importante, es para no ir añadiendo elementos al DOM, una vez esten ya cargados, solo hay q sustituir el contenido
			}
					
				
				$('#txt_tienda').css({opacity:'0'});
				$('#txt_tienda').animate({opacity:"0.8"}, 800);
				$('.ver_show').hover(function ()
				{
					$(this).css({cursor:"pointer"}); 
					$('#txt_ver_show').addClass('ver_show_underline');
				}, //hover (over,out)
							function () {
							$('#txt_ver_show').removeClass('ver_show_underline');
							}
			
				);
				$('.ver_show').click(function ()
				{					
					$(this).delay(400, function()
					{
						tienda="'molteni'";
						
						
						
						
						mapa_de_imagen="<map name='mapa_molteni' id='mapa_molteni'><area shape='circle' coords='248,91,8' href='#' onclick=\"actual_mapa(1,'molteni','"+enlace_html_mapa_tienda+"');\"/><area shape='circle' coords='140,93,7' href='#' onclick=\"actual_mapa(2,'molteni','"+enlace_html_mapa_tienda+"');\"/><area shape='circle' coords='102,91,6' href='#' onclick=\"actual_mapa(3,'molteni',''+enlace_html_mapa_tienda+'');\"/><area shape='circle' coords='94,52,6' href='#' onclick=\"actual_mapa(4,'molteni',''+enlace_html_mapa_tienda+'');\"/><area shape='circle' coords='53,70,7' href='#' onclick=\"actual_mapa(5,'molteni',''+enlace_html_mapa_tienda+'');\"/><area shape='circle' coords='40,48,7' href='#' onclick=\"actual_mapa(6,'molteni',''+enlace_html_mapa_tienda+'');\"/><area shape='circle' coords='53,33,6' href='#' onclick=\"actual_mapa(7,'molteni',''+enlace_html_mapa_tienda+'');\"/><area shape='circle' coords='22,40,6' href='#' onclick=\"actual_mapa(8,'molteni',''+enlace_html_mapa_tienda+'');\"/><area shape='circle' coords='24,74,6' href='#' onclick=\"actual_mapa(9,'molteni',''+enlace_html_mapa_tienda+'');\"/></map>";
						$('#txt_tienda').html(html_mapa_tienda+"<p id='titol_mapa'>Showroom</p><img src='img/plano_molteni_1.png' alt='' width='270' height='111' border='0' usemap='#mapa_molteni' class='img_plano'/>"+mapa_de_imagen);
						

						top_leyenda('Molteni Showroom');


						$('#img_segundo_plano').focus();

					});
				});
		});
	}
	
	if(tienda=="dada")//---------------SI DADA
	{
		$('#top_left_leyenda').html('');
		datos="<p>Calle de Castell&oacute;, 8 - 28001 <strong>Madrid</strong></p><p>Tel: 91 578 36 06 - 91 577 48 44</p><p>email: <a href='mailto:dada@conceptodr.com' class='link_gris'>dada@conceptodr.com</a><br/>web: <a href='http://www.dadaweb.it' target='_blank' class='link_gris'>www.dadaweb.it</a></p><ul id='iconos_tienda'><li class='iconos_1'><div class='leyenda_icono_tienda'>estudio</div></li><li class='iconos'>+</li><li class='iconos_2'><div class='leyenda_icono_tienda'>tienda</div></li><li class='iconos'>+</li><li class='iconos_3'><div class='leyenda_icono_tienda'>showroom</div></li></ul><div class='clear'></div>";
		hover_botones_tiendas(2);
		
 		if( $('#datos_tienda').attr('id') != 'datos_tienda' )//Si no exite todavia el elemento en DOM
		{
			$("#botones_tiendas").after("<div id='datos_tienda'>"+datos+"</div>");
		}else{
			$('#datos_tienda').html(datos);
		}
		
		
		
		$('#box_detalle').animate({marginRight:"0"}, 800, "swing", function()
		{
			iniciar_box_dcha_tienda_start(tienda);
			//marco el enlace como vble para pasarlo a actual_mapa()
			enlace_html_mapa_tienda="http://maps.google.es/maps/ms?ie=UTF8&hl=es&msa=0&msid=114758129774169013132.00047416b926b2f2d3728&ll=40.423094,-3.681654&spn=0.005407,0.009645&z=17";
			html_mapa_tienda="<div id='ver_mapa_tienda'><a href='"+enlace_html_mapa_tienda+"' rel='gmap' target='_blank'><img src='img/icon_ver_mapa_tienda.png'/></a><a href='"+enlace_html_mapa_tienda+"' class='ver_mapa' rel='gmap' target='_blank'>ver mapa</a></div>";
			var datos_txt_tienda=html_mapa_tienda+"<p id='msg_0'>&quot;Amo la casa en la cual no veo nada superfluo y dispongo de todo lo necesario&quot;</p><p class='cita'>&nbsp;<br/><i>&nbsp;</i></p><p class='ver_show'><span id='txt_ver_show'>ver showroom</span> <img src='img/ver_showroom.gif'/></p>";
			if( $('#txt_tienda').attr('id') != 'txt_tienda' )//Si no exite todavia el elemento en DOM
			{
				$('#box_detalle').append("<div id='txt_tienda'>"+datos_txt_tienda+"</div>");
			}else{
				$('#txt_tienda').html(datos_txt_tienda);//Importante, es para no ir añadiendo elementos al DOM, una vez esten ya cargados, solo hay q sustituir el contenido
			}
					
				
				$('#txt_tienda').css({opacity:'0'});
				$('#txt_tienda').animate({opacity:"0.8"}, 800);
				$('.ver_show').hover(function ()
				{
					$(this).css({cursor:"pointer"}); 
					$('#txt_ver_show').addClass('ver_show_underline');
				}, //hover (over,out)
							function () {
							$('#txt_ver_show').removeClass('ver_show_underline');
							}

				
				);
				$('.ver_show').click(function ()
				{					
					$(this).delay(400, function()
					{
						tienda="'dada'";
						mapa_de_imagen="<map name='mapa_dada' id='mapa_dada'><area shape='circle' coords='254,56,9' href='#' onclick=\"actual_mapa(1,'dada','"+enlace_html_mapa_tienda+"');\"/><area shape='circle' coords='233,31,5' href='#' onclick=\"actual_mapa(2,'dada','"+enlace_html_mapa_tienda+"');\"/><area shape='circle' coords='186,31,5' href='#' onclick=\"actual_mapa(3,'dada','"+enlace_html_mapa_tienda+"');\"/><area shape='circle' coords='118,34,5' href='#' onclick=\"actual_mapa(4,'dada','"+enlace_html_mapa_tienda+"');\"/><area shape='circle' coords='121,49,5' href='#' onclick=\"actual_mapa(5,'dada','"+enlace_html_mapa_tienda+"');\"/><area shape='circle' coords='133,65,5' href='#' onclick=\"actual_mapa(6,'dada','"+enlace_html_mapa_tienda+"');\"/><area shape='circle' coords='172,65,5' href='#' onclick=\"actual_mapa(7,'dada','"+enlace_html_mapa_tienda+"');\"/></map>";
						$('#txt_tienda').html(html_mapa_tienda+"<p id='titol_mapa'>Showroom</p><img src='img/plano_dada_1.png' border='0' usemap='#mapa_dada' class='img_plano'/>"+mapa_de_imagen);
						

						top_leyenda('Dada Showroom');
						$('#img_segundo_plano').focus();

					});
				});
		});
	}
	
	if(tienda=="minotti")//---------------SI MINOTTI
	{
		$('#top_left_leyenda').html('');
		datos="<p>Pr&iacute;ncipe de Vergara, 33 - 28001 <strong>Madrid</strong><p>Tel: 91 436 10 04 - Fax: 91 576 92 59</p><p>email: <a href='mailto:minotti@conceptodr.com' class='link_gris'>minotti@conceptodr.com</a><br/>web: <a href='http://www.minotti.it' target='_blank' class='link_gris'>www.minotti.it</a></p><ul id='iconos_tienda'><li class='iconos_1'><div class='leyenda_icono_tienda'>estudio</div></li><li class='iconos'>+</li><li class='iconos_2'><div class='leyenda_icono_tienda'>tienda</div></li><li class='iconos'>+</li><li class='iconos_3'><div class='leyenda_icono_tienda'>showroom</div></li></ul><div class='clear'></div>";
		hover_botones_tiendas(3);
		
		
	
 		if( $('#datos_tienda').attr('id') != 'datos_tienda' )//Si no exite todavia el elemento en DOM
		{
			$("#botones_tiendas").after("<div id='datos_tienda'>"+datos+"</div>");
		}else{
			$('#datos_tienda').html(datos);
		}
		
		
		
		$('#box_detalle').animate({marginRight:"0"}, 800, "swing", function()
		{
			iniciar_box_dcha_tienda_start(tienda);
			enlace_html_mapa_tienda="http://maps.google.es/maps?f=q&source=s_q&hl=es&geocode=&q=Pr%C3%ADncipe+de+Vergara,+33+-+28001+Madrid&sll=40.396764,-3.713379&sspn=11.422494,19.753418&ie=UTF8&z=16&iwloc=r5";
			html_mapa_tienda="<div id='ver_mapa_tienda'><a href='"+enlace_html_mapa_tienda+"' target='_blank'><img src='img/icon_ver_mapa_tienda.png'/></a><a href='"+enlace_html_mapa_tienda+"' class='ver_mapa' target='_blank'>ver mapa</a></div>";
			var datos_txt_tienda=html_mapa_tienda+"<p id='msg_0'>&quot;El mobiliario ha de adecuarse al uso, al espacio y a su tiempo. Esto significa adaptarlo a circunstancias nuevas&quot;</p><p class='ver_show'><span id='txt_ver_show'>ver showroom</span> <img src='img/ver_showroom.gif'/></p>";
			if( $('#txt_tienda').attr('id') != 'txt_tienda' )//Si no exite todavia el elemento en DOM
			{
				$('#box_detalle').append("<div id='txt_tienda'>"+datos_txt_tienda+"</div>");
			}else{
				$('#txt_tienda').html(datos_txt_tienda);//Importante, es para no ir añadiendo elementos al DOM, una vez esten ya cargados, solo hay q sustituir el contenido
			}
					
				
				$('#txt_tienda').css({opacity:'0'});
				$('#txt_tienda').animate({opacity:"0.8"}, 800);
				$('.ver_show').hover(function ()
				{
					$(this).css({cursor:"pointer"}); 
					$('#txt_ver_show').addClass('ver_show_underline');
				}, //hover (over,out)
							function () {
							$('#txt_ver_show').removeClass('ver_show_underline');
							}

				
				);
				$('.ver_show').click(function ()
				{					
					$(this).delay(400, function()
					{
						tienda="minotti";
						mapa_de_imagen="<map name='mapa_minotti' id='mapa_minotti'><area shape='circle' coords='84,31,8' href='#' onclick=\"actual_mapa(1,'minotti','"+enlace_html_mapa_tienda+"');\"/><area shape='circle' coords='24,102,6' href='#' onclick=\"actual_mapa(2,'minotti','"+enlace_html_mapa_tienda+"');\"/><area shape='circle' coords='145,84,5' href='#' onclick=\"actual_mapa(3,'minotti','"+enlace_html_mapa_tienda+"');\"/><area shape='circle' coords='70,106,5' href='#' onclick=\"actual_mapa(4,'minotti','"+enlace_html_mapa_tienda+"');\"/><area shape='circle' coords='152,220,5' href='#' onclick=\"actual_mapa(5,'minotti','"+enlace_html_mapa_tienda+"');\"/><area shape='circle' coords='123,221,5' href='#' onclick=\"actual_mapa(6,'minotti','"+enlace_html_mapa_tienda+"');\"/><area shape='circle' coords='153,232,6' href='#' onclick=\"actual_mapa(7,'minotti','"+enlace_html_mapa_tienda+"');\"/><area shape='circle' coords='135,245,5' href='#' onclick=\"actual_mapa(8,'minotti','"+enlace_html_mapa_tienda+"');\"/><area shape='circle' coords='174,265,5' href='#' onclick=\"actual_mapa(9,'minotti','"+enlace_html_mapa_tienda+"');\"/></map>";
						//Toco el padding de #titol_mapa y el margin-top de .img_plano por los DOS MAPAS
						$('#txt_tienda').html(html_mapa_tienda+"<p id='titol_mapa' style='padding-top:25px;'>Showroom</p><img src='img/plano_"+tienda+"_1.png' border='0' usemap='#mapa_"+tienda+"' class='img_plano' style='margin-top:10px;'/>"+mapa_de_imagen);
						
						top_leyenda('Minotti Showroom');
						$('#img_segundo_plano').focus();

					});
				});
		});
	}//Fin minotti
	
	if(tienda=="derre")//---------------SI DERRE
	{
		$('#top_left_leyenda').html('');
		datos="<p>Serrano, 22 - 28001 <strong>Madrid</strong></p><p>Tel: 91 578 03 18 - Fax: 91 576 73 55</p><p>email: <a href='mailto:derre@conceptodr.com' class='link_gris'>derre@conceptodr.com</a><br/>&nbsp;</p><ul id='iconos_tienda'><li class='iconos_1'><div class='leyenda_icono_tienda'>estudio</div></li><li class='iconos'>+</li><li class='iconos_2'><div class='leyenda_icono_tienda'>tienda</div></li><li class='iconos'>+</li><li class='iconos_3'><div class='leyenda_icono_tienda'>showroom</div></li></ul><div class='clear'></div>";
		
		hover_botones_tiendas(1);
		
	
 		if( $('#datos_tienda').attr('id') != 'datos_tienda' )//Si no exite todavia el elemento en DOM
		{
			$("#botones_tiendas").after("<div id='datos_tienda'>"+datos+"</div>");
		}else{
			$('#datos_tienda').html(datos);
		}
		
		
		
		$('#box_detalle').animate({marginRight:"0"}, 800, "swing", function()
		{
			iniciar_box_dcha_tienda_start(tienda);
			//Marco el enlaco como vble para pasarlo a funcion actual_mapa
			enlace_html_mapa_tienda="http://maps.google.es/maps?f=q&source=s_q&hl=es&geocode=&q=Serrano,+22+-+28001+Madrid&sll=40.440099,-3.684727&sspn=0.01073,0.01929&ie=UTF8&ll=40.423951,-3.688145&spn=0.010732,0.01929&z=16&iwloc=r2";
			html_mapa_tienda="<div id='ver_mapa_tienda'><a href='"+enlace_html_mapa_tienda+"' target='_blank'><img src='img/icon_ver_mapa_tienda.png'/></a><a href='"+enlace_html_mapa_tienda+"' class='ver_mapa' target='_blank'>ver mapa</a></div>";			
			
			
			var datos_txt_tienda=html_mapa_tienda+"<p id='msg_0'>&quot;El dise&ntilde;o debe seducir, educar y, quiz&aacute;s lo m&aacute;s importante, provocar una respuesta emocional&quot;</p><p class='cita'>&nbsp;<br/><i>&nbsp;</i></p><p class='ver_show'><span id='txt_ver_show'>ver showroom</span> <img src='img/ver_showroom.gif'/></p>";
			if( $('#txt_tienda').attr('id') != 'txt_tienda' )//Si no exite todavia el elemento en DOM
			{
				$('#box_detalle').append("<div id='txt_tienda'>"+datos_txt_tienda+"</div>");
			}else{
				$('#txt_tienda').html(datos_txt_tienda);//Importante, es para no ir añadiendo elementos al DOM, una vez esten ya cargados, solo hay q sustituir el contenido
			}
					
				
				$('#txt_tienda').css({opacity:'0'});
				$('#txt_tienda').animate({opacity:"0.8"}, 800);
				$('.ver_show').hover(function ()
				{
					$(this).css({cursor:"pointer"}); 
					$('#txt_ver_show').addClass('ver_show_underline');
				}, //hover (over,out)
							function () {
							$('#txt_ver_show').removeClass('ver_show_underline');
							}
				
				);
				$('.ver_show').click(function ()
				{					
					$(this).delay(400, function()
					{
						tienda="derre";
						mapa_de_imagen="<map name='mapa_derre' id='mapa_derre'><area shape='circle' coords='260,35,8' href='#' onclick=\"actual_mapa(1,'derre','"+enlace_html_mapa_tienda+"');\"/><area shape='circle' coords='183,26,6' href='#' onclick=\"actual_mapa(2,'derre','"+enlace_html_mapa_tienda+"');\"/><area shape='circle' coords='164,92,5' href='#' onclick=\"actual_mapa(3,'derre','"+enlace_html_mapa_tienda+"');\"/><area shape='circle' coords='220,89,6' href='#' onclick=\"actual_mapa(4,'derre','"+enlace_html_mapa_tienda+"');\"/><area shape='circle' coords='154,81,5' href='#' onclick=\"actual_mapa(5,'derre','"+enlace_html_mapa_tienda+"');\"/><area shape='circle' coords='217,30,6' href='#' onclick=\"actual_mapa(6,'derre','"+enlace_html_mapa_tienda+"');\"/><area shape='circle' coords='75,78,6' href='#' onclick=\"actual_mapa(7,'derre','"+enlace_html_mapa_tienda+"');\"/></map>";
						$('#txt_tienda').html(html_mapa_tienda+"<p id='titol_mapa'>Showroom</p><img src='img/plano_"+tienda+"_1.png' border='0' usemap='#mapa_"+tienda+"' class='img_plano' />"+mapa_de_imagen);
						
						top_leyenda('DeRRe Showroom');
						$('#img_segundo_plano').focus();

					});
				});
		});
	}//Fin DERRE
	
}


/**************/
function actual_mapa(numero_imagen, nombre_tienda, enlace_html_mapa_tienda)
{
	nombre_imagen="url(img/"+nombre_tienda+"_shw_"+numero_imagen+".jpg)";
	pagina_imagen_tienda_cargar=nombre_tienda+"_shw_"+numero_imagen+".htm";
	$('#visor_img_2').css('background-image','url(img/ajax-loader.gif)');
	$('#img_segundo_plano').css('background-image',nombre_imagen);	
	$('#img_segundo_plano').load(pagina_imagen_tienda_cargar, function()
	{
		$('.img_plano').css({opacity:"0"});	
		$('#txt_tienda').html("<div id='ver_mapa_tienda'><a href='"+enlace_html_mapa_tienda+"' ' target='_blank'><img src='img/icon_ver_mapa_tienda.png'/></a><a href='"+enlace_html_mapa_tienda+"' class='ver_mapa' target='_blank'>ver mapa</a></div><p id='titol_mapa'>Showroom</p><img src='img/plano_"+nombre_tienda+"_"+numero_imagen+".png'  border='0' usemap='#mapa_"+nombre_tienda+"' class='img_plano'/>"+mapa_de_imagen);
		
		//ESPECIAL DOS MAPAS- MINOTTI
		if(nombre_tienda=='minotti'){$('.img_plano').css({'margin-top':'10px'});$('#titol_mapa').css({'padding-top':'25px'});}
		
		$('.img_plano').animate({opacity:"1"}, 1500);	
		$('#visor_img_2').css({opacity:"0"});
		$('#visor_img_2').load(pagina_imagen_tienda_cargar, function()
		{	
			$('#visor_img_2').animate({opacity:"1"}, 1500);
		});
	});
	
	esconder_menus_shw();//x si esta on el menu
}

/*****************************/
function cerrar_box_dcha(){//Al hacer clic en los enlaces 1er menu( ó 2 o 3), debe apagarse la box dcha
		for(var logo=1; logo<5; logo++)
		{
			$('#bot_tienda_'+logo).css({backgroundPosition: '0 0'});//->Retorno los botones de tienda a los estados originales	
		}
		$('#txt_tienda').remove();
		bot_tienda=0;
		$('#datos_tienda').remove();
		$('#box_detalle').css({marginRight:"-210px"});
		
}

/**
 * jQuery-Plugin "preloadCssImages"
 * by Scott Jehl, scott@filamentgroup.com
 * http://www.filamentgroup.com
 * reference article: http://www.filamentgroup.com/lab/update_automatically_preload_images_from_css_with_jquery/
 * demo page: http://www.filamentgroup.com/examples/preloadImages/index_v2.php
 * 
 * Copyright (c) 2008 Filament Group, Inc
 * Dual licensed under the MIT (filamentgroup.com/examples/mit-license.txt) and GPL (filamentgroup.com/examples/gpl-license.txt) licenses.
 *
 * Version: 5.0, 10.31.2008
 * Changelog:
 * 	02.20.2008 initial Version 1.0
 *    06.04.2008 Version 2.0 : removed need for any passed arguments. Images load from any and all directories.
 *    06.21.2008 Version 3.0 : Added options for loading status. Fixed IE abs image path bug (thanks Sam Pohlenz).
 *    07.24.2008 Version 4.0 : Added support for @imported CSS (credit: http://marcarea.com/). Fixed support in Opera as well. 
 *    10.31.2008 Version: 5.0 : Many feature and performance enhancements from trixta
 * --------------------------------------------------------------------
 */

;jQuery.preloadCssImages = function(settings){
	settings = jQuery.extend({
		statusTextEl: null,
		statusBarEl: null,
		errorDelay: 999, // handles 404-Errors in IE
		simultaneousCacheLoading: 3
	}, settings);
	var allImgs = [],
		loaded = 0,
		imgUrls = [],
		thisSheetRules,	
		errorTimer;
		
		
function renovar_imagen()
	{
		$(this).delay(4000,function()
		{
			$('#visor_img').fadeOut(400, function()
			{
				var nueva_img="url(img/inicio_"+img_sig+".jpg)";
				$('#visor_img').css('background-image',nueva_img);
				img_sig++;
				if(img_sig>12){img_sig=1;}
					$('#visor_img').fadeIn(2000, function(){renovar_imagen();});

			});
		});
	}
	
	function onImgComplete(){
		//player();//Arranca el player de musica
		
		clearTimeout(errorTimer);
		if (imgUrls && imgUrls.length && imgUrls[loaded]) {
			loaded++;
			
			
			if (settings.statusTextEl) {
				var nowloading = (imgUrls[loaded]) ? 
					'Cargando: <span>' + imgUrls[loaded].split('/')[imgUrls[loaded].split('/').length - 1] : 
					'Carga Completa'; // wrong status-text bug fixed
					//Añadido x mi para quitar el status
					if(!imgUrls[loaded]){
						img_inici=1+(Math.round(Math.random() * 11));
						img_inici_00="url(img/inicio_"+img_inici+".jpg)";
						$('#visor_img').css('background-image',img_inici_00);
	
	

						img_sig=img_inici+1;
						if(img_sig>12){img_sig=1;}
						$('#textStatus').remove();
						$(this).delay(4000,function()
	{
		
		renovar_imagen();
		
	});
						}
					//Fin Añadido x mi para quitar el status
				jQuery(settings.statusTextEl).html("<span class='numLoaded'>" + loaded + "</span> de <span class='numTotal'>" + imgUrls.length + "</span> cargadas (<span class='percentLoaded'>" + (loaded / imgUrls.length * 100).toFixed(0) + "%</span>) <span class='currentImg'>" + nowloading + "</span></span>");
			}
			if (settings.statusBarEl) {
				var barWidth = jQuery(settings.statusBarEl).width();
				jQuery(settings.statusBarEl).css('background-position', -(barWidth - (barWidth * loaded / imgUrls.length).toFixed(0)) + 'px 50%');
			}
			loadImgs();
			
		}
	}
	
	function loadImgs(){
		//only load 1 image at the same time / most browsers can only handle 2 http requests, 1 should remain for user-interaction (Ajax, other images, normal page requests...)
		// otherwise set simultaneousCacheLoading to a higher number for simultaneous downloads
		if(imgUrls && imgUrls.length && imgUrls[loaded]){
			var img = new Image(); //new img obj
			img.src = imgUrls[loaded];	//set src either absolute or rel to css dir
			if(!img.complete){
				jQuery(img).bind('error load onreadystatechange', onImgComplete);
			} else {
				
				onImgComplete();
			}
			errorTimer = setTimeout(onImgComplete, settings.errorDelay); // handles 404-Errors in IE
		}
	}
	
	function parseCSS(sheets, urls) {
		var w3cImport = false,
			imported = [],
			importedSrc = [],
			baseURL;
		var sheetIndex = sheets.length;
		while(sheetIndex--){//loop through each stylesheet
			
			var cssPile = '';//create large string of all css rules in sheet
			
			if(urls && urls[sheetIndex]){
				baseURL = urls[sheetIndex];
			} else {
				var csshref = (sheets[sheetIndex].href) ? sheets[sheetIndex].href : 'window.location.href';
				var baseURLarr = csshref.split('/');//split href at / to make array
				baseURLarr.pop();//remove file path from baseURL array
				baseURL = baseURLarr.join('/');//create base url for the images in this sheet (css file's dir)
				if (baseURL) {
					baseURL += '/'; //tack on a / if needed
				}
			}
			if(sheets[sheetIndex].cssRules || sheets[sheetIndex].rules){
				thisSheetRules = (sheets[sheetIndex].cssRules) ? //->>> http://www.quirksmode.org/dom/w3c_css.html
					sheets[sheetIndex].cssRules : //w3
					sheets[sheetIndex].rules; //ie 
				var ruleIndex = thisSheetRules.length;
				while(ruleIndex--){
					if(thisSheetRules[ruleIndex].style && thisSheetRules[ruleIndex].style.cssText){
						var text = thisSheetRules[ruleIndex].style.cssText;
						if(text.toLowerCase().indexOf('url') != -1){ // only add rules to the string if you can assume, to find an image, speed improvement
							cssPile += text; // thisSheetRules[ruleIndex].style.cssText instead of thisSheetRules[ruleIndex].cssText is a huge speed improvement
						}
					} else if(thisSheetRules[ruleIndex].styleSheet) {
						imported.push(thisSheetRules[ruleIndex].styleSheet);
						w3cImport = true;
					}
					
				}
			}
			//parse cssPile for image urls
			var tmpImage = cssPile.match(/[^\("]+\.(gif|jpg|jpeg|png)/g);//reg ex to get a string of between a "(" and a ".filename" / '"' for opera-bugfix
			if(tmpImage){
				var i = tmpImage.length;
				while(i--){ // handle baseUrl here for multiple stylesheets in different folders bug
					var imgSrc = (tmpImage[i].charAt(0) == '/' || tmpImage[i].match('://')) ? // protocol-bug fixed
						tmpImage[i] : 
						baseURL + tmpImage[i];
					
					if(jQuery.inArray(imgSrc, imgUrls) == -1){
						imgUrls.push(imgSrc);
					}
				}
			}
			
			if(!w3cImport && sheets[sheetIndex].imports && sheets[sheetIndex].imports.length) {
				for(var iImport = 0, importLen = sheets[sheetIndex].imports.length; iImport < importLen; iImport++){
					var iHref = sheets[sheetIndex].imports[iImport].href;
					iHref = iHref.split('/');
					iHref.pop();
					iHref = iHref.join('/');
					if (iHref) {
						iHref += '/'; //tack on a / if needed
					}
					var iSrc = (iHref.charAt(0) == '/' || iHref.match('://')) ? // protocol-bug fixed
						iHref : 
						baseURL + iHref;
					
					importedSrc.push(iSrc);
					imported.push(sheets[sheetIndex].imports[iImport]);
				}
				
				
			}
		}//loop
		if(imported.length){
			parseCSS(imported, importedSrc);
			return false;
		}
		var downloads = settings.simultaneousCacheLoading;
		while( downloads--){
			setTimeout(loadImgs, downloads);
		}
	}
	parseCSS(document.styleSheets);
	return imgUrls;
	
	
	
};

