var autoID = 1;
function RPCFrame(targetWindow) {
	this.ID = autoID++;
	this.parent = targetWindow;
	if ((window.navigator.appVersion.search("MSIE 5.0") != -1) && (navigator.platform.indexOf('Mac')==-1)) {
		var newFrameHTML = "<iframe id='iframe"+this.ID+"' style='position:absolute;top:300px;display:none;border:0px;width:400px;height:200px;'></iframe>";
		targetWindow.document.body.innerHTML += newFrameHTML;
		this.HTMLObject = targetWindow.document.getElementById('iframe'+this.ID);
	} else {
		var newFrame = document.createElement("iframe");
		newFrame.setAttribute("id", "iframe"+this.ID);
		newFrame.style.position = "absolute";
		newFrame.style.border = "0px";
		newFrame.style.width = "0px";
		newFrame.style.height = "0px";
		this.HTMLObject = targetWindow.document.body.appendChild(newFrame);
	}
	return this;
}
RPCFrame.prototype.setLocation = function (newURL) {
	if (this.HTMLObject.contentDocument) {
		this.HTMLObject.contentDocument.location.replace(newURL);
	} else if (this.HTMLObject.contentWindow) {
		this.HTMLObject.contentWindow.document.location.replace(newURL);
	} else if (this.HTMLObject.document) {
		this.HTMLObject.src = newURL;
	}
}
RPCFrame.prototype.getDocument = function () {
	if (this.HTMLObject.contentDocument) {
		return this.HTMLObject.contentDocument;
	} else if (this.HTMLObject.contentWindow) {
		return this.HTMLObject.contentWindow.document;
	} else if (this.HTMLObject.document) {
		if (navigator.platform.indexOf('Mac') != -1) {
			return this.parent.document.frames["iframe"+this.ID].document;
		} else {
			return this.parent.frames["iframe"+this.ID].document;
		}
	}
}
RPCFrame.prototype.getHTMLObject = function (id) {
	return this.getDocument().getElementById(id);
}
