var SCRIPTS_PATH   = "temp/";

function Popup(url, width, height)
{
	if (width == 0 || height == 0) {
		width  = screen.width   - 50;
		height = screen.height - 100;
	}
	var title = url.replace(/[\/\'\"\\\.\*\?!=\-\[\]#&]/g, "");
	var handle = window.open(url, title, "toolbars=yes,scrollbars=yes,status=yes,width=" + width + ",height=" + height + ",left=0,top=0,resizable=yes");
	handle.focus();
}


function ViewSource(layer_name, img_name)
{
	var src = (document.all) ? document.images[img_name].src : document.layers[layer_name].document.images[img_name];

	src = src.substring(src.lastIndexOf("/") + 1);

	var perl_script = "../cgi-bin/view.pl?script=";

	if (src == "space.gif")	{
		alert("No script has been loaded");
		return;
	}

	var url = perl_script + SCRIPTS_PATH + src;

	Popup(url, 640, 480);
}
