/* Swaps out different flash movies on a single page.

On the page itself, set up a block with some variable declarations:

var playerFixed= true; // should the player resize based on the content, or be a fixed size for all 
var flashDiv= "flashgoeshere"; // id of the div where the flash will be rendered
var flashContainer= "right-column"; // id of the div that contains the render div. Needed for script purposes
var w = 400; // this is the width of the video.
var h = 300; // this is the height of the video. The swf will be taller than this height for the control bar.
*/


var flashvars = {
	src:"",
	width:"",
	height:"",
	controlHeight:24,
	autoplay:"true", // set to true or false
	loadHit:"", // the javascript function to be called when the application loads the movie
	completeHit:"" // the javascript function to be called when the movie finishes playing.
};
var params = {
	quality:"high",
	align:"middle",
	wmode:"window",
	allowScriptAccess:"sameDomain", // must be set to true for the js functions to work
	allowFullScreen:"true" // must be set to true for full screen mode to work.
};

//swfobject.embedSWF("FXVideo.swf", flashDiv, w, h+flashvars.controlHeight, "10.0.0", "/sitecollectionflash/expressInstall.swf", flashvars, params);


$(document).ready(function() {
$("dl p a").click(function(){
	//set up the flashvars for the next flash
	fpath= $(this).attr("fpath")

	if (!playerFixed) {
	fw= parseInt($(this).attr("fwidth"))
	fh= parseInt($(this).attr("fheight"))
		//make sure we have numbers and assign them
		if (!isNaN(fw) && !isNaN(fh)) {
			flashvars.width= fw+""
			flashvars.height= fh+""
		}
		// not numbers-- use the defaults
		else {
			flashvars.width= w+""
			flashvars.height= h+""
			fh= h
			fw= w		
		}
	}
	else {
		flashvars.width= w+""
		flashvars.height= h+""
		fh= h
		fw= w
	}
	
	//get the area ready for the next flash
	swfobject.removeSWF(flashDiv)
	$("#"+flashContainer).append('<div id="'+flashDiv+'"></div>')

	if (fpath.indexOf(".flv")>0) {
		flashvars.src= fpath
		swfobject.embedSWF("/sitecollectionflash/FXVideo.swf", flashDiv, fw, fh+flashvars.controlHeight, "10.0.0", "/sitecollectionflash/expressInstall.swf", flashvars, params);
	}
	else if (fpath.indexOf(".swf")>0) {
		swfobject.embedSWF(fpath, flashDiv, fw, fh, "10.0.0", "/sitecollectionflash/expressInstall.swf", "", params);
	}
	else if (fpath.indexOf(".mp3")>0) {
		flashvars.src= fpath
		swfobject.embedSWF("/sitecollectionflash/FXVideo.swf", flashDiv, fw, fh+flashvars.controlHeight, "10.0.0", "/sitecollectionflash/expressInstall.swf", flashvars, params);
	}
	
	else {
		window.open(fpath);
	}

	return false;
	})
});


