// GLOBAL VARIABLES
var rsSize = 0;
var rsMaxSize = 10000;
var rsRequestList = new Array();
var rsBrowser = checkBrowser();
var responseID = 0
ST_SUCCESS = 1
ST_FAIL = 0
ST_PENDING = -1
var request = null
function rsRequestObj( requestID ){
this.id = requestID;
this.busy = true;
this.callback = null;
this.errorcallback = null;
this.container = createProxy( requestID );
this.return_value = '';
this.status = ST_PENDING;
this.message = '';
this.GET = requestGET;
this.getResult = requestGetResult;
this.requestList = new Array;
}
function createProxy( proxyName ){
var container;
switch( rsBrowser ) {
case 'NS47':
container = new Layer(100);
container.name = proxyName;
container.visibility = 'hidden';
container.clip.width = 100;
container.clip.height = 100;
break;
case 'IE':
document.body.insertAdjacentHTML( "afterBegin", '' );
var span = document.all( "SPAN" + proxyName );
var html = '';
span.innerHTML = html;
span.style.display = 'none';
container = window.frames[ proxyName ];
break;
case 'NS60':
var span = document.createElement('SPAN');
span.id = "SPAN" + proxyName;
document.body.appendChild( span );
var iframe = document.createElement('IFRAME');
iframe.name = proxyName;
span.appendChild( iframe );
container = iframe;
container.style.visibility='hidden'
container.width=0;
container.height=0;
break;
}
return container;
}
function requestGET( rsPage, func, parms ){
var URL = rsPage;
URL += "?C=" + this.id;
if (func != null){
URL += "&F=" + escape(func);
if (parms != null){
if (typeof(parms) == "string"){
URL += "&P0=[" + escape(parms+'') + "]";
}else{
for( var i=0; i < parms.length; i++ ){
URL += "&P" + i + "=[" + escape(parms[i]+'') + "]";
}
}
}
}
var d = new Date();
URL += "&U=" + d.getTime();
//document.write(URL)
switch( rsBrowser ){
case 'NS47':
this.container.src = URL;
debug('Remote URL',URL)
break;
case 'IE':
this.container.location.href = URL;
break;
case 'NS60':
this.container.src = '';
this.container.src = URL;
break;
}
}
function requestGetResult(){
switch( rsBrowser ) {
case 'NS47':
return this.container.document.forms['rs_Form'].elements['rs_Result'].value;
case 'IE':
return this.container.document.forms['rs_Form']['rs_Result'].value;
case 'NS60':
return window.frames[this.container.name].document.forms['rs_Form']['rs_Result'].value;
}
}
function rsGetRequestID(){
var requestObj;
for (var i = 1; i <= rsSize; i++){
requestObj = rsRequestList[ 'rs' + i ];
if ( !requestObj.busy ){
requestObj.busy = true;
return requestObj.id;
}
}
if ( rsSize <= rsMaxSize ){
var requestID = "rs" + (rsSize + 1);
rsRequestList[ requestID ] = new rsRequestObj( requestID );
rsSize++;
return requestID;
}else {
rsError("-1","Error: request pool full");
return null;
}
}
function RSExecute( rspage, func, parms, callback, ecb,visibility ){
var requestObj = rsRequestList[ rsGetRequestID() ];
if(typeof(callback)!='undefined')
requestObj.callback = callback
else
requestObj.callback = null;
if(typeof(ecb)!= 'undefined')
requestObj.errorcallback = ecb
else
requestObj.errorcallback = null;
requestObj.GET( rspage, func, parms );
}
function rsLoaded( requestID ){
var requestObj = rsRequestList[ requestID ];
if(typeof(requestObj) == 'undefined'){
rsError(requestID + ' Unknown request id.');
return;
}
requestObj.return_value = rsUnescape( requestObj.getResult())
requestObj.status = ST_SUCCESS
requestObj.message = "Method Executed successfully"
if(typeof(requestObj.callback) == "function")
requestObj.callback(requestObj);
else
return(requestObj.return_value);
requestObj.callback = null;
requestObj.busy = false;
}
function rsError( requestID, str ){
var request = rsRequestList[ requestID ]
if(request.errorcallback != null)
request.errorcallback("\nRemote Scripting ERROR:\n" + unescape(str))
else
alert(unescape(str))
rsRequestList[ requestID ].busy = false
}
function escapeQuote( thing ){
return thing.replace(/'"'/g, '\\"');
}
function rsUnescape( str ){
return str.replace( /\\\//g, "/" );
}
function checkBrowser(){
if (document.layers) return "NS47";
if (document.all) return "IE";
if (document.getElementById) return "NS60";
return "OTHER";
}
var timestamp = 0
function debug(label, value) {
var funcName = debug.caller.toString()
funcName = funcName.substring(10, funcName.indexOf(")") + 1)
var msg = "In " + funcName + ": " + label + "=" + value
var now = new Date()
var elapsed = now - timestamp
if (elapsed < 10000) {
msg += " (" + elapsed + " msec)"
}
timestamp = now
if(!document.all)
java.lang.System.out.println(msg)
}