﻿//uses global jQuery Instance.
function RPMakeStubLoader1(jqueryIdent, jsonPurl) {
    window.JsonPropListCallBack = function(myObj) {
        if (myObj.CSSLink != "")
            jQuery("head").append('<link rel="stylesheet" type="text/css" href="' + myObj.CSSLink + '" />');
        window.RPJQuery = jQuery;
        jQuery(jqueryIdent).html(myObj.Content);
    }
    return function() {
        jQuery.ajax({
            dataType: 'jsonp',
            cache: true,
            url: jsonPurl,
            jsonpCallback: 'JsonPropListCallBack'
        });
    }
}
//uses jQuery instance passed into the loader.
function RPMakeStubLoaderJQ1(jQuery, jqueryIdent, jsonPurl) {
    function RPMakeStubLoader1A(jqueryIdent, jsonPurl) {
        window.JsonPropListCallBack = function(myObj) {
            window.RPJQRef1
            if (myObj.CSSLink != "")
                jQuery("head").append('<link rel="stylesheet" type="text/css" href="' + myObj.CSSLink + '" />');
            //Set the RPJQuery to this instance for now.  If needed later, whatever javascript in myObj.Content 
            //will have to capture it and save it for later in case this gets replaced.
            window.RPJQuery = jQuery;
            jQuery(jqueryIdent).html(myObj.Content);
        }
        
        return function() {
            jQuery.ajax({
                dataType: 'jsonp',
                cache: true,
                url: jsonPurl,
                jsonpCallback: 'JsonPropListCallBack'
            });
        }
    }
    jQuery(document).ready(RPMakeStubLoader1A(jqueryIdent, jsonPurl));

}
