
//new window constants:

var TOOLBAR = Math.ceil(getHeight() * ((getHeight()  > 600)? 0.12:0.15));


/************************************************************	
				newWindow(URL)
************************************************************/
//full size version
function newWindow(URL)
{
	var mWin = 0;
	var w = getWidth();
	var h = getHeight(); 
	//resizing for opitmal view
	h -= TOOLBAR;	
	w = w - w*0.01;

	var args = "height=" + h + ",width=" + w + ",top=0,left=0,status=yes,toolbar=yes,menubar=yes,location=yes,resizable=yes,scrollbars=yes";
	
	mWin = open(URL, "mWind" , args);
	mWin.focus();
	
}


/************************************************************	
				popUp(URL , name , args)
************************************************************/

function popUp2(URL , name , args )
{
	var mWin;	
	mWin = open(URL, name , args);
	mWin.focus();
	
}

/////////////////////////////////////////////////////////////////////////////////
//	function getWidth()
// 	gets: -
//	return: int width
// 	does: return the available screen width, if not avail then return 800
/////////////////////////////////////////////////////////////////////////////////
function getWidth() {
	if (screen.availWidth) 
		return window.screen.availWidth;
	else 
		return 800;
}

/////////////////////////////////////////////////////////////////////////////////
//	function getHeight()
// 	gets: -
//	return: int height
// 	does: return the available screen height, if not avail then return 600
/////////////////////////////////////////////////////////////////////////////////
function getHeight() {
	if (screen.availHeight) 
		return window.screen.availHeight;
	else 
		return 600;
}


/////////////////////////////////////////////////////////////////////////////////
//	function popUp(URL , width , height , top ,left , args , name)
// 	gets: URL , [width] , [height] , [top] , [left] , [args] , [name]
//	return: -
// 	does: open new window according to parameters, if not provided opens centered
//		  big window (you can provide only width or width & height and the window
//		  will be centerd according to the screen resolution.
/////////////////////////////////////////////////////////////////////////////////
function popUp(URL , width , height , top ,left , args , name)
{
	var h = getHeight();
	

	//set default values to parameters if not provided
	(!width)? width = getWidth():1;
	(!height)? height = getHeight():1;
	(!top)? top = (h/2 - height/2):1;
	(!left)? left = getWidth()/2 - width/2:1;
	(!args)? args = "status=no,toolbar=no,menubar=no,location=no,resizable=no,scrollbars=1":1;
	(!name)? name = null:1;
	
	if ((height + top) > (h - TOOLBAR)) {
		height = h - TOOLBAR/2;
		top -= (TOOLBAR/2)	
	}

	(top < 0)? top = 15:1;

	args += ",top=" + top + ",left=" + left + ",height=" + height + ",width=" + width
	var mWin;	
	mWin = open(URL, name , args);
	if(mWin != null) mWin.focus();

	return mWin
	
}

