var ts;
function setTab(id) {

    ts.select($("#" + id)[0]);
    console.log("test "+id);

}
function showShelf(id) {$(id).show();}

function setShelf(s) {

    if (ews && ews.Editor) {
        ews.Editor.NextLoadJavascript("showShelf('" + s + "')");
        ews.Editor.Layout();
    }
}

$(document).ready(function () {

    if ($("#tabs").length > 0) {
        ts = new Tabs($i("tabs"));
        ts.setContent($i("tab_one"), $i("content_one"));
        ts.setContent($i("tab_two"), $i("content_two"));
        ts.setContent($i("tab_three"), $i("content_three"));
        //ts.select($i("tab_two"));
    }

    $('#content_two>div.inner>div:first-child').hide();

    $("#contact-us-link").click(function () {
        $("#shelf-two").hide('slow');
        $("#shelf-one").toggle('slow', function () {
            setShelf("#shelf-one");
        });
        $("#ministry-index-link").parent().parent().removeClass('active');
        $("#ministry-index-link").toggle('slow');
        $("#my-northside-link").toggle('slow');
        $(this).parent().parent().toggleClass('active');




    });
    $("#ministry-index-link").click(function () {
        $("#shelf-one").hide('slow');
        $("#shelf-two").toggle('slow', function () {
            setShelf("#shelf-two");
        });
        $("#contact-us-link").parent().parent().removeClass('active');
        $("#contact-us-link").toggle('slow');
        $("#my-northside-link").toggle('slow');
        $(this).parent().parent().toggleClass('active');




    });

    if ($('#content_two').length > 0) {
        $('#content_two li').each(function () {
            var thedate = $(this).find('.event-date').text().split(" ");
            var thedateMod = thedate[0].split("/ ");

            if (thedateMod.length > 0) {
                $(this).find('.event-date').text(thedateMod[0]);
            }
            else {
                $(this).find('.event-date').text(thedate[0]);
            }


            if (thedate[1].charAt(0) == "0") {
                var thenumtime = thedate[1].substring(1);
            }
            else {
                var thenumtime = thedate[1];
            }



            thenumtime = thenumtime.slice(0, thenumtime.length - 3);
            $(this).find('.event-start').text(thenumtime + " " + thedate[2] + " - ");


            var theenddate = $(this).find('.event-end').text().split(" ");

            if (theenddate[1].charAt(0) == "0") {
                var thenumendtime = theenddate[1].substring(1);
            }
            else {
                var thenumendtime = theenddate[1];
            }
            thenumendtime = thenumendtime.slice(0, thenumendtime.length - 3);
            $(this).find('.event-end').text(thenumendtime + " " + theenddate[2]);
        });
    }

    //closes lightbox
    $('.closeLink').click(function () {
        $('div.shadow').hide();
    });
});
