/* ***************************************************************** */
/*                                                                   */
/* IBM Confidential                                                  */
/*                                                                   */
/* OCO Source Materials                                              */
/*                                                                   */
/* (C) Copyright IBM Corp. 2002, 2006                                */
/*                                                                   */
/* The source code for this program is not published or otherwise    */
/* divested of its trade secrets, irrespective of what has been      */
/* deposited with the U.S. Copyright Office.                         */
/*                                                                   */
/* ***************************************************************** */

var wAVWizard; // window handle
var wAVurl = "STsrc.nsf/AVWizardFramesetMC?OpenForm";

function myErrorAV(msg, url, linenum)
{
	// Error: can't find isLoaded function
	// Window hasn't loaded the page yet
	wAVWizard.location = wAVloc;
	return true;
}

function resetErrorHandler(msg, url, linenum)
{
	return false;
}

function AVWizardLaunch(isAnon) {
	wAVloc = wAVurl;
	
	// keep login for authenticated users
	if (!isAnon)
		wAVloc = wAVurl + "&login";

	var isWin = (navigator.userAgent.toLowerCase().indexOf("win") != -1)? true : false;
	var canresize = (isWin)? 1 : 0;
	
	if (isWin)
	{
		var Wth = (screen.availWidth * .75);
		var Hth = (screen.availHeight * .75);
	}
	else
	{
		var Wth = screen.availWidth;
		var Hth = screen.availHeight;		
	}

if (screen.availWidth > 1024)
{
	Wth=1024;
}
if (screen.availHeight > 768)
{
	Hth=768;
}

	if (navigator.platform.indexOf('Mac') !=-1)
	{
		Wth -= 22; // Remove room for MacOS 8 borders
		Hth -= 32; // Remove room for Mac menu bar
	}
	else
	{
		Wth -= 12; // Remove room for the window chrome
		Hth -= 29; // Remove room for the window chrome
	}
	Wth = Math.max(Wth, 740);
	Hth = Math.max(Hth, 520);
	
	
	if (navigator.platform.indexOf('Mac') !=-1)
	{
		var lpos = (screen.availWidth - Wth)/2 + screen.availLeft;
		var tpos = (screen.availHeight - Hth)/2 + screen.availTop;
		wAVWizard = window.open("", "AVWizard", "status=yes,scrollbars=yes,screenX="+lpos+",screenY="+tpos+",width="+Wth+",height="+Hth+",resizable="+canresize);
		wAVWizard.location = wAVloc;
	}
	else if ((navigator.appName == "Netscape") && (parseInt(navigator.appVersion) >= 4))
	{	
		var lpos = (screen.availWidth - Wth)/2 + screen.availLeft;
		var tpos = (screen.availHeight - Hth)/2 + screen.availTop;
		wAVWizard = window.open("", "AVWizard", "status=yes,scrollbars=yes,screenX="+lpos+",screenY="+tpos+",width="+Wth+",height="+Hth+",resizable="+canresize);
		window.onerror = myErrorAV;
		if (!wAVWizard.isLoaded())
			wAVWizard.location = wAVloc;
		else
			wAVWizard.focus();
		window.onerror = resetErrorHandler;
	}
	else 
	{
		var lpos = (screen.availWidth - Wth)/2;
		var tpos = (screen.availHeight - Hth)/2;
		wAVWizard = window.open("", "AVWizard", "status=yes,scrollbars=yes,top="+tpos+",left="+lpos+",width="+Wth+",height="+Hth+",resizable=1");
		if (wAVWizard.location != wAVloc)
			wAVWizard.location = wAVloc;
		else
			wAVWizard.focus();
	}
}
