widgetContext = { "wid": "efc8f6beec08b5222bd4a66de4ff7556-25", "url": "http://widgets.chalkpartners.com/embed-widgets/efc8f6beec08b5222bd4a66de4ff7556-25/content/", "width": "300", "height": "250", "jquery": "http://widgets.chalkpartners.com/misc/jquery.js", "new_placement": "http://widgets.chalkpartners.com/embed-widgets/js/get-code/%252F", "base_url": "http://widgets.chalkpartners.com/" }
// $Id: iframe.js,v 1.7.2.3 2009/09/09 03:08:02 jtsnow Exp $

// Test for minimal Javascript required.
if (document.getElementsByTagName && document.createElement && document.createTextNode && document.documentElement && document.getElementById) {

	if (navigator.appName == 'Microsoft Internet Explorer') {
		IE = true;
	} else {
		IE = false;
	}

	var DrupalEmbed = DrupalEmbed || [];
	DrupalEmbed[DrupalEmbed.length] = {
	  src: widgetContext['url'],
	  wid: widgetContext['wid'],
	  width: widgetContext['width'],
	  height: widgetContext['height'],
	  jquery: widgetContext['jquery'],
	  new_placement: widgetContext['new_placement'],
	  newID: false,
	  base_url: widgetContext['base_url']
	};

	if (typeof embedWidgetInsert == 'undefined') {
	  embedWidgetInsert = function () {
			
		  for (var i in DrupalEmbed) {
				
		    if (!DrupalEmbed[i]['processed']) {
		      DrupalEmbed[i]['processed'] = true;
		      
		      var separator = DrupalEmbed[i].src.indexOf('?') == -1 ? '?' : '&';
		      
		      // Keep track of how many widgets are embedded in this document.
		      if(undefined===window.widget_count){
		        window.widget_count = 0;
		      }
		      else {
		        widget_count++;
		      }

					
		      // Use unique ID for each widget on the page.
		      var script = document.getElementById('widget-embed-script-' + DrupalEmbed[i].wid);
		      script.setAttribute('id', 'widget-embed-script-' + DrupalEmbed[i].wid + widget_count);

					// widget_parent_swf_wrapper div
					var div = document.createElement('div');
					//div.setAttribute('id', 'widget-parent-swf-wrapper');
					if (!IE) {
						div.setAttribute('style', 'height:100px;left:-9999px;position:absolute;top:0px;width:100px;');
					} else {
						div.style.height = "100px";
						div.style.left = "-9999px";
						div.style.position = "absolute";
						div.style.top = "0px";
						div.style.width = "100px";
					}

					var swfId = "widget-parent-swf";
					var swfSrc = DrupalEmbed[0].base_url + "parent.swf";
					var swfWidth = 200;
					var swfHeight = 100;
					var swfParams = {
						allowScriptAccess: "always",
						flashVars: "WID=widget-embed-wid-"+ DrupalEmbed[i].wid +"&myConnID=" + (navigator.userAgent + DrupalEmbed[i].wid).replace(/([^a-zA-Z0-9\-]+)/g, '').toLowerCase()
					};
					var obj = '<object' + ((window.ActiveXObject)? ' id="' + swfId + '" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" data="' + swfSrc + '"' : '');
							obj += ' width="' + swfWidth + '"';
							obj += ' height="' + swfHeight + '"';
							obj += '>';
					var param = '<param';
							param += ' name="movie"';
							param += ' value="' + swfSrc + '"';
							param += '>';
							param += '';
					var extraParams = '';
					var extraAttributes = '';
					for(var swfParam in swfParams){
						extraParams += '<param name="' + swfParam + '" value="' + swfParams[swfParam] + '">';
						extraAttributes += ' ' + swfParam + '="' + swfParams[swfParam] + '"';
					}
					var embed = '<embed id="' + swfId + '" src="' + swfSrc + '" type="application/x-shockwave-flash" width="' + swfWidth + '" height="' + swfHeight + '"';
					var embedEnd = extraAttributes + '></embed>';
					var objEnd = '</object>';
					div.innerHTML = obj + param + extraParams + embed + embedEnd + objEnd;

					// Insert div into document.
					script.parentNode.insertBefore(div, script);
					
		      // Create iframe element.
		      var iframe = document.createElement('iframe');
		      iframe.setAttribute('id', 'widget-embed-' + widget_count);
					
					// IE and NOT IE8 
					if (IE && !(document.documentMode && document.documentMode == 8)) {
						iframe.setAttribute('className', 'widget-embed-wid-' + DrupalEmbed[i].wid);
					} else {
						iframe.setAttribute('class', 'widget-embed-wid-' + DrupalEmbed[i].wid);
					}
		      iframe.setAttribute('frameBorder', '0');
		      iframe.setAttribute('width', DrupalEmbed[i].width);
		      //iframe.setAttribute('height', '0');
					iframe.setAttribute('height', DrupalEmbed[i].height);
		      iframe.setAttribute('scrolling', 'no');
		      
		      /*if (DrupalEmbed[i].height) {
		        iframe.myHeight = DrupalEmbed[i].height;
		      }
		      if (DrupalEmbed[i].width) {
                iframe.myWidth = DrupalEmbed[i].width;
		      }*/

		      iframe.setAttribute('src', DrupalEmbed[i].src + separator + 'widgets_mode=' + DrupalEmbed[i].wid);
		      
		      // Set correct iframe height each time content in iframe changes.
		     /* iframe.onload = function () {
		  	        var iframeDocument = this.contentDocument ? this.contentDocument : (this.contentWindow ? this.contentWindow.document : null);
		  	        
		  	        if (iframeDocument) {
		  	          var height = this.myHeight;
		  	          var width = this.myWidth;

		  	          this.setAttribute('height', height);
		  	          this.setAttribute('width', width);
		  	          
		  	        }
		      };*/
					
		      // Insert iframe into document.
		      script.parentNode.insertBefore(iframe, script);

		    }
		  }
	  };
	}

	var headID = document.getElementsByTagName("head")[0]; 
  if (typeof jQuery == 'undefined') {  
    var newScript = document.createElement('script');
    newScript.type = 'text/javascript';
    newScript.onload = embedWidgetInsert;
    newScript.src = DrupalEmbed[0].jquery;
    headID.appendChild(newScript);
  }

	if (typeof widgetParentJS == 'undefined') {
		widgetParentJS = true;
		var widgetsScript = document.createElement('script');
		widgetsScript.type = 'text/javascript';
		widgetsScript.src = DrupalEmbed[0].base_url + "widgets.js";
		headID.appendChild(widgetsScript);
	}

  embedWidgetInsert();

}


