var win;
var FILE = "file:";
var HTTP = "http:";
var DEBUG = true;

function selectHost(target, hostlist) {
	if (!target)
		target = window;
	var p = window.location.protocol;
	if (p.indexOf(FILE) != -1)
		p = HTTP;
	var h;
	if (hostlist != null)
		h = hostlist.options[hostlist.selectedIndex].value;
	if (!h) 
		h = window.location.host;
	var d = window.location.pathname;
	var a = window.location.hash;

	var u = (p.length > 0) ? p + "//" : "";
	if (h.length > 0)
		u += h;
	if (d.length > 0)
		u += d;
	if (a.length > 0)
		u += a;
	eval(target + ".location='" + u + "'");
}
function updateHosts(hostlist) {
	if (hostlist != null) {
		var h = window.location.host.toLowerCase();
		var i, j;
		var b = false;
		for (i = 0, j = hostlist.length; i < j; ++i) {
			if (hostlist.options[i].value.toLowerCase() == h) {
				hostlist.options[i].selected = true;
				b = true;
				break;
			}
		}
		if(!b)
			hostlist.options[hostlist.length] = new Option("HOME", h, true, true);
	}
}

function openWindow(theURL,winName,features) {
	try {
		win.close();
	}
	catch (e) {}
	win = window.open(theURL,winName,features);
}
