var imgPopupInterval=false;
var imgPopupWindow=false;
function imgPopup(item, img_width, img_height){
	//if we already have an interval running, kill it
	if(imgPopupInterval !== false){
		clearInterval(imgPopupInterval);
	}
	//close old one to enforce resizing
	if(imgPopupWindow != false && !imgPopupWindow.closed){
		imgPopupWindow.close();
	}
	imgPopupWindow = window.open("popupwindow.html" , 'image'+window.name, 'toolbar=no,scrollbars=no,width='+img_width+',height='+img_height+',resizable=no');
	//the interval changes the href, alt, title etc in the popupwindow
	imgPopupInterval = setInterval("setImage(\""+item.href+"\", \""+item.childNodes[0].alt+"\")",100);
	return false;
}
function setImage(href, alt){
	//if we have a window
	if(!imgPopupWindow.closed){
		//and the image we want to edit is loaded, change it
		if(
			imgPopupWindow.document.getElementById('image')
			&& imgPopupWindow.document.getElementById('image').src != href
		){
			imgPopupWindow.document.getElementById('image').src = href;
			imgPopupWindow.document.getElementById('image').alt = alt;
			imgPopupWindow.document.title = alt;
		}
	//on close stop interval
	}else{
		clearInterval(imgPopupInterval);
		imgPopupInterval = false;
	}
}

