﻿var requestUrl = "../Services/BlogService.asmx/GetBlogContent";

$(document).ready(function () {
    $("#ulBlogTree").treeview();

    try {
        //grab the first li and make the render call
        $("li[onclick]:first").click();
        return;
    } catch (e) { }
});

function loadPost(url, title) {
    var jsonObjectArray = new Array();
    jsonObjectArray.push(new dataRequestObject(name = "url", value = url, dataType = "string"));
    jsonObjectArray.push(new dataRequestObject(name = "companyName", value = FitLogVars.companyName, dataType = "string"));

    try {
        $.ajax({
            type: "POST",
            contentType: 'application/json; charset=utf-8',
            url: requestUrl,
            data: buildJSONDataRequest(jsonObjectArray),
            dataType: 'json',
            success: function (result, status) {
                try {
                    updatedValue = result.d;
                    $("#divBlogContainer").html(updatedValue);
                    $("#divBlogContainerTitle").html(title);
                } catch (e) {
                    showAlert("ERROR " + e.message);
                }
            },
            error: function (xhr, textStatus, errorThrown) {
                // typically only one of textStatus or errorThrown 
                // will have info
                showAlert(xhr.responseText);
            }

        });
    } catch (e) {
        showAlert(e.message);
    }
}



