﻿//function OpenPopUpFromRibbon_DownloadOptions(_primaryEntityTypeName, _firstPrimaryItemId, _selectedEntityTypeName, _selectedControlSelectedItemIds, _commandProperties, _action, _fileFormat, _autoSubmit)
//{
//    var url = _getUrl() + "/WebResources" + "/iotap_DownloadOptions.htm";
//    if (_commandProperties == undefined && _action == undefined && _fileFormat == undefined && _autoSubmit == undefined)
//        var webResourceData = encodeURIComponent(_primaryEntityTypeName + '|' + _firstPrimaryItemId);
//    else
//        var webResourceData = encodeURIComponent(_primaryEntityTypeName + '|' + _firstPrimaryItemId + '|' + _selectedEntityTypeName + '|' + _selectedControlSelectedItemIds + '|' + _commandProperties.SourceControlId + '|' + _action + '|' + _fileFormat + '|' + _autoSubmit);

//    //Xrm.Utility.openWebResource(url, webResourceData, 430, 500)
//    var features = "location=no,menubar=no,status=no,toolbar=no,width=400,height=500,top=200,left=500";
//    window.open(url + "?Data=" + webResourceData, "_blank", features, false);
//}

function OpenPopUp_DownloadOptions(_primaryEntityTypeName, _firstPrimaryItemId) {
    var url = _getUrl() + "/WebResources" + "/iotap_DownloadOptions.htm";
    var webResourceData = encodeURIComponent(_primaryEntityTypeName + '|' + _firstPrimaryItemId);
    //Xrm.Utility.openWebResource(url, webResourceData, 430, 500)
    var features = "location=no,menubar=no,status=no,toolbar=no,resizable=yes,width=380,height=310,top=200,left=500";
    window.open(url + "?Data=" + webResourceData, "_blank", features, false);
}

function _getUrl()
{
    var url = Xrm.Page.context.getClientUrl();
    if (url.match(/\/$/))
        url = url.substring(0, url.length - 1);
    if (typeof Xrm.Page.context.getClientUrl != "undefined")
        url = Xrm.Page.context.getClientUrl();
    return url;
};