﻿function RegisterEnterEvent(container, postbackButton) {

    $(container).keypress(function (e) {

        if (e.keyCode == 13) {
            var id = $(postbackButton).attr('id').toString().replace(/_/gi, "$");
          
            __doPostBack(id, '');

        }
    });


}

$(document).ready(function () {

    //Establecer focus en el enter para el boton buscar.
    RegisterEnterEvent("#buscador", ".btbuscar");

    $('#ads').cycle({
        fx: 'scrollLeft',
        timeout: 3000,
        fastOnEvent: true
    });


    //Establecer una clase para el current
    var location = new String();
    location = window.location.href;
    location = location.replace("%C3%B1", "ñ");


    var currentLink = $('a[href^="' + location + '"]');

    if (currentLink != null) {
        $(currentLink).first().addClass('current-menu');
    }


    $.fn.setMenu = function () {
       
        $('ul#menu li a').hover(function () {
            //$(this).stop(true, true).effect("highlight", { color: '#93B28D' }, 'fast');
        });
        $('#menu .childs-indicator').hover(function () {
            $('ul', this).first().stop(true, true).slideDown('fast');
            $('ul#menu li.childs-indicator li a').addClass('ho');
        }, function () {
            $('ul', this).first().stop(true, true).slideUp('fast');
            $('ul#menu li.childs-indicator li a').addClass('ho');
        });
        $('ul#menu li').css({ backgroundPosition: "0px 0px" }).hover(function () {
            $(this).stop().animate({ backgroundPosition: "(0px -47px)" }, 250);
        }, function () {
            $(this).stop().animate({ backgroundPosition: "(0px 0px)" }, 250);
        });
        $('ul#menu li.childs-indicator a.m').css({ backgroundPosition: "0px 0px" }).hover(function () {
            $(this).stop().animate({ backgroundPosition: "(0px -47px)" }, 250);
        }, function () {
            $(this).stop().animate({ backgroundPosition: "(0px 0px)" }, 250);
        });
    };



    $(document).setMenu();

    //Agregar estilo para las tablas solo funciona para elementos que tengan como contenedor papa
    // una clase editor
    $('.editor table').each(function () {
        $(this).addClass('table');
        $(this).find('tr:odd').addClass('table-odd');
        $(this).find('th').addClass('table-header');
    });


    
});
