//Variables globales
var mapToShow = "";
var oldSection = "";

//Operaciones a realizar cuando el documento ha terminado de cargarse
$(document).ready(function(){
	//Barra de notificación para usuarios de navegadores antiguos
	if($.browser.msie && $.browser.version < 8){
		$.infoBar("" + 
			'<h5 style="text-align:center;">' +
				'Necesita actualizar Internet Explorer para ver correctamente este sitio. Para hacerlo pulse aquí...' +
			'</h5>'
		);
	}
	
	//Preparar los menús desplegables con las animaciones correspondientes para cada nivel
	$(".menu ul li.seccionPrincipal").hover(function(){
		$(this).children("ul.submenu").stop(true, true).slideDown();
	}, function(){
		$(this).children("ul.submenu").stop(true, true).slideUp();
	});
	$(".menu ul li.subSeccionPrincipal").hover(function(){
		$(this).children("ul.submenu").stop(true, true).show(300);
	}, function(){
		$(this).children("ul.submenu").stop(true, true).hide(300);
	});
	
	//Funciones para el manejo del historial
	$.history.init(function(url){
		if(url != "") mainLoadData(url);
		else mainLoadData("inicio.php");
	});
});

/**
* Función para la carga de datos de forma asíncrona mediante AJAX
*/
function mainLoadData(section){
	if(section == "") return;
	if(section == "inicio.php"){
		$(".menu").hide();
		$("#cabecera").load("cabecera.php", function(){
			$("#cabecera").css('height', '360px');
		});
		$("#contenido").load(section, function(){});
	}else{
		if($("#wowslider-container1").length > 0){
			//Si existe la capa del slider es que estamos en la sección principal.
			//En tal caso realizamos la transición desde esa sección
			$("#contenido").animate({"opacity" : "0.0"}, 500, function(){
				$("#contenido").load(section, function(){
					if(section == "contacto"){
						enviarContacto();
						desplegarDatosContacto();
						$("input[type=text]").focus(function(){colorOriginal($(this));});
					}else if(section == "instalaciones/actur" || section == "instalaciones/breton" || section == "instalaciones/unidad_acuatica_rehabilitacion_villamayor" || 
							 section == "instalaciones/cdm_duquesa_villahermosa" || section == "instalaciones/clinica_montecanal" || section == "instalaciones/centro_medico_palafox"){
						generarGaleria();
						mostrarVerMapa();
					}else if(section == "donde_estamos") mostrarMapas();
					
					$("#contenido").animate({"opacity" : "1.0"}, 500, function(){
						$("#wowslider-container1").fadeOut(function(){
							$("#cabecera").animate({"height" : "200px"}, 500, function(){
								//Establecer la imagen de cabecera de las subsecciones poniendo la misma que en las secciones padre
								if(section == "quienes_somos/historia" || section == "quienes_somos/presentacion") section = "quienesSomos";
								else if(section == "instalaciones/actur" || section == "instalaciones/breton" || section == "instalaciones/unidad_acuatica_rehabilitacion_villamayor" || 
										section == "instalaciones/cdm_duquesa_villahermosa" || section == "instalaciones/clinica_montecanal" || section == "instalaciones/centro_medico_palafox") section = "instalaciones";
								else if(section == "servicios/unidad_fisioterapia" || section == "servicios/unidad_podologia" || section == "servicios/rehabilitacion_vestibular_vertigo" || 
										section == "servicios/reconocimientos_medicos_deportivos" || section == "servicios/unidad_movil" || section == "rehabilitacion" || 
										section == "rehabVillamayor" || section == "rehabVillahermosa") section = "servicios";
								else if(section == "donde_estamos") section = "dondeEstamos";
								else if(section.indexOf("noticia") != -1) section = "noticias";
								
								//Chequear qué sección se va a mostrar. Si es igual que la última que se mostró, no recargar la imagen de la cabecera
								if(section != oldSection){
									$("#cabecera").html('<div class="innerCabecera" style="background:url(img/secciones/' + section + '.jpg) no-repeat center center;"></div>');
									$(".innerCabecera").fadeIn(function(){});
									$(".menu").show();
								}
								oldSection = section;
							});
						});
					});
				});
			});
		}else{
			//Si no existe el slider cargamos el contenido de la sección correspondiente
			$("#contenido").animate({"opacity" : "0.0"}, 500, function(){
				$("#contenido").load(section, function(){
					if(section == "contacto"){
						enviarContacto();
						desplegarDatosContacto();
						$("input[type=text]").focus(function(){colorOriginal($(this));});
					}else if(section == "instalaciones/actur" || section == "instalaciones/breton" || section == "instalaciones/unidad_acuatica_rehabilitacion_villamayor" || 
							 section == "instalaciones/cdm_duquesa_villahermosa" || section == "instalaciones/clinica_montecanal" || section == "instalaciones/centro_medico_palafox"){
						generarGaleria();
						mostrarVerMapa();
					}else if(section == "donde_estamos") mostrarMapas();
					
					$("#contenido").animate({"opacity" : "1.0"}, 500, function(){
						$("#cabecera").css("height", "200px");
						
						//Establecer la imagen de cabecera de las subsecciones poniendo la misma que en las secciones padre
						if(section == "quienes_somos/historia" || section == "quienes_somos/presentacion") section = "quienesSomos";
						else if(section == "instalaciones/actur" || section == "instalaciones/breton" || section == "instalaciones/unidad_acuatica_rehabilitacion_villamayor" || 
								section == "instalaciones/cdm_duquesa_villahermosa" || section == "instalaciones/clinica_montecanal" || section == "instalaciones/centro_medico_palafox") section = "instalaciones";
						else if(section == "servicios/unidad_fisioterapia" || section == "servicios/unidad_podologia" || section == "servicios/rehabilitacion_vestibular_vertigo" || 
								section == "servicios/reconocimientos_medicos_deportivos" || section == "servicios/unidad_movil" || section == "rehabilitacion" || section == "rehabVillamayor" || 
								section == "rehabVillahermosa") section = "servicios";
						else if(section == "donde_estamos") section = "dondeEstamos";
						else if(section.indexOf("noticia") != -1) section = "noticias";
						
						//Chequear qué sección se va a mostrar. Si es igual que la última que se mostró, no recargar la imagen de la cabecera
						if(section != oldSection){
							$("#cabecera").html('<div class="innerCabecera" style="background:url(img/secciones/' + section + '.jpg) no-repeat center center;"></div>');
							$(".innerCabecera").fadeIn(function(){});
							$(".menu").show();
						}
						oldSection = section;
					});
				});
			});
		}
	}
}

/* INSTALACIONES */
/**
* Función que genera la galería fotográfica usando el plugin fancybox de jQuery
*/
function generarGaleria(){
	$(".fancy").fancybox({
		'transitionIn'	:	'elastic',
		'transitionOut'	:	'elastic',
		'speedIn'		:	200, 
		'speedOut'		:	200, 
		'overlayShow'	:	false
	});
}
/**
* Función que prepara la capa con la dirección de una instalación para que al pasar el ratón por encima muestre el enlace de "Ver Mapa"
* y al quitarlo lo oculte
*/
function mostrarVerMapa(){
	$(".dirInst").hover(function(){
		$(this).stop(true, true).animate({width : "+=110"});
	}, function(){
		$(this).stop(true, true).animate({width : "-=110"});
	});
}

/* DÓNDE ESTAMOS */
/**
* Función que genera un mapa usando la API de Google Maps
* PARAM layerId ID de la capa sobre la que se va a generar el mapa
* PARAM longitud Longitud de la ubicación a mostrar
* PARAM latitud Latitud de la ubicación a mostrar
* PARAM title Título a mostrar al poner el ratón sobre la ubicación
* PARAM desc Descripción que se mostrará en el bocadillo al hacer clic en la ubicación
* PARAM imgPath Ruta a la imagen que se quiere mostrar en la ubicación
*/
function generarMapa(layerId, longitud, latitud, title, desc, imgPath){
	//Crear mapa y asignar longitud y latitud del centro del mapa
	var latlng = new google.maps.LatLng(longitud, latitud);
	var myOptions = {
		zoom: 17,
		center: latlng,
		mapTypeId: google.maps.MapTypeId.SATELLITE
	};
	var map = new google.maps.Map(document.getElementById(layerId), myOptions);
	
	//Establecer icono de posición y longitud y latitud para el icono
	var image = imgPath;
	var imageLatLng = new google.maps.LatLng(longitud, latitud);
				
	//Crear contenido del bocadillo que se mostrará al hacer clic sobre el icono
	var contentString = desc;
	var infowindow = new google.maps.InfoWindow({
		content: contentString
	});
	
	//Crear marcador
	var marker = new google.maps.Marker({
		position: imageLatLng,
		map: map,
		icon: image,
		title: title
	});
	
	//Agregar evento para que al hacer click sobre el icono se muestre el bocadillo
	google.maps.event.addListener(marker, 'click', function() {
		infowindow.open(map,marker);
	});
}
/**
* Función que prepara todos los mapas de las distintas sedes
*/
function mostrarMapas(){
	//Primero chequeamos si hay que destacar alguno de los mapas
	if(mapToShow == ""){
		$("#mapActur").css({"-moz-box-shadow" : "0 0 8px #000", "-webkit-box-shadow" : "0 0 8px #000", "box-shadow" : "0 0 8px #000"});
		$("#mapBreton").css({"-moz-box-shadow" : "0 0 8px #000", "-webkit-box-shadow" : "0 0 8px #000", "box-shadow" : "0 0 8px #000"});
		$("#mapVillamayor").css({"-moz-box-shadow" : "0 0 8px #000", "-webkit-box-shadow" : "0 0 8px #000", "box-shadow" : "0 0 8px #000"});
		$("#mapVillahermosa").css({"-moz-box-shadow" : "0 0 8px #000", "-webkit-box-shadow" : "0 0 8px #000", "box-shadow" : "0 0 8px #000"});
		$("#mapMontecanal").css({"-moz-box-shadow" : "0 0 8px #000", "-webkit-box-shadow" : "0 0 8px #000", "box-shadow" : "0 0 8px #000"});
		$("#mapPalafox").css({"-moz-box-shadow" : "0 0 8px #000", "-webkit-box-shadow" : "0 0 8px #000", "box-shadow" : "0 0 8px #000"});
	}else if(mapToShow == "mapActur"){
		$("#mapActur").css({"-moz-box-shadow" : "0 0 25px #006db2", "-webkit-box-shadow" : "0 0 25px #006db2", "box-shadow" : "0 0 25px #006db2"});
		$("#mapBreton").css({"-moz-box-shadow" : "0 0 8px #000", "-webkit-box-shadow" : "0 0 8px #000", "box-shadow" : "0 0 8px #000"});
		$("#mapVillamayor").css({"-moz-box-shadow" : "0 0 8px #000", "-webkit-box-shadow" : "0 0 8px #000", "box-shadow" : "0 0 8px #000"});
		$("#mapVillahermosa").css({"-moz-box-shadow" : "0 0 8px #000", "-webkit-box-shadow" : "0 0 8px #000", "box-shadow" : "0 0 8px #000"});
		$("#mapMontecanal").css({"-moz-box-shadow" : "0 0 8px #000", "-webkit-box-shadow" : "0 0 8px #000", "box-shadow" : "0 0 8px #000"});
		$("#mapPalafox").css({"-moz-box-shadow" : "0 0 8px #000", "-webkit-box-shadow" : "0 0 8px #000", "box-shadow" : "0 0 8px #000"});
	}else if(mapToShow == "mapBreton"){
		$("#mapActur").css({"-moz-box-shadow" : "0 0 8px #000", "-webkit-box-shadow" : "0 0 8px #000", "box-shadow" : "0 0 8px #000"});
		$("#mapBreton").css({"-moz-box-shadow" : "0 0 25px #006db2", "-webkit-box-shadow" : "0 0 25px #006db2", "box-shadow" : "0 0 25px #006db2"});
		$("#mapVillamayor").css({"-moz-box-shadow" : "0 0 8px #000", "-webkit-box-shadow" : "0 0 8px #000", "box-shadow" : "0 0 8px #000"});
		$("#mapVillahermosa").css({"-moz-box-shadow" : "0 0 8px #000", "-webkit-box-shadow" : "0 0 8px #000", "box-shadow" : "0 0 8px #000"});
		$("#mapMontecanal").css({"-moz-box-shadow" : "0 0 8px #000", "-webkit-box-shadow" : "0 0 8px #000", "box-shadow" : "0 0 8px #000"});
		$("#mapPalafox").css({"-moz-box-shadow" : "0 0 8px #000", "-webkit-box-shadow" : "0 0 8px #000", "box-shadow" : "0 0 8px #000"});
	}else if(mapToShow == "mapVillamayor"){
		$("#mapActur").css({"-moz-box-shadow" : "0 0 8px #000", "-webkit-box-shadow" : "0 0 8px #000", "box-shadow" : "0 0 8px #000"});
		$("#mapBreton").css({"-moz-box-shadow" : "0 0 8px #000", "-webkit-box-shadow" : "0 0 8px #000", "box-shadow" : "0 0 8px #000"});
		$("#mapVillamayor").css({"-moz-box-shadow" : "0 0 25px #006db2", "-webkit-box-shadow" : "0 0 25px #006db2", "box-shadow" : "0 0 25px #006db2"});
		$("#mapVillahermosa").css({"-moz-box-shadow" : "0 0 8px #000", "-webkit-box-shadow" : "0 0 8px #000", "box-shadow" : "0 0 8px #000"});
		$("#mapMontecanal").css({"-moz-box-shadow" : "0 0 8px #000", "-webkit-box-shadow" : "0 0 8px #000", "box-shadow" : "0 0 8px #000"});
		$("#mapPalafox").css({"-moz-box-shadow" : "0 0 8px #000", "-webkit-box-shadow" : "0 0 8px #000", "box-shadow" : "0 0 8px #000"});
	}else if(mapToShow == "mapVillahermosa"){
		$("#mapActur").css({"-moz-box-shadow" : "0 0 8px #000", "-webkit-box-shadow" : "0 0 8px #000", "box-shadow" : "0 0 8px #000"});
		$("#mapBreton").css({"-moz-box-shadow" : "0 0 8px #000", "-webkit-box-shadow" : "0 0 8px #000", "box-shadow" : "0 0 8px #000"});
		$("#mapVillamayor").css({"-moz-box-shadow" : "0 0 8px #000", "-webkit-box-shadow" : "0 0 8px #000", "box-shadow" : "0 0 8px #000"});
		$("#mapVillahermosa").css({"-moz-box-shadow" : "0 0 25px #006db2", "-webkit-box-shadow" : "0 0 25px #006db2", "box-shadow" : "0 0 25px #006db2"});
		$("#mapMontecanal").css({"-moz-box-shadow" : "0 0 8px #000", "-webkit-box-shadow" : "0 0 8px #000", "box-shadow" : "0 0 8px #000"});
		$("#mapPalafox").css({"-moz-box-shadow" : "0 0 8px #000", "-webkit-box-shadow" : "0 0 8px #000", "box-shadow" : "0 0 8px #000"});
	}else if(mapToShow == "mapMontecanal"){
		$("#mapActur").css({"-moz-box-shadow" : "0 0 8px #000", "-webkit-box-shadow" : "0 0 8px #000", "box-shadow" : "0 0 8px #000"});
		$("#mapBreton").css({"-moz-box-shadow" : "0 0 8px #000", "-webkit-box-shadow" : "0 0 8px #000", "box-shadow" : "0 0 8px #000"});
		$("#mapVillamayor").css({"-moz-box-shadow" : "0 0 8px #000", "-webkit-box-shadow" : "0 0 8px #000", "box-shadow" : "0 0 8px #000"});
		$("#mapVillahermosa").css({"-moz-box-shadow" : "0 0 8px #000", "-webkit-box-shadow" : "0 0 8px #000", "box-shadow" : "0 0 8px #000"});
		$("#mapMontecanal").css({"-moz-box-shadow" : "0 0 25px #006db2", "-webkit-box-shadow" : "0 0 25px #006db2", "box-shadow" : "0 0 25px #006db2"});
		$("#mapPalafox").css({"-moz-box-shadow" : "0 0 8px #000", "-webkit-box-shadow" : "0 0 8px #000", "box-shadow" : "0 0 8px #000"});
	}else if(mapToShow == "mapPalafox"){
		$("#mapActur").css({"-moz-box-shadow" : "0 0 8px #000", "-webkit-box-shadow" : "0 0 8px #000", "box-shadow" : "0 0 8px #000"});
		$("#mapBreton").css({"-moz-box-shadow" : "0 0 8px #000", "-webkit-box-shadow" : "0 0 8px #000", "box-shadow" : "0 0 8px #000"});
		$("#mapVillamayor").css({"-moz-box-shadow" : "0 0 8px #000", "-webkit-box-shadow" : "0 0 8px #000", "box-shadow" : "0 0 8px #000"});
		$("#mapVillahermosa").css({"-moz-box-shadow" : "0 0 8px #000", "-webkit-box-shadow" : "0 0 8px #000", "box-shadow" : "0 0 8px #000"});
		$("#mapMontecanal").css({"-moz-box-shadow" : "0 0 8px #000", "-webkit-box-shadow" : "0 0 8px #000", "box-shadow" : "0 0 8px #000"});
		$("#mapPalafox").css({"-moz-box-shadow" : "0 0 25px #006db2", "-webkit-box-shadow" : "0 0 25px #006db2", "box-shadow" : "0 0 25px #006db2"});
	}
	
	//Mapa Actur
	var layerId = "mapActur";
	var longitud = 41.67890;
	var latitud = -0.89175;
	var title = "Trauma Aragon. Actur";
	var desc = "" + 
		"<div style='overflow:hidden; font:14px/16px Calibri;'>" +
			"<p>C/ Francisco Ferrer, 9-11</p>" + 
			"<p>50018 Zaragoza, Espa&ntilde;a</p>" + 
			"<p>976 799 512</p>" + 
		"</div>";
	var imgPath = "img/logoMaps.png";
	generarMapa(layerId, longitud, latitud, title, desc, imgPath);
	//Mapa Bretón
	var layerId = "mapBreton";
	var longitud = 41.645400;
	var latitud = -0.897450;
	var title = "Trauma Aragon. Breton";
	var desc = "" + 
		"<div style='overflow:hidden; font:14px/16px Calibri;'>" + 
			"<p>C/ Bret&oacute;n, 48</p>" + 
			"<p>50005 Zaragoza, Espa&ntilde;a</p>" + 
		"</div>";
	var imgPath = "img/logoMaps.png";
	generarMapa(layerId, longitud, latitud, title, desc, imgPath);
	//Mapa Villamayor
	var layerId = "mapVillamayor";
	var longitud = 41.686936;
	var latitud = -0.769366;
	var title = "Trauma Aragon. Villamayor";
	var desc = "" + 
		"<div style='overflow:hidden; font:14px/16px Calibri;'>" + 
			"<p>C/Paso 250</p>" + 
			"<p>50162 Villamayor, Espa&ntilde;a</p>" + 
		"</div>";
	var imgPath = "img/logoMaps.png";
	generarMapa(layerId, longitud, latitud, title, desc, imgPath);
	//Mapa Villaheromas
	var layerId = "mapVillahermosa";
	var longitud = 41.646400;
	var latitud = -0.907700;
	var title = "Trauma Aragon. Villahermosa";
	var desc = "" + 
		"<div style='overflow:hidden; font:14px/16px Calibri;'>" + 
			"<p>C/ Duquesa Villahermosa, esq. Vía Universitas</p>" + 
			"<p>50000 Zaragoza, Espa&ntilde;a</p>" + 
		"</div>";
	var imgPath = "img/logoMaps.png";
	generarMapa(layerId, longitud, latitud, title, desc, imgPath);
	//Mapa Montecanal
	var layerId = "mapMontecanal";
	var longitud = 41.63900;
	var latitud = -0.948779;
	var title = "Clinica Montecanal";
	var desc = "" + 
		"<div style='overflow:hidden; font:14px/16px Calibri;'>" + 
			"<p>Calle de Franz Schubert s/n</p>" + 
			"<p>50012 Zaragoza, Espa&ntilde;a</p>" + 
		"</div>";
	var imgPath = "img/logoMaps.png";
	generarMapa(layerId, longitud, latitud, title, desc, imgPath);
	//Mapa Palafox
	var layerId = "mapPalafox";
	var longitud = 41.650068;
	var latitud = -0.883203;
	var title = "Clinica Montecanal";
	var desc = "" + 
		"<div style='overflow:hidden; font:14px/16px Calibri;'>" + 
			"<p>Centro Comercial Independencia</p>" + 
			"<p>50012 Zaragoza, Espa&ntilde;a</p>" + 
		"</div>";
	var imgPath = "img/logoMaps.png";
	generarMapa(layerId, longitud, latitud, title, desc, imgPath);
}

/* FORMULARIO DE CONTACTO */
/**
* Función que manda de forma asíncrona el formulario de contacto
*/
function enviarContacto(){
	$("#formContacto").submit(function(e){
		e.preventDefault();
		
		//Controlar que los datos obligatorios han sido introducidos
		var continuar = true;
		if($("#txtNombre").val() == ""){
			$("#txtNombre").css({"background" : "#FFDFDF", "border-color" : "#FF5F5F"});
			continuar = false;
		}
		if($("#txtApellidos").val() == ""){
			$("#txtApellidos").css({"background" : "#FFDFDF", "border-color" : "#FF5F5F"});
			continuar = false;
		}
		if($("#txtPoblacion").val() == ""){
			$("#txtPoblacion").css({"background" : "#FFDFDF", "border-color" : "#FF5F5F"});
			continuar = false;
		}
		if($("#txtTelefono").val() == ""){
			$("#txtTelefono").css({"background" : "#FFDFDF", "border-color" : "#FF5F5F"});
			continuar = false;
		}
		if($("#txtEmail").val() == ""){
			$("#txtEmail").css({"background" : "#FFDFDF", "border-color" : "#FF5F5F"});
			continuar = false;
		}
		if(!continuar) return;
		
		$.ajax({
            type: 'POST',
            cache: false,
            url: $(this).attr("action"),
            data: $(this).serialize(), 
            success: function(msg){
				if(msg == "0"){
					respuestaForm("OK", "Correo enviado correctamente. En breve nos pondremos en contacto con usted.");
					limpiarContacto(); //Tras un envío correcto del formulario, limpiar los campos
				}else if(msg == "-1"){
					respuestaForm("ERROR", "Se produjo un error al mandar el mensaje. Int&eacute;ntelo de nuevo m&aacute;s tarde.");
				}else{
					respuestaForm("ERROR", "Se produjo un error inesperado.");
				}
            },
			error: function(msg){
				respuestaForm("ERROR", "Se produjo un error inesperado.");
			}
        });
	});
}
/**
* Función que limpia los campos del formulario de envío
*/
function limpiarContacto(){
	$("#formContacto").each(function(){
		this.reset();
	});
}
/**
* Función que vuelve a poner los colores originales a los cuadros de texto del formulario de contacto
* PARAM textField Campo de texto al que aplicar los colores
*/
function colorOriginal(textField){
	textField.css({
		"border-color" 	: "#12222F",
		"background-color" 	: "#FFF"
	});
}
/**
* Función que muestra el mensaje del servidor al mandar el formulario de contacto
*/
function respuestaForm(type, message){
	var background, border, shadow;
	
	//Generar colores de la capa
	if(type == "OK"){
		background = "#AEC901"; //Verde claro
		border = "#608900"; //Verde oscuro
		shadow = "#608900"; //Verde oscuro
	}else if(type == "ERROR"){
		background = "#FF9191"; //Rojo claro
		border = "#FF2828"; //Rojo oscuro
		shadow = "#FF2828"; //Rojo oscuro
	}
	
	//Establecer el mensaje a mostrar
	$("#respuesta").html(message);
	
	//Definir el margen que deberá tener la capa en relación con su tamaño y el tamaño de la capa contenedora
	var messageSize = $("#respuesta").width() / 2;
	var marginLeft = 448 - messageSize;
	
	//Establecer las propiedades CSS correspondientes
	$("#respuesta").css({
		"background" 			: background + " url(img/" + type + ".png) no-repeat center left",
		"-moz-box-shadow" 		: "0px 0px 10px " + shadow,
		"-webkit-box-shadow" 	: "0px 0px 10px " + shadow,
		"box-shadow" 			: "0px 0px 10px " + shadow,
		"border" 				: "1px solid " + border,
		"margin-left" 			: marginLeft
	});
	
	//Mostrar la capa con el mensaje
	$("#respuesta").fadeIn().delay(3000).fadeOut(); //Ocultar la respuesta 3 segundos después de haber sido mostrada
}
/**
* Función que prepara la capa con datos de contacto para que al pasar el ratón por encima se despliegue mostrando información extra
*/
function desplegarDatosContacto(){
	$(".datosContacto").hover(function(){
		$(this).stop(true, true).animate({width : "+=397"});
	}, function(){
		$(this).stop(true, true).animate({width : "-=397"});
	});
}
