
function play_demo1(media, ObjID, event, title)
{
    var embedHTML = '<h3>' + title + '</h3>' +
		 '<OBJECT classid="clsid:22D6f312-B0F6-11D0-94AB-0080C74C7E95"' +
		 'codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,4,7,1112"' +
		 'standby="Loading Microsoft® Windows® Media Player components..."' +
		 'type="application/x-oleobject"' +
		 'align="middle"' +
		 'width="640"' +
		 'height="380">' +
		 '<param name="filename" value="' + media + '">' +
		 '<param name="enabled" value="true">' +
		 '<param name="uiMode" value="mini">' +
		 '<param name="autostart" value="true">' +
		 '<param name="ShowStatusBar" value="true">' +
		 '<embed type="application/x-mplayer2"' +
		 'pluginspage="http://www.microsoft.com/Windows/MediaPlayer/"' +
		 'src="' + media + '"' +
		 'align="middle"' +
		 'width="640"' +
		 'height="380"' +
		 'showstatusbar="true"' +
		 'autoplay="true"' +
		 'loop="false"></EMBED></OBJECT>' +
		  '<br><br><center><span class="medium"><strong>[ <a href=# onclick="hideCurrentPopup(\'player_popup\')">close</a> ]</strong></span></center>';
	showPopup(ObjID, event);
	document.getElementById(ObjID).innerHTML = embedHTML;
}

function play_demo2(media, ObjID, event, title)
{
    var embedHTML = '<h3>' + title + '</h3>' + 
		'<OBJECT classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B"' +
		 'width="640"' +
		 'height="376"' +
		 'codebase="http://www.apple.com/qtactivex/qtplugin.cab">' +
		 '<param name="src" value="' + media + '">' +
		 '<param name="autoplay" value="true">' +
		 '<param name="controller" value="true">' +
		 '<param name="loop" value="false">' +
		 '<EMBED src="' + media + '"' +
		 'width="640"' +
		 'height="376"' +
		 'autoplay="true"' +
		 'controller="true"' +
		 'loop="false"' +
		 'pluginspage="http://www.apple.com/quicktime/download/"></EMBED></OBJECT>' +
		  '<br><br><center><span class="medium"><strong>[ <a href=# onclick="hideCurrentPopup(\'player_popup\')">close</a> ]</strong></span></center>';
	showPopup(ObjID, event);
	document.getElementById(ObjID).innerHTML = embedHTML;
}

function play_demo3(media, ObjID, event, title)
{	
    var embedHTML = '<h3>' + title + '</h3>' + 
		'<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"' +
		  'style="width: 640px; height: 380px;">' +
	      '<param name="movie" value="movies/2kplayer.swf?file=' + media + '&autoStart=1" />' +
		  '<param name="wmode" value="transparent" />' +
		  '<param name="allowFullScreen" value="false" />' +
		  '<!--[if !IE]>--><object type="application/x-shockwave-flash"' + 
		  'style="width: 640px; height: 380px;"' +
		  'data="movies/2kplayer.swf?file=' + media + '&autoStart=1">' +
		  '<param name="wmode" value="transparent" /></object><!--<![endif]--></object>' +
		  '<br><br><center><span class="medium"><strong>[ <a href=# onclick="hideCurrentPopup(\'player_popup\')">close</a> ]</strong></span></center>';
	showPopup(ObjID, event);
	document.getElementById(ObjID).innerHTML = embedHTML;
}


// store variables to control where the popup will appear relative to the cursor position
// positive numbers are below or to the right of the cursor, negative numbers are above or to the left
var xOffset = 30;
var yOffset = 120;

// showPopup
function showPopup (targetObjectId, eventObj) {
    if(eventObj) {
	// hide any currently-visible popups
	hideCurrentPopup(targetObjectId);
	// stop event from bubbling up any farther
	eventObj.cancelBubble = true;
	// move popup div to current cursor position 
	// (add scrollTop to account for scrolling for IE)
	var newXCoordinate = xOffset; //(eventObj.pageX)?eventObj.pageX + xOffset:eventObj.x + xOffset + ((document.body.scrollLeft)?document.body.scrollLeft:0);
	var newYCoordinate = yOffset; //(eventObj.pageY)?eventObj.pageY + yOffset:eventObj.y + yOffset + ((document.body.scrollTop)?document.body.scrollTop:0);
	moveObject(targetObjectId, newXCoordinate, newYCoordinate);
	// and make it visible
	if( changeObjectVisibility(targetObjectId, 'visible') ) {
	    // if we successfully showed the popup
	    // store its Id on a globally-accessible object
	    window.currentlyVisiblePopup = targetObjectId;
	    return true;
	} else {
	    // we couldn't show the popup, boo hoo!
		return false;
	}
    } else {
	// there was no event object, so we won't be able to position anything, so give up
	return false;
    }
}

// hideCurrentPopup
function hideCurrentPopup(playerName) {
    // note: the currently visible popup is stored on the global object, window.currentlyVisiblePopup
    if(window.currentlyVisiblePopup) {
    // brute force method of killing quicktime playback... just wipe the div contents clean.
    document.getElementById(playerName).innerHTML = "";
	changeObjectVisibility(window.currentlyVisiblePopup, 'hidden');
	window.currentlyVisiblePopup = false;
    }
}


// Copyright © 2000 by Apple Computer, Inc., All Rights Reserved.
//
// You may incorporate this Apple sample code into your own code
// without restriction. This Apple sample code has been provided "AS IS"
// and the responsibility for its operation is yours. You may redistribute
// this code, but you are not permitted to redistribute it as
// "Apple sample code" after having made changes.
//
// ****************************
// *  layer utility routines  *
// ****************************

function getStyleObject(objectId) {
    // cross-browser function to get an object's style object given its id
    if(document.getElementById && document.getElementById(objectId)) {
	// W3C DOM
	// alert("Found the W3C DOM popup div object");
	return document.getElementById(objectId).style;
    } else if (document.all && document.all(objectId)) {
	// MSIE 4 DOM
	// alert("Found the MSIE 4 DOM  popup div object");
	return document.all(objectId).style;
    } else if (document.layers && document.layers[objectId]) {
	// NN 4 DOM.. note: this won't find nested layers
	// alert("Found the NN 4 DOM  popup div object");
	return document.layers[objectId];
    } else {
	alert("Sorry... can't find the popup div object");
	return false;
    }
} // getStyleObject

function changeObjectVisibility(objectId, newVisibility) {
    // get a reference to the cross-browser style object and make sure the object exists
    var styleObject = getStyleObject(objectId);
    if(styleObject) {
	styleObject.visibility = newVisibility;
	return true;
    } else {
	// we couldn't find the object, so we can't change its visibility
	return false;
    }
} // changeObjectVisibility

function moveObject(objectId, newXCoordinate, newYCoordinate) {
    // get a reference to the cross-browser style object and make sure the object exists
    var styleObject = getStyleObject(objectId);
    if(styleObject) {
	styleObject.left = String(newXCoordinate) + "px";
	styleObject.top = String(newYCoordinate) + "px";
	return true;
    } else {
	// we couldn't find the object, so we can't very well move it
	alert("Sorry...  can't find popup div object");
	return false; 
    }
/* 	document.getElementById(objectId).style.top = newXCoordinate;
	document.getElementById(objectId).style.left = newYCoordinate;
*/	
} // moveObject



// ***************************
// *  hacks and workarounds  *
// ***************************

// initialize hacks whenever the page loads
window.onload = initializeHacks;

// setup an event handler to hide popups for generic clicks on the document
// document.onclick = hideCurrentPopup;

function initializeHacks() {
    // this ugly little hack resizes a blank div to make sure you can click
    // anywhere in the window for Mac MSIE 5
    if ((navigator.appVersion.indexOf('MSIE 5') != -1) 
	&& (navigator.platform.indexOf('Mac') != -1)
	&& getStyleObject('blankDiv')) {
	window.onresize = explorerMacResizeFix;
    }
    resizeBlankDiv();
    // this next function creates a placeholder object for older browsers
    createFakeEventObj();
}

function createFakeEventObj() {
    // create a fake event object for older browsers to avoid errors in function call
    // when we need to pass the event object to functions
    if (!window.event) {
	window.event = false;
    }
} // createFakeEventObj

function resizeBlankDiv() {
    // resize blank placeholder div so IE 5 on mac will get all clicks in window
    if ((navigator.appVersion.indexOf('MSIE 5') != -1) 
	&& (navigator.platform.indexOf('Mac') != -1)
	&& getStyleObject('blankDiv')) {
	getStyleObject('blankDiv').width = document.body.clientWidth - 20;
	getStyleObject('blankDiv').height = document.body.clientHeight - 20;
    }
}

function explorerMacResizeFix () {
    location.reload(false);
}

// resize fix for ns4
var origWidth, origHeight;
if (document.layers) {
	origWidth = window.innerWidth; origHeight = window.innerHeight;
	window.onresize = function() { if (window.innerWidth != origWidth || window.innerHeight != origHeight) history.go(0); }
}


/*************************************************************************
  This code is from Dynamic Web Coding at http://www.dyn-web.com/
  Copyright 2001-3 by Sharon Paine 
  See Terms of Use at http://www.dyn-web.com/bus/terms.html
  regarding conditions under which you may use this code.
  This notice must be retained in the code as is!
*************************************************************************/

// functions for member div layer popups

var cur_lyr;	// holds id of currently visible layer
function swapLayers(id) {
  if (cur_lyr) hideLayer(cur_lyr);
  showLayer(id);
  cur_lyr = id;
}

function showLayer(id) {
  if (cur_lyr) hideLayer(cur_lyr);
  var lyr = getElemRefs(id);
  if (lyr && lyr.css) lyr.css.visibility = "visible";
  cur_lyr = id;
}

function hideLayer(id) {
  var lyr = getElemRefs(id);
  if (lyr && lyr.css) lyr.css.visibility = "hidden";
}

function getElemRefs(id) {
	var el = (document.getElementById)? document.getElementById(id): (document.all)? document.all[id]: (document.layers)? getLyrRef(id,document): null;
	if (el) el.css = (el.style)? el.style: el;
	return el;
}

// get reference to nested layer for ns4
// from old dhtmllib.js by Mike Hall of www.brainjar.com
function getLyrRef(lyr,doc) {
	if (document.layers) {
		var theLyr;
		for (var i=0; i<doc.layers.length; i++) {
	  	theLyr = doc.layers[i];
			if (theLyr.name == lyr) return theLyr;
			else if (theLyr.document.layers.length > 0) 
	    	if ((theLyr = getLyrRef(lyr,theLyr.document)) != null)
					return theLyr;
	  }
		return null;
  }
}
