//alert("included /includes/rpc_support.js");
// RPC functionality script - for iframe posted forms & querystring remote submission.
// version 325.23 (not really, but feels like it)
// handles pc ie 5+, mozilla, netscape 6.2+; mac ie 5.1+, safari

//There const values must match those detailed in the class "au.gov.nsw.iplan.basix.taglib.Index"
PT_NONE = 0;
PT_LOCAL = 1;
PT_PROJECT = 2;
PT_ALL = 3;

IT_NONE = 0;
IT_TEMP = 1;
IT_PROJECT = 2;
IT_BUILDING = 3;
IT_CENTRALISED_AREA = 4;
IT_COMMON_AREA = 5;
IT_DWELLING = 6;

rpcServer = "/rpc_server.jsp";

var rpcKeepAliveInterval = 600000;

rpcWaitText = "The server is currently busy, please wait until the pending operation is completed before continuing."; 

rpcRequestPending = false;
rpcRequestDirty = false;
rpcCalcAllValues = false;
rpcException = false;
rpcNeedsUpdate = false;
rpcErrors = "";
rpcWarnings = "";
rpcWaterScore = "";
rpcThermalScore = "";
rpcEnergyScore = "";
rpcEnergyTarget = "";
rpcDIYheatingScore = "";
rpcDIYcoolingScore = "";
rpcDIYheatingMaxAllowable = "";
rpcDIYcoolingMaxAllowable = "";
rpcDwellingIndex = -1;
rpcDwellingList = "";

rpcPara_Command = "";
rpcPara_CentralisedArea = -1;
rpcPara_CentralisedAreaList = "";
rpcPara_CommonArea = -1;
rpcPara_CommonAreaList = "";
rpcPara_Dwelling = -1;
rpcPara_DwellingList = "";
rpcPara_IndexType = 0;
rpcPara_ProcessType = 0;
rpcPara_IndexName = "";
rpcPara_IndexGroup = "";
rpcPara_SubErrorRange = "";
rpcPara_SubWarningRange = "";
rpcPara_ProcessEmptyValues = false;

// returns a querystring with optional parameters for the rpc call to the server.
// it gets added to the form's action in buildForm function.
function buildQueryString() {
	//Add optional parameters to query string
    var qs = "";
	qs += '?rpcPara_Command=' + rpcPara_Command;

	if (rpcPara_CentralisedArea > 0)
		qs += '&rpcPara_CentralisedArea=' + rpcPara_CentralisedArea;
	if (rpcPara_CentralisedAreaList.length > 0)
		qs += '&rpcPara_CentralisedAreaList=' + rpcPara_CentralisedAreaList;
	if (rpcPara_CommonArea > 0)
		qs += '&rpcPara_CommonArea=' + rpcPara_CommonArea;
	if (rpcPara_CentralisedAreaList.length > 0)
		qs += '&rpcPara_CentralisedAreaList=' + rpcPara_CentralisedAreaList;
	if (rpcPara_Dwelling > 0)
		qs += '&rpcPara_Dwelling=' + rpcPara_Dwelling;
	if (rpcPara_DwellingList.length > 0)
		qs += '&rpcPara_DwellingList=' + rpcPara_DwellingList;
	if (rpcPara_IndexType > 0)
		qs += '&rpcPara_IndexType=' + rpcPara_IndexType;
	if (rpcPara_ProcessType > 0)
		qs += '&rpcPara_ProcessType=' + rpcPara_ProcessType;
	if (rpcPara_IndexName.length > 0)
		qs += '&rpcPara_IndexName=' + rpcPara_IndexName;
	if (rpcPara_IndexGroup.length > 0)
		qs += '&rpcPara_IndexGroup=' + rpcPara_IndexGroup;
	if (rpcPara_SubErrorRange.length > 0)
		qs += '&rpcPara_SubErrorRange=' + rpcPara_SubErrorRange;
	if (rpcPara_SubWarningRange.length > 0)
		qs += '&rpcPara_SubWarningRange=' + rpcPara_SubWarningRange;
	if (rpcPara_ProcessEmptyValues.length > 0)
		qs += '&rpcPara_ProcessEmptyValues=' + rpcPara_ProcessEmptyValues;

	//Add client functions
	try {
		qs += add_client_functions();
	} catch(exception) {
		//Don't worry
	}

	return qs;
}

// an expansion on the document.createElement functionality of DOM to allow the document.createElementNS function
// integration if it is required by the browser client instead of simply using document.createElement function.
function myCreateElement(myDoc, myElement) {
    // for netscape which needs the named space (NS) stipulated.
    if (typeof myDoc.createElementNS != 'undefined') {
        return myDoc.createElementNS('http://www.w3.org/1999/xhtml', myElement);
    }
    if (typeof myDoc.createElement != 'undefined') {
        return myDoc.createElement(myElement);
    }
    return false;
}

// This function builds a form based on the form reference parameter in the document space provided by the parameter myDoc.
// callToServer function calls this function with myDoc referencing the dynamic iframe it created.
// buildForm then submits the built form.
function buildForm(myDoc, myForm, iframe) {
    // build "post" method form..
	//alert("building form");
	window.setTimeout("rpc_keep_alive()", rpcKeepAliveInterval); //Restart pulse

    var bodyRef = myDoc.body;
    var myQueryString = buildQueryString();  // get the querystring of all the other rpc required parameters to be passed in the form's action.

    var strutsAction = false;
    
    
    if(parent.currentPage == '5.1.4'){
    	strutsAction = true;
    	rpcServer = "/detached.construction.action"
      	myQueryString += "&rpcCalcConstruction=true";
    }
    
    
	//create a form
	if (iframe.contentDocument || (mac && ie)) {
        // if mozilla based...
        // build form..
    	myDoc.write("Submitting form"); //required for submitting form. probably for delay or establishment of body reference.
	    myDoc.write("<form name='basix_form' action='" + rpcServer + myQueryString + "' target='RSIFrame' method='post'>");

		if (!(mac && ie)) {
			myDoc.write("</form>");
			//alert("finished off form");
		}
    } else {
        // if ie based...
        if (!bodyRef) {
            setTimeout('callToServer()', 10);
            return false;
        }
        // build form..
        var aForm = myCreateElement(myDoc, "form");
      	aForm.setAttribute("action", rpcServer + myQueryString);
    	aForm.setAttribute("id", "basix_form");
        aForm.setAttribute("method", "post");
    	aForm.setAttribute("name", "basix_form");
    	bodyRef.appendChild(aForm);
    }
	
	var myInput;
    var found;

    // for each form field add to form in iframe..
	   	for (var i=0; i < myForm.elements.length; i++) {
	        found = false;
			if (myForm.elements[i].name != '') {
				if (myForm.elements[i].value == 'on') {
					if (myForm.elements[i].checked) {
						found = true;
					}
				} else {
					//See if it's a radio button
					if (myForm.elements[i].name.indexOf('_rb') > -1) {
						//is, only send back the checked="checked" one
						if (myForm.elements[i].checked)
	                        found = true;
					} else if(strutsAction) { 
						if (myForm.elements[i].type == "radio" || myForm.elements[i].type == "checkbox") {
							//is, only send back the checked="checked" one
							if (myForm.elements[i].checked) {
		                        found = true;
							}
						} else {
							found = true;
						}
					} else {
	                    found = true;
					}
				}
			}
	        if (found) {
				if (mac && ie) {
				    myDoc.write("<input type='text' name='" + myForm.elements[i].name + "' value='" + myForm.elements[i].value + "' />");
				} else {
		            // create hidden form field
		    		myInput = myCreateElement(myDoc, 'input'); // mac ie 5.1 crashes here.
		    		myInput.setAttribute("type", "hidden");
		    		myInput.setAttribute("id", myForm.elements[i].id);
		    		myInput.setAttribute("name", myForm.elements[i].name);
		            myInput.setAttribute("value", myForm.elements[i].value);
		        	myDoc.forms[0].appendChild(myInput);
				}
			} else {
				//alert("not found");
			}
	   	}

    
    
	if (mac && ie) {
		myDoc.write("</form>");
	}
	myDoc.close();
	
	if (myDoc.forms[0]) {
		myDoc.forms[0].submit(true);  // good for mozilla firefox & netscape 7 & safari & PC ie6 & PC ie5.5 & PC ie5 and now mac ie5.1+
	} else {
		alert("no form to submit");
	}
	return true;

}

function cleanUpIframes(myIFrame) {

	if (frames.length > 0) {
	
		//alert("setting iframe");
		//myIFrame = document.getElementById("RSIFrame");
		ifr = document.getElementById('RSIFrame');
	    	ifr.parentNode.removeChild(ifr);
	}
}

var iframe; // our IFrame object

// This function builds an invisible iframe in the current document it then calls buildForm function above
function callToServer(theFormName) {
	
	rpcRequestPending = true;
	document.body.style.cursor = 'wait';
	//waitDiv(true);

	if (!(document.createElementNS || document.createElement) || !document.createElement) {return true};
	var IFrameDoc;
	//var URL = 'rpc_test.jsp' + buildQueryString();

	cleanUpIframes(iframe);
	//alert(iframe);
	if (!iframe && (document.createElementNS || document.createElement)) {
		// create the IFrame and assign a reference to the
		// object to our global variable IFrameObj.
		// this will only happen the first time
		// callToServer() is called
		try {
    		var dv = myCreateElement(document, 'div');
    		dv = document.body.appendChild (dv);
    		dv.innerHTML = '<iframe id="RSIFrame" name="RSIFrame" style="width: 0px; height: 0px; border: none;"></iframe>';
    		var iframe = document.getElementById("RSIFrame");
			//alert("created IFRAME " + dv.innerHTML);
		} catch(exception) {
			alert("exception");
			return true;
		}
	} else {
		return true;
	}
	if (navigator.userAgent.indexOf('Gecko') != -1 && !iframe.contentDocument) {
		// we have to give NS6 a fraction of a second
		// to recognize the new IFrame
		setTimeout('callToServer()',10);
		return false;
	}

	if (iframe.contentDocument) {
		//alert("mozilla based");
		IFrameDoc = iframe.contentDocument;
	} else if (iframe.contentWindow) {
		// For IE5.5 and IE6
		IFrameDoc = iframe.contentWindow.document;
	} else if (iframe.document) {
		// For IE5 and mac
    	IFrameDoc = document.frames['RSIFrame'].document;
	} else {
		return true;
	}
	// wait until the document reference has been confirmed.
	if (!IFrameDoc) {
		setTimeout('callToServer()', 10);
		return false;
	}

	IFrameDoc.write("form created");  // needed to establish the IFrameDoc, think be due to dynamically creating the body element or something..

	if (!(buildForm(IFrameDoc, document.forms[theFormName], iframe))) {
        // need to remove/close first iframe...
		//alert("closing first iframe");
        iframe.close();
        return false;
    }
	return false;

}

function callToServerNoForm() {
	rpcRequestPending = true;
	document.body.style.cursor = 'wait';
	//waitDiv(true);
	if (!document.createElement) {return true};
		var IFrameDoc;
		var myURL = rpcServer + buildQueryString() + "&action=rpccall";
		if (!iframe && document.createElement) {
			// create the IFrame and assign a reference to the
			// object to our global variable IFrameObj.
			// this will only happen the first time
			// callToServer() is called
			try {
				var tempIFrame=document.createElement('iframe');
				tempIFrame.setAttribute('id','RSIFrame');
				tempIFrame.style.border='0px';
				tempIFrame.style.width='0px';
				tempIFrame.style.height='0px';
				IFrameObj = document.body.appendChild(tempIFrame);

				if (document.frames) {
					// this is for IE5 Mac, because it will only
					// allow access to the document object
					// of the IFrame if we access it through
					// the document.frames array
					IFrameObj = document.frames['RSIFrame'];
				}
			} catch(exception) {
				// This is for IE5 PC, which does not allow dynamic creation
				// and manipulation of an iframe object. Instead, we'll fake
				// it up by creating our own objects.
				iframeHTML='<iframe id="RSIFrame" style="';
				iframeHTML+='border:0px;';
				iframeHTML+='width:0px;';
				iframeHTML+='height:0px;';
				iframeHTML+='"><\/iframe>';
				document.body.innerHTML+=iframeHTML;
				IFrameObj = new Object();
				IFrameObj.document = new Object();
				IFrameObj.document.location = new Object();
				IFrameObj.document.location.iframe = document.getElementById('RSIFrame');
				IFrameObj.document.location.replace = function(location) {
				this.iframe.src = location;
			}
		}
	}

	if (navigator.userAgent.indexOf('Gecko') !=-1 && !IFrameObj.contentDocument) {
		// we have to give NS6 a fraction of a second
		// to recognize the new IFrame
		setTimeout('callToServerNoForm()',10);
		return false;
	}

	if (IFrameObj.contentDocument) {
		IFrameDoc = IFrameObj.contentDocument;
	} else if (IFrameObj.contentWindow) {
		// For IE5.5 and IE6
		IFrameDoc = IFrameObj.contentWindow.document;
	} else if (IFrameObj.document) {
		// For IE5
		IFrameDoc = IFrameObj.document;
	} else {
		return true;
	}

	IFrameDoc.location.replace(myURL);
	return false;
}

function rpc_server_call() {
	try {
		rpcNeedsUpdate = false;
		document.basix_form.action.value = "rpccall";
		callToServer("basix_form");
		document.basix_form.action.value = "#";
	} catch(exception) {
		alert("rpc server call failed!");
	}
}

function retry_rpc() {
	//alert("need to retry");
	window.setTimeout("rpc_server_call()", 5000);
}

function exception_rpc() {
	showErrorAlert('', 'An error occured while your results were being updated, please contact support.', '', '');
}

function flag_change() {
	rpcNeedsUpdate = true;
}

/*
Performs an "apply_all" function with optional parameters (if parameter not required simply pass an empty string)
Parameters are :-
indexType: Defines the index type (see btl:index, indextype);
processType: Defines the process type (see btl:index, processtype);
indexGroup: The group to use in this call
subErrorRange: The sub error range to use, the errors will be returned via rpcErrors
subWarningRange: The sub warning range to use, the warnings will be returned via rpcWarnings
subScoreRange: The sub score range to use, the score will be returned via rpcScore
*/

function rpc_apply_all_ex(processType, indexGroup, subErrorRange, subWarningRange) {
	//Check to make sure the rpc call is not busy
	if (rpcRequestPending) {
		window.setTimeout("rpc_apply_all_ex(" + processType + ", '" + indexGroup + "', '" + subErrorRange + "', '" + subWarningRange + "')", 100); //Retry
		return;
	}
	
	//Set parameters for this call
	rpcPara_Command = "calc";
	rpcPara_CentralisedArea = -1;
	rpcPara_CentralisedAreaList = "";
	rpcPara_CommonArea = -1;
	rpcPara_CommonAreaList = "";
	rpcPara_Dwelling = -1;
	rpcPara_DwellingList = "";
	rpcPara_IndexType = 0;
	rpcPara_ProcessType = processType;
	rpcPara_IndexName = "";
	rpcPara_IndexGroup = indexGroup;
	rpcPara_SubErrorRange = subErrorRange;
	rpcPara_SubWarningRange = subWarningRange;
	rpcPara_ProcessEmptyValues = false;

	//Now process
	rpc_server_call();
}

function rpc_apply_all(progBar) {
	//Check to make sure the rpc call is not busy
	if (progBar) {
		calcState();
	} else {
		waitDiv(true);
	}
	
	if (rpcRequestPending) {
		window.setTimeout("rpc_apply_all(" + progBar + ")", 100); //Retry
		return;
	}
	
	//Set calc all flag
	rpcCalcAllValues = true;
	
	//Set parameters for this call
	rpcPara_Command = "calc";
	rpcPara_CentralisedArea = -1;
	rpcPara_CentralisedAreaList = "";
	rpcPara_CommonArea = -1;
	rpcPara_CommonAreaList = "";
	rpcPara_Dwelling = -1;
	rpcPara_DwellingList = "";
	rpcPara_IndexType = IT_NONE;
	rpcPara_ProcessType = PT_ALL;
	rpcPara_IndexName = "";
	rpcPara_IndexGroup = "";
	rpcPara_SubErrorRange = "";
	rpcPara_SubWarningRange = "";
	rpcPara_ProcessEmptyValues = false;

	//Now process
	rpc_server_call();
}

function rpc_apply_all_validate(subErrorRange) {
	//Check to make sure the rpc call is not busy
	waitDiv(true);
	
	if (rpcRequestPending) {
		window.setTimeout("rpc_apply_all_validate('" + subErrorRange + "')", 100); //Retry
		return;
	}
	
	//Set calc all flag
	rpcCalcAllValues = true;
	
	//Set parameters for this call
	rpcPara_Command = "calc";
	rpcPara_CentralisedArea = -1;
	rpcPara_CentralisedAreaList = "";
	rpcPara_CommonArea = -1;
	rpcPara_CommonAreaList = "";
	rpcPara_Dwelling = -1;
	rpcPara_DwellingList = "";
	rpcPara_IndexType = IT_NONE;
	rpcPara_ProcessType = PT_ALL;
	rpcPara_IndexName = "";
	rpcPara_IndexGroup = "";
	rpcPara_SubErrorRange = subErrorRange;
	rpcPara_SubWarningRange = "";
	rpcPara_ProcessEmptyValues = false;

	//Now process
	rpc_server_call();
}

function rpc_apply_local() {
	//Check to make sure the rpc call is not busy

	if (rpcRequestPending) {
		window.setTimeout("rpc_apply_local()", 100); //Retry
		return;
	}
	
	//Set calc all flag
	rpcCalcAllValues = true;
	
	//Set parameters for this call
	rpcPara_Command = "calc";
	rpcPara_CentralisedArea = -1;
	rpcPara_CentralisedAreaList = "";
	rpcPara_CommonArea = -1;
	rpcPara_CommonAreaList = "";
	rpcPara_Dwelling = -1;
	rpcPara_DwellingList = "";
	rpcPara_IndexType = IT_NONE;
	rpcPara_ProcessType = PT_LOCAL;
	rpcPara_IndexName = "";
	rpcPara_IndexGroup = "";
	rpcPara_SubErrorRange = "";
	rpcPara_SubWarningRange = "";
	rpcPara_ProcessEmptyValues = false;

	//Now process
	rpc_server_call();
}

function rpc_apply_local_validate(subErrorRange) {
	//Check to make sure the rpc call is not busy
	//alert(rpcRequestPending);
	//if (rpcRequestPending) {
	//	window.setTimeout("rpc_apply_local_validate('" + subErrorRange + "')", 100); //Retry
	//	return;
	//}
	
	//Set calc all flag
	rpcCalcAllValues = true;
	
	//Set parameters for this call
	rpcPara_Command = "calc";
	rpcPara_CentralisedArea = -1;
	rpcPara_CentralisedAreaList = "";
	rpcPara_CommonArea = -1;
	rpcPara_CommonAreaList = "";
	rpcPara_Dwelling = -1;
	rpcPara_DwellingList = "";
	rpcPara_IndexType = IT_NONE;
	rpcPara_ProcessType = PT_LOCAL;
	rpcPara_IndexName = "";
	rpcPara_IndexGroup = "";
	rpcPara_SubErrorRange = subErrorRange;
	rpcPara_SubWarningRange = "";
	rpcPara_ProcessEmptyValues = false;
	//Now process
	rpc_server_call();
}

function rpc_apply_all_dwelling(dwelling) {
	//Check to make sure the rpc call is not busy
	if (rpcRequestPending) {
		window.setTimeout("rpc_apply_all_dwelling(" + dwelling + ")", 100); //Retry
		return;
	}
	
	//Set parameters for this call
	rpcPara_Command = "calc";
	rpcPara_CentralisedArea = -1;
	rpcPara_CentralisedAreaList = "";
	rpcPara_CommonArea = -1;
	rpcPara_CommonAreaList = "";
	rpcPara_Dwelling = dwelling;
	rpcPara_DwellingList = "";
	rpcPara_IndexType = IT_NONE;
	rpcPara_ProcessType = PT_NONE;
	rpcPara_IndexName = "";
	rpcPara_IndexGroup = "";
	rpcPara_SubErrorRange = "";
	rpcPara_SubWarningRange = "";
	rpcPara_ProcessEmptyValues = false;

	//Now process
	rpc_server_call();
}

function rpc_save_data() {
	//Check to make sure the rpc call is not busy
	waitDiv(true);
	
	if (rpcRequestPending) {
		window.setTimeout("rpc_save_data()", 100); //Retry
		return;
	}
	
	//Set parameters for this call
	rpcPara_Command = "save";
	rpcPara_CentralisedArea = -1;
	rpcPara_CentralisedAreaList = "";
	rpcPara_CommonArea = -1;
	rpcPara_CommonAreaList = "";
	rpcPara_Dwelling = -1;
	rpcPara_DwellingList = "";
	rpcPara_IndexType = IT_NONE;
	rpcPara_ProcessType = PT_NONE;
	rpcPara_IndexName = "";
	rpcPara_IndexGroup = "";
	rpcPara_SubErrorRange = "";
	rpcPara_SubWarningRange = "";
	rpcPara_ProcessEmptyValues = false;

	//Now process
	rpc_server_call();
	
}

function rpc_submit_data() {
	//Check to make sure the rpc call is not busy
	if (rpcRequestPending) {
		window.setTimeout("rpc_submit_data()", 100); //Retry
		return;
	}
	
	//Set parameters for this call
	rpcPara_Command = "submit";
	rpcPara_CentralisedArea = -1;
	rpcPara_CentralisedAreaList = "";
	rpcPara_CommonArea = -1;
	rpcPara_CommonAreaList = "";
	rpcPara_Dwelling = -1;
	rpcPara_DwellingList = "";
	rpcPara_IndexType = IT_NONE;
	rpcPara_ProcessType = PT_NONE;
	rpcPara_IndexName = "";
	rpcPara_IndexGroup = "";
	rpcPara_SubErrorRange = "";
	rpcPara_SubWarningRange = "";
	rpcPara_ProcessEmptyValues = false;

	//Now process
	rpc_server_call();
}

function rpc_refresh_dwellings(dwellingList) {
	//Check to make sure the rpc call is not busy
	if (rpcRequestPending) {
		window.setTimeout("rpc_refresh_dwellings('" + dwellingList + "')", 100); //Retry
		return;
	}
	
	//Set parameters for this call
	rpcPara_Command = "refresh_dwellings";
	rpcPara_CentralisedArea = -1;
	rpcPara_CentralisedAreaList = "";
	rpcPara_CommonArea = -1;
	rpcPara_CommonAreaList = "";
	rpcPara_Dwelling = -1;
	rpcPara_DwellingList = dwellingList;
	rpcPara_IndexType = IT_NONE;
	rpcPara_ProcessType = PT_NONE;
	rpcPara_IndexName = "";
	rpcPara_IndexGroup = "";
	rpcPara_SubErrorRange = "";
	rpcPara_SubWarningRange = "";
	rpcPara_ProcessEmptyValues = false;

	//Now process
	rpc_server_call();
}

function rpc_restore_index_refresh_dwellings(dwellingList) {
	//Check to make sure the rpc call is not busy
	if (rpcRequestPending) {
		window.setTimeout("rpc_restore_index_refresh_dwellings('" + dwellingList + "')", 100); //Retry
		return;
	}

	//Set parameters for this call
	rpcPara_Command = "restore_index_refresh_dwellings";
	rpcPara_CentralisedArea = -1;
	rpcPara_CentralisedAreaList = "";
	rpcPara_CommonArea = -1;
	rpcPara_CommonAreaList = "";
	rpcPara_Dwelling = -1;
	rpcPara_DwellingList = dwellingList;
	rpcPara_IndexType = IT_NONE;
	rpcPara_ProcessType = PT_NONE;
	rpcPara_IndexName = "";
	rpcPara_IndexGroup = "";
	rpcPara_SubErrorRange = "";
	rpcPara_SubWarningRange = "";
	rpcPara_ProcessEmptyValues = false;
	
	//Now process
	rpc_server_call();
}

function rpc_update_unit_names() {
	//Check to make sure the rpc call is not busy
	if (rpcRequestPending) {
		window.setTimeout("rpc_get_water_score()", 100); //Retry
		return;
	}
	
	rpcPara_Command = "update_unit_names";
	rpcPara_CentralisedArea = -1;
	rpcPara_CentralisedAreaList = "";
	rpcPara_CommonArea = -1;
	rpcPara_CommonAreaList = "";
	rpcPara_Dwelling = -1;
	rpcPara_DwellingList = "";
	rpcPara_IndexType = IT_NONE;
	rpcPara_ProcessType = PT_NONE;
	rpcPara_IndexName = "";
	rpcPara_IndexGroup = "";
	rpcPara_SubErrorRange = "";
	rpcPara_SubWarningRange = "";
	rpcPara_ProcessEmptyValues = false;

	//Now process
	rpc_server_call();
}

function rpc_keep_alive() {
	rpcPara_Command = "keep_alive";
	//Now process
	callToServerNoForm();
	window.setTimeout("rpc_keep_alive()", rpcKeepAliveInterval); //Restart pulse
}
//Start keep alive pulse
window.setTimeout("rpc_keep_alive()", rpcKeepAliveInterval); //Start pulse
