function popup(page, width, height)
{
	host = getHost(window.location.href);
	win = window.open(host + page, "", "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=" + width + ",height=" + height);
	win.creator = self;
}
function gotoURL(url)
{
	win = window.open(url, "", "toolbar=yes,location=yes,directories=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes,width=700,height=700");
	if (!win.opener) win.opener = self;
}
function getHost(url) {
	var e=/^((http|ftp|https):\/)?\/?([^:\/\s]+)(.*)$/;
	if (url.match(e)) {
		protocol = RegExp.$2
		host = RegExp.$3;
		return protocol + '://' + host;
	}
	else {
		return '';
	}
}
function disableForm(theform) {
	if (document.all || document.getElementById) {
		for (i = 0; i < theform.length; i++) {
			var tempobj = theform.elements[i];
			if (tempobj.type.toLowerCase() == "submit") {
				tempobj.disabled = true;
			}
		}
	}
}
function textCounter(field, max) {
	// include onkeydown and onkeyup events
	if (field.value.length > max) {
		field.value = field.value.substring(0, max);
		alert("Input is limited to " + max + " characters!");
	}
}
function toggle(id1,id2) {
	if (document.getElementById) { 
		var el1 = document.getElementById(id1);
		el1.style.display = (el1.style.display == 'none') ? 'block' : 'none'; 
		var el2 = document.getElementById(id2);
		el2.style.display = (el2.style.display == 'block') ? 'none' : 'block'; 
	}
}
function toggleDiv(div, trigger, id) {
	if (document.getElementById) {
		var el1 = document.getElementById(div);
		if (id == trigger) {
			el1.style.display = 'block'; 
		}
		else {
			el1.style.display = 'none'; 
		}
	}
}
function goCreator(page, keepopen) {
	host = getHost(window.location.href);
	opener.document.location = host + page;
	if (!keepopen) {
		window.close();
	}
}
