// Requires: xscreen.js
if(typeof(xScreen) == "undefined") alert("xScreen Required");

// ||||||||||||||||||||||||||||||||||||||||||||||||||

if(typeof(xWindow) == "undefined") xWindow = {};

xWindow.open = function(url,name,width,height,xpos,ypos,chrome,scroll,fullscreen){
	var x, y, w, h, moveX=0, moveY=0, features="";
	chrome = chrome ? "yes" : "no";
	scroll = scroll ? "yes" : "no";
	features += "toolbar="+chrome;
	features += ",menubar="+chrome;
	features += ",location="+chrome;
	features += ",status="+chrome;
	features += ",scrollbars="+scroll;
	features += ",resizable="+scroll;
	if(width) features += ",width="+width;
	if(height) features += ",height="+height;
	if(fullscreen) features += ",fullscreen=yes";
	if(xpos){
		w = xScreen.getWidth();
		width = parseInt(width);
		switch(xpos){
			case "left": x = 0; break;
			case "center": x = Math.round((w-width)/2); break;
			case "right": x = w-width; break;
			default: x = xpos;
		}
		features += ",screenX="+x+",left="+x;
		var moveX = x;
	}
	if(ypos){
		h = xScreen.getHeight();
		height = parseInt(height);
		switch(ypos){
			case "top": y = 0; break;
			case "middle": y = Math.round((h-height)/2); break;
			case "bottom": y = h-height; break;
			default: y = ypos;
		}
		features += ",screenY="+y+",top="+y;
		var moveY = y;
	}
	xWindow.windowReference = window.open(url,name,features);
};
xWindow.openScroll = function(url,name,width,height){
	this.open(url,name,width,height,false,false,false,"scroll");
};
xWindow.openCenter = function(url,name,width,height){
	this.open(url,name,width,height,"center","middle");
};
xWindow.openCenterScroll = function(url,name,width,height){
	this.open(url,name,width,height,"center","middle",false,"scroll");
};
xWindow.openFull = function(url,name){
	this.open(url,name,xScreen.getWidth(),xScreen.getHeight(),"0","0",false,false);
};
xWindow.openKiosk = function(url,name){
	this.open(url,name,xScreen.getWidth(),xScreen.getHeight(),"0","0",false,false,true);
};


