/*
 * Dynamic tag cloud, FigmentEngine.com 2008
 * version 1.2
 * reuse: feel free to reuse this script on your blog
 * or page
 * history:
 * v1.0 - first release
 * v1.1 - paremeter driven cloud id, navigation to posts, co-occurance lines
 * v1.2 - removes clients access policy issue for cross domain requests
 * v1.3 - updated xap
 */


/*
 * function feTagCloudLoad(feFeeds):
 * inserts a silverlight widget into the element
 * with the id 'feCloud',
 * Parameters:
 *  'elementId' the id of the element to create the cloud in
 *  'feed' the location of the rss feed
 *  'navigateFormat'
 *  'width' 
 *  'height' 
 * to specify tha address of the blogs feed
 */
function feTagCloudLoad(elementId, feed, navigateFormat, width, height)
{
  var params = "";

  if (feed != null)
    params += "feedAddress=" + feed + ", ";
  if (navigateFormat != null)
    params += "navigateFormat=" + navigateFormat + ", ";

  var slWidth = 350;
  if (width)
   slWidth = width;
  params += "width=" + slWidth + ", "; 

  var slHeight = 350;
  if (height)
   slHeight = height;

  var container = document.getElementById(elementId);
  var cloudControl = document.createElement('object');
  
  cloudControl.setAttribute('data', 'data:application/x-silverlight-2,');
  cloudControl.setAttribute('type', 'application/x-silverlight-2');
  cloudControl.setAttribute('id', 'feCloudControl');
  container.appendChild(cloudControl);

  var host = "http://www.figmentengine.com/";
  var source = host + "tagCloud/TagCloudV1.4.xap";
  var parentElement = container;
  var callbackId = "feCloud";
  var properties = { width: slWidth, height: slHeight, version: "2.0.31005.0", enableHtmlAccess: "true" };
  var events = { };
  var initParams = params;
  Silverlight.createObject(source, parentElement,
   callbackId, properties, events, initParams);
}