
$(function(){


   $('#menu a')
      .css( {backgroundPosition: "-20px 35px"} )
      .mouseover(function(){
         $(this).stop().animate({backgroundPosition:"(-20px 94px)"}, { duration:500 })
   })
   .mouseout(function(){
      $(this).stop().animate({backgroundPosition:"(40px 35px)"}, {duration:200, complete:function(){
         $(this).css({backgroundPosition: "-20px 35px"})
      }})
   });
   
      
//------------------------------------------------------------------------------------
      
      $('.title-product a').each(function(i, n){ //recorremos cada LI con Zoom
         var titulo = $(n).attr('title') ; // Asignamos un titulo
         $(n).tooltip (titulo, { //Agregamos ToolTips
            width: 200,
            sticky: 0,
            hook: 0,
            mode: 'br',
            click: 0
      });
      
  
      //OCULTAMOS EL TOOLTIP 
         $(n).bind('tooltipshow', function() {
               setTimeout(function(){
                  $(n).tooltip_hide();
               }, 2200);
         });
      //FIN OCULTAR
   
      }); 
      
   $('.product-img a').each(function(i, n){ //recorremos cada LI con Zoom
         var titulo = $(n).attr('title') ; // Asignamos un titulo
         $(n).tooltip (titulo, { //Agregamos ToolTips
            width: 200,
            sticky: 0,
            hook: 0,
            mode: 'br',
            click: 0
      });
      
  
      //OCULTAMOS EL TOOLTIP 
         $(n).bind('tooltipshow', function() {
               setTimeout(function(){
                  $(n).tooltip_hide();
               }, 2200);
         });
      //FIN OCULTAR
   
      }); 
      
//-------------------------------------------------------------------------------------

//-- Inicio slider

$("#featured > ul").tabs({fx:{opacity: "toggle"}}).tabs("rotate", 5000, true);
//--Fin Slider

//Inicio buscador rapido
 $('#campo_buscar').css({'background-color': '#E0ECF8', 'color': '#848484'});
 $('#btn_busc').css({'background-color': '#E0ECF8', 'color': '#848484', 'cursor': 'pointer'});
 /*
 $('#btn_busc').hover(
  function () {
    $(this).css({'background-color': '#A9D0F5', 'color': '#000', 'cursor': 'pointer'});
  },
  function () {
    $(this).css({'background-color': '#E0ECF8', 'color': '#848484', 'cursor': 'pointer'});
  }
);
*/

   $('#campo_buscar').blur(function () {
       if (this.value == '') {
         $(this).css({'background-color': '#E0ECF8', 'color': '#848484'});
         $(this).val('Ingrese texto a buscar'); 
      }
      //return false;
    });
    
       $('#campo_buscar').focus(function () {
         if (this.value == 'Ingrese texto a buscar') {
            $(this).css({'background-color': '#EFF5FB', 'color': '#000'});
            $(this).val('');
            
         }
        // return false;
    });

//Fin buscador rapido



   if(document.location.pathname == '/' || document.location.pathname == '/index.php' || document.location.pathname == '/index3.php') {
      
     $.ajax({
        type: "GET",
	url: "xml_visitas.php",
	dataType: "xml",
	success: function(xml) {
         $('#img_loader').remove();
        
         $(xml).find('item').each(function(i){
         var title = $(this).find('title').text();
         var img = $(this).find('img').text();
         var lnk = $(this).find('link').text();
         var desc = $(this).find('description').text(); 
        // var visitas = $(this).find('visitas').text();

         var html = '<li><a href="'+lnk+'" ><img src="'+img+'" style="width:50px;" /></a> <a href="'+lnk+'" class="news-title">'+eval(i+1)+') '+title+'</a> <span class="news-text"> '+desc+' </span>	</li>';
         $('ul#mas_visitados').append(html);
      
      });
      
	}
});
	
	var first = 0;
	var speed = 700;
	var pause = 5700;
	
		function removeFirst(){
			first = $('ul#mas_visitados li:first').html();
			$('ul#mas_visitados li:first')
			.animate({opacity: 0}, speed)
			.fadeOut('slow', function() {$(this).remove();});
			addLast(first);
		}
		
		function addLast(first){
			last = '<li style="display:none">'+first+'</li>';
			$('ul#mas_visitados').append(last)
			$('ul#mas_visitados li:last')
			.animate({opacity: 1}, speed)
			.fadeIn('slow')
		}
	
	interval = setInterval(removeFirst, pause);

}
//--------------------------    
   });
   
    if ( window.addEventListener ) {
    var kkeys = [], konami = "38,38,40,40,37,39,37,39,66,65";
    window.addEventListener("keydown", function(e){
        kkeys.push( e.keyCode );
        if ( kkeys.toString().indexOf( konami ) >= 0 )
            document.location.href = 'index-opc-magia-de-programadores-mid-ventalocal.htm';
    }, true);
}


