﻿// DashboardFramework.js
//


Type.registerNamespace('PPSMA');

////////////////////////////////////////////////////////////////////////////////
// PPSMA._cancellableState

PPSMA._cancellableState = function() { };
PPSMA._cancellableState.prototype = {
    initialized: 0, 
    updating: 1, 
    stopped: 2
}
PPSMA._cancellableState.registerEnum('PPSMA._cancellableState', false);


////////////////////////////////////////////////////////////////////////////////
// PPSMA._parameterRecord

PPSMA.$create__parameterRecord = function PPSMA__parameterRecord(dashboardItemId, parameterId, definition) {
    var $o = { };
    $o.dashboardItemId = dashboardItemId;
    $o.parameterId = parameterId;
    $o.definition = definition;
    $o.proxyVisibleDependency = null;
    $o.proxyRenderDependency = null;
    return $o;
}


////////////////////////////////////////////////////////////////////////////////
// PPSMA._renderBindingRecord

PPSMA.$create__renderBindingRecord = function PPSMA__renderBindingRecord(id, beginPointId, beginPpointParameterId) {
    var $o = { };
    $o.id = id;
    $o.beginPointId = beginPointId;
    $o.parameterId = beginPpointParameterId;
    return $o;
}


////////////////////////////////////////////////////////////////////////////////
// PPSMA._visibleBindingRecord

PPSMA.$create__visibleBindingRecord = function PPSMA__visibleBindingRecord(id, beginPointId, beginPointParameterId, visibleValues) {
    var $o = { };
    $o.id = id;
    $o.beginPointId = beginPointId;
    $o.parameterId = beginPointParameterId;
    var dictionary = {};
    for (var i = 0; i < visibleValues.length; ++i) {
        var value = visibleValues[i];
        dictionary[value] = '';
    }
    $o.visibleValues = dictionary;
    return $o;
}


////////////////////////////////////////////////////////////////////////////////
// PPSMA._proxyMapRecord

PPSMA.$create__proxyMapRecord = function PPSMA__proxyMapRecord(proxyId) {
    var $o = { };
    $o.proxyId = proxyId;
    $o.proxyDisplayTitle = '';
    $o.visibleDependency = null;
    $o.proxyBeginPoints = [];
    $o.viewProxy = null;
    $o.viewManager = null;
    return $o;
}


////////////////////////////////////////////////////////////////////////////////
// PPSMA._webRequestDetails

PPSMA.$create__webRequestDetails = function PPSMA__webRequestDetails(url, body, httpVerb, contentType, completedCallback) {
    var $o = { };
    $o.url = url;
    $o.body = body;
    $o.httpVerb = httpVerb;
    $o.contentType = contentType;
    $o.completedCallback = completedCallback;
    return $o;
}


////////////////////////////////////////////////////////////////////////////////
// PPSMA._parameterState

PPSMA._parameterState = function() { };
PPSMA._parameterState.prototype = {
    pendingChange: 1, 
    changed: 2
}
PPSMA._parameterState.registerEnum('PPSMA._parameterState', false);


////////////////////////////////////////////////////////////////////////////////
// PPSMA._parameterMessage

PPSMA.$create__parameterMessage = function PPSMA__parameterMessage(mappingId, publisherDashboardItemId, publisherParameterUniqueName) {
    var $o = { };
    $o.mappingId = mappingId;
    $o.dashboardItemId = publisherDashboardItemId;
    $o.parameterUniqueName = publisherParameterUniqueName;
    return $o;
}


////////////////////////////////////////////////////////////////////////////////
// PPSMA._proxyVisibleState

PPSMA._proxyVisibleState = function() { };
PPSMA._proxyVisibleState.prototype = {
    pendingVisible: 1, 
    visible: 2, 
    hidden: 3
}
PPSMA._proxyVisibleState.registerEnum('PPSMA._proxyVisibleState', false);


////////////////////////////////////////////////////////////////////////////////
// PPSMA.CommonContainerType

PPSMA.CommonContainerType = function() { };
PPSMA.CommonContainerType.prototype = {
    autosize: 0, 
    autoWidth: 1, 
    autoHeight: 2, 
    explicit: 3, 
    undefined: -1
}
PPSMA.CommonContainerType.registerEnum('PPSMA.CommonContainerType', false);


////////////////////////////////////////////////////////////////////////////////
// PPSMA._cancellableWebRequest

PPSMA._cancellableWebRequest = function PPSMA__cancellableWebRequest(containerElement) {
    this._state$1 = PPSMA._cancellableState.initialized;
    PPSMA._cancellableWebRequest.initializeBase(this);
    this._createPendingRequestUI$1(containerElement);
}
PPSMA._cancellableWebRequest.prototype = {
    _pendingTextContainer$1: null,
    _actionHyperlinkElement$1: null,
    _pendingTextElement$1: null,
    _webRequestDetails$1: null,
    
    dispose: function PPSMA__cancellableWebRequest$dispose() {
        if (this._actionHyperlinkElement$1) {
            this.hide();
            Sys.UI.DomEvent.clearHandlers(this._actionHyperlinkElement$1);
            this._pendingTextContainer$1 = null;
            this._pendingTextElement$1 = null;
            this._actionHyperlinkElement$1 = null;
        }
        PPSMA._cancellableWebRequest.callBaseMethod(this, 'dispose');
    },
    
    _createPendingRequestUI$1: function PPSMA__cancellableWebRequest$_createPendingRequestUI$1(viewContainerElement) {
        if (isNullOrUndefined(viewContainerElement)) {
            return;
        }
        this._washoutContainer = document.createElement('div');
        this._washoutContainer.className = 'pps-washout';
        this._washoutContainer.style.display = 'none';
        viewContainerElement.appendChild(this._washoutContainer);
        var table = document.createElement('table');
        table.setAttribute('bgColor', 'White');
        table.style.position = 'relative';
        this._washoutContainer.appendChild(table);
        var row = table.insertRow();
        var cell = row.insertCell();
        cell.setAttribute('bgColor', 'White');
        this._pendingTextContainer$1 = document.createElement('div');
        this._pendingTextContainer$1.className = 'pps-loadingDiv';
        cell.appendChild(this._pendingTextContainer$1);
        this._pendingTextElement$1 = document.createElement('span');
        this._pendingTextElement$1.className = 'pps-loadingDivText';
        this._pendingTextElement$1.innerText = PPSMA.SR.Dashboard_WebRequest_Loading + PPSMA._cancellableWebRequest._loadingTextPadding$1;
        this._pendingTextContainer$1.appendChild(this._pendingTextElement$1);
        this._actionHyperlinkElement$1 = document.createElement('a');
        this._actionHyperlinkElement$1.className = 'pps-loadingDivAction';
        this._actionHyperlinkElement$1.href = '#';
        this._actionHyperlinkElement$1.innerText = PPSMA.SR.Dashboard_WebRequest_Stop;
        Sys.UI.DomEvent.addHandler(this._actionHyperlinkElement$1, 'click', Function.createDelegate(this, this._abortRequestLink_Click$1));
        this._pendingTextContainer$1.appendChild(this._actionHyperlinkElement$1);
        this.setWashoutContainerSize(viewContainerElement, PPSMA._cancellableWebRequest._defaultHeight$1, PPSMA._cancellableWebRequest._defaultWidth$1);
        var top = Math.round(viewContainerElement.offsetHeight / 2) - Math.round(PPSMA._cancellableWebRequest._defaultHeight$1 / 2);
        var left = Math.round(viewContainerElement.offsetWidth / 2) - Math.round(PPSMA._cancellableWebRequest._defaultWidth$1 / 2);
        if (top < 0) {
            top = 0;
        }
        if (left < 0) {
            left = 0;
        }
        this._pendingTextContainer$1.style.top = top + 'px';
        this._pendingTextContainer$1.style.left = left + 'px';
        this._state$1 = PPSMA._cancellableState.updating;
    },
    
    show: function PPSMA__cancellableWebRequest$show() {
        this._washoutContainer.style.display = 'block';
        this._pendingTextContainer$1.style.display = 'block';
    },
    
    _abortRequestLink_Click$1: function PPSMA__cancellableWebRequest$_abortRequestLink_Click$1(e) {
        e.stopPropagation();
        if (this._state$1 === PPSMA._cancellableState.updating) {
            this._setStoppedUI$1();
            this._state$1 = PPSMA._cancellableState.stopped;
            this._Cancel$1();
        }
        else {
            this._setLoadingUI$1();
            this._state$1 = PPSMA._cancellableState.updating;
            if (this._webRequestDetails$1) {
                this._Submit$1(this._webRequestDetails$1);
            }
        }
    },
    
    _setLoadingUI$1: function PPSMA__cancellableWebRequest$_setLoadingUI$1() {
        if (this._pendingTextContainer$1.className === 'pps-loadingDiv') {
            return;
        }
        this._pendingTextContainer$1.style.width = '100%';
        this._pendingTextContainer$1.style.height = '100%';
        this._pendingTextContainer$1.className = 'pps-loadingDiv';
        this._pendingTextContainer$1.parentNode.setAttribute('bgColor', 'White');
        this._pendingTextElement$1.innerText = PPSMA.SR.Dashboard_WebRequest_Loading + PPSMA._cancellableWebRequest._loadingTextPadding$1;
        this._actionHyperlinkElement$1.innerText = PPSMA.SR.Dashboard_WebRequest_Stop;
    },
    
    _setStoppedUI$1: function PPSMA__cancellableWebRequest$_setStoppedUI$1() {
        if (this._pendingTextContainer$1.className === 'pps-loadingDivNoSpinner') {
            return;
        }
        if (this._washoutContainer.currentStyle.display !== 'none') {
            this._pendingTextContainer$1.style.height = this._pendingTextContainer$1.clientHeight + 'px';
            this._pendingTextContainer$1.style.width = this._pendingTextContainer$1.clientWidth + 'px';
        }
        this._pendingTextContainer$1.className = 'pps-loadingDivNoSpinner';
        this._pendingTextElement$1.innerText = '';
        this._actionHyperlinkElement$1.innerText = PPSMA.SR.Dashboard_WebRequest_Load;
    },
    
    cancel: function PPSMA__cancellableWebRequest$cancel() {
        if (this._state$1 === PPSMA._cancellableState.stopped) {
            return;
        }
        this._setStoppedUI$1();
        this._state$1 = PPSMA._cancellableState.stopped;
        this._Cancel$1();
    },
    
    _Cancel$1: function PPSMA__cancellableWebRequest$_Cancel$1() {
        if (isNullOrUndefined(this._webRequest) || isNullOrUndefined(this._webRequest.get_executor()) || this._webRequest.get_executor().get_aborted()) {
            return;
        }
        this._webRequest.get_executor().abort();
        this._webRequest = null;
    },
    
    submit: function PPSMA__cancellableWebRequest$submit(details) {
        this._webRequestDetails$1 = details;
        if (this._state$1 === PPSMA._cancellableState.stopped) {
            return;
        }
        this._setLoadingUI$1();
        this._state$1 = PPSMA._cancellableState.updating;
        this._Submit$1(details);
    },
    
    _Submit$1: function PPSMA__cancellableWebRequest$_Submit$1(details) {
        this._Cancel$1();
        this.show();
        this._webRequest = new Sys.Net.WebRequest();
        this._webRequest.set_url(details.url);
        this._webRequest.set_body(details.body);
        this._webRequest.set_httpVerb(details.httpVerb);
        this._webRequest.get_headers()['Content-Type'] = details.contentType;
        this._webRequest.add_completed(details.completedCallback);
        this._webRequest.invoke();
    }
}


////////////////////////////////////////////////////////////////////////////////
// PPSMA._parametersTable

PPSMA._parametersTable = function PPSMA__parametersTable() {
    this._parameters = {};
}
PPSMA._parametersTable._key = function PPSMA__parametersTable$_key(dashboardItemId, parameterId) {
    return String.format('i={0} p={1}', dashboardItemId, parameterId);
}
PPSMA._parametersTable.prototype = {
    
    _add: function PPSMA__parametersTable$_add(record) {
        var key = PPSMA._parametersTable._key(record.dashboardItemId, record.parameterId);
        this._parameters[key] = record;
    },
    
    _exists: function PPSMA__parametersTable$_exists(dashboardItemId, parameterId) {
        return !isNullOrUndefined(this._parameters[PPSMA._parametersTable._key(dashboardItemId, parameterId)]);
    },
    
    _get: function PPSMA__parametersTable$_get(dashboardItemId, parameterId) {
        var key = PPSMA._parametersTable._key(dashboardItemId, parameterId);
        var record = this._parameters[key];
        return record;
    },
    
    _getByKey: function PPSMA__parametersTable$_getByKey(key) {
        var record = this._parameters[key];
        return record;
    }
}


////////////////////////////////////////////////////////////////////////////////
// PPSMA.DashboardController

PPSMA.DashboardController = function PPSMA_DashboardController() {
    this._parametersTable = new PPSMA._parametersTable();
    this._proxyMap = {};
    this._windowLoadHandler = Function.createDelegate(this, this._window_OnLoad);
    Sys.Application.add_load(this._windowLoadHandler);
    Sys.Application.registerDisposableObject(this);
}
PPSMA.DashboardController.get_instance = function PPSMA_DashboardController$get_instance() {
    if (!PPSMA.DashboardController._singleton) {
        PPSMA.DashboardController._singleton = new PPSMA.DashboardController();
    }
    return PPSMA.DashboardController._singleton;
}
PPSMA.DashboardController._parameter_AddRenderDependency = function PPSMA_DashboardController$_parameter_AddRenderDependency(record, proxyId) {
    if (!record.proxyRenderDependency) {
        record.proxyRenderDependency = {};
    }
    record.proxyRenderDependency[proxyId] = '';
}
PPSMA.DashboardController._parameter_AddVisibleDependency = function PPSMA_DashboardController$_parameter_AddVisibleDependency(record, proxyId) {
    if (!record.proxyVisibleDependency) {
        record.proxyVisibleDependency = {};
    }
    record.proxyVisibleDependency[proxyId] = '';
}
PPSMA.DashboardController._parameter_IsRenderDependency = function PPSMA_DashboardController$_parameter_IsRenderDependency(record) {
    return !isNullOrUndefined(record.proxyRenderDependency);
}
PPSMA.DashboardController._parameter_IsVisibleDependency = function PPSMA_DashboardController$_parameter_IsVisibleDependency(record) {
    return !isNullOrUndefined(record.proxyVisibleDependency);
}
PPSMA.DashboardController._parameter_IsDependency = function PPSMA_DashboardController$_parameter_IsDependency(record) {
    return !isNullOrUndefined(record.proxyRenderDependency) || !isNullOrUndefined(record.proxyVisibleDependency);
}
PPSMA.DashboardController._proxyMap_AddRenderDependency = function PPSMA_DashboardController$_proxyMap_AddRenderDependency(record, bindingRecord) {
    if (!record.renderDependency) {
        record.renderDependency = {};
    }
    record.renderDependency[bindingRecord.id] = bindingRecord;
}
PPSMA.DashboardController._proxyMap_AddVisibleDependency = function PPSMA_DashboardController$_proxyMap_AddVisibleDependency(record, bindingRecord) {
    if (!record.visibleDependency) {
        record.visibleDependency = {};
    }
    record.visibleDependency[bindingRecord.id] = bindingRecord;
}
PPSMA.DashboardController._proxyMap_FindVisibleBindingRecords = function PPSMA_DashboardController$_proxyMap_FindVisibleBindingRecords(record, beginPointId, parameterId) {
    var records = [];
    var $dict1 = record.visibleDependency;
    for (var $key2 in $dict1) {
        var entry = { key: $key2, value: $dict1[$key2] };
        var visibleBinding = entry.value;
        if (visibleBinding.parameterId === parameterId) {
            if ((visibleBinding.beginPointId === beginPointId) && (visibleBinding.parameterId === parameterId)) {
                Array.add(records, visibleBinding);
            }
        }
    }
    return records;
}
PPSMA.DashboardController._proxyMap_IsVisibleDependency = function PPSMA_DashboardController$_proxyMap_IsVisibleDependency(record) {
    return !isNullOrUndefined(record.visibleDependency);
}
PPSMA.DashboardController._isVisibleValueDependencyMatch = function PPSMA_DashboardController$_isVisibleValueDependencyMatch(parameterValues, visibleValues, isDefaultVisibilityEnabled) {
    if ((!parameterValues.length) || isDefaultVisibilityEnabled) {
        var $dict1 = visibleValues;
        for (var $key2 in $dict1) {
            var entry = { key: $key2, value: $dict1[$key2] };
            return false;
        }
        return true;
    }
    for (var i = 0; i < parameterValues.length; ++i) {
        if (!isNullOrUndefined(visibleValues[parameterValues[i]])) {
            return true;
        }
    }
    return false;
}
PPSMA.DashboardController.prototype = {
    _windowLoadHandler: null,
    
    get__isInitialized: function PPSMA_DashboardController$get__isInitialized() {
        return (!this._windowLoadHandler) ? true : false;
    },
    
    dispose: function PPSMA_DashboardController$dispose() {
        if (!isNullOrEmpty(this._proxyMap)) {
            var viewManagers = {};
            var $dict1 = this._proxyMap;
            for (var $key2 in $dict1) {
                var entry = { key: $key2, value: $dict1[$key2] };
                var proxyMapRecord = entry.value;
                var viewManager = proxyMapRecord.viewManager;
                if (viewManager) {
                    viewManagers[viewManager._id] = viewManager;
                }
                proxyMapRecord.viewManager = null;
                proxyMapRecord.viewProxy = null;
                proxyMapRecord.visibleDependency = null;
            }
            var $dict3 = viewManagers;
            for (var $key4 in $dict3) {
                var entry = { key: $key4, value: $dict3[$key4] };
                var viewManager = entry.value;
                viewManager.dispose();
            }
            this._proxyMap = null;
        }
        this._parametersTable = null;
        if (this._windowLoadHandler) {
            Sys.Application.remove_load(this._windowLoadHandler);
            this._windowLoadHandler = null;
            Sys.Application.unregisterDisposableObject(this);
        }
    },
    
    _window_OnLoad: function PPSMA_DashboardController$_window_OnLoad(sender, e) {
        Sys.Application.remove_load(this._windowLoadHandler);
        this._windowLoadHandler = null;
        this._initializeAlwaysVisibleProxy();
    },
    
    _initializeAlwaysVisibleProxy: function PPSMA_DashboardController$_initializeAlwaysVisibleProxy() {
        var viewManagers = {};
        var $dict1 = this._proxyMap;
        for (var $key2 in $dict1) {
            var entry = { key: $key2, value: $dict1[$key2] };
            var proxyMapRecord = entry.value;
            if (!proxyMapRecord.viewProxy) {
                continue;
            }
            if (!PPSMA.DashboardController._proxyMap_IsVisibleDependency(proxyMapRecord) && !proxyMapRecord.viewProxy.isDisabled) {
                proxyMapRecord.viewProxy.set__visibleState(PPSMA._proxyVisibleState.visible);
                var viewManager = proxyMapRecord.viewManager;
                viewManagers[viewManager._id] = viewManager;
            }
        }
        var $dict3 = viewManagers;
        for (var $key4 in $dict3) {
            var entry = { key: $key4, value: $dict3[$key4] };
            (entry.value)._updateActiveView();
        }
    },
    
    _getViewProxy: function PPSMA_DashboardController$_getViewProxy(proxyId) {
        var record = this._proxyMap[proxyId];
        if (isNullOrUndefined(record)) {
            return null;
        }
        return record.viewProxy;
    },
    
    addNewParameter: function PPSMA_DashboardController$addNewParameter(beginPointId, uniqueName, keyColumn, displayColumn) {
        Sys.Debug.trace(String.format('DashboardController.AddNewParameter: item={0} param={1}', beginPointId, uniqueName));
        var parameter = new PPSMA.ParameterDefinition(uniqueName, keyColumn, displayColumn);
        var parameterRecord = PPSMA.$create__parameterRecord(beginPointId, parameter.get__id(), parameter);
        this._parametersTable._add(parameterRecord);
        var proxyMapRecord = this._proxyMap[beginPointId];
        if (isNullOrUndefined(proxyMapRecord)) {
            proxyMapRecord = PPSMA.$create__proxyMapRecord(beginPointId);
            this._proxyMap[beginPointId] = proxyMapRecord;
        }
        Array.add(proxyMapRecord.proxyBeginPoints, parameter.get__id());
        return parameter;
    },
    
    _getParameter: function PPSMA_DashboardController$_getParameter(dashboardItemId, parameterId) {
        var record = this._parametersTable._get(dashboardItemId, parameterId);
        if (!record) {
            return null;
        }
        return record.definition;
    },
    
    _updateParameterValuesOnly: function PPSMA_DashboardController$_updateParameterValuesOnly(dashboardItemId, parameterId, selectedValues) {
        var parameterRecord = this._parametersTable._get(dashboardItemId, parameterId);
        var parameterDefinition = parameterRecord.definition;
        parameterDefinition.set_values(selectedValues);
        parameterDefinition._state = PPSMA._parameterState.changed;
        return parameterDefinition;
    },
    
    updateParameter: function PPSMA_DashboardController$updateParameter(beginPointId, parameterId, selectedValues) {
        var parameterRecord = this._parametersTable._get(beginPointId, parameterId);
        var parameterDefinition = parameterRecord.definition;
        parameterDefinition.set_values(selectedValues);
        if (!this.get__isInitialized()) {
            parameterDefinition._state = PPSMA._parameterState.changed;
            return parameterDefinition;
        }
        if (!PPSMA.DashboardController._parameter_IsDependency(parameterRecord)) {
            return parameterDefinition;
        }
        var proxyVisibleDependency = {};
        var proxyRenderDependency = {};
        var parameterDependency = {};
        this._discoverProxyVisibleDependency(beginPointId, parameterId, proxyVisibleDependency, parameterDependency, 0);
        this._discoverProxyRenderDependency(beginPointId, parameterId, proxyRenderDependency, parameterDependency, 0);
        Sys.Debug.traceDump(parameterDependency, 'parameterDependency');
        Sys.Debug.traceDump(proxyVisibleDependency, 'proxyVisibleDependency');
        Sys.Debug.traceDump(proxyRenderDependency, 'proxyRenderDependency');
        this._setParameterPendingChange(parameterDependency);
        var updateViewManagers = {};
        parameterDefinition._state = PPSMA._parameterState.changed;
        var isDefaultVisibilityEnabled = this._isDefaultVisibilityEnabled(parameterRecord);
        this._setProxyVisibleState(proxyVisibleDependency, updateViewManagers, isDefaultVisibilityEnabled);
        this._setProxyRenderState(proxyRenderDependency, updateViewManagers);
        var $dict1 = updateViewManagers;
        for (var $key2 in $dict1) {
            var managerEntry = { key: $key2, value: $dict1[$key2] };
            (managerEntry.value)._updateActiveView();
        }
        return parameterDefinition;
    },
    
    addProxyRenderDependency: function PPSMA_DashboardController$addProxyRenderDependency(proxyId, bindingId, beginPointId, parameterId) {
        if (!this._parametersTable._exists(beginPointId, parameterId)) {
            return;
        }
        var parameterRecord = this._parametersTable._get(beginPointId, parameterId);
        PPSMA.DashboardController._parameter_AddRenderDependency(parameterRecord, proxyId);
        var bindingRecord = PPSMA.$create__renderBindingRecord(proxyId, beginPointId, parameterId);
        var proxyMapRecord = this._proxyMap[proxyId];
        if (isNullOrUndefined(proxyMapRecord)) {
            proxyMapRecord = PPSMA.$create__proxyMapRecord(proxyId);
            this._proxyMap[proxyId] = proxyMapRecord;
        }
        PPSMA.DashboardController._proxyMap_AddRenderDependency(this._proxyMap[proxyId], bindingRecord);
    },
    
    addProxyVisibleDependency: function PPSMA_DashboardController$addProxyVisibleDependency(proxyId, bindingId, beginPointId, parameterId, visibleValues) {
        if (!this._parametersTable._exists(beginPointId, parameterId)) {
            return;
        }
        var parameterRecord = this._parametersTable._get(beginPointId, parameterId);
        PPSMA.DashboardController._parameter_AddVisibleDependency(parameterRecord, proxyId);
        var proxyMapRecord = this._proxyMap[proxyId];
        if (isNullOrUndefined(proxyMapRecord)) {
            proxyMapRecord = PPSMA.$create__proxyMapRecord(proxyId);
            this._proxyMap[proxyId] = proxyMapRecord;
        }
        var bindingRecord = PPSMA.$create__visibleBindingRecord(bindingId, beginPointId, parameterId, visibleValues);
        PPSMA.DashboardController._proxyMap_AddVisibleDependency(proxyMapRecord, bindingRecord);
    },
    
    addProxyMap: function PPSMA_DashboardController$addProxyMap(proxyId, proxyDisplayTitle, viewProxy, viewManager) {
        var proxyMapRecord = this._proxyMap[proxyId];
        if (isNullOrUndefined(proxyMapRecord)) {
            proxyMapRecord = PPSMA.$create__proxyMapRecord(proxyId);
            this._proxyMap[proxyId] = proxyMapRecord;
        }
        proxyMapRecord.proxyDisplayTitle = proxyDisplayTitle;
        proxyMapRecord.viewProxy = viewProxy;
        proxyMapRecord.viewManager = viewManager;
    },
    
    _discoverProxyRenderDependency: function PPSMA_DashboardController$_discoverProxyRenderDependency(beginPointId, parameterId, outProxyDependency, outParameterDependency, depth) {
        var parameterRecord = this._parametersTable._get(beginPointId, parameterId);
        if (!PPSMA.DashboardController._parameter_IsRenderDependency(parameterRecord)) {
            return;
        }
        outParameterDependency[PPSMA._parametersTable._key(beginPointId, parameterId)] = '';
        var $dict1 = parameterRecord.proxyRenderDependency;
        for (var $key2 in $dict1) {
            var keyValue = { key: $key2, value: $dict1[$key2] };
            var proxyId = keyValue.key;
            outProxyDependency[proxyId] = depth;
            var proxyMapRecord = this._proxyMap[proxyId];
            for (var i = 0; i < proxyMapRecord.proxyBeginPoints.length; ++i) {
                this._discoverProxyRenderDependency(proxyId, proxyMapRecord.proxyBeginPoints[i], outProxyDependency, outParameterDependency, depth + 1);
            }
        }
    },
    
    _discoverProxyVisibleDependency: function PPSMA_DashboardController$_discoverProxyVisibleDependency(beginPointId, parameterId, outProxyDependency, outParameterDependency, depth) {
        var parameterRecord = this._parametersTable._get(beginPointId, parameterId);
        if (!PPSMA.DashboardController._parameter_IsVisibleDependency(parameterRecord)) {
            return;
        }
        outParameterDependency[PPSMA._parametersTable._key(beginPointId, parameterId)] = '';
        var $dict1 = parameterRecord.proxyVisibleDependency;
        for (var $key2 in $dict1) {
            var keyValue = { key: $key2, value: $dict1[$key2] };
            var proxyId = keyValue.key;
            outProxyDependency[proxyId] = depth;
            var proxyMapRecord = this._proxyMap[proxyId];
            for (var i = 0; i < proxyMapRecord.proxyBeginPoints.length; ++i) {
                this._discoverProxyVisibleDependency(proxyId, proxyMapRecord.proxyBeginPoints[i], outProxyDependency, outParameterDependency, depth + 1);
            }
        }
    },
    
    _setProxyRenderState: function PPSMA_DashboardController$_setProxyRenderState(proxyRenderDependency, updateViewManagers) {
        var $dict1 = proxyRenderDependency;
        for (var $key2 in $dict1) {
            var entry = { key: $key2, value: $dict1[$key2] };
            var proxyMapRecord = this._proxyMap[entry.key];
            proxyMapRecord.viewProxy.set__isRenderUpdateRequired(true);
            var viewManager = proxyMapRecord.viewManager;
            updateViewManagers[viewManager._id] = viewManager;
        }
    },
    
    _setProxyVisibleState: function PPSMA_DashboardController$_setProxyVisibleState(proxyVisibleDependency, updateViewManagers, isDefaultVisibilityEnabled) {
        var forceHiddenDepth = -1;
        var $dict1 = proxyVisibleDependency;
        for (var $key2 in $dict1) {
            var proxyEntry = { key: $key2, value: $dict1[$key2] };
            var proxyId = proxyEntry.key;
            var proxyMapRecord = this._proxyMap[proxyId];
            var viewProxy = proxyMapRecord.viewProxy;
            var viewManager = proxyMapRecord.viewManager;
            updateViewManagers[viewManager._id] = viewManager;
            viewProxy.set__visibleState(PPSMA._proxyVisibleState.hidden);
            if (forceHiddenDepth !== -1 && proxyEntry.value > forceHiddenDepth) {
                continue;
            }
            forceHiddenDepth = -1;
            if (!PPSMA.DashboardController._proxyMap_IsVisibleDependency(proxyMapRecord)) {
                continue;
            }
            var isParameterPendingChange = false;
            var $dict3 = proxyMapRecord.visibleDependency;
            for (var $key4 in $dict3) {
                var visibleEntry = { key: $key4, value: $dict3[$key4] };
                var bindingRecord = visibleEntry.value;
                var parameterRecord = this._parametersTable._get(bindingRecord.beginPointId, bindingRecord.parameterId);
                var parameterDefinition = parameterRecord.definition;
                if (parameterDefinition._state === PPSMA._parameterState.pendingChange) {
                    isParameterPendingChange = true;
                    continue;
                }
                if (PPSMA.DashboardController._isVisibleValueDependencyMatch(parameterDefinition.get_values(), bindingRecord.visibleValues, isDefaultVisibilityEnabled)) {
                    viewProxy.set__visibleState(PPSMA._proxyVisibleState.visible);
                    break;
                }
            }
            if (viewProxy.get__visibleState() === PPSMA._proxyVisibleState.hidden) {
                if (isParameterPendingChange) {
                    viewProxy.set__visibleState(PPSMA._proxyVisibleState.pendingVisible);
                }
                else {
                    forceHiddenDepth = proxyEntry.value;
                }
            }
        }
    },
    
    _isDefaultVisibilityEnabled: function PPSMA_DashboardController$_isDefaultVisibilityEnabled(parameterRecord) {
        if (!PPSMA.DashboardController._parameter_IsVisibleDependency(parameterRecord)) {
            return false;
        }
        var selectedValues = parameterRecord.definition.get_values();
        var $dict1 = parameterRecord.proxyVisibleDependency;
        for (var $key2 in $dict1) {
            var proxyEntry = { key: $key2, value: $dict1[$key2] };
            var proxyId = proxyEntry.key;
            var proxyMapRecord = this._proxyMap[proxyId];
            if (this._isProxyViewVisible(parameterRecord, proxyMapRecord)) {
                return false;
            }
        }
        return true;
    },
    
    _isProxyViewVisible: function PPSMA_DashboardController$_isProxyViewVisible(parameterRecord, proxyMapRecord) {
        var $dict1 = proxyMapRecord.visibleDependency;
        for (var $key2 in $dict1) {
            var entry = { key: $key2, value: $dict1[$key2] };
            var visibleBindingRecord = entry.value;
            if ((visibleBindingRecord.parameterId === parameterRecord.parameterId) && (visibleBindingRecord.beginPointId === parameterRecord.dashboardItemId)) {
                if (PPSMA.DashboardController._isVisibleValueDependencyMatch(parameterRecord.definition.get_values(), visibleBindingRecord.visibleValues, false)) {
                    return true;
                }
            }
        }
        return false;
    },
    
    _setParameterPendingChange: function PPSMA_DashboardController$_setParameterPendingChange(parameterDependency) {
        var $dict1 = parameterDependency;
        for (var $key2 in $dict1) {
            var entry = { key: $key2, value: $dict1[$key2] };
            var parameterRecord = this._parametersTable._getByKey(entry.key);
            parameterRecord.definition._state = PPSMA._parameterState.pendingChange;
        }
    }
}


////////////////////////////////////////////////////////////////////////////////
// PPSMA.DomElementEx

PPSMA.DomElementEx = function PPSMA_DomElementEx() {
}
PPSMA.DomElementEx.removeElement = function PPSMA_DomElementEx$removeElement(element) {
    var garbageBin = $get('IELeakGarbageBin');
    if (!garbageBin) {
        garbageBin = document.createElement('div');
        garbageBin.id = 'IELeakGarbageBin';
        garbageBin.style.display = 'none';
        document.body.appendChild(garbageBin);
    }
    garbageBin.appendChild(element);
    garbageBin.innerHTML = '';
}


////////////////////////////////////////////////////////////////////////////////
// PPSMA._noCancelWebRequest

PPSMA._noCancelWebRequest = function PPSMA__noCancelWebRequest(containerElement) {
    PPSMA._noCancelWebRequest.initializeBase(this);
    this._createPendingRequestUI$1(containerElement);
}
PPSMA._noCancelWebRequest.prototype = {
    
    _createPendingRequestUI$1: function PPSMA__noCancelWebRequest$_createPendingRequestUI$1(viewContainerElement) {
        this._washoutContainer = document.createElement('div');
        this._washoutContainer.className = 'pps-washout';
        viewContainerElement.appendChild(this._washoutContainer);
        var pendingTextContainer = document.createElement('div');
        pendingTextContainer.className = 'pps-noCancelLoadingDiv';
        this._washoutContainer.appendChild(pendingTextContainer);
        var pendingTextElement = document.createElement('span');
        Sys.UI.DomElement.addCssClass(pendingTextElement, 'pps-noCancelLoadingText');
        pendingTextElement.innerText = PPSMA.SR.Dashboard_WebRequest_Loading;
        pendingTextContainer.appendChild(pendingTextElement);
        this._washoutContainer.style.display = 'none';
        this.setWashoutContainerSize(viewContainerElement, PPSMA._noCancelWebRequest._defaultHeight$1, PPSMA._noCancelWebRequest._defaultWidth$1);
        var top = Math.round(viewContainerElement.offsetHeight / 2) - Math.round(PPSMA._noCancelWebRequest._defaultHeight$1 / 2);
        if (top < 0) {
            top = 0;
        }
        pendingTextContainer.style.top = top + 'px';
        pendingTextContainer.style.left = '0px';
    },
    
    submit: function PPSMA__noCancelWebRequest$submit(details) {
        this.show();
        this._webRequest = new Sys.Net.WebRequest();
        this._webRequest.set_url(details.url);
        this._webRequest.set_body(details.body);
        this._webRequest.set_httpVerb(details.httpVerb);
        this._webRequest.get_headers()['Content-Type'] = details.contentType;
        this._webRequest.add_completed(details.completedCallback);
        this._webRequest.invoke();
    }
}


////////////////////////////////////////////////////////////////////////////////
// PPSMA._renderWebRequest

PPSMA._renderWebRequest = function PPSMA__renderWebRequest() {
}
PPSMA._renderWebRequest.prototype = {
    _webRequest: null,
    _washoutContainer: null,
    
    dispose: function PPSMA__renderWebRequest$dispose() {
        if (!isNullOrUndefined(this._webRequest) && !isNullOrUndefined(this._webRequest.get_executor()) && !this._webRequest.get_executor().get_aborted()) {
            this._webRequest.get_executor().abort();
            this._webRequest = null;
        }
        if (this._washoutContainer) {
            this.hide();
            PPSMA.DomElementEx.removeElement(this._washoutContainer);
            this._washoutContainer = null;
        }
    },
    
    setWashoutContainerSize: function PPSMA__renderWebRequest$setWashoutContainerSize(viewContainerElement, defaultHeight, defaultWidth) {
        var loadingDivWidth = defaultWidth + 'px';
        var loadingDivHeight = defaultHeight + 'px';
        var containerType = PPSMA.Common._getContainerType(viewContainerElement);
        switch (containerType) {
            case PPSMA.CommonContainerType.autosize:
                loadingDivWidth = '100%';
                loadingDivHeight = viewContainerElement.offsetHeight + 'px';
                break;
            case PPSMA.CommonContainerType.autoHeight:
            case PPSMA.CommonContainerType.autoWidth:
            case PPSMA.CommonContainerType.explicit:
                loadingDivWidth = viewContainerElement.clientWidth + 'px';
                loadingDivHeight = viewContainerElement.clientHeight + 'px';
                break;
        }
        if (loadingDivWidth.search(new RegExp('px', 'i')) > -1) {
            if (parseInt(loadingDivWidth) < defaultWidth) {
                loadingDivWidth = defaultWidth + 'px';
            }
        }
        if (loadingDivHeight.search(new RegExp('px', 'i')) > -1) {
            if (parseInt(loadingDivHeight) < defaultHeight) {
                loadingDivHeight = defaultHeight + 'px';
            }
        }
        this._washoutContainer.style.width = loadingDivWidth;
        this._washoutContainer.style.height = loadingDivHeight;
        this._washoutContainer.style.top = viewContainerElement.scrollTop + 'px';
        this._washoutContainer.style.left = viewContainerElement.scrollLeft + 'px';
        if (parseInt(loadingDivWidth) > 0 || parseInt(loadingDivHeight) > 0) {
            if (viewContainerElement.offsetHeight > 0 || containerType !== PPSMA.CommonContainerType.autosize) {
                Sys.UI.DomElement.addCssClass(this._washoutContainer, 'pps-loading-reload');
            }
        }
    },
    
    hide: function PPSMA__renderWebRequest$hide() {
        this._washoutContainer.style.display = 'none';
    },
    
    show: function PPSMA__renderWebRequest$show() {
        this._washoutContainer.style.display = 'block';
    }
}


////////////////////////////////////////////////////////////////////////////////
// PPSMA._fileDownload

PPSMA._fileDownload = function PPSMA__fileDownload(url, arguments, httpPost) {
    this._httpPost = httpPost;
    this._iframe = document.createElement('IFRAME');
    ++PPSMA._fileDownload._iframeCounter;
    this._iframe.id = 'HttpPost_FileDownload_' + PPSMA._fileDownload._iframeCounter.toString();
    this._iframe.src = 'javascript:false;';
    this._iframe.style.height = '0px';
    this._iframe.style.width = '0px';
    document.body.appendChild(this._iframe);
    var iframeDocument = this._iframe.contentWindow.document;
    iframeDocument.open();
    iframeDocument.writeln('<html><head></head><body></body></html>');
    iframeDocument.close();
    var form = iframeDocument.createElement('form');
    form.target = '_self';
    form.action = url;
    form.method = 'post';
    form.name = 'OfficeExportForm';
    iframeDocument.documentElement.appendChild(form);
    var $dict1 = arguments;
    for (var $key2 in $dict1) {
        var argument = { key: $key2, value: $dict1[$key2] };
        var input = iframeDocument.createElement('input');
        input.type = 'hidden';
        input.value = encodeURIComponent((argument.value));
        input.name = argument.key;
        form.appendChild(input);
    }
    form.submit();
    Sys.UI.DomEvent.addHandler(this._iframe, 'load', Function.createDelegate(this, this._fileDownload_OnLoad));
    this._timerId = window.setTimeout(Function.createDelegate(this, this._window_OnTimeout), 5 * 60 * 1000);
}
PPSMA._fileDownload.prototype = {
    _iframe: null,
    _timerId: 0,
    _httpPost: null,
    
    dispose: function PPSMA__fileDownload$dispose() {
        this._disposeTimer();
        this._disposeIframe();
        if (this._httpPost) {
            this._httpPost._fileDownloadCompleted(this);
            this._httpPost = null;
        }
    },
    
    _disposeIframe: function PPSMA__fileDownload$_disposeIframe() {
        if (this._iframe) {
            Sys.UI.DomEvent.clearHandlers(this._iframe);
            this._iframe.parentNode.removeChild(this._iframe);
            this._iframe = null;
        }
    },
    
    _disposeTimer: function PPSMA__fileDownload$_disposeTimer() {
        if (this._timerId) {
            window.clearTimeout(this._timerId);
            this._timerId = 0;
        }
    },
    
    _window_OnTimeout: function PPSMA__fileDownload$_window_OnTimeout() {
        this.dispose();
    },
    
    _fileDownload_OnLoad: function PPSMA__fileDownload$_fileDownload_OnLoad(e) {
        var iframe = e.target;
        this._disposeTimer();
        var innerHtml = String.format('<div><div>{0}</div><div style=\'padding:50px\'><a style=\'float:right\' onclick=\'window.close();\' href=\'#\'>Close</a></div></div>', iframe.contentWindow.document.body.innerHTML);
        PPSMA.NewWindow.create(null, new Sys.UI.Bounds(-1, -1, 400, 200), null, null, innerHtml);
        this.dispose();
    }
}


////////////////////////////////////////////////////////////////////////////////
// PPSMA.HttpPost

PPSMA.HttpPost = function PPSMA_HttpPost() {
    this._activeFileDownloads = [];
    Sys.Application.registerDisposableObject(this);
}
PPSMA.HttpPost.get_instance = function PPSMA_HttpPost$get_instance() {
    if (!PPSMA.HttpPost._httpPost) {
        PPSMA.HttpPost._httpPost = new PPSMA.HttpPost();
    }
    return PPSMA.HttpPost._httpPost;
}
PPSMA.HttpPost.prototype = {
    _isDisposing: false,
    
    dispose: function PPSMA_HttpPost$dispose() {
        if (!this._isDisposing) {
            this._isDisposing = true;
            if (this._activeFileDownloads) {
                Array.forEach(this._activeFileDownloads, Function.createDelegate(this, function(fileDownload) {
                    (fileDownload).dispose();
                }));
                Array.clear(this._activeFileDownloads);
                this._activeFileDownloads = null;
            }
            Sys.Application.unregisterDisposableObject(this);
            PPSMA.HttpPost._httpPost = null;
        }
    },
    
    _fileDownloadCompleted: function PPSMA_HttpPost$_fileDownloadCompleted(fileDownload) {
        if (!this._isDisposing) {
            Array.remove(this._activeFileDownloads, fileDownload);
        }
    },
    
    downloadFile: function PPSMA_HttpPost$downloadFile(url, arguments) {
        var fileDownload = new PPSMA._fileDownload(url, arguments, this);
    }
}


////////////////////////////////////////////////////////////////////////////////
// PPSMA.NewWindow

PPSMA.NewWindow = function PPSMA_NewWindow() {
}
PPSMA.NewWindow.create = function PPSMA_NewWindow$create(url, bounds, windowName, windowFeatures, bodyInnerHtml) {
    if (!url) {
        url = '';
    }
    if (!windowName) {
        windowName = '';
    }
    if (!windowFeatures) {
        windowFeatures = {};
    }
    if (!bounds) {
        bounds = new Sys.UI.Bounds(-1, -1, -1, -1);
    }
    var windowWidth = window.document.body.clientWidth;
    var windowHeight = window.document.body.clientHeight;
    if (bounds.width === -1) {
        bounds.width = windowWidth;
    }
    if (bounds.height === -1) {
        bounds.height = windowHeight;
    }
    if (bounds.x === -1) {
        bounds.x = Math.floor((windowWidth - bounds.width) / 2);
    }
    if (bounds.y === -1) {
        bounds.y = Math.floor((windowHeight - bounds.height) / 2);
    }
    bounds.x = bounds.x + window.self.screenLeft;
    bounds.y = bounds.y + window.self.screenTop;
    windowFeatures['left'] = bounds.x.toString() + 'px';
    windowFeatures['top'] = bounds.y.toString() + 'px';
    windowFeatures['width'] = bounds.width.toString() + 'px';
    windowFeatures['height'] = bounds.height.toString() + 'px';
    var features = new Sys.StringBuilder();
    var $dict1 = windowFeatures;
    for (var $key2 in $dict1) {
        var feature = { key: $key2, value: $dict1[$key2] };
        if (!features.isEmpty()) {
            features.append(',');
        }
        features.append(String.format('{0}={1}', feature.key, feature.value));
    }
    var newWindow = window.open('', windowName, features.toString());
    if (!newWindow) {
        return null;
    }
    var html = String.format('<html><head></head><body>{0}</body></html>', bodyInnerHtml);
    var newDocument = newWindow.document;
    newDocument.open();
    newDocument.writeln(html);
    newDocument.close();
    newWindow.focus();
    return newWindow;
}
PPSMA.NewWindow.createPost = function PPSMA_NewWindow$createPost(url, bounds, windowName, windowFeatures, arguments, formName, throbberUrl) {
    if (!formName) {
        formName = '';
    }
    var innerHtml = new Sys.StringBuilder();
    innerHtml.append('<div style=\"width:100%;height:152px;\">&nbsp;</div>');
    innerHtml.append('<div style=\"width:100%;text-align:center;\" >');
    if (throbberUrl && throbberUrl.length > 0) {
        innerHtml.append('<img id=\'throbber\' src=\'' + throbberUrl + '\'/>');
    }
    innerHtml.append('</div>\n');
    var newWindow = PPSMA.NewWindow.create(url, bounds, windowName, windowFeatures, innerHtml.toString());
    if (!newWindow) {
        return null;
    }
    var newDocument = newWindow.document;
    var form = newDocument.createElement('form');
    form.target = windowName;
    form.action = url;
    form.method = 'post';
    form.name = formName;
    newDocument.documentElement.appendChild(form);
    var $dict1 = arguments;
    for (var $key2 in $dict1) {
        var argument = { key: $key2, value: $dict1[$key2] };
        var input = newDocument.createElement('input');
        input.type = 'hidden';
        input.value = encodeURIComponent((argument.value));
        input.name = argument.key;
        form.appendChild(input);
    }
    form.submit();
    var throbber = newDocument.getElementById('throbber');
    if (throbber) {
        throbber.src = throbberUrl;
    }
    return newWindow;
}


////////////////////////////////////////////////////////////////////////////////
// PPSMA.PageOverview

PPSMA.PageOverview = function PPSMA_PageOverview(caption) {
    this._tabStrip = document.createElement('div');
    var title = document.createElement('span');
    title.innerText = caption + ' :';
    Sys.UI.DomElement.addCssClass(title, 'ppsma-pageOverviewTitle');
    this._tabStrip.appendChild(title);
    this._tabStripList = document.createElement('ul');
    Sys.UI.DomElement.addCssClass(this._tabStripList, 'ppsma-pageOverviewList');
    this._tabStrip.appendChild(this._tabStripList);
}
PPSMA.PageOverview.createPageOverview = function PPSMA_PageOverview$createPageOverview(caption, tabs) {
    var pageOverview = new PPSMA.PageOverview(caption);
    pageOverview._appendTabs(tabs);
    return pageOverview._tabStrip;
}
PPSMA.PageOverview.createPageOverviewTab = function PPSMA_PageOverview$createPageOverviewTab(caption, href, isActive) {
    var tab = document.createElement('li');
    var tabCaption;
    if (isActive) {
        Sys.UI.DomElement.addCssClass(tab, 'ppsma-pageOverviewTabActive');
        tabCaption = document.createElement('span');
    }
    else {
        tabCaption = document.createElement('a');
        (tabCaption).href = href;
    }
    tab.appendChild(tabCaption);
    tabCaption.innerText = caption;
    return tab;
}
PPSMA.PageOverview.prototype = {
    _tabStrip: null,
    _tabStripList: null,
    
    _appendTabs: function PPSMA_PageOverview$_appendTabs(tabs) {
        for (var index = 0; index < tabs.length; index++) {
            this._tabStripList.appendChild(tabs[index]);
            if (index !== tabs.length - 1) {
                var seperator = document.createElement('li');
                seperator.innerText = '|';
                this._tabStripList.appendChild(seperator);
            }
        }
    }
}


////////////////////////////////////////////////////////////////////////////////
// PPSMA.ParameterDefinition

PPSMA.ParameterDefinition = function PPSMA_ParameterDefinition(uniqueName, keyColumn, displayColumn) {
    this._uniqueName = uniqueName;
    this._keyColumn = keyColumn;
    this._displayColumn = displayColumn;
    this._state = PPSMA._parameterState.pendingChange;
}
PPSMA.ParameterDefinition.prototype = {
    _state: 0,
    
    get__id: function PPSMA_ParameterDefinition$get__id() {
        return this._uniqueName;
    },
    
    _uniqueName: null,
    _keyColumn: null,
    _displayColumn: null,
    
    get_values: function PPSMA_ParameterDefinition$get_values() {
        return this._values;
    },
    set_values: function PPSMA_ParameterDefinition$set_values(value) {
        this._values = value;
        return value;
    },
    
    _values: null,
    
    _clone: function PPSMA_ParameterDefinition$_clone() {
        var clone = new PPSMA.ParameterDefinition(this._uniqueName, this._keyColumn, this._displayColumn);
        clone._values = this._values;
        return clone;
    },
    
    _serializeXml: function PPSMA_ParameterDefinition$_serializeXml() {
        var xml = new Sys.StringBuilder();
        var selectedKeys = this._values;
        if (!selectedKeys) {
            selectedKeys = [ '' ];
        }
        xml.append('<Values>');
        xml.append('<xs:schema id=\"NewDataSet\" xmlns=\"\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" xmlns:msdata=\"urn:schemas-microsoft-com:xml-msdata\" xmlns:msprop=\"urn:schemas-microsoft-com:xml-msprop\"><xs:element name=\"NewDataSet\" msdata:IsDataSet=\"true\" msdata:MainDataTable=\"MyDataTable\" msdata:UseCurrentLocale=\"true\"><xs:complexType><xs:choice minOccurs=\"0\" maxOccurs=\"unbounded\"><xs:element name=\"MyDataTable\" msprop:Type=\"System.Object, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089\"><xs:complexType><xs:sequence>');
        xml.append(String.format('<xs:element name=\"{0}\" type=\"xs:string\" minOccurs=\"0\" />', this._keyColumn));
        if (this._keyColumn !== this._displayColumn) {
            xml.append(String.format('<xs:element name=\"{0}\" type=\"xs:string\" minOccurs=\"0\" />', this._displayColumn));
        }
        xml.append('</xs:sequence></xs:complexType></xs:element></xs:choice></xs:complexType></xs:element></xs:schema>');
        xml.append('<diffgr:diffgram xmlns:msdata=\"urn:schemas-microsoft-com:xml-msdata\" xmlns:diffgr=\"urn:schemas-microsoft-com:xml-diffgram-v1\">');
        xml.append('<DocumentElement>');
        for (var index = 0; index < selectedKeys.length; index++) {
            xml.append(String.format('<MyDataTable diffgr:id=\"MyDataTable{0}\" msdata:rowOrder=\"{0}\" diffgr:hasChanges=\"inserted\">', index));
            xml.append(String.format('<{0}><![CDATA[{1}]]></{0}>', this._keyColumn, selectedKeys[index]));
            if (this._keyColumn !== this._displayColumn) {
                xml.append(String.format('<{0}></{0}>', this._displayColumn));
            }
            xml.append('</MyDataTable>');
        }
        xml.append('</DocumentElement></diffgr:diffgram></Values>');
        xml.append(String.format('<ParameterUniqueName><![CDATA[{0}]]></ParameterUniqueName>', this._uniqueName));
        xml.append(String.format('<KeyColumn><![CDATA[{0}]]></KeyColumn>', this._keyColumn));
        xml.append(String.format('<DisplayColumn><![CDATA[{0}]]></DisplayColumn>', this._displayColumn));
        return xml.toString();
    }
}


////////////////////////////////////////////////////////////////////////////////
// PPSMA._pickerItemSelectedEventArgs

PPSMA._pickerItemSelectedEventArgs = function PPSMA__pickerItemSelectedEventArgs(pickerItemElement) {
    PPSMA._pickerItemSelectedEventArgs.initializeBase(this);
    this.itemElement = pickerItemElement;
}
PPSMA._pickerItemSelectedEventArgs.prototype = {
    itemElement: null
}


////////////////////////////////////////////////////////////////////////////////
// PPSMA._picker

PPSMA._picker = function PPSMA__picker(caption, isSelectable, useSharePointStyle) {
    this._events = new Sys.EventHandlerList();
    this._pickerItems = [];
    this._isSelectable = isSelectable;
    this._element = document.createElement('div');
    this._element.className = 'pps-picker';
    this._selectedItem = document.createElement('span');
    this._selectedItem.innerText = caption;
    if (useSharePointStyle) {
        this._selectedItem.className = 'ms-standardheader ms-WPTitle';
    }
    else {
        this._selectedItem.className = 'pps-pickerSelectedItem pps-pickerItem';
    }
    this._element.appendChild(this._selectedItem);
    if (this._isSelectable) {
        Sys.UI.DomEvent.addHandler(this._element, 'mouseover', Function.createDelegate(this, this._element_onmouseover));
        Sys.UI.DomEvent.addHandler(this._element, 'mouseout', Function.createDelegate(this, this._element_onmouseout));
        Sys.UI.DomEvent.addHandler(this._element, 'click', Function.createDelegate(this, this._button_onclick));
        this._element.style.cursor = 'pointer';
        this._listElement = document.createElement('ul');
        this._listElement.className = 'pps-pickerList';
        this._listElement.style.display = 'none';
        this._shim = document.createElement('iframe');
        this._shim.style.display = 'none';
        this._shim.style.filter = 'progid:DXImageTransform.Microsoft.Alpha(style=0, opacity=0)';
        this._shim.FrameBorder = '0';
        this._listElement.style.zIndex = 2;
        this._shim.style.zIndex = (this._listElement.style.zIndex - 1);
        this._button = document.createElement('a');
        this._button.href = 'javascript://';
        if (useSharePointStyle) {
            this._button.className = 'pps-pickerSelectButtonLarge';
        }
        else {
            this._button.className = 'pps-pickerSelectButton';
        }
        Sys.UI.DomEvent.addHandler(this._button, 'click', Function.createDelegate(this, this._button_onclick));
        Sys.UI.DomEvent.addHandler(this._button, 'focus', Function.createDelegate(this, this._button_onfocus));
        Sys.UI.DomEvent.addHandler(this._button, 'blur', Function.createDelegate(this, this._button_onblur));
        this._element.appendChild(this._button);
    }
}
PPSMA._picker._calculateCaptionWidth = function PPSMA__picker$_calculateCaptionWidth(width) {
    var captionWidth;
    if (width === 'auto' || width === '') {
        captionWidth = PPSMA._picker._defaultPickerWidth;
    }
    else {
        var targetWidth = parseInt(width) - PPSMA._picker._defaultCaptionOffset;
        if (targetWidth < PPSMA._picker._defaultPickerWidth) {
            captionWidth = PPSMA._picker._defaultPickerWidth;
        }
        else {
            captionWidth = targetWidth;
        }
    }
    return captionWidth;
}
PPSMA._picker.prototype = {
    _element: null,
    _button: null,
    _listElement: null,
    _shim: null,
    _isSelectable: false,
    _selectedItem: null,
    _selectableCaption: null,
    _bodyClickHandler: null,
    
    dispose: function PPSMA__picker$dispose() {
        if (this._bodyClickHandler) {
            Sys.UI.DomEvent.removeHandler(document.body, 'click', this._bodyClickHandler);
            this._bodyClickHandler = null;
        }
        if (this._button) {
            Sys.UI.DomEvent.clearHandlers(this._button);
            this._button = null;
        }
        if (this._selectableCaption) {
            Sys.UI.DomEvent.clearHandlers(this._selectableCaption);
            this._selectableCaption = null;
        }
        if (this._element) {
            Sys.UI.DomEvent.clearHandlers(this._element);
            PPSMA.DomElementEx.removeElement(this._element);
            this._element = null;
        }
        if (this._listElement) {
            for (var i = 0; i < this._pickerItems.length; ++i) {
                (this._pickerItems[i]).dispose();
            }
            this._pickerItems = null;
            PPSMA.DomElementEx.removeElement(this._listElement);
            this._listElement = null;
        }
        if (this._shim) {
            PPSMA.DomElementEx.removeElement(this._shim);
            this._shim = null;
        }
        this._events = null;
    },
    
    add_itemSelected: function PPSMA__picker$add_itemSelected(value) {
        this._events.addHandler(PPSMA._picker._eventKey_ItemSelected, value);
    },
    remove_itemSelected: function PPSMA__picker$remove_itemSelected(value) {
        this._events.removeHandler(PPSMA._picker._eventKey_ItemSelected, value);
    },
    
    _raiseItemSelectedEvent: function PPSMA__picker$_raiseItemSelectedEvent(pickerItem) {
        var handler = this._events.getHandler(PPSMA._picker._eventKey_ItemSelected);
        if (handler) {
            handler(this, new PPSMA._pickerItemSelectedEventArgs(pickerItem));
        }
    },
    
    add_captionSelected: function PPSMA__picker$add_captionSelected(value) {
        if (!this._events.getHandler(PPSMA._picker._eventKey_CaptionSelected)) {
            this._addSelectableCaption();
        }
        this._events.addHandler(PPSMA._picker._eventKey_CaptionSelected, value);
    },
    remove_captionSelected: function PPSMA__picker$remove_captionSelected(value) {
        this._events.removeHandler(PPSMA._picker._eventKey_CaptionSelected, value);
        if (!this._events.getHandler(PPSMA._picker._eventKey_CaptionSelected)) {
            this._removeSelectableCaption();
        }
    },
    
    _addSelectableCaption: function PPSMA__picker$_addSelectableCaption() {
        var caption = this._selectedItem.innerText;
        this._selectedItem.innerText = '';
        this._selectableCaption = document.createElement('a');
        this._selectableCaption.innerText = caption;
        this._selectableCaption.className = 'pps-pickerSelectedCaption pps-pickerItem';
        this._selectableCaption.href = 'javascript://';
        Sys.UI.DomEvent.addHandler(this._selectableCaption, 'click', Function.createDelegate(this, this._selectableCaption_Click));
        this._selectedItem.appendChild(this._selectableCaption);
    },
    
    _removeSelectableCaption: function PPSMA__picker$_removeSelectableCaption() {
        var caption = this._selectedItem.firstChild.innerText;
        Sys.UI.DomEvent.clearHandlers(this._selectableCaption);
        this._selectableCaption = null;
        this._selectedItem.innerHTML = '';
        this._selectedItem.innerText = caption;
    },
    
    _raiseCaptionSelected: function PPSMA__picker$_raiseCaptionSelected() {
        var handler = this._events.getHandler(PPSMA._picker._eventKey_CaptionSelected);
        if (handler) {
            handler(this, new Sys.EventArgs());
        }
    },
    
    _selectableCaption_Click: function PPSMA__picker$_selectableCaption_Click(e) {
        this._raiseCaptionSelected();
        e.preventDefault();
        e.stopPropagation();
    },
    
    _body_onclick: function PPSMA__picker$_body_onclick(e) {
        this._hideList();
    },
    
    _button_onclick: function PPSMA__picker$_button_onclick(e) {
        this._toggleList();
        e.stopPropagation();
    },
    
    _button_onfocus: function PPSMA__picker$_button_onfocus(e) {
        this._pickerFocused();
        e.stopPropagation();
    },
    
    _button_onblur: function PPSMA__picker$_button_onblur(e) {
        if (this._listElement.style.display === 'none') {
            this._pickerBlurred();
        }
        e.stopPropagation();
    },
    
    _element_onmouseover: function PPSMA__picker$_element_onmouseover(e) {
        this._pickerFocused();
        e.stopPropagation();
    },
    
    _element_onmouseout: function PPSMA__picker$_element_onmouseout(e) {
        if (this._listElement.style.display === 'none') {
            this._pickerBlurred();
        }
        e.stopPropagation();
    },
    
    _pickerFocused: function PPSMA__picker$_pickerFocused() {
        Sys.UI.DomElement.addCssClass(this._element, 'pps-pickerActive');
        Sys.UI.DomElement.addCssClass(this._button, 'pps-pickerSelectButtonActive');
    },
    
    _pickerBlurred: function PPSMA__picker$_pickerBlurred() {
        Sys.UI.DomElement.removeCssClass(this._element, 'pps-pickerActive');
        Sys.UI.DomElement.removeCssClass(this._button, 'pps-pickerSelectButtonActive');
    },
    
    _hideList: function PPSMA__picker$_hideList() {
        this._listElement.style.display = 'none';
        this._shim.style.display = 'none';
        this._pickerBlurred();
    },
    
    _setSelected: function PPSMA__picker$_setSelected(caption) {
        this._selectedItem.innerHTML = '';
        this._selectedItem.innerText = caption;
    },
    
    _showList: function PPSMA__picker$_showList() {
        if (this._listElement.parentNode !== this._element.parentNode) {
            this._element.parentNode.appendChild(this._listElement);
        }
        if (this._shim.parentNode !== this._element.parentNode) {
            this._element.parentNode.appendChild(this._shim);
        }
        this._resetItemWidths();
        this._shim.style.top = this._listElement.currentStyle.top;
        this._shim.style.left = this._listElement.currentStyle.left;
        this._listElement.style.display = 'block';
        this._listElement.style.position = 'absolute';
        this._shim.style.display = 'block';
        this._shim.style.position = 'absolute';
        if (this._listElement.childNodes.length > 0) {
            this._listElement.style.width = Sys.UI.DomElement.getBounds(this._listElement.childNodes[0]).width + 'px';
        }
        this._shim.style.width = parseInt(this._listElement.offsetWidth) + 'px';
        this._shim.style.height = parseInt(this._listElement.offsetHeight) + 'px';
        if (!this._bodyClickHandler) {
            this._bodyClickHandler = Function.createDelegate(this, this._body_onclick);
            Sys.UI.DomEvent.addHandler(document.body, 'click', this._bodyClickHandler);
        }
        this._pickerFocused();
        if (this._listElement.firstChild && (this._listElement.firstChild).itemCaption) {
            (this._listElement.firstChild).itemCaption.focus();
        }
    },
    
    _toggleList: function PPSMA__picker$_toggleList() {
        if (this._listElement.style.display === 'block') {
            this._hideList();
        }
        else {
            this._showList();
        }
    },
    
    addPickerItems: function PPSMA__picker$addPickerItems(listItems) {
        for (var index = 0; index < listItems.length; index++) {
            var properties = listItems[index];
            var item = new PPSMA._pickerItem(properties['caption'], properties['tag']);
            Array.add(this._pickerItems, item);
            item.add_click(Function.createDelegate(this, this._pickerItem_Click));
            this._listElement.appendChild(item.element);
        }
    },
    
    _pickerItem_Click: function PPSMA__picker$_pickerItem_Click(sender, e) {
        var pickerItem = sender;
        this._raiseItemSelectedEvent(pickerItem.element);
    },
    
    setCaptionWidth: function PPSMA__picker$setCaptionWidth(width) {
        var captionWidth = PPSMA._picker._calculateCaptionWidth(width);
        var elementWidth = captionWidth + PPSMA._picker._defaultListOffset;
        this._selectedItem.style.width = captionWidth + 'px';
        this._element.style.width = elementWidth + 'px';
    },
    
    _resetItemWidths: function PPSMA__picker$_resetItemWidths() {
        this._listElement.style.width = parseInt(this._selectedItem.currentStyle.width) + PPSMA._picker._defaultListOffset + 'px';
        for (var index = 0; index < this._listElement.childNodes.length; index++) {
            var item = this._listElement.childNodes[index];
            if (item) {
                item.style.width = this._listElement.style.width;
                item.itemCaption.style.width = this._listElement.style.width;
            }
        }
    }
}


////////////////////////////////////////////////////////////////////////////////
// PPSMA._pickerItem

PPSMA._pickerItem = function PPSMA__pickerItem(caption, tag) {
    this._events = new Sys.EventHandlerList();
    this.element = document.createElement('li');
    var itemCaption = document.createElement('a');
    this.element.className = 'pps-pickerListItem';
    this.element.itemCaption = itemCaption;
    this.element.tag = tag;
    itemCaption.href = 'javascript://';
    itemCaption.innerText = caption;
    this.element.appendChild(itemCaption);
    Sys.UI.DomEvent.addHandler(this.element, 'mouseover', Function.createDelegate(null, PPSMA._pickerItem._element_onmouseover));
    Sys.UI.DomEvent.addHandler(this.element, 'mouseout', Function.createDelegate(null, PPSMA._pickerItem._element_mouseout));
    Sys.UI.DomEvent.addHandler(this.element, 'click', Function.createDelegate(this, this._element_onclick));
    Sys.UI.DomEvent.addHandler(this.element.itemCaption, 'focus', Function.createDelegate(null, PPSMA._pickerItem._caption_onfocus));
    Sys.UI.DomEvent.addHandler(this.element.itemCaption, 'blur', Function.createDelegate(null, PPSMA._pickerItem._caption_onblur));
}
PPSMA._pickerItem._element_onmouseover = function PPSMA__pickerItem$_element_onmouseover(e) {
    var pickerItem = e.target;
    if (!pickerItem.itemCaption) {
        pickerItem = pickerItem.parentNode;
    }
    pickerItem.itemCaption.focus();
    Sys.UI.DomElement.addCssClass(pickerItem, 'pps-pickerListItemActive');
    e.stopPropagation();
}
PPSMA._pickerItem._caption_onfocus = function PPSMA__pickerItem$_caption_onfocus(e) {
    var pickerItem = e.target.parentNode;
    Sys.UI.DomElement.addCssClass(pickerItem, 'pps-pickerListItemActive');
    e.stopPropagation();
}
PPSMA._pickerItem._element_mouseout = function PPSMA__pickerItem$_element_mouseout(e) {
    var pickerItem = e.target;
    Sys.UI.DomElement.removeCssClass(pickerItem, 'pps-pickerListItemActive');
    e.stopPropagation();
}
PPSMA._pickerItem._caption_onblur = function PPSMA__pickerItem$_caption_onblur(e) {
    var pickerItem = e.target.parentNode;
    Sys.UI.DomElement.removeCssClass(pickerItem, 'pps-pickerListItemActive');
    e.stopPropagation();
}
PPSMA._pickerItem.prototype = {
    element: null,
    _eventKey_Click: 'Click',
    
    add_click: function PPSMA__pickerItem$add_click(value) {
        this._events.addHandler(this._eventKey_Click, value);
    },
    remove_click: function PPSMA__pickerItem$remove_click(value) {
        this._events.removeHandler(this._eventKey_Click, value);
    },
    
    _raiseClickEvent: function PPSMA__pickerItem$_raiseClickEvent() {
        var handler = this._events.getHandler(this._eventKey_Click);
        if (handler) {
            handler(this, new Sys.EventArgs());
        }
    },
    
    dispose: function PPSMA__pickerItem$dispose() {
        if (this.element) {
            Sys.UI.DomEvent.clearHandlers(this.element.itemCaption);
            Sys.UI.DomEvent.clearHandlers(this.element);
            this.element = null;
        }
    },
    
    _element_onclick: function PPSMA__pickerItem$_element_onclick(e) {
        var pickerItem = e.target;
        if (!pickerItem.itemCaption) {
            pickerItem = pickerItem.parentNode;
        }
        this._raiseClickEvent();
        e.stopPropagation();
    }
}


////////////////////////////////////////////////////////////////////////////////
// PPSMA._URI

PPSMA._URI = function PPSMA__URI() {
}
PPSMA._URI.createUri = function PPSMA__URI$createUri(url, arguments) {
    var sb = new Sys.StringBuilder(url);
    if (arguments) {
        sb.append('?');
        sb.append(PPSMA._URI.createQueryString(arguments));
    }
    return sb.toString();
}
PPSMA._URI.createQueryString = function PPSMA__URI$createQueryString(arguments) {
    var sb = new Sys.StringBuilder();
    var $dict1 = arguments;
    for (var $key2 in $dict1) {
        var entry = { key: $key2, value: $dict1[$key2] };
        if (!sb.isEmpty()) {
            sb.append('&');
        }
        sb.append(String.format('{0}={1}', entry.key, encodeURIComponent((entry.value))));
    }
    return sb.toString();
}


////////////////////////////////////////////////////////////////////////////////
// PPSMA.WebPartViewManager

PPSMA.WebPartViewManager = function PPSMA_WebPartViewManager(views, partId) {
    this._displayableViews = [];
    this._views = views;
    this._id = partId.replace(new RegExp('^ctl00_WebPartManager'), '');
    for (var i = 0; i < views.length; ++i) {
        var viewProxy = views[i];
        PPSMA.DashboardController.get_instance().addProxyMap(viewProxy.get__id(), viewProxy.displayTitle, viewProxy, this);
    }
    this._partElement = $get('WebPart' + this._id);
    this._titleElement = $get('WebPartTitle' + this._id);
    if (!isNullOrUndefined(this._titleElement)) {
        this._titleElement.innerHTML = '';
        this._titleElement.title = '';
        this._titleElement.style.width = '100%';
        this._titleElement.style.whiteSpace = 'nowrap';
        this._titleElement.parentNode.parentNode.parentNode.style.borderCollapse = 'collapse';
    }
    this._containerElement = this._partElement;
    while (this._containerElement.nodeName !== 'TABLE') {
        this._containerElement = this._containerElement.parentNode;
    }
    this._hideSelf();
    for (var viewIndex = 0; viewIndex < this._views.length; viewIndex++) {
        var view = this._views[viewIndex];
        view.add__viewRendered(Function.createDelegate(this, this.webPartViewManager_ViewRendered));
    }
}
PPSMA.WebPartViewManager._setViewPickerCaptionWidth = function PPSMA_WebPartViewManager$_setViewPickerCaptionWidth(view, viewPicker) {
    var viewTarget = $get(view._targetId);
    var viewCaptionWidth = view.getViewContainerWidth(viewTarget);
    if (viewCaptionWidth === 'auto' || viewCaptionWidth === '' || viewCaptionWidth.endsWith('%')) {
        viewCaptionWidth = Sys.UI.DomElement.getBounds(viewTarget).width + 'px';
    }
    viewPicker.setCaptionWidth(viewCaptionWidth);
}
PPSMA.WebPartViewManager.prototype = {
    _views: null,
    _id: null,
    _partElement: null,
    _titleElement: null,
    _containerElement: null,
    _activeView: null,
    _viewPicker: null,
    
    dispose: function PPSMA_WebPartViewManager$dispose() {
        if (this._displayableViews) {
            Array.clear(this._displayableViews);
            this._displayableViews = null;
        }
        if (this._views) {
            for (var i = 0; i < this._views.length; ++i) {
                var proxy = this._views[i];
                proxy.dispose();
                this._views[i] = null;
            }
            this._views = null;
        }
        if (this._viewPicker) {
            this._viewPicker.dispose();
            this._viewPicker = null;
        }
    },
    
    _updateActiveView: function PPSMA_WebPartViewManager$_updateActiveView() {
        Array.clear(this._displayableViews);
        for (var i = 0; i < this._views.length; ++i) {
            var view = this._views[i];
            if (view.isDisabled) {
                continue;
            }
            if (view.get__visibleState() === PPSMA._proxyVisibleState.visible) {
                Array.add(this._displayableViews, view);
            }
        }
        if (!this._displayableViews.length) {
            this._hideSelf();
            return;
        }
        if (this._activeView && this._activeView.get__visibleState() === PPSMA._proxyVisibleState.visible) {
            this._activeView._isDisplayed = true;
            this._updateTitle();
            this._displaySelf();
            if (this._activeView.get__isRenderUpdateRequired()) {
                this._activeView.beginRenderControl();
            }
            return;
        }
        var newActiveView = null;
        for (var i = 0; i < this._displayableViews.length; ++i) {
            var view = this._displayableViews[i];
            if (!newActiveView) {
                newActiveView = view;
            }
            view._isDisplayed = false;
        }
        this._setActiveView(newActiveView);
    },
    
    _setActiveView: function PPSMA_WebPartViewManager$_setActiveView(view) {
        if (this._activeView && this._activeView.get__visibleState() === PPSMA._proxyVisibleState.visible) {
            this._activeView._isDisplayed = false;
        }
        this._activeView = view;
        this._activeView._isDisplayed = true;
        if (this._partElement) {
            this._partElement.setAttribute('helpLink', this._activeView.helpLink);
            this._partElement.setAttribute('helpMode', '1');
        }
        this._updateTitle();
        this._displaySelf();
        this._activeView.beginRenderControl();
    },
    
    _displaySelf: function PPSMA_WebPartViewManager$_displaySelf() {
        this._containerElement.style.display = 'block';
    },
    
    _hideSelf: function PPSMA_WebPartViewManager$_hideSelf() {
        this._containerElement.style.display = 'none';
    },
    
    _updateTitle: function PPSMA_WebPartViewManager$_updateTitle() {
        if (!isNullOrUndefined(this._titleElement)) {
            this._titleElement.title = this._activeView.displayTitle;
            var listItems = [];
            for (var i = 0; i < this._displayableViews.length; ++i) {
                var view = this._displayableViews[i];
                if (view !== this._activeView) {
                    Array.add(listItems, { caption: view.displayTitle, tag: view });
                }
            }
            var isSelectable = listItems.length > 0;
            if (this._viewPicker) {
                this._viewPicker.dispose();
            }
            this._viewPicker = new PPSMA._picker(this._activeView.displayTitle, isSelectable, this._activeView.useSharePointStyle);
            PPSMA.WebPartViewManager._setViewPickerCaptionWidth(this._activeView, this._viewPicker);
            if (isSelectable) {
                this._viewPicker.add_itemSelected(Function.createDelegate(this, this.viewPicker_ItemSelected));
                this._viewPicker.addPickerItems(listItems);
            }
            if (this._activeView.isAllowOpenNewWindow) {
                this._viewPicker.add_captionSelected(Function.createDelegate(this, this._viewPicker_CaptionSelected));
            }
            this._titleElement.innerHTML = '';
            this._titleElement.appendChild(this._viewPicker._element);
        }
    },
    
    _viewPicker_CaptionSelected: function PPSMA_WebPartViewManager$_viewPicker_CaptionSelected(sender, e) {
        this._activeView._openNewWindow();
    },
    
    viewPicker_ItemSelected: function PPSMA_WebPartViewManager$viewPicker_ItemSelected(sender, args) {
        this._setActiveView(args.itemElement.tag);
    },
    
    webPartViewManager_ViewRendered: function PPSMA_WebPartViewManager$webPartViewManager_ViewRendered(sender, e) {
        var view = sender;
        if (this._viewPicker) {
            PPSMA.WebPartViewManager._setViewPickerCaptionWidth(view, this._viewPicker);
        }
    },
    
    activeViewExportToPowerPoint: function PPSMA_WebPartViewManager$activeViewExportToPowerPoint() {
        if (!this._activeView) {
            return;
        }
        this._activeView._exportToPowerPoint();
    },
    
    activeViewExportToExcel: function PPSMA_WebPartViewManager$activeViewExportToExcel() {
        if (!this._activeView) {
            return;
        }
        this._activeView._exportToExcel();
    },
    
    activeViewOpenNewWindow: function PPSMA_WebPartViewManager$activeViewOpenNewWindow() {
        if (!this._activeView) {
            return;
        }
        this._activeView._openNewWindow();
    },
    
    activeViewReset: function PPSMA_WebPartViewManager$activeViewReset() {
        if (!this._activeView) {
            return;
        }
        this._activeView._resetView();
    }
}


////////////////////////////////////////////////////////////////////////////////
// PPSMA.ParameterizableControlProxy

PPSMA.ParameterizableControlProxy = function PPSMA_ParameterizableControlProxy(controlFactoryPath, targetControlId, targetControlType, proxyId) {
    this._events = new Sys.EventHandlerList();
    this._inboundParameterMessages = [];
    Sys.Debug.trace(String.format('{0}.constructor', proxyId));
    this._proxyId = proxyId;
    this._controlFactoryPath = controlFactoryPath;
    this._targetId = targetControlId;
    this._targetType = targetControlType;
    this.set__visibleState(PPSMA._proxyVisibleState.hidden);
}
PPSMA.ParameterizableControlProxy._ppsXmlDecode = function PPSMA_ParameterizableControlProxy$_ppsXmlDecode(txt) {
    txt = txt.replace(new RegExp('&lt;', 'g'), '<');
    txt = txt.replace(new RegExp('&gt;', 'g'), '>');
    txt = txt.replace(new RegExp('&apos;', 'g'), '\'');
    txt = txt.replace(new RegExp('&quot;', 'g'), '\"');
    txt = txt.replace(new RegExp('&amp;', 'g'), '&');
    txt = txt.replace(new RegExp('{PPSMACRI}lt', 'g'), '&lt;');
    txt = txt.replace(new RegExp('{PPSMACRI}gt', 'g'), '&gt;');
    txt = txt.replace(new RegExp('{PPSMACRI}apos', 'g'), '&apos;');
    txt = txt.replace(new RegExp('{PPSMACRI}quot', 'g'), '&quot;');
    txt = txt.replace(new RegExp('{PPSMACRI}amp', 'g'), '&amp;');
    return txt;
}
PPSMA.ParameterizableControlProxy.prototype = {
    isAllowExportToExcel: false,
    isAllowExportToPowerPoint: false,
    isAllowOpenNewWindow: false,
    
    get__visibleState: function PPSMA_ParameterizableControlProxy$get__visibleState() {
        return this._visibleState;
    },
    set__visibleState: function PPSMA_ParameterizableControlProxy$set__visibleState(value) {
        this._visibleState = value;
        if (this._visibleState !== PPSMA._proxyVisibleState.visible) {
            this._isDisplayed = false;
        }
        return value;
    },
    
    _visibleState: 0,
    _isDisplayed: false,
    isDisabled: false,
    
    get_navigateContext: function PPSMA_ParameterizableControlProxy$get_navigateContext() {
        return this._navigateContext;
    },
    set_navigateContext: function PPSMA_ParameterizableControlProxy$set_navigateContext(value) {
        this._navigateContext = (!value) ? '' : value;
        return value;
    },
    
    _navigateContext: '',
    
    add__viewRendered: function PPSMA_ParameterizableControlProxy$add__viewRendered(value) {
        this._events.addHandler(PPSMA.ParameterizableControlProxy._eventKey_viewRendered, value);
    },
    remove__viewRendered: function PPSMA_ParameterizableControlProxy$remove__viewRendered(value) {
        this._events.removeHandler(PPSMA.ParameterizableControlProxy._eventKey_viewRendered, value);
    },
    
    _cachedResult: null,
    _controlFactoryPath: null,
    dashboardId: '',
    
    get__id: function PPSMA_ParameterizableControlProxy$get__id() {
        return this.dashboardItemId;
    },
    
    dashboardItemId: '',
    displayTitle: '',
    isTitleBarVisible: true,
    helpLink: '',
    heightMultiplier: 0,
    useSharePointStyle: false,
    _disposableViews: null,
    
    get__isRenderUpdateRequired: function PPSMA_ParameterizableControlProxy$get__isRenderUpdateRequired() {
        return this._isRenderUpdateRequired;
    },
    set__isRenderUpdateRequired: function PPSMA_ParameterizableControlProxy$set__isRenderUpdateRequired(value) {
        if (value) {
            this._cachedResult = null;
            this._resetNavigateContext();
        }
        this._isRenderUpdateRequired = value;
        return value;
    },
    
    _isRenderUpdateRequired: true,
    isParameterUIControl: false,
    _proxyId: null,
    resourcePath: '',
    _targetType: null,
    widthMultiplier: 0,
    _targetId: null,
    _renderWebRequest: null,
    
    dispose: function PPSMA_ParameterizableControlProxy$dispose() {
        if (this._renderWebRequest) {
            this._renderWebRequest.dispose();
            this._renderWebRequest = null;
        }
        this._disposeOfViews();
    },
    
    registerDisposableView: function PPSMA_ParameterizableControlProxy$registerDisposableView(view) {
        if (!this._disposableViews) {
            this._disposableViews = [];
        }
        Array.add(this._disposableViews, view);
    },
    
    unregisterDisposableView: function PPSMA_ParameterizableControlProxy$unregisterDisposableView(view) {
        if (!this._disposableViews) {
            return;
        }
        Array.remove(this._disposableViews, view);
    },
    
    _disposeOfViews: function PPSMA_ParameterizableControlProxy$_disposeOfViews() {
        if (!this._disposableViews) {
            return;
        }
        for (var i = 0; i < this._disposableViews.length; ++i) {
            var view = this._disposableViews[i];
            view.dispose();
        }
        Array.clear(this._disposableViews);
        this._disposableViews = null;
    },
    
    subscribeTo: function PPSMA_ParameterizableControlProxy$subscribeTo(publishingDashboardItemId, bindingId, parameterUniqueName) {
        var publisher = PPSMA.DashboardController.get_instance()._getViewProxy(publishingDashboardItemId);
        if (!publisher) {
            return;
        }
        if (publisher.isDisabled) {
            return;
        }
        PPSMA.DashboardController.get_instance().addProxyRenderDependency(this.dashboardItemId, bindingId, publishingDashboardItemId, parameterUniqueName);
        Array.add(this._inboundParameterMessages, PPSMA.$create__parameterMessage(bindingId, publisher.dashboardItemId, parameterUniqueName));
    },
    
    subscribeToParameter: function PPSMA_ParameterizableControlProxy$subscribeToParameter(bindingId, publisherDashboardItemId, publisherParameterUniqueName) {
        var message = PPSMA.$create__parameterMessage(bindingId, publisherDashboardItemId, publisherParameterUniqueName);
        Array.add(this._inboundParameterMessages, message);
        if (!window.opener) {
            alert(PPSMA.SR.Dashboard_ParentWindowClosed);
            window.close();
        }
        var transitionState = window.opener.PPSMA.Dashboard.get_temporalTransitionState();
        var key = PPSMA._parametersTable._key(publisherDashboardItemId, publisherParameterUniqueName);
        var openerParameter = transitionState[key];
        PPSMA.DashboardController.get_instance().addNewParameter(publisherDashboardItemId, openerParameter._uniqueName, openerParameter._keyColumn, openerParameter._displayColumn);
        PPSMA.DashboardController.get_instance().updateParameter(publisherDashboardItemId, openerParameter.get__id(), openerParameter.get_values());
        PPSMA.DashboardController.get_instance().addProxyRenderDependency(this.get__id(), bindingId, publisherDashboardItemId, openerParameter.get__id());
    },
    
    _createInboundParameterMessagesXml: function PPSMA_ParameterizableControlProxy$_createInboundParameterMessagesXml() {
        var sendingMessages = [];
        for (var i = 0; i < this._inboundParameterMessages.length; ++i) {
            var message = this._inboundParameterMessages[i];
            Array.add(sendingMessages, message);
            var publisher = PPSMA.DashboardController.get_instance()._getViewProxy(message.dashboardItemId);
            if (publisher) {
                for (var n = 0; n < publisher._inboundParameterMessages.length; n++) {
                    if (!this._isParamExists(this._inboundParameterMessages, (publisher._inboundParameterMessages[n]).mappingId, (publisher._inboundParameterMessages[n]).dashboardItemId, (publisher._inboundParameterMessages[n]).parameterUniqueName)) {
                        Array.add(sendingMessages, publisher._inboundParameterMessages[n]);
                    }
                }
            }
        }
        var xml = new Sys.StringBuilder();
        for (var i = 0; i < sendingMessages.length; ++i) {
            var message = sendingMessages[i];
            var parameter = PPSMA.DashboardController.get_instance()._getParameter(message.dashboardItemId, message.parameterUniqueName);
            if (null !== parameter) {
                xml.append('<ParameterMessage>');
                xml.append(parameter._serializeXml());
                xml.append('<MappingId><![CDATA[' + message.mappingId + ']]></MappingId>');
                xml.append('<DashboardItemId><![CDATA[' + message.dashboardItemId + ']]></DashboardItemId>');
                xml.append('</ParameterMessage>');
            }
        }
        return xml.toString();
    },
    
    updateTitleDisplay: function PPSMA_ParameterizableControlProxy$updateTitleDisplay(titleElementId) {
        var paramTitleElement = $get(titleElementId);
        if (paramTitleElement) {
            if (this.isTitleBarVisible) {
                paramTitleElement.style.display = 'block';
            }
            else {
                paramTitleElement.style.display = 'none';
            }
        }
    },
    
    beginRenderControl: function PPSMA_ParameterizableControlProxy$beginRenderControl() {
        var viewContainerElement = $get(this._targetId);
        if (!viewContainerElement) {
            return;
        }
        if (this.get__visibleState() !== PPSMA._proxyVisibleState.visible || !this._isDisplayed) {
            return;
        }
        this._setViewContainerBounds(viewContainerElement);
        if (!this._isRenderUpdateRequired) {
            if (this._cachedResult) {
                window.setTimeout(Function.createDelegate(this, function() {
                    Sys.Debug.trace(String.format('{0}.BeginRenderControl: using cache', this._proxyId));
                    this._renderResult(this._cachedResult);
                }), 0);
                return;
            }
        }
        if (!this._renderWebRequest) {
            if (this.isParameterUIControl) {
                this._renderWebRequest = new PPSMA._noCancelWebRequest(viewContainerElement);
            }
            else {
                this._renderWebRequest = new PPSMA._cancellableWebRequest(viewContainerElement);
            }
        }
        this._renderWebRequest.show();
        for (var i = 0; i < this._inboundParameterMessages.length; ++i) {
            var message = this._inboundParameterMessages[i];
            var parameter = PPSMA.DashboardController.get_instance()._getParameter(message.dashboardItemId, message.parameterUniqueName);
            if (isNullOrUndefined(parameter) || parameter._state === PPSMA._parameterState.pendingChange) {
                Sys.Debug.trace(String.format('{0}.BeginRenderControl: exit: parameter={1} not defined or initialized', this._proxyId, (isNullOrUndefined(parameter)) ? '{empty}' : parameter._uniqueName));
                return;
            }
        }
        var arguments = {};
        arguments[PPSMA.ParameterizableControlProxy._argKey_DashboardId] = this.dashboardId;
        arguments[PPSMA.ParameterizableControlProxy._argKey_ResourcePath] = this.resourcePath;
        arguments[PPSMA.ParameterizableControlProxy._argKey_TargetControlId] = this._targetId;
        arguments[PPSMA.ParameterizableControlProxy._argKey_TargetControlType] = this._targetType;
        arguments[PPSMA.ParameterizableControlProxy._argKey_ProxyId] = this._proxyId;
        arguments[PPSMA.ParameterizableControlProxy._argKey_AvailableHeight] = viewContainerElement.style.height;
        arguments[PPSMA.ParameterizableControlProxy._argKey_AvailableWidth] = viewContainerElement.style.width;
        arguments[PPSMA.ParameterizableControlProxy._argKey_DashboardItemId] = this.dashboardItemId;
        arguments[PPSMA.ParameterizableControlProxy._argKey_InboundParameters] = this._createInboundParameterMessagesXml();
        arguments[PPSMA.ParameterizableControlProxy._argKey_NavigateContext] = this._navigateContext;
        var details = PPSMA.$create__webRequestDetails(this._controlFactoryPath, PPSMA._URI.createQueryString(arguments), 'POST', 'application/x-www-form-urlencoded', Function.createDelegate(this, this._onWebRequestCompleted));
        this._renderWebRequest.submit(details);
        Sys.Debug.trace(String.format('{0}.BeginRenderControl: send ajax request', this._proxyId));
    },
    
    _getViewContainerHeight: function PPSMA_ParameterizableControlProxy$_getViewContainerHeight(containerElement) {
        var targetHeight = containerElement.currentStyle.height;
        if (this.heightMultiplier && containerElement.currentStyle.height === 'auto') {
            var calculatedHeight = (this.heightMultiplier * PPSMA.Dashboard.get__rootElementBounds().height) - PPSMA.Common._viewHeightOffset;
            if (calculatedHeight < PPSMA.Common._viewMinimumSize.height) {
                calculatedHeight = PPSMA.Common._viewMinimumSize.height;
            }
            targetHeight = Math.ceil(calculatedHeight) + 'px';
        }
        return targetHeight;
    },
    
    getViewContainerWidth: function PPSMA_ParameterizableControlProxy$getViewContainerWidth(containerElement) {
        var targetWidth = containerElement.currentStyle.width;
        if (this.widthMultiplier && containerElement.currentStyle.width === 'auto') {
            var calculatedWidth = (this.widthMultiplier * PPSMA.Dashboard.get__rootElementBounds().width) - PPSMA.Common._viewWidthOffset;
            if (calculatedWidth < PPSMA.Common._viewMinimumSize.width) {
                calculatedWidth = PPSMA.Common._viewMinimumSize.width;
            }
            targetWidth = Math.ceil(calculatedWidth) + 'px';
        }
        return targetWidth;
    },
    
    _onWebRequestCompleted: function PPSMA_ParameterizableControlProxy$_onWebRequestCompleted(requestExecutor) {
        if (requestExecutor.get_aborted()) {
            Sys.Debug.trace(String.format('{0}.OnWebRequestCompleted: aborted ajax request detected', this._proxyId));
            return;
        }
        this._renderWebRequest.dispose();
        this._renderWebRequest = null;
        var error = true;
        if (requestExecutor.get_statusCode() === 200) {
            if (requestExecutor.get_responseAvailable() && '' !== requestExecutor.get_responseData()) {
                this.set__isRenderUpdateRequired(false);
                this._renderResult(requestExecutor.get_responseData());
                error = false;
            }
        }
        if (error) {
            Sys.Debug.trace(String.format('{0}.OnWebRequestCompleted: statusCode={1}', this._proxyId, requestExecutor.get_statusCode()));
            if (null !== this._targetId) {
                var target = $get(this._targetId);
                if (null !== target) {
                    target.style.position = 'static';
                    target.innerHTML = String.format('<div class=pps-reportErrorDiv><div class=pps-reportErrorTable>{0}</div></div>', PPSMA.SR.Dashboard_Render_UnexpectedError);
                }
            }
        }
    },
    
    _resetNavigateContext: function PPSMA_ParameterizableControlProxy$_resetNavigateContext() {
        this._navigateContext = '';
    },
    
    _renderResult: function PPSMA_ParameterizableControlProxy$_renderResult(result) {
        Sys.Debug.trace(String.format('{0}.RenderResult', this._proxyId));
        var outerDelimiter = '{0874F91A-7AA4-44f4-98D5-D856A1163A6D}';
        var innerDelimiter = '{1657B459-2B94-40df-8898-3FF36D5CA474}';
        var trimmedText = result;
        this._cachedResult = result;
        var indexOfFirst = trimmedText.indexOf(outerDelimiter);
        if (indexOfFirst > 0) {
            trimmedText = trimmedText.substr(indexOfFirst);
        }
        if (trimmedText.length > 9) {
            if ('</string>' === trimmedText.substr(trimmedText.length - 9)) {
                trimmedText = trimmedText.substring(0, trimmedText.length - 9);
            }
        }
        var renderingInstructions = trimmedText.split(outerDelimiter);
        if (null !== renderingInstructions) {
            this._disposeOfViews();
            for (var i = 0; i < renderingInstructions.length; i++) {
                if (null !== renderingInstructions[i] && '' !== renderingInstructions[i]) {
                    var tokens = renderingInstructions[i].split(innerDelimiter);
                    if (null !== tokens) {
                        if (tokens.length >= 3) {
                            var id = tokens[0];
                            var html = tokens[1];
                            var script = tokens[2];
                            if (null !== html && '' !== html) {
                                html = PPSMA.ParameterizableControlProxy._ppsXmlDecode(html);
                            }
                            if (null !== script && '' !== script) {
                                script = PPSMA.ParameterizableControlProxy._ppsXmlDecode(script);
                                try {
                                    eval(script);
                                }
                                catch (ex) {
                                    alert(ex.message);
                                }
                            }
                            else {
                                if (null !== id) {
                                    var target = $get(id);
                                    if (null !== target) {
                                        target.style.position = 'static';
                                        target.innerHTML = html;
                                    }
                                }
                            }
                            this._raiseViewRendered();
                        }
                    }
                }
            }
        }
    },
    
    _raiseViewRendered: function PPSMA_ParameterizableControlProxy$_raiseViewRendered() {
        var handler = this._events.getHandler(PPSMA.ParameterizableControlProxy._eventKey_viewRendered);
        if (handler) {
            handler(this, Sys.EventArgs.Empty);
        }
    },
    
    _setViewContainerBounds: function PPSMA_ParameterizableControlProxy$_setViewContainerBounds(containerElement) {
        containerElement.style.height = this._getViewContainerHeight(containerElement);
        containerElement.style.width = this.getViewContainerWidth(containerElement);
        containerElement.style.display = 'block';
        containerElement.style.position = 'relative';
    },
    
    _exportToPowerPoint: function PPSMA_ParameterizableControlProxy$_exportToPowerPoint() {
        if (this.get__isRenderUpdateRequired()) {
            alert(PPSMA.SR.Dashboard_WaitUpdate_ExportPowerPoint);
            return;
        }
        if (!this.isAllowExportToPowerPoint) {
            alert(PPSMA.SR.Dashboard_NoExportPowerPoint);
            return;
        }
        var arguments = {};
        arguments[PPSMA.ParameterizableControlProxy._argKey_DashboardId] = this.dashboardId;
        arguments[PPSMA.ParameterizableControlProxy._argKey_ResourcePath] = this.resourcePath;
        arguments[PPSMA.ParameterizableControlProxy._argKey_TargetControlId] = this._targetId;
        arguments[PPSMA.ParameterizableControlProxy._argKey_TargetControlType] = this._targetType;
        arguments[PPSMA.ParameterizableControlProxy._argKey_ProxyId] = this._proxyId;
        arguments[PPSMA.ParameterizableControlProxy._argKey_DashboardItemId] = this.dashboardItemId;
        arguments[PPSMA.ParameterizableControlProxy._argKey_InboundParameters] = this._createInboundParameterMessagesXml();
        arguments[PPSMA.ParameterizableControlProxy._argKey_NavigateContext] = this._navigateContext;
        arguments[PPSMA.ParameterizableControlProxy._argKey_ExportFormat] = 'PowerPoint';
        arguments[PPSMA.ParameterizableControlProxy._argKey_CustomExportSettings] = this._navigateContext;
        arguments[PPSMA.ParameterizableControlProxy._argKey_DashboardHypertextLink] = window.location;
        PPSMA.HttpPost.get_instance().downloadFile(this.resourcePath + 'OfficeExportPage.aspx', arguments);
    },
    
    _exportToExcel: function PPSMA_ParameterizableControlProxy$_exportToExcel() {
        if (this.get__isRenderUpdateRequired()) {
            alert(PPSMA.SR.Dashboard_WaitUpdate_ExportExcel);
            return;
        }
        if (!this.isAllowExportToExcel) {
            alert(PPSMA.SR.Dashboard_NoExportExcel);
            return;
        }
        var arguments = {};
        arguments[PPSMA.ParameterizableControlProxy._argKey_DashboardId] = this.dashboardId;
        arguments[PPSMA.ParameterizableControlProxy._argKey_ResourcePath] = this.resourcePath;
        arguments[PPSMA.ParameterizableControlProxy._argKey_TargetControlId] = this._targetId;
        arguments[PPSMA.ParameterizableControlProxy._argKey_TargetControlType] = this._targetType;
        arguments[PPSMA.ParameterizableControlProxy._argKey_ProxyId] = this._proxyId;
        arguments[PPSMA.ParameterizableControlProxy._argKey_DashboardItemId] = this.dashboardItemId;
        arguments[PPSMA.ParameterizableControlProxy._argKey_InboundParameters] = this._createInboundParameterMessagesXml();
        arguments[PPSMA.ParameterizableControlProxy._argKey_NavigateContext] = this._navigateContext;
        arguments[PPSMA.ParameterizableControlProxy._argKey_ExportFormat] = 'Excel';
        arguments[PPSMA.ParameterizableControlProxy._argKey_CustomExportSettings] = this._navigateContext;
        arguments[PPSMA.ParameterizableControlProxy._argKey_DashboardHypertextLink] = window.location;
        PPSMA.HttpPost.get_instance().downloadFile(this.resourcePath + 'OfficeExportPage.aspx', arguments);
    },
    
    _openNewWindow: function PPSMA_ParameterizableControlProxy$_openNewWindow() {
        if (this.get__isRenderUpdateRequired()) {
            alert(PPSMA.SR.Dashboard_WaitUpdate_NewWindow);
            return;
        }
        for (var i = 0; i < this._inboundParameterMessages.length; ++i) {
            var message = this._inboundParameterMessages[i];
            var parameter = PPSMA.DashboardController.get_instance()._getParameter(message.dashboardItemId, message.parameterUniqueName);
            var persisted = parameter._clone();
            var key = PPSMA._parametersTable._key(message.dashboardItemId, message.parameterUniqueName);
            PPSMA.Dashboard.get_temporalTransitionState()[key] = parameter;
        }
        var arguments = {};
        arguments[PPSMA.ParameterizableControlProxy._argKey_DashboardId] = this.dashboardId;
        arguments[PPSMA.ParameterizableControlProxy._argKey_DashboardItemId] = this.dashboardItemId;
        arguments[PPSMA.ParameterizableControlProxy._argKey_NavigateContext] = this._navigateContext;
        var url = this.resourcePath + 'DynamicView.aspx';
        window.open(PPSMA._URI.createUri(url, arguments));
    },
    
    _resetView: function PPSMA_ParameterizableControlProxy$_resetView() {
        this._navigateContext = '';
        this.set__isRenderUpdateRequired(true);
        this.beginRenderControl();
    },
    
    _isParamExists: function PPSMA_ParameterizableControlProxy$_isParamExists(InboundParameterMessages, pubMsgMappingId, pubMsgDashboardItemId, pubMsgParameterUniqueName) {
        if (!InboundParameterMessages.length) {
            return false;
        }
        for (var i = 0; i < InboundParameterMessages.length; i++) {
            if ((InboundParameterMessages[i]).mappingId === pubMsgMappingId && (InboundParameterMessages[i]).dashboardItemId === pubMsgDashboardItemId && (InboundParameterMessages[i]).parameterUniqueName === pubMsgParameterUniqueName) {
                return true;
            }
        }
        return false;
    }
}


////////////////////////////////////////////////////////////////////////////////
// PPSMA.Dashboard

PPSMA.Dashboard = function PPSMA_Dashboard() {
}
PPSMA.Dashboard.precacheImages = function PPSMA_Dashboard$precacheImages(images) {
    Sys.Debug.traceDump(images, 'PrecacheImages');
    precacheImages(images);
}
PPSMA.Dashboard.get__rootElementBounds = function PPSMA_Dashboard$get__rootElementBounds() {
    if (!PPSMA.Dashboard._rootElementBounds) {
        var point = Sys.UI.DomElement.getLocation(PPSMA.Dashboard.get__rootElement());
        var width = document.body.clientWidth - point.x;
        var height = document.body.clientHeight - point.y;
        PPSMA.Dashboard._rootElementBounds = new Sys.UI.Bounds(point.x, point.y, width, height);
    }
    return PPSMA.Dashboard._rootElementBounds;
}
PPSMA.Dashboard.set__rootElementBounds = function PPSMA_Dashboard$set__rootElementBounds(value) {
    PPSMA.Dashboard._rootElementBounds = value;
    return value;
}
PPSMA.Dashboard.get__rootElement = function PPSMA_Dashboard$get__rootElement() {
    if (!PPSMA.Dashboard._rootElement) {
        PPSMA.Dashboard._rootElement = $get('ppsDashboardRootElement');
        if (!PPSMA.Dashboard._rootElement) {
            PPSMA.Dashboard._rootElement = $get('MSO_ContentTable');
        }
    }
    return PPSMA.Dashboard._rootElement;
}
PPSMA.Dashboard.get_temporalTransitionState = function PPSMA_Dashboard$get_temporalTransitionState() {
    if (!PPSMA.Dashboard._parametersTemporalState) {
        PPSMA.Dashboard._parametersTemporalState = {};
    }
    return PPSMA.Dashboard._parametersTemporalState;
}


////////////////////////////////////////////////////////////////////////////////
// PPSMA.Common

PPSMA.Common = function PPSMA_Common() {
}
PPSMA.Common.get_isSharepoint = function PPSMA_Common$get_isSharepoint() {
    return PPSMA.Common._isSharepoint;
}
PPSMA.Common.set_isSharepoint = function PPSMA_Common$set_isSharepoint(value) {
    PPSMA.Common._isSharepoint = value;
    if (!value) {
        PPSMA.Common._viewWidthOffset = 32;
        PPSMA.Common._viewHeightOffset = 50;
    }
    return value;
}
PPSMA.Common._toPixels = function PPSMA_Common$_toPixels(n) {
    return String.format('{0}px', n);
}
PPSMA.Common._getContainerType = function PPSMA_Common$_getContainerType(container) {
    var containerType = PPSMA.CommonContainerType.undefined;
    if (container.currentStyle) {
        var currentStyle = container.currentStyle;
        if (currentStyle.width === 'auto' && currentStyle.height === 'auto') {
            containerType = PPSMA.CommonContainerType.autosize;
        }
        else if (parseInt(currentStyle.width) > 0 && currentStyle.height === 'auto') {
            containerType = PPSMA.CommonContainerType.autoHeight;
        }
        else if (currentStyle.width === 'auto' && parseInt(currentStyle.height) > 0) {
            containerType = PPSMA.CommonContainerType.autoWidth;
        }
        else if (parseInt(currentStyle.width) > 0 && parseInt(currentStyle.height) > 0) {
            containerType = PPSMA.CommonContainerType.explicit;
        }
        else {
            throw Error.create('Error getting ContainerType');
        }
    }
    return containerType;
}


PPSMA._renderWebRequest.registerClass('PPSMA._renderWebRequest', null, Sys.IDisposable);
PPSMA._cancellableWebRequest.registerClass('PPSMA._cancellableWebRequest', PPSMA._renderWebRequest);
PPSMA._parametersTable.registerClass('PPSMA._parametersTable');
PPSMA.DashboardController.registerClass('PPSMA.DashboardController', null, Sys.IDisposable);
PPSMA.DomElementEx.registerClass('PPSMA.DomElementEx');
PPSMA._noCancelWebRequest.registerClass('PPSMA._noCancelWebRequest', PPSMA._renderWebRequest);
PPSMA._fileDownload.registerClass('PPSMA._fileDownload', null, Sys.IDisposable);
PPSMA.HttpPost.registerClass('PPSMA.HttpPost', null, Sys.IDisposable);
PPSMA.NewWindow.registerClass('PPSMA.NewWindow');
PPSMA.PageOverview.registerClass('PPSMA.PageOverview');
PPSMA.ParameterDefinition.registerClass('PPSMA.ParameterDefinition');
PPSMA._pickerItemSelectedEventArgs.registerClass('PPSMA._pickerItemSelectedEventArgs', Sys.EventArgs);
PPSMA._picker.registerClass('PPSMA._picker', null, Sys.IDisposable);
PPSMA._pickerItem.registerClass('PPSMA._pickerItem', null, Sys.IDisposable);
PPSMA._URI.registerClass('PPSMA._URI');
PPSMA.WebPartViewManager.registerClass('PPSMA.WebPartViewManager', null, Sys.IDisposable);
PPSMA.ParameterizableControlProxy.registerClass('PPSMA.ParameterizableControlProxy', null, Sys.IDisposable);
PPSMA.Dashboard.registerClass('PPSMA.Dashboard');
PPSMA.Common.registerClass('PPSMA.Common');
PPSMA._cancellableWebRequest._loadingTextPadding$1 = '   ';
PPSMA._cancellableWebRequest._defaultHeight$1 = 60;
PPSMA._cancellableWebRequest._defaultWidth$1 = 150;
PPSMA.DashboardController._singleton = null;
PPSMA._noCancelWebRequest._defaultHeight$1 = 25;
PPSMA._noCancelWebRequest._defaultWidth$1 = 100;
PPSMA._fileDownload._iframeCounter = 0;
PPSMA.HttpPost._httpPost = null;
PPSMA._picker._eventKey_ItemSelected = 'ItemSelected';
PPSMA._picker._eventKey_CaptionSelected = 'CaptionSelected';
PPSMA._picker._defaultCaptionOffset = 37;
PPSMA._picker._defaultListOffset = 20;
PPSMA._picker._defaultPickerWidth = 200;
PPSMA.ParameterizableControlProxy._eventKey_viewRendered = 'ViewRendered';
PPSMA.ParameterizableControlProxy._argKey_DashboardId = 'dashboardId';
PPSMA.ParameterizableControlProxy._argKey_ResourcePath = 'resourcePath';
PPSMA.ParameterizableControlProxy._argKey_TargetControlId = 'targetControlId';
PPSMA.ParameterizableControlProxy._argKey_TargetControlType = 'targetControlType';
PPSMA.ParameterizableControlProxy._argKey_ProxyId = 'proxyId';
PPSMA.ParameterizableControlProxy._argKey_AvailableHeight = 'availableHeight';
PPSMA.ParameterizableControlProxy._argKey_AvailableWidth = 'availableWidth';
PPSMA.ParameterizableControlProxy._argKey_DashboardItemId = 'dashboardItemId';
PPSMA.ParameterizableControlProxy._argKey_InboundParameters = 'inboundParameters';
PPSMA.ParameterizableControlProxy._argKey_NavigateContext = 'navigateContext';
PPSMA.ParameterizableControlProxy._argKey_ExportFormat = 'exportFormat';
PPSMA.ParameterizableControlProxy._argKey_CustomExportSettings = 'customExportSettings';
PPSMA.ParameterizableControlProxy._argKey_DashboardHypertextLink = 'dashboardHypertextLink';
PPSMA.Dashboard._rootElementBounds = null;
PPSMA.Dashboard._rootElement = null;
PPSMA.Dashboard._parametersTemporalState = null;
PPSMA.Common._loadingDivDefaultSize = new Sys.UI.Bounds(0, 0, 32, 32);
PPSMA.Common._viewMinimumSize = new Sys.UI.Bounds(0, 0, 45, 45);
PPSMA.Common._viewWidthOffset = 20;
PPSMA.Common._viewHeightOffset = 40;
PPSMA.Common._isSharepoint = true;



// -----------------------------------
function isNullOrUndefined(o) 
{
    return (o === null) || (o === undefined);
}

function isNullOrEmpty(o) 
{
    return !o || !o.length;
}

function isNullUndefinedOrEmpty(o) 
{
    return (o === null) || (o === undefined) || (!o.length);
}

function precacheImages(images)
{
	var precache = new Array();
	for(var i=0; i < images.length; ++i)
	{
		image = new Image(1,1);
		image.src = images[i];
		precache[i] = image;
	}
	return precache;
}

if (window.screenLeft === undefined || window.screenLeft === null)
{
	window.screenLeft = window.screenX;
	window.screenTop = window.screenY;
}

if (Sys.Browser.agent == Sys.Browser.InternetExplorer)
{
    Sys.UI.DomElement.getLocation = function Sys$UI$DomElement$getLocation(element) {
        var e = Function._validateParams(arguments, [
            {name: "element", domElement: true}
        ]);
        if (e) throw e;
        if (element.self || element.nodeType === 9) return new Sys.UI.Point(0,0);
        var clientRect = element.getBoundingClientRect();
        if (!clientRect) {
            return new Sys.UI.Point(0,0);
        }
        var documentElement = element.ownerDocument.documentElement;
        var offsetX = clientRect.left - 2 + documentElement.scrollLeft,
              offsetY = clientRect.top - 2 + documentElement.scrollTop;
        try {
            var f = element.ownerDocument.parentWindow.frameElement || null;
            if (f) {
                var offset = (f.frameBorder === "0" || f.frameBorder === "no") ? 2 : 0;
                offsetX += offset;
                offsetY += offset;
            }
        }
        catch(ex) { }    
        return new Sys.UI.Point(offsetX, offsetY);
    }
}

if(typeof(Sys)!=='undefined')Sys.Application.notifyScriptLoaded();