/**********************************************************************/
/* Copyright 2004, Standpoint Technologies Inc. All rights reserved.  */
/*                                                                    */
/*       The code present here was designed and developed by          */
/*     Standpoint Technologies Inc. Any use of any part of this       */
/*            application is strictly prohibited.                     */
/*                                                                    */
/* For licensing, contact Gary Herron at Standpoint Technologies Inc. */
/*          www:              http://www.standpointtech.com           */
/*                                                                    */
/**********************************************************************/

var rmi_thrd = null, click_queue = null;

function rmi_exec(exec_str, delay) {
		//alert(exec_str + ':' + delay);
		//add2d('RMI EXECUTE!: ' + exec_str);
		//if (exec_str.substr(0, 3) == 'jum' || !wait_for_load)
		add2d('local rmi_exec ' + exec_str, 'red');
		if (!rmi_thrd) {
			threads.push(new Array());
			rmi_thrd = threads.length - 1;
		}
		if (!click_queue) {
			threads.push(new Array());
			click_queue = threads.length - 1;
		}
		if (exec_str.substr(0, 3) == 'jum' || !delay) {
			//alert(exec_str);
			add2d('evaling ' + exec_str, 'red');
			eval(exec_str);
		} else if (exec_str.substr(0, 11) == 'handleClick' || exec_str.substr(0, 11) == 'uFBMgOcSPVU') {
			add2d('queuing to click_queue: ' + exec_str, 'red');
		
			threads[click_queue].push(exec_str);
		} else {
			//alert('rmi: ' + exec_str);
			add2d('queuing to rmi_thrd: ' + exec_str, 'red');
			threads[rmi_thrd].push(exec_str);
		/*
			if (!rmi_thrd) {
				//rmi_thrd = threadPos.length;
				//alert('creating new thread');
				var temp = new Array();
				temp.push(exec_str);
				threads.push(temp);
				rmi_thrd = threads.length-1;
				threadStatus.push(0);
				//alert(threadPos.length);
				alert('here' + rmi_thrd);
				//executeThread(rmi_thrd);
				alert('yeah');
			} else {
				try {
					nextAction(rmi_thrd);
				} catch (e) {
					SOoyogWlJJKF(rmi_thrd);
				}
			}*/
		}
	}
	function exec_after_load(str) {
		if (wait_for_load) {
			//alert('waiting');
			setTimeout("exec_after_load('" + str + "');", 500);
		}
		else {
			//alert(str);
			wait_for_load = true;
			eval(str);
			setTimeout("wait_for_load=false", 2000);
		}
	}
	var src_obj;
	var fromRMI=false, allowAct=false;
	function click(obj) {
		src_obj = document.getElementById(obj);
		if (!fromRMI) {allowAct=true; src_obj.onclick(); allowAct=false; return;}
		var str = src_obj.onclick.toString();
		//alert('te:' + src_obj.getAttribute('onclick'));
		//return str;
		str = str.replace(/([\w\W]*)(performAltActions\(this)([.]*)/gi,
			function (pre, str) {
				//alert('pre: ' + pre);
				//return('performAltActionsRMI(' + thread + ', document.getElementById("' + obj + '")');
				return '{performAltActionsRMI(document.getElementById("' + obj + '")';
			}
		);
		str = str.replace(/([\w\W]*)(LiMGuQEcKiDS\(this)([.]*)/gi,
			function (pre, str) {
				return '{XGOggsoSRnhK(document.getElementById("' + obj + '")';
			}
		);
		
		str = str.replace(/\['/gi, '[\"');
		str = str.replace(/'\]/gi, '\"]');
		var temp = 'function anonymous()'
		//str = str.substr(temp.length);
		//alert(str);
		//setTimeout("src_obj.onclick();", 2000);
		//src_obj.onclick();
		//eval(str);
		//alert('click:' + str);
		return str;
		
		
	}
	var wait_for_load = false;
	function jump_2_thrd(x1, x2, x3) {
		document.getElementById('msgdiv').style.display = 'none';
		wait_for_load = true;
		try {
			KVPSRddPexgP(x1, x2, x3);
		} catch(e) {
			jumpToThread(x1, x2, x3);
		}
		setTimeout("wait_for_load=false", 5000);
		
	}
	function start_pres() {
		//alert('here');
		var d = new Date();
		if (meeting_id > 0)
			if (isPresenter) {
				make_server_call('presenter/control_connect.aspx?meeting=' + meeting_id + '&action=reset');
				//make_server_call('presenter/controller_start.asp?meeting=' + meeting_id);
				//document.getElementById('comm').src = 'presenter/control_checkin.asp?meeting=' + meeting_id + '&d=' + d.valueOf();
				//document.getElementById('comm').src = '/webpower/presenter/control_connect.aspx?meeting=' + meeting_id + '&action=reset&d=' + d.valueOf();
			} else
				document.getElementById('comm').src = 'presenter/client_connect3.aspx?meeting=' + meeting_id + '&pos=0&d=' + d.valueOf();
	}
	function start_pres2() {
		alert('here');
		comm_available()
		var d = new Date();
		document.getElementById('comm').src = 'presenter/control_checkin.aspx?meeting=' + meeting_id + '&d=' + d.valueOf();
		make_server_call('presenter/control_connect.aspx?meeting=' + meeting_id + '&action=reset');
	}
	
	var comm_in_use = false;
	var comm_queue = new Array();
	function comm_available() {
		if (comm_queue.length == 0) comm_in_use = false;
		while(comm_queue.length > 0) {
			var d=new Date();
			var str=comm_queue.shift();
			add2d('Unqueuing and sending command ' + str + ' to server.', 'red');
			document.getElementById('comm2').src = str + '&d=' + d.valueOf();
		}
		
	}
	function make_server_call(str) {
		if (comm_in_use) {
				comm_queue.push(str);
				add2d('COMM in use, queueing command: ' + str, 'red');
			} else {
				comm_in_use = true;
				var d=new Date();
				setTimeout("document.getElementById('comm2').src = \"" + str + '&d=' + d.valueOf() + "\"", 10);
				add2d('Sending command ' + str + ' to server.', 'red');
			}
	}
	function end_meeting() {
			alert('This meeting has ended. This window will now close');
			window.close();
	}
	function comm_2_server(action) {
		//alert(action);
		if (isPresenter) {
			//add2d('Sending presentation Action to server: ' + action);
			make_server_call("presenter/control_connect.aspx?meeting=" + meeting_id + "&action=push&act=" + action);
		}
	}
	function thrd_2_server(thread) {
		if (isPresenter) {
			make_server_call("presenter/control_connect.aspx?meeting=" + meeting_id + "&action=push&thrd=" + thread);
		}
	}
	function add2d(str, col) {
		try {
			CmMvxRSMnFDY(str, col);
		} catch (e) {
			addToDebug(str, col);
		}
	}
	
/**********************************************************************/
/* Copyright 2004, Standpoint Technologies Inc. All rights reserved.  */
/*                                                                    */
/*       The code present here was designed and developed by          */
/*     Standpoint Technologies Inc. Any use of any part of this       */
/*            application is strictly prohibited.                     */
/*                                                                    */
/* For licensing, contact Gary Herron at Standpoint Technologies Inc. */
/*          www:              http://www.standpointtech.com           */
/*                                                                    */
/**********************************************************************/


