

/* jQuery vimeo widget application adapted by Anne Breckbill, November 2008 from http://www.publicradio.org/columns/marketplace/gettingpersonal/feed_widget/feed_widget.js developed by Ari Koinuma, September 2008.  
This script will parse an Json file and spits out a div which contains the listing of entries.  What gets displayed are user-configurable.  

Documentation: http://infoserverwiki.publicradio.org/index.php/JQuery
Dependency: jquery 1.2.6, vimeo_widget_class.js, vimeo_widget_form.js
*/

/* Specific to MKP's Whiteboard Vimeo series 
Be sure to put the vimeo initials to the variable names in case there are more than one vimeo widget embedded on a page. */

var wbVimUser = "marketplace";
var wbVimStream = "album";
var wbVimId = "37581";
var wbVLogoCode = "mkpLogo";
var wbVFormURL = "http://marketplace.publicradio.org/tools/widgets/whiteboard_video_widget/";
var wbVButtonURL = "http://www.americanpublicmedia.org/standard/images/apm001/widgets/get_widget.gif";

VWidget.prototype.wb_buildVWidget = function() {
	var customURL ="http://vimeo.com/hubnut/?user_id=" + this.vimUser + "&amp;color=" + this.txtColor + "&amp;background=" + this.backColor + "&amp;fullscreen=1&amp;slideshow=" + this.autoSlide + "&amp;stream=" + this.vimStream + "&amp;id=" + this.vimId + "&amp;server=vimeo.com";
	
	//next, construct the global elements, such as blog title and link
	var moduleDiv = $('<div id="' + this.widgetId + '" style="background: #ffffff; padding: 0px; width: ' + this.width + 'px; border: 1px solid '	+ this.borderColor + '"></div>');
	//put branding on top
	moduleDiv.append(this.logoCode);
	

	//show the "Get this Widget" button or close brand section
	if (this.showGetButton == 1) {
		var buttonCode = '<a class="getWidgetButton" href="'+this.formURL+'" title="Get This Widget"><img src="'+this.buttonURL+'" alt="Get This Widget" border="0" align="right" style="margin:2px"></a><br style="clear:both;" />';
	} else {
		var buttonCode = '<br style="clear:both;" />';
	}
	moduleDiv.append(buttonCode);
	
	
	var videoObject = $('<object type="application/x-shockwave-flash" width="'+this.width+'" height="'+this.height+'" data="'+customURL + '">\n <param name="quality" value="best" />\n <param name="allowfullscreen" value="true" />\n <param name="scale" value="showAll" />\n <param name="movie" value="'+customURL+'" /></object>');
	moduleDiv.append(videoObject);
	
	//hidden iFrame for tracking
	var trackFrame = $('<iframe src="http://americanpublicmedia.publicradio.org/standard/js/all_domains/jquery/vimeo_widget/tracker.html?widget='+this.widgetId+'" style="display: none;"></iframe>');
	moduleDiv.append(trackFrame);
	
	//Finally, append the whole thing to the target div.
	$('#'+this.targetId).append(moduleDiv);
}



//Construct the vwidget object.  But the actual displaying of the vwidget will be taken care of by the inline code user embeds. 
function wbVExecute() {
	/*Here's the constructor of the vwidget object: vwidget(widgetId, vimUser, vimStream, vimId, logoCode, formURL, buttonURL)  vimeoInitial+VWidget is the target div ID.  logoCode will be already assigned to a global variable by the class -- so it's going to be either apmLogo or mprLogo.*/
	var widgetName = new VWidget('wbVWidget', wbVimUser, wbVimStream, wbVimId, mkpLogo, wbVFormURL, wbVButtonURL);
	return widgetName;
}

//execute
var wbVWidget = wbVExecute();

