﻿var LimelightIntegration = {
    IntegrationUrl: window.location.protocol + "//" + window.location.host  + "/Connect/Limelight/Integration.ashx",
    synchronise: function (settingItemId, ajaxParameters) {
        var params = "settingItemId=" + settingItemId + ajaxParameters;
        var http = new XMLHttpRequest();
        http.open("POST", LimelightIntegration.IntegrationUrl, true);
        http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
        http.setRequestHeader("Content-length", params.length);
        http.setRequestHeader("Connection", "close");
        http.onreadystatechange = function () {
            if (http.readyState == 4 && http.status == 200) {
                LimelightIntegration._onsuccess(eval(http.responseText));
            }
        }
        http.send(params);
    },
    _onsuccess: function (result) {
        if (result != "" && result != undefined && result != null && result.length && result.length > 0 && result[0].ClientId != "") {
            for (i = 0; i < result.length; i++) {
                document.getElementById(result[i].ClientId).innerHTML = result[i].InnerHtml;
            }
        }
    },
    _onerror: function (err) {
        alert(err);
    }
}

