﻿/* **************************************

 w3mm Versioning
 3.0 - Josh Scribner
 
***************************************** */

var mmbaseurl="/ibm/multimedia/w3mm/3/";
var mmamanagersetup=0;

function w3aManager(playtxt,stoptxt, downloadtxt) {
	this.playtxt=playtxt;
	this.stoptxt=stoptxt;
	this.downloadtxt=downloadtxt;

	this.idcount=0;

	if (typeof(_w3aManager_prototype_called) == 'undefined') {
		_w3aManager_prototype_called = true;
		w3aManager.prototype.writeSetup = writeSetup;
		w3aManager.prototype.writeAudio = writeAudio;
	}
	function writeSetup() {
		if(mmamanagersetup) {
			//Only can be setup once.
		} else {
			mmamanagersetup=1;
			document.write("<sc"+"ript language=\"javascript\" type=\"text/javascript\">");
			document.write("	var podPressBackendURL=\""+mmbaseurl+"podpress/\";");
			document.write("	var podPressText_PlayNow = \""+this.playtxt+"\";");
			document.write("	var podPressText_HidePlayer = \""+this.stoptxt+"\";");
			document.write("</sc"+"ript>");
		}
	}

	function writeAudio(audioURL, transcriptURL) {
		this.idcount=this.idcount+1;
		document.write("<div id=\"podPressPlayerSpace_"+this.idcount+"\" style=\"display: none; margin-bottom: 0px;\"></div>");
		document.write("<div class=\"podPress_content\"><img src=\""+mmbaseurl+"images/aud.gif\" alt=\"\" border=\"0\" height=\"16\" width=\"16\">&nbsp;&nbsp;<a class='fbox' href=\"javascript:void(null);\" onclick=\"podPressShowHidePlayerDiv('podPressPlayerSpace_"+this.idcount+"', 'mp3Player_"+this.idcount+"_0', '300:30', '"+audioURL+"'); return false;\"><b><span id=\"podPressPlayerSpace_"+this.idcount+"_label_mp3Player_"+this.idcount+"_0\">"+this.playtxt+"</span></b></a> or <a class=\"fbox\" href=\""+audioURL+"\" target=\"new\"><b>"+downloadtxt+"</b></a><br></div>");
		document.write("<div><img src=\""+mmbaseurl+"images/ebook_pdf_icon.png\" alt=\"\" border=\"0\" width=\"14\">&nbsp;&nbsp;"+(transcriptURL!=""?"<a href=\""+transcriptURL+"\">Show notes</a>":"")+"</div>");
	}
}
var podPressDivName = ''; 
function podPressLoadPageIntoDiv2(divname, paramDimensionSetting, paramMediaFile) {
	var responseTextHTML="";
	var pWidth=paramDimensionSetting.substring(0,paramDimensionSetting.indexOf(":"))-10;
	var pHeight=paramDimensionSetting.substring(paramDimensionSetting.indexOf(":")+1,paramDimensionSetting.length)-4;
	podPressDivName = divname;
	responseTextHTML=responseTextHTML+"<object type=\"application/x-shockwave-flash\" data=\"http://domino.research.ibm.com/comm/www_innovate.nsf/images/gio-podcast-podpress/$FILE/player.swf\" width=\""+pWidth+"\" height=\""+pHeight+"\" id=\"audioplayer9957\">";
	responseTextHTML=responseTextHTML+"	<param name=\"movie\" value=\"http://domino.research.ibm.com/comm/www_innovate.nsf/images/gio-podcast-podpress/$FILE/player.swf\" />";
	responseTextHTML=responseTextHTML+"	<param name=\"FlashVars\" value=\"playerID=9957&amp;bg=0xF8F8F8&amp;leftbg=0xEEEEEE&amp;text=0x666666&amp;lefticon=0x666666&amp;rightbg=0xCCCCCC&amp;rightbghover=0x999999&amp;righticon=0x666666&amp;righticonhover=0xFFFFFF&amp;slider=0x666666&amp;track=0xFFFFFF&amp;loader=0x9FFFB8&amp;border=0x666666&amp;autostart=yes&amp;soundFile="+escape(paramMediaFile)+"\" />";
	responseTextHTML=responseTextHTML+"	<param name=\"quality\" value=\"high\" />";
	responseTextHTML=responseTextHTML+"	<param name=\"menu\" value=\"false\" />";
	responseTextHTML=responseTextHTML+"	<param name=\"wmode\" value=\"transparent\" />";
	responseTextHTML=responseTextHTML+"</object><br/><br/>";
	document.getElementById(divname).innerHTML=responseTextHTML;  
}

function podPressShowHidePlayerDiv(divname, oftype, dimensionSetting, mediaFile, forceShow) {
	 if(document.getElementById(divname).title != '' && document.getElementById(divname).title != oftype) {
		var prev_oftype = document.getElementById(divname).title; 
		if(document.getElementById(divname+'_label_'+prev_oftype) != undefined) {
			document.getElementById(divname+'_label_'+prev_oftype).innerHTML=podPressText_PlayNow;
		}
	}
	document.getElementById(divname).title = oftype;
	if(forceShow == 'yes') {
		document.getElementById(divname+'_label_'+oftype).innerHTML=podPressText_HidePlayer;
		document.getElementById(divname).style.display='block';
		podPressLoadPageIntoDiv2(divname, dimensionSetting, mediaFile);
	} else {
		if(document.getElementById(divname+'_label_'+oftype).innerHTML == podPressText_PlayNow) {
			document.getElementById(divname+'_label_'+oftype).innerHTML=podPressText_HidePlayer;
			document.getElementById(divname).style.display='block';
			podPressLoadPageIntoDiv2(divname, dimensionSetting, mediaFile);

		} else {
			if(document.getElementById('winplayer') != undefined) {
				if(document.getElementById('winplayer').controls) {
					document.getElementById('winplayer').controls.stop();
				}
				document.getElementById(divname+'_label_'+oftype).innerHTML=podPressText_PlayNow;
				document.getElementById(divname).style.display='none';
			} else {
				document.getElementById(divname+'_label_'+oftype).innerHTML=podPressText_PlayNow;
				document.getElementById(divname).style.display='none';
				document.getElementById(divname).innerHTML='';
			}
		}
	} 
}
function ap_stopAll() {
	//Function not provided, placeholder to avoid JS error msg.
}
/////////////////////////////////////////////////////////////////////////////


function w3mmManager(divname,embedtype,offerbandwidth,title,backgroundimagesrc,backgroundimagealt,backgroundtext) {
	this.divname=divname;	//a string, must equal the name of the variable used to store this object.
	this.embedtype=embedtype;	//"main" or "right"
	this.offerbandwidth=offerbandwidth;	//boolean -- show bandwidth toggle, 0=false (all content is high-bandwidth) or 1=true (both)
	this.title=title; //text, i.e. "Tune in"
	this.bgsrc=backgroundimagesrc; //URL of an image to appear in the background. alternatives: "curtain" "curtain-video-only" "curtain-no-text."
	this.bgalt=backgroundimagealt;
	this.bgtxt=backgroundtext;

	this.items=[];	// array of w3mmItem's

	this.w3mmbroad=0;		//is this in broadband mode? 1=true, 0=false
	this.playingItem=-1;	//id# of playing #. -1=nothing playing.
	if (typeof(_w3mmManager_prototype_called) == 'undefined') {
		_w3mmManager_prototype_called = true;
		w3mmManager.prototype.addItem = addItem;
		w3mmManager.prototype.write = write;
		w3mmManager.prototype.writeMenu = writeMenu;
		w3mmManager.prototype.writeEmbed = writeEmbed;
		w3mmManager.prototype.bwWM = bwWM;
		w3mmManager.prototype.playItem = playItem;
		w3mmManager.prototype.doPlayerSwap = doPlayerSwap;
	}

	function addItem(itemname) {
		this.items[this.items.length]=itemname;
	}



	function write() {
		if(this.embedtype=="right") {
			document.write("<div class=\"color-block\" id=\"callout1\" "+(this.embedtype=="right"?"style=\"margin-left: -10px; margin-right: -40px; position: absolute; z-index:10;\"":"")+">");
		} else if(this.embedtype=="inline-left") {
			document.write("<div class=\"sidebar-left\" style=\"width: 274px\">");
		} else if(this.embedtype=="inline-right") {
			document.write("<div class=\"sidebar-right\" style=\"width: 274px\">");
		}	
		this.writeEmbed();

		if(this.embedtype=="right") {
			document.write("</div><div class=\"color-block\" id=\"callout1\" "+(this.embedtype=="right"?"style=\"margin-top: 310px;\"":"")+">" );
		}

		//Menu:
		this.writeMenu(0);
		if(this.embedtype=="right" | this.embedtype=="inline-left" | this.embedtype=="inline-right") {
			document.write("</div>"+(this.embedtype=="right"?"<br clear=\"all\" />":""));
		}
	}

	function writeMenu(useTables) {

		if(this.items.length>1) {
			document.write("<div id=\""+this.divname+"div-movieSelect\">");
			document.write("<div class=\"color-block\" id=\"callout2\">");
			if(useTables) {
				document.write("<table cellspacing=\"4\" cellpadding=\"0\" border=\"0\" width=\"100%\"><tr>");
			}
			for (var i=0; i<this.items.length; i++) {
				document.write("<!-- Menu Item "+(i+1)+" -->");
				if(useTables) {
					document.write("<td valign=\"top\" style=\"BORDER-RIGHT: #999999 "+((i+1)%3==0?"0":"1")+"px solid; BORDER-TOP: #999999 0px solid; BORDER-LEFT: #999999 0px solid; BORDER-BOTTOM: #999999 1px solid\" width=\"33%\" align=\"middle\">");
				}
				this.items[i].write(this.divname,i);		//We must tell the item which player the menu item should call.
				if(useTables) {
					document.write("</td>");
					if((i+1)%3==0) {
						document.write("</tr><tr>");
					}
				}
				document.write("<!-- /Menu Item "+(i+1)+" -->");
			}
			if(useTables) {
				document.write("</tr></table>");
			}

			document.write("</div></div>");
		} else if(this.items.length==1) {
			this.items[0].writelite(this.divname);
		}
	}
	function writeEmbed() {
		if(this.embedtype=="right" | this.embedtype=="inline-left" | this.embedtype=="inline-right") {
			document.write("<a name=\""+this.divname+"\"></a><h2 class=\"bar-green-med-light\" id=\""+this.divname+"div_vidboxStatus_small\" "+(this.embedtype=="right"?"style=\"MARGIN-RIGHT: -27px\"":"")+" >"+this.title+"</h2>");
			document.write("<div class=\"color-block\" id=\"callout1\" style=\"MARGIN-BOTTOM: 6px\">");
			if(this.items.length>1) {
				document.write("<iframe src=\""+mmbaseurl+"html/mmplayer_blankframe"+(this.bgsrc=="curtain"?"c.html?":".html?")+"call="+this.divname+"\" id=\""+this.divname+"_mmframesmall\" name=\""+this.divname+"_mmframesmall\" title=\"multimedia space\" frameborder=\"0\" scrolling=\"no\" marginheight=\"0\" marginwidth=\"0\" height=\"250\" width=\"274\" ><!-- --></iframe>");
			} else { 
				document.write("<iframe src=\""+mmbaseurl+"html/mmplayer_blankframe"+(this.bgsrc=="curtain"?"c.html?nomenu&":".html?nomenu&bkg="+this.bgsrc+"&")+"call="+this.divname+"\" id=\""+this.divname+"_mmframesmall\" name=\""+this.divname+"_mmframesmall\" title=\"multimedia space\" frameborder=\"0\" scrolling=\"no\" marginheight=\"0\" marginwidth=\"0\" height=\"250\" width=\"274\" ><!-- --></iframe>");
			}
			document.write("</div>");
		} else if (this.embedtype=="main") {
			document.write("<div class=\"sidebar-left\" id=\""+this.divname+"div_mmdivbig\" name=\""+this.divname+"div_mmdivbig\" width=\"99%\" style=\"MARGIN-TOP: 0px; MARGIN-BOTTOM: 5px; WIDTH: 99%; MARGIN-RIGHT: 4px\">");
			document.write("<a name=\""+this.divname+"\"></a><h2 class=\"bar-green-med-light\" id=\""+this.divname+"div_vidboxStatus_big\" width=\"100%\">"+this.title+"</h2>");
			document.write("<iframe src=\""+mmbaseurl+"html/mmplayer_blankframe"+(this.bgsrc=="curtain"?"c.html?":".html?")+"call="+this.divname+"\" id=\""+this.divname+"_mmframebig\" name=\""+this.divname+"_mmframebig\" title=\"multimedia space\" frameborder=\"0\" scrolling=\"no\" marginheight=\"0\" marginwidth=\"0\" style=\"WIDTH: 100%; HEIGHT: 330px\"><!-- --></iframe></div>");

			document.write("<div class=\"sidebar-left\" id=\""+this.divname+"div_mmdivsmall\" name=\""+this.divname+"div_mmdivsmall\" width=\"99%\" style=\"MARGIN-TOP: 0px; DISPLAY: none; MARGIN-BOTTOM: 5px; WIDTH: 99%; MARGIN-RIGHT: 4px\">");
			document.write("<a name=\""+this.divname+"\"></a><h2 class=\"bar-green-med-light\" id=\""+this.divname+"div_vidboxStatus_small\" width=\"100%\">"+this.title+"</h2>");
			document.write("<iframe src=\""+mmbaseurl+"html/mmplayer_blankframe"+(this.bgsrc=="curtain"?"c.html?":".html?")+"call="+this.divname+"\" id=\""+this.divname+"_mmframesmall\" name=\""+this.divname+"_mmframesmall\" title=\"multimedia space\" frameborder=\"0\" scrolling=\"no\" marginheight=\"0\" marginwidth=\"0\" style=\"WIDTH: 100%; HEIGHT: 270px\"><!-- --></iframe></div>");

			document.write("<br clear=\"all\" />");
			document.write("<p><!-- --></p>");
		} else {
			document.write("<p>Invalid w3mmManager Embed Type</p>");
		}
		this.bwWM(1);
	}
	function bwWM(bwwmhigh) {
		if(bwwmhigh) {
			this.w3mmbroad=1;
			if(this.embedtype=="main") {
				document.getElementById(this.divname+'div_mmdivsmall').style.display='none';
				document.getElementById(this.divname+'div_mmdivbig').style.display='';
				document.getElementById(this.divname+'div_vidboxStatus_big').innerHTML=this.title+"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<small>[ <a href=\"#\" onClick=\""+this.divname+".bwWM(0);\">Dialup</a> | <b>Broadband</b> ]</small>";

			}
			document.getElementById(this.divname+'div_vidboxStatus_small').innerHTML=this.title+"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<small>[ <a href=\"#\" onClick=\""+this.divname+".bwWM(0);\">Dialup</a> | <b>Broadband</b> ]</small>";
		} else {
			this.w3mmbroad=0;
			if(this.embedtype=="main") {
				document.getElementById(this.divname+'div_mmdivbig').style.display='none';
				document.getElementById(this.divname+'div_mmdivsmall').style.display='';
				document.getElementById(this.divname+'div_vidboxStatus_big').innerHTML=this.title+"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<small>[ <b>Dialup</b> | <a href=\"#\" onClick=\""+this.divname+".bwWM(1);\">Broadband</a> ]</small>";
			}
			document.getElementById(this.divname+'div_vidboxStatus_small').innerHTML=this.title+"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<small>[ <b>Dialup</b> | <a href=\"#\" onClick=\""+this.divname+".bwWM(1);\">Broadband</a> ]</small>";
		}
		if(this.playingItem>=0) {
			this.doPlayerSwap();
		}
	}
	function playItem(menuid) {
		if(menuid>=0 && menuid<this.items.length) {
			this.playingItem=menuid;
			this.doPlayerSwap();
		}
	}
	function doPlayerSwap() {
		if(this.embedtype=="right" | this.embedtype=="inline-right" | this.embedtype=="inline-left") {
			var directto=mmbaseurl+"html/mmplayerframe.html?"+(this.bgsrc=="curtain"?"mmcurtain&":"")+this.items[this.playingItem].getMediaType()+"="+(this.w3mmbroad==1?this.items[this.playingItem].getHigh():this.items[this.playingItem].getLow());
			frames[(this.divname+'_mmframesmall')].location.replace(directto);
		} else if(this.w3mmbroad==1) {
			frames[(this.divname+'_mmframebig')].location.replace(mmbaseurl+"html/mmplayerframe.html?big&"+(this.bgsrc=="curtain"?"mmcurtain&":"")+this.items[this.playingItem].getMediaType()+"="+this.items[this.playingItem].getHigh());
			frames[(this.divname+'_mmframesmall')].location.replace(mmbaseurl+"html/mmplayer_blankframe"+(this.bgsrc=="curtain"?"c.html?":".html?")+"call="+this.divname);
		} else {
			frames[(this.divname+'_mmframesmall')].location.replace(mmbaseurl+"html/mmplayerframe.html?"+(this.bgsrc=="curtain"?"mmcurtain&":"")+this.items[this.playingItem].getMediaType()+"="+this.items[this.playingItem].getLow());
			frames[(this.divname+'_mmframebig')].location.replace(mmbaseurl+"html/mmplayer_blankframe"+(this.bgsrc=="curtain"?"c.html?":".html?")+"call="+this.divname);
		}
	}
}

//////////////////////////////////////////////////////////
function w3mmItem (mediaType,playlow,playhigh,itemLayout,picturesrc,description,duration,transcripttxt,transcripturl,addltxt,addlurl) {
	switch (mediaType) {
		case "youtube":
			this.mediaType="youtube";break;			
		case "river":
			this.mediaType="river";break;			
		case "flash":
			this.mediaType="flash";break;
		case "a":
			this.mediaType="audio";break;			
		case "audio":
			this.mediaType="audio";break;
		case "v":
			this.mediaType="video";break;			
		case "video":
			this.mediaType="video";break;
		default:
			this.mediaType="video";
	}
	if(playlow=="") {
		this.playhigh=playhigh;
		this.playlow=playhigh;
	} else if (playhigh=="") {
		this.playhigh=playlow;
		this.playlow=playlow;
	} else {
		this.playhigh=playhigh;
		this.playlow=playlow;
	}
	switch (itemLayout) {
		case "bigpic":
			this.itemLayout="bigpic";break;
		case "picleft":
			this.itemLayout="picleft";break;
		case "arrow":
			this.itemLayout="arrow";break;
		default:
			this.itemLayout="arrow";
	}

	this.picturesrc=picturesrc;	//URL of the picture for this item
	this.description=description;	//text description for item
	this.duration=duration;		//duration in minutes and seconds (5:15)
	this.transcripttxt=transcripttxt;	//"Transcript"
	this.transcripturl=transcripturl;	//URL of the transcript
	this.addltxt=addltxt;			//"Learn more" (or other additional link's text)
	this.addlurl=addlurl;			//Additional link's URL

	if (typeof(_w3mmItem_prototype_called) == 'undefined') {
		_w3mmItem_prototype_called = true;
		w3mmItem.prototype.writelite = writelite;
		w3mmItem.prototype.write = write;
		w3mmItem.prototype.getMediaType = getMediaType;
		w3mmItem.prototype.getLow = getLow;
		w3mmItem.prototype.getHigh = getHigh;
	}

	function writelite(divname) {
		// Only for cases where this is the ONLY menu item.
		id=0;

		if(this.description!="") {
			document.write("<a style=\"COLOR: #000000; TEXT-DECORATION: none\" onclick=\""+divname+".playItem('"+id+"');\" href=\"#\">");
			document.write(""+this.description+(this.duration!=""?"&nbsp;(&nbsp;"+this.duration+"&nbsp;)":"")+"</a><br />");
		}
		if(this.transcripturl!="") {
			document.write(" [&nbsp;<a style=\"COLOR: #000000;\" href=\""+this.transcripturl+"\">"+this.transcripttxt+"</a>&nbsp;]");
		}
		if(this.addlurl!="") {
			document.write(" [&nbsp;<a style=\"COLOR: #000000;\" href=\""+this.addlurl+"\">"+this.addltxt+"</a>&nbsp;]");
		}
		document.write("<br clear=\"all\" /><br />");
	}	

	function write(divname,id) {
		if(this.itemLayout=="bigpic") {

			document.write("<div align=\"left\"><a style=\"COLOR: #000000; TEXT-DECORATION: none\" onclick=\""+divname+".playItem('"+id+"');\" href=\"#"+divname+"\"><img width=\"100\" src=\""+this.picturesrc+"\" style=\"MARGIN-BOTTOM: 5px; MARGIN-RIGHT: 5px\" alt=\"Click to Play\" border=\"0\" /><br />"+this.description+"&nbsp;[&nbsp;<u>Play&nbsp;"+this.duration+"</u>&nbsp;]</a>");
			if(this.transcripturl!="") {
				document.write(" [&nbsp;<a style=\"COLOR: #000000;\" href=\""+this.transcripturl+"\">"+this.transcripttxt+"</a>&nbsp;]");
			}
			if(this.addlurl!="") {
				document.write(" [&nbsp;<a style=\"COLOR: #000000;\" href=\""+this.addlurl+"\">"+this.addltxt+"</a>&nbsp;]");
			}
			document.write("<br clear=\"all\" /><br /></div>");


		} else if(this.itemLayout=="picleft") {
			document.write("<a style=\"COLOR: #000000; TEXT-DECORATION: none\" onclick=\""+divname+".playItem('"+id+"');\" href=\"#"+divname+"\">");
			document.write("<img style=\"MARGIN-BOTTOM: 5px; MARGIN-RIGHT: 5px\" height=\"50\" align=\"left\" alt=\"Click to Play\" src=\""+(this.picturesrc=="play"?mmbaseurl+"images/play50.jpg":this.picturesrc)+"\" width=\"50\" align=\"left\" border=\"0\" />"+this.description+"&nbsp;[&nbsp;<u>Play&nbsp;"+this.duration+"</u>&nbsp;]</a>");
			if(this.transcripturl!="") {
				document.write(" [&nbsp;<a style=\"COLOR: #000000;\" href=\""+this.transcripturl+"\">"+this.transcripttxt+"</a>&nbsp;]");
			}
			if(this.addlurl!="") {
				document.write(" [&nbsp;<a style=\"COLOR: #000000;\" href=\""+this.addlurl+"\">"+this.addltxt+"</a>&nbsp;]");
			}
			document.write("<br clear=\"all\" /><br />");
		} else {
			document.write("<a style=\"COLOR: #000000; TEXT-DECORATION: none\" onclick=\""+divname+".playItem('"+id+"');\" href=\"#"+divname+"\">");
			document.write("<img style=\"MARGIN-BOTTOM: 17px; MARGIN-RIGHT: 5px\" height=\"15\" alt=\"Click to Play\" src=\"//w3.ibm.com/ui/v8/images/icon-link-action.gif\" width=\"17\" align=\"left\" border=\"0\" />"+this.description+"&nbsp;[&nbsp;<u>Play&nbsp;"+this.duration+"</u>&nbsp;]</a>");
			if(this.transcripturl!="") {
				document.write(" [&nbsp;<a style=\"COLOR: #000000;\" href=\""+this.transcripturl+"\">"+this.transcripttxt+"</a>&nbsp;]");
			}
			if(this.addlurl!="") {
				document.write(" [&nbsp;<a style=\"COLOR: #000000;\" href=\""+this.addlurl+"\">"+this.addltxt+"</a>&nbsp;]");
			}
			document.write("<br clear=\"all\" /><br />");
		}
	}
	function getMediaType() {
		return ""+this.mediaType;
	}
	function getLow() {
		return ""+this.playlow;
	}
	function getHigh() {
		return ""+this.playhigh;
	}
}