//***************************************
// FOR JW FLV PLAYER
	// some variables to save
	var currentPosition;
	var currentVolume;
	var currentItem;
	var swfObjsLoaded = false;
	var tmrPrototype;

	// these functions are caught by the JavascriptView object of the player.
	function sendEvent(typ,prm) { thisMovie("mpl").sendEvent(typ,prm); };
	function getUpdate(typ,pr1,pr2,pid) {

	if(typ == "time") { currentPosition = pr1; }
		var id = document.getElementById(typ);
		id.innerHTML = typ+ ": "+Math.round(pr1);
	};

	function thisMovie(movieName) {
		if(navigator.appName.indexOf("Microsoft") != -1) {
			return window[movieName];
		} else {
			return document[movieName];
		}
	};

//***************************************

	function writeVideoObject(id, pic, flv, width, height){
		var file = flv;
		
		with(new SWFObject('/business/provideo/flvplayer/flvplayer.swf?preventCache=' + (new Date().valueOf()),id,width,height,'7')){
			addVariable('file',file);
			addVariable('image',pic);
			addVariable("javascriptid","_" + id);
			addVariable('height',height);
			addVariable('width',width);
			addVariable('displaywidth',width);
			addVariable('displayheight',height);
			addVariable('showvolume','true');
			//addVariable('enablejs','true'); //ENABLING THIS SEEMS TO CAUSE PROBLEMS IN IE
			addVariable('useaudio','false');
			addVariable('usecaptions','false');
			addVariable('usekeys','false');
			addVariable('autostart','true');
			addVariable("overstretch","fit");
			addParam('allowscriptaccess','always');
			addParam('allowfullscreen','true');
			addParam('wmode','transparent');
			addVariable('usefullscreen','false');
			addVariable('showdigits','true');
			addVariable('bufferlength','20');
			write(id);
		}
		
	}


	function writeAudioObject(id, url, width){
		var file = url;
				
		with(new SWFObject('flvplayer.swf?preventCache=' + (new Date().valueOf()),id,width,20,'7')){
			addVariable('file',file);
			addVariable("javascriptid","_" + id);
			addVariable('height',20);
			addVariable('width',width);
			addVariable('displaywidth',width);
			addVariable('displayheight',0);
			addVariable('showvolume','true');
			//addVariable('enablejs','true'); //ENABLING THIS SEEMS TO CAUSE PROBLEMS IN IE
			addVariable('useaudio','false');
			addVariable('usecaptions','false');
			addVariable('usekeys','false');
			addVariable('autostart','true');
			addVariable('showicons','false');
			addVariable('thumbsinplaylist','false');
			addVariable('shuffle','false');
			
			addParam('allowscriptaccess','always');
			addParam('allowfullscreen','true');
			
			addVariable('usefullscreen','false');
			addVariable('showdigits','true');
			write(id);
		}
		
	}
	
function writeFlashObject(srcElement,url,width,height){
	var div = srcElement.parentNode;
	if(typeof(srcElement)=='string') srcElement = $(srcElement);
	var ret = "<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0\" width=\""+width+"\" height=\""+height+"\"><param name=\"movie\" value=\""+url+"\"><param name=\"quality\" value=\"high\"><param name=\"wmode\" value=\"transparent\"><embed src=\""+url+"\" width=\""+width+"\" height=\""+height+"\" quality=\"high\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" wmode=\"transparent\" type=\"application/x-shockwave-flash\"></embed></object>";
	
	// FOR MAC
	if(navigator.appVersion.indexOf("Mac")!=-1){
		ret = "<embed src=\""+url+"\" width=\""+width+"\" height=\""+height+"\"></embed>";
	}
	
	srcElement.innerHTML = ret;	
}

////////////////////

function addCustomEvent(objElement,eventName,eventFunction){

	if(objElement.addEventListener){
		objElement.addEventListener (eventName,eventFunction,false);
	} else if(objElement.attachEvent) {
		objElement.attachEvent ('on' + eventName,eventFunction);
	} else {
		MyAttachEvent(objElement,eventName,eventFunction);
		objElement['on'+eventName]=function(){ MyFireEvent(objElement,eventName) };
	}

}

function MyAttachEvent(obj,evt,fnc){
	if (!obj.myEvents) obj.myEvents={};
	if (!obj.myEvents[evt]) obj.myEvents[evt]=[];
	var evts = obj.myEvents[evt];
	evts[evts.length]=fnc;
}

function MyFireEvent(obj,evt){
	if (!obj || !obj.myEvents || !obj.myEvents[evt]) return;
	var evts = obj.myEvents[evt];
	for (var i=0,len=evts.length;i<len;i++) evts[i]();
}

////////////////////