var popWin;

function openImagePopUp(src, options, name)
{
	var matches = options.match(/width\=(\d+)/i);
	var width = matches[1];
	var matches = options.match(/height\=(\d+)/i);
	var height = matches[1];

	var x = arguments[3] || (screen.width-width)/2;	
	var y = arguments[4] || (screen.height-height)/2;	
	var title = arguments[5];	
	var secondary = arguments[6];	
	var newopt;

	if (!(src.indexOf("http")==0 || src.indexOf("/")==0)) {
		src = _ABS_PATH+src;
	}
	
	if (!secondary) {
		if (x) options+= ",left="+x+",screenX="+x;
		if (y) options+= ",top="+y+",screenY="+y;
	}
	
	if (popWin) popWin.close();
	popWin = window.open( "", name, options);


	popWin.document.write( "<html><head>" );
	popWin.document.write( "<title>"+title+"</title>" );
	popWin.document.write( '</head><body bgcolor="#' );
    popWin.document.write('FFFFFF');
	popWin.document.write( '" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">' );
	popWin.document.write( "<img src='"+src+"' width='"+width+"' height='"+height+"' alt='"+title+"' title='"+title+"'>" );	
	popWin.document.write( "</body></html>" );
	popWin.focus();
}

function openPopWindow(src, options, name)
{
	var x = arguments[3];	
	var y = arguments[4];
	var desc = arguments[5];
	
	if (x) options+= ",left="+x+",screenX="+x;
	if (y) options+= ",top="+y+",screenY="+y;

	if (!(src.indexOf("http")==0 || src.indexOf("/")==0)) {
		src = _ABS_PATH+src;
	}

	if (src.search(/\.(jpg|gif|jpeg|png)$/ig) != -1) {
		openImagePopUp(src, options, name, x, y, desc, true);
		return;
	}
	
	if (popWin) popWin.close();
	
	popWin=window.open(src, name, options);

	popWin.focus();
	
}
