diff --git public_html/sites/all/modules/contrib/ctools/js/ajax-responder.js public_html/sites/all/modules/contrib/ctools/js/ajax-responder.js
index eb9b780..3f221a2 100644
--- public_html/sites/all/modules/contrib/ctools/js/ajax-responder.js
+++ public_html/sites/all/modules/contrib/ctools/js/ajax-responder.js
@@ -49,7 +49,7 @@
     var $objects = $('a[href=' + old_url + ']')
     $objects.addClass('ctools-fetching');
     try {
-      url = old_url.replace(/\/nojs(\/|$)/g, '/ajax$1');
+      url = Drupal.CTools.AJAX.urlReplaceNojs(url);
       $.ajax({
         type: "POST",
         url: url,
@@ -108,7 +108,7 @@
     var object = $(this);
     $(this).addClass('ctools-ajaxing');
     try {
-      url = url.replace(/\/nojs(\/|$)/g, '/ajax$1');
+      url = Drupal.CTools.AJAX.urlReplaceNojs(url);
       $.ajax({
         type: "POST",
         url: url,
@@ -150,7 +150,7 @@
     var object = $(this);
     try {
       if (url) {
-        url = url.replace(/\/nojs(\/|$)/g, '/ajax$1');
+        url = Drupal.CTools.AJAX.urlReplaceNojs(url);
         $.ajax({
           type: "POST",
           url: url,
@@ -196,7 +196,7 @@
     $form.addClass('ctools-ajaxing');
 
     try {
-      url = url.replace(/\/nojs(\/|$)/g, '/ajax$1');
+      url = Drupal.CTools.AJAX.urlReplaceNojs(url);
 
       var ajaxOptions = {
         type: 'POST',
@@ -287,7 +287,7 @@
     var form_id = $(object).parents('form').get(0).id;
     try {
       if (url) {
-        url = url.replace(/\/nojs(\/|$)/g, '/ajax$1');
+        url = Drupal.CTools.AJAX.urlReplaceNojs(url);
         $.ajax({
           type: "POST",
           url: url,
@@ -518,6 +518,22 @@
     $(data.selector).submit();
   }
 
+  /**
+   * Replacing 'nojs' with 'ajax' in the URL allows for an easy method to let
+   * the server detect when it needs to degrade gracefully.
+   * There are five scenarios to check for:
+   * 1. /nojs/
+   * 2. /nojs$ - The end of a URL string.
+   * 3. /nojs? - Followed by a query (with clean URLs enabled).
+   *      E.g.: path/nojs?destination=foobar
+   * 4. /nojs& - Followed by a query (without clean URLs enabled).
+   *      E.g.: ?q=path/nojs&destination=foobar
+   * 5. /nojs# - Followed by a fragment.
+   *      E.g.: path/nojs#myfragment
+   */
+  Drupal.CTools.AJAX.urlReplaceNojs = function(url) {
+    return url.replace(/\/nojs(\/|$|\?|&|#)/g, '/ajax$1');
+  }
 
   /**
    * Bind links that will open modals to the appropriate function.
diff --git public_html/sites/all/modules/contrib/dialog/LICENSE.txt public_html/sites/all/modules/contrib/dialog/LICENSE.txt
deleted file mode 100644
index 2c095c8..0000000
--- public_html/sites/all/modules/contrib/dialog/LICENSE.txt
+++ /dev/null
@@ -1,274 +0,0 @@
-GNU GENERAL PUBLIC LICENSE
-
-              Version 2, June 1991
-
-Copyright (C) 1989, 1991 Free Software Foundation, Inc. 675 Mass Ave,
-Cambridge, MA 02139, USA. Everyone is permitted to copy and distribute
-verbatim copies of this license document, but changing it is not allowed.
-
-                  Preamble
-
-The licenses for most software are designed to take away your freedom to
-share and change it. By contrast, the GNU General Public License is
-intended to guarantee your freedom to share and change free software--to
-make sure the software is free for all its users. This General Public License
-applies to most of the Free Software Foundation's software and to any other
-program whose authors commit to using it. (Some other Free Software
-Foundation software is covered by the GNU Library General Public License
-instead.) You can apply it to your programs, too.
-
-When we speak of free software, we are referring to freedom, not price. Our
-General Public Licenses are designed to make sure that you have the
-freedom to distribute copies of free software (and charge for this service if
-you wish), that you receive source code or can get it if you want it, that you
-can change the software or use pieces of it in new free programs; and that
-you know you can do these things.
-
-To protect your rights, we need to make restrictions that forbid anyone to
-deny you these rights or to ask you to surrender the rights. These restrictions
-translate to certain responsibilities for you if you distribute copies of the
-software, or if you modify it.
-
-For example, if you distribute copies of such a program, whether gratis or for
-a fee, you must give the recipients all the rights that you have. You must make
-sure that they, too, receive or can get the source code. And you must show
-them these terms so they know their rights.
-
-We protect your rights with two steps: (1) copyright the software, and (2)
-offer you this license which gives you legal permission to copy, distribute
-and/or modify the software.
-
-Also, for each author's protection and ours, we want to make certain that
-everyone understands that there is no warranty for this free software. If the
-software is modified by someone else and passed on, we want its recipients
-to know that what they have is not the original, so that any problems
-introduced by others will not reflect on the original authors' reputations.
-
-Finally, any free program is threatened constantly by software patents. We
-wish to avoid the danger that redistributors of a free program will individually
-obtain patent licenses, in effect making the program proprietary. To prevent
-this, we have made it clear that any patent must be licensed for everyone's
-free use or not licensed at all.
-
-The precise terms and conditions for copying, distribution and modification
-follow.
-
-           GNU GENERAL PUBLIC LICENSE
- TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND
-               MODIFICATION
-
-0. This License applies to any program or other work which contains a notice
-placed by the copyright holder saying it may be distributed under the terms
-of this General Public License. The "Program", below, refers to any such
-program or work, and a "work based on the Program" means either the
-Program or any derivative work under copyright law: that is to say, a work
-containing the Program or a portion of it, either verbatim or with
-modifications and/or translated into another language. (Hereinafter, translation
-is included without limitation in the term "modification".) Each licensee is
-addressed as "you".
-
-Activities other than copying, distribution and modification are not covered
-by this License; they are outside its scope. The act of running the Program is
-not restricted, and the output from the Program is covered only if its contents
-constitute a work based on the Program (independent of having been made
-by running the Program). Whether that is true depends on what the Program
-does.
-
-1. You may copy and distribute verbatim copies of the Program's source
-code as you receive it, in any medium, provided that you conspicuously and
-appropriately publish on each copy an appropriate copyright notice and
-disclaimer of warranty; keep intact all the notices that refer to this License
-and to the absence of any warranty; and give any other recipients of the
-Program a copy of this License along with the Program.
-
-You may charge a fee for the physical act of transferring a copy, and you
-may at your option offer warranty protection in exchange for a fee.
-
-2. You may modify your copy or copies of the Program or any portion of it,
-thus forming a work based on the Program, and copy and distribute such
-modifications or work under the terms of Section 1 above, provided that you
-also meet all of these conditions:
-
-a) You must cause the modified files to carry prominent notices stating that
-you changed the files and the date of any change.
-
-b) You must cause any work that you distribute or publish, that in whole or in
-part contains or is derived from the Program or any part thereof, to be
-licensed as a whole at no charge to all third parties under the terms of this
-License.
-
-c) If the modified program normally reads commands interactively when run,
-you must cause it, when started running for such interactive use in the most
-ordinary way, to print or display an announcement including an appropriate
-copyright notice and a notice that there is no warranty (or else, saying that
-you provide a warranty) and that users may redistribute the program under
-these conditions, and telling the user how to view a copy of this License.
-(Exception: if the Program itself is interactive but does not normally print such
-an announcement, your work based on the Program is not required to print
-an announcement.)
-
-These requirements apply to the modified work as a whole. If identifiable
-sections of that work are not derived from the Program, and can be
-reasonably considered independent and separate works in themselves, then
-this License, and its terms, do not apply to those sections when you distribute
-them as separate works. But when you distribute the same sections as part
-of a whole which is a work based on the Program, the distribution of the
-whole must be on the terms of this License, whose permissions for other
-licensees extend to the entire whole, and thus to each and every part
-regardless of who wrote it.
-
-Thus, it is not the intent of this section to claim rights or contest your rights to
-work written entirely by you; rather, the intent is to exercise the right to
-control the distribution of derivative or collective works based on the
-Program.
-
-In addition, mere aggregation of another work not based on the Program
-with the Program (or with a work based on the Program) on a volume of a
-storage or distribution medium does not bring the other work under the scope
-of this License.
-
-3. You may copy and distribute the Program (or a work based on it, under
-Section 2) in object code or executable form under the terms of Sections 1
-and 2 above provided that you also do one of the following:
-
-a) Accompany it with the complete corresponding machine-readable source
-code, which must be distributed under the terms of Sections 1 and 2 above
-on a medium customarily used for software interchange; or,
-
-b) Accompany it with a written offer, valid for at least three years, to give
-any third party, for a charge no more than your cost of physically performing
-source distribution, a complete machine-readable copy of the corresponding
-source code, to be distributed under the terms of Sections 1 and 2 above on
-a medium customarily used for software interchange; or,
-
-c) Accompany it with the information you received as to the offer to distribute
-corresponding source code. (This alternative is allowed only for
-noncommercial distribution and only if you received the program in object
-code or executable form with such an offer, in accord with Subsection b
-above.)
-
-The source code for a work means the preferred form of the work for
-making modifications to it. For an executable work, complete source code
-means all the source code for all modules it contains, plus any associated
-interface definition files, plus the scripts used to control compilation and
-installation of the executable. However, as a special exception, the source
-code distributed need not include anything that is normally distributed (in
-either source or binary form) with the major components (compiler, kernel,
-and so on) of the operating system on which the executable runs, unless that
-component itself accompanies the executable.
-
-If distribution of executable or object code is made by offering access to
-copy from a designated place, then offering equivalent access to copy the
-source code from the same place counts as distribution of the source code,
-even though third parties are not compelled to copy the source along with the
-object code.
-
-4. You may not copy, modify, sublicense, or distribute the Program except as
-expressly provided under this License. Any attempt otherwise to copy,
-modify, sublicense or distribute the Program is void, and will automatically
-terminate your rights under this License. However, parties who have received
-copies, or rights, from you under this License will not have their licenses
-terminated so long as such parties remain in full compliance.
-
-5. You are not required to accept this License, since you have not signed it.
-However, nothing else grants you permission to modify or distribute the
-Program or its derivative works. These actions are prohibited by law if you
-do not accept this License. Therefore, by modifying or distributing the
-Program (or any work based on the Program), you indicate your acceptance
-of this License to do so, and all its terms and conditions for copying,
-distributing or modifying the Program or works based on it.
-
-6. Each time you redistribute the Program (or any work based on the
-Program), the recipient automatically receives a license from the original
-licensor to copy, distribute or modify the Program subject to these terms and
-conditions. You may not impose any further restrictions on the recipients'
-exercise of the rights granted herein. You are not responsible for enforcing
-compliance by third parties to this License.
-
-7. If, as a consequence of a court judgment or allegation of patent
-infringement or for any other reason (not limited to patent issues), conditions
-are imposed on you (whether by court order, agreement or otherwise) that
-contradict the conditions of this License, they do not excuse you from the
-conditions of this License. If you cannot distribute so as to satisfy
-simultaneously your obligations under this License and any other pertinent
-obligations, then as a consequence you may not distribute the Program at all.
-For example, if a patent license would not permit royalty-free redistribution
-of the Program by all those who receive copies directly or indirectly through
-you, then the only way you could satisfy both it and this License would be to
-refrain entirely from distribution of the Program.
-
-If any portion of this section is held invalid or unenforceable under any
-particular circumstance, the balance of the section is intended to apply and
-the section as a whole is intended to apply in other circumstances.
-
-It is not the purpose of this section to induce you to infringe any patents or
-other property right claims or to contest validity of any such claims; this
-section has the sole purpose of protecting the integrity of the free software
-distribution system, which is implemented by public license practices. Many
-people have made generous contributions to the wide range of software
-distributed through that system in reliance on consistent application of that
-system; it is up to the author/donor to decide if he or she is willing to
-distribute software through any other system and a licensee cannot impose
-that choice.
-
-This section is intended to make thoroughly clear what is believed to be a
-consequence of the rest of this License.
-
-8. If the distribution and/or use of the Program is restricted in certain
-countries either by patents or by copyrighted interfaces, the original copyright
-holder who places the Program under this License may add an explicit
-geographical distribution limitation excluding those countries, so that
-distribution is permitted only in or among countries not thus excluded. In such
-case, this License incorporates the limitation as if written in the body of this
-License.
-
-9. The Free Software Foundation may publish revised and/or new versions
-of the General Public License from time to time. Such new versions will be
-similar in spirit to the present version, but may differ in detail to address new
-problems or concerns.
-
-Each version is given a distinguishing version number. If the Program specifies
-a version number of this License which applies to it and "any later version",
-you have the option of following the terms and conditions either of that
-version or of any later version published by the Free Software Foundation. If
-the Program does not specify a version number of this License, you may
-choose any version ever published by the Free Software Foundation.
-
-10. If you wish to incorporate parts of the Program into other free programs
-whose distribution conditions are different, write to the author to ask for
-permission. For software which is copyrighted by the Free Software
-Foundation, write to the Free Software Foundation; we sometimes make
-exceptions for this. Our decision will be guided by the two goals of
-preserving the free status of all derivatives of our free software and of
-promoting the sharing and reuse of software generally.
-
-               NO WARRANTY
-
-11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE,
-THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT
-PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE
-STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
-OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT
-WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED,
-INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
-OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND
-PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
-PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL
-NECESSARY SERVICING, REPAIR OR CORRECTION.
-
-12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR
-AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR
-ANY OTHER PARTY WHO MAY MODIFY AND/OR
-REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE
-LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL,
-SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES
-ARISING OUT OF THE USE OR INABILITY TO USE THE
-PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA
-OR DATA BEING RENDERED INACCURATE OR LOSSES
-SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE
-PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN
-IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF
-THE POSSIBILITY OF SUCH DAMAGES.
-
-          END OF TERMS AND CONDITIONS
diff --git public_html/sites/all/modules/contrib/dialog/dialog.admin.inc public_html/sites/all/modules/contrib/dialog/dialog.admin.inc
index c3f45c7..293534f 100644
--- public_html/sites/all/modules/contrib/dialog/dialog.admin.inc
+++ public_html/sites/all/modules/contrib/dialog/dialog.admin.inc
@@ -1,5 +1,5 @@
 <?php
-// $Id: dialog.admin.inc,v 1.1.2.1 2010/08/13 19:40:06 rz Exp $
+// $Id: dialog.admin.inc,v 1.1.2.2 2011/01/31 21:03:40 drewish Exp $
 
 /**
  * @file
@@ -16,20 +16,20 @@ function dialog_admin_settings() {
     '#type'  => 'fieldset',
     '#title' => t('Dialog default attributes'),
   );
-  
+
   $form['dialog_attributes']['dialog_default_height'] = array(
     '#type'          => 'textfield',
     '#title'         => t('Height'),
     '#default_value' => variable_get('dialog_default_height', 'auto'),
     '#description'   => t('The CSS value for dialog height'),
   );
-  
+
   $form['dialog_attributes']['dialog_default_width'] = array(
     '#type'          => 'textfield',
     '#title'         => t('Width'),
     '#default_value' => variable_get('dialog_default_width', '600px'),
     '#description'   => t('The CSS value for dialog width'),
   );
-    
+
   return system_settings_form($form);
 }
diff --git public_html/sites/all/modules/contrib/dialog/dialog.info public_html/sites/all/modules/contrib/dialog/dialog.info
index 07baee5..d67b420 100644
--- public_html/sites/all/modules/contrib/dialog/dialog.info
+++ public_html/sites/all/modules/contrib/dialog/dialog.info
@@ -7,10 +7,3 @@ package = User interface
 dependencies[] = ctools
 dependencies[] = jquery_update
 dependencies[] = jquery_ui
-
-; Information added by drupal.org packaging script on 2010-08-14
-version = "6.x-1.x-dev"
-core = "6.x"
-project = "dialog"
-datestamp = "1281744384"
-
diff --git public_html/sites/all/modules/contrib/dialog/dialog.js public_html/sites/all/modules/contrib/dialog/dialog.js
index 772a658..8e63a60 100644
--- public_html/sites/all/modules/contrib/dialog/dialog.js
+++ public_html/sites/all/modules/contrib/dialog/dialog.js
@@ -1,4 +1,4 @@
-// $Id: dialog.js,v 1.1.2.4 2010/08/13 19:40:06 rz Exp $
+// $Id: dialog.js,v 1.1.2.7 2011/02/02 15:57:39 drewish Exp $
 /**
  * @file
  *
@@ -24,8 +24,8 @@
         position: 'center'
       };
       Drupal.Dialog.dialog = $(Drupal.theme('DialogMain')).dialog(o);
-      
-      // Completely remove the dialog every time it is closed.  This is the 
+
+      // Completely remove the dialog every time it is closed.  This is the
       // simplest way to get a clean slate on every dialog invokation.
       Drupal.Dialog.dialog.bind('dialogclose', function(event, ui) {
         $(this).remove();
@@ -108,11 +108,11 @@
       return false;
     }
 
-    url = $(this).attr('action');
-    $(this).addClass('ctools-ajaxing');
     var object = $(this);
+    var url = object.attr('action');
+    object.addClass('ctools-ajaxing');
     try {
-      url.replace('/nojs/', '/ajax/');
+      url = Drupal.CTools.AJAX.urlReplaceNojs(url);
 
       var ajaxOptions = {
         type: 'POST',
@@ -165,12 +165,12 @@
       this.form.clk = this;
       $(this).after('<div class="ctools-ajaxing"> &nbsp; </div>');
 
-      // Submit the form. Notice the difference between $().submit() 
-      // which is the ajax submit and form.submit() which is the 
+      // Submit the form. Notice the difference between $().submit()
+      // which is the ajax submit and form.submit() which is the
       // default browser submit.
       $(this.form).submit();
     }
-    
+
     return false;
   };
 
@@ -199,7 +199,7 @@
       $('input[type="submit"]:not(.ctools-use-dialog-processed), button:not(.ctools-use-dialog-processed)', context)
         .addClass('ctools-use-dialog-processed')
         .click(Drupal.Dialog.clickFormButton);
-      
+
       var buttons = {}, buttonsMap = {};
       $('.ctools-dialog-button:not(.ctools-dialog-button-processed)', context)
         .addClass('ctools-dialog-button-processed')
@@ -211,7 +211,7 @@
             var text = $(e.target).text();
             var map = $(this).data('dialogButtonsMap');
             var button = map[text];
-            
+
             $(button).click();
           };
         });
@@ -227,32 +227,36 @@
    */
   Drupal.CTools.AJAX.commands.dialog_display = function(command) {
     var $el = Drupal.Dialog.dialog;
-    $el.html(command.output)
-      // remove any previously added buttons
-      .dialog('option', 'buttons', {})
-      .dialog('option', 'title', command.title)
-      .dialog('show');
-
-    var defaultOptions = {
-      height: Drupal.settings.Dialog.height,
-      width: Drupal.settings.Dialog.width,
-      position: 'center',
-      maxHeight: Math.floor($(window).height() * .8)
-    };
-    var o = $.extend(defaultOptions, command.options);
-    for (i in o) {
-      $el.dialog('option', i, o[i]);
-    }
-    if ($el.height() > o.maxHeight) {
-      $el.dialog('option', 'height', o.maxHeight);
-      $el.dialog('option', 'position', o.position);
-      // This is really ugly, but dialog gives us no way to call 
-      // _size() in a sane way!
-      $el.data('dialog')._size();
-    }
 
-    Drupal.attachBehaviors($el);
-  }
+    // Ensure that the dialog wasn't closed before the request completed.
+    if ($el) {
+      $el.html(command.output)
+        // remove any previously added buttons
+        .dialog('option', 'buttons', {})
+        .dialog('option', 'title', command.title)
+        .dialog('show');
+
+      var defaultOptions = {
+        height: Drupal.settings.Dialog.height,
+        width: Drupal.settings.Dialog.width,
+        position: 'center',
+        maxHeight: Math.floor($(window).height() * .8)
+      };
+      var o = $.extend(defaultOptions, command.options);
+      for (i in o) {
+        $el.dialog('option', i, o[i]);
+      }
+      if ($el.height() > o.maxHeight) {
+        $el.dialog('option', 'height', o.maxHeight);
+        $el.dialog('option', 'position', o.position);
+        // This is really ugly, but dialog gives us no way to call
+        // _size() in a sane way!
+        $el.data('dialog')._size();
+      }
+
+      Drupal.attachBehaviors($el);
+    }
+  };
 
   /**
    * AJAX responder command to dismiss the modal.
diff --git public_html/sites/all/modules/contrib/dialog/dialog.module public_html/sites/all/modules/contrib/dialog/dialog.module
index 75de634..b499ac1 100644
--- public_html/sites/all/modules/contrib/dialog/dialog.module
+++ public_html/sites/all/modules/contrib/dialog/dialog.module
@@ -1,5 +1,5 @@
 <?php
-// $Id: dialog.module,v 1.1.2.5 2010/08/13 20:09:21 rz Exp $
+// $Id: dialog.module,v 1.1.2.8 2011/02/01 22:38:45 drewish Exp $
 
 /**
  * Implementation of hook_theme().
@@ -43,6 +43,10 @@ function dialog_add_js() {
     return;
   }
 
+  // Include CTools ajax so it can preprocess the page's CSS and JS. Helps avoid
+  // issues with cache clears.
+  ctools_include('ajax');
+
   $settings = array(
     'Dialog' => array(
       'throbber' => theme('image', ctools_image_path('throbber.gif'), t('Loading...'), t('Loading')),
@@ -50,7 +54,7 @@ function dialog_add_js() {
       'width' => variable_get('dialog_default_width', '600px'),
     )
   );
-  
+
   drupal_add_js($settings, 'setting');
   drupal_add_js('misc/jquery.form.js');
   ctools_add_js('ajax-responder');
@@ -172,13 +176,13 @@ function dialog_form_render($form_state, $output) {
 /**
  * Generic dialog replacement for drupal_get_form().  Suitable for use as the
  * page callback in a menu item.
- * 
- * This function introduces a new form callback function to handle the 
+ *
+ * This function introduces a new form callback function to handle the
  * post-submit dialog commands, in the ajax context.  This function takes the
- * form of form_id_dialog_success.  If this function is found, it will be 
+ * form of form_id_dialog_success.  If this function is found, it will be
  * automatically called after a valid submission of the form has been detected.
- * If the function does not exist, a redirect will be issued based on the 
- * redirect value in the form_state array.  As the final fallback, if the 
+ * If the function does not exist, a redirect will be issued based on the
+ * redirect value in the form_state array.  As the final fallback, if the
  * redirect value is missing or empty, a client-side reload command is issued.
  *
  * @param $id
@@ -194,14 +198,16 @@ function dialog_get_form($form_id, $js) {
   $form_id = array_shift($args);
   $js = array_shift($args);
 
+  $form_state = array(
+    'ajax' => (bool) $js,
+    'title' => drupal_get_title(),
+    'args' => $args,
+  );
+
+  $output = dialog_form_wrapper($form_id, $form_state);
+
   if ($js) {
     ctools_include('ajax');
-    $form_state = array(
-      'ajax' => TRUE,
-      'title' => drupal_get_title(),
-      'args' => $args,
-    );
-    $output = dialog_form_wrapper($form_id, $form_state);
     if (empty($output)) {
       $func = $form_id .'_dialog_success';
       if (function_exists($func)) {
@@ -217,7 +223,7 @@ function dialog_get_form($form_id, $js) {
     ctools_ajax_render($output);
   }
   else {
-    return drupal_get_form($form_id);
+    return $output;
   }
 }
 
@@ -225,6 +231,6 @@ function dialog_get_form($form_id, $js) {
  * Process variables for dialog-content.tpl.php.
  */
 function template_preprocess_dialog_content(&$variables) {
-  $variables['help'] = theme('help');  
+  $variables['help'] = theme('help');
   $variables['messages'] = theme('status_messages');
 }
diff --git public_html/sites/all/modules/contrib/dialog/example/dialog_example.info public_html/sites/all/modules/contrib/dialog/example/dialog_example.info
index 66b3aa3..c556cda 100644
--- public_html/sites/all/modules/contrib/dialog/example/dialog_example.info
+++ public_html/sites/all/modules/contrib/dialog/example/dialog_example.info
@@ -3,10 +3,3 @@ name = Dialog Example
 description = Example implementation of the dialog API.
 core = 6.x
 dependencies[] = dialog
-
-; Information added by drupal.org packaging script on 2010-08-14
-version = "6.x-1.x-dev"
-core = "6.x"
-project = "dialog"
-datestamp = "1281744384"
-
diff --git public_html/sites/all/modules/contrib/dialog/example/dialog_example.module public_html/sites/all/modules/contrib/dialog/example/dialog_example.module
index 1e44ce5..595491b 100644
--- public_html/sites/all/modules/contrib/dialog/example/dialog_example.module
+++ public_html/sites/all/modules/contrib/dialog/example/dialog_example.module
@@ -1,5 +1,5 @@
 <?php
-// $Id: dialog_example.module,v 1.1 2009/12/07 01:47:59 rz Exp $
+// $Id: dialog_example.module,v 1.1.2.1 2011/01/31 20:57:05 drewish Exp $
 
 /**
  * Implementation of hook_menu().
@@ -35,11 +35,19 @@ function dialog_example_menu() {
 }
 
 function dialog_example_page() {
+  global $user;
+
   dialog_add_js();
   $links = array();
   $links[] = l('Simple test', 'dialog/nojs/example', array('attributes' => array('class' => 'ctools-use-dialog')));
-  $links[] = l('User login', 'user/login/nojs', array('attributes' => array('class' => 'ctools-use-dialog')));
-  $links[] = l('User registration', 'user/register/nojs', array('attributes' => array('class' => 'ctools-use-dialog')));
+  if (!$user->uid) {
+    $links[] = l('User login', 'user/login/nojs', array('attributes' => array('class' => 'ctools-use-dialog')));
+    $links[] = l('User registration', 'user/register/nojs', array('attributes' => array('class' => 'ctools-use-dialog')));
+  }
+  else {
+    $links[] = l(t('Logout'), 'logout', array('@logout' => url('logout', array('query' => array('destination' => 'dialog/example')))));
+  }
+
   return theme('item_list', $links);
 }
 
@@ -51,7 +59,7 @@ function dialog_example_ajax_callback($ajax = FALSE) {
       'position' => 'center',
     );
     dialog_ajax_render('test', dialog_example_page(), $options);
-    return;    
+    return;
   }
 
   return 'hello world';
@@ -90,7 +98,7 @@ function dialog_login_callback($type, $js) {
         if ($command['command'] == 'dialog_display') {
           $output[$i]['options']['height'] = 'auto';
           $output[$i]['options']['width'] = 600;
-          
+
           $output[$i]['options']['position'] = 'center';
           $output[$i]['options']['resizable'] = FALSE;
         }
@@ -110,5 +118,5 @@ function dialog_example_form_alter(&$form, $form_state, $form_id) {
   elseif ($form_id == 'user_register' && !empty($form_state['ajax'])) {
     $form['submit']['#attributes']['class'] = 'ctools-dialog-button';
   }
-  
-}
\ No newline at end of file
+
+}
diff --git public_html/sites/all/modules/contrib/dialog/modules/dialog_comment/dialog_comment.info public_html/sites/all/modules/contrib/dialog/modules/dialog_comment/dialog_comment.info
index a2a36cb..b0f8151 100644
--- public_html/sites/all/modules/contrib/dialog/modules/dialog_comment/dialog_comment.info
+++ public_html/sites/all/modules/contrib/dialog/modules/dialog_comment/dialog_comment.info
@@ -4,10 +4,3 @@ description = Provides Dialog integration for the core comment module.
 core = 6.x
 dependencies[] = dialog
 dependencies[] = comment
-
-; Information added by drupal.org packaging script on 2010-08-14
-version = "6.x-1.x-dev"
-core = "6.x"
-project = "dialog"
-datestamp = "1281744384"
-
diff --git public_html/sites/all/modules/contrib/dialog/modules/dialog_user/dialog_user.info public_html/sites/all/modules/contrib/dialog/modules/dialog_user/dialog_user.info
index 3d4a345..3a02d16 100644
--- public_html/sites/all/modules/contrib/dialog/modules/dialog_user/dialog_user.info
+++ public_html/sites/all/modules/contrib/dialog/modules/dialog_user/dialog_user.info
@@ -4,10 +4,3 @@ description = Provides Dialog integration for the core user module.
 core = 6.x
 dependencies[] = dialog
 dependencies[] = comment
-
-; Information added by drupal.org packaging script on 2010-08-14
-version = "6.x-1.x-dev"
-core = "6.x"
-project = "dialog"
-datestamp = "1281744384"
-
diff --git public_html/sites/all/modules/contrib/dialog/modules/dialog_user/dialog_user.module public_html/sites/all/modules/contrib/dialog/modules/dialog_user/dialog_user.module
index ebf7a40..ed7bef9 100644
--- public_html/sites/all/modules/contrib/dialog/modules/dialog_user/dialog_user.module
+++ public_html/sites/all/modules/contrib/dialog/modules/dialog_user/dialog_user.module
@@ -1,5 +1,5 @@
 <?php
-// $Id: dialog_user.module,v 1.2.2.2 2010/01/13 02:59:08 rz Exp $
+// $Id: dialog_user.module,v 1.2.2.3 2011/01/31 21:03:40 drewish Exp $
 
 /**
  * Implementation of hook_menu().
@@ -61,7 +61,7 @@ function dialog_user_block($op = 'list', $delta = 0, $edit = array()) {
           $links = array();
           $links[] = l(t('Log in'), 'user/login/nojs', array('attributes' => array('class' => 'ctools-use-dialog')));
           $links[] = l(t('Create a new account'), 'user/register/nojs', array('attributes' => array('class' => 'ctools-use-dialog')));
-          
+
           $block = array(
             'subject' => t('User login'),
             'content' => theme('item_list', $links),
@@ -79,7 +79,7 @@ function dialog_user_form_alter(&$form, $form_state, $form_id) {
   // Specify the submit buttons to be used as the dialog buttons.
   if ($form_id == 'user_login' && !empty($form_state['ajax'])) {
     $form['submit']['#attributes']['class'] = 'ctools-dialog-button';
-    
+
     // Add links like the user_form_block does.
     $items = array();
     if (variable_get('user_register', 1)) {
@@ -95,8 +95,8 @@ function dialog_user_form_alter(&$form, $form_state, $form_id) {
 
 /**
  * dialog_success handler for the user password form.  The standard password
- * form submit handler sets a message and redirects to 'user', leaving the 
- * user on the login form. That is emulated here by redirecting to 
+ * form submit handler sets a message and redirects to 'user', leaving the
+ * user on the login form. That is emulated here by redirecting to
  * the ajax version of the user login form.  Since this function is only ever
  * called in an ajax context, it is safe to redirect to another ajax handler.
  */
diff --git public_html/sites/all/modules/contrib/legal/legal.info public_html/sites/all/modules/contrib/legal/legal.info
index 563a903..c257b01 100644
--- public_html/sites/all/modules/contrib/legal/legal.info
+++ public_html/sites/all/modules/contrib/legal/legal.info
@@ -6,3 +6,10 @@ core = 6.x
 
 
 
+
+; Information added by drupal.org packaging script on 2010-11-28
+version = "6.x-2.4-rc2"
+core = "6.x"
+project = "legal"
+datestamp = "1290951968"
+
diff --git public_html/sites/all/modules/contrib/legal/legal.install public_html/sites/all/modules/contrib/legal/legal.install
index cd34a8d..1933baa 100644
--- public_html/sites/all/modules/contrib/legal/legal.install
+++ public_html/sites/all/modules/contrib/legal/legal.install
@@ -1,46 +1,54 @@
 <?php
-// $Id: legal.install,v 1.5 2008/08/02 14:03:13 MegaGrunt Exp $
+// $Id: legal.install,v 1.8 2010/10/15 02:02:11 MegaGrunt Exp $
 
 /**
  * Implementation of hook_install()
  */
 function legal_install() {
-  $created = drupal_install_schema('legal');
-
-  if ($created) {
-    drupal_set_message(t('Legal module installed successfully.'));
-  }
-  else {
-    drupal_set_message(t('Table installation for the Legal module was unsuccessful. The tables may need to be installed by hand. See legal.install file for a list of the installation queries.'), 'error');
-  }
-  
-  return;
+  drupal_install_schema('legal');
 }
 
 /**
  * Implementation of hook_schema().
  */
 function legal_schema() {
-  $schema['legal_accepted'] = array(
+  $schema['legal_conditions'] = array(
     'fields' => array(
-    	'legal_id'  => array('type' => 'serial', 'unsigned' => FALSE, 'not null' => TRUE, 'disp-width' => 10),
-    	'uid'       => array('type' => 'int', 'unsigned' => FALSE, 'not null' => TRUE, 'default' => 0, 'disp-width' => 10),
-    	'tc_id'     => array('type' => 'int', 'unsigned' => FALSE, 'not null' => TRUE, 'default' => 0, 'disp-width' => 10),
-    	'accepted'  => array('type' => 'int', 'unsigned' => FALSE, 'not null' => TRUE, 'default' => 0, 'disp-width' => 11),
+      'tc_id' => array('type' => 'serial', 'unsigned' => FALSE, 'not null' => TRUE, 'disp-width' => 10),
+      'version' => array('type' => 'int', 'unsigned' => FALSE, 'not null' => TRUE, 'default' => 0, 'disp-width' => 11),
+      'revision' => array('type' => 'int', 'unsigned' => FALSE, 'not null' => TRUE, 'default' => 0, 'disp-width' => 11),
+    	'language' => array(
+      	'description' => t("TODO."),
+      	'type' => 'varchar',
+      	'length' => '12',
+      	'not null' => TRUE,
+      	'default' => ''
+    	),
+      'conditions'  => array('type' => 'text', 'size' => 'big', 'not null' => TRUE),
+      'date'        => array('type' => 'int', 'unsigned' => FALSE, 'not null' => TRUE, 'default' => 0, 'disp-width' => 11),
+      'extras'      => array('type' => 'text'),
+      'changes'     => array('type' => 'text'),
     ),
-    'indexes' => array('uid' => array('uid')),
-    'primary key' => array('legal_id'),
+    'primary key' => array('tc_id'),
   );
 
-  $schema['legal_conditions'] = array(
+  $schema['legal_accepted'] = array(
     'fields' => array(
-    	'tc_id'       => array('type' => 'serial', 'unsigned' => FALSE, 'not null' => TRUE, 'disp-width' => 10),
-    	'conditions'  => array('type' => 'text', 'size' => 'big', 'not null' => TRUE),
-    	'date'        => array('type' => 'int', 'unsigned' => FALSE, 'not null' => TRUE, 'default' => 0, 'disp-width' => 11),
-    	'extras'      => array('type' => 'text'),
-    	'changes'     => array('type' => 'text'),
+      'legal_id'  => array('type' => 'serial', 'unsigned' => FALSE, 'not null' => TRUE, 'disp-width' => 10),
+      'version' => array('type' => 'int', 'unsigned' => FALSE, 'not null' => TRUE, 'default' => 0, 'disp-width' => 11),
+      'revision' => array('type' => 'int', 'unsigned' => FALSE, 'not null' => TRUE, 'default' => 0, 'disp-width' => 11),
+    	'language' => array(
+      	'description' => t("TODO."),
+      	'type' => 'varchar',
+      	'length' => '12',
+      	'not null' => TRUE,
+      	'default' => ''
+    	),
+      'uid'       => array('type' => 'int', 'unsigned' => FALSE, 'not null' => TRUE, 'default' => 0, 'disp-width' => 10),
+      'accepted'  => array('type' => 'int', 'unsigned' => FALSE, 'not null' => TRUE, 'default' => 0, 'disp-width' => 11),
     ),
-    'primary key' => array('tc_id'),
+    'indexes' => array('uid' => array('uid')),
+    'primary key' => array('legal_id'),
   );
 
   return $schema;
@@ -48,8 +56,8 @@ function legal_schema() {
 
 function legal_update_1() {
 
-	_system_update_utf8(array('legal_accepted', 'legal_conditions'));
-	
+  _system_update_utf8(array('legal_accepted', 'legal_conditions'));
+
   $ret = array();
 
   db_add_field($ret, 'legal_conditions', 'extras', array('type' => 'text'));
@@ -60,7 +68,7 @@ function legal_update_1() {
 
 /**
  * Remove conditions and extras from users.data field.
-*/ 
+*/
 function legal_update_2() {
   // How many users to process each time.
   $limit = 50;
@@ -70,7 +78,7 @@ function legal_update_2() {
     $conditions = db_fetch_array(db_query_range("SELECT * FROM {legal_conditions} ORDER BY tc_id DESC", 0, 1));
     if (empty($conditions['conditions'])) return;
 
-		$extras = empty($conditions['extras']) ? NULL : array_keys(unserialize($conditions['extras']));
+    $extras = empty($conditions['extras']) ? NULL : array_keys(unserialize($conditions['extras']));
 
     $_SESSION['legal_update_2'] = array(
       'uid' => 0,
@@ -85,18 +93,18 @@ function legal_update_2() {
   while ($user = db_fetch_object($result)) {
     $data = unserialize($user->data);
 
-    unset($data['conditions']); 
+    unset($data['conditions']);
 
-		if (!empty($_SESSION['legal_update_2']['extras'])) {
-	    foreach ($_SESSION['legal_update_2']['extras'] as $extra) {
-	      unset($data[$extra]);
-	    }
-		}
+    if (!empty($_SESSION['legal_update_2']['extras'])) {
+      foreach ($_SESSION['legal_update_2']['extras'] as $extra) {
+        unset($data[$extra]);
+      }
+    }
 
     db_query("UPDATE {users} SET data = '%s' WHERE uid = %d", serialize($data), $user->uid);
 
     $_SESSION['legal_update_2']['uid'] = $user->uid;
-    
+
     $user_count++;
   }
 
@@ -111,6 +119,31 @@ function legal_update_2() {
   }
 }
 
+/**
+ * Add version, revision, and language fields.
+*/
+function legal_update_6003() {
+
+  $ret = array();
+
+  db_add_field($ret, 'legal_conditions', 'version', array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0));
+  db_add_field($ret, 'legal_conditions', 'revision', array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0));
+  db_add_field($ret, 'legal_conditions', 'language', array('type' => 'varchar', 'length' => '12', 'not null' => TRUE, 'default' => ''));
+  db_add_field($ret, 'legal_accepted', 'version', array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0));
+  db_add_field($ret, 'legal_accepted', 'revision', array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0));
+  db_add_field($ret, 'legal_accepted', 'language', array('type' => 'varchar', 'length' => '12', 'not null' => TRUE, 'default' => ''));
+
+  $ret[] = update_sql('UPDATE {legal_conditions} SET version = tc_id');
+  $ret[] = update_sql('UPDATE {legal_conditions} SET revision = 1');
+  $ret[] = update_sql("UPDATE {legal_conditions} SET language = 'en'");
+  $ret[] = update_sql('UPDATE {legal_accepted} SET version = tc_id');
+  $ret[] = update_sql('UPDATE {legal_accepted} SET revision = 1');
+  $ret[] = update_sql("UPDATE {legal_accepted} SET language = 'en'");
+
+  db_drop_field($ret, 'legal_accepted', 'tc_id'); 
+
+  return $ret;	
+}
 
 /**
  * Implementation of hook_uninstall().
@@ -119,4 +152,3 @@ function legal_uninstall() {
   drupal_uninstall_schema('legal');
   variable_del('legal_display');
 }
-
diff --git public_html/sites/all/modules/contrib/legal/legal.module public_html/sites/all/modules/contrib/legal/legal.module
index 15f7703..ce8b1df 100644
--- public_html/sites/all/modules/contrib/legal/legal.module
+++ public_html/sites/all/modules/contrib/legal/legal.module
@@ -1,20 +1,20 @@
 <?php
-// $Id: legal.module,v 1.21 2008/08/02 13:36:32 MegaGrunt Exp $
+// $Id: legal.module,v 1.33 2010/11/28 13:42:42 MegaGrunt Exp $
 
 /**
  * Implementation of hook_help().
  */
 function legal_help($path, $arg) {
   $output = '';
-
   switch ($path) {
-     case 'admin/help#legal':
-      $output .= t('Display a Terms & Conditions statement on the registration page, require visitor to accept T&C to register.');
-      $output .= t('When a user creates an account they are required to accept your Terms & Conditions to complete their registration.');
+    case 'admin/help#legal':
+      $output .= t('Display a Terms & Conditions statement on the registration page, require visitor to accept T&C to register. 
+										When a user creates an account they are required to accept your Terms & Conditions to complete their registration.');
       break;
-     case 'admin/settings/legal':
-      $output .= t('Display a Terms & Conditions statement on the registration page, require visitor to accept the T&C to register. ');
-      $output .= t("A !page displaying your T&C will be automatically created, access to this page can be set via the !access administration page.", array('!page' => l('page', 'legal'), '!access' => l('permissions', 'admin/user/permissions')));
+    case 'admin/settings/legal':
+      $output .= t('Display a Terms & Conditions statement on the registration page, require visitor to accept the T&C to register. 
+										A <a href="@page">page</a> displaying your T&C will be automatically created, access to this page can be set via the <a href="@access">permissions</a> administration page.', 
+										array('@page' => url('legal'), '@access' => url('admin/user/permissions')));
   }
   return $output;
 }
@@ -30,38 +30,59 @@ function legal_perm() {
  * Implementation of hook_access().
  */
 function legal_access($op, $node, $account) {
-  if ($op == 'view' && (user_access('view Terms and Conditions') || user_access('administer Terms and Conditions') ) ) return TRUE;
+  return ($op == 'view' && (user_access('view Terms and Conditions') || user_access('administer Terms and Conditions')));
 }
 
 /**
  * Implementation of hook_menu().
  */
 function legal_menu() {
-
   $items = array();
 
-	$items['admin/settings/legal'] = array( 
-	   'title' => 'Legal', 
-	   'page callback' => 'drupal_get_form',
-	   'page arguments' => array('legal_administration'),
-	   'access arguments' => array('administer Terms and Conditions'),
-	   'description' => 'Display Terms and Conditions statement on the registration page.',
-	   );
-	$items['legal'] = array(
-	   'title' => 'Terms and Conditions',
-	   'page callback' => 'legal_page',
-	   'access arguments' => array('view Terms and Conditions'),
-	   'type' => MENU_CALLBACK
-	   );
-	$items['legal_accept/%/%'] = array(
-	   'title' => 'Terms and Conditions',
-	   'page callback' => 'drupal_get_form',
-	   'page arguments' => array('legal_login', 1, 2),
-	   'access callback' => TRUE,
-	   'type' => MENU_CALLBACK
-	   ); 
-
-  
+  $items['admin/settings/legal'] = array(
+    'title' => 'Legal',
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array('legal_administration'),
+    'access arguments' => array('administer Terms and Conditions'),
+    'description' => 'Display Terms and Conditions statement on the registration page.',
+    'file' => 'legal.admin.inc',
+  );
+
+	$items['admin/settings/legal/terms'] = array(
+	  'title' => 'Current Terms',
+	  'access arguments' => array('administer Terms and Conditions'),
+	  'description' => 'Display Terms and Conditions statement on the registration page.',
+	  'type' => MENU_DEFAULT_LOCAL_TASK, 
+	);
+	
+	$items['admin/settings/legal/languages'] = array(
+	  'title' => 'Languages',
+	  'page callback' => 'drupal_get_form',
+	  'page arguments' => array('legal_languages'),
+		'access callback' => 'legal_languages_access',
+	  'access arguments' => array('administer Terms and Conditions'),
+	  'description' => 'Display Terms and Conditions statement on the registration page.',
+	    'weight' => 10, 
+		'type' => MENU_LOCAL_TASK,
+	  'file' => 'legal.admin.inc',
+	); 
+	
+  $items['legal'] = array(
+    'title' => 'Terms and Conditions',
+    'page callback' => 'legal_page',
+    'access arguments' => array('view Terms and Conditions'),
+    'type' => MENU_CALLBACK,
+    'file' => 'legal.pages.inc',
+  );
+
+  $items['legal_accept/%/%'] = array(
+    'title' => 'Terms and Conditions',
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array('legal_login', 1, 2),
+    'access callback' => TRUE,
+    'type' => MENU_CALLBACK,
+  );
+
   return $items;
 }
 
@@ -78,668 +99,566 @@ function legal_theme() {
 }
 
 function legal_display_fields($conditions) {
-    
-    $form = array();
-		$accept_label = t('<strong>Accept</strong> Terms & Conditions of Use');
-    
-    $form['current_id'] = array(
-      '#type' => 'value',
-      '#value' => $conditions['tc_id'],
-    );
-    
-    $form['current_date'] = array(
-      '#type' => 'value',
-      '#value' => $conditions['date'],
-    );
-    
-    $form['display'] = array(
-      '#type' => 'value',
-      '#value' => variable_get('legal_display', '0'),
-    );
-    
-    $form['legal'] = array(
-      '#type' => 'fieldset',
-      '#title' => t('Terms and Conditions of Use'),
-      '#weight' => 29,
-    );
-
-    switch (variable_get('legal_display', '0')) {
-    
-        case 1: // scroll box (CSS)
-        case 2: // HTML
-            $form['legal']['conditions'] = array(
-              '#value' => filter_xss_admin($conditions['conditions']),
-            );
-            break;
-        case 3: // Page Link
-            $form['legal']['conditions'] = array(
-              '#value' => ' ',
-            );
-						$accept_label = t('<strong>Accept</strong> !terms of Use', array('!terms' => l('Terms & Conditions', 'legal')));
-            break;  
-
-        default: // scroll box (HTML)
-            $form['legal']['conditions'] = array(
-              '#type' => 'textarea',
-              '#title' => t('Terms & Conditions'),
-              '#default_value' => $conditions['conditions'],
-              '#value' => $conditions['conditions'],
-              '#rows' => 10,
-              '#weight' => 0,
-              '#attributes' => array('readonly' => 'readonly'),
-            );
-    }
+  $form = array();
+  $accept_label = t('<strong>Accept</strong> Terms & Conditions of Use');
 
-    if (!empty($conditions['extras'])) {
-        while (list ($key, $label) = each ($conditions['extras'])) {
-
-            if (!empty($label)) {
-                $form['legal'][$key] = array(
-                    '#type' => 'checkbox',
-                    '#title' => filter_xss_admin($label),
-                    '#default_value' => 0,
-                    '#weight' => 2,
-                    '#required' => TRUE,
-                );
-            }
-        }
-    }
-    
-    $form['legal']['legal_accept'] = array(
-        '#type' => 'checkbox',
-      	'#title' => $accept_label,
-        '#default_value' => 0,
-        '#weight' => 50,
-        '#required' => TRUE,
-    );
-    
-    return $form;
-}
+  $form['current_id'] = array(
+    '#type' => 'value',
+    '#value' => $conditions['version'],
+  );
+  $form['language_value'] = array(
+    '#type' => 'value',
+    '#value' => $conditions['language'],
+  );
+  $form['revision_id'] = array(
+    '#type' => 'value',
+    '#value' => $conditions['revision'],
+  );
+  $form['current_date'] = array(
+    '#type' => 'value',
+    '#value' => $conditions['date'],
+  );
+  $form['display'] = array(
+    '#type' => 'value',
+    '#value' => variable_get('legal_display', '0'),
+  );
+  $form['legal'] = array(
+    '#type' => 'fieldset',
+    '#title' => t('Terms and Conditions of Use'),
+    '#weight' => 29,
+  );
 
-function legal_page() {
-    
-    $conditions = legal_get_conditions();
-    $output = '';
-    
-    switch(variable_get('legal_display', '0')) {
-      case 0: // Scroll Box
-        $output = nl2br(strip_tags($conditions['conditions']));
-        break;
-      case 1: // CSS Scroll Box with HTML
-      case 2: // HTML
-      case 3: // Page Link 
-        $output = filter_xss_admin($conditions['conditions']);
-        break;
-    }
-    
-    return $output;
-}
+  switch (variable_get('legal_display', '0')) {
+    case 1: // scroll box (CSS)
+    case 2: // HTML
+      $form['legal']['conditions'] = array(
+        '#value' => filter_xss_admin($conditions['conditions']),
+      );
+      break;
 
-function legal_administration() {
-
-    $conditions = legal_get_conditions();
-    $form = legal_display_fields($conditions);
-    
-    $form['conditions'] = array(
-      '#type' => 'textarea',
-      '#title' => t('Terms & Conditions'),
-      '#default_value' => $conditions['conditions'],
-      '#description' => t('Your Terms & Conditions'),
-      '#required' => TRUE,
-    ); 
-    
-    // overide accept checbox requirement on preview 
-    $form['legal']['legal_accept']['#required'] = FALSE;
-    
-    // overide display setting
-    $form['display'] = array(
-      '#type' => 'radios',
-      '#title' => t('Display Style'),
-      '#default_value' => variable_get('legal_display', '0'),
-      '#options' => array(t('Scroll Box'), t('Scroll Box (CSS)'), t('HTML Text'), t('Page Link')),
-      '#description' => t('How terms & conditions should be displayed to users.'),
-      '#required' => TRUE,
-    );
-    
-    // additional checkboxes
-    $form['extras'] = array(
-      '#type' => 'fieldset',
-      '#title' => t('Additional Checkboxes'),
-      '#description' => t('Each field will be shown as a checkbox which the user must tick to register.'),
-      '#collapsible' => TRUE,
-      '#collapsed' => TRUE,
-      '#tree' => TRUE,
-    );
-  
-    $extras_count = count($conditions['extras']);
-    if ($extras_count < 5) $extras_count = 5;
-    
-    for ($counter = 1; $counter <= $extras_count; $counter++) {
-    
-      $form['extras']['extras-' . $counter] = array(
-	      '#type' => 'textfield',
-	      '#title' => t('Label'),
-	      '#default_value' => $conditions['extras']['extras-' . $counter],
+    case 3: // Page Link
+      $form['legal']['conditions'] = array(
+        '#value' => ' ',
       );
-      
-      // overide extra checkboxes  
-			if (!empty($conditions['extras']['extras-' . $counter])) {
-			  $form['legal']['extras-' . $counter] = array(
-		      '#type' => 'checkbox',
-		      '#title' => filter_xss_admin($conditions['extras']['extras-' . $counter]),
-		      '#default_value' => 0,
-		      '#weight' => 2,
-		      '#required' => FALSE,   
-			  ); 
-			} 
-    }
-    
-    // notes about changes to T&C
-    $form['changes'] = array(
-      '#type' => 'fieldset',
-      '#title' => t('Explain Changes'),
-      '#description' => t('Explain what changes were made to the T&C since the last version. This will only be shown to users who accepted a previous version. Each line will automatically be shown as a bullet point.'),
-      '#collapsible' => TRUE,
-      '#collapsed' => TRUE,
-    );
-    
-    $form['changes']['changes'] = array(
+      $accept_label = t('<strong>Accept</strong> <a href="@terms">Terms & Conditions</a> of Use', array('@terms' => url('legal')));
+      break;
+
+    default: // scroll box (HTML)
+      $form['legal']['conditions'] = array(
         '#type' => 'textarea',
-        '#title' => t('Changes'),
-    );
-    
-    $form['#after_build'] = array('legal_preview');
-    
-    $form['preview'] = array(
-      '#type' => 'button',
-      '#value' => t('Preview'),
-    );
-    
-    $form['save'] = array(
-      '#type' => 'submit',
-      '#value' => t('Save'),
-    );
-    
-    return $form;
-}
+        '#title' => t('Terms & Conditions'),
+        '#default_value' => $conditions['conditions'],
+        '#value' => $conditions['conditions'],
+        '#rows' => 10,
+        '#weight' => 0,
+        '#attributes' => array('readonly' => 'readonly'),
+      );
+  }
 
-function legal_preview($form, $form_values) {
-
-    switch ($form['display']['#value']) {
-    
-        case 1: // scroll box (CSS)
-        case 2: // HTML
-            $form['legal']['conditions'] = array(
-              '#value' => filter_xss_admin($form['conditions']['#value']),
-            );
-				    $form['legal']['legal_accept']['#title'] = t('<strong>Accept</strong> Terms & Conditions of Use');
-            break;
-        case 3: // Page Link
-            $form['legal']['conditions'] = array(
-              '#value' => ' ',
-            );
-				    $form['legal']['legal_accept']['#title'] = t('<strong>Accept</strong> !terms of Use', array('!terms' => l('Terms & Conditions', 'legal')));
-            break;  
-        default: // scroll box (HTML)
-            $form['legal']['conditions'] = array(
-              '#type' => 'textarea',
-              '#title' => t('Terms & Conditions'),
-              '#value' => $form['conditions']['#value'],
-              '#parents' => array('legal'),
-              '#rows' => 10,
-              '#attributes' => array('readonly' => 'readonly'),
-            );
-						$form['legal']['legal_accept']['#title'] = t('<strong>Accept</strong> Terms & Conditions of Use');
+  if (!empty($conditions['extras'])) {
+    foreach ($conditions['extras'] as $key => $label) {
+      if (!empty($label)) {
+        $form['legal'][$key] = array(
+          '#type' => 'checkbox',
+          '#title' => filter_xss_admin($label),
+          '#default_value' => 0,
+          '#weight' => 2,
+          '#required' => TRUE,
+        );
+      }
     }
+  }
 
-    // overide additional checkboxes in preview
-    if (!empty($form_values['extras'])) {
-   
-        while (list ($key, $label) = each ($form_values['extras'])) {
-            
-            if (empty($label)) {
-                unset($form['legal'][$key]);
-            } else {
-                $form['legal'][$key]['#title'] = filter_xss_admin($label);
-            }
+  $form['legal']['legal_accept'] = array(
+    '#type' => 'checkbox',
+    '#title' => $accept_label,
+    '#default_value' => 0,
+    '#weight' => 50,
+    '#required' => TRUE,
+  );
 
-        }
-        
-    }   
+  return $form;
+}
 
+function theme_legal_display($form) {
+  if (!empty($form['legal']['conditions']['#value'])) {
+    // Scroll box (CSS).
+    if ($form['display']['#value'] == 1) {
+      $path = base_path() . drupal_get_path('module', 'legal');
+      drupal_add_css(drupal_get_path('module', 'legal') .'/legal.css');
+      $form['legal']['conditions']['#prefix' ] = '<div class="legal-terms">';
+      $form['legal']['conditions']['#suffix' ] = '</div>';
+    }
     return $form;
+  }
 }
 
-function legal_administration_validate($form, &$form_state) {
-
-  if ( empty($form_state['values']['conditions']) ) form_set_error('conditions', t('Terms & Conditions must be entered.'));
-  return;
+function theme_legal_page($form) {
+  if (!empty($form['current_id']['#value'])) {
+    $form = theme('legal_display', $form);
+    return drupal_render($form);
+  }
 }
 
-function legal_administration_submit($form, &$form_state) {
+/**
+ * Implementation of hook_user().
+ */
+function legal_user($op, &$edit, &$account, $category = FALSE) {
+  global $user;
+  global $language;
 
-	$values = $form_state['values'];    
-	if ($form_state['clicked_button']['#value'] == t('Preview')) return;
+  switch ($op) {
+    case 'register':
+      $conditions = legal_get_conditions($language->language);
 
-  if ( variable_get('legal_display', '0') !=  $form_state['values']['display'] ) {
-      variable_set('legal_display', $form_state['values']['display']);
-      drupal_set_message(t('Display setting has been saved.'));
-  }
+      // Do nothing if there's no Terms and Conditions text set.
+      if (empty($conditions['conditions'])) {
+        return;
+      }
 
-  // If new conditions are different from current permisions - enter in database
-  if ( legal_conditions_updated($form) ) {
-      db_query("INSERT INTO {legal_conditions} (tc_id, conditions, date, extras, changes) VALUES (NULL, '%s', %d, '%s', '%s')", $values['conditions'], time(), serialize($values['extras']), $values['changes']);
-      drupal_set_message (t('Terms & Conditions have been saved.'));
-  }
-  
-  cache_clear_all();
-  return;  
-}
+      $form_fields = legal_display_fields($conditions);
 
-function theme_legal_administration($form) {
+      // Disable checkbox if:
+      //  - user is already registered (administer users);
+      //  - users with 'administer users' can access registration on admin/user/user/create.
+      if (!empty($user->uid)) {
+        $form_fields['legal']['legal_accept']['#attributes'] = array('disabled' => 'disabled');
+        $form_fields['legal']['legal_accept']['#required'] = FALSE;
 
-    if (empty($form['current_id']['#value'])) {
-        $output = '<p><strong>' .t('Terms & Conditions will not be shown to users, as no T&C have been saved.') . '</strong></p>';
-    } else {
-        $output = '<h4>' . t('Current Version') . '</h4><p><strong>' . t('Version ID:') . '</strong> ' . $form['current_id']['#value'] . '<br /><strong>' . t('Last saved:') . '</strong> ' . date("l jS \of F Y h:i:s A", $form['current_date']['#value']) . '</p>';
-    }
-    
-    // preview
-    if (empty($form['legal']['conditions']['#value'])) {
-        drupal_render($form['legal']);
-    } else {
-        
-        $output .= '<div id="preview">';
-        $output .= '<h3>'. t('Preview') .'</h3>';
-        $form = theme('legal_display', $form);
-        $output .= drupal_render($form['legal']);
-        $output .= '</div>';
-    }
+        foreach ($conditions['extras'] as $key => $label) {
+          if (!empty($label)) {
+            $form_fields['legal'][$key]['#attributes'] = array('disabled' => 'disabled');
+            $form_fields['legal'][$key]['#required'] = FALSE;
+          }
+        }
+      }
+      else {
+        $form_fields['legal']['legal_accept']['#default_value'] = $edit['legal_accept'];
+      }
+
+      $form = theme('legal_display', $form_fields);
+      return $form;
+
+    case 'login':
+	    if ($user->uid == 1) {
+	      break;
+	    }  
+
+      // get last accepted version for this account
+    	$legal_account = legal_get_accept($user->uid);
+
+			// if no version has been accepted yet, get version with current language revision
+			if (empty($legal_account['version'])) {
+				$conditions = legal_get_conditions($language->language);
+	      // no conditions set yet
+				if (empty($conditions['conditions'])) return;	
+			}
+			else { // get version / revision of last accepted language
+
+				$conditions = legal_get_conditions($legal_account['language']);
+				// no conditions set yet 
+	      if (empty($conditions['conditions'])) return;
+	
+        // Check latest version of T&C has been accepted.
+        $accepted = legal_version_check($user->uid, $conditions['version'], $conditions['revision'], $legal_account);
 
-    $output .= drupal_render($form);
-    
-    return $output;
-}
+				if ($accepted) {
+					return;
+				}
+			}
 
-function theme_legal_display($form) {
+      $uid = $user->uid;
 
-    if (empty($form['legal']['conditions']['#value'])) return;
-        
-    // scroll box (CSS)
-    if ($form['display']['#value'] == 1) {
-        $path = base_path() . drupal_get_path('module', 'legal');
-        drupal_add_css(drupal_get_path('module', 'legal') .'/legal.css');
-        $form['legal']['conditions']['#prefix' ] = '<div class="legal-terms">';
-        $form['legal']['conditions']['#suffix' ] = '</div>';
-    }
+      // Destroy the current session.
+      session_destroy();
+      module_invoke_all('user', 'logout', NULL, $user);
 
-    return $form;
-}
+      // We have to use $GLOBALS to unset a global variable.
+      $user = user_load(array('uid' => 0));
+      unset($_REQUEST['destination']);
 
-function theme_legal_page($form) {
+      $signatory = db_fetch_object(db_query_range('SELECT * FROM {users} WHERE uid = %d', $uid, 0, 1));
 
-    if (empty($form['current_id']['#value'])) return;
-        
-    $form = theme('legal_display', $form);
-    $output .= drupal_render($form);
-    
-    return $output;
-}
+      drupal_goto('legal_accept/' . $signatory->uid . '/' . md5($signatory->name . $signatory->pass . $signatory->login));
+      break;
 
-function legal_user($op, &$edit, &$account, $category = FALSE) {
+    case 'form':
 
-    global $user;
-    
-    switch ($op) {
-        
-      case 'register':
-        
-        $conditions = legal_get_conditions();
-        if (empty($conditions['conditions'])) return;
-        
-        $form_fields = legal_display_fields($conditions);
-        
-        // disable checkbox if:
-        // user is already registered (administer users)
-				// users with 'administer users' can access registration on admin/user/user/create
-        if (!empty($user->uid)) {
-            $form_fields['legal']['legal_accept']['#attributes'] = array('disabled' => 'disabled');
-            $form_fields['legal']['legal_accept']['#required'] = FALSE;
-            
-              
-                reset($conditions['extras']);
-                while (list ($key, $label) = each ($conditions['extras'])) {
-                    if (!empty($label)) {
-                        $form_fields['legal'][$key]['#attributes'] = array('disabled' => 'disabled');
-                        $form_fields['legal'][$key]['#required'] = FALSE;
-                    }
-                }
-           
-            
-        } else {
-            $form_fields['legal']['legal_accept']['#default_value'] = $edit['legal_accept'];
-        }
-        
-        $form = theme('legal_display', $form_fields);
-        return $form;
-
-      case 'login':
-
-        $conditions = legal_get_conditions();
-        if (empty($conditions['conditions'])) return;
-
-        $accepted = legal_version_check($user->uid, $conditions['tc_id']);
-        if ($accepted == TRUE || $user->uid == 1) break;
-
-        $uid = $user->uid;
-
-        // Destroy the current session:
-        session_destroy();
-        module_invoke_all('user', 'logout', NULL, $user);
-
-        // We have to use $GLOBALS to unset a global variable:
-        $user = user_load(array('uid' => 0));
-        unset($_REQUEST['destination']);
-
-        $signatory = db_fetch_object(db_query('SELECT * FROM {users} WHERE uid = %d LIMIT 1', $uid));
-
-        drupal_goto('legal_accept/' . $signatory->uid . '/' . md5($signatory->name . $signatory->password . $signatory->login)); 
-        break;  
-        
-      case 'form':
-        
-        $conditions = legal_get_conditions();
-        if (empty($conditions['conditions'])) return;
-        
-        if ($category == 'account') {
-    
-            $form_fields = legal_display_fields($conditions);
-            
-            // check latest version of T&C has been accepted
-            $accepted = legal_version_check($account->uid, $conditions['tc_id']);
-            
-            if ($accepted == TRUE) {
-                $form_fields['legal']['legal_accept']['#value'] = 1;
-                
-                if (!empty($conditions['extras'])) {
-                    while (list ($key, $label) = each ($conditions['extras'])) {
-                        if (!empty($label)) {
-                            $form_fields['legal'][$key]['#value'] = 1;
-                        }
-                    }
-                }
-            }
-    
-            // disable checkbox if:
-            // user is not account owner
-            // latest T&C has already been accepted
-            if ($account->uid != $user->uid || $accepted  == TRUE) {
-                $form_fields['legal']['legal_accept']['#attributes'] = array('disabled' => 'disabled');
-                
-                if (!empty($conditions['extras'])) {
-                    reset($conditions['extras']);
-                    while (list ($key, $label) = each ($conditions['extras'])) {
-                        if (!empty($label)) {
-                            $form_fields['legal'][$key]['#attributes'] = array('disabled' => 'disabled');
-                        }
-                    }
-                }
-            }
-            
-            // not required if user is not account owner
-            if ($account->uid != $user->uid) {
-                $form_fields['legal']['legal_accept']['#required'] = FALSE;
-            
-                if (!empty($conditions['extras'])) {
-                    reset($conditions['extras']);
-                    while (list ($key, $label) = each ($conditions['extras'])) {
-                        if (!empty($label)) {
-                            $form_fields['legal'][$key]['#required'] = FALSE;
-                        }
-                    }
-                }            
-            }
-
-            // enable account owner to accept
-            if ($account->uid == $user->uid && $accepted != TRUE) {
-                $form_fields['legal']['legal_accept']['#default_value'] = $edit['legal_accept'];
-                $form_fields['legal']['legal_accept']['#required'] = TRUE;
-                
-                if (!empty($conditions['extras'])) {
-                    reset($conditions['extras']);
-                    while (list ($key, $label) = each ($conditions['extras'])) {
-                        if (!empty($label)) {
-                            $form_fields['legal'][$key]['#default_value'] = $edit[$key];
-                            $form_fields['legal'][$key]['#required'] = TRUE;
-                        }
-                    }
-                } 
-                
-            }
-            
-            $form = theme('legal_display', $form_fields);
-            return $form;
-        }
+      if ($category != 'account') return;
+	
+      // get last accepted version for this account
+      $legal_account = legal_get_accept($account->uid);
+
+			// if no version has been accepted yet, get version with current language revision
+			if (empty($legal_account['version'])) {
+				$conditions = legal_get_conditions($language->language);
+	      // no conditions set yet
+				if (empty($conditions['conditions'])) return;	
+			}
+			else { // get version / revision of last accepted language
+
+				$conditions = legal_get_conditions($legal_account['language']);
+				// no conditions set yet 
+	      if (empty($conditions['conditions'])) return;
+	
+        // Check latest version of T&C has been accepted.
+        $accepted = legal_version_check($account->uid, $conditions['version'], $conditions['revision'], $legal_account);
+
+				// enable language switching if version accepted and revision up to date
+				if ($accepted && $legal_account['language'] != $language->language) {
+					$conditions = legal_get_conditions($language->language);
+				}
+			}
+
+       $form_fields = legal_display_fields($conditions);
+
+       if ($accepted == TRUE) {
+         $form_fields['legal']['legal_accept']['#value'] = 1;
+         if (!empty($conditions['extras'])) {
+           foreach ($conditions['extras'] as $key => $label) {
+             if (!empty($label)) {
+               $form_fields['legal'][$key]['#value'] = 1;
+             }
+           }
+         }
+       }
+
+       // Disable checkbox if:
+       //  - user is not account owner;
+       //  - latest T&C has already been accepted.
+       if ($account->uid != $user->uid || $accepted  == TRUE) {
+         $form_fields['legal']['legal_accept']['#attributes'] = array('disabled' => 'disabled');
+         if (!empty($conditions['extras'])) {
+           reset($conditions['extras']);
+           foreach ($conditions['extras'] as $key => $label) {
+             if (!empty($label)) {
+               $form_fields['legal'][$key]['#attributes'] = array('disabled' => 'disabled');
+             }
+           }
+         }
+       }
+
+       // Not required if user is not account owner.
+       if ($account->uid != $user->uid) {
+         $form_fields['legal']['legal_accept']['#required'] = FALSE;
+         if (!empty($conditions['extras'])) {
+           reset($conditions['extras']);
+           foreach ($conditions['extras'] as $key => $label) {
+             if (!empty($label)) {
+               $form_fields['legal'][$key]['#required'] = FALSE;
+             }
+           }
+         }
+       }
+
+       // Enable account owner to accept.
+       if ($account->uid == $user->uid && $accepted != TRUE) {
+         $form_fields['legal']['legal_accept']['#default_value'] = isset($edit['legal_accept']) ? $edit['legal_accept'] : '';
+         $form_fields['legal']['legal_accept']['#required'] = TRUE;
+
+         if (!empty($conditions['extras'])) {
+           reset($conditions['extras']);
+           foreach ($conditions['extras'] as $key => $label) {
+             if (!empty($label)) {
+               $form_fields['legal'][$key]['#default_value'] = $edit[$key];
+               $form_fields['legal'][$key]['#required'] = TRUE;
+             }
+           }
+         }
+       }
+
+       $form = theme('legal_display', $form_fields);
+       return $form;
 
-        break;
+      break;
 
     case 'insert':
+      $conditions = legal_get_conditions($language->language);
 
-        $conditions = legal_get_conditions();
-        if (empty($conditions['conditions'])) return;
+      if (empty($conditions['conditions'])) {
+        return;
+      }
 
-        $edit['legal_accept'] = NULL;
+      $edit['legal_accept'] = NULL;
 
-        $edit['conditions'] = NULL;
+      $edit['conditions'] = NULL;
 
-        foreach ($conditions['extras'] as $key => $label) {
-          $edit[$key] = NULL;
-        }
+      foreach ($conditions['extras'] as $key => $label) {
+        $edit[$key] = NULL;
+      }
 
-        // don't insert if user is already registered (administrator)
-        if (!empty($user->uid)) break;
+      // Don't insert if user is already registered (administrator).
+      if (!empty($user->uid)) {
+        break;
+      }
+
+      legal_save_accept($conditions['version'], $conditions['revision'], $conditions['language'], $account->uid);
+      break;
 
-        legal_save_accept($account->uid, $conditions['tc_id']);
-        break;  
-       
     case 'update':
-        
-        $conditions = legal_get_conditions();
-        if (empty($conditions['conditions'])) return;
-        
-        $edit['legal_accept'] = NULL;
-        $edit['conditions'] = NULL;
-        
-        foreach ($conditions['extras'] as $key => $label) {
-            $edit[$key] = NULL;
-        }
-        
-        if ($account->uid != $user->uid) break;     
-        
-        // if already accepted skip data entry
-        $accepted = legal_version_check($account->uid, $conditions['tc_id']);
-        
-        if ($accepted == TRUE) break;
-        
-        legal_save_accept($account->uid, $conditions['tc_id']);
+      $conditions = legal_get_conditions($language->language);
+      if (empty($conditions['conditions'])) {
+        return;
+      }
+
+      $edit['legal_accept'] = NULL;
+      $edit['conditions'] = NULL;
+
+      foreach ($conditions['extras'] as $key => $label) {
+        $edit[$key] = NULL;
+      }
+
+      if ($account->uid != $user->uid) {
         break;
-        
-    }
-    
-    return;
+      }
+
+      // If already accepted skip data entry.
+      $accepted = legal_version_check($account->uid, $conditions['version'], $conditions['revision']);
+
+      if ($accepted == TRUE) {
+        break;
+      }
+
+      legal_save_accept($conditions['version'], $conditions['revision'], $conditions['language'], $account->uid);
+      break;
   }
-  
-// require registered users to accept new T&C  
+}
+
+/**
+ * Require registered users to accept new T&C.
+ */
 function legal_login($constructor, $uid, $id_hash = NULL) {
+  global $language;
+
+	// get last accepted version for this account
+	$legal_account = legal_get_accept($uid);
+
+	// if no version has been accepted yet, get version with current language revision
+	if (empty($legal_account['version'])) {
+		$conditions = legal_get_conditions($language->language);
+	  // no conditions set yet
+		if (empty($conditions['conditions'])) return;	
+	}
+	else { // get version / revision of last accepted language
+
+		$conditions = legal_get_conditions($legal_account['language']);
+		// no conditions set yet 
+	  if (empty($conditions['conditions'])) return;
+
+	  // Check latest version of T&C has been accepted.
+	  $accepted = legal_version_check($uid, $conditions['version'], $conditions['revision'], $legal_account);
+
+		if ($accepted) {
+			return;
+		}
+	}
 	
-	$conditions = legal_get_conditions();
-	$form = legal_display_fields($conditions);
+  $form = legal_display_fields($conditions);
 
-	$form['uid'] = array(
-	    '#type' => 'value',
-	    '#value' => $uid,
-	);
-	$form['id_hash'] = array(
-	    '#type' => 'value',
-	    '#value' => $id_hash,
-	);
-	$form['tc_id'] = array(
-	    '#type' => 'value',
-	    '#value' => $conditions['tc_id'],
-	);
+  $form['uid'] = array(
+    '#type' => 'value',
+    '#value' => $uid,
+  );
 
-	$form = legal_display_changes($form, $uid);
+  $form['id_hash'] = array(
+    '#type' => 'value',
+    '#value' => $id_hash,
+  );
 
-	$form['save'] = array(
-	    '#type' => 'submit',
-	    '#value' => t('Confirm'),
-	);
+  $form['tc_id'] = array(
+    '#type' => 'value',
+    '#value' => $conditions['tc_id'],
+  );
+
+  $form['version'] = array(
+    '#type' => 'value',
+    '#value' => $conditions['version'],
+  );
+
+  $form['revision'] = array(
+    '#type' => 'value',
+    '#value' => $conditions['revision'],
+  );
+
+  $form['language'] = array(
+    '#type' => 'value',
+    '#value' => $conditions['language'],
+  );
+
+  $form = legal_display_changes($form, $uid);
+
+  $form['save'] = array(
+    '#type' => 'submit',
+    '#value' => t('Confirm'),
+  );
 
-	return $form; 
+  return $form;
 }
-  
 
 function legal_login_validate($form, &$form_state) {
-	$account = db_fetch_object( db_query('SELECT * FROM {users} WHERE uid = %d LIMIT 1', $form_state['values']['uid']) );
-	$id_hash = md5($account->name . $account->password . $account->login);
+  $account = db_fetch_object(db_query_range('SELECT * FROM {users} WHERE uid = %d', $form_state['values']['uid'], 0, 1));
+  $id_hash = md5($account->name . $account->pass . $account->login);
 
-	if ($id_hash != $form_state['values']['id_hash']) {
-	  form_set_error('legal_accept', t('User ID cannot be identified.'));
-	  drupal_goto();   
-	}
-
-	return; 
+  if ($id_hash != $form_state['values']['id_hash']) {
+    form_set_error('legal_accept', t('User ID cannot be identified.'));
+    drupal_goto();
+  }
 }
 
 function legal_login_submit($form, &$form_state) {
-      
-    global $user;
-    $user = user_load(array('uid' => $form_state['values']['uid']));
-
-    legal_save_accept($user->uid, $form_state['values']['tc_id']);
-    watchdog('legal', '%name accepted T&C version %tc_id.', array('%name' => $user->name, '%tc_id' => $form_state['values']['tc_id']));
-    
-    // Update the user table timestamp noting user has logged in.
-    db_query("UPDATE {users} SET login = '%d' WHERE uid = '%s'", time(), $user->uid);
-    
-    // user has new permissions, so we clear their menu cache
-    cache_clear_all($user->uid, 'cache_menu', TRUE);
-    
-    user_module_invoke('login', $edit, $user);
-		$form_state['redirect'] = 'user/'. $user->uid; 
-    return;
+  global $user;
+	$values = $form_state['values'];
+  $user = user_load(array('uid' => $values['uid']));
+
+  legal_save_accept($values['version'], $values['revision'], $values['language'], $user->uid);
+  watchdog('legal', '%name accepted T&C version %tc_id.', array('%name' => $user->name, '%tc_id' => $values['tc_id']));
+
+  // Update the user table timestamp noting user has logged in.
+  db_query("UPDATE {users} SET login = '%d' WHERE uid = '%s'", time(), $user->uid);
+
+  // User has new permissions, so we clear their menu cache.
+  cache_clear_all($user->uid, 'cache_menu', TRUE);
+  // fixes login problems in Pressflow
+  sess_regenerate();
+
+  user_module_invoke('login', $edit, $user);
+  $form_state['redirect'] = 'user/'. $user->uid;
 }
 
 function theme_legal_login($form) {
+  $form = theme('legal_display', $form);
 
-    $form = theme('legal_display', $form);
-    
-    $output .= '<p>' . t('To continue to use this site please read the Terms & Conditions below, and complete the form to confirm your acceptance.' ) . '</p>';
-    
-    if ($form['changes']) {
-
-        foreach (element_children($form['changes']) as $key) {
-            $form['changes'][$key]['#prefix'] .= '<li>';
-            $form['changes'][$key]['#suffix'] .= '</li>';
-        }
-            
-        $form['changes']['start_list'] = array('#value' => '<ul>', '#weight' => 0);
-        $form['changes']['end_list'] = array('#value' => '</ul>', '#weight' => 3);
-        $output .= drupal_render($form['changes']);
+  $output = '<p>' . t('To continue to use this site please read the Terms & Conditions below, and complete the form to confirm your acceptance.') . '</p>';
+
+  if (isset($form['changes']['#value'])) {
+    foreach (element_children($form['changes']) as $key) {
+      $form['changes'][$key]['#prefix'] .= '<li>';
+      $form['changes'][$key]['#suffix'] .= '</li>';
     }
 
-    $save = drupal_render($form['save']);
-    $output .= drupal_render($form);
-    $output .= $save;
-    
-    return $output;
+    $form['changes']['start_list'] = array('#value' => '<ul>', '#weight' => 0);
+    $form['changes']['end_list'] = array('#value' => '</ul>', '#weight' => 3);
+    $output .= drupal_render($form['changes']);
+  }
+
+  $save = drupal_render($form['save']);
+  $output .= drupal_render($form);
+  $output .= $save;
+
+  return $output;
 }
-  
+
 function legal_get_accept($uid) {
+	$keys = array('legal_id', 'version', 'revision', 'language', 'uid', 'accepted');
+  $result = db_fetch_array(db_query_range("SELECT * FROM {legal_accepted} WHERE uid = %d ORDER BY version DESC, revision DESC", $uid, 0, 1));
 
-    $accept = db_fetch_object(db_query("SELECT * FROM {legal_accepted} WHERE uid = '%d' ORDER BY legal_id DESC LIMIT 1", $uid));
-    return $accept;
+	foreach ($keys as $key) {
+		$accept[$key] = $result[$key]; 
+	}
+	
+  return $accept;
 }
 
+function legal_save_accept($version, $revision, $language, $uid) {
+  db_query("INSERT INTO {legal_accepted} (version, revision, language, uid, accepted) VALUES (%d, %d, '%s', %d, %d)", $version, $revision, $language, $uid, time());
+}
 
-function legal_save_accept($uid, $tc_id) {
-
-  db_query("INSERT INTO {legal_accepted} (legal_id, uid, tc_id, accepted) VALUES (NULL, '%d', '%d', '%d')", $uid, $tc_id, time());
+function legal_get_conditions($language = NULL) {
+	$keys = array('tc_id', 'version', 'revision', 'language', 'conditions', 'date', 'extras', 'changes');
+ 
+	if (!empty($language)) {
+    $args[] = $language;
+		$result = db_fetch_array(db_query_range("SELECT * FROM {legal_conditions} WHERE language = '%s' ORDER BY version DESC, revision DESC", $args, 0, 1));	
+	}
+	else {
+		$result = db_fetch_array(db_query_range("SELECT * FROM {legal_conditions} ORDER BY tc_id DESC", 0, 1));	
+	}
 
-  return;
+	foreach ($keys as $key) {
+		$conditions[$key] = isset($result[$key]) ? $result[$key] : '';
+	}
+	
+  $conditions['extras'] = empty($conditions['extras']) ? array() : unserialize($conditions['extras']);
+  return $conditions;
 }
 
-function legal_get_conditions() {
+/**
+ * Get all changes since user last accepted.
+ */
+function legal_display_changes($form, $uid) {
+	$is_list = FALSE;
+  $last_accepted = legal_get_accept($uid);
+
+  if (empty($last_accepted)) {
+    return $form;
+  }
 
-    $conditions = db_fetch_array(db_query("SELECT * FROM {legal_conditions} ORDER BY tc_id DESC LIMIT 1"));
-    $conditions['extras'] = unserialize($conditions['extras']);
-    return $conditions;
-}
+  $results = db_query("SELECT * FROM {legal_conditions} WHERE version > %d AND language = '%s' ORDER BY revision DESC", $last_accepted['version'], $last_accepted['language']);
+
+  if (empty($results)) {
+    return $form;
+  }
 
-function legal_conditions_updated($new) {
+  $form['changes'] = array(
+    '#type' => 'fieldset',
+    '#title' => t('Changes List'),
+    '#description' => t('Changes to the Terms & Conditions since last accepted:'),
+    '#collapsible' => TRUE,
+    '#collapsed' => TRUE,
+    '#tree' => TRUE,
+  );
 
-    $old = legal_get_conditions();
-    if ($old['conditions'] != $new['conditions']) return TRUE;
-    
-    $count = count($new['extras']);
-        
-    for ($counter = 1; $counter <= $count; $counter++) {
-    
-        if ( $old['extras']['extras-' . $counter] != $new['extras']['extras-' . $counter] ) return TRUE;
+  while ($conditions = db_fetch_object($results)) {
+    unset($changes);
+    if (!empty($conditions->changes)) {
+      $changes = explode("\r\n", $conditions->changes);
+      foreach($changes as $change) {
+        $form['changes'][] = array(
+          '#value' => filter_xss_admin($change),
+          '#weight' => 2,
+        );
+        $is_list = TRUE;
+      }
     }
-    
-    return FALSE;    
+  }
+
+  if (!$is_list) {
+    $form['changes'] = NULL;
+  }
+
+  return $form;
 }
 
-// get all changes since user last accepted
-function legal_display_changes($form, $uid) {
-    
-    $last_accepted = legal_get_accept($uid);
-    if (empty($last_accepted)) return $form;
-    
-    $results = db_query("SELECT * FROM {legal_conditions} WHERE tc_id > %d ORDER BY tc_id DESC", $last_accepted->tc_id);
-    
-    if (empty($results)) return $form;
-    
-    $form['changes'] = array(
-        '#type' => 'fieldset',
-        '#title' => t('Changes List'),
-        '#description' => t('Changes to the Terms & Conditions since last accepted:'),
-        '#collapsible' => TRUE,
-        '#collapsed' => TRUE,
-        '#tree' => TRUE,
-    );
-    
-    while ($conditions = db_fetch_object($results)) { 
-       
-       unset($changes);
-        
-        if (!empty($conditions->changes)) {
-        
-            $changes = explode("\r\n", $conditions->changes);
-            
-            foreach($changes as $change) {
-                $form['changes'][] = array(
-                    '#value' => filter_xss_admin($change),
-                    '#weight' => 2,
-                );
-                $is_list = TRUE;
-            }
-        }
-        
-    }
-    
-    if (!$is_list) $form['changes'] = NULL;
+/**
+ * Check if user has accepted latest version of T&C.
+ */
+function legal_version_check($uid, $version, $revision, $legal_account = array()) {
 
-    return $form;
+  if (empty($legal_account)) $legal_account = legal_get_accept($uid);
+
+  if ($legal_account['version'] == $version && $legal_account['revision'] == $revision) {
+		$accepted = TRUE;
+	} 
+	else {
+		$accepted = FALSE;
+	} 
+
+  return $accepted;
 }
 
-// check if user has accepted latest version of T&C
-function legal_version_check($uid, $current_tc_id) {
+/**
+ * Access control callback. 
+ * Check that Locale module is enabled and user has access permission.
+ */
+function legal_languages_access($perm) {
 
-    $legal_account = legal_get_accept($uid);
-    if ($legal_account->tc_id == $current_tc_id) return TRUE;
-    
-    // get change log messages
-    return $log_messages;
+  if (!module_exists('locale')) {
+		return FALSE;
+	}
+	
+	if (!user_access($perm)) {
+		return FALSE; 
+	}
+	
+	return TRUE;
 }
diff --git public_html/sites/all/modules/custom/m2api/modules/m2_js/m2_js.theme.inc public_html/sites/all/modules/custom/m2api/modules/m2_js/m2_js.theme.inc
index f927e8c..0465ba5 100644
--- public_html/sites/all/modules/custom/m2api/modules/m2_js/m2_js.theme.inc
+++ public_html/sites/all/modules/custom/m2api/modules/m2_js/m2_js.theme.inc
@@ -1,9 +1,7 @@
 <?php
 
 function theme_m2_js_album_links($links, $text) {
-  // @todo Need to have an R2 equivalent of theme_sonybmg_dropdown_links(). For
-  //   now we're just using theme_item_list().
-  return theme('item_list', $links, $text);
+  return r2_render_dropdown($text, theme('item_list', $links));
 }
 
 function theme_m2_js_album_link($m2id, $type, $add = NULL, $remove = NULL) {
@@ -37,4 +35,4 @@ function theme_m2_js_track_button($m2id, $add = NULL, $remove = NULL) {
   <span class='m2-button-placeholder' product_id='$m2id' add_text='$add' remove_text='$remove'></span>
 </span>
 HTML;
-}
\ No newline at end of file
+}
