var Nav4 = ((navigator.appName == "Netscape") && (parseInt(navigator.appVersion) == 4))
var dialogWin = new Object();
var centerWin = new Object();

function openDialog(url, name, width, height)
{
	if (!dialogWin.win || (dialogWin.win && dialogWin.win.closed)) 
	{
		dialogWin.url = url;
		dialogWin.width = width;
		dialogWin.height = height;
		if(!name)
			dialogWin.name = (new Date()).getSeconds().toString()
		else
			dialogWin.name = name;
		
		if (Nav4) 
		{
			dialogWin.left = window.screenX + ((window.outerWidth - dialogWin.width) / 2)
			dialogWin.top = window.screenY + ((window.outerHeight - dialogWin.height) / 2)
			var attr = "screenX=" + dialogWin.left + ",screenY=" + dialogWin.top + ",resizable=no,scrollbars=yes,width=" + dialogWin.width + ",height=" + dialogWin.height
		} 
		else 
		{
			dialogWin.left = (screen.width - dialogWin.width) / 2
			dialogWin.top = (screen.height - dialogWin.height) / 2
			var attr = "left=" + dialogWin.left + ",top=" + dialogWin.top + ",resizable=no,scrollbars=auto,width=" + dialogWin.width + ", statusbar=true, height=" + dialogWin.height
		}
			
		dialogWin.win=window.open(dialogWin.url, dialogWin.name, attr)
	}
	else
		dialogWin.win.focus();
}

function windowOpenCentered(url, popup_win_name, width, height, resizable, scrollable, auto, fullscreen)
{	
	if(!scrollable)
		scrollable = 'no';
	if(!auto || auto == 'no')
		auto = '';	
	else
		auto = 'auto';	
	if(!fullscreen)
		fullscreen = 'no';
    
	var leftMargin = getLeftMargin(width);
	var topMargin = getTopMargin(height);	
	var win_features = "top=" + topMargin + ",screenY=" + topMargin + ",left=" + leftMargin + ",screenX=" + leftMargin + ",resizable=" + resizable + ", width=" + width + ",height=" + height + ",scrollbars=" + scrollable + "," + auto + ",fullscreen=" + fullscreen;	
	window.open(url, popup_win_name, win_features);
}

function getLeftMargin(width)
{
	return (screen.availWidth - width)/2;
}

function getTopMargin(height)
{
	return (screen.availHeight - height)/2;
}

function promptForDeleteItem(uid)
{
	var msg = "Are you sure you want to delete selected row?";
	if(confirm(msg)){
		document.TableForm.action = "/servlet/com.odysseyinc.grid.servlets.GridDeleteItem?" + uid;
		document.TableForm.submit();
	}
	
}

function promptForDelete()
{
	var msg = "Are you sure you want to delete selected rows?";
	if(confirm(msg)){
		document.TableForm.task_action.value = "delete_many";
		document.TableForm.action = "/servlet/com.odysseyinc.grid.servlets.GridDeleteMultipleItems";
		document.TableForm.submit();
	}
}

function popup(url, name, width, height)
{
	if(width == null)
		width = 430;
	if(height == null)
		height = 400;
	openDialog(url, name, width, height);
}

function getReport(url)
{
	if(Nav4) 
	{
		var attr = "screenX=" + 0 + ",screenY=" + 0 + ",resizable=yes,scrollbars=yes,width=" + (window.screen.availWidth-10) + ",height=" + window.screen.availHeight
	} 
	else 
	{
		var attr = "left=" + 0 + ",top=" + 0 + ",resizable=yes,scrollbars=yes,width=" + (window.screen.availWidth-10) + ", statusbar=true, height=" + window.screen.availHeight
	}
	window.open(url, "", attr);
}