﻿(function ($) {
    $.fn.scriptures = function (options, book, chapter, selectVerse, searchKey) {

        var defaults = {
            sizeLeft: 560,
            minLeft: 150,
            minRight: 0,
            dockSpeed: 200,
            CountItemsTTRange: 5,
            DefaulItemTTRange: 3,
            RecordsOnPage: 100,
            FirstBookShort: 'Gen',
            FirstBookLong: 'Genesis',
            LastBookShort: 'Rev',
            LastBookLong: 'Revelation',
            FirstBookID: 1,
            LastBookID: 66,
            EndOldTestamentID: 39,
            StartNewTestamentID: 40,
            EndOldTestamentShort: 'Mal',
            StartNewTestamentShort: 'Mat',
            SearchCaption: 'Search',
            SearchOptionsCaption: 'Search options',
            KJV: 'KJV',
            EntireDictionary: 'Entire Dictionary',
            HebRew: 'HebRew',
            Greek: 'Greek',
            Strongs: 'Strongs',
            AllWords: 'All Words',
            AnyWords: 'Any Words',
            Phrases: 'Phrases',
            EntireBible: 'Entire Bible',
            OldTestament: 'Old Testament',
            NewTestament: 'New Testament',
            CaseSensitive: 'Case Sensitive',
            PartialMatch: 'Partial Match',
            TypeCaption: 'Type:',
            RangeCaption: 'Range:',
            None: 'None',
            ShowLinks: 'Show Links',
            ShowNumbers: 'Show Numbers',
            BackToolTip: 'Back',
            NextToolTip: 'Next',
            PageToolTip: 'Pages',
            ttRangeToolTip: 'ttRange',
            ToolTipToolTip: 'ToolTip',
            PrintToolTip: 'Print',
            BookToolTip: 'Book select',
            BeginRangeToolTip: 'Begin range select',
            EndRangeToolTip: 'Begin range select',
            ChapterToolTip: 'Chapter select',
            TypeViewToolTip: 'Type View',
            SearchToolTip: 'Show/hide search window',
            CreateNewSearchWindowToolTip: 'Create new search window',
            SearchTypeToolTip: 'Type search',
            SearchKeyToolTip: 'Search key',
            GoSearchToolTip: 'Go search',
            RangeSelectToolTip: 'Range select',
            StepToggle: 10,
            SpeedToggle: 10,
            NoResultSearch: 'No results found',
            ScripturesHeader: 'Scriptures (KJV)',
            SearchHeader: 'Search'


        };
        var opt = $.extend(true, {
            loadComplete: null

        }, defaults, options);
        function Control(content, Class, disableClass) {
            var content = content;
            return {
                content: function () {
                    return content;
                },
                focus: function () {
                    content.focus();
                },
                disable: function () {

                    content.attr('disabled', 'disabled');
                    if (disableClass != '') {
                        content.removeClass(Class);

                        content.addClass(disableClass);
                    }
                },
                enable: function () {
                    content.attr('disabled', '');
                    if (disableClass != '') {
                        content.removeClass(disableClass);
                        content.addClass(Class);
                    }
                },
                show: function () {
                    content.show();
                },
                hide: function () {
                    content.hide();
                },

                appendTo: function (parent) {
                    content.appendTo(parent);
                },
                attr: function (attrName, attrVaue) {
                    if (attrVaue != null)
                        content.attr(attrName, attrVaue);
                    return content.attr(attrName);

                },


                width: function (value) {
                    if (value != null)
                        content.width(value);
                    return content.width();
                },
                click: function (delegate) {
                    content.unbind('click');
                    content.click(delegate);
                },

                keypress: function (delegate) {
                    content.unbind('keypress');
                    content.keypress(delegate);
                }
            };
        };
        function Button(Class, toolTip) {
            var control = Control($('<input type="button" class="Button  ' + Class + '"/>'), Class, '', toolTip);
            var content = control.content;
            control.text = function (val) {
                if (val != null)
                    content().val(val);
                return content().val();
            };
            control.constructor = arguments.callee;
            return control;
        };
        function TextBox(Class, toolTip) {
            var control = Control($('<input type="text" class="TextBox ' + Class + '" title="' + toolTip + '"/>'), Class, '', toolTip);
            var content = control.content;
            control.text = function (val) {
                if (val != null)
                    content().val(val);
                return content().val();
            };
            control.constructor = arguments.callee;
            return control;
        };

        function DropDownList(Class, toolTip) {
            var control = Control($('<select  class="ToolDropDown ' + Class + '"></select>'), Class, '', toolTip);
            var content = control.content;
            control.additem = function (value, text, selected) {
                var option = $('<option value="' + value + '" ' + (selected ? 'selected' : '') + '>' + text + '</option>');
                content().append(option);
            };
            control.change = function (delegate) {
                content().unbind('change');
                content().change(delegate);
            };


            control.text = function () {

                return content().find('option').filter(':selected').text();
            };

            control.val = function (val) {
                if (val != null)
                    content().find('option').filter('[value="' + val + '"]').attr('selected', 'true');

                return content().find('option').filter(':selected').val();
            };
            control.empty = function () {

                content().children().remove().end();
                //content().empty();
            };
            control.constructor = arguments.callee;
            return control;
        };
        function CheckBox(Class, toolTip) {
            var control = Control($('<input id="' + Class + '" class="CheckBox ' + Class + '" type="checkbox"/><label for="' + Class + '">' + toolTip + '</label>'), Class, '', toolTip);
            var content = control.content;
            control.checked = function (val) {
                if (val != null)
                    content().filter(':first').attr('checked', val);
                return content().filter(':first').attr('checked');
            };
            control.constructor = arguments.callee;
            return control;
        };
        function ToolButton(Class, disableClass, toolTip) {

            var control = Control($('<div class="ToolButton ' + Class + '" title="' + toolTip + '"><div/></div>'), Class, disableClass, toolTip);
            var content = control.content;
            control.text = function (val) {
                if (val != null)
                    content().children().text(val);
                return content().children().text();
            };
            var istoggle = false;
            control.isToggle = function () {
                return istoggle;
            };
            control.toggle = function () {
                if (control.isToggle())
                    content().removeClass('Toggle');
                else
                    content().addClass('Toggle');
                istoggle = !istoggle;
            };
            control.constructor = arguments.callee;
            return control;
        };

        //extend(Button, Control);
        var showPopupMenu;
        var popupMenu;

        function SearchWindowContent(parent) {
            SearchWindowContent.prototype.ResizeContent = function () {
                SearchBody.ResizeContent();
            };
            SearchWindowContent.prototype.ResizeToolsBar = function () {
                ToolsBar.ResizeSearchKeyTextBox();
            };

            SearchWindowContent.prototype.SetKeySearch = function (searchKey) {
                ToolsBar.SearchKeyTextBox.text(searchKey);
            };
            SearchWindowContent.prototype.GoSearch = function (page, newSearch) {
                SearchBody.GoSearch(page, newSearch);
            };
            var StatusBar = {
                Height: 0,
                StatusBar: $('<div class="StatusBar"/>'),
                CreateStatusBar: function (parent) {
                    this.StatusBar.appendTo(parent);
                    this.Height = this.StatusBar.height();
                },
                UpdateStatusBar: function (text) {
                    this.StatusBar.text(text);
                }
            };
            var SearchBody = {
                Data: null,
                SearchBody: $('<div class="SearchBody"/>'),

                CountPages: 0,
                AllRecords: 0,
                AllSearchHitcount: 0,
                GetKJVURL: function (page) {


                    return 'Ajax.svc/DoBibleSearch?Page=' + page + '&RecordsOnPage=' + opt.RecordsOnPage + '&BookFrom=' + MenuTools.BeginRangeButton.attr('BookID') +
                            '&BookTo=' + MenuTools.EndRangeButton.attr('BookID') + '&sTerm=' + ToolsBar.SearchKeyTextBox.text() + '&searchType=' + MenuTools.SearchTypeSelect.val() +
                            '&IsWholeWds=' + MenuTools.PartialCheck.checked() + '&CaseSensitive=' + MenuTools.CaseSensCheck.checked();
                },
                GetStrongsURL: function (page) {
                    return 'Ajax.svc/DoStrongsSearch?Page=' + page + '&RecordsOnPage=' + opt.RecordsOnPage + '&RangeUp=' + MenuTools.RangeSelect.val() +
                            '&sTerm=' + ToolsBar.SearchKeyTextBox.text() + '&searchType=' + MenuTools.SearchTypeSelect.val() +
                            '&IsWholeWds=' + MenuTools.PartialCheck.checked() + '&CaseSensitive=' + MenuTools.CaseSensCheck.checked();
                },
                GoSearch: function (page, newSearch) {
                    if (ToolsBar.SearchKeyTextBox.text() == '') return;
                    $.fancybox.showActivity();

                    $.ajax({
                        url: ToolsBar.SearchTypeButton.text() == opt.KJV ? SearchBody.GetKJVURL(page) : SearchBody.GetStrongsURL(page),
                        dataType: 'json',
                        cache: false,
                        success: function (data) {
                            $.fancybox.hideActivity();
                            if (data.d == null) return;
                            if (ToolsBar.SearchTypeButton.text() == opt.KJV) {
                                SearchBody.Data = data.d;
                                SearchBody.ShowKJVSearch();

                                if (SearchBody.Data.length == 0) {

                                    var textstatusbar = 'Verse Count: 0 Hit count: 0 Viewing: 0';
                                    StatusBar.UpdateStatusBar(textstatusbar);
                                    SearchBody.SearchBody.append('<div class="NoSearchResults">' + opt.NoResultSearch + '</div>');
                                    return;

                                }

                                if (newSearch) {
                                    SearchBody.CountPages = SearchBody.Data[0].index;
                                    SearchBody.AllRecords = SearchBody.Data[0].UnderlineVerse;
                                    SearchBody.AllSearchHitcount = SearchBody.Data[0].NumberVerse;
                                    ToolsBar2.CreatePages(SearchBody.CountPages, SearchBody.AllRecords);
                                    ToolsBar2.enablebuttons(1, SearchBody.CountPages);
                                }
                            } else {

                                SearchBody.Data = data.d;
                                SearchBody.ShowStrongsSearch();
                                if (SearchBody.Data.length == 0) {

                                    var textstatusbar = 'Verse Count: 0 Hit count: 0 Viewing: 0';
                                    StatusBar.UpdateStatusBar(textstatusbar);
                                    SearchBody.SearchBody.append('<div class="NoSearchResults">' + opt.NoResultSearch + '</div>');
                                    return;

                                }

                                if (newSearch) {
                                    SearchBody.CountPages = SearchBody.Data[0].TotalPages;
                                    SearchBody.AllRecords = SearchBody.Data[0].AllRecords;
                                    SearchBody.AllSearchHitcount = SearchBody.Data[0].AllSearchHitcount;
                                    ToolsBar2.CreatePages(SearchBody.CountPages, SearchBody.AllRecords);
                                    ToolsBar2.enablebuttons(1, SearchBody.CountPages);
                                }
                            }
                            //   SearchBody.ResizeContent();
                            var textstatusbar = 'Verse Count: ' + SearchBody.AllRecords + ' Hit count: ' + SearchBody.AllSearchHitcount + ' Viewing: ' + ToolsBar2.PageSelect.text();
                            StatusBar.UpdateStatusBar(textstatusbar);

                            setTimeout(function () {
                                ToolsBar.SearchKeyTextBox.focus();
                            }, 1000);
                        },
                        error: function showError() {
                            $.fancybox.hideActivity();

                            alert('error');

                        }
                    });
                },

                ShowKJVSearch: function () {
                    this.SearchBody.empty();
                    for (var i = 0; i < this.Data.length; i++) {

                        var scripture = $('<p class="SearchScripture"></p>').appendTo(this.SearchBody);
                        var verseIndicator = $('<a class="SearchVerseIndicatorLink"  BookName="' + this.Data[i].BookName + '" id="s' + this.Data[i].Indicator + '">' + this.Data[i].BookIndicator + '</a>').appendTo(scripture);
                        var scriptures = this.Data[i].scriptures;
                        var verseText = $('<span class="SearchVerseText" id="v' + this.Data[i].Indicator + '">' + scriptures + '</span>').appendTo(scripture);

                    }
                    this.SearchBody.find('.SearchVerseIndicatorLink').unbind('click');
                    this.SearchBody.find('.SearchVerseIndicatorLink').click(function () {
                        ScriptureWindow.Toolsbar.BookButton.text($(this).attr('BookName').split(' ')[0]);
                        var indicator = $(this).attr('id').substr(1, 100);
                        var sp = indicator.split(':');
                        ScriptureWindow.Toolsbar.BookButton.attr('BookID', sp[0]);
                        LoadCountChapters(sp[0]);
                        ScriptureWindow.Toolsbar.ChapterButton.text(sp[1]);
                        ScriptureWindow.LoadScripture(sp[0], sp[1], ToolsBar.SearchKeyTextBox.text(), sp[2], true, MenuTools.SearchTypeSelect.val(), MenuTools.CaseSensCheck.checked(), MenuTools.PartialCheck.checked());

                    });
                    ToolsBar2.showtooltip();
                },
                ShowStrongsSearch: function () {
                    this.SearchBody.empty();
                    for (var i = 0; i < this.Data.length; i++) {
                        var scripture = $('<p class="Strongs"></p>').appendTo(this.SearchBody);
                        var verseIndicator = $('<a class="StrongsIndicatorLink" id="' + this.Data[i].StrongsNumber + '">' + this.Data[i].StrongsNumber + '</a>').appendTo(scripture);
                        $('<span class="StrongsTransliteral" >' + this.Data[i].TransLit + '</span>').appendTo(scripture);
                        $('<span class="StrongsPhonetic">' + this.Data[i].Phonetic + '</span>').appendTo(scripture);
                        $('<span class="StrongsDefinition">' + this.Data[i].DefinitionAlso + '</span>').appendTo(scripture);
                        scripture.append(this.Data[i].DefinitionGo);

                        // $('<span class="StrongsDefinition" >' + this.Data[i].DefinitionGo + '</span>').appendTo(Scripture);
                    }
                    ToolsBar2.showtooltip();
                },
                CreateSearchBody: function (parent) {
                    this.SearchBody.appendTo(parent);
                },

                ResizeContent: function () {
                    var tabNavigationheight = rightDock.find('.tabNavigation').height();
                    this.SearchBody.css('height', this.SearchBody.parent().parent().parent().height() - tabNavigationheight - ToolsBar.Height - Options.Height - ToolsBar2.Height - MenuTools.Height - StatusBar.Height - SearchWindow.Header.height() - SearchWindow.Footer.height() - 72);
                }

            };
            var Options = {
                Height: 0,
                Options: $('<div class="OptionsCaption"/>'),
                isToogle: false,
                slideToggle: function () {
                    var interval = setInterval(function () {
                        MenuTools.MenuTools.height(MenuTools.Height);
                        SearchBody.ResizeContent();
                        if (!this.isToogle)
                            if (MenuTools.Height == 0) {
                                clearInterval(interval);
                                this.isToogle = true;
                            }
                            else { }
                        else
                            if (MenuTools.Height >= MenuTools.OriginalHeight) {
                                clearInterval(interval);
                                this.isToogle = false;
                            }
                        MenuTools.Height = MenuTools.Height - opt.StepToggle * (this.isToogle ? -1 : 1);
                    }, opt.SpeedToggle);
                },


                CreateOptions: function (parent) {
                    this.Options.appendTo(parent);
                    this.Options.text(opt.SearchOptionsCaption);
                    this.Height = this.Options.height();
                    this.Options.click(function () {
                        Options.slideToggle();
                    });
                }
            };

            var MenuTools = {
                Collapse: false,
                Height: 0,
                OriginalHeight: 0,
                MenuTools: $('<div class="MenuTools"></div'),
                SearchTypeSelect: DropDownList('SearchTypeSelect', opt.SearchTypeToolTip),
                RangeSelect: DropDownList('RangeSelect', opt.RangeSelectToolTip),

                RangeTr: null,
                CaseSensCheck: CheckBox('CaseSensCheck', opt.CaseSensitive),
                PartialCheck: CheckBox('PartialCheck', opt.PartialMatch),
                BeginRangeButton: Button('BeginRangeButton', opt.BeginRangeToolTip),
                EndRangeButton: Button('EndRangeButton', opt.EndRangeToolTip),
                AtachEvents: function () {
                    this.RangeSelect.change(function () {
                        switch ($(this).val()) {
                            case "0":
                                MenuTools.BeginRangeButton.text(opt.FirstBookShort);
                                MenuTools.BeginRangeButton.attr('BookID', opt.FirstBookID);
                                MenuTools.EndRangeButton.text(opt.LastBookShort);
                                MenuTools.EndRangeButton.attr('BookID', opt.LastBookID);
                                break;
                            case "1":
                                MenuTools.BeginRangeButton.text(opt.FirstBookShort);
                                MenuTools.BeginRangeButton.attr('BookID', opt.FirstBookID);
                                MenuTools.EndRangeButton.text(opt.EndOldTestamentShort);
                                MenuTools.EndRangeButton.attr('BookID', opt.EndOldTestamentID);
                                break;

                            case "2":
                                MenuTools.BeginRangeButton.text(opt.StartNewTestamentShort);
                                MenuTools.BeginRangeButton.attr('BookID', opt.StartNewTestamentID);
                                MenuTools.EndRangeButton.text(opt.LastBookShort);
                                MenuTools.EndRangeButton.attr('BookID', opt.LastBookID);
                                break;

                        }
                    });
                    this.BeginRangeButton.click(function () {
                        CreateBooksPopup();
                        popupMenu.find('.Item.Book').unbind('click');
                        popupMenu.find('.Item.Book').click(function () {
                            MenuTools.BeginRangeButton.text($(this).attr('BookShort'));
                            MenuTools.BeginRangeButton.attr('BookID', $(this).attr('BookID'));
                            if (MenuTools.EndRangeButton.attr('BookID') < $(this).attr('BookID')) {
                                MenuTools.EndRangeButton.text($(this).attr('BookShort'));
                                MenuTools.EndRangeButton.attr('BookID', $(this).attr('BookID'));
                            }
                        });
                        showPopupMenu($(this), -100, 0);
                        return false;
                    });

                    this.EndRangeButton.click(function () {
                        CreateBooksPopup();
                        popupMenu.find('.Item.Book').click(function () {

                            MenuTools.EndRangeButton.text($(this).attr('BookShort'));
                            MenuTools.EndRangeButton.attr('BookID', $(this).attr('BookID'));
                            if (MenuTools.BeginRangeButton.attr('BookID') > $(this).attr('BookID')) {
                                MenuTools.BeginRangeButton.text($(this).attr('BookShort'));
                                MenuTools.BeginRangeButton.attr('BookID', $(this).attr('BookID'));
                            }
                        });
                        showPopupMenu($(this), -150, 0);
                        return false;
                    });
                },
                CreateKJVRangeMenu: function () {
                    this.RangeSelect.empty();
                    this.RangeSelect.additem("0", opt.EntireBible, true);
                    this.RangeSelect.additem("1", opt.OldTestament, false);
                    this.RangeSelect.additem("2", opt.NewTestament, false);
                },
                CreateStrongsRangeMenu: function () {
                    this.RangeSelect.empty();
                    this.RangeSelect.additem("", opt.EntireDictionary, true);
                    this.RangeSelect.additem("H", opt.HebRew, false);
                    this.RangeSelect.additem("G", opt.Greek, false);
                },
                CreateMenuTools: function (parent) {
                    this.MenuTools.appendTo(parent);
                    this.SearchTypeSelect.additem("0", opt.AllWords, true);
                    this.SearchTypeSelect.additem("1", opt.AnyWords, false);
                    this.SearchTypeSelect.additem("2", opt.Phrases, false);
                    this.CreateKJVRangeMenu();
                    this.PartialCheck.checked(true);
                    var table = $('<table align="center"/>').appendTo(this.MenuTools);
                    var tr = $('<tr/>').appendTo(table);
                    var td = $('<td />').appendTo(tr);
                    td.html(opt.TypeCaption);
                    td = $('<td />').appendTo(tr);
                    td.html(opt.RangeCaption);
                    tr = $('<tr/>').appendTo(table);
                    td = $('<td />').appendTo(tr);
                    this.SearchTypeSelect.appendTo(td);
                    td = $('<td />').appendTo(tr);
                    this.RangeSelect.appendTo(td);
                    tr = $('<tr/>').appendTo(table);
                    td = $('<td colspan="2" />').appendTo(tr);
                    this.CaseSensCheck.appendTo(td);
                    tr = $('<tr/>').appendTo(table);
                    td = $('<td colspan="2" />').appendTo(tr);
                    this.PartialCheck.appendTo(td);
                    this.RangeTr = $('<tr/>').appendTo(table);
                    td = $('<td colspan="2" class="RangeTD" align="center" />').appendTo(this.RangeTr);
                    var d = $("<div/>");
                    this.BeginRangeButton.appendTo(d);
                    d.appendTo(td);
                    $('<div>--&gt;</div>').appendTo(td);
                    var d1 = $("<div/>");
                    this.EndRangeButton.appendTo(d1);
                    d1.appendTo(td);
                    this.Height = this.MenuTools.height();
                    this.OriginalHeight = this.MenuTools.height();
                    this.BeginRangeButton.text(opt.FirstBookShort);
                    this.BeginRangeButton.attr('BookID', opt.FirstBookID);
                    this.EndRangeButton.text(opt.LastBookShort);
                    this.EndRangeButton.attr('BookID', opt.LastBookID);
                    this.AtachEvents();
                }
            };
            var ToolsBar2 = {
                Height: 0,
                ToolsBar: $('<div class="ToolsBar ToolsBar2" />'),
                BackButton: ToolButton('Back', 'Back_Disabled', opt.BackToolTip),
                PageSelect: DropDownList('Page', opt.PageToolTip),
                ttRangeSelect: DropDownList('ttRange', opt.ttRangeToolTip),
                NextButton: ToolButton('Next', 'Next_Disabled', opt.NextToolTip),
                ToolTipButton: ToolButton('ToolTip', 'ToolTip_Disabled', opt.ToolTipToolTip),
                PrintButton: ToolButton('Print', 'Print_Disabled', opt.PrintToolTip),
                AtachEvents: function () {
                    this.BackButton.click(function () {
                        SearchBody.GoSearch(parseInt(ToolsBar2.PageSelect.val()) - 1, false);
                        ToolsBar2.enablebuttons(parseInt(ToolsBar2.PageSelect.val()) - 1, SearchBody.CountPages);
                        ToolsBar2.PageSelect.val(parseInt(ToolsBar2.PageSelect.val()) - 1);

                    });
                    this.PageSelect.change(function () {
                        SearchBody.GoSearch($(this).val(), false);
                        ToolsBar2.enablebuttons($(this).val(), SearchBody.CountPages);
                    });
                    this.NextButton.click(function () {
                        SearchBody.GoSearch(parseInt(ToolsBar2.PageSelect.val()) + 1, false);
                        ToolsBar2.enablebuttons(parseInt(ToolsBar2.PageSelect.val()) + 1, SearchBody.CountPages);
                        ToolsBar2.PageSelect.val(parseInt(ToolsBar2.PageSelect.val()) + 1);

                    });
                    this.ToolTipButton.click(function () {
                        ToolsBar2.ToolTipButton.toggle();
                        ToolsBar2.showtooltip();
                    });
                    this.PrintButton.click(function () {
                        SearchBody.SearchBody.printElement({
                            overrideElementCSS: ['../Css/PrintStyle.css']
                        });


                    });
                },
                showtooltip: function () {
                    if (ToolsBar.SearchTypeButton.text() == opt.KJV) {
                        SearchBody.SearchBody.find('.SearchVerseIndicatorLink').mouseover(function () {
                            if (ToolsBar2.ToolTipButton.isToggle()) {

                                var f = $(this);
                                clearTimeout(JTDelay);
                                JTDelay = setTimeout(function () {
                                    JT_show('ShowVerse.aspx?vRange=' + f.attr('id').substr(1, 100) + '&vCount=' + ToolsBar2.ttRangeSelect.val() + '&width=300',
                                        f.attr('id'), f.attr('BookName'), f.position().top);
                                }, 1000);
                            }
                            ;
                        });
                        SearchBody.SearchBody.find('.SearchVerseIndicatorLink').mouseout(function () {
                            if (ToolsBar2.ToolTipButton.isToggle())
                                clearTimeout(JTDelay);
                                JTDelay = setTimeout(function () {
                                    JTClose();
                                }, 100);

                        });
                        SearchBody.SearchBody.find('.SearchVerseIndicatorLink').click(function () {
                            if (ToolsBar2.ToolTipButton.isToggle())
                                JTClose();
                        });

                    }
                    else {
                        SearchBody.SearchBody.find('.strongslink').mouseover(function () {
                            if (ToolsBar2.ToolTipButton.isToggle()) {
                                var f = $(this);
                                clearTimeout(JTDelay);
                                JTDelay = setTimeout(function () {
                                    JT_show('ShowStrongs.aspx?Strongs=' + f.attr('Strong'),
                                        f.attr('id'), 'STRONG' + "'" + 'S ' + f.attr('Caption'), f.position().top);
                                }, 1000);
                            }

                        });
                        SearchBody.SearchBody.find('.strongslink').mouseout(function () {
                            if (ToolsBar2.ToolTipButton.isToggle())
                                clearTimeout(JTDelay);
                                JTDelay = setTimeout(function () {
                                    JTClose();
                                }, 1000);

                        });
                        SearchBody.SearchBody.find('.strongslink').click(function () {
                            if (ToolsBar2.ToolTipButton.isToggle())
                                JTClose();

                        });

                    }

                },
                disablebuttons: function () {
                    this.BackButton.disable();
                    this.PageSelect.disable();
                    this.NextButton.disable();
                    this.ttRangeSelect.disable();
                    this.ToolTipButton.disable();
                    this.PrintButton.disable();
                },
                enablebuttons: function (page, countPages) {
                    if (page > 1)
                        this.BackButton.enable();
                    else
                        this.BackButton.disable();
                    if (page < countPages)
                        this.NextButton.enable();
                    else
                        this.NextButton.disable();
                    this.PageSelect.enable();
                    this.ttRangeSelect.enable();
                    this.ToolTipButton.enable();
                    this.PrintButton.enable();
                },
                CreatePages: function (countPages, allRecords) {
                    this.PageSelect.empty();
                    for (var i = 1; i <= countPages; i++)
                        this.PageSelect.additem(i, ((i - 1) * opt.RecordsOnPage + 1) + "-" + (i * opt.RecordsOnPage < allRecords ? (i * opt.RecordsOnPage) : allRecords));
                },

                CreateToolBar: function (parent) {
                    this.ToolsBar.appendTo(parent);
                    this.BackButton.appendTo(this.ToolsBar);
                    this.PageSelect.appendTo(this.ToolsBar);
                    this.NextButton.appendTo(this.ToolsBar);
                    this.ttRangeSelect.appendTo(this.ToolsBar);
                    this.ToolTipButton.appendTo(this.ToolsBar);
                    this.PrintButton.appendTo(this.ToolsBar);
                    for (var i = 1; i <= opt.CountItemsTTRange; i++)
                        this.ttRangeSelect.additem(i, i, i == opt.DefaulItemTTRange);
                    this.disablebuttons();
                    this.AtachEvents();
                    this.Height = this.ToolsBar.height();
                }
            };

            var ToolsBar = {
                Height: 0,

                ToolsBar: $('<div class="ToolsBar ToolsBar1"/>'),
                CreateNewSearchButton: ToolButton('NewSearch', 'NewSearch_Disabled', opt.CreateNewSearchWindowToolTip),
                SearchTypeButton: ToolButton('SearchType', 'SearchType_Disabled', opt.SearchTypeToolTip),
                SearchKeyTextBox: TextBox('SearchKey', opt.SearchKeyToolTip),
                GoSearchButton: ToolButton('GoSearch', 'GoSearch_Disabled', opt.GoSearchToolTip),
                ResizeSearchKeyTextBox: function () {
                    var width = this.ToolsBar.width() - this.CreateNewSearchButton.width() - this.SearchTypeButton.width() - this.GoSearchButton.width() - 15;
                    this.SearchKeyTextBox.width(width);

                },
                CreateSearchTypePopup: function () {
                    popupMenu.empty();

                    var column = $('<div  style="float:left"></div>').appendTo(popupMenu);
                    $('<div class="Item SearchTypeItem">' + opt.KJV + '</div>').appendTo(column);
                    $('<div class="Item SearchTypeItem">' + opt.Strongs + '</div>').appendTo(column);

                    popupMenu.find('.Item.SearchTypeItem').unbind('click');
                    popupMenu.find('.Item.SearchTypeItem').click(function () {
                        ToolsBar.SearchTypeButton.text($(this).text());
                        if ($(this).text() == opt.KJV) {
                            MenuTools.CreateKJVRangeMenu();
                            MenuTools.RangeTr.show();
                            ToolsBar2.ttRangeSelect.show();
                        }
                        else {
                            MenuTools.CreateStrongsRangeMenu();
                            MenuTools.RangeTr.hide();
                            ToolsBar2.ttRangeSelect.hide();
                        }

                    });
                },

                CreateToolBar: function (parent) {
                    this.ToolsBar.appendTo(parent);
                    this.CreateNewSearchButton.appendTo(this.ToolsBar);
                    this.SearchTypeButton.appendTo(this.ToolsBar);
                    this.SearchTypeButton.text(opt.KJV);
                    this.SearchKeyTextBox.appendTo(this.ToolsBar);
                    this.GoSearchButton.appendTo(this.ToolsBar);
                    this.Height = this.ToolsBar.height();
                    this.AtachEvents();
                },


                AtachEvents: function () {
                    this.GoSearchButton.click(function () {
                        SearchBody.GoSearch(1, true);


                    });
                    this.CreateNewSearchButton.click(function () {
                        SearchWindow.CreateSearchWindow();

                    });
                    this.SearchTypeButton.click(function () {
                        ToolsBar.CreateSearchTypePopup();
                        showPopupMenu($(this), 0, 0);
                        return false;
                    });

                    this.SearchKeyTextBox.keypress(function (e) {
                        if (e.keyCode == 13) {
                            SearchBody.GoSearch(1, true);
                            return false;
                        }
                        return true;
                    });

                }
            };
            ToolsBar.CreateToolBar(parent);
            Options.CreateOptions(parent);
            MenuTools.CreateMenuTools(parent);
            ToolsBar2.CreateToolBar(parent);
            SearchBody.CreateSearchBody(parent);
            StatusBar.CreateStatusBar(parent);

        };
        var SearchWindow =
    {
        Header: $('<div class="ContentHeader">' + opt.SearchHeader + '</div>'),
        Footer: $('<div class="ContentFooter"/>'),

        Tabs: {
            Tabs: $('<ul class="tabNavigation">'),
            TabContent: $('<div class="tabContent"/>')


        },
        ResizeSearchWindow: function () {
            this.Tabs.TabContent.height(this.Tabs.TabContent.parent().height() - this.Tabs.Tabs.height() - SearchWindow.Header.height() - SearchWindow.Footer.height() - 29);
            for (var i = 0; i < this.SearchWindows.length; i++)
                this.SearchWindows[i].ResizeContent();
        },
        CreateHeader: function (parent) {

            this.Header.appendTo(parent);
        },
        CreateFooter: function (parent) {

            this.Footer.appendTo(parent);
        },
        CreateSearchWindow: function () {
            var ID = SearchWindow.Tabs.Tabs.children().length + 1;
            var li = $('<li><span id="' + (opt.SearchCaption + ID) + '">' + (opt.SearchCaption + ID) + '</span></li>').appendTo(SearchWindow.Tabs.Tabs);
            var contentwindow = $('<div class="' + (opt.SearchCaption + ID) + ' tabContentBox"/>').appendTo(SearchWindow.Tabs.TabContent);

            this.SearchWindows[ID - 1] = $.extend(true, [], new SearchWindowContent(contentwindow));
            rightDock.simpleTabs(':last');
            SearchWindow.SearchWindows[ID - 1].ResizeContent();
            this.SearchWindows[ID - 1].ResizeToolsBar();
        },
        CurrentSearchWindow: function () {
            return this.SearchWindows[SearchWindow.Tabs.Tabs.find('.selected').parent().index()];
        },
        SearchWindows: new Array()

    };
        var leftDock = null;
        var rightDock = null;
        popupMenu = $('<div class="PopupMenu"></div>').appendTo('body');
        showPopupMenu = function (parent, offsetLeft, offsetTop) {
            popupMenu.css({ position: 'absolute', top: parent.offset().top + parent.height() + offsetTop, left: parent.offset().left + offsetLeft });
            popupMenu.show();
        };
        CreateBooksPopup = function () {
            popupMenu.empty();

            var column = $('<div  style="float:left"></div>').appendTo(popupMenu);
            var i;
            for (i = 0; i < 20; i++) {
                $('<div class="Item Book" BookShort="' + books[i].ShortName + '" BookID="' + books[i].ID + '">' + books[i].Name + '</div>').appendTo(column);
            }
            column = $('<div  style="float:left; padding-right:5px" ></div>').appendTo(popupMenu);
            for (i = 20; i < 39; i++) {
                $('<div class="Item Book" BookShort="' + books[i].ShortName + '"  BookID="' + books[i].ID + '">' + books[i].Name + '</div>').appendTo(column);
            }
            column = $('<div  style="float:left; border-left:1px solid lightgrey; padding-left:10px;"></div>').appendTo(popupMenu);
            for (i = 39; i < 59; i++) {
                $('<div class="Item Book" BookShort="' + books[i].ShortName + '"  BookID="' + books[i].ID + '">' + books[i].Name + '</div>').appendTo(column);
            }
            column = $('<div  style="float:left"></div>').appendTo(popupMenu);
            for (i = 59; i < 66; i++) {
                $('<div class="Item Book" BookShort="' + books[i].ShortName + '"  BookID="' + books[i].ID + '">' + books[i].Name + '</div>').appendTo(column);
            }

        };
        CreateChaptersPopup = function () {
            popupMenu.empty();
            var column = $('<div  style="float:left"></div>').appendTo(popupMenu);
            var i = 1;
            while (i <= ScriptureWindow.Toolsbar.CountChapters) {

                var j = 1;
                while ((j <= 20) && (i <= ScriptureWindow.Toolsbar.CountChapters)) {
                    $('<div class="Item Chapter">' + i + '</div>').appendTo(column);
                    j++;
                    i++;
                }
                if (i < ScriptureWindow.Toolsbar.CountChapters)
                    column = $('<div  style="float:left"></div>').appendTo(popupMenu);
            }
            popupMenu.find('.Item.Chapter').unbind('click');
            popupMenu.find('.Item.Chapter').click(function () {
                ScriptureWindow.Toolsbar.ChapterButton.text($(this).text());
                ScriptureWindow.LoadScripture(ScriptureWindow.Toolsbar.BookButton.attr('BookID'), $(this).text(), '',
                        -1, false, 0, false, false);
            });

        };
        CreateStrongsLinksPopup = function () {
            popupMenu.empty();
            var column = $('<div  style="float:left"></div>').appendTo(popupMenu);
            $('<div class="Item StrongsLink" View="0">' + opt.None + '</div>').appendTo(column);
            $('<div class="Item StrongsLink" View="1">' + opt.ShowLinks + '</div>').appendTo(column);
            $('<div class="Item StrongsLink" View="2">' + opt.ShowNumbers + '</div>').appendTo(column);
            popupMenu.find('.Item.StrongsLink').unbind('click');
            popupMenu.find('.Item.StrongsLink').click(function () {
                ScriptureWindow.View = $(this).attr('View');
                ScriptureWindow.ShowListScriptures(-1, ScriptureWindow.Toolsbar.BookButton.text() + ' ' + ScriptureWindow.Toolsbar.ChapterButton.text());

            });
        };
        LoadCountChapters = function (bookID) {
            $.ajax({
                url: 'Ajax.svc/GetCountChapters?BookID=' + bookID,
                dataType: 'json',
                success: function (data) {
                    if (data.d == null) return;
                    ScriptureWindow.Toolsbar.CountChapters = data.d;

                },
                error: function showError() {
                    alert('error');

                }
            });
        };
        LoadListBooks = function () {
            $.ajax({
                url: 'Ajax.svc/GetListBooks',
                dataType: 'json',
                success: function (data) {
                    if (data.d == null) return;
                    if (data.d.length == 0) return;
                    books = data.d;
                    ScriptureWindow.Toolsbar.BookButton.text(books[book - 1].Name);

                },
                error: function showError() {
                    alert('error');

                }
            });
        };
        killAllMenus = function () {
            popupMenu.hide();
        };
        var books = null;
        var loadingPanel = $("<div class='ScripturesLoading'/>'").appendTo('body');

        var ScriptureWindow = {
            Header: $('<div class="ContentHeader">' + opt.ScripturesHeader + '</div>'),
            Footer: $('<div class="ContentFooter" />'),
            CreateHeader: function (parent) {

                this.Header.appendTo(parent);
            },
            CreateFooter: function (parent) {

                this.Footer.appendTo(parent);
            },
            Toolsbar: {
                CountChapters: 1,
                BookButton: ToolButton('Book', 'Book_Disabled', opt.BookToolTip),
                ChapterButton: ToolButton('Chapter', 'Chapter_Disabled', opt.ChapterToolTip),
                BackButton: ToolButton('Back', 'Back_Disabled', opt.BackToolTip),
                NextButton: ToolButton('Next', 'Next_Disabled', opt.NextToolTip),
                StrongsLinksButton: ToolButton('StrongsLinks', 'StrongsLinks_Disabled', opt.TypeViewToolTip),
                SearchButton: ToolButton('Search', 'Search_Disabled', opt.SearchToolTip),
                PrintButton: ToolButton('Print', 'Print_Disabled', opt.PrintToolTip),
                ToolsBar: $('<div class="ToolsBar ScriptureWindow"/>'),
                CreateToolBar: function (parent) {
                    this.ToolsBar.appendTo(parent);
                    this.BookButton.appendTo(this.ToolsBar);
                    this.ChapterButton.appendTo(this.ToolsBar);
                    this.BackButton.appendTo(this.ToolsBar);
                    this.NextButton.appendTo(this.ToolsBar);
                    this.StrongsLinksButton.appendTo(this.ToolsBar);
                    this.SearchButton.appendTo(this.ToolsBar);
                    this.PrintButton.appendTo(this.ToolsBar);

                },

                LoadScripture: function (book, chapter, searchWds, searchVerse, hiLiteVerse, searchType, caseSens, partMatch) {
                    this.BookButton.attr('BookID', book);
                    this.ChapterButton.text(chapter);
                    LoadCountChapters(book);
                    ScriptureWindow.LoadScripture(book, chapter, searchWds, searchVerse, hiLiteVerse, searchType, caseSens, partMatch);

                },

                AtachEvents: function () {

                    this.BookButton.click(function () {
                        CreateBooksPopup();
                        popupMenu.find('.Item.Book').unbind('click');
                        popupMenu.find('.Item.Book').click(function () {
                            LoadCountChapters($(this).attr('BookID'));
                            ScriptureWindow.Toolsbar.BookButton.text($(this).text());
                            ScriptureWindow.Toolsbar.BookButton.attr('BookID', $(this).attr('BookID'));
                            ScriptureWindow.Toolsbar.ChapterButton.text('1');
                            ScriptureWindow.LoadScripture($(this).attr('BookID'), 1, '', -1, false, 0, false, false);

                        });
                        showPopupMenu($(this), 0, 0);
                        return false;
                    });

                    this.ChapterButton.click(function () {
                        CreateChaptersPopup();
                        showPopupMenu($(this), 0, 0);
                        return false;
                    });
                    this.StrongsLinksButton.click(function () {
                        CreateStrongsLinksPopup();
                        showPopupMenu($(this), 0, 0);
                        return false;
                    });
                    this.BackButton.click(function () {
                        var chapter = ScriptureWindow.Toolsbar.ChapterButton.text();
                        chapter--;
                        if (chapter >= 1) {
                            ScriptureWindow.LoadScripture(ScriptureWindow.Toolsbar.BookButton.attr('BookID'), chapter, '', -1,
                                    false, 0, false, false);
                            ScriptureWindow.Toolsbar.ChapterButton.text(chapter);

                        }
                        return false;
                    });

                    this.PrintButton.click(function () {
                        ScriptureWindow.ScriptureWindow.printElement({
                            overrideElementCSS: ['../Css/PrintStyle.css']
                        });


                    });
                    this.NextButton.click(function () {
                        var chapter = ScriptureWindow.Toolsbar.ChapterButton.text();
                        chapter++;
                        if (chapter <= ScriptureWindow.Toolsbar.CountChapters) {
                            ScriptureWindow.LoadScripture(ScriptureWindow.Toolsbar.BookButton.attr('BookID'), chapter, '', -1, false, 0, false, false);
                            ScriptureWindow.Toolsbar.ChapterButton.text(chapter);
                        }
                        return false;
                    });
                    this.SearchButton.click(function () {
                        void (leftDock.parent().trigger('toggleDock'));



                    });
                }

            },

            ScriptureWindow: $('<div class="BiblePage"/>'),
            Scriptures: null,
            View: "0",
            GetHeightWindow: function () {
                return this.ScriptureWindow.parent().height() - this.Toolsbar.ToolsBar.height() - ScriptureWindow.Header.height() - ScriptureWindow.Footer.height() - 47;
            },
            ResizeScriptureWindow: function () {
                //  ScriptureWindow.Toolsbar.BookButton.text(ScriptureWindow.Header.height());
                this.ScriptureWindow.height(ScriptureWindow.GetHeightWindow());
            },
            CreateScriptureWindow: function (parent) {
                this.ScriptureWindow.appendTo(parent);
                //  this.ScriptureWindow.css({ 'height':ScriptureWindow.GetHeightWindow() });
            },
            ShowListScriptures: function (selectVerse, headerText) {
                ScriptureWindow.ScriptureWindow.empty();

                $('<p class="Scripture ChapterHeading"></p>').append(headerText).appendTo(ScriptureWindow.ScriptureWindow);



                for (var i = 0; i < ScriptureWindow.Scriptures.length; i++) {
                    var scripture = $('<p class="' + (ScriptureWindow.Scriptures[i].Verse != selectVerse ? 'Scripture' : 'SearchVerseHighlight') + '"></p>').appendTo(ScriptureWindow.ScriptureWindow);

                    var verseText;
                    var scriptures;
                    var verseIndicator = $('<span class="VerseIndicator" id="' + ScriptureWindow.Scriptures[i].Indicator + '">' + ScriptureWindow.Scriptures[i].BookIndicator + '</span>').appendTo(scripture);
                    switch (ScriptureWindow.View) {
                        case "0":
                            scriptures = ScriptureWindow.Scriptures[i].scriptures;
                            verseText = $('<span class="VerseText" id="v' + ScriptureWindow.Scriptures[i].Indicator + '">' + scriptures + '</span>').appendTo(scripture);
                            break;
                        case "1":
                            scriptures = ScriptureWindow.Scriptures[i].UnderlineVerse;
                            verseText = $('<span class="VerseText" id="v' + ScriptureWindow.Scriptures[i].Indicator + '">' + scriptures + '</span>').appendTo(scripture);
                            break;
                        case "2":
                            scriptures = ScriptureWindow.Scriptures[i].NumberVerse;
                            verseText = $('<span class="VerseText" id="v' + ScriptureWindow.Scriptures[i].Indicator + '">' + scriptures + '</span>').appendTo(scripture);
                            break;
                    }
                }
                if (ScriptureWindow.ScriptureWindow.find('.SearchVerseHighlight .VerseIndicator').length > 0)
                    ScriptureWindow.ScriptureWindow.scrollTop(ScriptureWindow.ScriptureWindow.find('.SearchVerseHighlight .VerseIndicator').position().top + ScriptureWindow.ScriptureWindow.find('.SearchVerseHighlight').parent().scrollTop() - ScriptureWindow.ScriptureWindow.find('.SearchVerseHighlight').parent().height() + 50);


                switch (ScriptureWindow.View) {
                    case "1":
                        ScriptureWindow.ScriptureWindow.find('.strongslink').mouseover(function () {
                            var f = $(this);
                            clearTimeout(JTDelay);
                            JTDelay = setTimeout(function () {
                                JT_show('ShowStrongs.aspx?Strongs=' + f.attr('Strong'), f.attr('id'), f.attr('Caption'), f.position().top);
                            }, 1000);
                        });
                        ScriptureWindow.ScriptureWindow.find('.strongslink').mouseout(function () {
                            clearTimeout(JTDelay);
                            JTDelay = setTimeout(function () {
                                JTClose();
                            }, 100);
                        });

                        ScriptureWindow.ScriptureWindow.find('.strongslink').click(function () {
                            JTClose();

                        });

                        break;
                    case "2":

                        ScriptureWindow.ScriptureWindow.find('.strongslink_numbers').mouseover(function () {
                            var f = $(this);
                            clearTimeout(JTDelay);
                            JTDelay = setTimeout(function () {
                                JT_show('ShowStrongs.aspx?Strongs=' + f.attr('Strong'), f.attr('id'), f.attr('Caption'), f.position().top);
                            }, 1000);
                        });
                        ScriptureWindow.ScriptureWindow.find('.strongslink_numbers').mouseout(function () {
                            clearTimeout(JTDelay);
                            JTDelay = setTimeout(function () {
                                JTClose();
                            }, 1000);
                        });
                        ScriptureWindow.ScriptureWindow.find('.strongslink_numbers').click(function () {
                            JTClose();

                        });

                        break;

                }
            },
            LoadScripture: function (bookID, chapter, searchWds, searchVerse, hiLiteVerse, searchType, caseSens, partMatch) {
                $.fancybox.showActivity();
                $.ajax({
                    url: 'Ajax.svc/GetListBibles?BookID=' + bookID + '&Chapter=' + chapter + '&searchWds=' + searchWds + '&searchVerse=' + searchVerse + '&HiLiteVerse=' + hiLiteVerse + '&SearchType=' + searchType + '&caseSens=' + caseSens + '&partMatch=' + partMatch,
                    dataType: 'json',
                    success: function (data) {
                        if (data.d == null) return;
                        if (data.d.length == 0) return;
                        ScriptureWindow.Scriptures = data.d;
                        ScriptureWindow.ShowListScriptures(searchVerse, books[bookID - 1].Name + ' ' + ScriptureWindow.Toolsbar.ChapterButton.text());
                        //                        ScriptureWindow.Header.text(Books[BookID - 1].Name + ' ' + Chapter);
                        $.fancybox.hideActivity();

                    },
                    error: function showError() {
                        $.fancybox.hideActivity();

                        alert('error');
                    }
                });
            }

        };
        CreateDocks = function (parent) {
            leftDock = $('<div/>');
            rightDock = $('<div/>');
            leftDock.appendTo(parent);
            rightDock.appendTo(parent);
            rightDock.resize(function () {
                if (rightDock.width() == 0) {
                    SearchWindow.Tabs.Tabs.hide();
                    SearchWindow.Tabs.TabContent.hide();
                    SearchWindow.Footer.hide();
                    SearchWindow.Header.hide();

                }
                else {
                    SearchWindow.Tabs.Tabs.show();
                    SearchWindow.Tabs.TabContent.show();
                    SearchWindow.Footer.show();
                    SearchWindow.Header.show();
                }
                var index = $(this).find('.tabNavigation .selected').parent().index();
                if (index == -1) return;
                var width = rightDock.find('.ToolsBar.ToolsBar1')[index].offsetWidth - rightDock.find('.ToolsBar .NewSearch')[index].offsetWidth - rightDock.find('.ToolsBar .SearchType')[index].offsetWidth - rightDock.find('.ToolsBar .GoSearch')[index].offsetWidth - 15;
                rightDock.find('.ToolsBar .SearchKey').width(width);
            });
            parent.splitter({
                type: "v",
                outline: true,
                sizeLeft: opt.sizeLeft,
                minLeft: opt.minLeft,
                minRight: opt.minRight,
                resizeToWidth: true,
                resizeTo: window,
                anchorToWindow: true,
                dock: "right",
                dockSpeed: opt.dockSpeed,
                dockKey: 'Z',
                accessKey: 'I'
            });
        };
        CreateLeftDock = function (parent) {
            ScriptureWindow.CreateHeader(parent);
            ScriptureWindow.Toolsbar.CreateToolBar(parent);
            ScriptureWindow.CreateScriptureWindow(parent);
            ScriptureWindow.CreateFooter(parent);

            ScriptureWindow.ResizeScriptureWindow();

            LoadListBooks();
            ScriptureWindow.Toolsbar.AtachEvents();
        };
        CreateRightDock = function (parent) {
            SearchWindow.CreateHeader(parent);
            SearchWindow.Tabs.Tabs.appendTo(parent);
            SearchWindow.Tabs.TabContent.appendTo(parent);
            SearchWindow.CreateFooter(parent);
            SearchWindow.CreateSearchWindow();

            //    SearchWindow.ResizeSearchWindow();
        };
        return this.each(function () {
            var parent = $(this);
            CreateDocks(parent);
            CreateLeftDock(leftDock);
            ScriptureWindow.Toolsbar.LoadScripture(book, chapter, '', selectVerse, false, 0, false, false);
            CreateRightDock(rightDock);
            if (searchKey != '') {
                var searchwindow = SearchWindow.CurrentSearchWindow();
                searchwindow.SetKeySearch(searchKey);
                searchwindow.GoSearch(1, true);
            }
            $(document).click(killAllMenus);
            $(window).resize(function () {
                ScriptureWindow.ResizeScriptureWindow();
                SearchWindow.ResizeSearchWindow();
            });


        });

    };
})(jQuery);
