var IFrameObj; // our IFrame object

function callToServer(theFormName, URLpar) {
	if (!document.createElement) {return true};
    var IFrameDoc;
    var URL = URLpar + encodeURI(buildQueryString(theFormName));
	
	if (!IFrameObj && document.createElement) {
		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) {
			IFrameObj = document.frames['RSIFrame'];
		}
	}
	
	if (navigator.userAgent.indexOf('Gecko') !=-1 && !IFrameObj.contentDocument) {
		setTimeout('callToServer("'+theFormName+'","'+URLpar+'")',10);
		return false;
	}

	if (IFrameObj.contentDocument) {
		// For NS6
		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(URL);
	return;
}

function buildQueryString(theFormName) {
  theForm = document.forms[theFormName];
  var qs = '';
  for (e=0;e<theForm.elements.length;e++) {
    if (theForm.elements[e].name!='') {
      qs+=(qs=='')?'?':'&';
      qs+=theForm.elements[e].name+'='+theForm.elements[e].value;
    }
  }
  return qs;
}
