function refreshSocialChurnFeed(response_data){
  var sc, a, b, c;

  var sc = document.getElementById("sc_widget");
  
  sc.innerHTML = "";
  var a, b, c, container;

  container = document.createElement('div');
  container.className = "sc_container";
  sc.appendChild(container);

  for (var i in response_data){
  a = document.createElement('div');
  a.id = "ce_" + response_data[i].id;
  a.className = "sc_entry";

  // Profile Pic
  b = document.createElement('img');
  b.src = response_data[i].url;
  c = document.createElement('div');
  c.className = "sc_img";
  c.appendChild(b);
  a.appendChild(c);

  // Text
  c = document.createElement('div');
  c.className = "sc_name";
  c.innerHTML = response_data[i].name;
  a.appendChild(c);
  
  c = document.createElement('div');
  c.className = "sc_message";
  c.innerHTML = response_data[i].message;
  a.appendChild(c);


  container.appendChild(a);

  }
}




function JSONscriptRequest(fullUrl) {
    // REST request path
    this.fullUrl = fullUrl; 
    // Keep IE from caching requests
    this.noCacheIE = '&noCacheIE=' + (new Date()).getTime();
    // Get the DOM location to put the script tag
    this.headLoc = document.getElementsByTagName("head").item(0);
    // Generate a unique script tag id
    this.scriptId = 'JscriptId' + JSONscriptRequest.scriptCounter++;
}


JSONscriptRequest.scriptCounter = 1;

// buildScriptTag method
//
JSONscriptRequest.prototype.buildScriptTag = function () {

    // Create the script tag
    this.scriptObj = document.createElement("script");
    
    // Add script object attributes
    this.scriptObj.setAttribute("type", "text/javascript");
    this.scriptObj.setAttribute("charset", "utf-8");
    this.scriptObj.setAttribute("src", this.fullUrl + this.noCacheIE);
    this.scriptObj.setAttribute("id", this.scriptId);
}
 
// removeScriptTag method
// 
JSONscriptRequest.prototype.removeScriptTag = function () {
    // Destroy the script tag
    this.headLoc.removeChild(this.scriptObj);  
}

// addScriptTag method
//
JSONscriptRequest.prototype.addScriptTag = function () {
    // Create the script tag
    this.headLoc.appendChild(this.scriptObj);
    
}


// Application Specific Code:
  // Define the callback function
  function callbackfunc(jsonData) {     
     refreshSocialChurnFeed(jsonData);
     bObj.removeScriptTag(); 
  }
var req  = 'http://app.socialchurn.com/feed/3bc62a30-306a-012f-a9c4-4040934e44b0.js'; 
document.write("<div id='sc_widget'>...</div>");
bObj = new JSONscriptRequest(req); 
bObj.buildScriptTag(); 
bObj.addScriptTag();





