/**
 * @author		Library Automation Services Team
 * @version		1.0
 * @copyright	Sarawak Information Systems Sdn. Bhd.
 *
 * Development Environment			:	EditPlus, AceHTML
 * Name of the Application			:	windows.js
 * Overview of Application			:	Contains javascript functions for controlling windows
 * Creation/Modification History		:
 *		12-Apr-2001		Created
 *		16-Apr-2001		Edited
 *		20-Mar-2003		Edited
 *		05-Nov-2003		Edited
 *
 * 
 * Function Declaration:
 *		function openWindow(strUrl, strWindowName, intMenubar, intToolbar, intPersonalbar, intLocation, intScrollbars, intStatusbar, intResizable, intWidth, intHeight)
 *		function closeWindow(winObj, cfmMsg)
 *		function setWinLocation(winObj, winObjLocation, method)
 *		function maximize(winObj)
 *
 */


/**
 * Open a window based on specified property
 */
function openWindow(strUrl, strWindowName, intMenubar, intToolbar, intPersonalbar, intLocation,
	intScrollbars, intStatusbar, intResizable, intWidth, intHeight){

	var intX = 0, intY = 0;
	if (intWidth == 0 & intHeight == 0) {
		intX = screen.availWidth;
		intY = screen.availHeight;
		strFeature = "menubar=" + intMenubar + ",toolbar=" + intToolbar +
			",personalbar=" + intPersonalbar + ",location=" + intLocation +
			",status=" + intStatusbar + ",scrollbars=" + intScrollbars + 
			",resizable=" + intResizable;
		w = window.open(strUrl, strWindowName, strFeature);
		w.opener = self;
		maximize(w);
		/*w.resizeTo(screen.availWidth,screen.availHeight);
		if (navigator.appName=="Microsoft Internet Explorer")
		{	w.moveTo(0,0);
		}*/
/*		w.outerWidth = screen.availWidth;
		w.outerHeight = screen.availHeight;*/
		w.focus();
		return //w;
	}
	else {
		intX = (screen.availWidth - intWidth)/2;
		intY = (screen.availHeight - intHeight)/2;
		strFeature = "menubar=" + intMenubar + ",toolbar=" + intToolbar +
			",personalbar=" + intPersonalbar + ",location=" + intLocation +
			",status=" + intStatusbar + ",scrollbars=" + intScrollbars + 
			",resizable=" + intResizable + ",width=" + intWidth + ",height=" +
			intHeight + ",screenX=" + intX + ",screenY=" + intY;
		w = window.open(strUrl, strWindowName, strFeature);
		w.opener = self;
		w.focus();
		return //w;
	}
}


/**
 * Close a window with or without a confirmation message
 */
function closeWindow(winObj, cfmMsg){
var close = 1;	
	if (cfmMsg != ''){
		if (!(confirm(cfmMsg))) {
			close = 0;	
		}
	}
	if (close){
		winObj.close();
	}
	return;
}

/**
 *	Set the window location from one to the other 
 */
function setWinLocation(winObj, winObjLocation, method){
	if (method.toLowerCase() == 'replace'){
		eval(winObj + '.replace("'+ winObjLocation + '");');
	}
	else{
		eval(winObj + ' = "' + winObjLocation + '";');
	}
	return;
}

/**
 *	Maximize a window
 */
function maximize(winObj)
{	if (navigator.appName == "Netscape")
	{	if (navigator.appVersion.substr(0, 1)<5)
		{	winObj.resizeBy(screen.availWidth-winObj.outerWidth, screen.availHeight-winObj.outerHeight);
			winObj.moveTo(0,0);
			if ((screen.availWidth < winObj.outerWidth) && (screen.availHeight < winObj.outerHeight))
			{	winObj.resizeTo(screen.availWidth,screen.availHeight);
			}
		}
		else
		{	winObj.moveBy(-winObj.screenX,0);
			winObj.moveBy(0,-winObj.screenY);
			winObj.resizeTo(screen.availWidth,screen.availHeight);
			//for extra processing for the mozilla or netscape 7 browsers which is very slow (sometimes not working) in the response to re-positioning of window.
			winObj.moveBy(0,-winObj.screenY);
			winObj.moveBy(-winObj.screenX,0);
			winObj.moveTo(0,0);
		}
	}
	else
	{	winObj.moveTo(-4,-4);
		winObj.resizeTo(screen.availWidth+8,screen.availHeight+8)
	}
}

function toCenter(obj)
{	try{	obj.moveTo((screen.availWidth/2)-(obj.outerWidth/2), (screen.availHeight/2)-(obj.outerHeight/2));
	} catch (c) {}
}

// End of windows.js