﻿var a2bPopup = {
    Result: null,

    setupPopup: function(src, closeCallback, height, width) {
        this.Result = null;

        if (!height) {
            height = 450;
        }
        if (!width) {
            width = 830
        }

        var loadingHtml = '<div id="divWait" style="height:50px"><span class="spinner-big">Loading...</span></div>';
        $.modal(loadingHtml + '<iframe src="' + src + '" height="' + height + '" width="' + width + '" style="border:0">', {
            containerCss: {
                backgroundColor: "#fff",
                borderColor: "#0063dc",
                height: height,
                padding: 0,
                width: width
            },
            overlayClose: false,
            onClose: function() {
                // 1) Close the actual popup
                $.modal.close();

                // 2) Take whatever action is appropriate based on the value(s) retrieved from the popup.
                closeCallback(a2bPopup.Result);
            }
        });
    },

    close: function(result) {
        if (result) {
            a2bPopup.Result = result;
        }
        jQuery.modal.close(true);
    }
}


///**************************************************************
//* Popup for Adding UIDs to this Contract
//*************************************************************/
//$("#id").click(function() {

//    <%
//        RouteValueDictionary options = new RouteValueDictionary();
//        
//        // src_ goes into Query String
//        options.Add("src_Controller", "UID");
//        options.Add("src_Action", "ForNotInCustodyContractJSON");
//        options.Add("src_ContractPid", Model.Contract.PID);
//        
//        // ok_ set as Hidden fields for POST
//        options.Add("ok_Caption", "Append");
//        options.Add("ok_Controller", "CustodyContract");
//        options.Add("ok_Action", "AppendUidsJSON");
//        options.Add("ok_ContractPid", Model.Contract.PID);
//    %>
//    
//    var src = '<%= Url.Action("Popup", "UID", options)%>';
//                   
//    setupPopup(src, refreshUIDGrid);
//    
//    return false;
//}
///**************************************************************
//* End of UID popup
//*************************************************************/
//});

//function myCallback(popupResult)
//{
////Do something
//}
