// JavaScript Document
$(document).ready(function(){
	var posX = new Array("0px","-540px","-1080px","-1620");
	
	$(".tabs a").eq(0).css("background-position","0px -50px");
	$(".tabs a").each(function(index){
		$(this).click(function(){
			$(".tabs a").css("background-position","0px 0px");
			$(this).css("background-position","0px -50px");
			$(".slide").animate({left : posX[index]}, 350);
		});
	});
		
	$('.bg-menu a')
		.css({backgroundPosition: "-158px 0px"})
		.mouseover(function(){
			$(this).stop().animate({backgroundPosition:"(0px 0px)"}, {duration:500})
		})
		.mouseout(function(){
			if($(this).attr("id") != "active"){
				$(this).stop().animate({backgroundPosition:"(-158px 0px)"}, {duration:200, complete:function(){
					$(this).css({backgroundPosition: "-158px 0px"})
				}})
			}
		})
		$('.bg-menu a').each(function(x){
			if($(this).attr("id") == "active"){
				$('.bg-menu a').eq(x).css({backgroundPosition: "0px 0px"});		
			}						  
		});
		
		// MENU PRODUCTOS
		
		$('.menu-navegacion a')
		.css({backgroundPosition: "0px -17px"})
		.mouseover(function(){
			$(this).stop().animate({backgroundPosition:"(0px 0px)"}, {duration:300})
		})
		.mouseout(function(){
			if($(this).attr("id") != "ac"){
				$(this).stop().animate({backgroundPosition:"(0px -17px)"}, {duration:200, complete:function(){
					$(this).css({backgroundPosition: "0px -17px"})
				}})
			}
		})
		$('.menu-navegacion a').each(function(x){
			if($(this).attr("id") == "ac"){
				$('.menu-navegacion a').eq(x).css({backgroundPosition: "0px 0px"});		
			}						  
		});
		
	$("#ir").click( function(){
		var keyword = jQuery("#buscar").val()					   	
		buscar('productos.php',keyword)							
	})	
		
});

function search_enter(e) { 
	tecla = (document.all) ? e.keyCode : e.which; 
    if (tecla==13){
		buscar('productos.php',document.getElementById("buscar").value);
	}
	return true;
}

function buscar(url,texto){
	location.replace(url+'?q='+ texto);
}