﻿$(function () {
    //use a unique name to register the user control
    LoadScruptureWindow = function (Book, Chapter, Verse, Searchkey) {
        $("#Scriptures").scriptures({}, Book, Chapter, Verse, Searchkey);
    };
    $.dynamicLoader.registerUC('Scriptures', function (ctx, self) {
        $.event.trigger('ready', ctx, self);
        jQuery(document).ready(function () {
            ShowPanels('scriptures');
            var sp = null;
            var Searchkey = '';

            if (currenthash.indexOf("/Scripture/") > 0) {
                var selectverse = currenthash.substr(currenthash.indexOf("/Scripture/") + 11, 100);
                sp = selectverse.split(':');
                LoadScruptureWindow(sp[0], sp[1], sp[2], '');
            }
            else

                if (currenthash.indexOf("/SearchKey/") > 0) {
                    Searchkey = currenthash.substr(currenthash.indexOf("/SearchKey/") + 11, 100);
                    LoadScruptureWindow(1, 1, -1, Searchkey);
                }
                else
                    $.ajax({
                        url: 'Ajax.svc/GetVerseFromSession',
                        dataType: 'json',
                        success: function (data) {
                            sp = data.d.split(':');
                            LoadScruptureWindow(sp[0], sp[1], -1, '');

                        },
                        error: function showError() {
                            alert('error');

                        }
                    });
        });
    });
});

