$(function() {

			$('.nav').superfish({
				 autoArrows:    false,
				 delay: 0
			});

			$("#Caracteres").keypress(function(){
					var minu = String( $(this).val() ).toLowerCase();
    				$(this).attr("value",minu);
			});
			
			$("#Caracteres").blur(function(){
				var minu = String( $(this).val() ).toLowerCase();
				$(this).attr("value",minu);
			});
			
			$("#Busqueda").keypress(function(){
				if ( $('#TipoBusqueda').val() == "Empresa" )
				{
    				var mayus = String( $(this).val() ).toUpperCase();
    				$(this).attr("value",mayus);
				}
			});
			
			$("#Busqueda").blur(function(){
				if ( $('#TipoBusqueda').val() == "Empresa" )
				{
    				var mayus = String( $(this).val() ).toUpperCase();
    				$(this).attr("value",mayus);
				}
			});
			
			$('#TabEmpresa').click(function () {
				$('#LiEmpresa').addClass("current");
				$('#LiProductos').removeClass("current");
				$('#LiNovedades').removeClass("current");
				$('#TipoBusqueda').attr("value","Empresa");
				$('#FormularioBuscador').attr("action","resultado_busqueda_empresa.php");
			});

			$('#TabProductos').click(function () {
				$('#LiEmpresa').removeClass("current");
				$('#LiProductos').addClass("current");
				$('#LiNovedades').removeClass("current");
				$('#TipoBusqueda').attr("value","Productos");
				$('#FormularioBuscador').attr("action","resultado_busqueda_producto.php");
			});

			$('#TabNovedades').click(function () {
				$('#LiEmpresa').removeClass("current");
				$('#LiProductos').removeClass("current");
				$('#LiNovedades').addClass("current");
				$('#TipoBusqueda').attr("value","Novedades");
				$('#FormularioBuscador').attr("action","clasificados.php");
			});

			$( "form.formvalida" ).submit(function(){ return EvaluaReg( this ) });

                        $( "form.formvalidaRegistro" ).submit(function(){ 
                            if ( $("#AceptaTerminos").is(':checked') )
                                return EvaluaReg( this );
                             else
                             {
                                  alert("Debe aceptar los Terminos y Condiciones")
                                  return false;
                             }
                            
                        });
			
			//Esto para mostrar el div de categorias
			$(".show_container").click(function(){
				var checkedValue = $(this).attr("checked") ? "checked" : "";
				if( checkedValue == "checked" )
					$( "#" + $(this).attr("title") ).show("fast");
				else
					$( "#" + $(this).attr("title") ).hide("fast");
			});
			
			
			
			//AGREGADO POR JOHN PARA EL TOOLTIP
			$('[rel=tooltip]').bind('mouseover', function(){
	  
	
			 if ($(this).hasClass('ajax')) {
			 	
				var ajax = $(this).attr('ajax');	
						
			  $.get(ajax,
			  function(theMessage){
				//<![CDATA[
				$('<div class="tooltip"><span class="tooltip-image"></span><div class="tooltip-content">'  + theMessage + '</div></div>').appendTo('body').fadeIn('fast');});
			  	//]]>
			 }else{
						
					var theMessage = $(this).attr('content');
					var thename = $(this).attr('id');
					//<![CDATA[
					$('<div class="tooltip"><span class="tooltip-title">'+thename+'</span><span class="tooltip-image"></span><div class="tooltip-content">' + theMessage + '</div></div>').appendTo('body').fadeIn('fast');
					//]]>
			 		}
					
					$(this).bind('mousemove', function(e){
						$('div.tooltip').css({
							'top': e.pageY - ($('div.tooltip').height() / 2) - 5,
							'left': e.pageX + 15
						});
					});
				}).bind('mouseout', function(){
					$('div.tooltip').fadeOut('fast', function(){
						$(this).remove();
					});
				});

			//FIN TOOLTIP
			
		})
