	
	$(document).ready(function(){
		
		$("nav a").hover(
			function(){
				
				/* HOVER IN */
				
				var enlace = $(this).text();
				
				if(enlace != "inicio" || seccion != ""){
					if(enlace != seccion){
						var urlHover = "url(img/menu/hover/" + enlace + ".jpg) no-repeat center center";
											//alert(urlHover);
						$(this).css({"background": urlHover});
						$(this).css({"color": '#222'});
					}
				} 
				
				/* BG */
				$('nav a').each(function(index){
					if(index == 0 && seccion != "" && enlace != "inicio"){
						$(this).css({"background": "url(img/menu/bg/inicio.jpg)"});
						$(this).css({"color": 'white'});
					} else if(index != 0){
						if($(this).text() != enlace && $(this).text() != seccion){
							var urlImg = "url(img/menu/bg/" + $(this).text() + ".jpg) no-repeat center center";
							$(this).css({"background": urlImg});
							$(this).css({"color": 'white'});
						}
					}
				});
				
			}, function(){
				
				/* HOVER OUT */
				
				var enlace = $(this).text();
				
				if(seccion != "" || enlace != "inicio"){
					if(enlace != seccion){
						var urlImg = "url(img/menu/bg/" + $(this).text() + ".jpg) no-repeat center center";
						$(this).css({"background": urlImg});
						$(this).css({"color": 'white'});
					}
				}
				
			}
		);
				
		/* SELECCIONADO */
		
		switch(seccion){
			case 'empresa':
				$("nav #empresa").css({"background": "url(img/menu/selec/empresa.jpg) no-repeat center center"});
				$("nav #empresa").removeAttr("href");
				$("header #footer").css({"background": "url(img/menu/sombra/empresa.jpg) no-repeat center center"});
			break;
			case 'productos':
				$("nav #productos").css({"background": "url(img/menu/selec/productos.jpg) no-repeat center center"});
				$("nav #productos").removeAttr("href");
				$("header #footer").css({"background": "url(img/menu/sombra/productos.jpg) no-repeat center center"});
			break;
			case 'contacto':
				$("nav #contacto").css({"background": "url(img/menu/selec/contacto.jpg) no-repeat center center"});
				$("nav #contacto").removeAttr("href");
				$("header #footer").css({"background": "url(img/menu/sombra/contacto.jpg) no-repeat center center"});
			break;
			default:
				$("nav #inicio").css({"background": "url(img/menu/selec/inicio.jpg) no-repeat center center"});
				$("nav #inicio").removeAttr("href");
				$("header #footer").css({"background": "url(img/menu/sombra/inicio.jpg) no-repeat center center"});
			break;
		}
	
	
	
	
	
		
		/*$("nav #inicio").hover(
			function(){
				
				$(this).css({"background": "url(img/menu/hover/inicio.jpg"});
				
	
				$('nav a').each(function(index){
					if($(this).text() != "inicio"){
						var urlImg = "url(img/menu/bg/" + $(this).text() + ".jpg)";
						$(this).css({"background": urlImg});
					}
				});
				
			}
		);
		
		$("nav #empresa").hover(
			function(){
				
				$(this).css({"background": "url(img/menu/hover/empresa.jpg"});
				
				
				$('nav a').each(function(index){
					if($(this).text() != "empresa"){
						var urlImg = "url(img/menu/bg/" + $(this).text() + ".jpg)";
						$(this).css({"background": urlImg});
					}
				});									   
				
			}
		);
		
		$("nav #productos").hover(
			function(){
				
				$(this).css({"background": "url(img/menu/hover/productos.jpg"});
			
			
				$('nav a').each(function(index){
					if($(this).text() != "productos"){
						var urlImg = "url(img/menu/bg/" + $(this).text() + ".jpg)";
						$(this).css({"background": urlImg});
					}
				});
				
			}
		);
		
		$("nav #contacto").hover(
			function(){
				
				$(this).css({"background": "url(img/menu/hover/contacto.jpg"});
				
			
				$('nav a').each(function(index){
					if($(this).text() != "contacto"){
						var urlImg = "url(img/menu/bg/" + $(this).text() + ".jpg)";
						$(this).css({"background": urlImg});
					}
				});
				
			}
		);
		*/
		
	});		
