function myWMPlayer (mymediaid,myfile,width,height,showcontrols,showdisplay,showstatusbar,autoplay,autostart) {
/**
 * myWMPlayer v1.0: Javascript function that works with WMPObject.js and is used to build the object.
 * Derived by www.webado.net  from the original by by Kovan Abdulla of www.imetasoft.com.
 *
 * WMPbject is (c) 2006 Kovan Abdulla  and is released under the MIT License:
 * http://www.opensource.org/licenses/mit-license.php
 *
 *
 * For all usage credits must remain intact.
 */

// on input height of movie needs to be increased by 144px for the full controls - width stays the same
// audio player only needs a hight from 45px to 145px depending on options

   var myfilename = addPath(myfile); // add the proper path if not already given

				var qtVid = new WMPObject(myfilename, 'MMPlayer1', width, height);
				qtVid.addParam('TYPE', 'application/x-mplayer2');
				qtVid.addParam('PLUGINSPACE', 'http://www.microsoft.com/Windows/MediaPlayer/download/default.asp');
				qtVid.addParam('ShowControls', showcontrols); 
				qtVid.addParam('ShowDisplay', showdisplay); 
				qtVid.addParam('ShowStatusBar', showstatusbar); 
				qtVid.addParam('Autoplay', autoplay); 
 				qtVid.addParam('Autostart', autostart); // needed for Firefox; set equal to autoplay

				qtVid.addParam('DefaultFrame', 'Slide'); 
				qtVid.write(mymediaid);

}


// The next 2 functions are used to get get the full, absolute path and to add it to the filename if necessary

function findPath() {
	/*
	This function gets the URL of the current page, then extracts the file name
	and path from the URL
    Special handling for localhost, in particular for Opera.
	*/

	var URL = unescape(location.href);	// get current URL in plain ASCII
	var xstart = URL.lastIndexOf("/") + 1;
	var xend = URL.length;
	var hereName = URL.substring(xstart,xend);
	var herePath = URL.substring(0,xstart);

	var path=herePath; // what we need further down

// adjust for when it's run in local mode
	var pos1 = herePath.search(/file:\/\//);
	if (pos1 != -1) {
		var pos2 = herePath.search(/localhost/); // this will show up for Opera
		var pleng = herePath.length;

		if (pos2 !=-1) {
			var keep=herePath.substring(pos2+10,pleng);
			path = "file://" + keep; // this will be the apth for Opera in local mode
		}
	}

return path;
}

function addPath(fn) {
	/*
	This function adds the proper path to a filename, as long as the filename does not start with http: or file: .
	This is because Firfox and Opera, especially when running locally, need a fully qualified absolute path to the media file.
	*/

	var filename = fn;

	var fix1 =  filename.search(/http:/);
	var fix2 =  filename.search(/file:/);
	var path = findPath();
	if ((fix1 == -1) && (fix2 == -1)) { filename = path + filename; } else {filename = fn; }

	return filename;
}
