/* Copyright Magneetto 2005
Magneetto Webcast Dynamic UI Builder
*/
var initContainerFlag = false;
var chatAdmin = new MGChatAdmin();
var errorStatus = false;
var updateFlag = true;
var firstOpenFlag = true;
var initFlag = false;
var hasOndemand = false;
var currentLive = '';
var currentSourceType = 'live';
var alertFlag = true;
var chatAdminFlag = false;
var alertCounter = 1;
var menuPathContent ='';
var currentTime =0;
var chatLines ='';
var chatPrintOut='<DIV ID="userInfoBox" name="userInfoBox" style="font-family:Arial; font-size:11px; color:#000000; background-color:f0f0f0; border-width:1px 1px 1px 1px; border-style:solid; border-color:#808080; padding:2px 8px 2px 8px; position:absolute; left:0px; top:0px; visibility:hidden; z-index:999;"></DIV>';
var lastCommunicatorResult='No status received';
var communicatorOpened = false;
var latestAdminID=0;
var communicatorParams ='';
var extraParams='';
var currentResource='';

function getElement(n, d) { // original: MM_findObj v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=getElement(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MGChatAdmin(){
	this.deleteLine = deleteChatLine;
	this.deleteAll = deleteChatAll;
	this.build = buildChatAdminView;
	this.addLine = addChatAdminLine;
	this.acceptLine = acceptChatLine;
}
function MGPlayer(){
	//defining the MGmenu class
	this.items = new Array();
	//this.setSpeakerTitle= setSpeakerTitle;
	//this.setCompany = setCompany;
	this.addItem = addItem;
	this.setSlide = setSlide;
	this.setSpeaker = setSpeaker;
	this.build = build;
	this.openPresentationList = openPresentationList;
	this.buildPresentationMenu = buildPresentationMenu;
	this.openWebcastList = openWebcastList;
	this.openSlides = openSlides;
	this.openChat = openChat;
	this.openMaterialList = openMaterialList;
	this.openWebcastList = openWebcastList;
	this.runCommand = runCommand();
	if(this.items.length){
			currentItem = this.items[this.items.length];	
		this.addShow = currentItem.addShow;
	}
}
function addItem(){
	//menu-kohdan lisäys
	if(arguments[0].toString().indexOf("[object Object]") != -1) {
		this.items[this.items.length] = arguments[0];
	} else {
		this.items[this.items.length] = new MGMenuItem(arguments[0], arguments[1], arguments[2], arguments[3]);
		//alert(this.items[this.items.length-1].topic);
		return(this.items[this.items.length-1])
	}
}
function addShow(){
	//menu-kohdan lisäys
	if(arguments[0].toString().indexOf("[object Object]") != -1) {
		this.shows[this.shows.length] = arguments[0];
	} else {
		this.shows[this.shows.length] = new MGShow(arguments[0], arguments[1], arguments[2],arguments[3]);
	}
	return(this.shows[this.shows.length-1])
}

function MGMenuItem(topic,description,url,type){
	//menukohdan määrittely
	this.id = null;
	this.date = null;
	this.company = null;
	this.speakertitle = null;
	this.topic = topic ? topic : -'';
	this.description = description!='undefined' ? description : '';
	this.url = url ? url : "";
	this.type = type;
	this.number = MGnumber++;
	this.shows = new Array();
	this.addShow = addShow;
	this.speaker= '';
	MGLastItem = this;
	this.setDateVal = setDateVal;
	this.setID = setID;
	this.setCompany = setCompany;
	this.setSpeakerTitle = setSpeakerTitle;
}
function MGShow(topic,speaker,description,slides){
	this.showSlides = new Array();
	this.showSlideIDs = new Array();
	this.company = null;
	this.fileName = null;
	this.speakertitle = null;
	this.time = null;
	this.controlStatus = false;
	this.presentationStatus = 'inherit';
	this.id=null;
	this.showSlideTypes = new Array();
	this.slideChangeTimes = new Array();
	this.topic = topic ? topic : '';
	this.description = description;
	this.speaker = speaker;
	this.slides = slides ? slides : 0;
		this.setSpeakerTitle = setSpeakerTitle;
		this.setCompany = setCompany;
		this.setTimeVal = setTimeVal;
		this.addSlide = addSlide;
		this.addSlideTimes = addSlideTimes;
		this.checkForSlideChange = checkForSlideChange;
		this.setID = setID;
		this.setControlStatus = setControlStatus;
		this.setPresentationStatus = setPresentationStatus;
		this.setFileName = setFileName;
}
function setDateVal(val){
	this.date = val;
}
function setTimeVal(val){
	this.time = val;
}
function setID(newid){
	this.id = newid;
}
function setFileName(newname){
	this.fileName = newname;
}
function setControlStatus(newstatus){
	this.controlStatus = newstatus;
}
function setPresentationStatus(newstatus){
	this.presentationStatus = newstatus;
}
function setCompany(val){
	this.company = val;
}
function setSpeakerTitle(val){
	this.speakertitle = val;
}
function runCommand(param){
	switch(param){
		case "clear":
		case "clearChat":
		chatLines='';
		chatPrintOut='<DIV ID="userInfoBox" name="userInfoBox" style="font-family:Arial; font-size:11px; color:#000000; background-color:f0f0f0; border-width:1px 1px 1px 1px; border-style:solid; border-color:#808080; padding:2px 8px 2px 8px; position:absolute; left:0px; top:0px; visibility:hidden; z-index:999;"></DIV>';
		this.openChat();
		break;
	}
}

function addSlide(slideid,slidename,slidetype){
this.showSlides[this.showSlides.length] = slidename;
this.showSlideIDs[this.showSlideIDs.length]= slideid;
this.showSlideTypes[this.showSlideTypes.length] = slidetype;
}

function checkForSlideChange(newtime){
	var found=-1;
	var temp = null;
	var s = 0;
newtime=parseInt(newtime);
if(newtime==currentTime) return;
else currentTime = newtime;
for(i=0;(i<this.slideChangeTimes.length);i++)
	{
	vals=this.slideChangeTimes[i].split(":");
	if(vals[0]&&vals[0]>0)
			{
			 s=(parseInt(vals[0])*60+parseInt(vals[1]));
			}
	else
		 s=parseInt(vals[0]);
	if(newtime>=s) found=i;
	}
if(found!=-1){
	temp=found;
	temp=trim(temp);
	if(currentSlide!=temp) setSlide(temp);
	}
}

function addSlideTimes(){
this.slideChangeTimes = arguments;	
}

//main content area Openers:
function openSlides(){
currentResource='';
chatAdminFlag=false;
setSlide(currentSlide);
}
function openContentPage(pageresource){
if(currentResource!=pageresource){
		currentResource = pageresource;
	var slideTD=getElement('slideTD');
	slideTD.innerHTML = '<iframe id="slides" marginwidth="0" marginheight="0" frameborder="0" scrolling="auto" src="'+pageresource+'" height="'+slideHeight+'" width="'+slideWidth+'"></iframe>';
	}
else {
	openSlides();
	}
}
function enlargeCurrentSlide(){
	//alert('enlarging slide '+currentShow.showSlides[currentSlide]);
	window.open('http://itviikko.seminaarit.net/viewpicture.php?pid='+currentShow.showSlideIDs[currentSlide-1], 'ViewSlide','status=no,location=no,menubar=no,toolbar=no,scrollbars=yes,resizable=no');
}

function openMaterialList(){
//	getElement('slides').src="";
}
function openBanner(){
	if(getElement('container3TD')){
	getElement('container3TD').innerHTML='<iframe id="container3" name="container3" marginwidth="0" marginheight="0" frameborder="0" scrolling="no" src="banner.php" width="570" height="100"></iframe>';
	}
}
function openPoll(){
if(getElement('container2').location)
getElement('container2').location.href='/poll.php?webcast='+MGwebcastItem.id;
else if(top.container2)
	top.container2.location.href='/poll.php?webcast='+MGwebcastItem.id;
if(getElement('kyselyTD'))getElement('kyselyTD').background='images/activebg.gif';
getElement('agendaTD').background='';
getElement('rightTD').background='';
getElement('agendaTabImg').src='images/container2menu_rightup.gif';
getElement('kyselyTabImg').src='images/container2menu_leftup.gif';
}
//container 2 Openers:
function openChat(){
	/*var element = null;
	initContainer2();
	if(self.container2) element = self.container2;
	else if(document.frames) element = document.frames.container2;
	else if(getElement('container2')) element = getElement('container2');
	element.height="150";
	if(element.style)element.style.height=150;
	element.innerHTML='<DIV ID="userInfoBox" name="userInfoBox" style="font-family:Arial; font-size:11px; color:#000000; background-color:f0f0f0; border-width:1px 1px 1px 1px; border-style:solid; border-color:#808080; padding:2px 8px 2px 8px; position:absolute; left:0px; top:0px; visibility:hidden; z-index:999;"></DIV>';
	element.buildChat();
	getElement('container3TD').innerHTML='<iframe id="container3" name="container3" marginwidth="0" marginheight="0" frameborder="0" scrolling="no" src="chat_submit.php?sid='+sid+'" width="570" height="100"></iframe>';
	/*
	if(getElement('container3')) element = getElement('container3');
	else if(document.frames) element = document.frames.container3;
	else if(self.container3) element = self.container3;
	if(element.style)element.style.height=27;
	else document.all.container3.style.height=27;
	if(getElement('container3body')) element = getElement('container3body');
		else if(document.frames) element = document.frames.container3.container3body;
	else if(self.container3) element = self.container3.getElement('container3body');
	if(element){
		element.display='block';
		element.height="27";
		//alert(element.innerHTML+element.display+element.style.visibility);
		}
		*/
	//getElement('container2.header').innerHTML='LIVE CHAT';
	//openCommunicator();
	
}
function openChatAdmin(){
	var element = null;
	chatAdminFlag = true;
	chatAdmin.build('slideTD');
}
function openPresentationList(){
	//alert('opening presentation list');
	//getElement('container2.header').innerHTML='PRESENTATIONS';
	 var initVal = 1;
	if(initContainerFlag==false){
	 	initVal = initContainer2();
		 initContainerFlag = true;
	 	}
	if(initVal==-1) {
		 setTimeout('MGroot.openPresentationList()',200);
		 return(1);
	 		}
	else {
		this.buildPresentationMenu(1,useshow);
		initContainerFlag = false;
	}
/*	if(getElement('container3')) element = getElement('container3');
	else if(document.frames) element = document.frames.container3;
	else if(self.container3) element = self.container3;
	if(element.style)   element.style.height=0;
	else document.all.container3.style.height=0;
if(getElement('container3body')) element = getElement('container3body');
		else if(document.frames) element = document.frames.container3.container3body;
	else if(self.container3) element = self.container3.getElement('container3body');
	if(element){
	element.display='none';
	e	lement.height="0";
	}
*/
getElement('agendaTD').background='images/activebg.gif';
if(getElement('kyselyTD'))getElement('kyselyTD').background='';
getElement('rightTD').background='images/activebg.gif';
getElement('agendaTabImg').src='images/container2menu_leftup.gif';
getElement('kyselyTabImg').src='images/container2menu_rightup.gif';
closeCommunicator();
//openBanner();
}

//Main UI Builder
function build(area,show){
//dynamically builds the UI
var currentItem = this.items[area-1];
var addPlayerHeight=0;
if(!show) show = 1;
useshow = esitys = show;
currentSlide = initCurrentSlide;
communicatorParams ='&chatAdmin=false';
//alert(currentItem.shows[show-1]);
if(currentItem.shows) currentShow = currentItem.shows[show-1];
else {
	currentShow = null;
	}
var output ='';
if(currentShow=='undefined') currentShow = null;
//menupolku
/*target = getElement('menupath');
if(firstOpenFlag) menuPathContent = target.innerHTML;
target.innerHTML = menuPathContent+currentItem.topic;
*/
//+' : ' +currentShow.topic;
//esityksen nimi 
if(currentShow && currentShow!='undefined'){
	if(currentShow.speaker == null) currentShow.speaker ='';
	if(currentShow.speakertitle == null) currentShow.speakertitle ='';
	if(currentShow.company == null) currentShow.company ='';
	if(getElement('webcastName'))
		getElement('webcastName').innerHTML= ((webcastStatus=='live') ? '<font class="presentationHeader" style="color:#990000; font-weight:bold;">LIVE</font>&nbsp;' :'')+'<font class="presentationHeader">'+ currentItem.topic+'</font>';
	if(getElement('playerHeader')){
		getElement('playerHeader').innerHTML='<font class="presentationHeader" style="font-weight:bold;">'+ currentShow.speaker +'</font><br><font class="actionLink"> ';
		if(currentShow.speakertitle!='') getElement('playerHeader').innerHTML += currentShow.speakertitle+', ';
		getElement('playerHeader').innerHTML+=currentShow.company+'</font>';
	}
}
else getElement('playerHeader').innerHTML='<img src="images/spacer.gif" width="10" align="left" border="0">'+ currentItem.topic;
//PDF
if(getElement('openPDF'))
getElement('openPDF').href='presentation_images/'+area+'/'+show+'/Slides.pdf';

//rakennetaan player-alue
target = getElement('player');
target.height="270";
var mediapath=mediaServer;
if(webcastStatus =='ondemand'){
	if(currentShow){
	if(currentShow.fileName!=null && currentShow.fileName!="undefined") {
			//alert(currentShow.fileName);
				mediapath+='/'+currentShow.fileName;
					}
		else mediapath+='/'+show+'.'+mediaExtension;
		}
	}
	if(currentShow){
		if(webcastStatus=='ondemand' && currentShow.controlStatus == true){
			addPlayerHeight=71;
			}
		}
output='<object classid="CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95" codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,4,5,715" type="application/x-oleobject" width="'+playerWidth+'" border="0" height="'+(playerHeight+addPlayerHeight)+'" hspace="0" vspace="0" standby="Loading Microsoft® Windows® Media Player components..." id="MediaPlayer">'+
'        <param name="FileName" value="'+mediapath+'">'+
'        <param name="AutoStart" value="true">'+
'        <param name="AutoRewind" value="true">'+
'        <param name="Loop" value="true">'+
'        <param name="TransparentAtStart" value="true">'+
'        <param name="AnimationatStart" value="false">';
if(currentShow)
	if(webcastStatus=='ondemand' && currentShow.controlStatus == true) output+='        <param name="ShowControls" value="true">'+
'        <param name="ShowAudioControls" value="true">'+
'        <param name="ShowStatusBar" value="true">'+
'        <param name="ShowTracker" value="true">';
else output+='        <param name="ShowControls" value="false">'+
'        <param name="ShowAudioControls" value="false">'+
'        <param name="ShowStatusBar" value="false">'+
'        <param name="ShowTracker" value="false">';
output+='        <param name="autoSize" value="false">'+
'        <param name="ShowGotoBar" value="false">'+
'        <param name="ShowDisplay" value="false">'+
'        <param name="uiMode" value="mini">'+
'        <param name="displaySize" value="0">'+

'        <param name="ShowPositionControls" value="false">'+
'        <embed type="application/x-mplayer2" id="MediaPlayer"'+
'	 pluginspage="http://www.microsoft.com/Windows/Downloads/Contents/Products/MediaPlayer/"'+
'	 src="'+mediapath+'"'+
'	 height='+(playerHeight+addPlayerHeight)+
'	 width='+playerWidth+
'	 hspace=0'+
'	 vspace=0'+
'	 border=0'+
'	 autostart=1'+
'	 transparentatstart=0'+
'	 animationstart=1';
if(webcastStatus=='ondemand' && currentShow.controlStatus == true) output+='	 showcontrols=1'+
'	 showstatusbar=1'+
'	 showtracker=1'+
'	 showaudiocontrols=1';
else output+='	 showcontrols=0'+
'	 showstatusbar=0'+
'	 showtracker=0'+
'	 showaudiocontrols=0';
output+='	 showdisplay=0'+
'	 showpositioncontrols=0'+
'	 uimode=mini'+
' autosize=0'+
'	 displaysize=0> </embed>'+
'      </object>';
if(firstOpenFlag || (webcastStatus=='ondemand'))
target.innerHTML=output;
	getElement('MediaPlayer').InvokeURLs=0;
	getElement('MediaPlayer').URL=mediapath;
	if(!navigator.userAgent.indexOf("IE") == -1) getElement('MediaPlayer').Open(mediapath);
//rakennetaan ohjelma
//setSlide(1);
//if(firstOpenFlag==true) openContentPage('browsertest.html');
 this.openSlides();
	this.openPresentationList();
	// openBanner();
firstOpenFlag = false;
}


//PRESENTATION CONTROL

function openPresentation(pres){
MGroot.build(alue,pres);
}

function setSpeaker(speaker){
	//Alias openPresentationille:: bstrParams käyttää
openPresentation(speaker);
}


//SLIDE CONTROL
function setOpacity(obj, opacity) {
  opacity = (opacity == 100)?99.999:opacity;
  
  // IE/Win
  obj.style.filter = "alpha(opacity:"+opacity+")";
  
  // Safari<1.2, Konqueror
  obj.style.KHTMLOpacity = opacity/100;
  
  // Older Mozilla and Firefox
  obj.style.MozOpacity = opacity/100;
  
  // Safari 1.2, newer Firefox and Mozilla, CSS3
  obj.style.opacity = opacity/100;
}

function fadeIn(objId,opacity) {
    obj = getElement(objId);
    if (opacity <= 100) {
      setOpacity(obj, opacity);
      opacity += 10;
      window.setTimeout("fadeIn('"+objId+"',"+opacity+")", 100);
    }
  }
function initImage(imageID) {
  image = getElement(imageID);
  setOpacity(image, 0);
  image.style.visibility = 'visible';
  fadeIn(imageID,0);

}
function setSlide(slideno){
var arrayno=slideno-1;	
	//alert('setting slide:'+currentShow.showSlides[slideno-1]);
	if(webcastStatus=='ondemand'){

		if(slideno==1){
			if(getElement('slidePreviousButton')) getElement('slidePreviousButton').disabled=true;
			}
		else if(getElement('slidePreviousButton')) getElement('slidePreviousButton').disabled=false;
		/*alert(currentShow.slides);
		if(!currentShow.slides) currentShow.slides = 0;
		if (currentShow.slides == null )  currentShow.slides = 0;*/
		if(currentShow){
			if(slideno>=currentShow.slides){
				if(getElement('slideNextButton')) getElement('slideNextButton').disabled=true;
				}
		else if(getElement('slideNextButton')) getElement('slideNextButton').disabled=false;
		}
		
		}
	var slideTD=getElement('slideTD');
	if(currentShow)
	if(currentShow.showSlideTypes[arrayno]=='image'){
		slideTD.innerHTML='<img style="visibility:hidden;" src="'+currentShow.showSlides[arrayno]+'" name="dia" alt="" width="'+slideWidth+'" hspace="0" vspace="0" border="0" id="dia">';
		initImage('dia');
		}
	else{ 
		slideTD.innerHTML = '<iframe id="slides" marginwidth="0" marginheight="0" frameborder="0" scrolling="auto" src="openSlide.php?id='+currentShow.showSlideIDs[arrayno]+'" height="'+slideHeight+'" width="'+slideWidth+'"></iframe>';
		initImage('slides');
		}
if(getElement('slidePointer')) {
	if(currentShow)getElement('slidePointer').innerHTML = slideno + ' / ' + currentShow.slides;
	}
//	getElement('slides').src='slides.html?alue='+alue+'&esitys='+useshow+'&slide='+slideno;
}
function slidePrevious(){
	if(currentSlide>1) setSlide(--currentSlide);
}
function slideNext(){
	if(currentShow.slides == null) currentShow.slides = 0;
	if(currentSlide<currentShow.slides) setSlide(++currentSlide);	
}

// UI Dynamic communication init

function openCommunicator(){
	updateFlag = true;
	initFlag = true;
	if(communicatorOpened==false){
		communicatorOpened=true;
		updateSystem();
	}
	else if(communicatorParams) updateSystem();
}

function displayCommunicatorStatus(){
	if(updateFlag == true) message = 'running';
	else message = 'stopped';
	alert('Communicator '+message+'.\n Last result:'+lastCommunicatorResult+'\n SRC:'+getElement('communicator').src);
}
function closeCommunicator(){
updateFlag = false;
chatAdminFlag = false;
latestAdminID=0;
communicatorOpened = false;
//alert('closing Communicator');
	}

function updateSystem(runOnceParams){
	if(!runOnceParams) runOnceParams='';
	extraParams = '';
	if(chatAdminFlag == true ) extraParams = '&chatAdmin=true';
	if(latestAdminID)extraParams+='&lastAdminID='+latestAdminID;
//	if(communicatorParams || runOnceParams) alert('sending commands:' + communicatorParams + runOnceParams);
	if(updateFlag == true) getElement('communicator').src='system_communicate.php?sid='+sid+'&session='+sessid+'&latestChatlineID='+latestMessageID+communicatorParams+extraParams+runOnceParams;
	if(updateFlag == true && (communicatorParams|| runOnceParams)){
		communicatorParams ='';
		setTimeout('updateSystem()',1000);
		}
	initFlag = false;
		
}
function sendRDVOpenCommand(address){
	//alert('Sending Open Remote Desktop Viewer Connection command, target address '+address);
	communicatorParams = '&executeCommand=openrdv&rdvaddress='+address;
	updateSystem();
	
}

//Chat Screen Update
function addChatLine(name,message,arrival,id,userid){
if(name!='system'){
/*	var chatOutput='<table id="chat_'+id+'" width="100%" cellpadding="0" cellspacing="3" border="0"><tr align="left" valign="top"';
	if(name=='system') chatOutput+=' style="color:#009900;"';
	chatOutput += '>  <td width="10" height="20">&nbsp;</td>';
	chatOutput += '<td width="90" align="left"';
	if(name=='system')chatOutput+=' style="color:#009900;"';
	chatOutput+='><a href=\"#\" onClick=\"return false;\" onMouseOver=\"getUser('+userid+');\" onMouseOut=\"showUser(false);\">&lt;'+name+'&gt;</a></td>'; 
	
	chatOutput += ' <td align="left">'+message+'</td>'+
	'			  </tr>'+
	'			  <tr><td height="1" colspan="3" bgcolor="#CED6D2"><img src="images/spacer.gif" height="1" border="0" vspace="0"></td></tr></table>';
	if(updateFlag)window.frames['container2'].getElement('container2body').innerHTML=chatOutput+window.frames['container2'].getElement('container2body').innerHTML;
	
	//chatPrintOut = window.frames['container2'].getElement('container2body').innerHTML;
	*/
	}
}
function deleteChatLine(lineid){
	
var	params ='&executeCommand=deleteline&lineid='+lineid;
	updateSystem(params);
		//chatAdmin.build('slideTD');
	}
function acceptChatLine(lineid){
//alert ('accepting line '+lineid);
var	params ='&executeCommand=acceptline&lineid='+lineid;
	updateSystem(params);
		//chatAdmin.build('slideTD');

	}
function deleteChatAll(lineid){
	//alert('Deleting lines older than '+lineid)
var	params ='&executeCommand=deleteall&lineid='+lineid;
	updateSystem(params);
//	chatAdmin.build('slideTD');

}
function addChatAdminLine(name,message,arrival,id,msgtype){
var chatOutput='<table width="100%" cellpadding="0" cellspacing="2" border="0"><tr align="left" valign="top"';
if(name=='system') chatOutput+=' style="color:#009900;"';
chatOutput += '>  <td width="10">&nbsp;</td>';
chatOutput += '<td width="20%">'+arrival+'</td><td align="left"';
if(name=='system')chatOutput+=' style="color:#009900;"';
chatOutput+='>&lt;'+name+'&gt;</td>'+
'			  <td align="left">'+message+'</td><td align="right">';
if(msgtype==0) chatOutput+='<a href="#" onClick="chatAdmin.acceptLine('+id+'); return false;">Accept</a> :';
chatOutput+='<a href="#" onClick="chatAdmin.deleteLine('+id+'); return false;">Delete</a>'+
': <a href="#" onClick="chatAdmin.deleteAll('+id+'); return false;"> Delete older</a>'+
'</td>'+
'			  </tr>'+
'			  <tr><td height="1" colspan="3" bgcolor="#CED6D2"><img src="images/spacer.gif" height="1" border="0" vspace="0"></td></tr></table>';

getElement('slideTD').innerHTML=chatOutput+getElement('slideTD').innerHTML;

}

function buildPresentationMenu(darea,dcurrent){
darea--;
dcurrent--;
var dcurrentItem = this.items[darea];
var output='';

if(dcurrentItem.shows[0]) {
		output+='<table width="100%" cellspacing="2" cellpadding="0">';
		for(j=0; dcurrentItem.shows[j];j++){
			dcurrentShow=dcurrentItem.shows[j];
			if(webcastStatus=='ondemand')output+='<tr onClick="parent.openPresentation('+(j+1)+')" style="cursor:pointer; cursor:hand">';
			else output+='<tr>';
			output+='<td width="10">&nbsp;</td><td class="normal" style="padding:4px;">';
			if(j==dcurrent) output += '<strong>';
			output+=''+dcurrentShow.topic;
			if(j==dcurrent) output+='</strong>';
			output+='<br>'+dcurrentShow.speaker;
			if(dcurrentShow.speakertitle!=null &&  dcurrentShow.speakertitle.length>0) output+=','+dcurrentShow.speakertitle;
			if(dcurrentShow.company != null && dcurrentShow.company.length > 0) output+=','+dcurrentShow.company;
			output+='</td></tr>';
		if(dcurrentItem.shows[j+1]) output+='<tr><td colspan="2" height="1" bgcolor="#CCCCCC"><img src="images/spacer.gif" alt="" border="0" vspace="0" height="1"></td></tr>';
		}//for
	}//if
else {
	output+='<strong>'+dcurrentItem.topic+'</strong><br>';
	}
output+='</table>';

var tframe = null;
if(getElement('container2body')) element = getElement('container2body');
else if(document.frames) element = document.frames.container2.container2body;
else if(self.container2) element = self.container2.getElement('container2body');
if(element)
	element.innerHTML=output;
}
function initContainer2(){
	if(getElement('container2').location){
		if(getElement('container2').location.pathname!='/container2.html'){
			//alert('setting location, was'+getElement('container2').location.pathname);
			getElement('container2').location.href='container2.html';
			getElement('container2').location.pathname='/container2.html';
			return(-1);
			}
		else return(1);
		}
	else if(top.container2){
		if(top.container2.location.pathname!='/container2.html'){
			top.container2.location.href='container2.html';
			top.container2.location.pathname='/container2.html';
			return(1);
			}
		else return(1);
		}
	return(1);
	}
	
function openWebcastList(){
//rakentaa menun

target = getElement('container2body');
var element;
var output ='<table width="100%" cellspacing="0" cellpadding="2" border="0">';
for(i=0; this.items[i];i++){
	listItem = this.items[i];
	//alert(currentItem.topic);
	output +='			  <tr>';
	if(currentShow.id == listItem.id) output += '	<td width="20" align="center" bgcolor="#1C5FC2"><img src="images/bullet.gif" border="0" width="8" height="8"></td><td height="20" align="left" bgcolor="#1C5FC2"><a target="_top" href="index.php?view_id='+currentItem.id+'" style="text-decoration:none; color:#FFFFFF;">'+currentItem.topic+'</a></td><td align="right" bgcolor="#1C5FC2" style="color:#ffffff;">'+currentItem.date+'</td>';

	else output +='			<td width="20">&nbsp;</td><td height="20" align="left" ><a target="_top" href="index.php?view_id='+listItem.id+'" style="text-decoration:none">'+listItem.topic+'</a></td><td align="right">'+listItem.date+'</td>';

	 output+='  </tr>';
	}//for
	output+='</table>';
if(getElement('container2body')) element = getElement('container2body');
else if(document.frames) element = document.frames.container2.container2body;
else if(self.container2) element = self.container2.getElement('container2body');
if(element){
	element.innerHTML=output;
	element.valign="top";
//	openBanner();
	}
else alert('error: could not render Webcast List');
}

function buildChatAdminView(targetID){
	if(targetID){
	if(getElement(targetID)){
		element = getElement(targetID);
		element.innerHTML='Chat Administration';
		element.style.valign='top';
		lastAdminID=0;
		chatAdminFlag = true;
		latestAdminID=0;
		communicatorParams ='&loadAllMessages=true&executeCommand=openChatADmin';		
		if(communicatorOpened==false)openCommunicator();
		else updateSystem();
		
	}
	}
	else errorStatus = 'unable to open Chat Administration View';
	
}
function executeCommand(commandParam,valueParam){
	//alert(commandParam);
	switch(commandParam){
		case "openrdv":
			openRDV(valueParam);
			break;

	}
}
function openRDV(targetaddr){
	if(updateFlag ==false) openCommunicator();
setTimeout("CheckForWindowOpen('"+targetaddr+"')",1000);
			window.open(targetaddr,'_blank','location=no,titlebar=no,toolbar=no');
}
function CheckForWindowOpen(param){
 addChatLine('system','If the RDV Viewer did not open, you can access it by clicking <a style=\"color:green\" target="_blank" href="'+param+'">here</a>.','','0');
}
