function showhide(name){
	if (document.layers) {
		var div=document.layers[name];
		if (div.visibility=="hide") {
			div.visibility="show";
			div.top = 20 + window.pageYOffset;
		} else {
			div.visibility="hide";
		}
	} else {
		var div=document.getElementById(name);
		if (div.style.visibility=="hidden") {
			div.style.visibility="visible";
			div.style.top = 20 + document.body.scrollTop;
		} else {
			div.style.visibility="hidden";
		}
  }
}

function showHideID(what,why) {
	var div = document.getElementById(what);
	if (why) {
		div.style.display = '';
	} else {
		div.style.display = 'none';
	}
}

var mainpopup = '';
function openWin(URL) {

	if (!mainpopup.closed) {
		mainpopup.close;
	}

	mainpopup = window.open(URL,"helpwindow","toolbar=no,width=600,height=600,status=no,scrollbars=yes,resize=yes,resizable=yes,menubar=no");
	if (!mainpopup.opener) {mainpopup.opener = self;}
	if (window.focus) {mainpopup.focus()}
}

function openWin2(URL,name) {
	bWindow = window.open(URL,name,"toolbar=no,width=600,height=600,status=no,scrollbars=yes,resize=yes,resizable=yes,menubar=no");
	if (!bWindow.opener) {bWindow.opener = self;}
	if (window.focus) {newwindow.focus()}
}

function close_popup_refresh() {
	window.opener.refresh;
	window.close;
}

// RPC (AJAX) implementation
function RPCcreateRequestObject() {
    var ro;
    var browser = navigator.appName;
    if(browser == "Microsoft Internet Explorer"){
        ro = new ActiveXObject("Microsoft.XMLHTTP");
    } else {
        ro = new XMLHttpRequest();
    }
    return ro;
}

var http = RPCcreateRequestObject();

function RPCsndReqArg(action,arg) {
	http.open('get', 'rpc.php?action=' + action + '&arg=' + arg);
	http.onreadystatechange = RPChandleResponse;
	http.send(null);
}

function RPChandleResponse() {
	if(http.readyState == 4) {
		var response = http.responseText;
		var update = new Array();

		if(response.indexOf('|' != -1)) {
			update = response.split('|');
			document.getElementById(update[0]).innerHTML = update[1];
		}
	}
}
