// All the javascript routines for LeonardoLog

window.focus();

var App = {}
App.windows = new Array();
App.openwin = function (name, url, ax, ay, bx, by, cx, cy, width, height) {
	if (navigator.platform.indexOf('Mac')==-1) window.onfocus=App.reappearMain;
	if (screenwidth<900) {
	// 800x600
		this.windows[name] = window.open(url,name,'width='+width+',height='+height+',left='+(leftpos+ax)+',top='+(toppos+ay)+',screenX='+(leftpos+ax)+',screenY='+(toppos+ay)+',menubar=no,scrollbars=no,location=no,toolbar=no,directories=no,status=no');
	} else if (screenwidth<1100) {
	//1024x768
		this.windows[name] = window.open(url,name,'width='+width+',height='+height+',left='+(leftpos+bx)+',top='+(toppos+by)+',screenX='+(leftpos+bx)+',screenY='+(toppos+by)+',menubar=no,scrollbars=no,location=no,toolbar=no,directories=no,status=no');
	} else {
	//1280x1024
		this.windows[name] = window.open(url,name,'width='+width+',height='+height+',left='+(leftpos+cx)+',top='+(toppos+cy)+',screenX='+(leftpos+cx)+',screenY='+(toppos+cy)+',menubar=no,scrollbars=no,location=no,toolbar=no,directories=no,status=no');
	}
}
App.close = function (handle) {
	if (handle) {
		if (this.windows[handle] && (!this.windows[handle].closed)) this.windows[handle].close();
	} else {
		for (var win in this.windows) this.windows[win].close();
	}
}
App.disappearMain = function () {
	window.resizeTo(10,10);
	window.moveTo(leftpos,toppos);
}
App.reappearMain = function () {
	window.moveTo(10,10);
	window.resizeTo(800,600);
}


screenwidth=(window.x||window.screen.width||window.clientX);

function getCoords() {
	
	if (screenwidth<900) {
	// 800x600
		leftpos=360;
		toppos=80;
	} else if (screenwidth<1100) {
	//1024x768
		leftpos=470;
		toppos=240;
	} else {
	//1280x1024
		leftpos=500;
		toppos=300;
	}
}
