
<!-- Hide	

// remote access processor
// requests take the form (requestdata)
// where
// requestdata = the data associated with the command
//

var t;
var duration=260;   // milliseconds about a quarter second
var requestdata='';

// buffer=xlate("%%eq%%","=",buffer);
//
function xlate(patt,repl,buffer) {
var newstr='';
newstr=buffer.replace(patt,repl);
return newstr;
}

function parse(buffer) {
//alert('parse:'+buffer.valueOf());
var newstr='';
var newstr2='';
var separator="|";
re = /}{/gi;
newstr=buffer.replace(re,separator);
//alert('step1:'+newstr.valueOf());
len=newstr.length;
idx=0;
while(idx<len) {
	if (newstr.charAt(idx)=='{') {
		newstr2=newstr.substr(idx+1);
		break;
	} else {
		idx++;
	}
}
if (newstr2=='') {
return '';
}
//alert('step2:'+newstr2.valueOf());
len=newstr2.length;
while(len>0) {
	len--;
	if (newstr2.charAt(len)=='}') {
		newstr=newstr2.substr(0,len);
		break;
	}
}
//alert('step3:'+newstr.valueOf());

arrayOfStrings = newstr.split(separator)
return arrayOfStrings;
}

function ajaxFunction()
{
var xmlhttp;
if (window.XMLHttpRequest)
  {
//alert('1');
  // code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else if (window.ActiveXObject)
  {
//alert('2');
  // code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  stopUpdate();
  }
else
  {
  alert("Your browser does not support XMLHTTP!");
  stopUpdate();
  }

xmlhttp.onreadystatechange=function() {
    if(xmlhttp.readyState==4) {
        // --------------------------
        // process incoming commands:
        // --------------------------
        //
	stringarray=parse(xmlhttp.responseText);
        var target='';
	for (var i=0; i < stringarray.length; i++) {
//alert('stringarray='+stringarray[i]);
            nvarray=stringarray[i].split('=');
            nm=nvarray[0];
            vl=nvarray[1];
//alert('nm='+nm+',vl='+vl);
            if (nm=='cartid') {
                document.getElementById('cartid').value=vl;
                //document.getElementById('echotest1').value=vl;
                stopUpdate();
            }
            if (nm=='thepage') {
                document.getElementById('thepage').value=vl;
                //document.getElementById('echotest2').value=vl;
            }
            if (nm=='starttime') {
                document.getElementById('starttime').value=vl;
                //document.getElementById('echotest3').value=vl;
            }
            if (nm=='write') {  // write complete
                stopUpdate();
            }
            if (nm=='target') {
                target=vl;
            }
            if (nm=='output') {
                re=/\%\%equals\%\%/gi;
                vl=xlate(re,"=",vl);
                re=/\%\%quot\%\%/gi;
                vl=xlate(re,"\"",vl);
                re=/\%\%squo\%\%/gi;
                vl=xlate(re,"'",vl);
                re=/\%\%pound\%\%/gi;
                vl=xlate(re,"#",vl);
                re=/\%\%eoln\%\%/gi;
                vl=xlate(re,"",vl);
                re=/\%\%cr\%\%/gi;
                vl=xlate(re,"",vl);
                re=/\%\%newline\%\%/gi;
                vl=xlate(re,"",vl);
                re=/\%\%bs\%\%/gi;
                vl=xlate(re,"",vl);
                re=/\|/gi;
                vl=xlate(re,"/",vl);


                agawebs_fade_out(target);
                document.getElementById(target).innerHTML=vl;
                agawebs_fade_in(target);

//alert('output to '+target+',vl='+vl);
                stopUpdate();
            }
	}
    }
}

    if (requestdata!='') {    // something to do
        // build URL
        urlstart=new String(window.location.href);
        arraywork = urlstart.split('/');
        thehttp=arraywork[0];
        theurl=arraywork[2];
        additionalurl='/';
        var urllength=arraywork.length-1;   // subtract one for the file name
        for (var i=3; i < urllength; i++) {
            additionalurl+=arraywork[i];
            additionalurl+='/';
        }
        thefullurl=thehttp+"//"+theurl+additionalurl+"rap.php?{"+requestdata+"}";
//alert('url='+thefullurl);
        requestdata='';
        // send command
        xmlhttp.open("GET",thefullurl,true);
        xmlhttp.send(null);
    }   // something to do

}

function timedUpdate()
{
ajaxFunction();
t=setTimeout("timedUpdate()",duration);
}

// NO timedUpdate();	// first call

function stopUpdate()
{
clearTimeout(t);
}

function sendRequest(incartid,inrequestid,inrequestdata) {
    stopUpdate();
    requestdata='{cartid='+incartid+'}{requestid='+inrequestid+'}{requestdata='+inrequestdata+'}';
    timedUpdate();
}

// show -->

