// hides the given div
function hide(id) {
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(id).style.visibility = 'hidden';
		document.getElementById(id).style.height = '0px';
		document.getElementById(id).style.display = 'none';
	}
}

// shows the given div
function show(id) {
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(id).style.visibility = 'visible';
		document.getElementById(id).style.height = 'auto';
		document.getElementById(id).style.display = 'block';
	}
}

// toggles visibility
function toggle(id) {
	if (document.getElementById) {
		if (document.getElementById(id).style.visibility == 'visible') {
			hide(id);
		} else {
			show(id);
		}
	}
}

// handles text swapping
oldTextAry = new Array();
function changeText (fieldObj, newTexStr) {
	if (newTexStr == fieldObj.innerHTML) {
		fieldObj.innerHTML = oldTextAry[fieldObj.id];
	} else {
		oldTextAry[fieldObj.id] = fieldObj.innerHTML;
		fieldObj.innerHTML = newTexStr;
	}
}

// pops up an edit window
openWindowAry = new Array();
function popup(mylink, windowname) {
	if (!window.focus) return true;
	
	var href;
	if (typeof(mylink) == 'string') {
		href=mylink;
	} else {
		href=mylink.href;
	}
	
	// this checks if the window is already open
	if (openWindowAry[href]) {
		if (!openWindowAry[href].closed) {
			return false;
		}
	}
	
	var win = window.open(href,windowname,'width=800,height=400,scrollbars=yes');
	openWindowAry[href] = win;
	return false;
}

