/* Window manipulation functions for WebTOP [Compiled by Mzoughi and Davis Herring */

var stopModule=0;
var menuLink="";
var NavigationFolder="";
var ModuleSize=1280;
var FontViewSize=2;
var CurrentFontSize=2;
var docURL=document.URL;
//A MousePos object contains fields x and y with the obvious denotations.

function MousePos() {
	if (document.layers) {
		this.x = e.pageX;
		this.y = e.pageY;
	} else if (document.all) {
		this.x = event.clientX + document.body.scrollLeft;
		this.y = event.clientY + document.body.scrollTop;
	}
}

//Sets the current window's status string to str, and returns true
function setStatus(str) {status=str; return true;}

//Creates a new window (takes the same arguments as window.open), and returns false
function newWindow(url,name,flags) {open(url,name,flags); return false;}

//Creates a window to hold text; returns that window
function textWindow(text,w,h) {
	mp=new MousePos();
	win=window.open('', 'WebTOP_textWindow', 'width='+w+',height='+h+',screenX='+mp.x+',screenY='+mp.y+'top='+mp.y+',left='+mp.x);
	win.document.open();
	win.document.write('<html><body bgcolor=white leftmargin=2 topmargin=2 marginwidth=0 marginheight=0>'+text+'</body></html>');
	win.document.close();
	return win;
}

//Creates an explanation window for saving a WSL script.  Returns false.
function wslExplanation() {
	textWindow('Press the right mouse button and use the provided menu to save the script to your computer.',250,80);
	return false;
}

//Creates a window to hold an image/figure; returns that window
function imageWindow(image) {
	win=window.open("",'WebTOP_imageWindow','toolbar=no,width=600,height=450,screenX=0,screenY=0,directories=no,status=yes,scrollbars=yes,resizable=yes,menubar=no');
	win.document.write("<html><body bgcolor=#ffffff><center><img src='"+image+"'><br><br><a href='Javascript:window.close()'>Close this Window</a></center></body></html>");
	win.focus();
	return win;
}

//Creates a window to display a QuickTime video of the specified size; returns that window
function qtWindow(video,width,height) {
	win=window.open("","WebTOP_videoWindow","toolbar=no,width="+(width+50)+",height="+(height+100)+",screenX=0,screenY=0,directories=no,status=yes,scrollbars=yes,resizable=yes,menubar=no");
	win.document.write("<html><body bgcolor=#ffffff>\n<center>\n<OBJECT CLASSID='clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B'");
	win.document.write(" width="+width+" height="+height);
	win.document.write(" CODEBASE='../jars/qtplugin.cab'>\n");
	win.document.write("<PARAM name='SRC' VALUE='"+video+"'>\n");
	win.document.write("<PARAM name='AUTOPLAY' VALUE='true'><PARAM name='CONTROLLER' VALUE='false'>\n");
	win.document.write("<EMBED SRC='"+video+"' AUTOPLAY='true' CONTROLLER='false' PLUGINSPAGE='http://www.apple.com/quicktime/download/'></EMBED>");
	win.document.write("\n</OBJECT>\n<br>");
	win.document.write("<br><br><a href='Javascript:window.close()'>Close this Window</a></center></body></html>");
	win.focus();
	return win;
}
