//Start On-Demand
//Recursive function to loop through Media URL Offset array
function startOnDemand(){

	this.everyRequest();
	
	this.checkForAudioClipPlaylist();
	
	if (this.boolSyncFlashDemo) this.everyRequestForFlashDemo();
	
	var changed=false;
	
	//obtains player position, relative the stream offset
	var position = this.player.getPosition();
//	alert(position);

	//this is used to set the position of the media player based on the streamoffsetlog
	this.checkStreamOffset();
	
		//finds the stream offset and adds it to the player object
	if (this.streamStartOffsetObject && this.streamStartOffsetObject.offset && this.player) this.player.streamoffset = this.streamStartOffsetObject.offset;
	
	//sets index value for use in chapterizing	
	this.currIndex=-1;
	for (var i in this.offsetlog) {
		//this part is for simulive. Once the on-demand part ends, it should go to the live part.
		if(this.paramObj.contenttype && this.paramObj.contenttype=="L" && this.paramObj.simulive && this.paramObj.simulive=="y"){
			//alert(this.offsetlog[i].presentationcode);
			var timeElasped=this.getTimeElasped();
			if( this.player.getCurrentEntry()>0) {
			//if(this.offsetlog[i].presentationcode=="endlive") {
				//if(timeElasped >= this.ondemandPresentationLength*1000) {
					//alert("Go to Live Part");
					this.interval=200;
					this.startLiveStreaming();
					return false;
				//}
			}
			//re-sync simulive player if the player is out of sync by 15 secs.
			if(this.player.getPlayerStatus()=="playing" && this.player.getCurrentEntry()==0 && (timeElasped-position) >= 15*1000){
				this.setPlayerPosition(timeElasped/1000)
				window.main.clearTimeout(this.toid);
				this.toid = window.main.setTimeout(this.name+".startOnDemand()",2000);
				return false;
			}
		}
		//simulive part ends here
		if (position < this.offsetlog[i].ondemandoffset) {
			if (i>0 && this.mediaurlId!=this.offsetlog[i-1].id) {
				this.mediaurlId=this.offsetlog[i-1].id;
				if (this.offsetlog[i-1].id>0) changed=true;
			}
			break;
		}
		this.currIndex+=1;
	}
	
	//tests for a change to slides, polls, etc.
	if (changed) {
		this.mediaurlObj=null; //re-initialize the object.
		for (var i in this.mediaurl) {
			if (this.mediaurl[i].id==this.mediaurlId) {
				this.mediaurlObj=this.mediaurl[i];
				break;
			}
		}
		if(this.mediaurlObj==null){
			window.main.clearTimeout(this.toid);
			this.toid = window.main.setTimeout(this.name+".startOnDemand()",this.interval);
			return false;
		}
		
		if(this.thumbnailPreviewMode==true){
			if(bIE)
				if(this.doc.thumbnailFrame) {
					if(this.doc.thumbnailFrame.setActiveSlide) this.doc.thumbnailFrame.setActiveSlide(this.mediaurlObj.categorycode,this.mediaurlObj.url);
				}
			else {
				if(this.getObjByName(this.doc,"thumbnailFrame")) {
					if(this.getObjByName(this.doc,"thumbnailFrame").setActiveSlide) this.getObjByName(this.doc,"thumbnailFrame").setActiveSlide(this.mediaurlObj.categorycode,this.mediaurlObj.url);
				}
			}
			window.main.clearTimeout(this.toid);
			this.toid = window.main.setTimeout(this.name+".startOnDemand()",this.interval);
			return false;
		}
		var originalMediaCode=this.mediaurlObj.code;
		if (this.mediaurlObj.code=="chapter") {
			this.changeChapterDropdown(this.mediaurlObj.name);
			var tmp=this.getLastPushedElement(position,"slide",false);
			if (tmp) this.mediaurlObj=tmp;
		}
		if (this.mediaurlObj.code=="audio" && this.mediaurlObj.categorycode=="clip" && this.getEventInfoObj("audio","clip")) {
			this.changeChapterDropdown(this.mediaurlObj.name);
			var tmp=this.getLastPushedElement(position,"slide",false);
			if (tmp) this.mediaurlObj=tmp;
		}
		if (this.mediaurlObj.code=="slide") {
			this.slideurl=this.mediaurlObj.url;
			this.slideheight=this.mediaurlObj.height;
			this.slidewidth=this.mediaurlObj.width;
			this.slidepopup=this.mediaurlObj.popup;
			this.slidename=this.mediaurlObj.name;
			this.showSlide();
			if(originalMediaCode=="slide" && this.mediaurlObj.popup) this.changeChapterDropdown(this.slidename);
			if(bIE) {
				if(this.doc.thumbnailFrame) {
					if(this.doc.thumbnailFrame.setActiveSlide) this.doc.thumbnailFrame.setActiveSlide(this.mediaurlObj.categorycode,this.slideurl);
				}
			} else {
				if(this.getObjByName(this.doc,"thumbnailFrame")) {
					if(this.getObjByName(this.doc,"thumbnailFrame").setActiveSlide) this.getObjByName(this.doc,"thumbnailFrame").setActiveSlide(this.mediaurlObj.categorycode,this.slideurl);
					else if(this.getObjByName(this.doc,"thumbnailFrame").contentWindow.setActiveSlide) this.getObjByName(this.doc,"thumbnailFrame").contentWindow.setActiveSlide(this.mediaurlObj.categorycode,this.slideurl);
				}
			}
		}
		if (this.mediaurlObj.code=="www") {
			this.wwwurl=this.mediaurlObj.url;
			this.wwwheight=this.mediaurlObj.height;
			this.wwwwidth=this.mediaurlObj.width;
			this.wwwpopup=this.mediaurlObj.popup;
			this.wwwname=this.mediaurlObj.name;
			this.showURL();
		}
		if (this.mediaurlObj.code=="poll") {
			this.pollurl=this.mediaurlObj.url;
			this.pollheight=this.mediaurlObj.height;
			this.pollwidth=this.mediaurlObj.width;
			this.pollpopup=this.mediaurlObj.popup;
			this.pollname=this.mediaurlObj.name;
			this.showPoll();
		}		
		if (this.mediaurlObj.code=="userquestion") {
			this.questionurl=this.mediaurlObj.url;
			this.questionheight=this.mediaurlObj.height;
			this.questionwidth=this.mediaurlObj.width;
			this.questionpopup=this.mediaurlObj.popup;
			this.questionname=this.mediaurlObj.name;
			this.showQuestion();
		}	
	}
	
	this.transcriptCounter++;
	if(this.transcriptCounter>=20){//20 times of 50ms = 1 secs
		this.processTranscript(position);
		this.transcriptCounter=0;
	}
	
	//Recall this function
	window.main.clearTimeout(this.toid);
	this.toid = window.main.setTimeout(this.name+".startOnDemand()",this.interval);
	return false;
}

//Start Live Streaming
//Recursive function to parse dummyFrame querystring
function startLiveStreaming(){

	this.everyRequest();
	
	if (this.boolSyncFlashDemo) this.everyRequestForFlashDemo();
	
	this.brequest = null;
	if(this.scriptCommandURL!=""){
		if(this.scriptCommandURL.indexOf("?")>0) this.brequest=this.scriptCommandURL.substring(this.scriptCommandURL.indexOf("?"))
		else this.brequest=this.scriptCommandURL;
	}	
	else this.brequest = window.dummyFrame.location.search;

	//flags
	this.validrequest = false;
	this.wwwchange=false;
	this.pollchange=false;
	this.questionchange=false;
	this.slidechange=false;
	this.slideadded=false;
	this.questionadded=false;
	this.statuschange=false;
	this.servletupdate=false;

	var dump="";
	
	dump+= "this.toid = "+this.toid+" <br> \n";
	dump+= "this.interval = "+this.interval+" <br> <br>\n";
		
	if((this.brequest!=this.lastbrequest)){
		this.lastbrequest=this.brequest;
		var qstring=this.lastbrequest;
		if(qstring.indexOf("?")==0) qstring=qstring.substring(1);
		var pairs=qstring.split("%A");
		for(var i=0;i<pairs.length;++i){
			var pairsplit=pairs[i].split("=")
			
			pairsplit[1]=unescape(pairsplit[1]);
			if (pairsplit[0]=="wwwtimestamp" && this[pairsplit[0]]!=pairsplit[1]) {
				this.wwwchange=true;				
				this.wwwtimestamp=pairsplit[1];				
			}
			if (pairsplit[0]=="polltimestamp" && this[pairsplit[0]]!=pairsplit[1]) {
				this.pollchange=true;				
				this.polltimestamp=pairsplit[1];
			}
			if (pairsplit[0]=="questiontimestamp" && this[pairsplit[0]]!=pairsplit[1]) {
				this.questionchange=true;
			}
			if (pairsplit[0]=="slidetimestamp" && this[pairsplit[0]]!=pairsplit[1]) {
				this.slidechange=true;
			}
			if (pairsplit[0]=="slidesyncurl" && this[pairsplit[0]]!=pairsplit[1]) {
				this.slideadded=true;
			}
			if (pairsplit[0]=="questionsynctimestamp" && this[pairsplit[0]]!=pairsplit[1]) {
				this.questionadded=true;
			}
			if ((pairsplit[0]=="startpractice" && this[pairsplit[0]]!=pairsplit[1]) || (pairsplit[0]=="endpractice" && this[pairsplit[0]]!=pairsplit[1]) || (pairsplit[0]=="startlive" && this[pairsplit[0]]!=pairsplit[1]) || (pairsplit[0]=="endlive" && this[pairsplit[0]]!=pairsplit[1])) {
				this.statuschange=true;
			}
			if (pairsplit[0]=="presentersynctimestamp" && this[pairsplit[0]]!=pairsplit[1]) {
				this.servletupdate=true;
			}
			
			if (pairsplit[0]!="") {
				dump+= pairsplit[0]+" = "+pairsplit[1]+" <br> \n";
				this[pairsplit[0]]=pairsplit[1];
			}
		}
		
		if(this.debug) {
			this.debugdump(dump);
		}
				
		//Test whether this is the first request
		if(this.firstrequest==true){
			this.firstrequest=false;
			window.main.clearTimeout(this.toid);
			this.toid = window.main.setTimeout(this.name+".startLiveStreaming()",this.interval);
			return false;
		}
		
		if(!this.maxSyncDelay) {
			if(this.paramObj.maxsyncdelay) this.maxSyncDelay=this.paramObj.maxsyncdelay-1;
			else this.maxSyncDelay=100;
		}
		
		if (this.slidechange) {
			//this.showSlide();
			window.main.setTimeout(this.name+".showSlide();",Math.floor(Math.random()*this.maxSyncDelay));
		}
		if (this.statuschange) {
			this.updateStatus();
		}	
		if (this.wwwchange) {
			//this.showURL();
			window.main.setTimeout(this.name+".showURL();",Math.floor(Math.random()*this.maxSyncDelay));
		}
		if (this.pollchange) {
			//this.showPoll();
			window.main.setTimeout(this.name+".showPoll();",Math.floor(Math.random()*this.maxSyncDelay));
		}		
		if (this.questionchange) {
			//this.showQuestion();
			window.main.setTimeout(this.name+".showQuestion();",Math.floor(Math.random()*this.maxSyncDelay));
		}		
		if (this.slideadded) {
			this.refreshSlides();
		}		
		if (this.questionadded) {
			this.refreshQuestions();
		}			
		if (this.servletupdate) {
			this.refreshAll();
		}
	}
	
	if(window.logging=="y" && this.paramObj.format.indexOf("fh")!=0){
		this.playStateCounter++;
		if(this.playStateCounter>=25){ //25 times of 200ms = 5 secs
			var status=this.player.getPlayerStatus();
			var pos=this.player.getPosition();
			if(status=="status") status=this.player.getPlayState();
			if(this.startPlayerStatusLogging==true){
				if(status!=this.currentPlayerStatus) this.logEvent("Player Console: Media Player state changed",( this.paramObj.format.indexOf("rm")!=-1?"Real ":"Windows Media ")+" Player state changed from "+this.currentPlayerStatus + " to " +status);
				if(pos==this.lastLivePlayerPosition && status!="buffering" && status!="stopped" && status!="paused") this.logEvent("Player Console: Media Player is not advancing",( this.paramObj.format.indexOf("rm")!=-1?"Real ":"Windows Media ")+" Player is not advancing from position "+pos);
			}
			this.currentPlayerStatus=status;
			this.lastLivePlayerPosition=pos;
			this.playStateCounter=0;
			if(this.startPlayerStatusLogging==false && status=="playing") this.startPlayerStatusLogging=true;
		}
	}
	//Recall this function
	window.main.clearTimeout(this.toid);
	this.toid = window.main.setTimeout(this.name+".startLiveStreaming()",this.interval);
	return false;
}

//function to get the content of the event text file via applet
function getAppletRequest() {

	if (!this.doc.requester) return null;
//	alert(this.doc.requester);
	var now = new Date();
	var ms = now.getTime();
	//alert(this.eventtextfile+"?ms="+ms);
	var objAppletResponse = this.doc.requester.request(this.eventtextfile+(this.eventtextfile.indexOf("?")!=-1?"&":"?")+"ms="+ms);
	//alert(objAppletResponse);
	
	var tempnames = this.doc.requester.getResponseNamesAsString();
	var tempvalues = this.doc.requester.getResponseValuesAsString();
	var names = new String(tempnames);
	var values = new String(tempvalues);
	var names = names.split("\n");
	var values = values.split("\n");
	var objArrays = new Object();
	objArrays.names = names;
	objArrays.values = values;
	
	//debugging code
	var responseCode = this.doc.requester.getResponseCode();
	var requestSequenceNumber = this.doc.requester.getRequestSequenceNumber();
	var responseParamCount = this.doc.requester.getResponseParamCount();
	var strDump = "";	
	strDump+= "responseCode = "+responseCode+" <br> \n";
	strDump+= "requestSequenceNumber = "+requestSequenceNumber+" <br> \n";
	strDump+= "responseParamCount = "+responseParamCount+" <br> <br>\n";
	
	//checks whether the request is valid, and if so, return the object of arrays
	for(var i=0;i<names.length;++i){
		if (names[i]=="presentersynctimestamp" && values[i]>1000000000) {
			return objArrays;
		}
	}
	
	return null;	
}

// gets the content of the event text file via the MSXML activeX object
function getMsxmlResponse() {
	var objEventTextFileXml = this.win.parent.objEventTextFileXml;

	if (!objEventTextFileXml) return null;
	var objResponseObject = objEventTextFileXml.getEventInfoObject(this.eventid,this.sessionid);
		
	//exit if the object is not defined
	if (!objResponseObject) return null;
	
	//create arrays and assign values to them
	var names = new Array();
	var values = new Array();
		
	for (var i in objResponseObject) {
		names[names.length] = i;
		values[values.length] = objResponseObject[i];
	}

	//create a new object and add the arrays to the object
	var objRequest = new Object();
	objRequest.names = names;
	objRequest.values = values;
	
	//return the object
	return objRequest;
}

//Start Live Non-Streaming
//Recursive function to request parameters from Applet
function startLiveNonStreaming(){
	
	this.everyRequest();
	
	if (this.boolSyncFlashDemo) this.everyRequestForFlashDemo();
	
	this.brequest = null;
		//for (var i in this.paramObj) alert(i +" : "+ this.paramObj[i]);
	//uses either the applet or msxml, based on querystring parameters
	if (this.paramObj.useapplet && this.paramObj.useapplet=="n") {
		var objBrowserInfo = this.getBrowserInfo();
		if (objBrowserInfo.is_nav6up || objBrowserInfo.is_ie6up || objBrowserInfo.is_firefox) {
			this.brequest = this.getMsxmlResponse();
		} else {
			this.brequest = this.getAppletRequest();
		}
	} else {
		this.brequest = this.getAppletRequest();
	}
	
	//flags
	this.validrequest = false;
	this.wwwchange=false;
	this.pollchange=false;
	this.questionchange=false;
	this.slidechange=false;
	this.slideadded=false;
	this.questionadded=false;
	this.statuschange=false;
	this.servletupdate=false;

	//parse applet response
	if(this.brequest){
		var names = this.brequest.names;
		var values = this.brequest.values;
		
		var dump="";
		dump+= "this.toid = "+this.toid+" <br> \n";
		dump+= "this.interval = "+this.interval+" <br> <br>\n";
		
		for(var i=0;i<names.length;++i){
			if (names[i]=="wwwtimestamp" && this[names[i]]!=values[i]) {
				this.wwwchange=true;
				this.wwwtimestamp=pairsplit[1];				
			}
			if (names[i]=="polltimestamp" && this[names[i]]!=values[i]) {
				this.pollchange=true;
				this.polltimestamp=pairsplit[1];			
			}
			if (names[i]=="questiontimestamp" && this[names[i]]!=values[i]) {
				this.questionchange=true;
			}
			if (names[i]=="slidetimestamp" && this[names[i]]!=values[i]) {
				this.slidechange=true;
			}
			if (names[i]=="slidesyncurl" && this[names[i]]!=values[i]) {
				this.slideadded=true;
			}
			if (names[i]=="questionsynctimestamp" && this[names[i]]!=values[i]) {
				this.questionadded=true;
			}
			if ((names[i]=="startpractice" && this[names[i]]!=values[i]) || (names[i]=="endpractice" && this[names[i]]!=values[i]) || (names[i]=="startlive" && this[names[i]]!=values[i]) || (names[i]=="endlive" && this[names[i]]!=values[i])) {
				this.statuschange=true;
			}
			if (names[i]=="presentersynctimestamp" && this[names[i]]!=values[i]) {
				this.servletupdate=true;
			}
			if (names[i]!="") {
				dump+= names[i]+" = "+values[i]+" <br> \n";
				this[names[i]]=values[i];
			}
		}
		
		if(this.debug) {
			this.debugdump(dump);
		}
		//Test whether this is the first request
		if(this.firstrequest==true){
			this.firstrequest=false;
			window.main.clearTimeout(this.toid);
			this.toid = window.main.setTimeout(this.name+".startLiveNonStreaming()",this.interval);
			return false;
		}
		
		if(!this.maxSyncDelay) {
			if(this.paramObj.maxsyncdelay) this.maxSyncDelay=this.paramObj.maxsyncdelay-1;
			else this.maxSyncDelay=100;
		}
		
		if (this.slidechange) {
			//this.showSlide();
			window.main.setTimeout(this.name+".showSlide();",Math.floor(Math.random()*this.maxSyncDelay));
		}
		if (this.statuschange) {
			this.updateStatus();
		}	
		if (this.wwwchange) {
			//this.showURL();
			window.main.setTimeout(this.name+".showURL();",Math.floor(Math.random()*this.maxSyncDelay));
		}
		if (this.pollchange) {
			//this.showPoll();
			window.main.setTimeout(this.name+".showPoll();",Math.floor(Math.random()*this.maxSyncDelay));
		}		
		if (this.questionchange) {
			//this.showQuestion();
			window.main.setTimeout(this.name+".showQuestion();",Math.floor(Math.random()*this.maxSyncDelay));
		}		
		if (this.slideadded) {
			this.refreshSlides();
		}		
		if (this.questionadded) {
			this.refreshQuestions();
		}			
		if (this.servletupdate) {
			this.refreshAll();
		}
	}
	
	//Recall this function
	window.main.clearTimeout(this.toid);
	this.toid = window.main.setTimeout(this.name+".startLiveNonStreaming()",this.interval);
	return false;
}

function asyncUrlResponse(requestid,xmlBody){
	//so far, only requestid=0 has been used, and that is for mediametric callback, no need to process the returned info
	//if (this.eventid==524) alert(wwwHost);
}

//this method gets called every 1 sec for non-streaming, every 200 ms for live streaming and every 50 ms for OD. The random numver generated inside the function is based on frequency. (60 sec/1 sec = 60, 60 sec/200 ms = 300,  60 sec/50 ms = 1200)
function mediametriccallback(){
	//get a number to make sure that mediametric call happens every 1 minute
	var limit = 60; //non-streaming. 
	if((this.paramObj.contenttype && this.paramObj.contenttype=="L" && this.paramObj.simulive && this.paramObj.simulive=="y")
		|| (this.paramObj.contenttype && this.paramObj.contenttype=="A") ){
		limit = 1200 //simulive & od
	} else if(this.paramObj.contenttype && this.paramObj.contenttype=="L"){
		limit = 300 // live streaming
	}
	
	var ran_number=Math.floor(Math.random()*limit); 
	 
	//top.window.status(ran_number);
	if (ran_number==0){
		//alert("alive callback"+ran_number);
		
		this.callMediaMetricServlet();//<--------to explicitly call mediametric servlet
	}
}

//Enlarge Slide Function
function enlarge(x,y){
	if (this.boolPollInSlideFrame) return false;
	this.closeEnlargeWin();
	var slideSRC=null;

	if (bIE) {
		slideSRC=this.doc.slide_frame.location.href;
	} else if (bNN) {
		slideSRC=getObjByName(this.doc,"slide_frame").src;
	}
	var enlargeURL=slideSRC;
	if (enlargeURL.indexOf("?")==-1) enlargeURL+="?"; 
	enlargeURL+="&eventid="+this.eventid+"&enlarged=true&usecdn="+window.usecdn+"&disableprinting="+window.disablePrinting+"&cdnprefix="+window.cdnprefix+"&cacheinterval="+window.cacheinterval;
	var intLeftOffset = x-0+20;
	var intTopOffset = y-200;
	
	
	
	var params = "width=640,height=480,innerWidth=640,innerHeight=480,resizable=1,left="+intLeftOffset+",top="+intTopOffset;
 	if (this.eventid && (this.eventid-0)>25332 && screen.height>750) {
		params = "width=1000,height=750,innerWidth=1000,innerHeight=750,resizable=1,left="+intLeftOffset+",top="+intTopOffset;
		enlargeURL+="&size=_1000x750"; 	
 	}else if (this.eventid && this.eventid-0>25332) {
		params = "width=768,height=576,innerWidth=768,innerHeight=576,resizable=1,left="+intLeftOffset+",top="+intTopOffset;
		enlargeURL+="&size=_1000x750";
 	}else if (this.eventid && this.eventid-0>8100) {
		params = "width=768,height=576,innerWidth=768,innerHeight=576,resizable=1,left="+intLeftOffset+",top="+intTopOffset;
		enlargeURL+="&size=_768x576";
	}else
		enlargeURL+="&size=_640x480";

	this.enlargeWin=window.open(enlargeURL,"enlargeWin",params);
	
	//this.enlargeWin.moveTo(x+20,y-200);
}

//Close Child Window Function
function closeEnlargeWin(){
	if(this.enlargeWin){
		if(!this.enlargeWin.closed){
				this.enlargeWin.close();
		}
	}
}

//Debug function
function debugdump(dump){
	this.debugwin=window.open("","debugwin");
	this.debugwin.document.open();
	this.debugwin.document.write(dump);
}

//Function to Flip Slides
function showSlide() {
	this.processPushedElementCounter();
	
	if ((this.slideurl + "" != "undefined") && (this.slideurl != "")) {
		this.showSlidePointer=false;
		var slideurl=this.slideurl;
		//this will control the highlighting of agenda items, Brent 2003-04-27
		// 2nd condition is added by kamal to make sure that agenda item slide #s corresponds to primary slide deck 2003-06-05
		if (this.setSummary && (/\/slide\/slide\/[0-9]+[_]?[A-Z0-9]*\./.test(this.slideurl))) this.setSummary(this.getSlideNumber(this.slideurl));
		
		//this block added by Brent & Kamal 2003.04.24
		//it will test whether the Main Page has an image named "portrait"
		//if so, it will push slides of category "portrait" to that image
		//it will also check for the last pushed portrait and push that if the slide is not a portrait
		//changed on 2003.07.01. This change is made so that portrait works for dynMain.html for NS
		if(this.altPortraitImg==null) this.altPortraitImg=this.doc.portrait;
		if(this.altPortraitImg) {
			if(/\/slide\/portrait\/[0-9]+[_]?[A-Z0-9]*\./.test(slideurl)){
				this.altPortraitImg.src = slideurl;
				this.showSlideTranscript(slideurl);
				return;
			//this is for the on-demand version
			} else if (this.player && this.paramObj && this.paramObj.contenttype && 
							(this.paramObj.contenttype=="A" || 
							(this.paramObj.contenttype=="L" && this.paramObj.simulive && this.paramObj.simulive=="y"))
						) {
				//to find the last portrait slide and assign it to the image
				var position = this.player.getPosition();
				var tmp=this.getLastPushedElement(position,"slide","portrait");
				if (tmp) {this.altPortraitImg.src=tmp.url; this.showSlideTranscript(tmp.url);}
			//this is for the live version
			} else if (this.firstrequest) {
				var tmpUrl=this.getLastPushedMediaURL("slide","portrait");
				if(tmpUrl==null) tmpUrl=this.getFirstMediaURL("slide","portrait");
				//if(this.eventid==1087) alert(tmpUrl);
				if (tmpUrl) {this.altPortraitImg.src=tmpUrl; this.showSlideTranscript(tmpUrl);}
			}
		}
		
		//this block added by Brent 2003.08.27
		//it will test whether the Main Page has an agenda area
		//if so, it will push slides of category "agenda" to that area
		//it will also check for the last pushed agenda and push that if the slide is not an agenda slide
		//changed on 2003.07.01. This change is made so that portrait works for dynMain.html for NS
		if(this.getObjByName(this.doc,"agenda_frame")) {
			if(/\/slide\/agenda\/[0-9]+[_]?[A-Z0-9]*\./.test(slideurl)){
				this.showAgendaSlide(slideurl);
				this.showSlideTranscript(slideurl);
				return;
			//this is for the on-demand version
			} else if (this.player && this.paramObj && this.paramObj.contenttype && 
							(this.paramObj.contenttype=="A" || 
							(this.paramObj.contenttype=="L" && this.paramObj.simulive && this.paramObj.simulive=="y"))
						) {
				//to find the last portrait slide and assign it to the image
				var position = this.player.getPosition();
				var tmp=this.getLastPushedElement(position,"slide","agenda");
				if (tmp) {this.showAgendaSlide(tmp.url); this.showSlideTranscript(tmp.url);}
			//this is for the live version
			} else if (this.firstrequest) {
				var tmpUrl=this.getLastPushedMediaURL("slide","agenda");
				if(tmpUrl==null) tmpUrl=this.getFirstMediaURL("slide","agenda");
				//if(this.eventid==1087) alert(tmpUrl);
				if (tmpUrl) {this.showAgendaSlide(tmpUrl); this.showSlideTranscript(tmpUrl);}
			}
		}
		
		if(this.getObjByName(this.doc,"frame_player_slide_transcript1") || this.getObjByName(this.doc,"frame_player_slide_transcript2") || this.getObjByName(this.doc,"frame_player_slide_transcript3")) this.showSlideTranscript(slideurl);
		
		//this variable declaration must be in a single line for the aut0-CD creation process to work
		var strSlideFrameSRC = "slide.html?slideurl="+escape(slideurl);
		if (bIE) {
			this.doc.slide_frame.location.href=strSlideFrameSRC;
		} else {
			//this.doc.slide_frame.src=strSlideFrameSRC;
			getObjByName(this.doc,"slide_frame").src=strSlideFrameSRC;
		}
		this.boolPollInSlideFrame=false;
		
		//this block is to enlarge the slide	
		if(this.enlargeWin && !this.enlargeWin.closed){
			var strEnlargeUrl = strSlideFrameSRC
			+"&enlarged=true"
			+"&eventid="+this.eventid
			+"&usecdn="+window.usecdn
			+"&disableprinting="+window.disablePrinting
			+"&cdnprefix="+window.cdnprefix
			+"&cacheinterval="+window.cacheinterval;
			if (this.eventid && this.eventid-0>25332) 
				strEnlargeUrl+="&size=_1000x750";
			else if (this.eventid && this.eventid-0>8100) 
				strEnlargeUrl+="&size=_768x576";
			else strEnlargeUrl+="&size=_640x480";
			
			this.enlargeWin.location.href=strEnlargeUrl;
			this.enlargeWin.focus();
			return false;
		} 
		window.focus();
	}
}

function showAgendaSlide(strAgendaSlideUrl) {
	//this.processPushedElementCounter();
	
	//if(this.eventid!=2970) return;
	if(!strAgendaSlideUrl || strAgendaSlideUrl=="null") return;
	//if(this.firstrequest==true) return;
	//alert(objAgendaFrame.location);
	this.agendaPageHtml=this.findActiveMediaURL("documents","agendapage",this.agendaPageHtml);
	if(this.agendaPageHtml.indexOf(wwwHost)==-1){
		var startIdx=this.agendaPageHtml.indexOf("://");
		var endIdx=this.agendaPageHtml.indexOf("/",startIdx+3);
		var hostname=this.agendaPageHtml.substring(startIdx+3,endIdx);
		var re=new RegExp(hostname,"g");
		this.agendaPageHtml=this.agendaPageHtml.replace(re,wwwHost);
	}
	//alert(this.agendaPageHtml);
	//if (!objAgendaFrame || !objAgendaFrame.location) return;
	if (!this.agendaPageHtml) return;
	if (this.currentAgendaSlide == strAgendaSlideUrl) return;
	this.currentAgendaSlide = strAgendaSlideUrl;
	var slideno=0;
	var sIdx=strAgendaSlideUrl.lastIndexOf("/");
	var eIdx=strAgendaSlideUrl.lastIndexOf(".");
	if(sIdx>0 && eIdx>0 && sIdx<eIdx) slideno=strAgendaSlideUrl.substring(sIdx+1,eIdx);
	var strAgendaFrameSrc = this.agendaPageHtml;
	strAgendaFrameSrc += (strAgendaFrameSrc.indexOf("?")==-1?"?":"&")+(new Date().getTime())+"#agenda"+slideno;
		//	+"?eventid="+this.eventid
		//	+"&eventhost="+eventHost
		//	+"&key="+this.eventuserkey
		//	+"&strAgendaSlideUrl="+strAgendaSlideUrl;
	if (bIE) {
		var objAgendaFrame = this.doc.agenda_frame;
		if (!objAgendaFrame || !objAgendaFrame.location) return;
		//for (var i in objAgendaFrame) alert(i+" : "+objAgendaFrame[i]);
		objAgendaFrame.location.href=strAgendaFrameSrc;
	} else {
		var objAgendaFrame = this.getObjByName(this.doc,"agenda_frame");
		if (!objAgendaFrame || !objAgendaFrame.src) return;
		//for (var i in objAgendaFrame) alert(i+" : "+objAgendaFrame[i]);
		objAgendaFrame.src=strAgendaFrameSrc;
	}
}

//Function to launch poll
function showPoll() {
	this.processPushedElementCounter();	
	if ((this.pollurl + "" != "undefined") && (this.pollurl != "")) {
	
		var strPollUrl = this.pollurl;
		// For white labeling events.
		strPollUrl = replaceHost(strPollUrl);
		
		if (this.eventuserid) strPollUrl+="&eventuserid="+this.eventuserid;
		if (this.eventuserkey) strPollUrl+="&key="+this.eventuserkey;
		
		var pollid = 0; 
		var extpos=this.pollurl.lastIndexOf("mediaurlid"); 
		pollid=this.pollurl.substr(extpos+11);
		
		var boolPollPopped=false;
		for (var i in this.arrPopupPolls) {
			if (this.arrPopupPolls[i]==pollid) boolPollPopped=true;
		}
		
		var intPollScreenLeft = 0;
		var intPollScreenTop = 0;
		
		if (bIE) {
			intPollScreenLeft = (this.pollPopupScreenLeft==null?(window.screenLeft + window.main.slideFrameLeft + 10):(window.screenLeft + this.pollPopupScreenLeft));
			intPollScreenTop = (this.pollPopupScreenTop==null?(window.screenTop + window.main.slideFrameTop + 10):(window.screenTop + this.pollPopupScreenTop));
		} else {
			intPollScreenLeft = (this.pollPopupScreenLeft==null?(window.screenX + window.main.slideFrameLeft + 10):(window.screenX + this.pollPopupScreenLeft));
			intPollScreenTop = (this.pollPopupScreenTop==null?(window.screenY + window.main.slideFrameTop + 30):(window.screenY + this.pollPopupScreenTop + 20));
		}

		if (boolPollPopped) {
			window.open(strPollUrl,'','resizable=1,width='+this.pollPopupWidth+',height='+this.pollPopupHeight+',left='+intPollScreenLeft+',top='+intPollScreenTop);
		} else if (""+this.pollpopup=="true") {
			window.open(strPollUrl,'','resizable=1,width='+this.pollPopupWidth+',height='+this.pollPopupHeight+',left='+intPollScreenLeft+',top='+intPollScreenTop);
			this.arrPopupPolls[this.arrPopupPolls.length]=pollid;
		} else {
			//this variable declaration must be in a single line for the aut0-CD creation process to work
			var strFramedPollUrl = "poll.html?pollurl="+escape(this.pollurl);
			if (this.eventuserid) strFramedPollUrl+="&eventuserid="+this.eventuserid;
			if (this.eventuserkey) strFramedPollUrl+="&key="+this.eventuserkey;
			this.boolPollInSlideFrame=true;
			if (bIE) {
				this.doc.slide_frame.location.href=strFramedPollUrl;
			} else {
				getObjByName(this.doc,"slide_frame").src=strPollUrl;
			}
			window.focus();
		}
	}
}

//Function to show URL
function showURL(urlAsParam) {
	this.processPushedElementCounter();
	
	if ((this.wwwurl + "" != "undefined") && (this.wwwurl != "")) {
		var strWwwUrl = this.wwwurl;
				
		if((strWwwUrl.indexOf("flashplayer.html")!=-1 || strWwwUrl.indexOf("flashDemo.html")!=-1)){
		 	if(strWwwUrl.indexOf("movepointer=true")!=-1){
				if(this.paramObj.contenttype=="L" && !this.prevflashwwwurl){
					strWwwUrl=strWwwUrl.replace(/movepointer=true/g,"showpointer=true");
				} else {
					var sourceX = strWwwUrl.match(/sourceX=[0-9]+/)+"";
					var sourceY = strWwwUrl.match(/sourceY=[0-9]+/)+"";
					sourceX= sourceX?sourceX.substring(sourceX.indexOf("=")+1)*1:400;
					sourceY= sourceY?sourceY.substring(sourceY.indexOf("=")+1)*1:300;
					this.showFlashPointer=true;
					this.flashPointerPosX=this.wwwwidth;
					this.flashPointerPosY=this.wwwheight;
					this.flashPointerSourceX=sourceX;
					this.flashPointerSourceY=sourceY;
					return;
				}
			}
			this.prevflashwwwurl=strWwwUrl
		}
		
		if(strWwwUrl.toLowerCase().indexOf("slidepointer=y")!=-1){
			var sourceX = strWwwUrl.match(/sourceX=[0-9]+/)+"";
			var sourceY = strWwwUrl.match(/sourceY=[0-9]+/)+"";
			sourceX= sourceX?sourceX.substring(sourceX.indexOf("=")+1)*1:400;
			sourceY= sourceY?sourceY.substring(sourceY.indexOf("=")+1)*1:300;
			this.showSlidePointer=true;
			this.slidePointerPosX=this.wwwwidth;
			this.slidePointerPosY=this.wwwheight;
			this.slidePointerSourceX=sourceX;
			this.slidePointerSourceY=sourceY;
			return;
		}
		
		if(strWwwUrl.indexOf("utils/action.html")!=-1 && strWwwUrl.indexOf("action=DemoConcluded")!=-1){
			//this.player.setMute(false);
			return;
		}
		
		if(strWwwUrl.indexOf("utils/action.html")!=-1 && strWwwUrl.indexOf("action=ClearChat")!=-1){
			return;
		}
		
		if(strWwwUrl.indexOf("utils/action.html")!=-1 && strWwwUrl.indexOf("action=StreamMonitorEmbed")!=-1){
			return;
		}
		
		if(strWwwUrl.indexOf("utils/action.html")!=-1 && strWwwUrl.indexOf("action=ClosePCView")!=-1){
			try{
				if(this.audiencepcviewpopup && !this.audiencepcviewpopup.closed) this.audiencepcviewpopup.close();
			}catch(err){}
			return;
		}
		
		
		if(strWwwUrl.indexOf("utils/action.html")!=-1 && strWwwUrl.indexOf("eventuserid=")!=-1){
			var targeteventuserid="";
			var sIdx=strWwwUrl.indexOf("eventuserid=")+12;
			var eIdx=strWwwUrl.indexOf("&",sIdx);
			if(eIdx!=-1) targeteventuserid=strWwwUrl.substring(sIdx,eIdx);
			else targeteventuserid=strWwwUrl.substring(sIdx);
			//if(targeteventuserid==this.eventuserid) alert("blocking/deleting user "+targeteventuserid);
			if(targeteventuserid==this.eventuserid){
				strWwwUrl+=strWwwUrl.indexOf("?")==-1?"?":"";
				strWwwUrl+=strWwwUrl.indexOf("eventid=")==-1?"&eventid="+this.eventid:"";
				strWwwUrl+=strWwwUrl.indexOf("sessionid=")==-1?"&sessionid="+this.sessionid:"";
				strWwwUrl+=strWwwUrl.indexOf("key=")==-1?"&key="+this.eventuserkey:"";
				//alert(strWwwUrl);
				window.location.href=strWwwUrl;
				
			}
			return;
		}
		
		//handle Flash Demo case with appropriate function, and then exit
		if(strWwwUrl.indexOf("flashDemo.html")!=-1 || strWwwUrl.indexOf("flashplayer.html")!=-1){
			if(window.kbits>0) this.wwwurl+="&kbits="+window.kbits;
			this.wwwurl+="&sourcepage=console";
			if((strWwwUrl.indexOf("flashplayer.html")!=-1 || strWwwUrl.indexOf("flashDemo.html")!=-1) && strWwwUrl.indexOf("slidebg=")==-1){
				if(this.paramObj.minhighbw) this.wwwurl+="&minhighbw="+this.paramObj.minhighbw;
				this.wwwurl+="&slidebg="+this.slideurl;
			}
			this.wwwurl+="&language="+this.paramObj.text_language_id
						+ (this.paramObj.localeCountryCode?"&localeCountryCode="+this.paramObj.localeCountryCode:"");
						
			this.showFlashDemo(this.wwwurl);
			this.showFlashPointer=false;
			this.flashPointerPosX=0;
			this.flashPointerPosY=0;
			return;
		}
		
		//this will append the on24 event user id if the URL is from *.on24.com
		if(strWwwUrl.indexOf(".on24.com")!=-1){
			if(strWwwUrl.indexOf("?")!=-1) strWwwUrl+="&eventuserid="+this.eventuserid;
			else  strWwwUrl+="?eventuserid="+this.eventuserid;
		}
		
		if(strWwwUrl.indexOf("##")!=-1) strWwwUrl=this.replaceTokensFromURL(strWwwUrl,"##");
		if(strWwwUrl.indexOf("#")!=-1) strWwwUrl=this.replaceTokensFromURL(strWwwUrl,"#");
		
		//this will append the external event user id if it is present
		if(this.paramObj.needuserinfo && this.paramObj.needuserinfo!="" && this.paramObj.needuserinfo!="null"){
			if(strWwwUrl.indexOf("?")==-1) strWwwUrl+="?";
			if (this.paramObj.eventid) strWwwUrl+="&eventid="+this.paramObj.eventid;
			if (this.paramObj.exteventusercd && this.paramObj.exteventusercd!="" && this.paramObj.exteventusercd!="null") strWwwUrl+="&ext_event_user_cd="+this.paramObj.exteventusercd;
			if (this.paramObj.firstname && this.paramObj.firstname!="" && this.paramObj.firstname!="null") strWwwUrl+="&firstname="+this.paramObj.firstname;
			if (this.paramObj.lastname && this.paramObj.lastname!="" && this.paramObj.lastname!="null") strWwwUrl+="&lastname="+this.paramObj.lastname;
			if (this.paramObj.company && this.paramObj.company!="" && this.paramObj.company!="null") strWwwUrl+="&company="+this.paramObj.company;
			if (this.paramObj.email && this.paramObj.email!="" && this.paramObj.email!="null") strWwwUrl+="&email="+this.paramObj.email;
		}
		
		//if mode is Simple Audio and not FAA, target the slide frame with a link to the URL
		if (this.getEventInfoObj("audio","clip") 
			&& this.getEventInfoObj("autoAudioRequired","autoAudioRequired")==null
			&& (this.paramObj.contenttype && this.paramObj.contenttype=="A")
			) {
			strWwwUrl="www.html?url="+escape(this.wwwurl)
			strWwwUrl+="&simpleaudio=true";
			strWwwUrl+="&wwwname="+this.wwwname;
			this.setSlideFrameSrc(strWwwUrl);
			this.boolPollInSlideFrame=true;
			return;
		}
		
		
		//for PC View
		if(strWwwUrl.indexOf("/pm2/launchpcview.html")!=-1) {
			//strWwwUrl=this.getPCViewURL();
			strWwwUrl = "launchpcview.html" 
						+ (strWwwUrl.indexOf("?")!=-1?strWwwUrl.substring(strWwwUrl.indexOf("?")):"");
			//alert(strWwwUrl)
			this.wwwurl=strWwwUrl;
			this.wwwpopup=(strWwwUrl.indexOf("popup=false")==-1);		
			if(this.enlargeWin && !this.enlargeWin.closed){
				this.showPCViewLinkinEnlargedArea();
			}
			var launchDurationSecs = 0;
			if(strWwwUrl.indexOf("launchdurationsecs=") !=-1){
				var ind=strWwwUrl.indexOf("launchdurationsecs=")+"launchdurationsecs=".length;
				launchDurationSecs = parseInt(strWwwUrl.substring(ind));								
				launchDurationSecs = Math.ceil(Math.random()  * launchDurationSecs);				
			}
			window.main.setTimeout(this.name+".launchDelayedPCView('"+strWwwUrl+"')", launchDurationSecs*1000);
			//alert(strWwwUrl);
			
			/*if (bIE) {
				this.doc.slide_frame.location.href=strWwwUrl;
			} else {
				this.getObjByName(this.doc,"slide_frame").src=strWwwUrl;
			}			
			*/
			return false;							
		}
		
		if(strWwwUrl.indexOf("/pm2/refreshconsoles.html")!=-1) {
			window.location.reload();
			return false;
		}
		
		if(strWwwUrl.indexOf("/pm2/closeconsoles.html")!=-1) {
			var redirectURL = "presentationover.html?"
						+ "eventid="+this.eventid
						+ "&sessionid="+this.sessionid
						+ "&key="+this.eventuserkey
						+ (this.paramObj.text_language_id?"&text_language_id="+this.paramObj.text_language_id:"")
						+ (this.paramObj.localeCountryCode?"&localeCountryCode="+this.paramObj.localeCountryCode:"");
			window.location.href=redirectURL;
			return false;
		}
		
		if(strWwwUrl.indexOf("/presentation/survey.jsp")!=-1 || strWwwUrl.indexOf("/presentation/html.jsp")!=-1) {
			// For white labeling events.
			strWwwUrl = replaceHost(strWwwUrl);		
		}
		
		//for portrait images, deprecated
		if((strWwwUrl.indexOf("/leftslide/")!=-1) || (strWwwUrl.indexOf("/portrait/")!=-1)){
			this.doc.portrait.src = strWwwUrl;
		//for all other cases
		} else if (""+this.wwwpopup=="false") {
			this.wwwurl=strWwwUrl;
			if(urlAsParam==true){
				strWwwUrl="www.html?url="+escape(this.wwwurl)
			} else {
				strWwwUrl="www.html"
			}
			this.setSlideFrameSrc(strWwwUrl);
			window.focus();
			/*if (bIE) {
				this.doc.slide_frame.location.href=strWwwUrl;
			} else {
				this.getObjByName(this.doc,"slide_frame").src=strWwwUrl;
			}*/
			this.boolPollInSlideFrame=true;
		} else if(this.wwwwidth>0 && this.wwwheight>0) { 
		   window.open(strWwwUrl,'','location=1,menubar=yes,titlebar=no,status=yes,scrollbars=yes,toolbar=yes,resizable=yes,width='+this.wwwwidth+',height='+this.wwwheight)
//			window.open(strWwwUrl,'','width='+this.wwwwidth+',height='+this.wwwheight)
		} else {
			window.open(strWwwUrl,'');
		}
	}
}

function launchDelayedPCView(strWwwUrl){
	//alert(strWwwUrl);
	this.setSlideFrameSrc(strWwwUrl);
	this.launchPCView();
}

//Function to Display Question
function showQuestion() { 
	this.processPushedElementCounter();
	
	if ((this.questionurl + "" != "undefined") && (this.questionurl != "")) { 
		if(this.questionurl=="AnswerToUser.html"){
			if (bIE) {
				if(this.doc.answer_frame)  return false;
			} else if (bNN) {
				if(this.getObjByName(this.doc,"answer_frame"))  return false;
			}
		}
		var q_media_url_id = 0; 
		var extpos=this.questionurl.lastIndexOf("mediaurlid"); 
		//when questionurl doesn't have mediaurlid (submitted on the fly), get it directly
		if(extpos==-1) q_media_url_id=this.questionid;
		else q_media_url_id=this.questionurl.substr(extpos+11);
		//If the question (answer) is targeted to any particular user, 
		//question width will have the id of the user.
		if(this.questionwidth>1000){
			if(this.questionwidth!=this.eventuserid) return false;
		}
		
		if(q_media_url_id==null || q_media_url_id=="") return false;
		//this variable declaration must be in a single line for the aut0-CD creation process to work
		var strSlideFrameSRC = "question.html?eventid="+this.eventid
			+"&eventhost="+eventHost
			+"&key="+this.eventuserkey
			+"&mediaurlid="+q_media_url_id
			+"&popup="+this.questionpopup;
		
		if(this.questionpopup+""=="false"){ // to slide area
			// strSlideFrameSRC+="&gobackurl="+escape((bIE)?this.doc.slide_frame.location.href:getObjByName(this.doc,"slide_frame").src);
			if (bIE) {
				this.doc.slide_frame.location.href=strSlideFrameSRC;
			} else {
				getObjByName(this.doc,"slide_frame").src=strSlideFrameSRC;
			}
		} else {
			if (bIE) {
				if(this.doc.question_frame)
					this.doc.question_frame.location.href=strSlideFrameSRC;
			} else {
				if(getObjByName(this.doc,"question_frame"))
					getObjByName(this.doc,"question_frame").src=strSlideFrameSRC;
			}
		}
		window.focus();
		//when a particular user is targetted and the msg to the user is in form of an alert, enlarged view doesn't change
		if(this.questionpopup=="true" && this.questionwidth>0){
			if(this.questionwidth==this.eventuserid) return false;
		}
		this.boolPollInSlideFrame=false;
				
		if(this.enlargeWin && !this.enlargeWin.closed){ 
			this.enlargeWin.location.href=strSlideFrameSRC+"&enlarged=true"; 
		}               
	} 
}

function refreshQuestions() { }

function refreshSlides() { }

//Function to call when the event status changes
function updateStatus() { 
	//reset flags
	this.wwwchange=false;
	this.pollchange=false;
	this.questionchange=false;
	this.slidechange=false;
	this.slideadded=false;
	this.questionadded=false;
	if (this.endlive.indexOf("true")!=-1) this.stopMediaMetric();
	if (this.onEndLive && (this.endlive.indexOf("true")!=-1)) {
		try{
		if(this.player!=null) this.player.stop();
		}catch(e){}
		//alert("This event is now over: This Event Console will be closed or redirected.");
		//window.open("consoleclosingnotification.html","consoleclosingnotification","left=200,top=200,status=n,scrollbars=n,height=200,width=300,");

		var lngRandom = Math.random();
		var intTimeout = 1000 + (lngRandom*24000);
		window.main.clearTimeout(this.toid);

		//wait is not important if all you're doing in closing, 
		//(it is important when redirecting ALL users to a url)
		if (this.onEndLive=="close") intTimeout =3000;

		window.main.setTimeout(this.name+".handleEndLive()",intTimeout);
	}
}

function refreshAll() { }

function everyRequest() { 
	//mediametriccallback();
}

function checkForAudioClipPlaylist() {
	if (this.audioClipPlaylistChecked==false) {
		if (this.getEventInfoObj("audio","clip")) { //checks that "audio"/"clip" is in EVENT_INFO table
			var arrAudioClips = this.getMediaUrlSubArray("audio","clip"); //get array of audio clips
			if (arrAudioClips && this.player) {
				var arrPlaylist = new Array(); //will hold array of clip durations
				
				for (var i in arrAudioClips) if(arrAudioClips[i].notes=="Y") arrPlaylist[arrPlaylist.length] = arrAudioClips[i].width;
				
				if(arrPlaylist.length > 1){
					this.player.arrAudioClips = arrAudioClips;
					this.player.arrPlaylist = arrPlaylist;
					this.player.boolHasPlaylist = true;
				}
			}
		}
		this.audioClipPlaylistChecked=true;
	}
}

//Function to determine first slide in primary deck
function getFirstSlide() {
	var slide1=false;
	for (var i in this.sessionObj.mediaurl) {
		if (this.sessionObj.mediaurl[i].active && this.sessionObj.mediaurl[i].categorycode=="slide") {
			slide1=this.sessionObj.mediaurl[i].url;
			return slide1;
		}
	}
	return slide1;
}

//Function to determine event_user_id
function getUserID() {
	var nameStr = "eventid"+this.eventid+"=";
	var maxLen = document.cookie.length
	var i = 0
	while (i < maxLen) {
	  var j = i + nameStr.length
	  if (document.cookie.substring(i,j) == nameStr) {
	     var cookieEnd = document.cookie.indexOf(";",j);
	
	     if (cookieEnd == -1) {
	        cookieEnd = document.cookie.length;
	     }
	     return unescape(document.cookie.substring(j,cookieEnd));
	  }
	  i++
	}
	return null;
	} 

//Function to send user question to database
function sendUserQuestion(q){
alert('This function has been disabled.')
return false;
	
	var question = q;
	if(!this.eventuserid) {
		var alertMsg="You have not yet registered for this event. Please register before submitting a question.";
		if(this.eventObj.message.notregistered && this.eventObj.message.notregistered!=null && this.eventObj.message.notregistered!="") alertMsg=this.eventObj.message.notregistered;
		alert(alertMsg);
		return false;
	}

	if (question=="") {
		var alertMsg="Please type a question to submit.";
		if(this.eventObj.message.typequestion && this.eventObj.message.typequestion!=null && this.eventObj.message.typequestion!="") alertMsg=this.eventObj.message.typequestion;		
		alert(alertMsg);
		return false;
	} else if (q.length>600) {
		var alertMsg="Your question is too long. Please limit it to 600 characters.";
		if(this.eventObj.message.questiontoolong600 && this.eventObj.message.questiontoolong600!=null && this.eventObj.message.questiontoolong600!="") alertMsg=this.eventObj.message.questiontoolong600;
		alert(alertMsg);
		return false;
	}
	
	//question=escapeASCIIOnly(question);
	var now = new Date();
	var ms = now.getTime();	
	
	if(this.questionDefaultPriority < 0){
		this.questionDefaultPriority = this.getQuestionDefaultPriority();
	}
	
	var imgsrc = "http://www.on24.com/eventManager/PresentationServlet";
	var params = "eventid="+this.eventid+"&sessionid="+this.sessionid;
		params += "&mode=insert";
		params += "&categorycode=userquestion";
		params += "&type=userquestion";
		params += "&questionsource="+this.eventuserid;
		params += "&questiontype=singletext";
		params += "&sequence=" + this.questionDefaultPriority;
		params += "&"+ms;
	
	if(!this.submitXMLHTTPPost(imgsrc, params+"&question="+question.replace(/&/g,"%26").replace(/\+/g,"%2B"))) {
		params += "&question="+this.escapeASCIIOnly(question);
		var tempimg1=null;
		//alert(imgsrc);
		tempimg1=new Image();
		tempimg1.src=imgsrc+"?"+params;
	}
	var answerElement=this.getElementFromDoc("window.main","document.Answer","answer");
	if(answerElement!=null){
		answerElement.value+="Q>"+q+"\n";
		if(bIE) answerElement.scrollTop=answerElement.scrollHeight;
		else if(bNN) answerElement.select();
		return true;
	}
	var alertMsg="Your question has been submitted.";
	if(this.eventObj.message.questionsubmitted && this.eventObj.message.questionsubmitted!=null && this.eventObj.message.questionsubmitted!="") alertMsg=this.eventObj.message.questionsubmitted;
	alert(alertMsg);
	return true;
}

function getQuestionDefaultPriority() {
	var defaultPriorityUrl = "http://www.on24.com/pm2/pmdefaultassignment.jsp?eventid="+this.eventid;
	var defaultPriority = GetUrlResponse(defaultPriorityUrl);
	defaultPriority = defaultPriority.replace( /^\s+/g, "" );// strip leading
  	defaultPriority = defaultPriority.replace( /\s+$/g, "" );// strip trailing	
	if (defaultPriority == 1) {
		return 2;
	} else if (defaultPriority == 2) {
		return 1;
	} else if (defaultPriority == 3) {
		return 0;
	} else if (defaultPriority == 4) {
		return 3;
	}	
}

//function to find last-pushed slide for new arrivals to live streaming event
//this function is deprecated
function getLastPushedSlide() {
	return this.getLastPushedMediaURL("slide","slide");
}

function getDisplayDate(showDay) {
	var arrayMonths = new Array();
	arrayMonths[0]="January";
	arrayMonths[1]="February";
	arrayMonths[2]="March";
	arrayMonths[3]="April";
	arrayMonths[4]="May";
	arrayMonths[5]="June";
	arrayMonths[6]="July";
	arrayMonths[7]="August";
	arrayMonths[8]="September";
	arrayMonths[9]="October";
	arrayMonths[10]="November";
	arrayMonths[11]="December";
	
	var arrayWeekdays = new Array();
	arrayWeekdays[0]="Sunday";
	arrayWeekdays[1]="Monday";
	arrayWeekdays[2]="Tuesday";
	arrayWeekdays[3]="Wednesday";
	arrayWeekdays[4]="Thursday";
	arrayWeekdays[5]="Friday";
	arrayWeekdays[6]="Saturday";
	
	var strDate=""
	if(showDay) strDate+=arrayWeekdays[this.eventObj.goodafter.getDay()]+", ";
	strDate+=arrayMonths[this.eventObj.goodafter.getMonth()]+" ";
	strDate+=this.eventObj.goodafter.getDate()+", ";
	strDate+=this.eventObj.goodafter.getFullYear();
	return strDate;
}

function getDisplayTime(timezone) {
	var pmOffset=0;
	var timezoneOffset=0;
	switch(this.eventObj.displaytimezone){
		case "Eastern Daylight Time" : 
		case "Eastern Standard Time" :
			timezoneOffset=3;
			break;
		case "Mountain Daylight Time" : 
		case "Mountain Standard Time" :
			timezoneOffset=1;
			break;
		case "Central Daylight Time" : 
		case "Central Standard Time" : 
			timezoneOffset=2;
			break;
	}
	var utcOffset=8;
	if(this.eventObj.displaytimezone.toLowerCase().indexOf("daylight")!=-1)	utcOffset=7;
	var utcdate=new Date(this.eventObj.goodafter.getUTCFullYear(),this.eventObj.goodafter.getUTCMonth(),this.eventObj.goodafter.getUTCDate(),this.eventObj.goodafter.getUTCHours(),this.eventObj.goodafter.getUTCMinutes(),this.eventObj.goodafter.getUTCSeconds(),this.eventObj.goodafter.getUTCMilliseconds());
	var newgoodafter=new Date(utcdate.getTime()+((timezoneOffset-utcOffset)*60*60*1000))
	var hours=newgoodafter.getHours();
	var minutes=newgoodafter.getMinutes();
	if(hours>12) {
		pmOffset=12;
	}
	var meridian=" a.m.";
	if(hours>11) {
		meridian=" p.m.";
	}
	var strTime="";
	strTime+=(hours-pmOffset)+":";
	if(minutes<10) strTime+="0";
	strTime+=minutes;
	strTime+=meridian;
	if(timezone) strTime+=" "+this.eventObj.displaytimezone;
	return strTime;
}


//Function to write Q and A Textarea field
function writeQandA() {
	var strQandA="";
	if(bIE) {
		strQandA+='<textarea id="textareaQuestionBlock" cols="25" rows="3" name="question"></textarea>';
	} else {
		strQandA+='<textarea id="textareaQuestionBlock" cols="15" rows="2" name="question"></textarea>';
	}	
	strQandA+='<br><img src="clear.gif" width=200 height=4 border=0><br><a href="#" onclick="window.parent.main.ep1.sendUserQuestion(document.'+this.formname+'.question.value);document.'+this.formname+'.question.value=\'\';return false;"><img src="submit_59x23.gif" width="59" height="23" alt="" border="0" align="top"></a>';
	return strQandA;
}

//Function to write the PC View audience button
function writePCViewbutton() {
	var strPCView="";
	var username=""; 
	var defeatcache="233242";
	var PCViewObj=this.getEventInfoObj("pcview","pcview");
	if(PCViewObj==null) return "";
	username=PCViewObj.value;
	var buttonURL='altpcview.html?username='+username+'&'+defeatcache; 
	if (bIE){
		strPCView='<div id="pcview" style="position:absolute; left:450 px; top:427 px"><iframe name="pcview_frame" width=111 height=28 frameborder=0 scrolling=no marginheight=0 marginwidth=0 src="'+buttonURL+'"></div>';
	}else{
		strPCView='<layer name="pc_view" id="pc_view" pagex=450 pagey=427 src="'+buttonURL+'"></layer>';	
	}
	return strPCView;
}

//Function to launch the PC View popup for specific meeting room
function launchPCView(username) {
	var url=this.getPCViewURL(username);
	var params = "width="  + parseInt(screen.availWidth);
	params += ",height="  + parseInt(screen.availHeight);
	params += ",scrollbars=yes,resizable=yes,left=0,top=0";
	this.audiencepcviewpopup = window.open(url, 'audiencepcviewpopup', params)
	//this.audiencepcviewpopup.moveTo(0,0);
}

function getPCViewURL(username) {
	/*if(!username){ 
		var PCViewObj=this.getEventInfoObj("pcview","pcview");
		if(PCViewObj==null) return "";
		username=PCViewObj.value;
	}*/
	
	var url= "launch.html?mode=audience&" + this.wwwurl.substring(this.wwwurl.indexOf("?")+1);
	return url;

}
//Function to write Q and A Textarea field
function writeQandA2(pcolumns,prows,button) {
	var cols=25;
	var rows=3;
	var btn="default";
	if (pcolumns) cols=pcolumns;
	if (prows) rows=prows;
	if (button) btn=button;
	var strQandA="";
	if (btn=="default") btn="submit_59x23.gif";
	if(bIE) {
		strQandA+='<textarea id="textareaQuestionBlock" cols="'+cols+'" rows="'+rows+'" name="question"></textarea>';
	} else {
		strQandA+='<textarea id="textareaQuestionBlock" cols="'+(cols-5)+'" rows="'+(rows-1)+'" name="question"></textarea>';
	}	
	if (!btn) return strQandA;
	strQandA+='<br><img src="clear.gif" width=200 height=4 border=0><br>';
	strQandA+=this.writeQandAbutton(btn);
	return strQandA;
}

//Function to write Q and A Textarea field
function writeQandA3(IEcolumns,IErows,NNcolumns,NNrows) {
	var strQandA="";
	//check for unix
	var agt=navigator.userAgent.toLowerCase();
	var is_sun   = (agt.indexOf("sunos")!=-1);
    var is_irix  = (agt.indexOf("irix") !=-1);
    var is_hpux  = (agt.indexOf("hp-ux")!=-1);
    var is_aix   = (agt.indexOf("aix") !=-1); 
    var is_linux = (agt.indexOf("inux")!=-1);
    var is_sco   = (agt.indexOf("sco")!=-1) || (agt.indexOf("unix_sv")!=-1);
    var is_unixware = (agt.indexOf("unix_system_v")!=-1); 
    var is_mpras    = (agt.indexOf("ncr")!=-1); 
    var is_reliant  = (agt.indexOf("reliantunix")!=-1);
    var is_dec   = ((agt.indexOf("dec")!=-1) || (agt.indexOf("osf1")!=-1) || 
           (agt.indexOf("dec_alpha")!=-1) || (agt.indexOf("alphaserver")!=-1) || 
           (agt.indexOf("ultrix")!=-1) || (agt.indexOf("alphastation")!=-1)); 
    var is_sinix = (agt.indexOf("sinix")!=-1);
    var is_freebsd = (agt.indexOf("freebsd")!=-1);
    var is_bsd = (agt.indexOf("bsd")!=-1);
    var is_unix  = ((agt.indexOf("x11")!=-1) || is_sun || is_irix || is_hpux || 
                 is_sco ||is_unixware || is_mpras || is_reliant || 
                 is_dec || is_sinix || is_aix || is_linux || is_bsd || is_freebsd);
	//alert("UNIX? "+is_unix)
	//alert("Netscape? "+bNN)
	//alert("Version? "+parseInt(navigator.appVersion))
	if(is_unix && bNN && parseInt(navigator.appVersion)<=4){
		strQandA+='<input type=text size="'+NNcolumns+'" name="question">';
	}
	else if(bIE) {
		strQandA+='<textarea id="textareaQuestionBlock" cols="'+IEcolumns+'" rows="'+IErows+'" name="question"></textarea>';
	} else {
		//alert('ns');
		strQandA+='<textarea id="textareaQuestionBlock" cols="'+NNcolumns+'" rows="'+NNrows+'" name="question"></textarea>';
	}	
	return strQandA;
}

//Function to write Q and A Button Image
function writeQandAbutton(btn) {
	var strButton="";
	if (btn=="default") btn="submit_59x23.gif";
	strButton+='<a href="#" onclick="window.parent.main.ep1.sendUserQuestion(document.'+this.formname+'.question.value);document.'+this.formname+'.question.value=\'\';return false;"><img src="'+btn+'" alt="" border="0"></a>';
	return strButton;
}

//Function to write Answer Textarea field
function writeAnswer(hasHTMLAnswerBlock,width,height,IEcolumns,IErows,NNcolumns,NNrows) {
	var strAnswer="";
	if(hasHTMLAnswerBlock==true) {
		var answerBlockURL="answersfrompresenters.html"
							+"?eventid="+this.eventid
							+"&sessionid="+this.sessionid
							+"&key="+this.eventuserkey
							+"&eventuserid="+this.eventuserid
							+"&displaymode=console"
							+"&sortby=answerseq"
							+"&order="+(this.paramObj.contenttype=="L"?"false":"true");
		strAnswer='<iframe id="answer_frame" name="answer_frame" width='+width+' height='+height+' frameborder=1  scrolling=yes marginheight=0 marginwidth=0 src="'+answerBlockURL+'"></iframe>';
		return strAnswer;
	}
	if(bIE) {
		strAnswer+='<textarea id="textareaAnswerBlock" cols="'+IEcolumns+'" rows="'+IErows+'" name="answer" style="border:1px solid black;" onfocus="blur()"></textarea>';
	} else {
		strAnswer+='<textarea id="textareaAnswerBlock" cols="'+NNcolumns+'" rows="'+NNrows+'" name="answer" onfocus="blur()"></textarea>';
	}	
	return strAnswer;
}
//Function to write slide frame
function writeSlideFrame(width,height,left,top) {
	var slide1=this.getFirstSlide();
	var strSlideFrameSRC = "slide.html?slideurl="+escape(slide1);
	if (!slide1) {
		strSlideFrameSRC="blank.html";
	} 
	//alert(slide1);
	var strSlideFrame='<div id="slide_div" style="position:absolute; left:'+left+'px; top:'+top+'px;"><iframe id="slide_frame" name="slide_frame" width='+width+' height='+height+' frameborder=0 scrolling=no marginheight=0 marginwidth=0 src="'+strSlideFrameSRC+'"></iframe></div>';
	//if(this.doc.layers) strSlideFrame='<layer name="slide_frame" id="slide_frame" pagex='+left+' pagey='+top+' clip="0,0,'+width+','+height+'" width='+width+' height='+height+'>test</layer>';
	if(this.doc.layers) strSlideFrame='<layer name="slide_frame" id="slide_frame" pagex='+left+' pagey='+top+' clip="0,0,'+width+','+height+'" width='+width+' height='+height+' src="'+strSlideFrameSRC+'"></layer>';
	return strSlideFrame;
}

//Function to change streaming media format
function switchMedia(newformat,regServlet) {
	if (regServlet) {
		var regURL = "http://www.on24.com/eventRegistration/eventRegistrationServlet"
		+"?eventid="+this.eventid
		+"&sessionid="+this.sessionid
		+"&format="+newformat
		+"&key="+this.eventuserkey
		+"&sourcepage=lobby";
		window.location.href=regURL;
	} else {
		var regURL = window.location.pathname
		+"?eventid="+this.eventid
		+"&sessionid="+this.sessionid
		+"&format="+newformat
		+"&key="+this.eventuserkey
		+"&contenttype="+this.paramObj.contenttype
		+"&mediametricid="+this.paramObj.mediametricid
		+"&mediametricsessionid="+this.paramObj.mediametricsessionid;
		//alert(regURL);
		window.location.href=regURL;
	}
}

//Function to write Switch Media Format link
function writeSwitchMedia(btnRM,btnWM,oldformat,regServlet) {
	var bitrate=oldformat.substring(2);
	var newformat=null;
	var message=null;
	var strSwitchMedia="";
	//alert (bitrate);
	if (oldformat.indexOf("rm")!=-1) {
		newformat="wm"+bitrate;
		message="Switch to Windows Media Player";
		if (btnWM) message=btnWM;
	} else if (oldformat.indexOf("wm")!=-1) {
		newformat="rm"+bitrate;
		message="Switch to Real Player";
		if (btnRM) message=btnRM;
	}
	strSwitchMedia+="<a class=\"switchMedia\" href=\"#\" onclick=\""+this.name+".switchMedia('"+newformat+"',"+regServlet+");return false;\">";
	strSwitchMedia+=message;
	strSwitchMedia+="</a>";
	//alert(strSwitchMedia);
	return strSwitchMedia;
}

//Function to write opening Form tag
function writeFormTag() {
	var strForm='<form name="'+this.formname+'" onsubmit="return false;">';
	return strForm;
}

//Function to write chapters dropdown
function writeChapters(charLimit,code,category) {
	if(!charLimit) charLimit=100;
	if(!code) code="chapter";
	if(!category) category="chapter";
	this.chapterTextLength=charLimit;
	var arrChapters = this.getChapterArray(code,category); //a subarray of offsetlog array
	
	var strChapters="";
	for (var i in arrChapters) {
		
		var objOffset = arrChapters[i];
		var objMediaUrl = this.getMediaURLObject(objOffset.id);
		var offset = objOffset.ondemandoffset/1000;
		var formattedOffsetString="";
		if(this.paramObj.chaptertimes && this.paramObj.chaptertimes=="y") formattedOffsetString=" ("+formatseconds(Math.round(offset))+")";
		
		var name = objMediaUrl.name;
		name=name.substr(0,charLimit);
		strChapters+='<option value="'+offset+'">'+name+formattedOffsetString+'</option>';
	}
	if (strChapters!="") {
		strChapters='<select name="selchapter" onchange="'+this.name+'.setPlayerPosition(this.options[this.selectedIndex].value)">'+strChapters+'</select>';
	}
	return strChapters;
}

function sortByOffset(a,b) {
	return a.ondemandoffset - b.ondemandoffset;
}

//Function to return a subset of the offsetlog, as an array of chapters, indexed by offset
//It will include slides as chapters if that flag is in EVENT_INFO table
//This will also include audio clips, if enabled for this event.
function getChapterArray(code,category) {
	if(!code) code="chapter";
	if(!category) category="chapter";
	
	var arrChapters = new Array();
	this.addAudioClipsToOffsets();
	
	//loop through array of offsets
	for (var i in this.sessionObj.offsetlog) {
		var objOffset = this.sessionObj.offsetlog[i];
		if (objOffset.id==0) continue;
		var objMediaUrl = this.getMediaURLObject(objOffset.id);
		if(objMediaUrl==null) continue;
		
		if(objMediaUrl.code==code && objMediaUrl.categorycode==category) {
			//alert(objOffset.id+" : "+objMediaUrl.code+" : "+objMediaUrl.categorycode+" : "+objOffset.ondemandoffset+" : "+objMediaUrl.name);
			arrChapters[arrChapters.length]=objOffset; //matches the code and category
		} else if (this.getEventInfoObj("requireChapterColumn","requireChapterColumn") && objMediaUrl.code=="slide" && objMediaUrl.popup==true) {
			//alert(objOffset.id+" : "+objMediaUrl.code+" : "+objMediaUrl.categorycode+" : "+objOffset.ondemandoffset+" : "+objMediaUrl.name);
			arrChapters[arrChapters.length]=objOffset; //matches slide, popup=true for slides as chapters
		} else if (this.getEventInfoObj("audio","clip") && objMediaUrl.code=="audio" && objMediaUrl.categorycode=="clip" && objMediaUrl.popup==true) {
			//alert(objOffset.id+" : "+objMediaUrl.code+" : "+objMediaUrl.categorycode+" : "+objOffset.ondemandoffset+" : "+objMediaUrl.name);
			arrChapters[arrChapters.length]=objOffset; //matches slide, popup=true for slides as chapters
		}
	}
	return arrChapters;
}

function addAudioClipsToOffsets() {
	if(this.boolAudioClipsAddedToOffsets) return;
	if (!this.getEventInfoObj("audio","clip")) return;  //checks that "audio"/"clip" is in EVENT_INFO table
	
	var arrAudioClips = this.getMediaUrlSubArray("audio","clip"); //get array of audio clips
	var arrAudioChapters = new Array();
	if (arrAudioClips) {
		var intClipOffsets = 0;
		for (var i in arrAudioClips) {
			if(arrAudioClips[i].notes=="Y" && arrAudioClips[i].popup==true) { //check that clip is encoded and active
				var objMediaUrl = arrAudioClips[i]; //get Media Url Object from mediaurl array
				var intMediaUrlId = objMediaUrl.id; //
				var intMediaOffset = intClipOffsets-0+500;
				var objOffset = new this.win.parent.presentationinfo(intMediaUrlId,"",true,null,intMediaOffset);
				if(!this.boolAudioClipsAddedToOffsets) this.sessionObj.offsetlog[this.sessionObj.offsetlog.length] = objOffset;
			}
			if(arrAudioClips[i].notes=="Y") intClipOffsets+=arrAudioClips[i].width-0;
		}	
	}
	this.sessionObj.offsetlog.sort(this.sortByOffset);
				
	this.boolAudioClipsAddedToOffsets = true;
}

//Function to write chapters dropdown
function writeChapterLinks(charLimit,code,category,delimiter) {
	if(!charLimit) charLimit=100;
	if(!code) code="chapter";
	if(!category) category="chapter";
	if(!delimiter) delimiter="<br>";
	this.arrChapters = new Array();
	var strChapters="";
	this.chapterTextLength=charLimit;
	
	var counter=0;
	for (var i in this.sessionObj.offsetlog) {
		var offset = this.sessionObj.offsetlog[i].ondemandoffset/1000;
		var id = this.sessionObj.offsetlog[i].id;
		for (var j in this.sessionObj.mediaurl) {
			var name=this.sessionObj.mediaurl[j].name;
			name=name.substr(0,charLimit);
			if (this.sessionObj.mediaurl[j].id==id && this.sessionObj.mediaurl[j].code==code && this.sessionObj.mediaurl[j].categorycode==category) {
				this.arrChapters[this.arrChapters.length]=offset;
				//if (counter>0) 
				strChapters+=delimiter;
				if (this.paramObj.contenttype=="A") {
					strChapters+='<a href="#" onclick="'+this.name+'.setPlayerPosition('+offset+');return false;"><span name="chapter'+offset+'" id="chapter'+offset+'">'+name+'</span></a>';
				} else {
					strChapters+='<a><span name="chapter'+offset+'" id="chapter'+offset+'">'+name+'</span></a>';
				}

				counter++;
			}
			
		}

	}
//alert(strChapters);
	return strChapters;
}

//Function to find a Named Parameter
function findNamedParam (str,param) {
	var start=str.indexOf(param);
		if(start!=-1){
			str=str.substring(start,str.length);
			var end=str.indexOf("&");
			if(end!=-1) {
				return str.substring(param.length+1,end);
			} else {
				return str.substring(param.length+1,str.length);
			}
		} 
	return false;
}

//Function to determine Source file for primary deck
function getSlideSourceFile() {
	var sourcefilename=false;
	for (var i in this.sessionObj.mediaurl) {
		if (this.sessionObj.mediaurl[i].active && this.sessionObj.mediaurl[i].categorycode=="slide") {
			var url=this.sessionObj.mediaurl[i].url;
			var pos=url.lastIndexOf("/");
			var end=url.length;
			var pathname=url.substring(0,pos+1);
			
			sourcefilename=this.sessionObj.mediaurl[i].sourcefilename;
			return pathname+sourcefilename;
		}
	}
	return sourcefilename;
}


//New function to determine if Q and A is required
function QandArequired() {
	return this.isEventInfoRequired("qAndARequired");
}

//New function to determine if PCView is required
function pcviewRequired() {
	return this.isEventInfoRequired("pcview");
}

//New function to determine if polling is required
function pollingRequired() {
	return this.isEventInfoRequired("pollingRequired");
}
//New function to determine if slide is required
function slidesRequired() {
	return this.isEventInfoRequired("slide");
}

//New function to determine if slides is required
function isEventInfoRequired(typeCode) {
	if (typeCode==null || this.eventObj==null) return false;
	for (var i in this.eventObj.eventinfo) {
		if (this.eventObj.eventinfo[i].typecode==typeCode) {
			return true;
		}
	}
	return false;
}

//returns sub array of media url array that is restricted by code and category
function getMediaUrlSubArray(code,categorycode) {
	var arrSubArray = new Array();
	for (var i in this.mediaurl) {
		if (this.mediaurl[i].active && (code==false || this.mediaurl[i].code==code) && (categorycode==false || this.mediaurl[i].categorycode==categorycode)) {
			arrSubArray[arrSubArray.length] = this.mediaurl[i];
		}
	}
	if (arrSubArray.lenght==0) return null;
	return arrSubArray;
}

//Function to find URL in mediaurl array
function findMediaURL(code,categorycode) {
	var mediaURL=null;
	for (var i in this.mediaurl) {
		if (this.mediaurl[i].active && (code==false || this.mediaurl[i].code==code) && (categorycode==false || this.mediaurl[i].categorycode==categorycode)) {
			mediaURL=this.mediaurl[i].url;
		}
	}
	return mediaURL;
}

//Function to find mediaurl object in mediaurl array
function findMediaURLobject(code,categorycode) {
	var mediaURLobject=null;
	for (var i in this.mediaurl) {
		if (this.mediaurl[i].active && (code==false || this.mediaurl[i].code==code) && (categorycode==false || this.mediaurl[i].categorycode==categorycode)) {
			mediaURLobject=this.mediaurl[i];
		}
	}
	return mediaURLobject;
}

//Function to find default media stream based on format parameter
function findDefaultStream(format) {
	//var defaultStream="http://www.on24.com/clients/default/media/unavailable";
	//if (format.indexOf("rm")!=-1) {
	//	defaultStream+=".ram";
	//} else {
	//	defaultStream+=".asx";
	//}
	var defaultStream="http://www.on24.com/eventRegistration/media/meta.jsp"
		+"?eventid="+this.eventid
		+"&sessionid="+this.sessionid
		+"&period="+this.paramObj.contenttype
		+"&format="+this.paramObj.format
		+"&key="+this.eventuserkey	
		//+"&usecdn="+window.usecdn	
		+(this.paramObj.contenttype && this.paramObj.contenttype=="L" && this.paramObj.simulive && 			this.paramObj.simulive=="y"?"&simulive=y":"")
//		+"&streamorder=random"

//if (this.eventid=="14918")	alert(defaultStream);
	return defaultStream;
}

//Function to find default media stream based on format parameter
function findDefaultLocalStream(format) {
	var strDefaultLocalStream="13/04/94/rt";
		strDefaultLocalStream+="/";
		strDefaultLocalStream+=this.sessionid;
		strDefaultLocalStream+="_";
		strDefaultLocalStream+=format;
		strDefaultLocalStream+=".";
		strDefaultLocalStream+=format.indexOf("rm")!=-1?"ram":"asx";
	return strDefaultLocalStream;
}

//Function to find value in eventinfo array
function findEventInfo(typecode,category) {
	for (var i in this.eventinfo) {
		if ((typecode==false || this.eventinfo[i].typecode==typecode) && (category==false || this.eventinfo[i].category==category) && (typecode || category)) {
			return true;
		}
	}
	return false;
}

//Function to get eventinfo object in eventinfo array
function getEventInfoObj(typecode,category) {
	for (var i in this.eventinfo) {
		if (this.eventinfo[i].typecode==typecode && this.eventinfo[i].category==category) {
			return this.eventinfo[i];
		}
	}
	return null;
}

//Function that combines findEventInfo() and findMediaURL()
function findActiveMediaURL(code,categorycode,defaultvalue) {
	if (!this.findEventInfo(code,categorycode)) return defaultvalue;
	
	var url=this.findMediaURL(code,categorycode);
	if (url) {
		return url;
	} else {
		return defaultvalue;
	}
}

//Function that combines findEventInfo() and findMediaURL()
function findActiveMediaURLobject(code,categorycode,defaultvalue) {
	if (!this.findEventInfo(code,categorycode)) return defaultvalue;
	
	var mediaURLobject=this.findMediaURLobject(code,categorycode);
	if (mediaURLobject) {
		return mediaURLobject;
	} else {
		return defaultvalue;
	}
}

//Function to return media url object
function getMediaURLObject(id) {
	var objElement=null;
	for(var i in this.mediaurl){
		if(this.mediaurl[i].id==id){
			objElement=this.mediaurl[i];
		}				
	}
	return objElement;
}

//function to find last-pushed element in offset log based on passed parameters
function getLastPushedElement(position,code,categorycode) {
	var objElement=null;
	var id=null
	var tmpObjElement=null
	for (var i in this.offsetlog) {
		if (position < this.offsetlog[i].ondemandoffset) {
			return objElement;
		}
		id=this.offsetlog[i].id;
		tmpObjElement=this.getMediaURLObject(id);
		if (tmpObjElement && (!code || tmpObjElement.code==code) && (!categorycode || tmpObjElement.categorycode==categorycode) && tmpObjElement.active) {
			objElement=tmpObjElement;
		}
	}
	return objElement;
}

//Function to determine first media url based on code and categorycode
function getFirstMediaURL(code,categorycode) {
	var mediaURL=null;
	for (var i in this.sessionObj.mediaurl) {
		if (this.sessionObj.mediaurl[i].active && this.sessionObj.mediaurl[i].code==code && this.sessionObj.mediaurl[i].categorycode==categorycode) {
			mediaURL=this.sessionObj.mediaurl[i].url;
			return mediaURL;
		}
	}
	return mediaURL;
}

//Function to determine last media url based on code and categorycode
function getLastPushedMediaURL(code,categorycode) {
	var mediaURL=null;
	var mediaURLObject = this.getLastPushedMediaURLObject(code,categorycode);
	if(mediaURLObject!=null) mediaURL=mediaURLObject.url;
	/*var mArray=this.mediaurl;
	for (var i in this.revtimestamplog) {
		for (var j in mArray) {
			if (mArray[j].active && (!code || mArray[j].code==code) && (!categorycode || mArray[j].categorycode.indexOf(categorycode)!=-1) && mArray[j].id==this.revtimestamplog[i].id) {
				mediaURL=mArray[j].url;
				return mediaURL;
			}
		}
	}*/
	return mediaURL;
}

function getDisplayDate2(DateObject,showDay) {
	var arrayMonths = new Array();
	arrayMonths[0]="January";
	arrayMonths[1]="February";
	arrayMonths[2]="March";
	arrayMonths[3]="April";
	arrayMonths[4]="May";
	arrayMonths[5]="June";
	arrayMonths[6]="July";
	arrayMonths[7]="August";
	arrayMonths[8]="September";
	arrayMonths[9]="October";
	arrayMonths[10]="November";
	arrayMonths[11]="December";
	
	var arrayWeekdays = new Array();
	arrayWeekdays[0]="Sunday";
	arrayWeekdays[1]="Monday";
	arrayWeekdays[2]="Tuesday";
	arrayWeekdays[3]="Wednesday";
	arrayWeekdays[4]="Thursday";
	arrayWeekdays[5]="Friday";
	arrayWeekdays[6]="Saturday";
	
	var strDate=""
	if(showDay) strDate+=arrayWeekdays[DateObject.getDay()]+", ";
	strDate+=arrayMonths[DateObject.getMonth()]+" ";
	strDate+=DateObject.getDate()+", ";
	strDate+=DateObject.getFullYear();
	return strDate;
}

function getDisplayTime2(DateObject,timezone) {
	var pmOffset=0;
	var timezoneOffset=0;
	switch(this.eventObj.displaytimezone){
		case "Eastern Daylight Time" : 
		case "Eastern Standard Time" :
			timezoneOffset=3;
			break;
		case "Mountain Daylight Time" : 
		case "Mountain Standard Time" :
			timezoneOffset=1;
			break;
		case "Central Daylight Time" : 
		case "Central Standard Time" : 
			timezoneOffset=2;
			break;
	}
	var utcOffset=8;
	if(this.eventObj.displaytimezone.toLowerCase().indexOf("daylight")!=-1)	utcOffset=7;
	var utcdate=new Date(DateObject.getUTCFullYear(),DateObject.getUTCMonth(),DateObject.getUTCDate(),DateObject.getUTCHours(),DateObject.getUTCMinutes(),DateObject.getUTCSeconds(),DateObject.getUTCMilliseconds());
	var newgoodafter=new Date(utcdate.getTime()+((timezoneOffset-utcOffset)*60*60*1000));
	var hours=newgoodafter.getHours();
	var minutes=newgoodafter.getMinutes();
	if(hours>12) {
		pmOffset=12;
	}
	var meridian=" a.m.";
	if(hours>11) {
		meridian=" p.m.";
	}
	var strTime="";
	strTime+=(hours-pmOffset)+":";
	if(minutes<10) strTime+="0";
	strTime+=minutes;
	strTime+=meridian;
	if(timezone) strTime+=" "+this.eventObj.displaytimezone;
	return strTime;
}

function handleEndLive() {
	this.callMediaMetricServlet();
	var option = this.onEndLive;
	if (!option) return;
	if (option=="close") {
		var redirectURL = "presentationover.html?"
						+ "eventid="+this.eventid
						+ "&sessionid="+this.sessionid
						+ "&key="+this.eventuserkey
						+ (this.paramObj.text_language_id?"&text_language_id="+this.paramObj.text_language_id:"")
						+ (this.paramObj.localeCountryCode?"&localeCountryCode="+this.paramObj.localeCountryCode:"");
		this.win.parent.location.href=redirectURL;
	} else if (option.indexOf("on24.com/utils/rollover.html?")!=-1) {
		this.win.parent.location.href=option
			+"&eventid="+this.eventid
			+"&sessionid="+this.sessionid
			+"&key="+this.paramObj.key
			+"&format="+this.paramObj.format
			+"&eventuserid="+this.eventuserid;
	} else if (option.indexOf("on24.com/utils/rollover.html")!=-1) {
		this.win.parent.location.href=option
			+"?eventid="+this.eventid
			+"&sessionid="+this.sessionid
			+"&key="+this.paramObj.key
			+"&format="+this.paramObj.format
			+"&eventuserid="+this.eventuserid;
	} else if (option.indexOf("http")!=-1) {
		if(option.indexOf("##")!=-1) option=this.replaceTokensFromURL(option,"##");
		if(option.indexOf("#")!=-1) option=this.replaceTokensFromURL(option,"#");
		this.win.parent.location.href=option;
	} else if (option=="refresh") {
		this.switchMedia(this.paramObj.format,true);
	}
}

//will log user's presence in the event console
function callMediaMetricServlet(useFrame){

	if (this.paramObj.mediametricid+""!="null"){	
		var reqURL="http://www.on24.com/utilApp/MediaMetricServlet"
		var reqParams="mode=log"
		+"&mediametricid="+this.paramObj.mediametricid
		+"&mediametricsessionid="+this.paramObj.mediametricsessionid
		+"&eventid="+this.eventid
		+"&key="+this.paramObj.key;
		//if (this.eventid=="524") alert(location.host +' '+eventHost);
		
		if(!this.submitXMLHTTPGet(reqURL,reqParams)){
			if(useFrame) {
				window.dummy1.location.href=reqURL+"?"+reqParams;
				//alert(window.dummy1.location.href)
			} else {
				//if instructed to use applet for communication, use an image for this function
				var reqImage = new Image(); //create request image object	
				reqImage.src = reqURL+"?"+reqParams; //make the request to log use
			}
		}
	}
}

//Function to find mediaurl object in mediaurl array
function findStreamOffsetObject(encodingformatcode,offsetcode) {
	if (!this.streamoffsetlog || this.streamoffsetlog.length<1) return null;
	var streamOffsetObject=null;
	for (var i in this.streamoffsetlog) {
		if ((encodingformatcode==false || this.streamoffsetlog[i].encodingformatcode==encodingformatcode) && (offsetcode==false || this.streamoffsetlog[i].offsetcode==offsetcode)) {
			streamOffsetObject=this.streamoffsetlog[i];
		}
	}
	return streamOffsetObject;
}

function checkStreamOffset() {
	if (!this.streamStartOffsetObject && this.bookmarkoffset==0) return false;
	var position = this.player.getPositionAbsolute();
	var offset = 0;
	if(this.streamStartOffsetObject) offset=this.streamStartOffsetObject.offset;
	if (this.player.getPlayerStatus()=="playing" && (offset+(this.bookmarkoffset*1)) > position) {
		this.player.setPositionAbsolute((offset+(this.bookmarkoffset*1))/1000);
		this.bookmarkoffset=0;
	}
	return false;
}

function stopMediaMetric() {
	if (this.win.parent.mm1) {
		if (this.win.parent.mm1.mediametricid) this.win.parent.mm1.mediametricid="";
		if (this.win.parent.mm1.mediametricsessionid) this.win.parent.mm1.mediametricsessionid="";
	}
}
//returns the string after escaping the special ascii chars (i.e. &!@#$%^&)
function escapeASCIIOnly(str){
	var transform =  [
        "&euro;",   
        "",           
        "&#8218;", 
        "&#402;",
        "&#8222;",
        "&#8230;",
        "&#8224;",
        "&#8225;",
        "&#710;",
        "&#8240;",
        "&#352;",
        "&#8249;",
        "&#338;",
        "",
        "&#381;",
        "",
        "",
        "&#8216;",
        "&#8217;",
        "&#8220;",
        "&#8221;",
        "&#8226;",
        "&#8211;",
        "&#8212;",
        "&#732;",
        "&#8482;",
        "&#353;",
        "&#8250;",
        "&#339;",
        "",
        "&#382;",
        "&#376;",  // 159
        "&nbsp;",    // 160
        "&iexcl;",
        "&cent;",
        "&pound;",
        "&curren;",
        "&yen;",
        "&brvbar;",
        "&sect;",
        "&uml;",
        "&copy;",
        "&ordf;",
        "&laquo;",
        "&not;",
        "&shy;",
        "&reg;",
        "&macr;",
        "&deg;",
        "&plusmn;",
        "&sup2;",
        "&sup3;",
        "&acute;",
        "&micro;",
        "&para;",
        "&middot;",
        "&cedil;",
        "&sup1;",
        "&ordm;",
        "&raquo;",
        "&frac14;",
        "&frac12;",
        "&frac34;",
        "&iquest;",
        "&Agrave;",
        "&Aacute;",
        "&Acirc;",
        "&Atilde;",
        "&Auml;",
        "&Aring;",
        "&AElig;",
        "&Ccedil;",
        "&Egrave;",
        "&Eacute;",
        "&Ecirc;",
        "&Euml;",
        "&Igrave;",
        "&Iacute;",
        "&Icirc;",
        "&Iuml;",
        "&ETH;",
        "&Ntilde;",
        "&Ograve;",
        "&Oacute;",
        "&Ocirc;",
        "&Otilde;",
        "&Ouml;",
        "&times;",
        "&Oslash;",
        "&Ugrave;",
        "&Uacute;",
        "&Ucirc;",
        "&Uuml;",
        "&Yacute;",
        "&THORN;",
        "&szlig;",
        "&agrave;",
        "&aacute;",
        "&acirc;",
        "&atilde;",
        "&auml;",
        "&aring;",
        "&aelig;",
        "&ccedil;",
        "&egrave;",
        "&eacute;",
        "&ecirc;",
        "&euml;",
        "&igrave;",
        "&iacute;",
        "&icirc;",
        "&iuml;",
        "&eth;",
        "&ntilde;",
        "&ograve;",
        "&oacute;",
        "&ocirc;",
        "&otilde;",
        "&ouml;",
        "&divide;",
        "&oslash;",
        "&ugrave;",
        "&uacute;",
        "&ucirc;",
        "&uuml;",
        "&yacute;",
        "&thorn;",
        "&yuml;"    // 255
    ];
	var x;
	var uni = "";
	for( var i=0;i<str.length;i++){
		x = str.charCodeAt(i);
		if(x <= 255){ //ascii??
			if(x >=48 && x <=57){ 
				uni = uni + str.charAt(i);
			} else if(x >=65 && x <=90){ 
				uni = uni + str.charAt(i);
			} else if(x >=97 && x <=122){
				uni = uni + str.charAt(i);
			} else if(x ==13 || x==10){
				uni = uni + str.charAt(i);
			} else if(x >=128){
				uni = uni + escape(transform[x-128]);
			} else {
				uni = uni + "%" + x.toString(16);
			}
		} else {
			//uni = uni + "%u" + x.toString(16);
			uni = uni + str.charAt(i);
		}
	}
	return uni;
}

//functions added for simulive events

function getTimeToStart(){
	var launchTime=servertime.getTime();
	var startTime=this.eventObj.goodafter.getTime();
	if(this.sessionid>1) startTime=this.sessionObj.startdate.getTime();
	return (startTime-launchTime);
}

function getTimeElasped(){
	var curTime=new Date().getTime()+this.clientTimeOffset;
	var startTime=this.eventObj.goodafter.getTime();
	if(this.sessionid>1) startTime=this.sessionObj.startdate.getTime();
	return (curTime - startTime);
}

function getPresentationLength(){
	/*if(this.player){
		if(this.player.getTotalEntries()==1 && this.ondemandPresentationLength>0) return this.ondemandPresentationLength*1000;
	}*/
	var startTime=this.eventObj.goodafter.getTime();
	if(this.sessionid>1) startTime=this.sessionObj.startdate.getTime();
	var endTime=this.sessionObj.enddate.getTime();
	return (endTime-startTime);
}

function simuLivePlay(){
	if(this.player.getPlayerStatus()!="stopped" && this.player.getPlayerStatus()!="paused") return false;	
	this.player.setVolume(0);
	if(this.getTimeElasped()>=this.getPresentationLength()){
		var alertMsg="This presentation is over.";
		if(this.eventObj.message.presentationover && this.eventObj.message.presentationover!=null && this.eventObj.message.presentationover!="") alertMsg=this.eventObj.message.presentationover;
		//alert(alertMsg);
		var redirectURL = "presentationover.html?"
						+ "eventid="+this.eventid
						+ "&sessionid="+this.sessionid
						+ "&key="+this.eventuserkey
						+ (this.paramObj.text_language_id?"&text_language_id="+this.paramObj.text_language_id:"")
						+ (this.paramObj.localeCountryCode?"&localeCountryCode="+this.paramObj.localeCountryCode:"");
		window.location.href=redirectURL;
		return false;
	}
	var pos=Math.floor(this.getTimeElasped()/1000);
	if(this.getTimeElasped()>0) {
		if(this.player.canPlay()) this.player.play();
		if(this.player.getCurrentEntry()==1) this.player.gotoPrevEntry();
		if(pos>=this.ondemandPresentationLength) {
			this.setPlayerPosition(this.ondemandPresentationLength);
			if(this.paramObj.format.indexOf("wm")!=-1) this.player.play();
			this.interval=200;
			this.startLiveStreaming();
			return false;
		}
		this.setPlayerPosition(pos); 
		this.startOnDemand();
		if(this.paramObj.format.indexOf("wm")!=-1) this.player.play();
	} else {
		this.playMusic();
		this.player.setVolume(this.curVolume);
	}
}

function playMusic(){
        if(this.player.canPlay()==false) this.player.stop();
		var playerURL="";
        if(this.paramObj.format.indexOf("rm")!=-1){
			 //if(window.usecdn)  playerURL="rtsp://cdo.earthcache.net/ssvc005194-grma.media.globix.net/media/news/corporatevideo/music/music.rm";
			 //else playerURL="rtsp://rm.on24.com/media/news/corporatevideo/music/music.rm";
			 playerURL="http://event.on24.com/eventRegistration/media/meta.jsp?eventid=700&sessionid=1&format=rmmulti&period=A";
		} else{
			//if(window.usecdn)  playerURL="mms://cdo.earthcache.net/ssvc005191.media.globix.net/media/news/corporatevideo/music/music.asf";
			//else playerURL="mms://wm.on24.com/media/news/corporatevideo/music/music.asf";
			playerURL="http://event.on24.com/eventRegistration/media/meta.jsp?eventid=700&sessionid=1&format=wmmulti&period=A";
		}
		this.player.setSource(playerURL)
        this.player.play();
}

function setTimer(timeToStart,playerURL){
	window.main.setTimeout(this.name+".playPresentation('"+playerURL+"');",timeToStart);
}
function playPresentation(playerURL){
        if(this.player.canPlay()==false) this.player.stop();
        this.player.setSource(playerURL);
        this.player.play();
		this.startOnDemand();
}

function raiseVolume(){
	if(this.curVolume<100){
		this.curVolume+=10;
		this.player.setVolume(this.curVolume)
	}
}

function dropVolume(){
	if(this.curVolume>0){
		this.curVolume-=10;
		this.player.setVolume(this.curVolume)
	}
}

function setmute(){
	var imgMute=this.getElementFromDoc("window.main","document","mute");
	if(imgMute==null) return false;
	if(this.mutestatus==true){
	this.mutestatus=false;
	this.player.setMute(false)
	imgMute.src="muteoff.gif";
	}
	else {
	this.mutestatus=true
	this.player.setMute(true)
	imgMute.src="muteon.gif";
	}
}

function getElementFromDoc(refFrame, container,eName){
	var returnElemment=null;
	var refFrameLayers=eval(refFrame+".document.layers");
	if(eval(refFrame)+""=="undefined") return null;
	if(eval(refFrame+"."+container)+""!="undefined"){
		if(eval(refFrame+"."+container+"."+eName)+""!="undefined") returnElemment=eval(refFrame+"."+container+"."+eName)
	} else if(refFrameLayers){
		//alert(document.layers.length)
		for(var i=0;i<refFrameLayers.length;++i){
			if(eval("refFrameLayers[i]."+container)+""!="undefined" && eval("refFrameLayers[i]."+container+"."+eName)+""!="undefined"){
				returnElemment=eval("refFrameLayers[i]."+container+"."+eName);
				break;
				//alert(returnElemment)
			}
		}
	}
	return returnElemment;
}

function formatseconds(param){
	if(param<=0) return "00:00:00";
	var hours=Math.floor(param/3600);
	var mins=Math.floor((param%3600)/60);
	var secs=param-((hours*3600)+(mins*60))
	if(hours<10) hours='0'+hours;
	if(mins<10) mins='0'+mins;
	if(secs<10) secs='0'+secs;
	return hours+":"+mins+":"+secs
}

function getObjByName(objDocument,name)
{
  if (objDocument.getElementById)
  {
  	return objDocument.getElementById(name);
  }
  else if (objDocument.all)
  {
	return objDocument.all[name];
  }
  else if (objDocument.layers)
  {
	return this.getObjNN4(objDocument,name);
  }
}

function getObjNN4(obj,name)
{
	var x = obj.layers;
	var foundLayer;
	for (var i=0;i<x.length;i++)
	{
		if (x[i].id == name)
		 	foundLayer = x[i];
		else if (x[i].layers.length)
			var tmp = this.getObjNN4(x[i],name);
		if (tmp) foundLayer = tmp;
	}
	return foundLayer;
}

function setSimuLivePlayerPosition(pos){
	if(this.player.getPlayerStatus()=="status") window.main.setTimeout(this.name+".setSimuLivePlayerPosition("+pos+")",1000);
	else {
		//alert(pos)
		//alert(this.ondemandPresentationLength)
		if(pos>=this.ondemandPresentationLength) {
			this.setPlayerPosition(this.ondemandPresentationLength);
			//show last pushed element when the console is launched after the OD period
			this.showLastPushedElements();
			this.interval=200;
			this.startLiveStreaming();
			return false;
		}
		this.setPlayerPosition(pos); 
		this.startOnDemand();
	}
}
// Bring lobby(parent window) page in focus. Opens a new window if that is closed.
function showLobby(){
	var url="lobby.html?e="+this.eventid+"&s="+this.sessionid+"&k="+this.paramObj.key;
	if(this.eventObj.lobbyurl!="") {
		url=this.eventObj.lobbyurl;
		url=url.replace(/&onload=launchandclose/g,"");
		url=url.replace(/onload=launchandclose&/g,"");
		url=url.replace(/&onload=launchwebcast/g,"");
		url=url.replace(/onload=launchwebcast&/g,"");
		url+=(url.indexOf("?")!=-1?"&":"?")+"eventid="+this.eventid+"&sessionid="+this.sessionid+"&key="+this.paramObj.key+"&eventuserid="+this.eventuserid;
	}
	if(this.paramObj.overwritelobby && this.paramObj.overwritelobby=="y") {
		window.location.href=url;
		return false;
	}
	if(window.opener){
		if(window.opener.closed){
			window.open(url);
		} else {
			window.opener.location.href=url;
			window.opener.focus();
		}
	} else {
		window.open(url);
	}
}


//Function to send chat messge
function sendChatMessage(){
	var chatMsgElement=this.getElementFromDoc("window.main","document.chat","message");
	var chatRecipientElement=this.getElementFromDoc("window.main","document.chat","users");
	if(chatMsgElement==null || chatRecipientElement==null) return false;
	var question = chatMsgElement.value;
	var recipient=chatRecipientElement.options[chatRecipientElement.options.selectedIndex].value;
	if(this.paramObj.initiatorid=="") {
		alert("You have not yet registered for this event. Please register before submitting a question.");
		return false;
	}

	if (question=="") {
		alert('Please type a message to submit.');
		return;
	} else if (question.length>600) {
		alert('Your message is too long. Please limit it to 600 characters.');
		return;
	}
	question=escapeASCIIOnly(question);
	var now = new Date();
	var ms = now.getTime();
	
	var imgsrc = "http://www.on24.com/eventManager/chat/ChatService.jsp";
		imgsrc += "?eventid="+this.eventid
		imgsrc += "&sessionid="+this.sessionid;
		imgsrc += "&key="+this.eventuserkey;
		imgsrc += "&initiatorid="+this.eventuserid
		imgsrc += "&initiatortype=U"
		imgsrc += "&recipientid="+(recipient.length>1?recipient.substring(1):recipient);
		imgsrc += (recipient.length>1?("&recipienttype="+recipient.substring(0,1)):'');
		imgsrc += "&mode=push";
		imgsrc += "&message="+question;
		imgsrc += "&"+ms;
		
	var tempimg1=null;
	tempimg1=new Image();
	tempimg1.src=imgsrc;
	chatMsgElement.value="";
	return false;
}

function startChat(param, chatWidth, chatHeight){
	var useapplet="y";
	if (this.paramObj.useapplet && this.paramObj.useapplet=="n") useapplet="n";
	if(this.doc.layers) {
		getObjByName(this.doc,"chat_frame").src="http://www.on24.com/eventManager/chat/ChatService.jsp?mode="+(param=="all"?"getall":"get")+"&eventid="+this.eventid+"&sessionid="+this.sessionid+"&key="+this.eventuserkey+"&initiatorid="+this.eventuserid+"&initiatortype=U&target=refreshChatNS.jsp&users=P&ms="+(new Date().getTime());;
		window.main.clearTimeout(this.chattoid);
		this.chattoid=window.main.setTimeout(this.name+".startChat('get')",5000);
	} else {
		if(bIE)	this.doc.chat_frame.location.href="refreshChatIE.html?mode="+(param=="all"?"getall":"get")+"&eventid="+this.eventid+"&sessionid="+this.sessionid+"&key="+this.eventuserkey+"&initiatorid="+this.eventuserid+"&initiatortype=U&users=P&width="+chatWidth+"&height="+chatHeight+"&useapplet="+useapplet+"&ms="+(new Date().getTime());
		else getObjByName(this.doc,"chat_frame").src="refreshChatIE.html?mode="+(param=="all"?"getall":"get")+"&eventid="+this.eventid+"&sessionid="+this.sessionid+"&key="+this.eventuserkey+"&initiatorid="+this.eventuserid+"&initiatortype=U&users=P&width="+chatWidth+"&height="+chatHeight+"&useapplet="+useapplet+"&ms="+(new Date().getTime());
	} 
}

function addChatUser(id,name,type){
	var chatRecipientElement=this.getElementFromDoc("window.main","document.chat","users");
	var chatMsgElement=this.getElementFromDoc("window.main","document.chat","message");
	if(chatRecipientElement==null) return false;
	if(chatMsgElement.value!="" && chatRecipientElement.selectedIndex>1) return false;
	if(this.userRefreshed==false) chatRecipientElement.length=1;
	if(type=="P") chatRecipientElement.options[chatRecipientElement.options.length]=new Option(name,"P"+id);
	else chatRecipientElement.options[chatRecipientElement.options.length]=new Option(name,"U"+id);
	this.userRefreshed=true;
}

function addChatMessage(id,name,msg){
	var chatLogElement=this.getElementFromDoc("window.main","document.chat","messagelog");
	if(chatLogElement==null) return false;
	msg=msg.replace(/\&lt;/g,"<");
	msg=msg.replace(/\&gt;/g,">");
	chatLogElement.value+=(id==0?"-  ":id+". ")+name+"-> "+msg+"\n";
	if(bIE) chatLogElement.scrollTop=chatLogElement.scrollHeight;
	else if(bNN) chatLogElement.select();
}

function writeChatBlock(chatWidth, chatHeight){
	//alert(chatWidth)
	var strChat="";
	var frameWidth=chatWidth;
	var frameHeight=chatHeight;
	var chatHeight=chatHeight/3;
	var pcolumns=Math.floor((chatWidth-20)/5);
	var prows=Math.floor((chatHeight-5)/14);
	var padding="";
	for(var i=0;i<((chatWidth-38)/3);++i) padding+="&nbsp;";
	if(bNN && this.doc.layers){ //NS4.7x
		padding="";
		var pcolumns=Math.floor((chatWidth-25)/8);
		var prows=Math.floor((chatHeight-30)/14);
		for(var i=0;i<((chatWidth-45)/3);++i) padding+="&nbsp;";
	} else if(bNN){ //NN7 & Mozilla
		var pcolumns=Math.floor((chatWidth-45)/5);
		var prows=Math.floor((chatHeight-20)/13);
	}
	if(this.doc.layers) {
		strChat="<form id='formChat' name=chat><table border=0 cellspacing=1><tr><td class=chatText><textarea id='textareaMessageLog' name=messagelog cols='"+pcolumns+"' rows='"+prows+"' onfocus='blur();'></textarea></td></tr><tr><td class=chatText><textarea class=chatText name=message cols='"+pcolumns+"' rows='"+prows+"'  onkeypress='if(event.which==13) {window.parent.main.ep1.sendChatMessage();return false;}'></textarea></td></tr>";
		strChat+="<tr><td class=chatText><select class=chatText name=users size='"+(prows-(-1))+"'><option value='P0' selected>All"+padding+"</select></td></tr></table></form>"
		strChat+='<layer name="chat_frame" id="chat_frame" width=1 height=1></layer>';
	} else strChat='<iframe id="chat_frame" name="chat_frame" width='+frameWidth+' height='+frameHeight+' frameborder=0 scrolling=no marginheight=0 marginwidth=0 ></iframe>';
	//alert(strChat)
	return strChat;
}

function writeAgenda(width,height){
	var strAgenda="";
	if(document.layers) strAgenda='<layer name="agenda_frame" id="agenda_frame" clip="0,0,'+(width-15)+','+height+'" width='+(width-15)+' height='+height+' src="blank.html"></layer>'
	else strAgenda='<iframe scrolling=auto  id="agenda_frame" name="agenda_frame" width='+width+' height='+height+' frameborder=0 marginheight=0 marginwidth=0 src="'+this.agendaPageHtml+'"></iframe>'
	return strAgenda;
}

function getAgendaScrollButton(width,height){
	if(document.layers) return '<table border=0 cellpadding=0 cellspacing=0 width='+width+' height='+height+' background="scroll_bg.gif"><tr><td align="right" valign="top"><a href="#" onclick="scrollayer(\'agenda_frame\',-15);return false;" id="arrow_up"><img src="scrollup.gif" border=0></a></td></tr><tr><td align="right" valign="bottom"><a href="#" onclick="scrollayer(\'agenda_frame\',15);return false;" id="arrow_down"><img src="scrolldown.gif" border=0></a></td></tr></table>';
	else return '';
}

function loadAgendaPage(){
	if(document.layers) {
		var objAgendaFrame = this.getObjByName(this.doc,"agenda_frame");
		if (objAgendaFrame==null) return;
		//for (var i in objAgendaFrame) alert(i+" : "+objAgendaFrame[i]);
		objAgendaFrame.src=this.agendaPageHtml;
	}
}

function launchEmailtoFriend(){
	var URL="http://www.on24.com/eventManager/presentation/emailafriend.jsp?eventid="+this.eventid+"&sessionid="+this.sessionid+"&key="+this.eventuserkey+"&eventuserid="+this.eventuserid;
	window.open(URL,"emailafriendpopup","width=420,height=390,scrollbars=0,resizable=1");
	this.logEvent("Email a Friend","Email a Friend button is clicked from console.");
}

function logEvent(requestdetails,requestnotes){
	var tmpImg=new Image();
	var logURL="http://www.on24.com/eventManager/EventLogServlet"
	+"?eventid="+this.eventid
	+"&sessionid="+this.sessionid
	+"&userid="+this.eventuserid
	+"&usertypecode=eventuser"
	+"&mode=insert"
	+"&actiontypecode=insert"
	+"&actioncategorycode=usagelog"
	+"&requestdetails="+requestdetails
	+"&requestnotes="+requestnotes
	tmpImg.src=logURL;
}

function getBrowserInfo() {
	
	var objBrowserInfo = new Object();
	
        // convert all characters to lowercase to simplify testing
    var agt=navigator.userAgent.toLowerCase();
    var appVer = navigator.appVersion.toLowerCase();

    // *** BROWSER VERSION ***

    var is_minor = parseFloat(appVer);
    var is_major = parseInt(is_minor);

    // Note: On IE, start of appVersion return 3 or 4
    // which supposedly is the version of Netscape it is compatible with.
    // So we look for the real version further on in the string

    var iePos  = appVer.indexOf('msie');
    if (iePos !=-1) {
       is_minor = parseFloat(appVer.substring(iePos+5,appVer.indexOf(';',iePos)))
       is_major = parseInt(is_minor);
    }

    var is_nav  = ((agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1)
                && (agt.indexOf('compatible') == -1) && (agt.indexOf('opera')==-1)
                && (agt.indexOf('webtv')==-1) && (agt.indexOf('hotjava')==-1));

    // Netscape6 is mozilla/5 + Netscape6/6.0!!!
    // Mozilla/5.0 (Windows; U; Win98; en-US; m18) Gecko/20001108 Netscape6/6.0
    // Changed this to use navigator.vendor/vendorSub - dmr 060502   
    // var nav6Pos = agt.indexOf('netscape6');
    // if (nav6Pos !=-1) {
    if ((navigator.vendor)&&
        ((navigator.vendor=="Netscape6")||(navigator.vendor=="Netscape"))&&
        (is_nav)) {
       is_major = parseInt(navigator.vendorSub);
       // here we need is_minor as a valid float for testing. We'll
       // revert to the actual content before printing the result. 
       is_minor = parseFloat(navigator.vendorSub);
    }

    var is_nav2 = (is_nav && (is_major == 2));
    var is_nav3 = (is_nav && (is_major == 3));
    var is_nav4 = (is_nav && (is_major == 4));
    var is_nav4up = (is_nav && is_minor >= 4);  // changed to is_minor for
                                                // consistency - dmr, 011001
    var is_navonly      = (is_nav && ((agt.indexOf(";nav") != -1) ||
                          (agt.indexOf("; nav") != -1)) );

    var is_nav6   = (is_nav && is_major==6);    // new 010118 mhp
    var is_nav6up = (is_nav && is_minor >= 6) // new 010118 mhp

    var is_nav5   = (is_nav && is_major == 5 && !is_nav6); // checked for ns6
    var is_nav5up = (is_nav && is_minor >= 5);
	
    var is_nav7   = (is_nav && is_major == 7);
    var is_nav7up = (is_nav && is_minor >= 7);
    var is_nav71up = (is_nav && is_minor >= 7.1);
    var is_nav47 = (is_nav && (agt.indexOf('4.7')!=-1));

    var is_ie     = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));
    var is_ie3    = (is_ie && (is_major < 4));
    var is_ie4    = (is_ie && (is_major == 4) && (agt.indexOf("msie 4")!=-1) );
    var is_ie4up  = (is_ie && (is_major >= 4));
    var is_ie5    = (is_ie && (is_major == 4) && (agt.indexOf("msie 5.0")!=-1) );
    var is_ie5_5  = (is_ie && (is_major == 4) && (agt.indexOf("msie 5.5") !=-1));
    var is_ie5up  = (is_ie && !is_ie3 && !is_ie4);
    var is_ie5_5up =(is_ie && !is_ie3 && !is_ie4 && !is_ie5);
    var is_ie6    = (is_ie && (is_major == 4) && (agt.indexOf("msie 6.")!=-1) );
    var is_ie6up  = (is_ie && !is_ie3 && !is_ie4 && !is_ie5 && !is_ie5_5);
	var is_firefox=(agt.indexOf("firefox") > -1);
	
	objBrowserInfo.is_nav6up = is_nav6up;
	objBrowserInfo.is_ie6up = is_ie6up;
	
	objBrowserInfo.agt = agt;
    objBrowserInfo.appVer = appVer;
	
    objBrowserInfo.is_minor = is_minor;
    objBrowserInfo.is_major = is_major;
	
	objBrowserInfo.is_firefox=is_firefox;

	return objBrowserInfo;
}

function changeChapterDropdown(chaptername){
	var chapterElement=this.getElementFromDoc("window.main","document.frmChapters","selchapter");
	if(chapterElement==null) return false;
	chaptername=chaptername.substr(0,this.chapterTextLength);
	if(this.paramObj.chaptertimes && this.paramObj.chaptertimes=="y") chaptername+=" (";
	chaptername=chaptername.replace(/\s+/g," ");
	for(var i=0;i<chapterElement.options.length;i++){
		//alert(chapterElement.options[i].text)
		var chapternamefromdropdown = chapterElement.options[i].text;
		chapternamefromdropdown=chapternamefromdropdown.replace(/\s+/g," ");
		if(this.paramObj.chaptertimes && this.paramObj.chaptertimes=="y"){
			if(chapternamefromdropdown.indexOf(chaptername)==0){
				chapterElement.options[i].selected=true;
				return true;
			}
		} else {
			if(chapternamefromdropdown==chaptername){
				chapterElement.options[i].selected=true;
				return true;
			}
		}
	}
}

function startRewindForward(dir,ms){
	if(this.paramObj.contenttype && this.paramObj.contenttype=="L") return false;
	if(!ms) ms=100;
	window.main.clearTimeout(this.frtoid);
	this.frtoid = window.main.setTimeout(this.name+".startRewindForward('"+dir+"',"+ms+")",ms);
	if(this.player){
		this.player.pause();
		var position = this.player.getPosition()/1000;
		if(position<0) return false;
		if(dir=="rewind") {
			if(position<5) position=0;
			else position-=5;
		} else {
			position+=5;
		}
		//alert(position)
		this.player.setPosition(position, this.player.getCurrentEntry(), dir);
	}
}

function stopRewindForward(){
	if(this.paramObj.contenttype && this.paramObj.contenttype=="L") return false;
	window.main.clearTimeout(this.frtoid);
	this.player.play();
}

function writeTranscriptBlock(width,height){
	return '<form id="formTranscript" name=transcriptForm onsubmit="return false;"><input name=searchText type=text>&nbsp;&nbsp;<a href=# onclick="window.parent.main.ep1.startSearch();return false;"><img src="clear.gif" border=0 width=47 height=17 class=searchsubmit></a>&nbsp;&nbsp;<a href=# onclick="window.parent.main.ep1.clearSearch();return false;"><img src="clear.gif" border=0 width=47 height=17 class=searchclear></a><br><img src=clear.gif border=0 width=1 height=5><br><iframe name=transcript_frame id=transcript_frame width='+width+' height='+(height-30)+' scrollbars=yes frameborder=1 marginheight="5" marginwidth="5"></iframe></form>';
}

function processTranscript(position){
//handle transcripts
	if(typeof window.main.transcriptArray+""!="undefined"){
		var searchTextElement=this.getElementFromDoc("window.main","document.transcriptForm","searchText");
		if(searchTextElement!=null){
			if(searchTextElement.value!="") this.transcriptEnabled=false;
			else this.transcriptEnabled=true;
		}
		if(this.transcriptEnabled){
			for (var i=0;i<window.main.transcriptArray.length;i++) {
				if (position < window.main.transcriptArray[i].offset) {
					if (i>0 && i!=(this.currentTranscriptLine-(-1))) {
						//alert(i!=this.currentTranscriptLine)
						this.currentTranscriptLine=i-1;
						var strTranscriptFrameSRC="transcript.html?lineno="+this.currentTranscriptLine+"#line"+this.currentTranscriptLine;
						if (bIE) {
							if(this.doc.transcript_frame) this.doc.transcript_frame.location.href=strTranscriptFrameSRC;
						} else {
							//alert(getObjByName(this.doc,"transcript_frame"))
							if(getObjByName(this.doc,"transcript_frame")) getObjByName(this.doc,"transcript_frame").src=strTranscriptFrameSRC;
						}
					} else if(i==0 && this.transcriptLoaded==false){
						this.transcriptLoaded=true;
						var strTranscriptFrameSRC="transcript.html";
						if (bIE) {
							if(this.doc.transcript_frame) this.doc.transcript_frame.location.href=strTranscriptFrameSRC;
						} else {
							//alert(getObjByName(this.doc,"transcript_frame"))
							if(getObjByName(this.doc,"transcript_frame")) getObjByName(this.doc,"transcript_frame").src=strTranscriptFrameSRC;
						}
					}
					break;
				}
			}
		}
	}
}

function startSearch(){
	if(typeof window.main.transcriptArray+""!="undefined"){
		var searchTextElement=this.getElementFromDoc("window.main","document.transcriptForm","searchText");
		if(searchTextElement==null) return false;
		if(searchTextElement.value=="") return false;
		
		var strTranscriptFrameSRC="transcript.html?mode=search&s=" +escape(searchTextElement.value)+"#match1"
		if (bIE) {
			if(this.doc.transcript_frame) this.doc.transcript_frame.location.href=strTranscriptFrameSRC;
		} else {
			if(getObjByName(this.doc,"transcript_frame")) getObjByName(this.doc,"transcript_frame").src=strTranscriptFrameSRC;
		}
	}
}

function clearSearch(){
	var searchTextElement=this.getElementFromDoc("window.main","document.transcriptForm","searchText");
	if(searchTextElement==null) return false;
	searchTextElement.value="";
}

function getBookMark(){
	if(this.hasBookMark){
		//this.player.stop();
		var bookMarkCookie=getCookieValue("bm_"+this.eventid+"_"+this.sessionid);
		//alert(bookMarkCookie)
		if(bookMarkCookie>0) {
			var confirmMsg="Would you like to resume this webcast from where you last left off?\n\n-Click OK to resume webcast.\n-Click Cancel to start from beginning of webcast.\n\n";
			if(eventObj.message.resumefrombookmark && eventObj.message.resumefrombookmark!=null && eventObj.message.resumefrombookmark!="") confirmMsg=eventObj.message.resumefrombookmark;
			if(confirm(confirmMsg)) this.bookmarkoffset=bookMarkCookie*1000;
			else deleteEscapedCookie("bm_"+this.eventid+"_"+this.sessionid);
		}
	}
}

function addBookMark(){
	if(location.href.indexOf("http")!=0) return false;
	var position = Math.round(this.player.getPosition()/1000);
	if(position<=0) {
		var alertMsg="Bookmarking is not allowed at this point.";
		if(this.eventObj.message.bookmarknotallowed && this.eventObj.message.bookmarknotallowed!=null && this.eventObj.message.bookmarknotallowed!="") alertMsg=this.eventObj.message.bookmarknotallowed;
		alert(alertMsg);
	} else {
		var now = new Date();
		setEscapedCookie("bm_"+this.eventid+"_"+this.sessionid,position,new Date((now.getFullYear() + 1), now.getMonth(), now.getDate()),"/",wwwHost.substring(wwwHost.indexOf(".")));
		var alertMsg1="Webcast is bookmarked at ";
		var alertMsg2="Click OK to continue. ";
		if(this.eventObj.message.webcastbookmarked && this.eventObj.message.webcastbookmarked!=null && this.eventObj.message.webcastbookmarked!="") alertMsg1=this.eventObj.message.webcastbookmarked;
		if(this.eventObj.message.clickoktocontinue && this.eventObj.message.clickoktocontinue!=null && this.eventObj.message.clickoktocontinue!="") alertMsg2=this.eventObj.message.clickoktocontinue;
		alert(alertMsg1+this.formatseconds(position)+"."+alertMsg2);
		//if(confirm("Webcast is bookmarked at "+this.formatseconds(position)+".\n\n-Click OK to close the webcast.\n-Click Cancel to continue.\n\n")) window.close();
	}
}

function getOndemandPresentationLength(){
	// gets the endlive offset for ondemand presentation
	for (var i in this.offsetlog) {
		if(this.offsetlog[i].presentationcode=="endlive") {
			this.ondemandPresentationLength=Math.round(this.offsetlog[i].ondemandoffset/1000);
			return;
		}
	}
	this.ondemandPresentationLength=24*60*60;
}

//Function to determine last media url object based on code and categorycode
function getLastPushedMediaURLObject(code,categorycode) {
	var mArray=this.mediaurl;
	for (var i in this.revtimestamplog) {
		for (var j in mArray) {
			if (mArray[j].active && (!code || mArray[j].code==code) && (!categorycode || mArray[j].categorycode.indexOf(categorycode)!=-1) && mArray[j].id==this.revtimestamplog[i].id) {
				return mArray[j];
			}
		}
	}
	return null;
}

//Function to determine last non popup media url based on code and categorycode
function getLastPushedSlideAreaObjectForLive() {
	var objMediaUrl=null;
	for (var i in this.revtimestamplog) {
		objTimestamp = this.revtimestamplog[i];
		if(objTimestamp.id==4){//pcview was pushed. check a dummy URL for the new users
			var mu=new Object();
			mu.code="www"
			mu.url="launchpcview.html";
			mu.id=4;
			mu.popup=false;
			mu.idth=-2;
			mu.height=-2;
			return mu;
		}
		objMediaUrl = this.getMediaURLObject(objTimestamp.id);
		if(objMediaUrl==null) continue;
		if (objMediaUrl.code=="slide") return objMediaUrl;
		if (objMediaUrl.code=="www" && objMediaUrl.popup==false) return objMediaUrl;
		if (objMediaUrl.code=="poll" && objMediaUrl.popup==false) return objMediaUrl;
		if (objMediaUrl.code=="userquestion" && objMediaUrl.popup==false) return objMediaUrl;
	}
	return null;
}

//called once by streaming and non-streaming presentation, upon onload
function showLastPushedElements(){
	var slide1 = this.getLastPushedSlide();
	if(slide1==null) slide1=this.getFirstMediaURL("slide","slide");
	if(slide1==null) slide1=this.getFirstMediaURL("slide","portrait");
	if (slide1) {
		this.slideurl=slide1;
		this.showSlide();
	}
	
	var lastSlideAreaElement=this.getLastPushedSlideAreaObjectForLive(); //last pushed non popup element
	if(lastSlideAreaElement!=null){
		//alert("slide area: "+lastSlideAreaElement.code);
		if(lastSlideAreaElement.code=='slide'){
			if(lastSlideAreaElement.url!=slide1) {
				this.slideurl=lastSlideAreaElement.url;
				this.showSlide();
			}
		} else if(lastSlideAreaElement.code=='poll'){
			this.pollurl=lastSlideAreaElement.url;
			this.pollpopup=lastSlideAreaElement.popup;
			this.showPoll();
		} else if(lastSlideAreaElement.code=='www'){
			this.wwwurl=lastSlideAreaElement.url;
			this.wwwid=lastSlideAreaElement.id;
			this.wwwpopup=lastSlideAreaElement.popup;
			this.wwwwidth=lastSlideAreaElement.width;
			this.wwwheight=lastSlideAreaElement.height;
			this.showURL(true);
		} else if(lastSlideAreaElement.code=='userquestion'){
			this.questionurl=lastSlideAreaElement.url;
			this.questionpopup=lastSlideAreaElement.popup;
			this.questionwidth=lastSlideAreaElement.width;
			this.questionheight=lastSlideAreaElement.height;
			this.showQuestion();
		}
	}
	
	// show last pushed popup elements
	var lastElement=this.getLastPushedMediaURLObject(); //last pushed element, can be popup or non-popup
	if(lastElement!=null){
		if(lastElement.popup==false) return;
		//alert("popup: "+lastElement.code)
		if(lastElement.code=='poll'){
			this.pollpopup=lastElement.popup;
			this.pollurl=lastElement.url;
			this.showPoll();
		} else if(lastElement.code=='www'){
			this.wwwurl=lastElement.url;
			this.wwwid=lastElement.id;
			this.wwwpopup=lastElement.popup;
			this.wwwwidth=lastElement.width;
			this.wwwheight=lastElement.height;
			this.showURL();
		} else if(lastElement.code=='userquestion'){
			this.questionurl=lastElement.url;
			this.questionpopup=lastElement.popup;
			this.questionwidth=lastElement.width;
			this.questionheight=lastElement.height;
			this.showQuestion();
		}
	}
	
}

function setPlayerPosition(param){
	//alert(param)
	if (this.player) {
		if(this.player.getPlayerStatus()=="status") window.main.setTimeout(this.name+".setPlayerPosition("+param+")",1000);
		else {
			//if(this.player.canPlay()) {
				if(this.playedForChapterChange==false) this.player.play();
				this.playedForChapterChange=true;
				if((this.paramObj.format.indexOf("wm")!=-1 && this.player.getPlayerStatus()!="playing" && this.player.getPlayerStatus()!="buffering") || (this.paramObj.format.indexOf("rm")!=-1 && this.player.getPlayState()!=3 && this.player.getPlayState()!=2)) {
					window.main.setTimeout(this.name+".setPlayerPosition("+param+")",1000);
					return;
				}
			//}
			if(this.paramObj.contenttype && this.paramObj.contenttype=="L" && this.paramObj.simulive && this.paramObj.simulive=="y"){
				var mediaStreamLength=(this.player.getLength()/1000)-0.001;
				if(param>mediaStreamLength) param=mediaStreamLength;
			}
			if ((this.paramObj.format.indexOf("wm")!=-1) && (param!=0)){
				this.player.setPosition((param*1)+.001);
			} else {
				this.player.setPosition(param);
			}
			if((this.paramObj.format.indexOf("wm")!=-1) && (this.player.getPosition()>=0) && this.player.getPlayerStatus()!="playing" && this.player.getPlayerStatus()!="buffering") {
				this.player.play();
			}
			this.playedForChapterChange=false;
			if(this.paramObj.contenttype && this.paramObj.contenttype=="L" && this.paramObj.simulive && this.paramObj.simulive=="y") this.player.setVolume(this.curVolume)
		}
	} 
}

//utility function that gets MediaUrlObject based on URL parameter
function getMediaURLObjectByUrl (strUrl) {
	var objElement=null;
	for(var i in this.mediaurl){
		if(this.mediaurl[i].url==strUrl){
			objElement=this.mediaurl[i];
		}				
	}
	return objElement;
}

//utility function that gets most recent timestamp based on mediaurlid parameter
function getTimestampByMediaUrlId (intMediaUrlId) {
	for (var i in this.revtimestamplog) {
		if (intMediaUrlId==this.revtimestamplog[i].id) return this.revtimestamplog[i].timestamp;
	}
	return null;
}

//utility function that gets most recent timestamp (in milliseconds) based on mediaurlid parameter
function getMsTimestampByMediaUrlId (intMediaUrlId) {
	for (var i in this.revtimestamplog) {
		if (intMediaUrlId==this.revtimestamplog[i].id) return this.revtimestamplog[i].mstimestamp;
	}
	return null;
}

//utility function that gets timestamp based on mediaurlid parameter
function getOffsetByMediaUrlId (intMediaUrlId) {
	for (var i in this.offsetlog) {
		if (intMediaUrlId==this.offsetlog[i].id) return this.offsetlog[i].ondemandoffset;
	}
	return null;
}

//this function will be called during caching, so these parameters are required
function getFlashDemoBaseUrl (strFlashDemoUrl) {
	var strFlashDemoBaseUrl = strFlashDemoUrl;
	if(strFlashDemoBaseUrl.indexOf("http://www.on24.com/")!=0){
		var endIdx=strFlashDemoBaseUrl.indexOf("/",7);
		var flashDemoHostname=strFlashDemoBaseUrl.substring(7,endIdx);
		if(endIdx>0){
			var re=new RegExp(flashDemoHostname,"g");
			strFlashDemoBaseUrl=strFlashDemoBaseUrl.replace(re,wwwHost);
		}
	}
	if(window.usecdn) strFlashDemoBaseUrl += "&usecdn=true";
	if(window.cdnprefix) strFlashDemoBaseUrl += "&cdnprefix="+escape(window.cdnprefix);
	return strFlashDemoBaseUrl;
}

//utility function that gets timestamp based on mediaurlid parameter
function showFlashDemo (strFlashDemoUrl) {
	//this.processPushedElementCounter();
	
	strFlashDemoUrl = this.getFlashDemoBaseUrl (strFlashDemoUrl);
	var strParams = "";
		strParams += "&format="+this.paramObj.format
		strParams += "&popup="+this.wwwpopup;
	
	//ondemand
	if (this.paramObj.contenttype && this.paramObj.contenttype=="A") {
		strParams += "&ondemandoffset="+(this.offsetlog[this.currIndex].ondemandoffset)/1000; //offset in seconds
		strParams += "&contenttype=A";
		strParams += "&mode=ondemandstreaming";
	//simu-live
	} else if (this.paramObj.contenttype && this.paramObj.contenttype=="L" && this.paramObj.simulive && this.paramObj.simulive=="y") {
		strParams += "&ondemandoffset="+(this.offsetlog[this.currIndex].ondemandoffset)/1000; //offset in seconds
		strParams += "&contenttype=A";
		strParams += "&mode=ondemandstreaming";
	//live streaming and non-streaming
	} else if (this.paramObj.contenttype && this.paramObj.contenttype=="L") {
		strParams += "&contenttype=L";
		if (this.paramObj.format.indexOf("nonstreaming")!=-1) {
			strParams += "&mode=livenonstreaming";
			strParams += "&servertimeoffset="+this.clientTimeOffset/1000;
		} else {
			strParams += "&mode=livestreaming";
		}
		
		//true if Event Console loaded when URL is pushed
		if (this.wwwchange) {
			strParams += "&livepushtimestamp="+this.wwwtimestamp; //value in seconds
		//attendee arrives after URL is pushed
		} else if (this.wwwid) {
			var objMediaUrl = this.getMediaURLObject(this.wwwid);
			var intTimestamp = this.getMsTimestampByMediaUrlId(this.wwwid);
			if(objMediaUrl && (this.wwwurl.indexOf(objMediaUrl.url)!=-1) && intTimestamp) strParams += "&livepushtimestamp="+(intTimestamp/1000); //value in seconds
		}
	}
	//add params to flashDemo.html url
	strFlashDemoUrl += strParams;
	if (""+this.wwwpopup=="false") {
		this.setSlideFrameSrc(strFlashDemoUrl);
		this.boolPollInSlideFrame=false;
		if(this.enlargeWin && !this.enlargeWin.closed){ 
			this.enlargeWin.location.href=strFlashDemoUrl+"&enlarged=true"; 
		} 
	} else if(this.wwwwidth>0 && this.wwwheight>0) { 
		   window.open(strFlashDemoUrl,'','resizable=1,width='+this.wwwwidth+',height='+this.wwwheight);
	} else {
		window.open(strFlashDemoUrl,'');
	}
	this.boolSyncFlashDemo=true;
}

function setSlideFrameSrc(strUrl) {
	if (bIE) {
		this.doc.slide_frame.location.href=strUrl;
	} else {
		this.getObjByName(this.doc,"slide_frame").src=strUrl;
	}
}

//calculate the ServerTimestamp, based on the LocalTimestamp + offset
function getNonStreamingServerTimestamp() {
	var now = new Date();
	var ms = now.getTime(); //local time in milliseconds
	return (ms + this.clientTimeOffset)/1000; //offset is in milliseconds, returns seconds value
}

//calculates the offset between local time and server time
// ServerTimestamp - LocalTimestamp
function setServerTimestampOffset(strServerTimestamp) { //strTimestamp is in seconds, value of presentersynctimestamp
	var intServerTimestamp = strServerTimestamp-0;
	var now = new Date();
	var ms = now.getTime(); //value is in milliseconds
	this.intServerTimestampOffset = intServerTimestamp - ms/1000; //sets offset in seconds
}

function everyRequestForFlashDemo() {
	if (!this.boolSyncFlashDemo) return; //exit if not true
	
	//obtain player position
	if (this.player) this.intPlayerLastPositionMs = (this.intPlayerCurrentPositionMs)?this.intPlayerCurrentPositionMs:0;
	if (this.player) this.intPlayerCurrentPositionMs = this.player.getPosition();
	if (this.player) this.strPlayerStatus = this.player.getPlayerStatus();
	
	//for simu-live
	if(this.paramObj.contenttype && this.paramObj.contenttype=="L" && this.paramObj.simulive && this.paramObj.simulive=="y") { //live block
		//do nothing
	//for live
	} else if (this.paramObj.contenttype && this.paramObj.contenttype=="L") {
		//non-streaming
		if(this.paramObj.format && this.paramObj.format.indexOf("nonstreaming")!=-1) {
			this.intServerTimestamp = this.getNonStreamingServerTimestamp(); //server timestamp, in seconds, from event te
		//live streaming
		} else {
			//RealPlayer get timestamp
			if(this.player && this.paramObj.format && this.paramObj.format.indexOf("rm")!=-1) {
				this.player.intLiveTimestamp = parseInt(this.player.getCopyright());
			}
			this.intServerTimestamp = this.player.intLiveTimestamp;
		}		
	}
}

//converts the date-time string in the timestamplog array to seconds
function convertTimestampLogValueToSeconds (strDateTime) {
	//strDateTime must be of the following format
	//2004-10-08 16:15:22.0 (YYYY-MM-DD HH:mm:ss.0)
	
	var strYear = strDateTime.substring(0,4);
	var strMonth = strDateTime.substring(5,7);
	var strDay = strDateTime.substring(8,10);
	var strHours = strDateTime.substring(11,13);
	var strMinutes = strDateTime.substring(14,16);
	var strSeconds = strDateTime.substring(17,19);
	var newdate=new Date(strYear-0,strMonth-1,strDay-0,strHours-0,strMinutes-0,strSeconds-0);
	return newdate.getTime()/1000;
}

function replaceTokensFromURL(url,delim){
	if(url.indexOf(delim)==-1) return url;
	var curIdx=0;
	while(url.indexOf(delim, curIdx)!=-1){
		var sIdx=url.indexOf(delim, curIdx)+delim.length;
		var eIdx=url.indexOf(delim, sIdx);
		if(eIdx==-1) return url;
		var token=url.substring(sIdx,eIdx);
		var re=null;
		eval("re=new RegExp(/"+delim+token+delim+"/g)");
		var paramName = token.toLowerCase();
		
		if(token=="LOCALECOUNTRYCODE"){
			//this is a special case. 
			//we should avoid using mixed case parameter names
			paramName = "localeCountryCode";
		}
		if(this.paramObj[paramName] && this.paramObj[paramName]!="" && this.paramObj[paramName]!=null){
			url=url.replace(re,this.paramObj[paramName]);
			//alert(url)
		} else {
			url=url.replace(re,"");
		}
		curIdx=sIdx-1;
		//alert(curIdx)
	}
	return url;
}

function refreshAnswerBlock(){
alert('This function has been disabled.')
return false;

	var answerBlockURL="http://www.on24.com/pm2/answersLibrary.jsp"
						+"?eventid="+this.eventid
						+"&sessionid="+this.sessionid
						+"&key="+this.eventuserkey
						+"&eventuserid="+this.eventuserid
						+"&displaymode=console"
						+"&sortby=answerseq"
						+"&order="+(this.paramObj.contenttype=="L"?"false":"true");
	if (bIE) {
		if(this.doc.answer_frame.location) this.doc.answer_frame.location.href=answerBlockURL;
	} else if (bNN) {
		if(this.getObjByName(this.doc,"answer_frame")) this.getObjByName(this.doc,"answer_frame").src=answerBlockURL;
	}
}

function processPushedElementCounter(){
	if(this.pushedElementCounter%5==0) this.callMediaMetricServlet(true); //update media metric in every 5th lement push
	this.pushedElementCounter++;
}

function writeSlideTranscriptArea(areaID,width,height){
	var strSlidetranscript="";
	strSlidetranscript='<iframe scrolling=auto  id="frame_player_slide_transcript'+areaID+'" name="frame_player_slide_transcript'+areaID+'" width='+width+' height='+height+' frameborder=0 marginheight=0 marginwidth=0 src="'+this.slideTranscriptPageHtml+(this.slideTranscriptPageHtml.indexOf('?')!=-1?'&area=':'?area=')+areaID+'"></iframe>'
	return strSlidetranscript;
}

function showSlideTranscript(strSlideUrl) {
	if(!strSlideUrl || strSlideUrl=="null") return;
	if (!this.slideTranscriptPageHtml) return;
	if(this.slideTranscriptPageHtml.indexOf(wwwHost)==-1){
		var startIdx=this.slideTranscriptPageHtml.indexOf("://");
		var endIdx=this.slideTranscriptPageHtml.indexOf("/",startIdx+3);
		var hostname=this.slideTranscriptPageHtml.substring(startIdx+3,endIdx);
		var re=new RegExp(hostname,"g");
		this.slideTranscriptPageHtml=this.slideTranscriptPageHtml.replace(re,wwwHost);
	}

	var slideno=0;
	var sIdx=strSlideUrl.lastIndexOf("/");
	var eIdx=strSlideUrl.lastIndexOf(".");
	if(sIdx>0 && eIdx>0 && sIdx<eIdx) slideno=strSlideUrl.substring(sIdx+1,eIdx);
	var slidecategory = strSlideUrl.substring(strSlideUrl.lastIndexOf("/",sIdx-1)+1,sIdx);
	var strTranscriptFrameSrc1 = this.slideTranscriptPageHtml;
	var strTranscriptFrameSrc2 = this.slideTranscriptPageHtml;
	var strTranscriptFrameSrc3 = this.slideTranscriptPageHtml;
	strTranscriptFrameSrc1 += (strTranscriptFrameSrc1.indexOf("?")==-1?"?":"&")+(new Date().getTime())+"&area=1#transcript"+slidecategory+"_"+slideno;
	strTranscriptFrameSrc2 += (strTranscriptFrameSrc2.indexOf("?")==-1?"?":"&")+(new Date().getTime())+"&area=2#transcript"+slidecategory+"_"+slideno;
	strTranscriptFrameSrc3 += (strTranscriptFrameSrc3.indexOf("?")==-1?"?":"&")+(new Date().getTime())+"&area=3#transcript"+slidecategory+"_"+slideno;
	var transcriptFilter="";
	if (bIE) {
		var objTranscriptFrame1 = this.doc.frame_player_slide_transcript1;
		var objTranscriptFrame2 = this.doc.frame_player_slide_transcript2;
		var objTranscriptFrame3 = this.doc.frame_player_slide_transcript3;
		if (objTranscriptFrame1 && objTranscriptFrame1.location && this.slideTranscriptsProperties1!=null){
			if(this.slideTranscriptsProperties1.length>0 && this.slideTranscriptsProperties1[0]+""!="undefined"){
				transcriptFilter=this.slideTranscriptsProperties1[0].displayOptionValue;
				if(transcriptFilter.indexOf(slidecategory+"|")!=-1){
					if (this.currentTranscriptSlide1 == strSlideUrl) return;
					this.currentTranscriptSlide1 = strSlideUrl;
					objTranscriptFrame1.location.href=strTranscriptFrameSrc1;
				}
			}
		}
		if (objTranscriptFrame2 && objTranscriptFrame2.location && this.slideTranscriptsProperties2!=null){
			if(this.slideTranscriptsProperties2.length>0 && this.slideTranscriptsProperties2[0]+""!="undefined"){
				transcriptFilter=this.slideTranscriptsProperties2[0].displayOptionValue;
				if(transcriptFilter.indexOf(slidecategory+"|")!=-1){
					if (this.currentTranscriptSlide2 == strSlideUrl) return;
					this.currentTranscriptSlide2 = strSlideUrl;
					objTranscriptFrame2.location.href=strTranscriptFrameSrc2;
				}
			}
		}
		if (objTranscriptFrame3 && objTranscriptFrame3.location && this.slideTranscriptsProperties3!=null){
			if(this.slideTranscriptsProperties3.length>0 && this.slideTranscriptsProperties3[0]+""!="undefined"){
				transcriptFilter=this.slideTranscriptsProperties3[0].displayOptionValue;
				if(transcriptFilter.indexOf(slidecategory+"|")!=-1){
					if (this.currentTranscriptSlide3 == strSlideUrl) return;
					this.currentTranscriptSlide3 = strSlideUrl;
					objTranscriptFrame3.location.href=strTranscriptFrameSrc3;
				}
			}
		}
	} else {
		var objTranscriptFrame1 = this.getObjByName(this.doc,"frame_player_slide_transcript1");
		var objTranscriptFrame2 = this.getObjByName(this.doc,"frame_player_slide_transcript2");
		var objTranscriptFrame3 = this.getObjByName(this.doc,"frame_player_slide_transcript3");
		if (objTranscriptFrame1 && this.slideTranscriptsProperties1!=null){
			if(this.slideTranscriptsProperties1.length>0 && this.slideTranscriptsProperties1[0]+""!="undefined"){
				transcriptFilter=this.slideTranscriptsProperties1[0].displayOptionValue;
				if(transcriptFilter.indexOf(slidecategory+"|")!=-1){
					if (this.currentTranscriptSlide1 == strSlideUrl) return;
					this.currentTranscriptSlide1 = strSlideUrl;
					objTranscriptFrame1.src=strTranscriptFrameSrc1;
				}
			}
		}
		if (objTranscriptFrame2  && this.slideTranscriptsProperties2!=null){
			if(this.slideTranscriptsProperties2.length>0 && this.slideTranscriptsProperties2[0]+""!="undefined"){
				transcriptFilter=this.slideTranscriptsProperties2[0].displayOptionValue;
				if(transcriptFilter.indexOf(slidecategory+"|")!=-1){
					if (this.currentTranscriptSlide2 == strSlideUrl) return;
					this.currentTranscriptSlide2 = strSlideUrl;
					objTranscriptFrame2.src=strTranscriptFrameSrc2;
				}
			}
		}
		if (objTranscriptFrame3  && this.slideTranscriptsProperties3!=null){
			if(this.slideTranscriptsProperties3.length>0 && this.slideTranscriptsProperties3[0]+""!="undefined"){
				transcriptFilter=this.slideTranscriptsProperties3[0].displayOptionValue;
				if(transcriptFilter.indexOf(slidecategory+"|")!=-1){
					if (this.currentTranscriptSlide3 == strSlideUrl) return;
					this.currentTranscriptSlide3 = strSlideUrl;
					objTranscriptFrame3.src=strTranscriptFrameSrc3;
				}
			}
		}
	}
}

function writeSlideThumbnailArea(width,height){
	return '<iframe name="thumbnailFrame" id="thumbnailFrame" width="'+width+'" height="'+height+'" scrolling="auto" src="thumbnail.html" frameborder="0"></iframe>'
}

function writeSlideSearchTextbox(width,height){
	return '<form id="formSearchSlide" name=searchSlideForm onsubmit="return false;"><input type=text name=searchText style="width:'+width+'px;height:'+(height-1)+'px;" onkeypress="if((event.which && event.which==13) || (event.keyCode && event.keyCode==13)) ep1.startSlideSearch();"  onkeydown="if((event.which && event.which==13) || (event.keyCode && event.keyCode==13)) ep1.startSlideSearch();" maxlength="200"></form>'
}

function startSlideSearch(){
	var searchTextElement=this.getElementFromDoc("window.main","document.searchSlideForm","searchText");
	if(searchTextElement==null) return false;
	if(searchTextElement.value=="") return false;
	//don't delete the following line. it'll force the CD ceration process to copy search.html
	//var strSlideSearchFrameSRC="search.html"
	var strSlideSearchFrameSRC="searchFrame.html?"+escape(searchTextElement.value);
	if(this.showSlideNotes==true) strSlideSearchFrameSRC+="&showSlideNotes=true";
	var params="width=400,height=500";
	if(bIE) params+=",left="+window.screenLeft+",top="+window.screenTop;
	else params+=",left="+window.screenX+",top="+window.screenY;
	//alert(params);
	window.open(strSlideSearchFrameSRC,"strSlideSearchFrameSRC",params);
}

function showPCViewLinkinEnlargedArea(){
	if(this.enlargeWin && !this.enlargeWin.closed){
		this.enlargeWin.location.href="launchpcview.html"
		//"www.html?url="+escape(this.getPCViewURL());
		this.enlargeWin.focus();
	}
}

function showPCViewLinkinSlideArea(){
	this.setSlideFrameSrc("launchpcview.html");
}

function submitXMLHTTPPost(reqUrl, reqParams){
	try{
		var xmlhttp = this.win.parent.getXMLHTTP();
		if(xmlhttp){
			xmlhttp.open("POST",reqUrl,true);
			xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
			xmlhttp.send(reqParams);
			return true;
		}
	} catch (ex){}
	return false;
}

function submitXMLHTTPGet(reqUrl, reqParams){
	try{
		var xmlhttp = this.win.parent.getXMLHTTP();
		if(xmlhttp){
			xmlhttp.open("GET",reqUrl + "?" + reqParams,true);
			xmlhttp.send(null);
			return true;
		}
	} catch (ex){}
	return false;
}

function replaceHost(pageurl) {	
	if(pageurl.indexOf(wwwHost)==-1){		
		var startIdx=pageurl.indexOf("://");
		var endIdx=pageurl.indexOf("/",startIdx+3);
		var hostname=pageurl.substring(startIdx+3,endIdx);
		var re=new RegExp(hostname,"g");
		pageurl=pageurl.replace(re,wwwHost);
	}
	return pageurl;
}
