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 () {

    $('#ews_shelf_link').click(function (event) {
        $('#top-shelf').slideToggle('slow', function () { setShelf("#top-shelf"); });
    });

    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"));
    }
    $("#tab_one").click(function () {
        ews.Editor.NextLoadJavascript("ts.select($i('tab_one'));");
        ews.Editor.Layout();
    });

    $("#tab_two").click(function () {
        ews.Editor.NextLoadJavascript("ts.select($i('tab_two'));");
        ews.Editor.Layout();
    });

    $("#tab_three").click(function () {
        ews.Editor.NextLoadJavascript("ts.select($i('tab_three'));");
        ews.Editor.Layout();
    });


    $('#ewsmenu_submenu li:has(ul)>a').click(function () {
        $(this).next().toggle('slow');
        return false;
    }).next().hide();

    $('#ewsmenu_submenu li.selected>ul').css("display", "block");

}); 
