var req2;
var myNextAction2;
var myFutureActions2;
var myActionURL2;
var myActionDIV2;
var delimiterPosition2;

function Left2(str2, n2){
	if (n2 <= 0)
	    return "";
	else if (n2 > String(str2).length)
	    return str2;
	else
	    return String(str2).substring(0,n2);
}
function Right2(str2, n2){
    if (n2 <= 0)
       return "";
    else if (n2 > String(str2).length)
       return str2;
    else {
       var iLen2 = String(str2).length;
       return String(str2).substring(iLen2, iLen2 - n2);
    }
}

function updateDIV2(myActions2) {
	//alert(myActions2);
	
	//myActions format: actionURL~actionORSC|actionURL~actionORSC|actionURL~actionORSC|
	
	//alert(myActions2);
	myActionsArray2 = myActions2.split("|");
	myNextAction2 = myActionsArray2[0];
	//alert("myNextAction:"+myNextAction2);

	myFutureActions2 = Right2(myActions2,myActions2.length-myNextAction2.length-1)
	alert("myFutureAction:"+myFutureActions2);

	myActionArray2 = myNextAction2.split("~");
	myActionURL2 = myActionArray2[0];
	myActionDIV2 = myActionArray2[1];
//	alert(myActionURL+" : "+myActionDIV2);

	req2 = false;

    // branch for native XMLHttpRequest object
    if(window.XMLHttpRequest && !(window.ActiveXObject)) {
    	try {
			req2 = new XMLHttpRequest();
        } catch(e) {
			req2 = false;
        }
    // branch for IE/Windows ActiveX version
    } else if(window.ActiveXObject) {
       	try {
        	req2 = new ActiveXObject("Msxml2.XMLHTTP");
      	} catch(e) {
        	try {
          		req2 = new ActiveXObject("Microsoft.XMLHTTP");
        	} catch(e) {
          		req2 = false;
        	}
		}
    }
	if(req2) {
    //alert(req.readyState);
    myRandomNumber2 = parseInt(Math.random()*999999999);
		req2.onreadystatechange = replaceDIVcontent2;
		//alert(myActionURL + "&rand=" + myRandomNumber);
		req2.open("GET", myActionURL2 + "&rand=" + myRandomNumber2, true);
		req2.send("");

	}
}



function replaceDIVcontent2() 
	{
  // only if req shows "loaded"
  //alert(req.readyState);
  if(req2.readyState == 4) 
  	{
    // only if "OK"
		//alert(req2.statusText);
    if(req2.status == 200) 
    	{
			//alert("hi");
			var myText2 = req2.responseText;
			//alert(myText2);
			//document.getElementById('testtarget').innerHTML = myText2;
			document.getElementById(myActionDIV2).innerHTML = myText2;
			if (myFutureActions2.length>6)
				{
				//alert(myFutureActions);
				updateDIV2(myFutureActions2);
				}
    	}
    else 
    	{
			alert("There was a problem retrieving the data:\n" +
			req2.statusText);
    	}
  	}
	}

