var objLoadFunctions = new Array();

var g_strAdminServer 	= null;
var g_strDomain 		= null;

function WebOnLogOut()
{
	CallServer( "/solution/operations/soap_webOn.aspx", "WebonLogOut", "POST" );
	document.location = document.forms[1].action;
}

function PostWebOnForm()
{
	CallServer( "/solution/operations/soap_webOn.aspx", "WebonLogIn", "POST" );
}

function ShowError( strError )
{
	alert( strError );
}


function AttachToLoad( objFunction )
{
	objLoadFunctions[ objLoadFunctions.length ] = objFunction;
}

function InitLoads()
{
	for ( var i = 0 ; i < objLoadFunctions.length ; i++ )
	{
		eval(objLoadFunctions[ i ]);
	}
}

function OpenSecondaryWindow( strURL )
{
	window.open( strURL, "_blank", "toolbar=no, menubar=no, location=no, resizable=yes, status=yes" );
}

function CloseSecondaryWindow()
{
	window.top.close();
}

function GetAdminServer()
{
	if ( !g_strAdminServer )
	{
		g_strAdminServer = "" + CallServer( "/solution/operations/soap_Operations.aspx", "GetAdminServer", "GET" );
	}

	return g_strAdminServer;
}

function GetAdminDomain()
{
	if ( !g_strDomain )
	{
		var strAdminServer = GetAdminServer();
		if ( strAdminServer.indexOf( "." ) != -1 && strAdminServer.split( "." ).length > 2 )
		{
			var objParts = strAdminServer.split( "." );
			g_strDomain = objParts[ objParts.length - 2 ] + "." + objParts[ objParts.length - 1 ];
		}
		else
		{
			g_strDomain = strAdminServer;
		}
		
		// Strip end slash
		if ( g_strDomain.substring( g_strDomain.length - 1 ) == "/" )
		{
			g_strDomain = g_strDomain.substring( 0, g_strDomain.length - 1 );
		}
		
		// Strip 'http://' prefix
		if ( g_strDomain.substring( 0, 7 ).toLowerCase() == "http://" )
		{
			g_strDomain = g_strDomain.substring( 7 );
		}
	}

	return g_strDomain;
}



function SetCurrentUserMenuID ( strMenuID )
{
	CallServer( "/solution/operations/soap_preFabUtilities.aspx", "SetCurrentUserMenuID", "POST", strMenuID );
}

// Set the domain of the document to equal the domain of the admin server
// This is to enable modal dialogs after the MSIE Patch of Feb 2003
//document.domain = GetAdminDomain();

window.onload = InitLoads;