jQuery(function($) {
   var nextID = 0;
   var pendingcallbacks = {};
   function ebaycallback(root) {
     callback = pendingcallbacks[root.CorrelationID];
     if (callback) {
       pendingcallbacks[root.CorrelationID] = undefined;
       callback(root);
     }
   }
   $.ebay = $.extend({
	
     appid: "Buyonint-4d5f-45d2-8cbb-4fc4ff848eea",
     endpointURL: "http://open.api.ebay.com/shopping",
     siteid: 71, // The US
     call: function (callname, arguments, callback) {
       if ($.ebay.appid == "<appid required>") {
         console.error("eBay Shopping API jQuery plugin requires that $.ebay.appid be set before an calls are made");
       }
       var messageid = "jqueryebayshoppingapi" + (nextID++);
       // Set up the callback
       pendingcallbacks[messageid] = callback;
       window["_cb_" + callname] = ebaycallback;
       // Make the call
       /*
         &appid=$appID&ItemID=$itemID";
        $apicall .= "&responseencoding=XML";
        $apicall .= "&IncludeSelector=$includeSelector";
       */ 
       
       arguments = $.extend({callname: callname,
                             appid: $.ebay.appid,
                             version: 517,
                             siteid: $.ebay.siteid,
                             MessageID: messageid,
                             responseencoding: "JSON",
                             /*IncludeSelector: "ShippingCosts,Details,Description",*/
                             callback: "true"}, arguments);
       $.ajax({url: $.ebay.endpointURL, dataType: "script", cache: true, data: arguments});
       
       var encodedparams = [];
       $.each(arguments, function (key,value) {
       encodedparams[encodedparams.length] =  (key + "=" + escape(value));
       })
        var url = $.ebay.endpointURL + "?" + encodedparams.join("&");
       /* console.log(url); */
       
     }}, $.ebay || {});
});
