// The contents of this file are subject to the Mozilla Public License Version 1.1
// (the "License"); you may not use this file except in compliance with the License.
// You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
// 
// Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
// WARRANTY OF ANY KIND, either express or implied. See the License for the specific
// language governing rights and limitations under the License.
// 
// The Original Code is the Venice Web Communities System.
// 
// The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
// for Silverwrist Design Studios.  Portions created by Eric J. Bowersox are
// Copyright (C) 2002-03 Eric J. Bowersox/Silverwrist Design Studios.  All Rights Reserved.
// 
// Contributor(s): 

importClass(Packages.com.silverwrist.dynamo.Namespaces);
importPackage(Packages.com.silverwrist.dynamo.iface);
importPackage(Packages.com.silverwrist.dynamo.util);
importClass(Packages.com.silverwrist.venice.VeniceNamespaces);
importPackage(Packages.com.silverwrist.venice.content);

req = bsf.lookupBean("request");
req_help = bsf.lookupBean("request_help");
target = req_help.getParameterString("tgt");
if (target==null)
  target = "top.js.vs";
vlib.setOnError(req,target);

// Check the user account.
user = vlib.getUser(req);
if (!(user.isAnonymous()))  // user already logged in, must log out first
  dynamo.scriptReturn(new ErrorBox(null,"You cannot create a new account while logged in on an existing one. "
                                      + "You must log out first.",target));

// Get the user agreement title and subtitle.
globals = vcast.getGlobalPropertiesStore(req);
s_title = globals.getObject(VeniceNamespaces.CONTENT_LAF_NAMESPACE,"user.agreement.title");
s_subtitle = PropertyUtils.getPropertyNoErr(globals,VeniceNamespaces.CONTENT_LAF_NAMESPACE,
                                            "user.agreement.subtitle");

// Get the content block provider.
csupp = vcast.queryContentBlockProvider(req_help.getRequestObject(Namespaces.DYNAMO_OBJECT_NAMESPACE,
                                                                  "venice-content"));

// Construct the "User Agreement" page.
vlib.setDisplayLogin(req,false);
rc = new StdTextMessage(req);
rc.title = s_title;
if (s_subtitle!=null)
  rc.subtitle = s_subtitle;
rc.content = csupp.getContentBlock("user.agreement");
rc.addButton("SERVLET","new_account_2.js.vs?tgt=" + stringutils.encodeURL(target),"i.accept");
rc.addButton("SERVLET",target,"i.decline");
dynamo.scriptOutput(rc);
