jQuery.fn.initMenu = function () {
    return this.each(function () {
        var theMenu = $(this).get(0);
        $('.acitem', this).hide();
        $('li.expand > .acitem', this).show();
        $('li.expand > .acitem', this).prev().addClass('active');
        $('li a', this).mouseover(
            function () {
                var theElement = $(this).next();
                var parent = this.parentNode.parentNode;
                if ($(parent).hasClass('noaccordion')) {
                    if (theElement[0] === undefined) {
                        window.location.href = this.href;
                    }
                    $(theElement).slideToggle('normal', function () {
                        if ($(this).is(':visible')) {
                            $(this).prev().addClass('active');
                        }
                        else {
                            $(this).prev().removeClass('active');
                        }
                    });
                    return false;
                }
                else {
                    if (theElement.hasClass('acitem') && theElement.is(':visible')) {
                        if ($(parent).hasClass('collapsible')) {
                            $('.acitem:visible', parent).first().slideUp('normal',
                            function () {
                                $(this).prev().removeClass('active');
                            }
                        );
                        }
                        return false;
                    }
                    if (theElement.hasClass('acitem') && !theElement.is(':visible')) {
                        $('.acitem:visible', parent).first().slideUp('normal', function () {
                            $(this).prev().removeClass('active');
                        });
                        theElement.slideDown('normal', function () {
                            $(this).prev().addClass('active');
                        });
                        return false;
                    }
                }
            }
    );
    });
};

$(document).ready(function () { $('.menu').initMenu(); });

$(function () {
    if (!$('#nav_animate li.lnkAbout').length) {
        $('#nav_animate li#ctl00_btn_home')
        		.css({ backgroundPosition: "-426px 30px" })
        		.mouseover(function () {
        		    $(this).stop().animate({ backgroundPosition: "(-426px 0)" }, { duration: 500 })
        		})
        		.mouseout(function () {
        		    $(this).stop().animate({ backgroundPosition: "(-426px 30px)" }, { duration: 200, complete: function () {
        		        $(this).css({ backgroundPosition: "-426px 30px" })
        		    }
        		    })
        		})
    }
    if (!$('#nav_animate li.lnkxrite').length) {
        $('#nav_animate li#ctl00_btn_x')
        		.css({ backgroundPosition: "-357px 30px" })
        		.mouseover(function () {
        		    $(this).stop().animate({ backgroundPosition: "(-357px 0)" }, { duration: 500 })
        		})
        		.mouseout(function () {
        		    $(this).stop().animate({ backgroundPosition: "(-357px 30px)" }, { duration: 200, complete: function () {
        		        $(this).css({ backgroundPosition: "-357px 30px" })
        		    }
        		    })
        		})
    }
    if (!$('#nav_animate li.lnkIndycenter').length) {
        $('#nav_animate li#ctl00_btn_indycenter')
        		.css({ backgroundPosition: "-288px 30px" })
        		.mouseover(function () {
        		    $(this).stop().animate({ backgroundPosition: "(-288px 0)" }, { duration: 500 })
        		})
        		.mouseout(function () {
        		    $(this).stop().animate({ backgroundPosition: "(-288px 30px)" }, { duration: 200, complete: function () {
        		        $(this).css({ backgroundPosition: "-288px 30px" })
        		    }
        		    })
        		})
    }
  if (!$('#nav_animate li.lnkArticle').length) {
        $('#nav_animate li#ctl00_btn_articles')
        		.css({ backgroundPosition: "-217px 30px" })
        		.mouseover(function () {
        		    $(this).stop().animate({ backgroundPosition: "(-217px 0)" }, { duration: 500 })
        		})
        		.mouseout(function () {
        		    $(this).stop().animate({ backgroundPosition: "(-217px 30px)" }, { duration: 200, complete: function () {
        		        $(this).css({ backgroundPosition: "-217px 30px" })
        		    }
        		    })
        		})
    }
    if (!$('#nav_animate li.lnkLinks').length) {
        $('#nav_animate li#ctl00_btn_links')
        		.css({ backgroundPosition: "-145px 30px" })
        		.mouseover(function () {
        		    $(this).stop().animate({ backgroundPosition: "(-145px 0)" }, { duration: 500 })
        		})
        		.mouseout(function () {
        		    $(this).stop().animate({ backgroundPosition: "(-145px 30px)" }, { duration: 200, complete: function () {
        		        $(this).css({ backgroundPosition: "-145px 30px" })
        		    }
        		    })
        		})
    }
    if (!$('#nav_animate li.lnkContact').length) {
        $('#nav_animate li#ctl00_btn_contact')
        		.css({ backgroundPosition: "-75px 30px" })
        		.mouseover(function () {
        		    $(this).stop().animate({ backgroundPosition: "(-75px 0)" }, { duration: 500 })
        		})
        		.mouseout(function () {
        		    $(this).stop().animate({ backgroundPosition: "(-75px 30px)" }, { duration: 200, complete: function () {
        		        $(this).css({ backgroundPosition: "-75px 30px" })
        		    }
        		    })
        		})
  }
  if (!$('#nav_animate li.lnkEnglish').length) {
      $('#nav_animate li#ctl00_btn_english')
        		.css({ backgroundPosition: "-4px 30px" })
        		.mouseover(function () {
        		    $(this).stop().animate({ backgroundPosition: "(-4px 0)" }, { duration: 500 })
        		})
        		.mouseout(function () {
        		    $(this).stop().animate({ backgroundPosition: "(-4px 30px)" }, { duration: 200, complete: function () {
        		        $(this).css({ backgroundPosition: "-4px 30px" })
        		    }
        		    })
        		})
  }
});
