function expand_link(elm, perform, expandId) {
	if (perform == "show" && elm) {
		elm.className = "expand minus";
		elm.onclick = function () {expand_link(elm, "hide", expandId);};
		if (expandId) {
			expElm = document.getElementById(expandId);
			expElm.style.display = "block";
		}
	} else if (perform == "hide") {
		elm.className = "expand plus";
		elm.onclick = function () {expand_link(elm, "show", expandId);};
		if (expandId) {
			expElm = document.getElementById(expandId);
			expElm.style.display = "none";
		}
	}
}

function getDim(el) {
	for (var lx=0,ly=0; el!=null; lx+=el.offsetLeft,ly+=el.offsetTop,el=el.offsetParent);
	return {x:lx,y:ly}
}

function getParentByTagName(elm, tag) {
	if (elm == null || elm.parentNode == null) return null;
	
	if (elm.parentNode.nodeType == 1 && elm.parentNode.tagName.toLowerCase() == tag.toLowerCase()) return elm.parentNode;
	else return getParentByTagName(elm.parentNode, tag);
}

function popUp(URL) {
	day = new Date();
	id = day.getTime();
	eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=700,height=780');");
}

function showArtworkOverlay(zElm, oId) {
	var elm = document.getElementById(oId);
	var thisDim;
	if (elm) {
		/*
		elm.style.top = (thisDim.y - (elm.offsetHeight)/2)+"px";
		elm.style.left = (thisDim.x - (elm.offsetWidth)/2)+"px";
		*/
		elm.style.display = "block";
		if (zElm) thisDim  = getDim(zElm);
		elm.style.top = (thisDim.y - (elm.offsetHeight)/2) + 160 + "px";
		elm.style.left = (thisDim.x - (elm.offsetWidth)/2) + 60 + "px";
	}
	// if (zElm) zElm.src = "images/icons/zoom_new_over.png";
}

function hideArtworkOverlay(zElm, oId) {
	var elm = document.getElementById(oId);
	if (elm) elm.style.display = "none";
	if (zElm) zElm.src = "images/icons/zoom_new.png";
}