diff --git a/CRM/Activity/Form/Task/Batch.php b/CRM/Activity/Form/Task/Batch.php
old mode 100755
new mode 100644
diff --git a/CRM/Activity/Form/Task/Delete.php b/CRM/Activity/Form/Task/Delete.php
old mode 100755
new mode 100644
diff --git a/CRM/Activity/Form/Task/PickProfile.php b/CRM/Activity/Form/Task/PickProfile.php
old mode 100755
new mode 100644
diff --git a/CRM/Admin/Form/Setting/Event.php b/CRM/Admin/Form/Setting/Event.php
new file mode 100644
index 0000000..42cc129
--- /dev/null
+++ b/CRM/Admin/Form/Setting/Event.php
@@ -0,0 +1,65 @@
+<?php
+
+/*
+ +--------------------------------------------------------------------+
+ | CiviCRM version 4.0                                                |
+ +--------------------------------------------------------------------+
+ | Copyright CiviCRM LLC (c) 2004-2011                                |
+ +--------------------------------------------------------------------+
+ | This file is a part of CiviCRM.                                    |
+ |                                                                    |
+ | CiviCRM is free software; you can copy, modify, and distribute it  |
+ | under the terms of the GNU Affero General Public License           |
+ | Version 3, 19 November 2007 and the CiviCRM Licensing Exception.   |
+ |                                                                    |
+ | CiviCRM is distributed in the hope that it will be useful, but     |
+ | WITHOUT ANY WARRANTY; without even the implied warranty of         |
+ | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.               |
+ | See the GNU Affero General Public License for more details.        |
+ |                                                                    |
+ | You should have received a copy of the GNU Affero General Public   |
+ | License and the CiviCRM Licensing Exception along                  |
+ | with this program; if not, contact CiviCRM LLC                     |
+ | at info[AT]civicrm[DOT]org. If you have questions about the        |
+ | GNU Affero General Public License or the licensing of CiviCRM,     |
+ | see the CiviCRM license FAQ at http://civicrm.org/licensing        |
+ +--------------------------------------------------------------------+
+*/
+
+/**
+ *
+ * @package CRM
+ * @copyright CiviCRM LLC (c) 2004-2011
+ * $Id$
+ *
+ */
+
+require_once 'CRM/Admin/Form/Setting.php';
+
+class CRM_Admin_Form_Setting_Event extends CRM_Admin_Form_Setting
+{
+    public function buildQuickForm( ) 
+    {
+        CRM_Utils_System::setTitle(ts('Settings - CiviEvent'));
+        $this->addElement( 'advcheckbox', 'enable_cart', ts( 'Enable Cart Checkout' ) );
+        $check = true;
+
+        require_once 'CRM/Contact/BAO/ContactType.php';
+        require_once 'CRM/Core/BAO/UFGroup.php';
+        $types    = array_merge( array( 'Contact', 'Individual', 'Participant' ),
+                                 CRM_Contact_BAO_ContactType::subTypes( 'Individual' ) );
+        $profiles = CRM_Core_BAO_UFGroup::getProfiles( $types );
+        
+        $mainProfiles = array('' => ts('- select -')) + $profiles;
+
+        $this->add('select', 'default_participant_profile', ts('Default Participant Profile'), $mainProfiles);
+        
+        // redirect to Administer Section After hitting either Save or Cancel button.
+        $session = CRM_Core_Session::singleton( );
+        $session->pushUserContext( CRM_Utils_System::url( 'civicrm/admin', 'reset=1' ) );
+        
+        parent::buildQuickForm( $check );
+    }
+}
+
+
diff --git a/CRM/Campaign/BAO/Query.php b/CRM/Campaign/BAO/Query.php
old mode 100755
new mode 100644
diff --git a/CRM/Campaign/Controller/Search.php b/CRM/Campaign/Controller/Search.php
old mode 100755
new mode 100644
diff --git a/CRM/Campaign/Form/Gotv.php b/CRM/Campaign/Form/Gotv.php
old mode 100755
new mode 100644
diff --git a/CRM/Campaign/Form/Search.php b/CRM/Campaign/Form/Search.php
old mode 100755
new mode 100644
diff --git a/CRM/Campaign/Form/Search/Campaign.php b/CRM/Campaign/Form/Search/Campaign.php
old mode 100755
new mode 100644
diff --git a/CRM/Campaign/Form/Search/Petition.php b/CRM/Campaign/Form/Search/Petition.php
old mode 100755
new mode 100644
diff --git a/CRM/Campaign/Form/Search/Survey.php b/CRM/Campaign/Form/Search/Survey.php
old mode 100755
new mode 100644
diff --git a/CRM/Campaign/Form/Task.php b/CRM/Campaign/Form/Task.php
old mode 100755
new mode 100644
diff --git a/CRM/Campaign/Form/Task/Interview.php b/CRM/Campaign/Form/Task/Interview.php
old mode 100755
new mode 100644
diff --git a/CRM/Campaign/Form/Task/Print.php b/CRM/Campaign/Form/Task/Print.php
old mode 100755
new mode 100644
diff --git a/CRM/Campaign/Form/Task/Result.php b/CRM/Campaign/Form/Task/Result.php
old mode 100755
new mode 100644
diff --git a/CRM/Campaign/PseudoConstant.php b/CRM/Campaign/PseudoConstant.php
old mode 100755
new mode 100644
diff --git a/CRM/Campaign/Selector/Search.php b/CRM/Campaign/Selector/Search.php
old mode 100755
new mode 100644
diff --git a/CRM/Campaign/StateMachine/Search.php b/CRM/Campaign/StateMachine/Search.php
old mode 100755
new mode 100644
diff --git a/CRM/Campaign/Task.php b/CRM/Campaign/Task.php
old mode 100755
new mode 100644
diff --git a/CRM/Contact/BAO/Query.php b/CRM/Contact/BAO/Query.php
index 3578a51..1e88b0d 100644
--- a/CRM/Contact/BAO/Query.php
+++ b/CRM/Contact/BAO/Query.php
@@ -3818,10 +3818,10 @@ SELECT COUNT( civicrm_contribution.total_amount ) as cancel_count,
 
         if ( $name == "{$fieldName}_low" ||
              $name == "{$fieldName}_high" ) {
-            if ( isset( $this->_rangeCache[$fieldName] ) ) {
+            if ( isset( $this->_rangeCache[$name] ) ) {
                 return;
             }
-            $this->_rangeCache[$fieldName] = 1;
+            $this->_rangeCache[$name] = 1;
 
             $secondOP = $secondPhrase = $secondValue = $secondDate = $secondDateFormat = null;
 
@@ -3830,20 +3830,6 @@ SELECT COUNT( civicrm_contribution.total_amount ) as cancel_count,
                 $firstPhrase  = 'greater than or equal to';
                 $firstDate    = CRM_Utils_Date::processDate( $value );
 
-                $secondValues = $this->getWhereValues( "{$fieldName}_high", $grouping );
-                if ( ! empty( $secondValues ) &&
-                     $secondValues[2] ) {
-                    $secondOP          = '<=';
-                    $secondPhrase      = 'less than or equal to';
-                    $secondValue       = $secondValues[2];
-
-                    if ( $appendTimeStamp &&
-                         strlen( $secondValue ) == 10 ) {
-                        $secondValue .= ' 23:59:59';
-                    }
-                    $secondDate = CRM_Utils_Date::processDate( $secondValue );
-                }
-
             } else if ( $name == $fieldName . '_high' ) {
                 $firstOP           = '<=';
                 $firstPhrase       = 'less than or equal to';
@@ -3853,15 +3839,6 @@ SELECT COUNT( civicrm_contribution.total_amount ) as cancel_count,
                     $value .= ' 23:59:59';
                 }
                 $firstDate    = CRM_Utils_Date::processDate( $value );
-
-                $secondValues = $this->getWhereValues( "{$fieldName}_low", $grouping );
-                if ( ! empty( $secondValues ) &&
-                     $secondValues[2] ) {
-                    $secondOP          = '>=';
-                    $secondPhrase      = 'greater than or equal to';
-                    $secondValue       = $secondValues[2];
-                    $secondDate = CRM_Utils_Date::processDate( $secondValue );
-                }
             }
 
             if ( ! $appendTimeStamp ) {
@@ -3869,27 +3846,9 @@ SELECT COUNT( civicrm_contribution.total_amount ) as cancel_count,
             }
             $firstDateFormat = CRM_Utils_Date::customFormat( $firstDate );
 
-            if ( $secondDate ) {
-                if ( ! $appendTimeStamp ) {
-                    $secondDate = substr(  $secondDate, 0, 8 );
-                }
-                $secondDateFormat = CRM_Utils_Date::customFormat( $secondDate );
-            }
-
             $this->_tables[$tableName] = $this->_whereTables[$tableName] = 1;
-            if ( $secondDate ) {
-                $this->_where[$grouping][] = "
-( {$tableName}.{$dbFieldName} $firstOP '$firstDate' ) AND
-( {$tableName}.{$dbFieldName} $secondOP '$secondDate' )
-";
-                $this->_qill[$grouping][]  = 
-                    "$fieldTitle - $firstPhrase \"$firstDateFormat\" " .
-                    ts('AND') .
-                    " $secondPhrase \"$secondDateFormat\"";
-            } else {
-                $this->_where[$grouping][] = "{$tableName}.{$dbFieldName} $firstOP '$firstDate'";
-                $this->_qill[$grouping][]  = "$fieldTitle - $firstPhrase \"$firstDateFormat\"";
-            }
+            $this->_where[$grouping][] = "{$tableName}.{$dbFieldName} $firstOP '$firstDate'";
+            $this->_qill[$grouping][]  = "$fieldTitle - $firstPhrase \"$firstDateFormat\"";
         }
 
         if ( $name == $fieldName ) {
diff --git a/CRM/Contact/Form/Edit/Address.php b/CRM/Contact/Form/Edit/Address.php
index fb19201..d90ded9 100644
--- a/CRM/Contact/Form/Edit/Address.php
+++ b/CRM/Contact/Form/Edit/Address.php
@@ -263,7 +263,7 @@ class CRM_Contact_Form_Edit_Address
      * @access public
      * @static
      */
-    static function formRule( $fields, $errors )
+    static function formRule( $fields )
     {
         $errors = array( );
         // check for state/county match if not report error to user.
diff --git a/CRM/Contribute/Form/Contribution/Main.php b/CRM/Contribute/Form/Contribution/Main.php
index 4f5427b..f6eed7c 100644
--- a/CRM/Contribute/Form/Contribution/Main.php
+++ b/CRM/Contribute/Form/Contribution/Main.php
@@ -340,6 +340,8 @@ class CRM_Contribute_Form_Contribution_Main extends CRM_Contribute_Form_Contribu
         $this->applyFilter('__ALL__', 'trim');
         $this->add( 'text', "email-{$this->_bltID}",
                     ts( 'Email Address' ), array( 'size' => 30, 'maxlength' => 60 ), true );
+        $this->add( 'text', "conf_email-{$this->_bltID}",
+                    ts( 'Confirm Email Address' ), array( 'size' => 30, 'maxlength' => 60 ), true );
         $this->addRule( "email-{$this->_bltID}", ts('Email is not valid.'), 'email' );
                 
         //build pledge block.
@@ -1004,6 +1006,12 @@ class CRM_Contribute_Form_Contribution_Main extends CRM_Contribute_Form_Contribu
                 }
             }
         }
+
+        if ( isset( $fields["email-{$self->_bltID}"] ) &&
+             ($fields["conf_email-{$self->_bltID}"] != $fields["email-{$self->_bltID}"]) )
+        {
+            $errors["conf_email-{$self->_bltID}"] = ts('Email does not match.');
+        }
         
         return empty( $errors ) ? true : $errors;
     }
diff --git a/CRM/Core/BAO/Address.php b/CRM/Core/BAO/Address.php
index 1a11e9d..e4ca4d8 100644
--- a/CRM/Core/BAO/Address.php
+++ b/CRM/Core/BAO/Address.php
@@ -654,11 +654,30 @@ ORDER BY civicrm_address.is_primary DESC, civicrm_address.location_type_id DESC,
                                                 $stateCountryMap );
     }
 
-    static function fixAllStateSelects( &$form, &$defaults ) 
+    static function fixAllStateSelects( &$form, $defaults = null ) 
     {
         $config = CRM_Core_Config::singleton( );
 
-        if ( ! empty(  $config->stateCountryMap ) ) {
+        $stateCountryMap = array( );
+        foreach (array_keys($form->_elementIndex) as $name)
+        {
+            $matches = array();
+            if (preg_match("/(field.*)?(state_province|country|county)(?:_id)?-(.+)/", $name, $matches))
+            {
+                $fieldName = $matches[2];
+                $location_type_index = $matches[3];
+                // dirty hack:
+                if ($matches[1]) $location_type_index .= $matches[1];
+                if ( ! array_key_exists( $location_type_index, $stateCountryMap ) ) {
+                    $stateCountryMap[$location_type_index] = array( );
+                }
+                $stateCountryMap[$location_type_index][$fieldName] = $name;
+            }
+        }
+        self::addStateCountryMap($stateCountryMap);
+
+        if (!empty($config->stateCountryMap))
+        {
             foreach ( $config->stateCountryMap as $index => $match ) {
                 if ( array_key_exists( 'state_province', $match ) &&
                      array_key_exists( 'country', $match ) ) {
diff --git a/CRM/Core/BAO/CMSUser.php b/CRM/Core/BAO/CMSUser.php
index 28a8841..5490d4a 100644
--- a/CRM/Core/BAO/CMSUser.php
+++ b/CRM/Core/BAO/CMSUser.php
@@ -505,6 +505,7 @@ SELECT username, email
         $form_state['values']  = array (
                                     'name' => $params['cms_name'],
                                     'mail' => $params[$mail],
+                                    'conf_mail' => $params["conf_{$mail}"],
                                     'op'   => 'Create new account'
                                     );
         if ( !variable_get('user_email_verification', TRUE )) {
diff --git a/CRM/Core/BAO/MessageTemplates.php b/CRM/Core/BAO/MessageTemplates.php
index 2b3c8b7..20ddb5e 100644
--- a/CRM/Core/BAO/MessageTemplates.php
+++ b/CRM/Core/BAO/MessageTemplates.php
@@ -342,6 +342,7 @@ class CRM_Core_BAO_MessageTemplates extends CRM_Core_DAO_MessageTemplates
     static function sendTemplate($params)
     {
         $defaults = array(
+            'table'       => 'civicrm_msg_template',
             'groupName'         => null,    // option group name of the template
             'valueName'         => null,    // option value name of the template
             'messageTemplateID' => null,    // ID of the template
@@ -378,6 +379,7 @@ class CRM_Core_BAO_MessageTemplates extends CRM_Core_DAO_MessageTemplates
                       WHERE og.name = %1 AND ov.name = %2 AND mt.is_default = 1';
             $sqlParams = array(1 => array($params['groupName'], 'String'), 2 => array($params['valueName'], 'String'));
         }
+        CRM_Utils_Hook::preLoad( $params );
         $dao = CRM_Core_DAO::executeQuery($query, $sqlParams);
         $dao->fetch();
 
diff --git a/CRM/Core/BAO/UFGroup.php b/CRM/Core/BAO/UFGroup.php
index 573d2d3..dcb97db 100644
--- a/CRM/Core/BAO/UFGroup.php
+++ b/CRM/Core/BAO/UFGroup.php
@@ -1986,12 +1986,17 @@ AND    ( entity_id IS NULL OR entity_id <= 0 )
                                                         $defaults[$fldName] = $config->defaultContactCountry;
                                                     }
                                                 }
-                                            } else if ( $fieldName == 'phone' ) {
-                                                if ( $phoneTypeId &&
-                                                     isset( $value['phone'][$phoneTypeId] ) ) {
-                                                    $defaults[$fldName] = $value['phone'][$phoneTypeId];
+											} else if ( $fieldName == 'phone' ) {
+                                                if ( $phoneTypeId ) {
+                                                    if ( isset( $value['phone'][$phoneTypeId] ) ) {
+                                                        $defaults[$fldName] = $value['phone'][$phoneTypeId];
+                                                    }
                                                 } else {
-                                                    $defaults[$fldName] = CRM_Utils_Array::value( 'phone', $value );
+                                                    $phoneDefault = CRM_Utils_Array::value( 'phone', $value );
+                                                    // CRM-9216
+                                                    if ( ! is_array( $phoneDefault ) ) {
+                                                        $defaults[$fldName] = $phoneDefault;
+                                                    }
                                                 }
                                             } else if ( $fieldName == 'email' ) {
                                                 //adding the first email (currently we don't support multiple emails of same location type)
diff --git a/CRM/Core/Payment/Form.php b/CRM/Core/Payment/Form.php
index 34f853d..56049e9 100644
--- a/CRM/Core/Payment/Form.php
+++ b/CRM/Core/Payment/Form.php
@@ -246,9 +246,7 @@ class CRM_Core_Payment_Form {
 
             // also take care of state country widget
             require_once 'CRM/Core/BAO/Address.php';
-            $stateCountryMap = array( 1 => array( 'country'        => "billing_country_id-{$form->_bltID}"       ,
-                                                  'state_province' => "billing_state_province_id-{$form->_bltID}" ) );
-            CRM_Core_BAO_Address::addStateCountryMap( $stateCountryMap );
+            CRM_Core_BAO_Address::fixAllStateSelects($form);
         }
             
         if ( $form->_paymentProcessor['billing_mode'] & CRM_Core_Payment::BILLING_MODE_BUTTON ) {
diff --git a/CRM/Event/BAO/Event.php b/CRM/Event/BAO/Event.php
index a65b817..03f6dad 100644
--- a/CRM/Event/BAO/Event.php
+++ b/CRM/Event/BAO/Event.php
@@ -337,11 +337,12 @@ class CRM_Event_BAO_Event extends CRM_Event_DAO_Event
         $config = CRM_Core_Config::singleton();
         
         // We're fetching recent and upcoming events (where start date is 7 days ago OR later)
+        $now = date('YmdHis');
         $query = "SELECT count(id) as total_events
                   FROM   civicrm_event e
                   WHERE  e.is_active=1 AND
                         ( e.is_template IS NULL OR e.is_template = 0) AND
-                        e.start_date >= DATE_SUB( NOW(), INTERVAL 7 day );";
+                        e.start_date >= DATE_SUB( '$now', INTERVAL 7 day );";
         
         $dao =& CRM_Core_DAO::executeQuery( $query );
         
@@ -385,10 +386,12 @@ class CRM_Event_BAO_Event extends CRM_Event_DAO_Event
                 . " ) ";
         }
 
+        $now = date('YmdHis');
         $query = "
 SELECT     civicrm_event.id as id, civicrm_event.title as event_title, civicrm_event.is_public as is_public,
            civicrm_event.max_participants as max_participants, civicrm_event.start_date as start_date,
            civicrm_event.end_date as end_date, civicrm_event.is_online_registration, civicrm_event.is_monetary, civicrm_event.is_show_location,civicrm_event.is_map as is_map, civicrm_option_value.label as event_type, civicrm_tell_friend.is_active as is_friend_active,
+           civicrm_event.slot_label_id,
            civicrm_event.summary as summary
 FROM       civicrm_event
 LEFT JOIN  civicrm_option_value ON (
@@ -397,7 +400,7 @@ LEFT JOIN  civicrm_option_value ON (
 LEFT JOIN  civicrm_tell_friend ON ( civicrm_tell_friend.entity_id = civicrm_event.id  AND civicrm_tell_friend.entity_table = 'civicrm_event' )
 WHERE      civicrm_event.is_active = 1 AND
            ( civicrm_event.is_template IS NULL OR civicrm_event.is_template = 0) AND
-           civicrm_event.start_date >= DATE_SUB( NOW(), INTERVAL 7 day )
+           civicrm_event.start_date >= DATE_SUB( '$now', INTERVAL 7 day )
            $validEventIDs
 GROUP BY   civicrm_event.id
 ORDER BY   civicrm_event.start_date ASC
@@ -515,6 +518,7 @@ LIMIT      0, 10
             $eventSummary['events'][$dao->id]['is_monetary'] = $dao->is_monetary;
             $eventSummary['events'][$dao->id]['is_online_registration'] = $dao->is_online_registration;
             $eventSummary['events'][$dao->id]['is_show_location'] = $dao->is_show_location;
+            $eventSummary['events'][$dao->id]['is_subevent'] = $dao->slot_label_id;
 
             $statusTypes = CRM_Event_PseudoConstant::participantStatus( );
             foreach ( $statusValues as $statusId => $statusValue ) {
@@ -789,6 +793,9 @@ WHERE civicrm_event.is_active = 1
         $permissions = CRM_Core_Permission::event( CRM_Core_Permission::VIEW );
 
         require_once 'CRM/Utils/String.php';
+        if ($config->enable_cart) {
+            require_once 'CRM/Event/Cart/BAO/EventInCart.php';
+        }
         while ( $dao->fetch( ) ) {
             if ( in_array($dao->event_id, $permissions) ) {
                 $info                     = array( );
@@ -828,6 +835,12 @@ WHERE civicrm_event.is_active = 1
                                           CRM_Utils_Address::format($addrFields) );
                 $info['location'     ] = $address;
                 $info['url'          ] = CRM_Utils_System::url( 'civicrm/event/info', 'reset=1&id=' . $dao->event_id, true, null, false );
+
+                if ($config->enable_cart) {
+                    $reg = CRM_Event_Cart_BAO_EventInCart::get_registration_link($dao->event_id);
+                    $info['registration_link'] = CRM_Utils_System::url($reg['path'], $reg['query'], true);
+                    $info['registration_link_text'] = $reg['label'];
+                }
                 
                 $all[] = $info;
             }
@@ -1016,23 +1029,20 @@ WHERE civicrm_event.is_active = 1
         
         if ( $values['event']['is_email_confirm'] || $returnMessageText ) {
             require_once 'CRM/Contact/BAO/Contact/Location.php';
-            //use primary email address, since we are not creating billing address for
-            //1. participant is pay later.
-            //2. participant might be additional participant.
-            //3. participant might be on waiting list.
-            //4. registration might require approval.
-            if ( CRM_Utils_Array::value( 'is_pay_later',          $values['params'] ) ||
-                 CRM_Utils_Array::value( 'additionalParticipant', $values['params'] ) ||
-                 CRM_Utils_Array::value( 'isOnWaitlist',          $values['params'] ) ||
-                 CRM_Utils_Array::value( 'isRequireApproval',     $values['params'] ) ||
-                 !CRM_Utils_Array::value( 'is_monetary',          $values['event']  ) ) {
-                list( $displayName, $email ) = CRM_Contact_BAO_Contact_Location::getEmailDetails( $contactID );
-            } else {
+            if ( !CRM_Utils_Array::value( 'is_pay_later',          $values['params'] ) &&
+                 !CRM_Utils_Array::value( 'additionalParticipant', $values['params'] ) &&
+                 !CRM_Utils_Array::value( 'isOnWaitlist',          $values['params'] ) &&
+                 !CRM_Utils_Array::value( 'isRequireApproval',     $values['params'] ) &&
+                 CRM_Utils_Array::value( 'is_monetary',          $values['event']  ) ) {
                 // get the billing location type
                 $locationTypes =& CRM_Core_PseudoConstant::locationType( );
                 $bltID = array_search( 'Billing',  $locationTypes );
                 list( $displayName, $email ) = CRM_Contact_BAO_Contact_Location::getEmailDetails( $contactID, false, $bltID );
             }
+
+            if (!isset($email)) {
+                list( $displayName, $email ) = CRM_Contact_BAO_Contact_Location::getEmailDetails( $contactID );
+            }
             
             //send email only when email is present
             if ( isset( $email ) || $returnMessageText ) {
@@ -1085,6 +1095,13 @@ WHERE civicrm_event.is_active = 1
                     $sendTemplateParams['tplParams']['lineItem']   = $lineItem;
                 }
 
+                require_once 'CRM/Event/Cart/BAO/Conference.php';
+                $sessions = CRM_Event_Cart_BAO_Conference::get_participant_sessions($participantId);
+                $sendTemplateParams['tplParams']['conference_sessions'] = $sessions;
+                $sendTemplateParams['tplParams']['payer'] = CRM_Utils_Array::value('payer', $values);
+                //XXX how did this work previously?
+                $sendTemplateParams['tplParams']['event'] = CRM_Utils_Array::value('event', $values);
+
                 require_once 'CRM/Core/BAO/MessageTemplates.php';
                 if ( $returnMessageText ) {
                     list ($sent, $subject, $message, $html) = CRM_Core_BAO_MessageTemplates::sendTemplate($sendTemplateParams);
@@ -1878,4 +1895,11 @@ LEFT  JOIN  civicrm_price_field_value value ON ( value.id = lineItem.price_field
         return (int)CRM_Core_DAO::singleValueQuery( $query, array( 1 => array( $eventId, 'Positive' ) ) );
     }
     
+    static function get_sub_events($event_id)
+    {
+        $params = array('parent_event_id' => $event_id);
+        $defaults = array();
+        return CRM_Event_BAO_Event::retrieve($params, $defaults);
+    }
+
 }
diff --git a/CRM/Event/BAO/Participant.php b/CRM/Event/BAO/Participant.php
index 43f975a..9260eb4 100644
--- a/CRM/Event/BAO/Participant.php
+++ b/CRM/Event/BAO/Participant.php
@@ -239,38 +239,17 @@ class CRM_Event_BAO_Participant extends CRM_Event_DAO_Participant
             CRM_Core_BAO_CustomValueTable::store( $params['custom'], 'civicrm_participant', $participant->id );
         }
         
-        //process note, CRM-7634
-        require_once 'CRM/Core/BAO/Note.php';
-        $noteId = null;
-        if ( CRM_Utils_Array::value( 'id', $params ) ) {
-            $note = CRM_Core_BAO_Note::getNote( $params['id'], 'civicrm_participant' );
-            $noteId = key( $note );
-        }
-        $noteValue = null;
-        $hasNoteField = false;
         foreach ( array( 'note', 'participant_note' ) as $noteFld ) {
             if ( array_key_exists( $noteFld, $params ) ) {
-                $noteValue = $params[$noteFld];
-                $hasNoteField = true;
+                $note_params = array(
+                    'participant_id' => $params['id'],
+                    'contact_id' => $id,
+                    'note' => $params[$noteFld],
+                );
+                self::update_note($note_params);
                 break;
             }
         }
-        if ( $noteId || $noteValue ) {
-            if ( $noteValue ) {
-                $noteParams = array( 'entity_table'  => 'civicrm_participant',
-                                     'note'          => $noteValue,
-                                     'entity_id'     => $participant->id,
-                                     'contact_id'    => $id,
-                                     'modified_date' => date('Ymd') );
-                $noteIDs = array( );
-                if ( $noteId ) {
-                    $noteIDs['id'] = $noteId;
-                }
-                CRM_Core_BAO_Note::add( $noteParams, $noteIDs );
-            } else if ( $noteId && $hasNoteField ) {
-                CRM_Core_BAO_Note::del( $noteId, false );
-            }
-        }
         
         // Log the information on successful add/edit of Participant data.
         require_once 'CRM/Core/BAO/Log.php';
@@ -333,6 +312,41 @@ class CRM_Event_BAO_Participant extends CRM_Event_DAO_Participant
         
         return $participant;
     }
+
+    /*
+     * params:
+     *  participant_id=
+     *  contact_id=
+     *  note=
+     *
+     * TODO many-to-one
+     */
+    static function update_note($params)
+    {
+        //process note, CRM-7634
+        require_once 'CRM/Core/BAO/Note.php';
+        $old_note_id = null;
+        if ( CRM_Utils_Array::value( 'participant_id', $params ) ) {
+            $old_note = CRM_Core_BAO_Note::getNote( $params['participant_id'], 'civicrm_participant' );
+            $old_note_id = key( $old_note );
+        }
+        if ( $old_note_id || $params['note'] ) {
+            if ( $params['note'] ) {
+                $noteParams = array( 'entity_table'  => 'civicrm_participant',
+                                     'note'          => $params['note'],
+                                     'entity_id'     => $params['participant_id'],
+                                     'contact_id'    => $params['contact_id'],
+                                     'modified_date' => date('Ymd') );
+                $noteIDs = array( );
+                if ( $old_note_id ) {
+                    $noteIDs['id'] = $old_note_id;
+                }
+                CRM_Core_BAO_Note::add( $noteParams, $noteIDs );
+            } else if ($old_note_id) {
+                CRM_Core_BAO_Note::del( $old_note_id, false );
+            }
+        }
+    }
     
     /**
      * Check whether the event is full for participation and return as
@@ -1140,8 +1154,9 @@ INNER JOIN civicrm_price_field_value value ON ( value.id = lineItem.price_field_
         //when we did update status, useful for moving participant
         //from pending to expired.
         $setClause = "status_id = {$statusId}";
+        $now = date('YmdHis');
         if ( $updateRegisterDate ) {
-            $setClause .= ", register_date = NOW()";
+            $setClause .= ", register_date = '$now'";
         }
         
         $participantIdClause = '( ' . implode( ',', $participantIds ) . ' )';
diff --git a/CRM/Event/Cart/BAO/Cart.php b/CRM/Event/Cart/BAO/Cart.php
new file mode 100644
index 0000000..28de947
--- /dev/null
+++ b/CRM/Event/Cart/BAO/Cart.php
@@ -0,0 +1,281 @@
+<?php
+
+require_once 'CRM/Event/Cart/DAO/Cart.php';
+require_once 'CRM/Event/Cart/BAO/EventInCart.php';
+
+class CRM_Event_Cart_BAO_Cart extends CRM_Event_Cart_DAO_Cart
+{
+  public $associations_loaded = false;
+  public $events_in_carts = array( /* event_in_cart_id => $event_in_cart */ );
+
+  public static function add( &$params )
+  {
+    $cart = new CRM_Event_Cart_BAO_Cart( );
+    $cart->copyValues( $params );
+    $result = $cart->save( );
+    return $result;
+  }
+
+  public function add_event( $event_id )
+  {
+	$this->load_associations();
+	$event_in_cart = $this->get_event_in_cart_by_event_id( $event_id );
+	if ($event_in_cart) {
+	    return $event_in_cart;
+	}
+
+	$params = array(
+	  'event_id' => $event_id, 
+	  'event_cart_id' => $this->id 
+	);
+	$event_in_cart = CRM_Event_Cart_BAO_EventInCart::create( $params );
+	$event_in_cart->load_associations($this);
+	$this->events_in_carts[$event_in_cart->event_id] = $event_in_cart;
+	return $this->events_in_carts[$event_in_cart->event_id];
+  }
+  
+  function add_participant_to_cart($participant)
+  {
+    $event_in_cart = $this->get_event_in_cart_by_event_id($participant->event_id);
+    if (!$event_in_cart) $event_in_cart = $this->add_event($participant->event_id);
+    $event_in_cart->add_participant($participant);
+    $event_in_cart->save();
+  }
+
+  public static function create( $params )
+  {
+	require_once 'CRM/Core/Transaction.php';
+	$transaction = new CRM_Core_Transaction( );
+
+	$cart = self::add( $params );
+
+	if ( is_a( $cart, 'CRM_Core_Error') ) {
+	  $transaction->rollback( );
+	  CRM_Core_Error::fatal( ts( 'There was an error creating an event cart') );
+	}
+
+	$transaction->commit( );
+
+	return $cart;
+  }
+
+  public static function find_by_id( $id )
+  {
+	return self::find_by_params( array( 'id' => $id ) );
+  }
+
+  public static function find_by_params( $params )
+  {
+	$cart = new CRM_Event_Cart_BAO_Cart( );
+	$cart->copyValues( $params );
+	if ( $cart->find( true ) ) {
+	  return $cart;
+	} else {
+	  return false;
+	}
+  }
+
+  public static function find_or_create_for_current_session( )
+  {
+	$session = CRM_Core_Session::singleton( );
+	$event_cart_id = $session->get( 'event_cart_id' );
+        $userID = $session->get( 'userID' );
+	$cart = false;
+	if ( !is_null( $event_cart_id ) ) {
+	  $cart = self::find_uncompleted_by_id( $event_cart_id );
+          if ($cart && $userID)
+          {
+            if (!$cart->user_id)
+            {
+              $saved_cart = self::find_uncompleted_by_user_id( $userID );
+              if ($saved_cart)
+              {
+                $cart->adopt_participants($saved_cart->id);
+                $saved_cart->delete();
+                $cart->load_associations();
+              } else {
+                $cart->user_id = $userID;
+                $cart->save();
+              }
+            }
+          }
+	}
+	if ( $cart === false ) {
+	  if ( is_null( $userID ) ) {
+		$cart = self::create( array( ) );
+	  } else {
+		$cart = self::find_uncompleted_by_user_id( $userID );
+		if ( $cart === false ) {
+		  $cart = self::create( array( 'user_id' => $userID ) );
+		}
+	  }
+	  $session->set( 'event_cart_id', $cart->id );
+	}
+
+        if (function_exists("error_backtrace_write"))
+        {
+          $date_string = date('Y-m-d H:i:s');
+          $client = ip_address();
+          error_backtrace_write("[$date_string] $client -- Loaded cart {$cart->id}\n");
+        }
+
+	return $cart;
+  }
+
+  public static function find_uncompleted_by_id( $id )
+  {
+	return self::find_by_params( array( 'id' => $id, 'completed' => 0 ) );
+  }
+
+  public static function find_uncompleted_by_user_id( $user_id )
+  {
+	return self::find_by_params( array( 'user_id' => $user_id, 'completed' => 0 ) );
+  }
+
+  public function get_main_events_in_carts( )
+  {
+	//return CRM_Event_Cart_BAO_EventInCart::find_all_by_params( array( 'main_conference_event_id' 
+	$all = array( );
+	foreach ( $this->events_in_carts as $event_in_cart ) {
+	    if (!$event_in_cart->is_child_event()) {
+		$all[] = $event_in_cart;
+	    }
+	}
+	return $all;
+  }
+
+  public function get_events_in_carts_by_main_event_id( $main_conference_event_id )
+  {
+	$all = array( );
+        if (!$main_conference_event_id) {
+            return $all;
+        }
+	foreach ( $this->events_in_carts as $event_in_cart ) {
+	    if ($event_in_cart->event->parent_event_id == $main_conference_event_id) {
+		$all[] = $event_in_cart;
+	    }
+	}
+	usort($all, "CRM_Event_Cart_BAO_Cart::compare_event_dates");
+	return $all;
+  }
+
+  static function compare_event_dates($event_in_cart_1, $event_in_cart_2)
+  {
+	$date_1 = CRM_Utils_Date::unixTime( $event_in_cart_1->event->start_date );
+	$date_2 = CRM_Utils_Date::unixTime( $event_in_cart_2->event->start_date );
+
+	if ($date_1 == $date_2) return 0;
+	return ($date_1 < $date_2) ? -1 : 1;
+  }
+
+  public function get_subparticipants($main_participant)
+  {
+    $subparticipants = array();
+    foreach ($this->events_in_carts as $event_in_cart)
+    {
+      if ($event_in_cart->is_child_event($main_participant->event_id))
+      {
+        foreach ( $event_in_cart->participants as $participant ) {
+            if ($participant->contact_id == $main_participant->contact_id) {
+                $subparticipants[] = $participant;
+                continue;
+            }
+        }
+      }
+    }
+    return $subparticipants;
+  }
+
+  public function get_event_in_cart_by_event_id( $event_id )
+  {
+        return CRM_Utils_Array::value( $event_id, $this->events_in_carts );
+  }
+
+  public function &get_event_in_cart_by_id( $event_in_cart_id )
+  {
+        foreach ($this->events_in_carts as $event_in_cart ) {
+	  if ( $event_in_cart->id == $event_in_cart_id ) {
+		return $event_in_cart;
+	  }
+	}
+        return null;
+  }
+
+  public function get_main_event_participants()
+  {
+    $participants = array();
+    foreach ($this->get_main_events_in_carts() as $event_in_cart)
+    {
+      $participants = array_merge($participants, $event_in_cart->participants);
+    }
+    return $participants;
+  }
+
+  public function load_associations( )
+  {
+	if ( $this->associations_loaded ) {
+	  return;
+	}
+	$this->associations_loaded = true;
+	$this->events_in_carts = CRM_Event_Cart_BAO_EventInCart::find_all_by_event_cart_id( $this->id );
+	foreach ( $this->events_in_carts as $event_in_cart ) {
+	  $event_in_cart->load_associations($this);
+	}
+	$this->save( );
+  }
+
+  public function remove_event_in_cart( $event_in_cart_id )
+  {
+	$event_in_cart = CRM_Event_Cart_BAO_EventInCart::find_by_id( $event_in_cart_id );
+        if ($event_in_cart) {
+            $sessions_to_remove = $this->get_events_in_carts_by_main_event_id( $event_in_cart->event_id );
+            foreach ($sessions_to_remove as $session) {
+                $this->remove_event_in_cart( $session->id );
+            }
+            unset($this->events_in_carts[$event_in_cart->event_id]);
+            $event_in_cart->delete( );
+        }
+	return $event_in_cart;
+  }
+
+  function get_participant_index_from_id($participant_id)
+  {
+    foreach ($this->events_in_carts as $event_in_cart)
+    {
+        $index = 0;
+        foreach ($event_in_cart->participants as $participant)
+        {
+            if ($participant->id == $participant_id)
+            {
+                return $index;
+            }
+            $index++;
+        }
+    }
+    return -1;
+  }
+
+  public static function retrieve( &$params, &$values )
+  {
+	$cart = self::find_by_params( $params );
+	if ( $cart === false ) {
+	  CRM_Core_Error::fatal( ts( 'Could not find cart matching %1', array ( 1 => var_export( $params, true ) ) ) );
+	}
+	CRM_Core_DAO::storeValues( $cart, $values );
+	return $values;
+  }
+
+
+  public function adopt_participants($from_cart_id)
+  {
+    $params = array(
+      1 => array( $this->id, 'Integer' ),
+      2 => array( $from_cart_id, 'Integer' ),
+    );
+    $sql = "UPDATE civicrm_participant SET cart_id='%1' WHERE cart_id='%2'";
+
+    CRM_Core_DAO::executeQuery($sql, $params);
+  }
+}
+
+?>
diff --git a/CRM/Event/Cart/BAO/Conference.php b/CRM/Event/Cart/BAO/Conference.php
new file mode 100644
index 0000000..dc98483
--- /dev/null
+++ b/CRM/Event/Cart/BAO/Conference.php
@@ -0,0 +1,36 @@
+<?php
+
+class CRM_Event_Cart_BAO_Conference
+{
+//XXX flattens the object tree for convenient templating
+    static function get_participant_sessions($main_event_participant_id)
+    {
+        $sql = <<<EOS
+SELECT sub_event.* FROM civicrm_participant main_participant
+    JOIN civicrm_event sub_event ON sub_event.parent_event_id = main_participant.event_id
+    JOIN civicrm_participant sub_participant ON sub_participant.event_id = sub_event.id
+    LEFT JOIN
+        civicrm_option_value slot ON sub_event.slot_label_id = slot.value
+    LEFT JOIN
+        civicrm_option_group og ON slot.option_group_id = og.id
+  WHERE
+      main_participant.id = %1
+      AND sub_participant.contact_id = main_participant.contact_id
+      AND og.name = 'conference_slot'
+  ORDER BY
+      slot.weight,
+      sub_event.start_date
+EOS;
+        $sql_args = array( 1 => array($main_event_participant_id, 'Integer') );
+        $dao = CRM_Core_DAO::executeQuery( $sql, $sql_args );
+        $smarty_sessions = array( );
+        while ($dao->fetch( ))
+        {
+            $smarty_sessions[] = get_object_vars($dao);
+        }
+        if (empty($smarty_sessions)) {
+            return null;
+        }
+        return $smarty_sessions;
+    }
+}
diff --git a/CRM/Event/Cart/BAO/EventInCart.php b/CRM/Event/Cart/BAO/EventInCart.php
new file mode 100644
index 0000000..a53a35f
--- /dev/null
+++ b/CRM/Event/Cart/BAO/EventInCart.php
@@ -0,0 +1,241 @@
+<?php
+
+require_once 'CRM/Event/Cart/DAO/EventInCart.php';
+
+class CRM_Event_Cart_BAO_EventInCart extends CRM_Event_Cart_DAO_EventInCart implements
+  ArrayAccess
+{
+  public $assocations_loaded = false;
+  public $event;
+  public $event_cart;
+  public $location = null;
+  public $participants = array( );
+
+  function __construct( )
+  {
+	parent::__construct( );
+  }
+
+  public function add_participant($participant)
+  {
+    $this->participants[$participant->id] = $participant;
+  }
+
+  public static function create( $params )
+  {
+	require_once 'CRM/Core/Transaction.php';
+	$transaction = new CRM_Core_Transaction( );
+	$event_in_cart = new CRM_Event_Cart_BAO_EventInCart( );
+	$event_in_cart->copyValues( $params );
+	$event_in_cart = $event_in_cart->save( );
+
+	if ( is_a( $event_in_cart, 'CRM_Core_Error') ) {
+	  $transaction->rollback( );
+	  CRM_Core_Error::fatal( ts( 'There was an error creating an event_in_cart') );
+	}
+
+	$transaction->commit( );
+
+	return $event_in_cart;
+  }
+
+  function delete()
+  {
+    $this->load_associations();
+    $contacts_to_delete = array();
+    foreach ($this->participants as $participant)
+    {
+        $defaults = array( );
+        $params = array( 'id' => $participant->contact_id);
+        $temporary_contact = CRM_Contact_BAO_Contact::retrieve( $params, $defaults );
+
+        if ($temporary_contact->is_deleted) {
+          $contacts_to_delete[$temporary_contact->id] = 1;
+        }
+        $participant->delete();
+    }
+    foreach (array_keys($contacts_to_delete) as $contact_id)
+    {
+        CRM_Contact_BAO_Contact::deleteContact($contact_id);
+    }
+    parent::delete();
+  }
+
+  public static function find_all_by_event_cart_id( $event_cart_id )
+  {
+	return self::find_all_by_params( array( 'event_cart_id' => $event_cart_id ) );
+  }
+
+  public static function find_all_by_params( $params )
+  {
+	$event_in_cart = new CRM_Event_Cart_BAO_EventInCart( );
+	$event_in_cart->copyValues( $params );
+	$result = array();
+	if ( $event_in_cart->find( ) ) {
+	  while ( $event_in_cart->fetch( ) ) {
+		$result[$event_in_cart->event_id] = clone( $event_in_cart );
+	  }
+	}
+	return $result;
+  }
+
+  public static function find_by_id( $id )
+  {
+	return self::find_by_params( array( 'id' => $id ) );
+  }
+
+  public static function find_by_params( $params )
+  {
+	$event_in_cart = new CRM_Event_Cart_BAO_EventInCart( );
+	$event_in_cart->copyValues( $params );
+	if ( $event_in_cart->find( true ) ) {
+	  return $event_in_cart;
+	} else {
+	  return false;
+	}
+  }
+
+  public function remove_participant_by_contact_id($contact_id) {
+	$to_remove = array( );
+	foreach ( $this->participants as $participant ) {
+	      if ($participant->contact_id == $contact_id) {
+		$to_remove[$participant->id] = 1;
+		$participant->delete( );
+	      }
+	}
+	$this->participants = array_diff_key( $this->participants, $to_remove );
+  }
+
+  public function get_participant_by_id($participant_id) {
+    return $this->participants[$participant_id];
+  }
+
+  public function remove_participant_by_id($participant_id) {
+    $this->get_participant_by_id($participant_id)->delete();
+    unset($this->participants[$participant_id]);
+  }
+
+  static function part_key( $participant ) {
+      return $participant->id;
+  }
+
+  public function load_associations( $event_cart = null ) {
+	if ( $this->assocations_loaded ) {
+	  return;
+	}
+	$this->assocations_loaded = true;
+	require_once 'CRM/Event/BAO/Event.php';
+	$params = array( 'id' => $this->event_id );
+	$defaults = array( );
+	$this->event = CRM_Event_BAO_Event::retrieve( $params, $defaults );
+
+	if ( $event_cart != null ) {
+	  $this->event_cart = $event_cart;
+	  $this->event_cart_id = $event_cart->id;
+	} else {
+	  $this->event_cart = CRM_Event_Cart_BAO_Cart::find_by_id( $this->event_cart_id);
+	}
+
+	require_once 'CRM/Event/Cart/BAO/MerParticipant.php';
+	$participants = CRM_Event_Cart_BAO_MerParticipant::find_all_by_event_and_cart_id($this->event_id, $this->event_cart->id);
+	foreach ($participants as $participant) {
+	    $participant->load_associations( );
+	    $this->add_participant( $participant );
+	}
+  }
+
+  public function load_location( ) {
+	if ($this->location == null) {
+	  $location_params = array( 'entity_id' => $this->event_id, 'entity_table' => 'civicrm_event' );
+	  $this->location = CRM_Core_BAO_Location::getValues( $location_params, true );
+	}
+  }
+
+  public function not_waiting_participants( ) {
+	$result = array( );
+	foreach ( $this->participants as $participant ) {
+	  if ( !$participant->must_wait ) {
+		$result[] = $participant;	
+	  }
+	}
+	return $result;
+  }
+
+  public function num_not_waiting_participants( ) {
+	return count( $this->not_waiting_participants( ) );
+  }
+
+  public function num_waiting_participants( ) {
+	return count( $this->waiting_participants( ) );
+  }
+
+
+  public function offsetExists( $offset ) {
+	return array_key_exists(array_merge($this->fields( ), array('main_conference_event_id')), $offset);
+  }
+
+  public function offsetGet( $offset ) {
+	if ( $offset == 'event' ) {
+	  return $this->event->toArray();
+	}
+	if ( $offset == 'id' ) {
+	  return $this->id;
+	}
+	if ( $offset == 'main_conference_event_id' ) {
+	  return $this->main_conference_event_id;
+	}
+	$fields =& $this->fields( );
+	return $fields[$offset];
+  }
+
+  public function offsetSet( $offset, $value ) {
+  }
+
+  public function offsetUnset( $offset ) {
+  }
+
+  public function waiting_participants( ) {
+	$result = array( );
+	foreach ( $this->participants as $participant ) {
+	  if ( $participant->must_wait ) {
+		$result[] = $participant;	
+	  }
+	}
+	return $result;
+  }
+
+  static function get_registration_link($event_id)
+  {
+      require_once 'CRM/Event/Cart/BAO/Cart.php';
+      $cart = CRM_Event_Cart_BAO_Cart::find_or_create_for_current_session( );
+      $cart->load_associations( );
+      $event_in_cart = $cart->get_event_in_cart_by_event_id( $event_id );
+
+      if ($event_in_cart) {
+        return array(
+          'label' => "Remove from Cart",
+          'path' => 'civicrm/event/remove_from_cart',
+          'query' => "reset=1&id={$event_id}",
+        );
+      } else {
+        return array(
+          'label' => "Add to Cart",
+          'path' => 'civicrm/event/add_to_cart',
+          'query' => "reset=1&id={$event_id}",
+        );
+      }
+  }
+
+  function is_parent_event()
+  {
+    return (null !== (CRM_Event_BAO_Event::get_sub_events($this->event_id)));
+  }
+
+  function is_child_event($parent_event_id = null)
+  {
+    if ($parent_event_id == null)
+        return $this->event->parent_event_id;
+    else
+        return $this->event->parent_event_id == $parent_event_id;
+  }
+}
diff --git a/CRM/Event/Cart/BAO/MerParticipant.php b/CRM/Event/Cart/BAO/MerParticipant.php
new file mode 100644
index 0000000..fa2760d
--- /dev/null
+++ b/CRM/Event/Cart/BAO/MerParticipant.php
@@ -0,0 +1,124 @@
+<?php
+
+require_once('CRM/Event/BAO/Participant.php');
+
+class CRM_Event_Cart_BAO_MerParticipant extends CRM_Event_BAO_Participant
+{
+  public $email = null;
+  public $contribution_id = null;
+
+    //XXX
+  function __construct($participant = null)
+  {
+    parent::__construct();
+    $a = (array)$participant;
+    $this->copyValues($a);
+
+    $this->email = CRM_Utils_Array::value('email', $participant);
+  }
+
+  public static function create( $params )
+  {
+        $participantParams = array
+        (
+            'id'                => CRM_Utils_Array::value('id', $params),
+            'role_id'           => self::get_attendee_role_id(),
+            'status_id'         => self::get_pending_in_cart_status_id(),
+            'contact_id'        => $params['contact_id'],
+            'event_id'          => $params['event_id'],
+            'cart_id'           => $params['cart_id'],
+            //XXX
+            //'registered_by_id'  =>
+            //'discount_amount'   =>
+            //'fee_level'         => $params['fee_level'],
+        );
+        $participant = CRM_Event_BAO_Participant::create($participantParams);
+
+	if ( is_a( $participant, 'CRM_Core_Error') ) {
+	  CRM_Core_Error::fatal( ts( 'There was an error creating a cart participant') );
+	}
+
+	$mer_participant = new CRM_Event_Cart_BAO_MerParticipant($participant);
+
+        return $mer_participant;
+  }
+
+  static function get_attendee_role_id()
+  {
+    $roles = CRM_Event_PseudoConstant::participantRole(null, "v.label='Attendee'");
+    return array_pop(array_keys($roles));
+  }
+
+  static function get_pending_in_cart_status_id()
+  {
+    $status_types = CRM_Event_PseudoConstant::participantStatus(null, "name='Pending in cart'");
+    return array_pop(array_keys($status_types));
+  }
+
+  public static function find_all_by_cart_id( $event_cart_id )
+  {
+        if ($event_cart_id == null)
+            return null;
+        return self::find_all_by_params( array( 'cart_id' => $event_cart_id ) );
+  }
+
+  public static function find_all_by_event_and_cart_id( $event_id, $event_cart_id )
+  {
+        if ($event_cart_id == null)
+            return null;
+        return self::find_all_by_params( array( 'event_id' => $event_id, 'cart_id' => $event_cart_id ) );
+  }
+
+  public static function find_all_by_params( $params )
+  {
+        $participant = new CRM_Event_BAO_Participant( );
+        $participant->copyValues( $params );
+        $result = array();
+        if ( $participant->find( ) ) {
+          while ( $participant->fetch( ) ) {
+                $result[] = new CRM_Event_Cart_BAO_MerParticipant(clone( $participant ));
+          }
+        }
+        return $result;
+  }
+
+  public static function get_by_id($id)
+  {
+    $results = self::find_all_by_params(array('id' => $id));
+    return array_pop($results);
+  }
+
+  function load_associations()
+  {
+    require_once 'CRM/Contact/BAO/Contact.php';
+    $contact_details = CRM_Contact_BAO_Contact::getContactDetails($this->contact_id);
+    $this->email = $contact_details[1];
+  }
+
+  function get_participant_index( )
+  {
+    if (!$this->cart) {
+        $this->cart = CRM_Event_Cart_BAO_Cart::find_by_id($this->cart_id);
+        $this->cart->load_associations();
+    }
+    $index = $this->cart->get_participant_index_from_id($this->id);
+    return $index + 1;
+  }
+
+  static function billing_address_from_contact( $contact )
+  {
+        foreach ($contact->address as $loc) {
+            if ($loc['is_billing']) return $loc;
+        }
+        foreach ($contact->address as $loc) {
+            if ($loc['is_primary']) return $loc;
+        }
+        return null;
+  }
+
+  function get_form()
+  {
+    require_once('CRM/Event/Cart/Form/MerParticipant.php');
+    return new CRM_Event_Cart_Form_MerParticipant($this);
+  }
+}
diff --git a/CRM/Event/Cart/Controller/Checkout.php b/CRM/Event/Cart/Controller/Checkout.php
new file mode 100644
index 0000000..9ef0311
--- /dev/null
+++ b/CRM/Event/Cart/Controller/Checkout.php
@@ -0,0 +1,26 @@
+<?php
+
+require_once 'CRM/Core/Controller.php';
+
+class CRM_Event_Cart_Controller_Checkout extends CRM_Core_Controller 
+{
+  function __construct( $title = null, $action = CRM_Core_Action::NONE, $modal = true ) 
+  {
+    parent::__construct( $title, $modal );
+
+    require_once 'CRM/Event/Cart/StateMachine/Checkout.php';
+
+    $this->_stateMachine = new CRM_Event_Cart_StateMachine_Checkout( $this, $action );
+    $this->addPages( $this->_stateMachine, $action );
+    $config = CRM_Core_Config::singleton( );
+
+    //changes for custom data type File
+    $uploadNames = $this->get( 'uploadNames' );
+    if ( is_array( $uploadNames ) && ! empty ( $uploadNames ) ) {
+      $this->addActions( $config->customFileUploadDir, $uploadNames );
+    } else {
+      // add all the actions
+      $this->addActions( );
+    }
+  }
+}
diff --git a/CRM/Event/Cart/DAO/Cart.php b/CRM/Event/Cart/DAO/Cart.php
new file mode 100644
index 0000000..c7466a3
--- /dev/null
+++ b/CRM/Event/Cart/DAO/Cart.php
@@ -0,0 +1,220 @@
+<?php
+/*
++--------------------------------------------------------------------+
+| CiviCRM version 3.2                                                |
++--------------------------------------------------------------------+
+| Copyright CiviCRM LLC (c) 2004-2010                                |
++--------------------------------------------------------------------+
+| This file is a part of CiviCRM.                                    |
+|                                                                    |
+| CiviCRM is free software; you can copy, modify, and distribute it  |
+| under the terms of the GNU Affero General Public License           |
+| Version 3, 19 November 2007 and the CiviCRM Licensing Exception.   |
+|                                                                    |
+| CiviCRM is distributed in the hope that it will be useful, but     |
+| WITHOUT ANY WARRANTY; without even the implied warranty of         |
+| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.               |
+| See the GNU Affero General Public License for more details.        |
+|                                                                    |
+| You should have received a copy of the GNU Affero General Public   |
+| License and the CiviCRM Licensing Exception along                  |
+| with this program; if not, contact CiviCRM LLC                     |
+| at info[AT]civicrm[DOT]org. If you have questions about the        |
+| GNU Affero General Public License or the licensing of CiviCRM,     |
+| see the CiviCRM license FAQ at http://civicrm.org/licensing        |
++--------------------------------------------------------------------+
+*/
+/**
+ *
+ * @package CRM
+ * @copyright CiviCRM LLC (c) 2004-2010
+ * $Id$
+ *
+ */
+require_once 'CRM/Core/DAO.php';
+require_once 'CRM/Utils/Type.php';
+class CRM_Event_Cart_DAO_Cart extends CRM_Core_DAO
+{
+    /**
+     * static instance to hold the table name
+     *
+     * @var string
+     * @static
+     */
+    static $_tableName = 'civicrm_event_carts';
+    /**
+     * static instance to hold the field values
+     *
+     * @var array
+     * @static
+     */
+    static $_fields = null;
+    /**
+     * static instance to hold the FK relationships
+     *
+     * @var string
+     * @static
+     */
+    static $_links = null;
+    /**
+     * static instance to hold the values that can
+     * be imported / apu
+     *
+     * @var array
+     * @static
+     */
+    static $_import = null;
+    /**
+     * static instance to hold the values that can
+     * be exported / apu
+     *
+     * @var array
+     * @static
+     */
+    static $_export = null;
+    /**
+     * static value to see if we should log any modifications to
+     * this table in the civicrm_log table
+     *
+     * @var boolean
+     * @static
+     */
+    static $_log = false;
+    /**
+     * Cart Id
+     *
+     * @var int unsigned
+     */
+    public $id;
+    /**
+     * FK to civicrm_contact who created this cart
+     *
+     * @var int unsigned
+     */
+    public $user_id;
+    /**
+     *
+     * @var boolean
+     */
+    public $completed;
+    /**
+     * class constructor
+     *
+     * @access public
+     * @return civicrm_event_carts
+     */
+    function __construct()
+    {
+        parent::__construct();
+    }
+    /**
+     * return foreign links
+     *
+     * @access public
+     * @return array
+     */
+    function &links()
+    {
+        if (!(self::$_links)) {
+            self::$_links = array(
+                'user_id' => 'civicrm_contact:id',
+            );
+        }
+        return self::$_links;
+    }
+    /**
+     * returns all the column names of this table
+     *
+     * @access public
+     * @return array
+     */
+    function &fields()
+    {
+        if (!(self::$_fields)) {
+            self::$_fields = array(
+                'cart_id' => array(
+                    'name' => 'id',
+                    'type' => CRM_Utils_Type::T_INT,
+                    'required' => true,
+                ) ,
+                'user_id' => array(
+                    'name' => 'user_id',
+                    'type' => CRM_Utils_Type::T_INT,
+                    'FKClassName' => 'CRM_Contact_DAO_Contact',
+                ) ,
+                'completed' => array(
+                    'name' => 'completed',
+                    'type' => CRM_Utils_Type::T_BOOLEAN,
+                    'title' => ts('Completed') ,
+                ) ,
+            );
+        }
+        return self::$_fields;
+    }
+    /**
+     * returns the names of this table
+     *
+     * @access public
+     * @return string
+     */
+    function getTableName()
+    {
+        return self::$_tableName;
+    }
+    /**
+     * returns if this table needs to be logged
+     *
+     * @access public
+     * @return boolean
+     */
+    function getLog()
+    {
+        return self::$_log;
+    }
+    /**
+     * returns the list of fields that can be imported
+     *
+     * @access public
+     * return array
+     */
+    function &import($prefix = false)
+    {
+        if (!(self::$_import)) {
+            self::$_import = array();
+            $fields = & self::fields();
+            foreach($fields as $name => $field) {
+                if (CRM_Utils_Array::value('import', $field)) {
+                    if ($prefix) {
+                        self::$_import['event_carts'] = & $fields[$name];
+                    } else {
+                        self::$_import[$name] = & $fields[$name];
+                    }
+                }
+            }
+        }
+        return self::$_import;
+    }
+    /**
+     * returns the list of fields that can be exported
+     *
+     * @access public
+     * return array
+     */
+    function &export($prefix = false)
+    {
+        if (!(self::$_export)) {
+            self::$_export = array();
+            $fields = & self::fields();
+            foreach($fields as $name => $field) {
+                if (CRM_Utils_Array::value('export', $field)) {
+                    if ($prefix) {
+                        self::$_export['event_carts'] = & $fields[$name];
+                    } else {
+                        self::$_export[$name] = & $fields[$name];
+                    }
+                }
+            }
+        }
+        return self::$_export;
+    }
+}
diff --git a/CRM/Event/Cart/DAO/EventInCart.php b/CRM/Event/Cart/DAO/EventInCart.php
new file mode 100644
index 0000000..bb3fef2
--- /dev/null
+++ b/CRM/Event/Cart/DAO/EventInCart.php
@@ -0,0 +1,222 @@
+<?php
+/*
++--------------------------------------------------------------------+
+| CiviCRM version 3.2                                                |
++--------------------------------------------------------------------+
+| Copyright CiviCRM LLC (c) 2004-2010                                |
++--------------------------------------------------------------------+
+| This file is a part of CiviCRM.                                    |
+|                                                                    |
+| CiviCRM is free software; you can copy, modify, and distribute it  |
+| under the terms of the GNU Affero General Public License           |
+| Version 3, 19 November 2007 and the CiviCRM Licensing Exception.   |
+|                                                                    |
+| CiviCRM is distributed in the hope that it will be useful, but     |
+| WITHOUT ANY WARRANTY; without even the implied warranty of         |
+| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.               |
+| See the GNU Affero General Public License for more details.        |
+|                                                                    |
+| You should have received a copy of the GNU Affero General Public   |
+| License and the CiviCRM Licensing Exception along                  |
+| with this program; if not, contact CiviCRM LLC                     |
+| at info[AT]civicrm[DOT]org. If you have questions about the        |
+| GNU Affero General Public License or the licensing of CiviCRM,     |
+| see the CiviCRM license FAQ at http://civicrm.org/licensing        |
++--------------------------------------------------------------------+
+*/
+/**
+ *
+ * @package CRM
+ * @copyright CiviCRM LLC (c) 2004-2010
+ * $Id$
+ *
+ */
+require_once 'CRM/Core/DAO.php';
+require_once 'CRM/Utils/Type.php';
+class CRM_Event_Cart_DAO_EventInCart extends CRM_Core_DAO
+{
+    /**
+     * static instance to hold the table name
+     *
+     * @var string
+     * @static
+     */
+    static $_tableName = 'civicrm_events_in_carts';
+    /**
+     * static instance to hold the field values
+     *
+     * @var array
+     * @static
+     */
+    static $_fields = null;
+    /**
+     * static instance to hold the FK relationships
+     *
+     * @var string
+     * @static
+     */
+    static $_links = null;
+    /**
+     * static instance to hold the values that can
+     * be imported / apu
+     *
+     * @var array
+     * @static
+     */
+    static $_import = null;
+    /**
+     * static instance to hold the values that can
+     * be exported / apu
+     *
+     * @var array
+     * @static
+     */
+    static $_export = null;
+    /**
+     * static value to see if we should log any modifications to
+     * this table in the civicrm_log table
+     *
+     * @var boolean
+     * @static
+     */
+    static $_log = false;
+    /**
+     * Event In Cart Id
+     *
+     * @var int unsigned
+     */
+    public $id;
+    /**
+     * FK to Event ID
+     *
+     * @var int unsigned
+     */
+    public $event_id;
+    /**
+     * FK to Event Cart ID
+     *
+     * @var int unsigned
+     */
+    public $event_cart_id;
+    /**
+     * class constructor
+     *
+     * @access public
+     * @return civicrm_events_in_carts
+     */
+    function __construct()
+    {
+        parent::__construct();
+    }
+    /**
+     * return foreign links
+     *
+     * @access public
+     * @return array
+     */
+    function &links()
+    {
+        if (!(self::$_links)) {
+            self::$_links = array(
+                'event_id' => 'civicrm_event:id',
+                'event_cart_id' => 'civicrm_event_carts:id',
+            );
+        }
+        return self::$_links;
+    }
+    /**
+     * returns all the column names of this table
+     *
+     * @access public
+     * @return array
+     */
+    function &fields()
+    {
+        if (!(self::$_fields)) {
+            self::$_fields = array(
+                'event_in_cart_id' => array(
+                    'name' => 'id',
+                    'type' => CRM_Utils_Type::T_INT,
+                    'required' => true,
+                ) ,
+                'event_id' => array(
+                    'name' => 'event_id',
+                    'type' => CRM_Utils_Type::T_INT,
+                    'FKClassName' => 'CRM_Event_DAO_Event',
+                ) ,
+                'event_cart_id' => array(
+                    'name' => 'event_cart_id',
+                    'type' => CRM_Utils_Type::T_INT,
+                    'FKClassName' => 'CRM_Event_DAO_Cart',
+                ) ,
+            );
+        }
+        return self::$_fields;
+    }
+    /**
+     * returns the names of this table
+     *
+     * @access public
+     * @return string
+     */
+    function getTableName()
+    {
+        return self::$_tableName;
+    }
+    /**
+     * returns if this table needs to be logged
+     *
+     * @access public
+     * @return boolean
+     */
+    function getLog()
+    {
+        return self::$_log;
+    }
+    /**
+     * returns the list of fields that can be imported
+     *
+     * @access public
+     * return array
+     */
+    function &import($prefix = false)
+    {
+        if (!(self::$_import)) {
+            self::$_import = array();
+            $fields = & self::fields();
+            foreach($fields as $name => $field) {
+                if (CRM_Utils_Array::value('import', $field)) {
+                    if ($prefix) {
+                        self::$_import['events_in_carts'] = & $fields[$name];
+                    } else {
+                        self::$_import[$name] = & $fields[$name];
+                    }
+                }
+            }
+        }
+        return self::$_import;
+    }
+    /**
+     * returns the list of fields that can be exported
+     *
+     * @access public
+     * return array
+     */
+    function &export($prefix = false)
+    {
+        if (!(self::$_export)) {
+            self::$_export = array();
+            $fields = & self::fields();
+            foreach($fields as $name => $field) {
+                if (CRM_Utils_Array::value('export', $field)) {
+                    if ($prefix) {
+                        self::$_export['events_in_carts'] = & $fields[$name];
+                    } else {
+                        self::$_export[$name] = & $fields[$name];
+                    }
+                }
+            }
+        }
+        return self::$_export;
+    }
+}
diff --git a/CRM/Event/Cart/DAO/MerParticipant.php b/CRM/Event/Cart/DAO/MerParticipant.php
new file mode 100644
index 0000000..85ed0f7
--- /dev/null
+++ b/CRM/Event/Cart/DAO/MerParticipant.php
@@ -0,0 +1,265 @@
+<?php
+/*
++--------------------------------------------------------------------+
+| CiviCRM version 3.4                                                |
++--------------------------------------------------------------------+
+| Copyright CiviCRM LLC (c) 2004-2011                                |
++--------------------------------------------------------------------+
+| This file is a part of CiviCRM.                                    |
+|                                                                    |
+| CiviCRM is free software; you can copy, modify, and distribute it  |
+| under the terms of the GNU Affero General Public License           |
+| Version 3, 19 November 2007 and the CiviCRM Licensing Exception.   |
+|                                                                    |
+| CiviCRM is distributed in the hope that it will be useful, but     |
+| WITHOUT ANY WARRANTY; without even the implied warranty of         |
+| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.               |
+| See the GNU Affero General Public License for more details.        |
+|                                                                    |
+| You should have received a copy of the GNU Affero General Public   |
+| License and the CiviCRM Licensing Exception along                  |
+| with this program; if not, contact CiviCRM LLC                     |
+| at info[AT]civicrm[DOT]org. If you have questions about the        |
+| GNU Affero General Public License or the licensing of CiviCRM,     |
+| see the CiviCRM license FAQ at http://civicrm.org/licensing        |
++--------------------------------------------------------------------+
+*/
+/**
+ *
+ * @package CRM
+ * @copyright CiviCRM LLC (c) 2004-2011
+ * $Id$
+ *
+ */
+require_once 'CRM/Core/DAO.php';
+require_once 'CRM/Utils/Type.php';
+class CRM_Event_Cart_DAO_MerParticipant extends CRM_Core_DAO
+{
+    /**
+     * static instance to hold the table name
+     *
+     * @var string
+     * @static
+     */
+    static $_tableName = 'civicrm_events_in_carts_participants';
+    /**
+     * static instance to hold the field values
+     *
+     * @var array
+     * @static
+     */
+    static $_fields = null;
+    /**
+     * static instance to hold the FK relationships
+     *
+     * @var string
+     * @static
+     */
+    static $_links = null;
+    /**
+     * static instance to hold the values that can
+     * be imported / apu
+     *
+     * @var array
+     * @static
+     */
+    static $_import = null;
+    /**
+     * static instance to hold the values that can
+     * be exported / apu
+     *
+     * @var array
+     * @static
+     */
+    static $_export = null;
+    /**
+     * static value to see if we should log any modifications to
+     * this table in the civicrm_log table
+     *
+     * @var boolean
+     * @static
+     */
+    static $_log = false;
+    /**
+     *
+     * @var int unsigned
+     */
+    public $id;
+    /**
+     * FK to Event In Cart Id
+     *
+     * @var int unsigned
+     */
+    public $event_in_cart_id;
+    /**
+     * Discount Amount
+     *
+     * @var int unsigned
+     */
+    public $discount_amount;
+    /**
+     * Cost
+     *
+     * @var int unsigned
+     */
+    public $cost;
+    /**
+     * Fee Level
+     *
+     * @var int unsigned
+     */
+    public $fee_level;
+    /**
+     * FK to civicrm_participant
+     *
+     * @var int unsigned
+     */
+    public $participant_id;
+    /**
+     * On Waiting List
+     *
+     * @var boolean
+     */
+    public $must_wait;
+    /**
+     * class constructor
+     *
+     * @access public
+     * @return civicrm_events_in_carts_participants
+     */
+    function __construct()
+    {
+        parent::__construct();
+    }
+    /**
+     * return foreign links
+     *
+     * @access public
+     * @return array
+     */
+    function &links()
+    {
+        if (!(self::$_links)) {
+            self::$_links = array(
+                'event_in_cart_id' => 'civicrm_events_in_carts:id',
+                'participant_id' => 'civicrm_participant:id',
+            );
+        }
+        return self::$_links;
+    }
+    /**
+     * returns all the column names of this table
+     *
+     * @access public
+     * @return array
+     */
+    function &fields()
+    {
+        if (!(self::$_fields)) {
+            self::$_fields = array(
+                'id' => array(
+                    'name' => 'id',
+                    'type' => CRM_Utils_Type::T_INT,
+                ) ,
+                'event_in_cart_id' => array(
+                    'name' => 'event_in_cart_id',
+                    'type' => CRM_Utils_Type::T_INT,
+                    'required' => true,
+                    'FKClassName' => 'CRM_Event_Cart_DAO_EventInCart',
+                ) ,
+                'discount_amount' => array(
+                    'name' => 'discount_amount',
+                    'type' => CRM_Utils_Type::T_INT,
+                    'title' => ts('Discount Amount') ,
+                ) ,
+                'cost' => array(
+                    'name' => 'cost',
+                    'type' => CRM_Utils_Type::T_INT,
+                    'title' => ts('Cost') ,
+                ) ,
+                'fee_level' => array(
+                    'name' => 'fee_level',
+                    'type' => CRM_Utils_Type::T_INT,
+                    'title' => ts('Fee Level') ,
+                ) ,
+                'participant_id' => array(
+                    'name' => 'participant_id',
+                    'type' => CRM_Utils_Type::T_INT,
+                    'FKClassName' => 'CRM_Event_DAO_Participant',
+                ) ,
+                'must_wait' => array(
+                    'name' => 'must_wait',
+                    'type' => CRM_Utils_Type::T_BOOLEAN,
+                    'title' => ts('Must Wait') ,
+                ) ,
+            );
+        }
+        return self::$_fields;
+    }
+    /**
+     * returns the names of this table
+     *
+     * @access public
+     * @return string
+     */
+    function getTableName()
+    {
+        return self::$_tableName;
+    }
+    /**
+     * returns if this table needs to be logged
+     *
+     * @access public
+     * @return boolean
+     */
+    function getLog()
+    {
+        return self::$_log;
+    }
+    /**
+     * returns the list of fields that can be imported
+     *
+     * @access public
+     * return array
+     */
+    function &import($prefix = false)
+    {
+        if (!(self::$_import)) {
+            self::$_import = array();
+            $fields = & self::fields();
+            foreach($fields as $name => $field) {
+                if (CRM_Utils_Array::value('import', $field)) {
+                    if ($prefix) {
+                        self::$_import['events_in_carts_participants'] = & $fields[$name];
+                    } else {
+                        self::$_import[$name] = & $fields[$name];
+                    }
+                }
+            }
+        }
+        return self::$_import;
+    }
+    /**
+     * returns the list of fields that can be exported
+     *
+     * @access public
+     * return array
+     */
+    function &export($prefix = false)
+    {
+        if (!(self::$_export)) {
+            self::$_export = array();
+            $fields = & self::fields();
+            foreach($fields as $name => $field) {
+                if (CRM_Utils_Array::value('export', $field)) {
+                    if ($prefix) {
+                        self::$_export['events_in_carts_participants'] = & $fields[$name];
+                    } else {
+                        self::$_export[$name] = & $fields[$name];
+                    }
+                }
+            }
+        }
+        return self::$_export;
+    }
+}
diff --git a/CRM/Event/Cart/Form/Cart.php b/CRM/Event/Cart/Form/Cart.php
new file mode 100644
index 0000000..1cab0d1
--- /dev/null
+++ b/CRM/Event/Cart/Form/Cart.php
@@ -0,0 +1,176 @@
+<?php
+
+require_once('CRM/Core/Form.php');
+class CRM_Event_Cart_Form_Cart extends CRM_Core_Form
+{
+  public $cart;
+
+  public $_action;
+  public $contact;
+  public $event_cart_id = null;
+  public $_mode;
+  public $participants;
+
+  public function preProcess()
+  {
+    $this->_action = CRM_Utils_Request::retrieve( 'action', 'String', $this, false );
+    $this->_mode = 'live';
+    $this->loadCart( );
+
+    $this->checkWaitingList( );
+
+    $locationTypes = CRM_Core_PseudoConstant::locationType( );
+    $this->_bltID = array_search( 'Billing', $locationTypes);
+    $this->assign('bltID', $this->_bltID);
+
+    $event_titles = array();
+    foreach ($this->cart->get_main_events_in_carts() as $event_in_cart)
+    {
+      $event_titles[] = $event_in_cart->event->title;
+    }
+    if (!isset($this->discounts)) {
+      $this->discounts = array();
+    }
+  }
+
+  function loadCart( )
+  {
+	if ( $this->event_cart_id == null ) {
+	  $this->cart = CRM_Event_Cart_BAO_Cart::find_or_create_for_current_session( );
+	} else {
+	  $this->cart = CRM_Event_Cart_BAO_Cart::find_by_id( $this->event_cart_id );
+	}
+        $this->cart->load_associations( );
+        $this->stub_out_and_inherit( );
+  }
+
+  function stub_out_and_inherit( )
+  {
+	require_once 'CRM/Event/Cart/BAO/MerParticipant.php';
+	require_once 'CRM/Core/Transaction.php';
+	$transaction = new CRM_Core_Transaction( );
+
+	foreach ( $this->cart->get_main_events_in_carts( ) as $event_in_cart ) {
+	  if ( empty($event_in_cart->participants) ) {
+		$participant = CRM_Event_Cart_BAO_MerParticipant::create( array(
+                      'cart_id' => $this->cart->id,
+		      'event_id' => $event_in_cart->event_id,
+		      'contact_id' => self::find_or_create_contact( $this->getContactID() ),
+		) );
+                $participant->save();
+		$event_in_cart->add_participant( $participant );
+	  }
+          $event_in_cart->save();
+	}
+	$transaction->commit( );
+  }
+
+  function checkWaitingList( )
+  {
+	require_once 'CRM/Event/BAO/Participant.php';
+	foreach ( $this->cart->events_in_carts as $event_in_cart )
+	{
+	  $empty_seats = $this->checkEventCapacity( $event_in_cart->event_id );
+	  if ($empty_seats === null) {
+		continue;
+	  }
+	  foreach ( $event_in_cart->participants as $participant ) {
+		if ( $empty_seats <= 0 ) {
+		  $participant->must_wait = true;
+		}
+		$empty_seats--;
+	  }
+	}
+  }
+
+  function checkEventCapacity( $event_id )
+  {
+	require_once 'CRM/Event/BAO/Participant.php';
+	$empty_seats = CRM_Event_BAO_Participant::eventFull( $event_id, true );
+	if (is_numeric($empty_seats)) {
+	    return $empty_seats;
+	} if (is_string($empty_seats)) {
+	    return 0;
+	} else {
+	    return null;
+	}
+  }
+
+  static function is_administrator()
+  {
+        global $user;
+  	return CRM_Core_Permission::check( 'administer CiviCRM' );
+  }
+
+  function getContactID( )
+  {
+        //XXX when do we query 'cid' ?
+	$tempID = CRM_Utils_Request::retrieve( 'cid', 'Positive', $this );
+
+	//check if this is a checksum authentication
+	$userChecksum = CRM_Utils_Request::retrieve( 'cs', 'String', $this );
+	if ( $userChecksum ) {
+	  //check for anonymous user.
+	  require_once 'CRM/Contact/BAO/Contact/Utils.php';
+	  $validUser = CRM_Contact_BAO_Contact_Utils::validChecksum( $tempID, $userChecksum );
+	  if ( $validUser ) return  $tempID;
+	}
+
+	// check if the user is registered and we have a contact ID
+	$session = CRM_Core_Session::singleton( );
+	return $session->get( 'userID' );
+  }
+
+  static function find_contact($fields)
+  {
+    require_once 'CRM/Dedupe/Finder.php';
+    $dedupe_params = CRM_Dedupe_Finder::formatParams($fields, 'Individual');
+    $dedupe_params['check_permission'] = false;
+    $ids = CRM_Dedupe_Finder::dupesByParams($dedupe_params, 'Individual');
+    if (is_array($ids))
+      return array_pop($ids);
+    else
+      return null;
+  }
+
+  static function find_or_create_contact( $registeringContactID = null, $fields = array() )
+  {
+    $contact_id = self::find_contact($fields);
+
+    if ($contact_id) {
+      return $contact_id;
+    }
+
+    require_once 'CRM/Contact/BAO/Group.php';
+
+    //XXX
+    $params = array( 'name' => 'RegisteredByOther' );
+    $values = array( );
+    $group = CRM_Contact_BAO_Group::retrieve( $params, $values );
+    $add_to_groups = array( );
+    if ( $group != null ) {
+      $add_to_groups[] = $group->id;
+    }
+    // still add the employer id of the signed in user  //???
+    $contact_params = array(
+      'email-Primary' => CRM_Utils_Array::value('email', $fields, null),
+      'first_name' => CRM_Utils_Array::value('first_name', $fields, null),
+      'last_name' => CRM_Utils_Array::value('last_name', $fields, null),
+      'is_deleted' => CRM_Utils_Array::value('is_deleted', $fields, true),
+    );
+    $no_fields = array( );
+    require_once 'CRM/Utils/Hook.php';
+    CRM_Utils_Hook::createCartContact( $registeringContactID, $contact_params );
+    $contact_id = CRM_Contact_BAO_Contact::createProfileContact( $contact_params, $no_fields, null, $add_to_groups );
+    if (!$contact_id) {
+      CRM_Core_Error::displaySessionError("Could not create or match a contact with that email address.  Please contact the webmaster.");
+    }
+    return $contact_id;
+  }
+
+  function getValuesForPage( $page_name )
+  {
+	$container = $this->controller->container( );
+	return $container['values'][$page_name];
+  }
+}
diff --git a/CRM/Event/Cart/Form/Checkout/ConferenceEvents.php b/CRM/Event/Cart/Form/Checkout/ConferenceEvents.php
new file mode 100644
index 0000000..f67f5e0
--- /dev/null
+++ b/CRM/Event/Cart/Form/Checkout/ConferenceEvents.php
@@ -0,0 +1,151 @@
+<?php
+
+class CRM_Event_Cart_Form_Checkout_ConferenceEvents extends CRM_Event_Cart_Form_Cart
+{
+  public $conference_event = null;
+  public $events_by_slot = array();
+  public $main_participant = null;
+  public $contact_id = null;
+
+  function preProcess( )
+  {
+	parent::preProcess( );
+	$matches = array();
+	preg_match( "/.*_(\d+)_(\d+)/", $this->getAttribute('name'), $matches );
+	$event_id = $matches[1];
+	$participant_id = $matches[2];
+        $event_in_cart = $this->cart->get_event_in_cart_by_event_id($event_id);
+        $this->conference_event = $event_in_cart->event;
+        $this->main_participant = $event_in_cart->get_participant_by_id($participant_id);
+        $this->contact_id = $this->main_participant->contact_id;
+        $this->main_participant->display_name = CRM_Contact_BAO_Contact::displayName($this->contact_id);
+
+	$events = new CRM_Event_BAO_Event();
+	$query = <<<EOS
+	  SELECT
+               civicrm_event.*,
+               slot.label AS slot_label
+          FROM
+               civicrm_event
+          JOIN
+                civicrm_option_value slot ON civicrm_event.slot_label_id = slot.value
+          JOIN
+                civicrm_option_group og ON slot.option_group_id = og.id
+	  WHERE
+		parent_event_id = {$this->conference_event->id}
+                AND civicrm_event.is_active = 1
+                AND civicrm_event.is_public = 1
+                AND COALESCE(civicrm_event.is_template, 0) = 0
+                AND og.name = 'conference_slot'
+	  ORDER BY
+		slot.weight, start_date
+EOS;
+	$events->query($query);
+	while ( $events->fetch() ) {
+	  if ( !array_key_exists( $events->slot_label, $this->events_by_slot ) ) {
+		$this->events_by_slot[$events->slot_label] = array();
+	  }
+	  $this->events_by_slot[$events->slot_label][] = clone($events);
+	}
+  }
+
+  function buildQuickForm( )
+  {
+	//drupal_add_css(drupal_get_path('module', 'jquery_ui') . '/jquery.ui/themes/base/jquery-ui.css');
+	//variable_set('jquery_update_compression_type', 'none');
+	//jquery_ui_add('ui.dialog');
+
+	$slot_index = -1;
+	$slot_fields = array( );
+	$session_options = array( );
+	$defaults = array( );
+	$previous_event_choices = $this->cart->get_subparticipants($this->main_participant);
+	foreach ( $this->events_by_slot as $slot_name => $events ) {
+	  $slot_index++;
+	  $slot_buttons = array( );
+	  $group_name = "slot_$slot_index";
+	  foreach ( $events as $event ) {
+	    $seats_available = $this->checkEventCapacity( $event->id );
+	    $event_is_full = ($seats_available === null) ? false : ($seats_available < 1);
+	    $radio = $this->createElement('radio', null, null, $event->title, $event->id);
+	    $slot_buttons[] = $radio;
+	    $event_description = ($event_is_full ? $event->event_full_text."<p>" : '')
+		. $event->description;
+
+	    $session_options[$radio->getAttribute('id')] = array (
+	    	'session_title' => $event->title,
+		'session_description' => $event_description,
+		'session_full' => $event_is_full,
+		'event_id' => $event->id
+	    );
+	    foreach ( $previous_event_choices as $choice ) {
+		if ($choice->event_id == $event->id) {
+		    $defaults[$group_name] = $event->id;
+		}
+	    }
+	  }
+	  $this->addGroup( $slot_buttons, $group_name, $slot_name);
+	  $slot_fields[$slot_name] = $group_name;
+	  if (!isset($defaults[$group_name])) {
+	      $defaults[$group_name] = $events[0]->id;
+	  }
+	}
+	$this->setDefaults( $defaults );
+
+	$this->assign( 'mer_participant', $this->main_participant );
+	$this->assign( 'events_by_slot', $this->events_by_slot );
+	$this->assign( 'slot_fields', $slot_fields );
+	$this->assign( 'session_options', json_encode($session_options) );
+
+	$buttons = array( );
+	$buttons[] = array(
+	  'name' => ts('<< Go Back'),
+	  'spacing' => '&nbsp;&nbsp;&nbsp;&nbsp',
+	  'type' => 'back',
+	);
+	$buttons[] = array(
+	   'isDefault' => true,
+	   'name' => ts('Continue >>'),
+	   'spacing' => '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;',
+	   'type' => 'next',
+	 );
+	$this->addButtons( $buttons );
+  }
+
+  function postProcess( )
+  {
+	$params = $this->controller->exportValues( $this->_name );
+
+	$main_event_in_cart = $this->cart->get_event_in_cart_by_event_id( $this->conference_event->id );
+
+	foreach ( $this->cart->events_in_carts as $event_in_cart ) {
+	    if ($event_in_cart->event->parent_event_id == $this->conference_event->id) {
+		$event_in_cart->remove_participant_by_contact_id($this->contact_id);
+                if (empty( $event_in_cart->participants )) {
+                    $this->cart->remove_event_in_cart( $event_in_cart->id );
+                }
+	    }
+	}
+
+	$slot_index = -1;
+	foreach ( $this->events_by_slot as $slot_name => $events ) {
+	  $slot_index++;
+	  $field_name = "slot_$slot_index";
+	  $session_event_id = CRM_Utils_Array::value($field_name, $params, null);
+          if (!$session_event_id) {
+            continue;
+          }
+          $event_in_cart = $this->cart->add_event( $session_event_id );
+
+	  $values = array( );
+	  CRM_Core_DAO::storeValues( $this->main_participant, $values );
+	  $values['id'] = null;
+	  $values['event_id'] = $event_in_cart->event_id;
+	  require_once 'CRM/Event/Cart/BAO/MerParticipant.php';
+	  $participant = CRM_Event_Cart_BAO_MerParticipant::create( $values );
+          $participant->save();
+          $event_in_cart->add_participant( $participant );
+	}
+	$this->cart->save( );
+  }
+}
diff --git a/CRM/Event/Cart/Form/Checkout/ParticipantsAndPrices.php b/CRM/Event/Cart/Form/Checkout/ParticipantsAndPrices.php
new file mode 100644
index 0000000..b1f42a5
--- /dev/null
+++ b/CRM/Event/Cart/Form/Checkout/ParticipantsAndPrices.php
@@ -0,0 +1,255 @@
+<?php
+
+require_once 'CRM/Core/Form.php';
+require_once 'CRM/Core/OptionGroup.php';
+require_once 'CRM/Event/Cart/BAO/Cart.php';
+require_once 'CRM/Event/Cart/Form/Cart.php';
+require_once 'CRM/Price/BAO/Set.php';
+      
+class CRM_Event_Cart_Form_Checkout_ParticipantsAndPrices extends CRM_Event_Cart_Form_Cart
+{
+  public $price_fields_for_event;
+
+  function preProcess()
+  {
+    parent::preProcess();
+
+    $this->cid = CRM_Utils_Request::retrieve( 'cid', 'Positive', $this );
+    if (!isset($this->cid) || $this->cid > 0) {
+      //TODO users with permission can default to another contact
+      $this->cid = self::getContactID();
+    }
+  }
+
+  function buildQuickForm( )
+  {
+    $this->price_fields_for_event = array();
+    require_once('CRM/Event/Cart/Form/MerParticipant.php');
+    foreach ( $this->cart->get_main_event_participants( ) as $participant )
+    {
+      $form = new CRM_Event_Cart_Form_MerParticipant($participant);
+      $form->buildQuickForm($this);
+    }
+    foreach ($this->cart->get_main_events_in_carts() as $event_in_cart)
+    {
+      $this->price_fields_for_event[$event_in_cart->event_id] = $this->build_price_options($event_in_cart->event);
+    }
+    $this->addElement('text', 'discountcode', ts('If you have a discount code, enter it here')); //XXX
+    $this->assign( 'events_in_carts', $this->cart->get_main_events_in_carts() );
+    $this->assign( 'price_fields_for_event', $this->price_fields_for_event );
+    $this->addButtons( 
+      array ( 
+      array ( 'type' => 'upload',
+      'name' => ts('Continue >>'),
+      'spacing' => '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;',
+      'isDefault' => true )
+      )
+    );
+
+    if ($this->cid) {
+      $params = array( 'id' => $this->cid );
+      $contact = CRM_Contact_BAO_Contact::retrieve( $params, $defaults );
+      $contact_values = array();
+      CRM_Core_DAO::storeValues($contact, $contact_values);
+      $this->assign( 'contact', $contact_values );
+    }
+  }
+
+  static function primary_email_from_contact( $contact )
+  {
+	foreach ( $contact->email as $email ) {
+	  if ( $email['is_primary'] ) {
+		return $email['email'];
+	  }
+	}
+
+	return null;
+  }
+
+  function build_price_options($event)
+  {
+    $price_fields_for_event = array();
+    $base_field_name = "event_{$event->id}_amount";
+    $price_set_id = CRM_Price_BAO_Set::getFor( 'civicrm_event', $event->id );
+    if ( $price_set_id === false && $event->is_monetary) {
+      require_once 'CRM/Utils/Money.php';
+      //$fee_data = array();
+      CRM_Core_OptionGroup::getAssoc( "civicrm_event.amount.{$event->id}", $fee_data, true );
+      $choices = array();
+      foreach ( $fee_data as $fee ) {
+        if ( is_array( $fee ) ) {
+          $choices[] = $this->createElement( 'radio', null, '', CRM_Utils_Money::format( $fee['value']) . ' ' . $fee['label'], $fee['amount_id'] );
+        }
+      }
+      $this->addGroup( $choices, $base_field_name, $event->fee_label);
+      $this->addRule($base_field_name, ts("Select at least one option from Price Levels"), 'required');
+      $price_fields_for_event[] = $base_field_name;
+    } elseif ($price_set_id) {
+      $price_sets = CRM_Price_BAO_Set::getSetDetail( $price_set_id, true, true );
+      $price_set = $price_sets[$price_set_id];
+      $index = -1;
+      foreach ( $price_set['fields'] as $field ) {
+        $index++;
+        $field_name = "event_{$event->id}_price_{$field['id']}";
+        CRM_Price_BAO_Field::addQuickFormElement( $this, $field_name, $field['id'], false );
+        $price_fields_for_event[] = $field_name;
+      }
+    }
+    return $price_fields_for_event;
+  }
+
+  function validate()
+  {
+    parent::validate();
+    if ($this->_errors)
+        return false;
+    $this->cart->load_associations( );
+    $fields = $this->_submitValues;
+
+    foreach ( $this->cart->get_main_events_in_carts( ) as $event_in_cart )
+	{
+      $price_set_id = CRM_Event_BAO_Event::usesPriceSet( $event_in_cart->event_id );
+      if ( $price_set_id ) {
+        $priceField = new CRM_Price_DAO_Field( );
+        $priceField->price_set_id = $price_set_id;
+        $priceField->find( );
+        
+        $check = array( );
+        
+        while ( $priceField->fetch( ) ) {
+          if ( ! empty( $fields["event_{$event_in_cart->event_id}_price_{$priceField->id}"] ) ) {
+            $check[] = $priceField->id; 
+          }
+        }
+        
+        //XXX
+        if ( empty( $check ) ) {
+          $this->_errors['_qf_default'] = ts( "Select at least one option from Price Levels." );
+        }
+
+        $lineItem = array( );
+        if ( is_array( $this->_values['fee']['fields'] ) ) {
+          CRM_Price_BAO_Set::processAmount( $this->_values['fee']['fields'], $fields, $lineItem );
+          //XXX total...
+          if ($fields['amount'] < 0) {
+            $this->_errors['_qf_default'] = ts( "Price Levels can not be less than zero. Please select the options accordingly" );
+          }
+        }
+      }
+      
+      foreach ( $event_in_cart->participants as $mer_participant )
+      {
+          $participant_fields = $fields['event'][$event_in_cart->event_id]['participant'][$mer_participant->id];
+          $contact_id = self::find_contact($participant_fields);
+
+          if ($contact_id)
+          {
+            require_once('CRM/Event/BAO/Participant.php');
+            $participant = new CRM_Event_BAO_Participant();
+            $participant->event_id = $event_in_cart->event_id;
+            $participant->contact_id = $contact_id;
+            $statusTypes = CRM_Event_PseudoConstant::participantStatus( null, 'is_counted = 1' );
+            $participant->find();
+            while ($participant->fetch())
+            {
+              if (array_key_exists($participant->status_id, $statusTypes))
+              {
+                $form = $mer_participant->get_form();
+                $this->_errors[$form->html_field_name('email')] = ts("The participant %1 is already registered for %2 (%3).", array(1 => $participant_fields['email'], 2 => $event_in_cart->event->title, 3 => $event_in_cart->event->start_date));
+	      }
+            }
+          }
+      }
+    }
+    return empty( $this->_errors );
+  }
+
+  public function setDefaultValues( )
+  {
+    $this->loadCart();
+
+    $defaults = array();
+    require_once 'CRM/Event/Cart/Form/MerParticipant.php';
+    foreach ( $this->cart->get_main_event_participants() as $participant )
+    {
+        $form = $participant->get_form();
+        if (empty($participant->email)
+          && !CRM_Event_Cart_Form_Cart::is_administrator()
+          && ($participant->get_participant_index() == 1)
+          && ($this->cid != 0))
+        {
+          require_once 'CRM/Contact/BAO/Contact.php';
+          $defaults = array( );
+          $params = array( 'id' => $this->cid );
+          $contact = CRM_Contact_BAO_Contact::retrieve( $params, $defaults );
+          $participant->contact_id = $this->cid;
+          $participant->save();
+          $participant->email = self::primary_email_from_contact( $contact );
+        } elseif ($this->cid == 0
+          && $participant->contact_id == self::getContactID())
+        {
+          $participant->email = null;
+          $participant->contact_id = self::find_or_create_contact( $this->getContactID() );
+    }
+        $defaults += $form->setDefaultValues();
+    }
+    require_once 'CRM/Core/BAO/Address.php';
+    CRM_Core_BAO_Address::fixAllStateSelects($this, $defaults);
+    return $defaults;
+  }
+
+  function postProcess()
+  {
+    if (!array_key_exists('event', $this->_submitValues)) return;
+    foreach ( $this->_submitValues['event'] as $event_id => $participants ) {
+      foreach ($participants['participant'] as $participant_id => $fields) {
+	require_once 'CRM/Contact/BAO/Contact.php';
+        $contact_id = self::find_or_create_contact( $this->getContactID(), $fields );
+
+        $participant = $this->cart->get_event_in_cart_by_event_id($event_id)->get_participant_by_id($participant_id);
+        if ($participant->contact_id && $contact_id != $participant->contact_id)
+        {
+          $defaults = array( );
+          $params = array( 'id' => $participant->contact_id);
+          $temporary_contact = CRM_Contact_BAO_Contact::retrieve( $params, $defaults );
+
+          foreach ($this->cart->get_subparticipants($participant) as $subparticipant) {
+            $subparticipant->contact_id = $contact_id;
+            $subparticipant->save();
+          }
+
+          $participant->contact_id = $contact_id;
+          $participant->save();
+
+          if ($temporary_contact->is_deleted) {
+            #ARGH a permissions check prevents us from using skipUndelete,
+            #so we potentially leave records pointing to this contact for now
+            #CRM_Contact_BAO_Contact::deleteContact($temporary_contact->id);
+            $temporary_contact->delete();
+          }
+        }
+
+        //TODO security check that participant ids are already in this cart
+        $participant_params = array
+        (
+          'id' => $participant_id,
+          'cart_id' => $this->cart->id,
+          'event_id' => $event_id,
+          'contact_id' => $contact_id,
+          //'registered_by_id' => $this->cart->user_id,
+          'email' => $fields['email'],
+        );
+        $participant = new CRM_Event_Cart_BAO_MerParticipant($participant_params);
+        $participant->save();
+        $this->cart->add_participant_to_cart($participant);
+
+        if (array_key_exists('field', $this->_submitValues) && array_key_exists($participant_id, $this->_submitValues['field'])) {
+          $custom_fields = array_merge($participant->get_form()->get_participant_custom_data_fields());
+
+          CRM_Contact_BAO_Contact::createProfileContact($this->_submitValues['field'][$participant_id], $custom_fields, $contact_id);
+        }
+      }
+    }
+    $this->cart->save();
+  }
+}
diff --git a/CRM/Event/Cart/Form/Checkout/Payment.php b/CRM/Event/Cart/Form/Checkout/Payment.php
new file mode 100644
index 0000000..47d8de4
--- /dev/null
+++ b/CRM/Event/Cart/Form/Checkout/Payment.php
@@ -0,0 +1,747 @@
+<?php
+
+require_once 'CRM/Core/Form.php';
+require_once 'CRM/Event/Cart/BAO/Cart.php';
+
+class CRM_Event_Cart_Form_Checkout_Payment extends CRM_Event_Cart_Form_Cart
+{
+  public $all_participants;
+  public $contribution_type_id;
+  public $description;
+  public $line_items;
+  public $_fields = array();
+  public $_paymentProcessor;
+  public $total;
+  public $sub_total;
+  public $payment_required = true;
+  public $payer_contact_id;
+  public $is_pay_later = false;
+  public $pay_later_receipt;
+
+  function registerParticipant( $params, &$participant, $event ) 
+  {
+	require_once 'CRM/Core/Transaction.php';
+	$transaction = new CRM_Core_Transaction( );
+
+	// handle register date CRM-4320
+	$registerDate = date( 'YmdHis' );
+	$participantParams = array(
+	  'id'            => $participant->id,
+	  'event_id'      => $event->id,
+	  'register_date' => $registerDate,
+	  'source'        => CRM_Utils_Array::value('participant_source', $params, $this->description),
+	  //'fee_level'     => $participant->fee_level,
+	  'is_pay_later'  => CRM_Utils_Array::value( 'is_pay_later', $params, 0 ),
+	  'fee_amount'    => CRM_Utils_Array::value('amount', $params, 0),
+          //XXX why is this a ref to participant and not contact?:
+	  //'registered_by_id' => $this->payer_contact_id,
+	  'fee_currency'     => CRM_Utils_Array::value( 'currencyID', $params )
+	);
+
+	$participant_statuses = CRM_Event_PseudoConstant::participantStatus();
+	if ( $participant->must_wait ) {
+	  $participantParams['status_id'] = array_search( 'On waitlist', $participant_statuses );
+          //XXX magic:
+          $this->assign('isOnWaitlist', true);
+	} else if ( $params['is_pay_later'] ) {
+	  $participantParams['status_id'] = array_search( 'Pending from pay later', $participant_statuses );
+	} else {
+          $participantParams['status_id'] = array_search( 'Registered', $participant_statuses );
+        }
+
+	if ( $this->_action & CRM_Core_Action::PREVIEW || CRM_Utils_Array::value( 'mode', $params ) == 'test' ) {
+	  $participantParams['is_test'] = 1;
+	} else {
+	  $participantParams['is_test'] = 0;
+	}
+
+        if (self::is_administrator())
+        {
+          if (CRM_Utils_Array::value('note', $params))
+          {
+            $note_params = array(
+              'participant_id' => $participant->id,
+              'contact_id' => self::getContactID(),
+              'note' => $params['note'],
+            );
+            CRM_Event_BAO_Participant::update_note($note_params);
+          }
+        }
+
+        $participant->copyValues($participantParams);
+        $participant->save();
+
+	if (CRM_Utils_Array::value('contributionID', $params)) {
+	  require_once 'CRM/Event/BAO/ParticipantPayment.php';
+	  $payment_params = array(
+		'participant_id' => $participant->id,
+		'contribution_id' => $params['contributionID'],
+	  );
+	  $ids = array( );
+	  $paymentParticpant = CRM_Event_BAO_ParticipantPayment::create( $payment_params, $ids );
+	}
+
+        $defaults = array();
+        $ids = array( 'contact_id' => $participant->contact_id );
+        $contact = CRM_Contact_BAO_Contact::retrieve( $ids, $defaults );
+        $contact->is_deleted = 0;
+        $contact->save();
+
+	$transaction->commit( );
+
+        $event_values = array();
+        CRM_Core_DAO::storeValues($event, $event_values);
+
+        $location = array();
+        if ( CRM_Utils_Array::value( 'is_show_location', $event_values ) == 1 )
+        {
+            $locationParams = array( 'entity_id'    => $participant->event_id,
+                                     'entity_table' => 'civicrm_event');
+            require_once 'CRM/Core/BAO/Location.php';
+            $location = CRM_Core_BAO_Location::getValues( $locationParams, true );
+            require_once 'CRM/Core/BAO/Address.php';
+            CRM_Core_BAO_Address::fixAddress( $location['address'][1] );
+        }
+
+        require_once 'CRM/Event/Cart/Form/MerParticipant.php';
+        list ($pre_id, $post_id) = CRM_Event_Cart_Form_MerParticipant::get_profile_groups($participant->event_id);
+        $payer_values = array
+        (
+          'email' => '',
+          'name' => '',
+        );
+        if ($this->payer_contact_id) {
+            $payer_contact_details = CRM_Contact_BAO_Contact::getContactDetails( $this->payer_contact_id );
+            $payer_values = array
+            (
+              'email' => $payer_contact_details[1],
+              'name' => $payer_contact_details[0],
+            );
+        }
+        $values = array(
+          'params' => $participantParams,
+          'event' => $event_values,
+          'location' => $location,
+          'custom_pre_id' => $pre_id,
+          'custom_post_id' => $post_id,
+          'payer' => $payer_values,
+        );
+        CRM_Event_BAO_Event::sendMail($participant->contact_id, $values, $participant->id);
+
+	return $participant;
+  }
+
+  function buildPaymentFields( )
+  {
+	$payment_processor_id = null;
+        $can_pay_later = true;
+        $pay_later_text = "";
+        $this->pay_later_receipt = "";
+	foreach ( $this->cart->get_main_events_in_carts() as $event_in_cart ) {
+	  if ( $payment_processor_id == null && $event_in_cart->event->payment_processor_id != null ) {
+		$payment_processor_id = $event_in_cart->event->payment_processor_id;
+		$this->contribution_type_id = $event_in_cart->event->contribution_type_id;
+	  } else {
+		if ( $event_in_cart->event->payment_processor_id != NULL && $event_in_cart->event->payment_processor_id != $payment_processor_id ) {
+		  CRM_Core_Error::statusBounce( ts( 'When registering for multiple events all events must use the same payment processor. ') );
+		}
+	  }
+          if (!$event_in_cart->event->is_pay_later) {
+            $can_pay_later = false;
+          } else {
+            //XXX
+            $pay_later_text = $event_in_cart->event->pay_later_text;
+            $this->pay_later_receipt = $event_in_cart->event->pay_later_receipt;
+          }
+	}
+
+	if ( $payment_processor_id == null ) {
+	  CRM_Core_Error::statusBounce( ts( 'A payment processor must be selected for this event registration page, or the event must be configured to give users the option to pay later (contact the site administrator for assistance).' ) );
+	}
+
+	require_once 'CRM/Core/BAO/PaymentProcessor.php';
+	$this->_paymentProcessor = CRM_Core_BAO_PaymentProcessor::getPayment( $payment_processor_id, $this->_mode );
+	$this->assign( 'paymentProcessor', $this->_paymentProcessor );
+
+	require_once 'CRM/Core/Payment/Form.php';
+	CRM_Core_Payment_Form::setCreditCardFields( $this );
+	CRM_Core_Payment_Form::buildCreditCard( $this );
+
+        if ($can_pay_later)
+        {
+            $this->addElement( 'checkbox', 'is_pay_later', 
+                               $pay_later_text, null, $attributes );
+            $this->assign( 'pay_later_instructions', $this->pay_later_receipt );
+        }
+  }
+
+
+  function buildQuickForm( )
+  {
+	require_once 'CRM/Core/BAO/CustomValueTable.php';
+
+	$this->line_items = array();
+	$this->sub_total = 0;
+	$this->_price_values = $this->getValuesForPage( 'ParticipantsAndPrices' );
+
+	// iterate over each event in cart
+	foreach ($this->cart->get_main_events_in_carts() as $event_in_cart)
+        {
+          $this->process_event_line_item($event_in_cart);
+          foreach ($this->cart->get_events_in_carts_by_main_event_id($event_in_cart->event_id) as $subevent)
+          {
+            $this->process_event_line_item($subevent, 'subevent');
+          }
+        }
+
+        $this->total = $this->sub_total;
+        $this->payment_required = ($this->total > 0);
+	$this->assign( 'payment_required', $this->payment_required );
+	$this->assign( 'line_items', $this->line_items );
+	$this->assign( 'sub_total', $this->sub_total );
+	$this->assign( 'total', $this->total );
+	$buttons = array( );
+	$buttons[] = array(
+	  'name' => ts('<< Go Back'),
+	  'spacing' => '&nbsp;&nbsp;&nbsp;&nbsp',
+	  'type' => 'back',
+	);	
+	$buttons[] = array(
+	  'isDefault' => true,
+	  'name' => ts('Complete Transaction >>'),
+	  'spacing' => '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;',
+	  'type' => 'next',
+	);
+
+        if ($this->total) {
+            $this->add('text', 'billing_contact_email', 'Billing Email','', true );
+            $this->assign('collect_billing_email', true);
+        }
+  	if (self::is_administrator())
+        {
+            $this->add('textarea', 'note', 'Note');
+            $this->add('text', 'source', 'Source', array('size' => 80));
+            $instruments = array();
+            CRM_Core_OptionGroup::getAssoc('payment_instrument', $instruments, true);
+            $options = array();
+            foreach ($instruments as $type)
+            {
+                $options[] = $this->createElement('radio', null, '', $type['label'], $type['value'] );
+            }
+            $this->addGroup($options, 'payment_type', ts("Alternative Payment Type"));
+            $this->add('text', 'check_number', ts('Check No.'), array('size' => 20));
+            $this->addElement('checkbox', 'is_pending', ts('Create a pending registration') );
+
+            $this->assign('administrator', true);
+  	}
+	$this->addButtons( $buttons );
+
+	$this->addFormRule( array( 'CRM_Event_Cart_Form_Checkout_Payment', 'formRule' ), $this );
+
+        if ($this->payment_required) {
+          $this->buildPaymentFields( );
+        }
+  }
+  
+  function process_event_line_item(&$event_in_cart, $class = null)
+  {
+      $cost = 0;
+      $price_set_id = CRM_Price_BAO_Set::getFor( "civicrm_event", $event_in_cart->event_id );
+      $amount_level = null;
+      if ( $price_set_id === false ) {
+            CRM_Core_OptionGroup::getAssoc( "civicrm_event.amount.{$event_in_cart->event_id}", $fee_data, true );
+            $price_set_amount = CRM_Utils_Array::value("event_{$event_in_cart->event_id}_amount", $this->_price_values);
+            $fee_level = CRM_Utils_Array::value($price_set_amount, $fee_data);
+            if ($fee_level) $cost = $fee_data[$price_set_amount]['value'];
+      } else {
+            $event_price_values = array();
+            foreach ( $this->_price_values as $key => $value ) {
+              if ( preg_match( "/event_{$event_in_cart->event_id}_(price.*)/", $key, $matches ) ) {
+                    $event_price_values[$matches[1]] = $value;
+              }
+            }
+            $price_sets = CRM_Price_BAO_Set::getSetDetail( $price_set_id, true );
+            $price_set = $price_sets[$price_set_id];
+            $price_set_amount = array( );
+            CRM_Price_BAO_Set::processAmount( $price_set['fields'], $event_price_values, $price_set_amount );
+            $price_set_index = end(array_keys($event_price_values['amount_priceset_level_radio']));
+            $cost = $event_price_values['amount'];
+            $amount_level = $event_price_values['amount_level'];
+      }
+      
+      // iterate over each participant in event
+      foreach ($event_in_cart->participants as &$participant) {
+            $participant->cost = $cost;
+            $participant->fee_level = $amount_level;
+      }
+
+      $this->add_line_item($event_in_cart, $class);
+  }
+
+  function add_line_item($event_in_cart, $class = null)
+  {
+      $amount = 0;
+      $cost = 0;
+      $not_waiting_participants = array();
+      foreach ($event_in_cart->not_waiting_participants() as $participant)
+      {
+          $amount += $participant->cost;
+          $cost = max($cost, $participant->cost);
+          $not_waiting_participants[] = array(
+            'display_name' => CRM_Contact_BAO_Contact::displayName($participant->contact_id),
+          );
+      }
+      $waiting_participants = array();
+      foreach ($event_in_cart->waiting_participants() as $participant)
+      {
+          $waiting_participants[] = array(
+            'display_name' => CRM_Contact_BAO_Contact::displayName($participant->contact_id),
+          );
+      }
+      $this->line_items[] = array( 
+            'amount' => $amount,
+            'cost' => $cost,
+            'event' => $event_in_cart->event,
+            'participants' => $not_waiting_participants,
+            'num_participants' => count($not_waiting_participants),
+            'num_waiting_participants' => count($waiting_participants),
+            'waiting_participants' => $waiting_participants,
+            'class' => $class,
+      );
+      
+      $this->sub_total += $amount;
+  }
+
+  function getDefaultFrom( )
+  {
+	require_once 'CRM/Core/OptionGroup.php';
+	$values = CRM_Core_OptionGroup::values('from_email_address');
+	return $values[1];
+  }
+
+  function emailReceipt( $events_in_cart, $params )
+  {
+	require_once 'CRM/Contact/BAO/Contact.php';
+	$contact_details = CRM_Contact_BAO_Contact::getContactDetails( $this->payer_contact_id );
+	$state_province = new CRM_Core_DAO_StateProvince();
+	$state_province->id = $params["billing_state_province_id-{$this->_bltID}"];
+	$state_province->find( );
+	$state_province->fetch( );
+	$country = new CRM_Core_DAO_Country();
+	$country->id = $params["billing_country_id-{$this->_bltID}"];
+	$country->find( );
+	$country->fetch( );
+	foreach ( $this->line_items as &$line_item ) {
+	  $location_params = array( 'entity_id' => $line_item['event']->id, 'entity_table' => 'civicrm_event' );
+	  $line_item['location'] = CRM_Core_BAO_Location::getValues( $location_params, true );
+	}
+	$send_template_params = array
+	(
+          'table' => 'civicrm_msg_template',
+	  'contactId' => $this->payer_contact_id,
+	  'from' => $this->getDefaultFrom( ),
+	  'groupName' => 'msg_tpl_workflow_event',
+	  'isTest' => false,
+	  'toEmail' => $contact_details[1],
+	  'toName' => $contact_details[0],
+	  'tplParams' => array
+	  (
+		'billing_name' => "{$params['billing_first_name']} {$params['billing_last_name']}",
+		'billing_city' => $params["billing_city-{$this->_bltID}"],
+		'billing_country' => $country->name,
+		'billing_postal_code' => $params["billing_postal_code-{$this->_bltID}"],
+		'billing_state' => $state_province->abbreviation,
+		'billing_street_address' => $params["billing_street_address-{$this->_bltID}"], 
+		'credit_card_exp_date' => $params['credit_card_exp_date'],
+		'credit_card_type' => $params['credit_card_type'],
+		'credit_card_number' => "************" . substr($params['credit_card_number'], -4, 4),
+		'discounts' => $this->discounts, //XXX cart->get_discounts
+		'email' => $contact_details[1],
+		'events_in_cart' => $events_in_cart,
+		'line_items' => $this->line_items,
+		'name' => $contact_details[0],
+		'transaction_id' => $params['trxn_id'],
+		'transaction_date' => $params['trxn_date'],
+                'is_pay_later' => $this->is_pay_later,
+                'pay_later_receipt' => $this->pay_later_receipt,
+	  ),
+	  'valueName' => 'event_registration_receipt',
+	);
+	$template_params_to_copy = array
+	(
+	  'billing_name',
+	  'billing_city',
+	  'billing_country',
+	  'billing_postal_code',
+	  'billing_state',
+	  'billing_street_address',
+	  'credit_card_exp_date',
+	  'credit_card_type',
+	  'credit_card_number',
+	);
+	foreach ( $template_params_to_copy as $template_param_to_copy ) {
+	  $this->set( $template_param_to_copy, $send_template_params['tplParams'][$template_param_to_copy]);
+	}
+
+        require_once 'CRM/Core/BAO/MessageTemplates.php';
+        CRM_Core_BAO_MessageTemplates::sendTemplate( $send_template_params );
+  }
+
+  static function formRule( $fields, $files, $self ) 
+  {
+	$errors = array( );
+
+	if ($self->payment_required)
+	{
+	  require_once 'CRM/Core/BAO/PaymentProcessor.php';
+	  require_once 'CRM/Core/Payment/Form.php';
+	  require_once 'CRM/Core/Payment.php';
+	  $payment =& CRM_Core_Payment::singleton( $self->_mode, $self->_paymentProcessor, $this );
+	  $error = $payment->checkConfig( $self->_mode );
+	  if ( $error ) {
+		$errors['_qf_default'] = $error;
+	  }
+
+	  foreach ( $self->_fields as $name => $field ) {
+		if ( $field['is_required'] && CRM_Utils_System::isNull( CRM_Utils_Array::value( $name, $fields ) ) ) {
+		  $errors[$name] = ts( '%1 is a required field.', array( 1 => $field['title'] ) );
+		}
+	  }
+
+	  require_once 'CRM/Utils/Rule.php';
+
+	  if ( CRM_Utils_Array::value( 'credit_card_type', $fields ) ) {
+		if ( CRM_Utils_Array::value( 'credit_card_number', $fields ) &&
+		  ! CRM_Utils_Rule::creditCardNumber( $fields['credit_card_number'], $fields['credit_card_type'] ) ) {
+			$errors['credit_card_number'] = ts( "Please enter a valid Credit Card Number" );
+		}
+
+		if ( CRM_Utils_Array::value( 'cvv2', $fields ) &&
+		  ! CRM_Utils_Rule::cvv( $fields['cvv2'], $fields['credit_card_type'] ) ) {
+			$errors['cvv2'] =  ts( "Please enter a valid Credit Card Verification Number" );
+		}
+	  }
+	}
+
+	return empty( $errors ) ? true : $errors;
+  }
+
+  function validate()
+  {
+    if ($this->is_pay_later) {
+      $this->_fields['credit_card_number']['is_required'] = false;
+      $this->_fields['cvv2']['is_required'] = false;
+      $this->_fields['credit_card_exp_date']['is_required'] = false;
+      $this->_fields['credit_card_type']['is_required'] = false;
+    }
+    return parent::validate();
+  }
+
+  function preProcess()
+  {
+    $params = $this->_submitValues;
+    $this->is_pay_later = CRM_Utils_Array::value('is_pay_later', $params, false);
+
+    parent::preProcess();
+  }
+
+  function postProcess( ) {
+	require_once 'CRM/Contact/BAO/Contact.php';
+	require_once 'CRM/Contribute/BAO/Contribution.php';
+	require_once 'CRM/Contribute/PseudoConstant.php';
+	require_once 'CRM/Core/BAO/CustomValueTable.php';
+	require_once 'CRM/Core/Config.php';
+	require_once 'CRM/Core/Transaction.php';
+	require_once 'CRM/Core/BAO/FinancialTrxn.php';
+	require_once 'CRM/Event/PseudoConstant.php';
+	require_once 'CRM/Utils/Rule.php';
+
+	$transaction = new CRM_Core_Transaction( );
+	$trxn = null;
+	$params = $this->_submitValues;
+
+        if (array_key_exists('billing_contact_email', $params))
+        {
+          $this->payer_contact_id = self::find_or_create_contact( $this->getContactID(), array(
+            'email' => $params['billing_contact_email'],
+            'first_name' => $params['billing_first_name'],
+            'last_name' => $params['billing_last_name'],
+            'is_deleted' => false,
+          ));
+
+          $ctype = CRM_Core_DAO::getFieldValue( 'CRM_Contact_DAO_Contact',
+                                                $this->payer_contact_id,
+                                                'contact_type' );
+          $billing_fields = array
+          (
+              "billing_first_name" => 1,
+              "billing_middle_name" => 1,
+              "billing_last_name" => 1,
+              "billing_street_address-{$this->_bltID}" => 1,
+              "billing_city-{$this->_bltID}" => 1,
+              "billing_state_province_id-{$this->_bltID}" => 1,
+              "billing_postal_code-{$this->_bltID}" => 1,
+              "billing_country_id-{$this->_bltID}" => 1,
+              "address_name-{$this->_bltID}" => 1,
+              "email-{$this->_bltID}" => 1,
+          );
+
+          $params["address_name-{$this->_bltID}"] =
+              CRM_Utils_Array::value( 'billing_first_name', $params ) . ' ' .
+              CRM_Utils_Array::value( 'billing_middle_name', $params ) . ' ' .
+              CRM_Utils_Array::value( 'billing_last_name', $params );
+ 
+          $params["email-{$this->_bltID}"] = $params['billing_contact_email'];
+          CRM_Contact_BAO_Contact::createProfileContact(
+              $params,
+              $billing_fields,
+              $this->payer_contact_id,
+              null,
+              null,
+              $ctype,
+              true
+          );
+        }
+
+        $params['now'] = date( 'YmdHis' );
+	$params['invoiceID'] = md5(uniqid(rand(), true));
+        $params['amount'] = $this->total;
+        $params['contribution_type_id'] = $this->contribution_type_id;
+	if ($this->payment_required && !$this->is_pay_later)
+	{
+          $trxn = $this->make_payment($params);
+          $params['trxn_id'] = $trxn->trxn_id;
+          $params['trxn_date'] = $trxn->trxn_date;
+          $params['currencyID'] = $trxn->currency;
+          $params['financial_trxn_id'] = $trxn->id;
+        }
+	if ($trxn == null) {
+	  $params['trxn_id'] = strftime("VR%Y%m%d%H%M%S");
+          $params['trxn_date'] = $params['now'];
+	}
+	$this->cart->completed = true;
+	$this->cart->save( );
+	$this->set( 'last_event_cart_id', $this->cart->id );
+
+        if ($this->payment_required)
+        {
+          $this->emailReceipt( $this->cart->events_in_carts, $params );
+        }
+	$contribution_statuses = CRM_Contribute_PseudoConstant::contributionStatus( null, 'name' );
+        if ($this->is_pay_later) {
+            $params['contribution_status_id'] = array_search('Pending', $contribution_statuses);
+            $params['payment_instrument_id'] = null;
+        } else {
+            $params['contribution_status_id'] = array_search('Completed', $contribution_statuses);
+            $params['payment_instrument_id'] = CRM_Core_OptionGroup::getValue( 'payment_instrument', 'Credit Card', 'name' );
+        }
+        // n.b. we need to process the subparticipants before main event
+        // participants so that session attendance can be included in the email
+        $main_participants = $this->cart->get_main_event_participants();
+        $this->all_participants = array();
+        foreach ($main_participants as $main_participant) {
+          $this->all_participants = array_merge($this->all_participants, $this->cart->get_subparticipants($main_participant));
+        }
+        $this->all_participants = array_merge($this->all_participants, $main_participants);
+
+	$this->sub_trxn_index = 0;
+        foreach ( $this->all_participants as $mer_participant )
+        {
+          $event_in_cart = $this->cart->get_event_in_cart_by_event_id($mer_participant->event_id);
+
+          $this->sub_trxn_index += 1;
+
+          if ($mer_participant->must_wait) {
+              $this->registerParticipant( $params, $mer_participant, $event_in_cart->event );
+          } else {
+            $params['amount'] = $mer_participant->cost - $mer_participant->discount_amount; //XXX move
+
+            if ($event_in_cart->event->contribution_type_id && $mer_participant->cost) {
+              $params['contribution_type_id'] = $event_in_cart->event->contribution_type_id;
+              $params['participant_contact_id'] = $mer_participant->contact_id;
+              $this->record_contribution($mer_participant, $params, $event_in_cart->event );
+            }
+            $this->registerParticipant( $params, $mer_participant, $event_in_cart->event );
+          }
+        }
+	$this->saveDataToSession( $params['trxn_id'] );
+	$transaction->commit();
+  }
+
+
+  function make_payment(&$params)
+  {
+          $config = CRM_Core_Config::singleton();
+          if ( isset( $params["billing_state_province_id-{$this->_bltID}"] ) && $params["billing_state_province_id-{$this->_bltID}"] ) {
+              $params["billing_state_province-{$this->_bltID}"] =
+                  CRM_Core_PseudoConstant::stateProvinceAbbreviation( $params["billing_state_province_id-{$this->_bltID}"] ); 
+          }
+          
+          if ( isset( $params["billing_country_id-{$this->_bltID}"] ) && $params["billing_country_id-{$this->_bltID}"] ) {
+              $params["billing_country-{$this->_bltID}"]        =
+                  CRM_Core_PseudoConstant::countryIsoCode( $params["billing_country_id-{$this->_bltID}"] ); 
+          }
+          $params['ip_address']     = CRM_Utils_System::ipAddress( );
+          $params['currencyID'    ] = $config->defaultCurrency;
+          $params['payment_action'] = 'Sale';
+
+	  $payment =& CRM_Core_Payment::singleton( $this->_mode, $this->_paymentProcessor, $this );
+          CRM_Core_Payment_Form::mapParams( $this->_bltID, $params, $params, true );
+	  $params['month'] = $params['credit_card_exp_date']['M'];
+	  $params['year'] = $params['credit_card_exp_date']['Y'];
+	  $result =& $payment->doDirectPayment( $params );
+	  if ( is_a( $result, 'CRM_Core_Error' ) ) {
+		CRM_Core_Error::displaySessionError( $result );
+		CRM_Utils_System::redirect( CRM_Utils_System::url( 'civicrm/event/cart_checkout', "_qf_Payment_display=1&qfKey={$this->controller->_key}", true, null, false ) );
+		return;
+	  }
+	  $trxnParams = array
+	  (
+            'trxn_date'         => $params['now'],
+            'trxn_type'         => 'Debit',
+            'total_amount'      => $params['amount'],
+            'fee_amount'        => CRM_Utils_Array::value( 'fee_amount', $result ),
+            'net_amount'        => CRM_Utils_Array::value( 'net_amount', $result, $params['amount'] ), 
+            'currency'          => CRM_Utils_Array::value( 'currencyID', $params ),
+            'payment_processor' => $this->_paymentProcessor['payment_processor_type'],
+            'trxn_id'           => $result['trxn_id'],
+      );
+      $trxn = new CRM_Core_DAO_FinancialTrxn();
+      $trxn->copyValues($trxnParams);
+      if (! CRM_Utils_Rule::currencyCode($trxn->currency)) {
+            $config = CRM_Core_Config::singleton();
+            $trxn->currency = $config->defaultCurrency;
+      }
+      $trxn->save();
+
+      return $trxn;
+  }
+
+  function record_contribution(&$mer_participant, &$params, $event)
+  {
+      if (self::is_administrator() && CRM_Utils_Array::value('payment_type', $params))
+      {
+        $params['payment_instrument_id'] = $params['payment_type'];
+      }
+
+      if ($this->payer_contact_id) {
+        $payer = $this->payer_contact_id;
+      } else if (self::getContactID()) {
+        $payer = self::getContactID();
+      } else {
+        $payer = $params['participant_contact_id'];
+      }
+
+      $contribParams = array
+      (
+        'contact_id' => $payer,
+        'contribution_type_id' => $params['contribution_type_id'],
+        'receive_date' => $params['now'],
+        'total_amount' => $params['amount'],
+        'amount_level' => $mer_participant->fee_level,
+        'fee_amount' => $mer_participant->cost,
+        'net_amount' => $params['amount'],
+        'invoice_id' => "{$params['invoiceID']}-{$this->sub_trxn_index}",
+        'trxn_id' => "{$params['trxn_id']}-{$this->sub_trxn_index}",
+        'currency' => CRM_Utils_Array::value('currencyID', $params),
+        'source' => $event->title,
+        'is_pay_later' => CRM_Utils_Array::value('is_pay_later', $params, 0),
+        'contribution_status_id' => $params['contribution_status_id'],
+        'payment_instrument_id' => $params['payment_instrument_id'],
+        'check_number' => CRM_Utils_Array::value('check_number', $params),
+      );
+
+      $contribution =& CRM_Contribute_BAO_Contribution::add( $contribParams, $ids );
+      if ( is_a( $contribution, 'CRM_Core_Error' ) ) {
+        CRM_Core_Error::fatal( ts("There was an error creating a contribution record for your event. Please report this error to the webmaster. Details: %1\n", array(1 => $contribution->getMessages($contribution))) );
+      }
+      $mer_participant->contribution_id = $contribution->id;
+      $params['contributionID'] = $contribution->id;
+      $params['receive_date'] =  $contribution->receive_date;
+      if ( CRM_Utils_Array::value('financial_trxn_id', $params) ) {
+        $entity_financial_trxn_params = array(
+              'entity_table'      => "civicrm_contribution",
+              'entity_id'         => $contribution->id,
+              'financial_trxn_id' => $params['financial_trxn_id'],
+              'amount'            => $params['amount'],
+              'currency'          => CRM_Utils_Array::value('currencyID', $params),
+        );
+        $entity_trxn =& new CRM_Core_DAO_EntityFinancialTrxn();
+        $entity_trxn->copyValues($entity_financial_trxn_params);
+        $entity_trxn->save();
+      }
+  }
+
+  function saveDataToSession( $trxn_id )
+  {
+	$session_line_items = array( );
+	foreach ( $this->line_items as $line_item ) {
+	  $session_line_item = array();
+	  $session_line_item['amount'] = $line_item['amount'];
+	  $session_line_item['cost'] = $line_item['cost'];
+	  $session_line_item['event_id'] = $line_item['event']->id;
+	  $session_line_items[] = $session_line_item;
+	}
+	$this->set( 'line_items', $session_line_items );
+	$this->set( 'payment_required', $this->payment_required );
+	$this->set( 'is_pay_later', $this->is_pay_later );
+	$this->set( 'pay_later_receipt', $this->pay_later_receipt );
+	$this->set( 'trxn_id', $trxn_id );
+	$this->set( 'total', $this->total );
+  }
+
+  function setDefaultValues()
+  {
+	require_once 'CRM/Core/Config.php';
+	require_once 'CRM/Contact/BAO/Contact.php';
+	require_once 'CRM/Event/Cart/BAO/MerParticipant.php';
+
+	$defaults = parent::setDefaultValues();
+
+        $config = CRM_Core_Config::singleton();
+        $default_country = new CRM_Core_DAO_Country();
+        $default_country->iso_code = $config->defaultContactCountry();
+        $default_country->find(true);
+        $defaults["billing_country_id-{$this->_bltID}"] = $default_country->id;
+
+        if (self::getContactID() && !self::is_administrator())
+        {
+          $params = array( 'id' => self::getContactID() );
+          $contact = CRM_Contact_BAO_Contact::retrieve( $params, $defaults );
+
+          foreach ( $contact->email as $email ) {
+            if ( $email['is_billing'] ) {
+              $defaults["billing_contact_email"] = $email['email'];
+            }
+          }
+          if (!CRM_Utils_Array::value('billing_contact_email', $defaults)) {
+            foreach ( $contact->email as $email ) {
+              if ( $email['is_primary'] ) {
+                $defaults["billing_contact_email"] = $email['email'];
+              }
+            }
+          }
+
+          $defaults["billing_first_name"] = $contact->first_name;
+          $defaults["billing_middle_name"] = $contact->middle_name;
+          $defaults["billing_last_name"] = $contact->last_name;
+
+          $billing_address = CRM_Event_Cart_BAO_MerParticipant::billing_address_from_contact($contact);
+
+          if ($billing_address != null) {
+              $defaults["billing_street_address-{$this->_bltID}"] = $billing_address['street_address'];
+              $defaults["billing_city-{$this->_bltID}"] = $billing_address['city'];
+              $defaults["billing_postal_code-{$this->_bltID}"] = $billing_address['postal_code'];
+              $defaults["billing_state_province_id-{$this->_bltID}"] = $billing_address['state_province_id'];
+              $defaults["billing_country_id-{$this->_bltID}"] = $billing_address['country_id'];
+          }
+        }
+        
+        $defaults["source"] = $this->description;
+
+        require_once 'CRM/Core/BAO/Address.php';
+        CRM_Core_BAO_Address::fixAllStateSelects($this, $defaults);
+
+	return $defaults;
+  }
+}
diff --git a/CRM/Event/Cart/Form/Checkout/ThankYou.php b/CRM/Event/Cart/Form/Checkout/ThankYou.php
new file mode 100644
index 0000000..2bd3c07
--- /dev/null
+++ b/CRM/Event/Cart/Form/Checkout/ThankYou.php
@@ -0,0 +1,94 @@
+<?php
+
+require_once 'CRM/Core/DAO/FinancialTrxn.php';
+require_once 'CRM/Contact/BAO/Contact.php';
+require_once 'CRM/Event/BAO/Participant.php';
+
+class CRM_Event_Cart_Form_Checkout_ThankYou extends CRM_Event_Cart_Form_Cart
+{
+  public $line_items = null;
+  public $sub_total = 0;
+
+  function buildLineItems( )
+  {
+	foreach ( $this->cart->events_in_carts as $event_in_cart ) {
+	  $event_in_cart->load_location( );
+	}
+	$line_items = $this->get( 'line_items' );
+	foreach ( $line_items as $line_item )
+        {
+          $event_in_cart = $this->cart->get_event_in_cart_by_event_id($line_item['event_id']);
+
+          $not_waiting_participants = array();
+          foreach ($event_in_cart->not_waiting_participants() as $participant)
+          {
+            $not_waiting_participants[] = array(
+              'display_name' => CRM_Contact_BAO_Contact::displayName($participant->contact_id),
+            );
+          }
+          $waiting_participants = array();
+          foreach ($event_in_cart->waiting_participants() as $participant)
+          {
+            $waiting_participants[] = array(
+              'display_name' => CRM_Contact_BAO_Contact::displayName($participant->contact_id),
+            );
+          }
+
+          $line_item['event'] = $event_in_cart->event;
+          $line_item['num_participants'] = count($not_waiting_participants);
+          $line_item['participants'] = $not_waiting_participants;
+          $line_item['num_waiting_participants'] = count($waiting_participants);
+          $line_item['waiting_participants'] = $waiting_participants;
+          $line_item['location'] = $event_in_cart->location;
+          $line_item['class'] = $event_in_cart->event->parent_event_id ? 'subevent' : null;
+
+	  $this->sub_total += $line_item['amount'];
+	  $this->line_items[] = $line_item;
+	}
+	$this->assign( 'line_items', $this->line_items );
+  }
+
+  function buildQuickForm( )
+  {
+    $defaults = array( );
+    $ids = array( );
+	$transaction = new CRM_Core_DAO_FinancialTrxn( );
+	$transaction->trxn_id = $this->get( 'trxn_id' );
+	$transaction->find( true );
+	$template_params_to_copy = array
+	(
+	  'billing_name',
+	  'billing_city',
+	  'billing_country',
+	  'billing_postal_code',
+	  'billing_state',
+	  'billing_street_address',
+	  'credit_card_exp_date',
+	  'credit_card_type',
+	  'credit_card_number',
+	);
+	foreach ( $template_params_to_copy as $template_param_to_copy ) {
+	  $this->assign( $template_param_to_copy, $this->get( $template_param_to_copy ) );
+	}
+	$this->buildLineItems( );
+	$this->assign( 'discounts', $this->get( 'discounts' ) );
+	$this->assign( 'events_in_carts', $this->cart->events_in_carts );
+	$this->assign( 'transaction', $transaction );
+	$this->assign( 'payment_required', $this->get( 'payment_required' ) );
+	$this->assign( 'is_pay_later', $this->get( 'is_pay_later' ) );
+	$this->assign( 'pay_later_receipt', $this->get( 'pay_later_receipt' ) );
+	$this->assign( 'sub_total', $this->sub_total );
+	$this->assign( 'total', $this->get( 'total' ) );
+	$this->assign( 'trxn_id', $this->get( 'trxn_id' ) );
+        // XXX Configure yourself
+	//$this->assign( 'site_name', "" );
+	//$this->assign( 'site_contact', "" );
+  }
+
+  function preProcess( )
+  {
+    $this->event_cart_id = $this->get( 'last_event_cart_id' );
+    $this->loadCart( );
+    //$this->loadParticipants( );
+  }
+}
diff --git a/CRM/Event/Cart/Form/MerParticipant.php b/CRM/Event/Cart/Form/MerParticipant.php
new file mode 100644
index 0000000..3419d83
--- /dev/null
+++ b/CRM/Event/Cart/Form/MerParticipant.php
@@ -0,0 +1,119 @@
+<?php
+class CRM_Event_Cart_Form_MerParticipant extends CRM_Core_Form
+{
+  public $participant = null;
+
+  function __construct($participant)
+  {
+    parent::__construct();
+    //XXX
+    $this->participant = $participant;
+  }
+
+  function buildQuickForm(&$form)
+  {
+    $textarea_size = array('size' => 30, 'maxlength' => 60);
+    $form->add('text', $this->email_field_name(), ts('Email Address'), $textarea_size, true);
+
+    list(
+      $custom_fields_pre,
+      $custom_fields_post
+    ) = $this->get_participant_custom_data_fields($this->participant->event_id);
+
+    require_once('CRM/Profile/Form.php');
+    foreach ($custom_fields_pre as $key => $field)
+    {
+      CRM_Core_BAO_UFGroup::buildProfile( $form, $field, CRM_Profile_Form::MODE_CREATE, $this->participant->id);
+    }
+    foreach ($custom_fields_post as $key => $field)
+    {
+      CRM_Core_BAO_UFGroup::buildProfile( $form, $field, CRM_Profile_Form::MODE_CREATE, $this->participant->id);
+    }
+    $custom = CRM_Utils_Array::value('custom', $form->getTemplate()->_tpl_vars, array());
+    $form->assign('custom', array_merge($custom, array(
+      $this->html_field_name('customPre') => $custom_fields_pre,
+      $this->html_field_name('customPost') => $custom_fields_post,
+
+      $this->html_field_name('number') => $this->name(),
+    )));
+  }
+
+  function get_profile_groups($event_id)
+  {
+    require_once 'CRM/Core/BAO/UFJoin.php'; 
+    $ufJoinParams = array( 'entity_table' => 'civicrm_event',   
+                           'module'       => 'CiviEvent',
+                           'entity_id'    => $event_id );
+    $group_ids = CRM_Core_BAO_UFJoin::getUFGroupIds( $ufJoinParams ); 
+    if (!$group_ids[0] && !$group_ids[1])
+    {
+      require_once 'CRM/Core/Config.php';
+      $config = CRM_Core_Config::singleton();
+      return array(null, $config->default_participant_profile);
+    }
+    $garbage = array();
+    foreach ($group_ids as $el) {
+      if (is_array($el)) $garbage[] = array_pop($el);
+      else $garbage[] = $el;
+    }
+    return $garbage;
+  }
+
+  function get_participant_custom_data_fields()
+  {
+    list( $custom_pre_id, $custom_post_id ) = self::get_profile_groups($this->participant->event_id);
+
+    require_once 'CRM/Core/BAO/UFGroup.php'; 
+    $pre_fields = $post_fields = array();
+    if ( $custom_pre_id && CRM_Core_BAO_UFGroup::filterUFGroups($custom_pre_id, $this->participant->contact_id)  ) {
+      $pre_fields = CRM_Core_BAO_UFGroup::getFields($custom_pre_id, false, CRM_Core_Action::ADD);
+    }
+    if ( $custom_post_id && CRM_Core_BAO_UFGroup::filterUFGroups($custom_post_id, $this->participant->contact_id)  ) {
+      $post_fields = CRM_Core_BAO_UFGroup::getFields($custom_post_id, false, CRM_Core_Action::ADD);
+    }
+
+    return array($pre_fields, $post_fields);
+  }
+
+  function email_field_name( )
+  {
+	return $this->html_field_name( "email" );
+  }
+
+  static function full_field_name( $event_id, $participant_id, $field_name )
+  {
+        return "event[$event_id][participant][$participant_id][$field_name]";
+  }
+
+  function html_field_name( $field_name )
+  {
+	return self::full_field_name( $this->participant->event_id, $this->participant->id, $field_name );
+  }
+
+  function name( )
+  {
+	return "Participant {$this->participant->get_participant_index()}";
+  }
+
+  //XXX poor name
+  static public function get_form($participant)
+  {
+    return new CRM_Event_Cart_Form_MerParticipant($participant);
+  }
+
+  function setDefaultValues()
+  {
+    $defaults = array(
+      $this->html_field_name('email') => $this->participant->email,
+    );
+    list($custom_fields_pre, $custom_fields_post) = $this->get_participant_custom_data_fields($this->participant->event_id);
+    $all_fields = $custom_fields_pre + $custom_fields_post;
+    require_once 'CRM/Core/BAO/UFGroup.php';
+    $flat = array();
+    CRM_Core_BAO_UFGroup::setProfileDefaults( $this->participant->contact_id, $all_fields, $flat );
+    foreach ($flat as $name => $field) {
+      $defaults["field[{$this->participant->id}][{$name}]"] = $field;
+    }
+    return $defaults;
+  }
+}
diff --git a/CRM/Event/Cart/Page/AddToCart.php b/CRM/Event/Cart/Page/AddToCart.php
new file mode 100644
index 0000000..093901c
--- /dev/null
+++ b/CRM/Event/Cart/Page/AddToCart.php
@@ -0,0 +1,31 @@
+<?php
+
+require_once 'CRM/Core/Page.php';
+
+class CRM_Event_Cart_Page_AddToCart extends CRM_Core_Page {
+  function run( ) {
+    require_once 'CRM/Core/Transaction.php';
+    $transaction = new CRM_Core_Transaction();
+
+    $this->_id = CRM_Utils_Request::retrieve( 'id', 'Positive', $this, true );
+    if ( !CRM_Core_Permission::check( 'register for events' ) ) {
+      CRM_Core_Error::fatal( ts( 'You do not have permission to register for this event' ) );
+    }
+    require_once 'CRM/Event/BAO/Event.php';
+    if ( ! CRM_Core_Permission::event( CRM_Core_Permission::VIEW, $this->_id ) ) { 
+      CRM_Core_Error::fatal( ts( 'You cannot register for an event you do not have permission to view' ) ); 
+    }
+     
+    require_once 'CRM/Event/Cart/BAO/Cart.php';
+    $cart = CRM_Event_Cart_BAO_Cart::find_or_create_for_current_session( );
+    $event_in_cart = $cart->add_event($this->_id);
+
+    drupal_set_message( ts("<b>%1</b> has been added to your cart. <a href='/civicrm/event/view_cart'>View your cart.</a>", array(1 => $event_in_cart->event->title) ) );
+
+    $transaction->commit();
+
+    return CRM_Utils_System::redirect( $_SERVER['HTTP_REFERER'] );
+  }
+}
+
+?>
diff --git a/CRM/Event/Cart/Page/CheckoutAJAX.php b/CRM/Event/Cart/Page/CheckoutAJAX.php
new file mode 100644
index 0000000..9a6c7d4
--- /dev/null
+++ b/CRM/Event/Cart/Page/CheckoutAJAX.php
@@ -0,0 +1,59 @@
+<?php
+
+class CRM_Event_Cart_Page_CheckoutAJAX
+{
+  function add_participant_to_cart( )
+  {
+    require 'CRM/Core/Transaction.php';
+    $transaction = new CRM_Core_Transaction();
+    $cart_id = $_GET['cart_id'];
+    $event_id = $_GET['event_id'];
+
+    require_once 'CRM/Event/Cart/BAO/Cart.php';
+    $cart = CRM_Event_Cart_BAO_Cart::find_by_id($_GET['cart_id']);
+
+    //XXX security
+	require_once 'CRM/Event/Cart/BAO/MerParticipant.php';
+    require_once 'CRM/Event/Cart/Form/Cart.php';
+    $participant = CRM_Event_Cart_BAO_MerParticipant::create( array(
+        'cart_id' => $cart->id,
+		'contact_id' => CRM_Event_Cart_Form_Cart::find_or_create_contact(),
+	'event_id' => $event_id,
+    ) );
+    $participant->save( );
+
+    require_once 'CRM/Event/Cart/Form/MerParticipant.php';
+    require_once 'CRM/Core/Form.php';
+    $form = new CRM_Core_Form();
+    $pform = new CRM_Event_Cart_Form_MerParticipant($participant);
+    $pform->buildQuickForm($form);
+
+    $renderer = $form->getRenderer();
+
+    $config = CRM_Core_Config::singleton();
+    $templateDir = $config->templateDir;
+    if ( is_array( $templateDir ) ) {
+        $templateDir = array_pop( $templateDir );
+    }
+    $requiredTemplate = file_get_contents( $templateDir . '/CRM/Form/label.tpl' );
+    $renderer->setRequiredTemplate( $requiredTemplate );
+
+    $form->accept($renderer);
+    $template = CRM_Core_Smarty::singleton ();
+    $template->assign( 'form', $renderer->toArray() );
+    $template->assign( 'participant', $participant );
+    $output = $template->fetch( "CRM/Event/Cart/Form/Checkout/Participant.tpl" );
+    $transaction->commit();
+    echo $output;
+    CRM_Utils_System::civiExit( );
+  }
+
+  function remove_participant_from_cart( )
+  {
+    require_once 'CRM/Event/Cart/BAO/MerParticipant.php';
+    $participant = CRM_Event_Cart_BAO_MerParticipant::get_by_id($_GET['id']);
+    $participant->delete();
+
+    CRM_Utils_System::civiExit( );
+  }
+}
diff --git a/CRM/Event/Cart/Page/RemoveFromCart.php b/CRM/Event/Cart/Page/RemoveFromCart.php
new file mode 100644
index 0000000..f53e391
--- /dev/null
+++ b/CRM/Event/Cart/Page/RemoveFromCart.php
@@ -0,0 +1,22 @@
+<?php
+
+require_once 'CRM/Core/Page.php';
+
+class CRM_Event_Cart_Page_RemoveFromCart extends CRM_Core_Page {
+  function run( ) {
+    require_once('CRM/Core/Transaction.php');
+    $transaction = new CRM_Core_Transaction();
+    $this->_id = CRM_Utils_Request::retrieve( 'id', 'Positive', $this, true );
+    require_once 'CRM/Event/Cart/BAO/Cart.php';
+    $cart = CRM_Event_Cart_BAO_Cart::find_or_create_for_current_session( );
+    $cart->load_associations( );
+    $event_in_cart = $cart->get_event_in_cart_by_event_id($this->_id);
+    $removed_event = $cart->remove_event_in_cart($event_in_cart->id);
+    $removed_event_title = $removed_event->event->title;
+    CRM_Core_Session::setStatus( ts("<b>%1</b> has been removed from your cart.", array( 1 => $removed_event_title ) ) );
+    $transaction->commit();
+    return CRM_Utils_System::redirect( $_SERVER['HTTP_REFERER'] );
+  }
+}
+
+?>
diff --git a/CRM/Event/Cart/Page/ViewCart.php b/CRM/Event/Cart/Page/ViewCart.php
new file mode 100644
index 0000000..fece19e
--- /dev/null
+++ b/CRM/Event/Cart/Page/ViewCart.php
@@ -0,0 +1,23 @@
+<?php
+
+require_once 'CRM/Core/Page.php';
+
+class CRM_Event_Cart_Page_ViewCart extends CRM_Core_Page 
+{
+  function run( ) {
+    require_once 'CRM/Core/Transaction.php';
+    $transaction = new CRM_Core_Transaction();
+
+    require_once 'CRM/Event/Cart/BAO/Cart.php';
+    $cart = CRM_Event_Cart_BAO_Cart::find_or_create_for_current_session( );
+    $cart->load_associations( );
+    $this->assign_by_ref( 'events_in_carts', $cart->get_main_events_in_carts() );
+    $this->assign( 'events_count', count($cart->get_main_events_in_carts()) );
+
+    $transaction->commit();
+
+    return parent::run();
+  }
+}
+
+?>
diff --git a/CRM/Event/Cart/StateMachine/Checkout.php b/CRM/Event/Cart/StateMachine/Checkout.php
new file mode 100644
index 0000000..9f3b4bf
--- /dev/null
+++ b/CRM/Event/Cart/StateMachine/Checkout.php
@@ -0,0 +1,43 @@
+<?php
+
+class CRM_Event_Cart_StateMachine_Checkout extends CRM_Core_StateMachine
+{
+  function __construct( $controller, $action = CRM_Core_Action::NONE )
+  {
+    parent::__construct( $controller, $action );
+
+    require_once 'CRM/Event/Cart/BAO/Cart.php';
+    $cart = CRM_Event_Cart_BAO_Cart::find_or_create_for_current_session( );
+    $cart->load_associations();
+    if ( $cart->is_empty() ) {
+      CRM_Core_Error::statusBounce( ts( "You don't have any events in you cart. Please add some events." ), CRM_Utils_System::url( 'civicrm/event' ) );
+    }
+
+    $pages = array( );
+	$is_monetary = false;
+	$is_conference = false;
+	foreach ($cart->events_in_carts as $event_in_cart) {
+	  if ($event_in_cart->event->is_monetary) {
+		$is_monetary = true;
+	  }
+	}
+	$pages["CRM_Event_Cart_Form_Checkout_ParticipantsAndPrices"] = null;
+        foreach ($cart->events_in_carts as $event_in_cart)
+        {
+            if ($event_in_cart->is_parent_event())
+            {
+              foreach ($event_in_cart->participants as $participant)
+              {
+                $pages["CRM_Event_Cart_Form_Checkout_ConferenceEvents_{$event_in_cart->event_id}_{$participant->id}"] = array
+                (
+                  'className' => 'CRM_Event_Cart_Form_Checkout_ConferenceEvents',
+                  'title' => "Select {$event_in_cart->event->title} Events For {$participant->email}",
+                );
+              }
+            }
+        }
+	$pages["CRM_Event_Cart_Form_Checkout_Payment"] = null;
+	$pages["CRM_Event_Cart_Form_Checkout_ThankYou"] = null;
+    $this->addSequentialPages( $pages, $action );
+  }
+}
diff --git a/CRM/Event/DAO/Event.php b/CRM/Event/DAO/Event.php
index c446fad..5c4d735 100644
--- a/CRM/Event/DAO/Event.php
+++ b/CRM/Event/DAO/Event.php
@@ -416,6 +416,18 @@ class CRM_Event_DAO_Event extends CRM_Core_DAO
      */
     public $campaign_id;
     /**
+     * Implicit FK to civicrm_event: parent event
+     *
+     * @var int unsigned
+     */
+    public $parent_event_id;
+    /**
+     * Subevent slot label. Implicit FK to civicrm_option_value where option_group = conference_slot.
+     *
+     * @var int unsigned 
+     */
+    public $slot_label_id;
+    /**
      * class constructor
      *
      * @access public
@@ -811,6 +823,15 @@ class CRM_Event_DAO_Event extends CRM_Core_DAO
                     'type' => CRM_Utils_Type::T_INT,
                     'FKClassName' => 'CRM_Campaign_DAO_Campaign',
                 ) ,
+                'parent_event_id' => array(
+                    'name' => 'parent_event_id',
+                    'type' => CRM_Utils_Type::T_INT,
+                ) ,
+                'slot_label_id' => array(
+                    'name' => 'slot_label_id',
+                    'type' => CRM_Utils_Type::T_INT,
+                    'title' => ts('Subevent Slot Label ID') ,
+                ) ,
             );
         }
         return self::$_fields;
diff --git a/CRM/Event/DAO/Participant.php b/CRM/Event/DAO/Participant.php
index 3b339a8..81a9b86 100644
--- a/CRM/Event/DAO/Participant.php
+++ b/CRM/Event/DAO/Participant.php
@@ -169,6 +169,24 @@ class CRM_Event_DAO_Participant extends CRM_Core_DAO
      */
     public $campaign_id;
     /**
+     * Discount Amount
+     *
+     * @var int unsigned
+     */
+    public $discount_amount;
+    /**
+     * FK to civicrm_event_carts
+     *
+     * @var int unsigned
+     */
+    public $cart_id;
+    /**
+     * On Waiting List
+     *
+     * @var int
+     */
+    public $must_wait;
+    /**
      * class constructor
      *
      * @access public
@@ -194,6 +212,7 @@ class CRM_Event_DAO_Participant extends CRM_Core_DAO
                 'registered_by_id' => 'civicrm_participant:id',
                 'discount_id' => 'civicrm_discount:id',
                 'campaign_id' => 'civicrm_campaign:id',
+                'cart_id' => 'civicrm_event_carts:id',
             );
         }
         return self::$_links;
@@ -372,6 +391,21 @@ class CRM_Event_DAO_Participant extends CRM_Core_DAO
                     'export' => true,
                     'FKClassName' => 'CRM_Campaign_DAO_Campaign',
                 ) ,
+                'discount_amount' => array(
+                    'name' => 'discount_amount',
+                    'type' => CRM_Utils_Type::T_INT,
+                    'title' => ts('Discount Amount') ,
+                ) ,
+                'cart_id' => array(
+                    'name' => 'cart_id',
+                    'type' => CRM_Utils_Type::T_INT,
+                    'FKClassName' => 'CRM_Event_Cart_DAO_Cart',
+                ) ,
+                'must_wait' => array(
+                    'name' => 'must_wait',
+                    'type' => CRM_Utils_Type::T_INT,
+                    'title' => ts('Must Wait') ,
+                ) ,
             );
         }
         return self::$_fields;
diff --git a/CRM/Event/Form/ManageEvent/Conference.php b/CRM/Event/Form/ManageEvent/Conference.php
new file mode 100644
index 0000000..a0b985c
--- /dev/null
+++ b/CRM/Event/Form/ManageEvent/Conference.php
@@ -0,0 +1,137 @@
+<?php
+
+/*
+ +--------------------------------------------------------------------+
+ | CiviCRM version 3.4                                                |
+ +--------------------------------------------------------------------+
+ | Copyright CiviCRM LLC (c) 2004-2011                                |
+ +--------------------------------------------------------------------+
+ | This file is a part of CiviCRM.                                    |
+ |                                                                    |
+ | CiviCRM is free software; you can copy, modify, and distribute it  |
+ | under the terms of the GNU Affero General Public License           |
+ | Version 3, 19 November 2007 and the CiviCRM Licensing Exception.   |
+ |                                                                    |
+ | CiviCRM is distributed in the hope that it will be useful, but     |
+ | WITHOUT ANY WARRANTY; without even the implied warranty of         |
+ | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.               |
+ | See the GNU Affero General Public License for more details.        |
+ |                                                                    |
+ | You should have received a copy of the GNU Affero General Public   |
+ | License and the CiviCRM Licensing Exception along                  |
+ | with this program; if not, contact CiviCRM LLC                     |
+ | at info[AT]civicrm[DOT]org. If you have questions about the        |
+ | GNU Affero General Public License or the licensing of CiviCRM,     |
+ | see the CiviCRM license FAQ at http://civicrm.org/licensing        |
+ +--------------------------------------------------------------------+
+*/
+
+/**
+ *
+ * @package CRM
+ * @copyright CiviCRM LLC (c) 2004-2011
+ * $Id$
+ *
+ */
+
+require_once 'CRM/Event/Form/ManageEvent.php';
+require_once 'CRM/Event/BAO/Event.php';
+require_once 'CRM/Core/OptionGroup.php';
+
+/**
+ * This class generates form components for Conference Slots
+ * 
+ */
+class CRM_Event_Form_ManageEvent_Conference extends CRM_Event_Form_ManageEvent
+{
+    /**
+     * Page action
+     */
+    public $_action;
+
+    /**
+     * This function sets the default values for the form. For edit/view mode
+     * the default values are retrieved from the database
+     *
+     * @access public
+     * @return None
+     */
+    function setDefaultValues( )
+    {  
+        $parentDefaults = parent::setDefaultValues( );
+        
+        $eventId = $this->_id;
+        $params   = array( );
+        $defaults = array( );
+        if ( isset( $eventId ) ) {
+            $params = array( 'id' => $eventId );
+        }
+        
+        CRM_Event_BAO_Event::retrieve( $params, $defaults );
+               
+        if (isset($defaults['parent_event_id']))
+        {
+            $params = array ('id' => $defaults['parent_event_id']);
+            $r_defaults = array();
+            $parent_event = CRM_Event_BAO_Event::retrieve($params, $r_defaults);
+            $defaults['parent_event_name'] = $parent_event->title;
+        }
+
+        $defaults = array_merge( $defaults, $parentDefaults );
+        $defaults['id'] = $eventId;
+
+        return $defaults;
+    }
+    
+    /**
+     * Function to build the form
+     *
+     * @return None
+     * @access public
+     */
+    public function buildQuickForm( ) 
+    {
+        require_once 'CRM/Core/OptionGroup.php';
+        $slots = CRM_Core_OptionGroup::values('conference_slot');
+
+        $this->add('select',
+                   'slot_label_id',
+                   ts('Conference Slot'),
+                   array('' => ts('- select -')) + $slots,
+                   false);
+
+        $this->addElement('text', 'parent_event_name', ts( 'Parent Event' ));
+        $this->addElement('hidden', 'parent_event_id');
+
+        parent::buildQuickForm();
+    }
+    
+    public function postProcess()
+    {
+        $params = array( );
+        $params = $this->exportValues( );
+        
+        if (trim($params['parent_event_name']) === '')
+        {
+            $params['parent_event_id'] = ''; # believe me...
+        }
+        //update events table
+        require_once 'CRM/Event/BAO/Event.php';
+        $params['id'] = $this->_id;
+        CRM_Event_BAO_Event::add( $params );
+
+        parent::endPostProcess( );
+    }
+    
+    /**
+     * Return a descriptive name for the page, used in wizard header
+     *
+     * @return string
+     * @access public
+     */
+    public function getTitle( ) 
+    {
+        return ts('Conference Slots');
+    }
+
+}
diff --git a/CRM/Event/Form/ManageEvent/Location.php b/CRM/Event/Form/ManageEvent/Location.php
index bef395e..c9cbe1f 100644
--- a/CRM/Event/Form/ManageEvent/Location.php
+++ b/CRM/Event/Form/ManageEvent/Location.php
@@ -168,9 +168,8 @@ class CRM_Event_Form_ManageEvent_Location extends CRM_Event_Form_ManageEvent
      */
     static function formRule( $fields ) 
     {
-        $errors = array( );
         // check for state/country mapping
-        CRM_Contact_Form_Edit_Address::formRule($fields, $errors);
+        $errors = CRM_Contact_Form_Edit_Address::formRule($fields);
 
         return empty($errors) ? true : $errors;
     }    
diff --git a/CRM/Event/Form/ManageEvent/TabHeader.php b/CRM/Event/Form/ManageEvent/TabHeader.php
index de5008e..84d19c7 100644
--- a/CRM/Event/Form/ManageEvent/TabHeader.php
+++ b/CRM/Event/Form/ManageEvent/TabHeader.php
@@ -80,6 +80,12 @@ class CRM_Event_Form_ManageEvent_TabHeader {
                                                'active' => false,
                                                'current' => false,
                                                ),
+                      'conference' => array( 'title' => ts( 'Conference Slots' ),
+                                               'link'   => null,
+                                               'valid' => false,
+                                               'active' => false,
+                                               'current' => false,
+                                               ),
                       'friend'       => array( 'title' => ts( 'Tell a Friend' ),
                                                'link'   => null,
                                                'valid' => false,
diff --git a/CRM/Event/Form/Participant.php b/CRM/Event/Form/Participant.php
index e5c38ae..ee6c9c9 100644
--- a/CRM/Event/Form/Participant.php
+++ b/CRM/Event/Form/Participant.php
@@ -1436,6 +1436,7 @@ loadCampaign( {$this->_eID}, {$eventCampaigns} );
             }
           
             $this->assign( 'isAmountzero', 1 );
+            $event = array_merge($event, CRM_Event_BAO_Event::multiple_day_info($params['event_id']));
             $this->assign( 'event' , $event );
             
             $this->assign( 'isShowLocation', $event['is_show_location'] ); 
@@ -1444,7 +1445,9 @@ loadCampaign( {$this->_eID}, {$eventCampaigns} );
                                          'entity_table' => 'civicrm_event');
                 require_once 'CRM/Core/BAO/Location.php';
                 $location = CRM_Core_BAO_Location::getValues( $locationParams, true );
-                $this->assign( 'location', $location );
+                require_once 'CRM/Core/BAO/Address.php';
+                CRM_Core_BAO_Address::fixAddress( $location['address'][1] );
+                $this->assign( 'location' , $location );
             }             
             
             $status = CRM_Event_PseudoConstant::participantStatus();
diff --git a/CRM/Event/Page/EventInfo.php b/CRM/Event/Page/EventInfo.php
index 9eebc0d..d32b3bc 100644
--- a/CRM/Event/Page/EventInfo.php
+++ b/CRM/Event/Page/EventInfo.php
@@ -104,7 +104,7 @@ class CRM_Event_Page_EventInfo extends CRM_Core_Page
 
             // get price set options, - CRM-5209
             if ( $priceSetId = CRM_Price_BAO_Set::getFor( 'civicrm_event', $this->_id ) ) {
-                $setDetails     = CRM_Price_BAO_Set::getSetDetail( $priceSetId );
+                $setDetails     = CRM_Price_BAO_Set::getSetDetail( $priceSetId, true, true );
                 $priceSetFields = $setDetails[$priceSetId]['fields'];
                 if ( is_array( $priceSetFields ) ) {
                     $fieldCnt = 1;                    
@@ -219,30 +219,29 @@ class CRM_Event_Page_EventInfo extends CRM_Core_Page
         $allowRegistration = false;
         if ( CRM_Utils_Array::value( 'is_online_registration', $values['event'] ) ) {
             if ( CRM_Event_BAO_Event::validRegistrationDate( $values['event'], $this->_id ) ) {
+                // we always generate urls for the front end in joomla
+                $action_query = $action === CRM_Core_Action::PREVIEW ? "&action=$action" : '';
+                $url    = CRM_Utils_System::url( 'civicrm/event/register',
+                                                 "id={$this->_id}&reset=1{$action_query}",
+                                                 true, null, true,
+                                                 true );
                 if ( !$eventFullMessage || $hasWaitingList ) {
                     $registerText = ts('Register Now');
                     if ( CRM_Utils_Array::value('registration_link_text', $values['event'] ) ) {
                         $registerText = $values['event']['registration_link_text'];
                     }
+                    if ($config->enable_cart)
+                    {
+                        require_once('CRM/Event/Cart/BAO/EventInCart.php');
+                        $link = CRM_Event_Cart_BAO_EventInCart::get_registration_link($this->_id);
+                        $registerText = $link['label'];
+
+                        $url = CRM_Utils_System::url( $link['path'], $link['query'].$action_query, true, null, true, true);
+                    }
                     //Fixed for CRM-4855
                     $allowRegistration = CRM_Event_BAO_Event::showHideRegistrationLink( $values );
                     
                     $this->assign( 'registerText', $registerText );
-                }
-                
-                // we always generate urls for the front end in joomla
-                if ( $action ==  CRM_Core_Action::PREVIEW ) {
-                    $url    = CRM_Utils_System::url( 'civicrm/event/register',
-                                                     "id={$this->_id}&reset=1&action=preview",
-                                                     true, null, true,
-                                                     true );
-                } else {
-                    $url = CRM_Utils_System::url( 'civicrm/event/register',
-                                                  "id={$this->_id}&reset=1",
-                                                  true, null, true,
-                                                  true );
-                }
-                if ( !$eventFullMessage || $hasWaitingList ) {
                     $this->assign( 'registerURL', $url    );
                 }
             } else if ( CRM_Core_Permission::check( 'register for events' ) ) {
diff --git a/CRM/Event/Page/ICalendar.php b/CRM/Event/Page/ICalendar.php
index ae864db..5930f51 100644
--- a/CRM/Event/Page/ICalendar.php
+++ b/CRM/Event/Page/ICalendar.php
@@ -78,6 +78,9 @@ class CRM_Event_Page_ICalendar extends CRM_Core_Page
         } else if ( $gData ) {
             $calendar = $template->fetch( 'CRM/Core/Calendar/GData.tpl' );
         } else if ( $html ) {
+            if ($config->enable_cart) {
+                $this->assign( 'registration_links', true );
+            }
             return parent::run( );
         } else {
             $calendar = $template->fetch( 'CRM/Core/Calendar/ICal.tpl' );
diff --git a/CRM/Event/xml/Menu/Event.xml b/CRM/Event/xml/Menu/Event.xml
index e77a401..a27bab2 100644
--- a/CRM/Event/xml/Menu/Event.xml
+++ b/CRM/Event/xml/Menu/Event.xml
@@ -58,6 +58,15 @@
      <weight>0</weight>
   </item>
   <item>
+     <path>civicrm/admin/event_settings</path>
+     <title>Configure CiviEvent Settings</title>
+     <page_callback>CRM_Admin_Form_Setting_Event</page_callback>
+     <desc>Configure global event settings.</desc>
+     <access_arguments>access CiviEvent,administer CiviCRM</access_arguments>
+     <adminGroup>CiviEvent</adminGroup>
+     <weight>360</weight>
+  </item>
+  <item>
      <path>civicrm/admin/event</path>
      <title>Manage Events</title>
      <page_callback>CRM_Event_Page_ManageEvent</page_callback>
@@ -110,6 +119,16 @@
      <weight>395</weight>
   </item>
   <item>
+     <path>civicrm/admin/options/conference_slot</path>
+     <title>Conference Slot Labels</title>
+     <page_callback>CRM_Admin_Page_Options</page_callback>
+     <desc>Define conference slots and labels.</desc>
+     <path_arguments>group=conference_slot</path_arguments>
+     <access_arguments>administer CiviCRM,access CiviEvent</access_arguments>
+     <adminGroup>CiviEvent</adminGroup>
+     <weight>415</weight>
+  </item>  
+  <item>
      <path>civicrm/event/search</path>
      <title>Find Participants</title>
      <page_callback>CRM_Event_Controller_Search</page_callback>
@@ -173,6 +192,14 @@
      <weight>940</weight>
   </item>
   <item>
+     <path>civicrm/event/manage/conference</path>
+     <title>Conference Slots</title>
+     <page_callback>CRM_Event_Form_ManageEvent_Conference</page_callback>
+     <access_arguments>access CiviEvent</access_arguments>
+     <is_ssl>true</is_ssl>
+     <weight>950</weight>
+  </item>
+  <item>
      <path>civicrm/event/add</path>
      <path_arguments>action=add</path_arguments>
      <title>New Event</title>
@@ -234,4 +261,46 @@
      <page_callback>CRM_Event_Page_AJAX::eventList</page_callback>
      <access_arguments>access CiviCRM,access CiviEvent</access_arguments>
   </item>
+  <item>
+    <path>civicrm/ajax/event/add_participant_to_cart</path>
+    <page_callback>CRM_Event_Cart_Page_CheckoutAJAX::add_participant_to_cart</page_callback>
+    <access_callback>1</access_callback>
+  </item>
+  <item>
+    <path>civicrm/ajax/event/remove_participant_from_cart</path>
+    <page_callback>CRM_Event_Cart_Page_CheckoutAJAX::remove_participant_from_cart</page_callback>
+    <access_callback>1</access_callback>
+  </item>
+  <item>
+    <path>civicrm/event/add_to_cart</path>
+    <title>Add Event To Cart</title>
+    <page_callback>CRM_Event_Cart_Page_AddToCart</page_callback>
+    <access_callback>1</access_callback>
+    <is_public>true</is_public>
+    <is_ssl>false</is_ssl>
+  </item>
+  <item>
+    <path>civicrm/event/cart_checkout</path>
+    <title>Cart Checkout</title>
+    <page_callback>CRM_Event_Cart_Controller_Checkout</page_callback>
+    <access_callback>1</access_callback>
+    <is_public>true</is_public>
+    <is_ssl>true</is_ssl>
+  </item>
+  <item>
+    <path>civicrm/event/remove_from_cart</path>
+    <title>Remove From Cart</title>
+    <page_callback>CRM_Event_Cart_Page_RemoveFromCart</page_callback>
+    <access_callback>1</access_callback>
+    <is_public>true</is_public>
+    <is_ssl>false</is_ssl>
+  </item>
+  <item>
+    <path>civicrm/event/view_cart</path>
+    <title>View Cart</title>
+    <page_callback>CRM_Event_Cart_Page_ViewCart</page_callback>
+    <access_callback>1</access_callback>
+    <is_public>true</is_public>
+    <is_ssl>false</is_ssl>
+  </item>
 </menu>
diff --git a/CRM/Mailing/BAO/BouncePattern.php b/CRM/Mailing/BAO/BouncePattern.php
index 0ed8e7e..37df9bf 100644
--- a/CRM/Mailing/BAO/BouncePattern.php
+++ b/CRM/Mailing/BAO/BouncePattern.php
@@ -95,7 +95,7 @@ class CRM_Mailing_BAO_BouncePattern extends CRM_Mailing_DAO_BouncePattern {
             if (preg_match($re, $message, $matches)) {
                 $bounce = array(
                                 'bounce_type_id' => $type,
-                                'bounce_reason' => $matches[0]
+                                'bounce_reason' => $message,
                                 );
                 
                 return $bounce;
@@ -106,7 +106,7 @@ class CRM_Mailing_BAO_BouncePattern extends CRM_Mailing_DAO_BouncePattern {
 
         $bounce = array( 
                         'bounce_type_id' => null, 
-                        'bounce_reason' => null 
+                        'bounce_reason' => $message,
                          );
         
         return $bounce;
diff --git a/CRM/Mailing/Event/BAO/Bounce.php b/CRM/Mailing/Event/BAO/Bounce.php
index d21549e..8341df0 100644
--- a/CRM/Mailing/Event/BAO/Bounce.php
+++ b/CRM/Mailing/Event/BAO/Bounce.php
@@ -74,7 +74,9 @@ class CRM_Mailing_Event_BAO_Bounce extends CRM_Mailing_Event_DAO_Bounce {
         // with the connection or smtp server etc
         if ( empty( $params['bounce_type_id'] ) ) {
             $params['bounce_type_id'] = 11;
-            $params['bounce_reason'] = ts( 'Unknown bounce type: Could not parse bounce email' );
+            if (empty($params['bounce_reason'])) {
+                $params['bounce_reason'] = ts( 'Unknown bounce type: Could not parse bounce email' );
+            }
         }
              
         $bounce->copyValues($params);
diff --git a/CRM/Member/BAO/Membership.php b/CRM/Member/BAO/Membership.php
index 3122adb..8e61ff2 100644
--- a/CRM/Member/BAO/Membership.php
+++ b/CRM/Member/BAO/Membership.php
@@ -1156,6 +1156,7 @@ AND civicrm_membership.is_test = %2";
         //this condition arises when separate membership payment is
         //enabled and contribution amount is not selected. fix for CRM-3010
         require_once 'CRM/Contribute/BAO/Contribution/Utils.php';
+        $membershipParams['robots'] = true; // since CAPTCHA is not displayed to the user, do not require it for validation.
         if ( $form->_amount > 0.0 ) {
             $result = CRM_Contribute_BAO_Contribution_Utils::processConfirm( $form, $membershipParams, 
                                                                              $premiumParams, $contactID,
diff --git a/CRM/Profile/Form.php b/CRM/Profile/Form.php
index afa4526..45f5618 100644
--- a/CRM/Profile/Form.php
+++ b/CRM/Profile/Form.php
@@ -362,6 +362,10 @@ class CRM_Profile_Form extends CRM_Core_Form
         }
         
         $this->setDefaults( $this->_defaults );
+        
+        // now fix all state country selectors
+        require_once 'CRM/Core/BAO/Address.php';
+        CRM_Core_BAO_Address::fixAllStateSelects( $this, $this->_defaults );
     } 
     
     /**
@@ -503,14 +507,6 @@ class CRM_Profile_Form extends CRM_Core_Form
                 continue;
             }
             
-            list( $prefixName, $index ) = CRM_Utils_System::explode( '-', $name, 2 );
-            if ( $prefixName == 'state_province' || $prefixName == 'country' || $prefixName == 'county' ) {
-                if ( ! array_key_exists( $index, $stateCountryMap ) ) {
-                    $stateCountryMap[$index] = array( );
-                }
-                $stateCountryMap[$index][$prefixName] = $name;
-            }
-            
             CRM_Core_BAO_UFGroup::buildProfile($this, $field, $this->_mode );
             
             if ($field['add_to_group_id']) {
@@ -566,10 +562,6 @@ class CRM_Profile_Form extends CRM_Core_Form
             }
         }
         
-    	// also do state country js
-    	require_once 'CRM/Core/BAO/Address.php';
-    	CRM_Core_BAO_Address::addStateCountryMap( $stateCountryMap, $this->_defaults );
-        
         $action = CRM_Utils_Request::retrieve('action', 'String',$this, false, null );
         if ( $this->_mode == self::MODE_CREATE  ) { 
             require_once 'CRM/Core/BAO/CMSUser.php';
@@ -580,10 +572,6 @@ class CRM_Profile_Form extends CRM_Core_Form
         
         $this->assign( 'groupId', $this->_gid ); 
         
-        // now fix all state country selectors
-        require_once 'CRM/Core/BAO/Address.php';
-        CRM_Core_BAO_Address::fixAllStateSelects( $this, $this->_defaults );
-        
         // if view mode pls freeze it with the done button.
         if ($this->_action & CRM_Core_Action::VIEW) {
             $this->freeze();
diff --git a/CRM/Report/Form.php b/CRM/Report/Form.php
index 3e16a95..af68d72 100644
--- a/CRM/Report/Form.php
+++ b/CRM/Report/Form.php
@@ -1735,6 +1735,7 @@ WHERE cg.extends IN ('" . implode( "','", $this->_customGroupExtends ) . "') AND
 
     function groupBy( ) {
         $this->_groupBy = "";
+        $group_bys = array();
         if ( CRM_Utils_Array::value( 'group_bys', $this->_params ) &&
              is_array($this->_params['group_bys']) &&
              !empty($this->_params['group_bys']) ) {
@@ -1742,12 +1743,15 @@ WHERE cg.extends IN ('" . implode( "','", $this->_customGroupExtends ) . "') AND
                 if ( array_key_exists('group_bys', $table) ) {
                     foreach ( $table['group_bys'] as $fieldName => $field ) {
 								if ( CRM_Utils_Array::value( $fieldName, $this->_params['group_bys'] ) ) {
-                                    $this->_groupBy[] = $field['dbAlias'];
+                                    $group_bys[] = $field['dbAlias'];
 								}
                     }
                 }
             }
         } 
+        if (!empty($group_bys)) {
+          $this->_groupBy = "GROUP BY ".join(', ', $group_bys);
+        }
     }
 
     function orderBy( ) {
@@ -2788,4 +2792,4 @@ LEFT JOIN civicrm_contact {$field['alias']} ON {$field['alias']}.id = {$this->_a
         }
     }
     
-}
\ No newline at end of file
+}
diff --git a/CRM/UF/Form/Preview.php b/CRM/UF/Form/Preview.php
index 7aa6af8..7b05a9a 100644
--- a/CRM/UF/Form/Preview.php
+++ b/CRM/UF/Form/Preview.php
@@ -133,28 +133,7 @@ class CRM_UF_Form_Preview extends CRM_Core_Form
     function &setDefaultValues()
     {
         $defaults = array();
-        $stateCountryMap = array( );
-        foreach ($this->_fields as $name => $field ) {
-            if ($customFieldID = CRM_Core_BAO_CustomField::getKeyID($field['name'])) {
-                CRM_Core_BAO_CustomField::setProfileDefaults( $customFieldID, $name, $defaults, null, CRM_Profile_Form::MODE_REGISTER );
-            }
 
-            //CRM-5403
-            if ( ( substr($name,0,14) === 'state_province') || ( substr($name,0,7) === 'country' ) || ( substr($name,0,6) === 'county' ) ) {
-                list( $fieldName, $index ) = CRM_Utils_System::explode( '-', $name, 2 );
-                if ( ! array_key_exists( $index, $stateCountryMap ) ) {
-                    $stateCountryMap[$index] = array( );
-                }
-                $stateCountryMap[$index][$fieldName] = $name;
-            }
-        }
-
-        // also take care of state country widget
-        if ( !empty($stateCountryMap) ) {
-            require_once 'CRM/Core/BAO/Address.php';
-            CRM_Core_BAO_Address::addStateCountryMap( $stateCountryMap, $defaults );
-        }
-        
         //set default for country.
         CRM_Core_BAO_UFGroup::setRegisterDefaults( $this->_fields, $defaults );
 
diff --git a/CRM/Upgrade/3.2.1.msg_template/civicrm_msg_template.tpl b/CRM/Upgrade/3.2.1.msg_template/civicrm_msg_template.tpl
old mode 100755
new mode 100644
diff --git a/CRM/Upgrade/3.2.alpha1.msg_template/civicrm_msg_template.tpl b/CRM/Upgrade/3.2.alpha1.msg_template/civicrm_msg_template.tpl
old mode 100755
new mode 100644
diff --git a/CRM/Upgrade/3.2.alpha1.msg_template/message_templates/event_offline_receipt_html.tpl b/CRM/Upgrade/3.2.alpha1.msg_template/message_templates/event_offline_receipt_html.tpl
old mode 100755
new mode 100644
diff --git a/CRM/Upgrade/3.2.alpha1.msg_template/message_templates/event_offline_receipt_text.tpl b/CRM/Upgrade/3.2.alpha1.msg_template/message_templates/event_offline_receipt_text.tpl
old mode 100755
new mode 100644
diff --git a/CRM/Upgrade/3.2.alpha1.msg_template/message_templates/event_online_receipt_html.tpl b/CRM/Upgrade/3.2.alpha1.msg_template/message_templates/event_online_receipt_html.tpl
old mode 100755
new mode 100644
diff --git a/CRM/Upgrade/3.2.alpha1.msg_template/message_templates/event_online_receipt_text.tpl b/CRM/Upgrade/3.2.alpha1.msg_template/message_templates/event_online_receipt_text.tpl
old mode 100755
new mode 100644
diff --git a/CRM/Upgrade/3.2.alpha2.msg_template/civicrm_msg_template.tpl b/CRM/Upgrade/3.2.alpha2.msg_template/civicrm_msg_template.tpl
old mode 100755
new mode 100644
diff --git a/CRM/Upgrade/3.2.alpha3.msg_template/civicrm_msg_template.tpl b/CRM/Upgrade/3.2.alpha3.msg_template/civicrm_msg_template.tpl
old mode 100755
new mode 100644
diff --git a/CRM/Upgrade/3.3.2.msg_template/civicrm_msg_template.tpl b/CRM/Upgrade/3.3.2.msg_template/civicrm_msg_template.tpl
old mode 100755
new mode 100644
diff --git a/CRM/Upgrade/3.3.3.msg_template/civicrm_msg_template.tpl b/CRM/Upgrade/3.3.3.msg_template/civicrm_msg_template.tpl
old mode 100755
new mode 100644
diff --git a/CRM/Upgrade/3.3.beta1.msg_template/civicrm_msg_template.tpl b/CRM/Upgrade/3.3.beta1.msg_template/civicrm_msg_template.tpl
old mode 100755
new mode 100644
diff --git a/CRM/Upgrade/3.3.beta2.msg_template/civicrm_msg_template.tpl b/CRM/Upgrade/3.3.beta2.msg_template/civicrm_msg_template.tpl
old mode 100755
new mode 100644
diff --git a/CRM/Upgrade/Form.php b/CRM/Upgrade/Form.php
index 61cd1e3..98c7129 100644
--- a/CRM/Upgrade/Form.php
+++ b/CRM/Upgrade/Form.php
@@ -252,7 +252,7 @@ SET    version = '$version'
                            array(dirname(__FILE__), 'Incremental', 'sql') );
         $sqlFiles = scandir($sqlDir);
 
-        $sqlFilePattern = '/^(\d{1,2}\.\d{1,2}\.(\d{1,2}|\w{4,7}))\.(my)?sql(\.tpl)?$/i';
+        $sqlFilePattern = '/^(\d{1,2}\.\d{1,2}\.(\d{1,2}\.)?(\d{1,2}|\w{4,7}))\.(my)?sql(\.tpl)?$/i';
         foreach ($sqlFiles as $file) {
             if ( preg_match($sqlFilePattern, $file, $matches) ) {
                 if ( ! in_array($matches[1], $revList) ) {
diff --git a/CRM/Upgrade/Incremental/sql/3.4.4.1.mysql.tpl b/CRM/Upgrade/Incremental/sql/3.4.4.1.mysql.tpl
new file mode 100644
index 0000000..bd34232
--- /dev/null
+++ b/CRM/Upgrade/Incremental/sql/3.4.4.1.mysql.tpl
@@ -0,0 +1,62 @@
+-- /*****   Civicrm Multi-Event Registration   ***********/ 
+
+-- /*******************************************************
+-- *
+-- * civicrm_event_carts
+-- *
+-- *******************************************************/
+CREATE TABLE civicrm_event_carts (
+
+
+     id int unsigned NOT NULL AUTO_INCREMENT  COMMENT 'Cart Id',
+     user_id int unsigned    COMMENT 'FK to civicrm_contact who created this cart',
+     coupon_code varchar(255) DEFAULT NULL,
+     completed tinyint   DEFAULT 0
+,
+    PRIMARY KEY ( id )
+
+
+,
+     CONSTRAINT FK_civicrm_event_carts_user_id FOREIGN KEY (user_id)
+REFERENCES civicrm_contact(id) ON DELETE SET NULL
+)  ENGINE=InnoDB DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci  ;
+
+-- /*******************************************************
+-- *
+-- * civicrm_events_in_carts
+-- *
+-- *******************************************************/
+CREATE TABLE civicrm_events_in_carts (
+
+
+     id int unsigned NOT NULL AUTO_INCREMENT  COMMENT 'Event In Cart Id',
+     event_id int unsigned    COMMENT 'FK to Event ID',
+     event_cart_id int unsigned    COMMENT 'FK to Event Cart ID',
+    PRIMARY KEY ( id )
+,
+     CONSTRAINT FK_civicrm_events_in_carts_event_id FOREIGN KEY (event_id)
+REFERENCES civicrm_event(id) ON DELETE CASCADE,
+     CONSTRAINT FK_civicrm_events_in_carts_event_cart_id FOREIGN KEY
+(event_cart_id) REFERENCES civicrm_event_carts(id) ON DELETE CASCADE
+)  ENGINE=InnoDB DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci  ;
+
+
+ALTER TABLE civicrm_participant
+    ADD discount_amount int unsigned DEFAULT 0 COMMENT 'Discount Amount';
+ALTER TABLE civicrm_participant
+    ADD cart_id int unsigned DEFAULT NULL COMMENT 'FK to civicrm_event_carts';
+ALTER TABLE civicrm_participant
+    ADD CONSTRAINT FK_civicrm_participant_cart_id FOREIGN KEY (cart_id)
+        REFERENCES civicrm_event_carts(id) ON DELETE SET NULL;
+
+-- XXX a hint to the payment form.  Can someone make this go away?
+ALTER TABLE civicrm_participant
+    ADD must_wait TINYINT   DEFAULT 0 COMMENT 'On Waiting List';
+
+
+SELECT @pending_id                 := MAX(id) + 1 FROM civicrm_participant_status_type;
+INSERT INTO civicrm_participant_status_type
+  (id,          name,                         label,                                                       class,      is_reserved, is_active, is_counted, weight,      visibility_id)
+VALUES
+  (@pending_id, 'Pending in cart',            '{ts escape="sql"}Pending in cart{/ts}',                     'Pending',  1,           1,         0,          @pending_id, 2            );
+
diff --git a/CRM/Upgrade/Incremental/sql/3.4.4.2.mysql.tpl b/CRM/Upgrade/Incremental/sql/3.4.4.2.mysql.tpl
new file mode 100644
index 0000000..71815c9
--- /dev/null
+++ b/CRM/Upgrade/Incremental/sql/3.4.4.2.mysql.tpl
@@ -0,0 +1,5 @@
+ALTER TABLE civicrm_event
+    ADD parent_event_id int unsigned DEFAULT 0 COMMENT 'Implicit FK to civicrm_event: parent event';
+
+ALTER TABLE civicrm_event
+    ADD slot_label varchar(255) DEFAULT NULL COMMENT 'Subevent slot label';
diff --git a/CRM/Upgrade/Incremental/sql/3.4.4.3.mysql.tpl b/CRM/Upgrade/Incremental/sql/3.4.4.3.mysql.tpl
new file mode 100644
index 0000000..1116d5f
--- /dev/null
+++ b/CRM/Upgrade/Incremental/sql/3.4.4.3.mysql.tpl
@@ -0,0 +1,23 @@
+ALTER TABLE civicrm_event
+    MODIFY parent_event_id int unsigned DEFAULT NULL COMMENT 'Implicit FK to civicrm_event: parent event';
+
+INSERT INTO 
+   `civicrm_option_group` (`name`, `description`, `is_reserved`, `is_active`)
+VALUES 
+   ('conference_slot'               , '{ts escape="sql"}Conference Slot{/ts}'                    , 0, 1);
+
+ALTER TABLE civicrm_event
+    DROP slot_label;
+ALTER TABLE civicrm_event
+    ADD slot_label_id int unsigned DEFAULT NULL COMMENT 'Subevent slot label. Implicit FK to civicrm_option_value where option_group = conference_slot.';
+
+SELECT @msg_tpl_workflow_event := MAX(id)     FROM civicrm_option_group WHERE name = 'msg_tpl_workflow_event';
+SELECT @weight                 := MAX(weight) + 1 FROM civicrm_option_value WHERE option_group_id = @msg_tpl_workflow_event;
+
+INSERT INTO civicrm_option_value
+  (option_group_id,         name,                         label,                                         value,   weight)
+VALUES
+  (@msg_tpl_workflow_event, 'event_registration_receipt', '{ts escape="sql"}Events - Receipt only{/ts}', @weight, @weight);
+
+{* SELECT @tpl_ovid_$vName := MAX(id) FROM civicrm_option_value WHERE option_group_id = @tpl_ogid_$gName AND name = '$vName'; *}
+{* INSERT INTO civicrm_msg_template *}
diff --git a/CRM/Upgrade/Incremental/sql/3.4.4.4.mysql.tpl b/CRM/Upgrade/Incremental/sql/3.4.4.4.mysql.tpl
new file mode 100644
index 0000000..f9d40e1
--- /dev/null
+++ b/CRM/Upgrade/Incremental/sql/3.4.4.4.mysql.tpl
@@ -0,0 +1,9 @@
+SELECT @msg_tpl_workflow_event := MAX(id)     FROM civicrm_option_group WHERE name = 'msg_tpl_workflow_event';
+
+SELECT @tpl_ovid_event_registration_receipt := MAX(id) FROM civicrm_option_value WHERE option_group_id = @msg_tpl_workflow_event AND name = 'event_registration_receipt';
+
+-- NOT FOR RELEASE:
+-- the following code assumes we are using the filebacked_entity hack
+
+INSERT INTO civicrm_msg_template
+  (workflow_id, is_default, is_reserved) VALUES (@tpl_ovid_event_registration_receipt, 1, 0)
diff --git a/CRM/Utils/Hook.php b/CRM/Utils/Hook.php
index 1a4f665..575e615 100644
--- a/CRM/Utils/Hook.php
+++ b/CRM/Utils/Hook.php
@@ -716,6 +716,22 @@ class CRM_Utils_Hook {
     }
     
     /** 
+     * Hook can be called before using CRM_Core_DAO::query to select an object
+     *
+     * @param array $selectParams  - key/value description of the object of our search.
+     */
+    static function preLoad( &$selectParams ) {
+        $config =& CRM_Core_Config::singleton( );
+        require_once( str_replace( '_', DIRECTORY_SEPARATOR, $config->userHookClass ) . '.php' );
+        $null =& CRM_Core_DAO::$_nullObject;
+
+        return
+            eval( 'return ' .
+                $config->userHookClass .
+                '::invoke( 1, $selectParams, $null, $null, $null, $null, \'civicrm_preLoad\' );' );
+    }
+
+    /**
      * This hook is called before record is exported as CSV
      * 
      * @param string $exportTempTable - name of the temporary export table used during export
@@ -846,5 +862,22 @@ class CRM_Utils_Hook {
         $null =& CRM_Core_DAO::$_nullObject;
         return eval("return {$config->userHookClass}::invoke(4, \$objectName, \$headers, \$rows, \$selector, \$null, 'civicrm_searchColumns');");
     }
+    
+    /** 
+     * This hook is called before creating a contact for a cart
+     * 
+     * @param array  &$params	 the params that will be used to create the participan
+     * @return null the return value is ignored
+     * @access public 
+     */ 
+    static function createCartContact( $registeringContactID, &$params ) {
+        $config = CRM_Core_Config::singleton( );
+	require_once( str_replace( '_', DIRECTORY_SEPARATOR, $config->userHookClass ) . '.php' );
+        $null =& CRM_Core_DAO::$_nullObject;
+        return   
+            eval( 'return ' .
+                  $config->userHookClass .
+                  '::invoke( 2, $registeringContactID, $params, $null, $null, $null, \'civicrm_createCartContact\' );' );  
+    }
 
 }
diff --git a/CRM/Utils/Rule.php b/CRM/Utils/Rule.php
index 1c765fe..27256af 100644
--- a/CRM/Utils/Rule.php
+++ b/CRM/Utils/Rule.php
@@ -123,7 +123,19 @@ class CRM_Utils_Rule
 
     static function url($url)
     {
-        return (bool) filter_var($url, FILTER_VALIDATE_URL);
+      $result = (bool) filter_var($url, FILTER_VALIDATE_URL);
+      if ($result === false)
+      {
+	if (preg_match("#((http|https|ftp)://(\S*?\.\S*?))(\s|\;|\)|\]|\[|\{|\}|,|\"|'|:|\<|$|\.\s)#ie", $url) == 1)
+	{
+	  $result = true;
+	}
+	else
+	{
+	  $result = false;
+	}
+      }
+      return $result;
     }
 
     static function wikiURL( $string )
diff --git a/CRM/Utils/System.php b/CRM/Utils/System.php
index d751bf4..a0c0e18 100644
--- a/CRM/Utils/System.php
+++ b/CRM/Utils/System.php
@@ -832,7 +832,7 @@ class CRM_Utils_System {
     }
 
     static function isVersionFormatValid( $version ) {
-        return preg_match("/^(\d{1,2}\.){2}(\d{1,2}|(alpha|beta)\d{1,2})(\.upgrade)?$/", $version );
+        return preg_match("/^(\d{1,2}\.){2,3}(\d{1,2}|(alpha|beta)\d{1,2})(\.upgrade)?$/", $version );
     }
 
     static function getAllHeaders( ) {
diff --git a/bin/ParticipantProcessor.php b/bin/ParticipantProcessor.php
index 6d7062e..fb9a641 100644
--- a/bin/ParticipantProcessor.php
+++ b/bin/ParticipantProcessor.php
@@ -68,8 +68,8 @@ class CRM_ParticipantProcessor
         $expiredParticipantCount = $waitingConfirmCount = $waitingApprovalCount = 0;
         
         //get all participant who's status in class pending and waiting
-        $query = "SELECT * FROM civicrm_participant WHERE status_id IN {$statusIds} ORDER BY register_date";
         
+        $now = date('YmdHis');
         $query = "
    SELECT  participant.id,
            participant.contact_id,
@@ -83,7 +83,7 @@ class CRM_ParticipantProcessor
      FROM  civicrm_participant participant
 LEFT JOIN  civicrm_event event ON ( event.id = participant.event_id )
     WHERE  participant.status_id IN {$statusIds}
-     AND   (event.end_date > now() OR event.end_date IS NULL)
+     AND   (event.start_date > DATE_ADD('$now', INTERVAL 1 DAY) OR event.end_date IS NULL)
      AND   event.is_active = 1 
  ORDER BY  participant.register_date, participant.id 
 ";
diff --git a/bin/cron.inc b/bin/cron.inc
new file mode 100644
index 0000000..a81e510
--- /dev/null
+++ b/bin/cron.inc
@@ -0,0 +1,35 @@
+#!/usr/bin/env php
+<?php
+
+$civicrm_settings_path = dirname(__FILE__) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'default' . DIRECTORY_SEPARATOR . 'civicrm.settings.php';
+require_once($civicrm_settings_path);
+require_once('CRM/Core/Config.php');
+require_once('CRM/Core/BAO/UFMatch.php');
+require_once 'CRM/Core/Session.php';
+require_once('CRM/Mailing/BAO/Job.php');
+require_once('CRM/Utils/System.php');
+
+function run( )
+{
+  global $civicrm_root;
+  global $user;
+  $config =& CRM_Core_Config::singleton();
+  $_SERVER['SCRIPT_FILENAME'] = "$civicrm_root/bin/cron.php";
+  CRM_Utils_System::loadBootStrap();
+  $session = CRM_Core_Session::singleton();
+  $user_id = 1;
+  $user = user_load($user_id);
+  $contact_id = CRM_Core_BAO_UFMatch::getContactId($user_id);
+  if (!$contact_id) 
+  {
+	throw new Exception("Couldn't find a contact in CiviCRM to match the Drupal Super Administrator (User ID: $user_id).");
+  }
+  $session->set('ufID', $user_id);
+  $session->set('userID', $contact_id);
+  $batch_size = $config->mailerBatchLimit;
+  CRM_Mailing_BAO_Job::runJobs_pre($batch_size);
+  CRM_Mailing_BAO_Job::runJobs();
+  CRM_Mailing_BAO_Job::runJobs_post();
+}
+
+run();
diff --git a/bin/regen.sh.txt b/bin/regen.sh.txt
old mode 100755
new mode 100644
diff --git a/bin/setup.sh.txt b/bin/setup.sh.txt
old mode 100755
new mode 100644
diff --git a/css/civicrm.css b/css/civicrm.css
index b9bab81..6b6b18f 100644
--- a/css/civicrm.css
+++ b/css/civicrm.css
@@ -715,6 +715,11 @@ div.spacer,
 #crm-container ul.indented {
     padding-left: 3em;
 }
+#crm-container tr.subevent td.event-title,
+#crm-container tr.subevent td.event-info {
+    padding-left: 3em;
+}
+
 
 /*
 ** CSS for links from Drupal Blocks.
@@ -2189,6 +2194,13 @@ div.grippie {
     border: none;
 }
 
+#crm-container .paypal_button_info-section {
+    display: none;
+}
+#crm-container ._qf_Payment_upload_express-section {
+    display: none;
+}
+
 /* create new XXX style (drupal block) */ 
 
 #crm-participant-wrapper,
diff --git a/drupal/civicrm.module b/drupal/civicrm.module
index fd81572..829e6e6 100644
--- a/drupal/civicrm.module
+++ b/drupal/civicrm.module
@@ -53,8 +53,10 @@ function civicrm_html_head()
             if ( empty( $line ) ) {
                 continue;
             }
-            if ( strpos( $line, '.css' ) !== false ) {
-                drupal_add_css( drupal_get_path('module', 'civicrm' ) . '/../' . $line );
+            if ( strpos( $line, '.js' ) !== false ) {
+                drupal_add_js( drupal_get_path('module', 'civicrm' ) . '/../' . $line, 'theme' );
+            } else if ( strpos( $line, '.css' ) !== false ) {
+                drupal_add_css( drupal_get_path('module', 'civicrm' ) . '/../' . $line, 'theme' );
             }
         }
         
@@ -1052,4 +1054,3 @@ function civicrm_filter($op, $delta = 0, $format = -1, $text = "") {
     }
     
 }
-
diff --git a/drupal/modules/civicrm_engage/civicrm_engage.info b/drupal/modules/civicrm_engage/civicrm_engage.info
old mode 100755
new mode 100644
diff --git a/drupal/modules/views/civicrm/civicrm_handler_field_event_link.inc b/drupal/modules/views/civicrm/civicrm_handler_field_event_link.inc
index fe07ed8..d1fc720 100644
--- a/drupal/modules/views/civicrm/civicrm_handler_field_event_link.inc
+++ b/drupal/modules/views/civicrm/civicrm_handler_field_event_link.inc
@@ -106,9 +106,18 @@ class civicrm_handler_field_event_link extends views_handler_field {
     // LINKING TO EVENT REGISTRATION PAGE
       case 'registration':
            if (user_access('register for events') && $data !== NULL && $data !== '') {
-           return civicrm_views_href( $data,
-                                            'civicrm/event/register',
-                                            "reset=1&id={$values->{$this->aliases['id']}}" );
+                $config = CRM_Core_Config::singleton();
+                if ($config->enable_cart)
+                {
+                    require_once 'CRM/Event/Cart/BAO/EventInCart.php';
+                    //TODO don't call for every row
+                    $link = CRM_Event_Cart_BAO_EventInCart::get_registration_link($values->{$this->aliases['id']});
+                    return civicrm_views_href( $link['label'], $link['path'], $link['query'] );
+                } else {
+                    return civicrm_views_href( $data,
+                                                'civicrm/event/register',
+                                                "reset=1&id={$values->{$this->aliases['id']}}" );
+                }
            }
 
     // LINKING TO EVENT CONFIG PAGE
diff --git a/drupal/modules/views/civicrm/civicrm_handler_filter_custom_option.inc b/drupal/modules/views/civicrm/civicrm_handler_filter_custom_option.inc
old mode 100755
new mode 100644
diff --git a/packages/DB/scripts/DB_DataObject_createTables.bat b/packages/DB/scripts/DB_DataObject_createTables.bat
old mode 100755
new mode 100644
diff --git a/packages/Google/README b/packages/Google/README
old mode 100755
new mode 100644
diff --git a/packages/Google/UPGRADE b/packages/Google/UPGRADE
old mode 100755
new mode 100644
diff --git a/packages/Google/demo/basicapiresponsehandlerdemo.php b/packages/Google/demo/basicapiresponsehandlerdemo.php
old mode 100755
new mode 100644
diff --git a/packages/Google/demo/cartdemo.php b/packages/Google/demo/cartdemo.php
old mode 100755
new mode 100644
diff --git a/packages/Google/demo/digitalCart.php b/packages/Google/demo/digitalCart.php
old mode 100755
new mode 100644
diff --git a/packages/Google/demo/lineItemShipping.php b/packages/Google/demo/lineItemShipping.php
old mode 100755
new mode 100644
diff --git a/packages/Google/demo/merchantsubscriptionrecurrencedemo.php b/packages/Google/demo/merchantsubscriptionrecurrencedemo.php
old mode 100755
new mode 100644
diff --git a/packages/Google/demo/pollingdemo.php b/packages/Google/demo/pollingdemo.php
old mode 100755
new mode 100644
diff --git a/packages/Google/demo/responsehandlerdemo.php b/packages/Google/demo/responsehandlerdemo.php
old mode 100755
new mode 100644
diff --git a/packages/Google/demo/sampcodetest.php b/packages/Google/demo/sampcodetest.php
old mode 100755
new mode 100644
diff --git a/packages/Google/demo/subscriptiondemo.php b/packages/Google/demo/subscriptiondemo.php
old mode 100755
new mode 100644
diff --git a/packages/Google/library/googlecart.php b/packages/Google/library/googlecart.php
old mode 100755
new mode 100644
diff --git a/packages/Google/library/googleitem.php b/packages/Google/library/googleitem.php
old mode 100755
new mode 100644
diff --git a/packages/Google/library/googlelog.php b/packages/Google/library/googlelog.php
old mode 100755
new mode 100644
diff --git a/packages/Google/library/googlemerchantcalculations.php b/packages/Google/library/googlemerchantcalculations.php
old mode 100755
new mode 100644
diff --git a/packages/Google/library/googlenotification.php b/packages/Google/library/googlenotification.php
old mode 100755
new mode 100644
diff --git a/packages/Google/library/googlenotificationhistory.php b/packages/Google/library/googlenotificationhistory.php
old mode 100755
new mode 100644
diff --git a/packages/Google/library/googlepoll.php b/packages/Google/library/googlepoll.php
old mode 100755
new mode 100644
diff --git a/packages/Google/library/googlerequest.php b/packages/Google/library/googlerequest.php
old mode 100755
new mode 100644
diff --git a/packages/Google/library/googleresponse.php b/packages/Google/library/googleresponse.php
old mode 100755
new mode 100644
diff --git a/packages/Google/library/googleresult.php b/packages/Google/library/googleresult.php
old mode 100755
new mode 100644
diff --git a/packages/Google/library/googleshipping.php b/packages/Google/library/googleshipping.php
old mode 100755
new mode 100644
diff --git a/packages/Google/library/googlesubscription.php b/packages/Google/library/googlesubscription.php
old mode 100755
new mode 100644
diff --git a/packages/Google/library/googletax.php b/packages/Google/library/googletax.php
old mode 100755
new mode 100644
diff --git a/packages/Google/library/htmlSignatureGen.php b/packages/Google/library/htmlSignatureGen.php
old mode 100755
new mode 100644
diff --git a/packages/Google/library/xml-processing/gc_xmlbuilder.php b/packages/Google/library/xml-processing/gc_xmlbuilder.php
old mode 100755
new mode 100644
diff --git a/packages/Google/library/xml-processing/gc_xmlparser.php b/packages/Google/library/xml-processing/gc_xmlparser.php
old mode 100755
new mode 100644
diff --git a/packages/Net/SMTP.php b/packages/Net/SMTP.php
index 220fc33..6518e04 100644
--- a/packages/Net/SMTP.php
+++ b/packages/Net/SMTP.php
@@ -398,7 +398,8 @@ class Net_SMTP
             return $error;
         }
 
-        return true;
+        $errorMessage = 'Invalid response code received from SMTP (outbound mail) server while attempting to send email.  This is often caused by a misconfiguration in the CiviCRM Outbound Email settings. Please verify the settings at Administer CiviCRM >> Global Settings >> Outbound Email (SMTP).';
+        return PEAR::raiseError( $errorMessage );
     }
 
     /**
diff --git a/packages/OpenFlashChart/js/swfobject_src.js b/packages/OpenFlashChart/js/swfobject_src.js
old mode 100755
new mode 100644
diff --git a/packages/PEAR/pear b/packages/PEAR/pear
old mode 100755
new mode 100644
diff --git a/packages/PEAR/peardev b/packages/PEAR/peardev
old mode 100755
new mode 100644
diff --git a/packages/PEAR/pecl b/packages/PEAR/pecl
old mode 100755
new mode 100644
diff --git a/packages/PHP/php_beautifier b/packages/PHP/php_beautifier
old mode 100755
new mode 100644
diff --git a/packages/dompdf/dompdf.php b/packages/dompdf/dompdf.php
old mode 100755
new mode 100644
diff --git a/packages/dompdf/load_font.php b/packages/dompdf/load_font.php
old mode 100755
new mode 100644
diff --git a/packages/jquery/jquery-ui-1.8.11/css/smoothness/images/ui-bg_flat_0_aaaaaa_40x100.png b/packages/jquery/jquery-ui-1.8.11/css/smoothness/images/ui-bg_flat_0_aaaaaa_40x100.png
old mode 100755
new mode 100644
diff --git a/packages/jquery/jquery-ui-1.8.11/css/smoothness/images/ui-bg_flat_75_ffffff_40x100.png b/packages/jquery/jquery-ui-1.8.11/css/smoothness/images/ui-bg_flat_75_ffffff_40x100.png
old mode 100755
new mode 100644
diff --git a/packages/jquery/jquery-ui-1.8.11/css/smoothness/images/ui-bg_glass_55_fbf9ee_1x400.png b/packages/jquery/jquery-ui-1.8.11/css/smoothness/images/ui-bg_glass_55_fbf9ee_1x400.png
old mode 100755
new mode 100644
diff --git a/packages/jquery/jquery-ui-1.8.11/css/smoothness/images/ui-bg_glass_65_ffffff_1x400.png b/packages/jquery/jquery-ui-1.8.11/css/smoothness/images/ui-bg_glass_65_ffffff_1x400.png
old mode 100755
new mode 100644
diff --git a/packages/jquery/jquery-ui-1.8.11/css/smoothness/images/ui-bg_glass_75_dadada_1x400.png b/packages/jquery/jquery-ui-1.8.11/css/smoothness/images/ui-bg_glass_75_dadada_1x400.png
old mode 100755
new mode 100644
diff --git a/packages/jquery/jquery-ui-1.8.11/css/smoothness/images/ui-bg_glass_75_e6e6e6_1x400.png b/packages/jquery/jquery-ui-1.8.11/css/smoothness/images/ui-bg_glass_75_e6e6e6_1x400.png
old mode 100755
new mode 100644
diff --git a/packages/jquery/jquery-ui-1.8.11/css/smoothness/images/ui-bg_glass_95_fef1ec_1x400.png b/packages/jquery/jquery-ui-1.8.11/css/smoothness/images/ui-bg_glass_95_fef1ec_1x400.png
old mode 100755
new mode 100644
diff --git a/packages/jquery/jquery-ui-1.8.11/css/smoothness/images/ui-bg_highlight-soft_75_cccccc_1x100.png b/packages/jquery/jquery-ui-1.8.11/css/smoothness/images/ui-bg_highlight-soft_75_cccccc_1x100.png
old mode 100755
new mode 100644
diff --git a/packages/jquery/jquery-ui-1.8.11/css/smoothness/images/ui-icons_222222_256x240.png b/packages/jquery/jquery-ui-1.8.11/css/smoothness/images/ui-icons_222222_256x240.png
old mode 100755
new mode 100644
diff --git a/packages/jquery/jquery-ui-1.8.11/css/smoothness/images/ui-icons_2e83ff_256x240.png b/packages/jquery/jquery-ui-1.8.11/css/smoothness/images/ui-icons_2e83ff_256x240.png
old mode 100755
new mode 100644
diff --git a/packages/jquery/jquery-ui-1.8.11/css/smoothness/images/ui-icons_454545_256x240.png b/packages/jquery/jquery-ui-1.8.11/css/smoothness/images/ui-icons_454545_256x240.png
old mode 100755
new mode 100644
diff --git a/packages/jquery/jquery-ui-1.8.11/css/smoothness/images/ui-icons_888888_256x240.png b/packages/jquery/jquery-ui-1.8.11/css/smoothness/images/ui-icons_888888_256x240.png
old mode 100755
new mode 100644
diff --git a/packages/jquery/jquery-ui-1.8.11/css/smoothness/images/ui-icons_cd0a0a_256x240.png b/packages/jquery/jquery-ui-1.8.11/css/smoothness/images/ui-icons_cd0a0a_256x240.png
old mode 100755
new mode 100644
diff --git a/packages/jquery/jquery-ui-1.8.11/css/smoothness/jquery-ui-1.8.11.custom.css b/packages/jquery/jquery-ui-1.8.11/css/smoothness/jquery-ui-1.8.11.custom.css
old mode 100755
new mode 100644
diff --git a/packages/jquery/jquery-ui-1.8.11/development-bundle/AUTHORS.txt b/packages/jquery/jquery-ui-1.8.11/development-bundle/AUTHORS.txt
old mode 100755
new mode 100644
diff --git a/packages/jquery/jquery-ui-1.8.11/development-bundle/GPL-LICENSE.txt b/packages/jquery/jquery-ui-1.8.11/development-bundle/GPL-LICENSE.txt
old mode 100755
new mode 100644
diff --git a/packages/jquery/jquery-ui-1.8.11/development-bundle/MIT-LICENSE.txt b/packages/jquery/jquery-ui-1.8.11/development-bundle/MIT-LICENSE.txt
old mode 100755
new mode 100644
diff --git a/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/i18n/jquery-ui-i18n.js b/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/i18n/jquery-ui-i18n.js
old mode 100755
new mode 100644
diff --git a/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/i18n/jquery.ui.datepicker-af.js b/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/i18n/jquery.ui.datepicker-af.js
old mode 100755
new mode 100644
diff --git a/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/i18n/jquery.ui.datepicker-ar-DZ.js b/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/i18n/jquery.ui.datepicker-ar-DZ.js
old mode 100755
new mode 100644
diff --git a/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/i18n/jquery.ui.datepicker-ar.js b/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/i18n/jquery.ui.datepicker-ar.js
old mode 100755
new mode 100644
diff --git a/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/i18n/jquery.ui.datepicker-az.js b/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/i18n/jquery.ui.datepicker-az.js
old mode 100755
new mode 100644
diff --git a/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/i18n/jquery.ui.datepicker-bg.js b/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/i18n/jquery.ui.datepicker-bg.js
old mode 100755
new mode 100644
diff --git a/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/i18n/jquery.ui.datepicker-bs.js b/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/i18n/jquery.ui.datepicker-bs.js
old mode 100755
new mode 100644
diff --git a/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/i18n/jquery.ui.datepicker-ca.js b/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/i18n/jquery.ui.datepicker-ca.js
old mode 100755
new mode 100644
diff --git a/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/i18n/jquery.ui.datepicker-cs.js b/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/i18n/jquery.ui.datepicker-cs.js
old mode 100755
new mode 100644
diff --git a/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/i18n/jquery.ui.datepicker-da.js b/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/i18n/jquery.ui.datepicker-da.js
old mode 100755
new mode 100644
diff --git a/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/i18n/jquery.ui.datepicker-de.js b/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/i18n/jquery.ui.datepicker-de.js
old mode 100755
new mode 100644
diff --git a/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/i18n/jquery.ui.datepicker-el.js b/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/i18n/jquery.ui.datepicker-el.js
old mode 100755
new mode 100644
diff --git a/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/i18n/jquery.ui.datepicker-en-AU.js b/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/i18n/jquery.ui.datepicker-en-AU.js
old mode 100755
new mode 100644
diff --git a/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/i18n/jquery.ui.datepicker-en-GB.js b/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/i18n/jquery.ui.datepicker-en-GB.js
old mode 100755
new mode 100644
diff --git a/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/i18n/jquery.ui.datepicker-en-NZ.js b/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/i18n/jquery.ui.datepicker-en-NZ.js
old mode 100755
new mode 100644
diff --git a/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/i18n/jquery.ui.datepicker-eo.js b/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/i18n/jquery.ui.datepicker-eo.js
old mode 100755
new mode 100644
diff --git a/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/i18n/jquery.ui.datepicker-es.js b/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/i18n/jquery.ui.datepicker-es.js
old mode 100755
new mode 100644
diff --git a/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/i18n/jquery.ui.datepicker-et.js b/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/i18n/jquery.ui.datepicker-et.js
old mode 100755
new mode 100644
diff --git a/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/i18n/jquery.ui.datepicker-eu.js b/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/i18n/jquery.ui.datepicker-eu.js
old mode 100755
new mode 100644
diff --git a/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/i18n/jquery.ui.datepicker-fa.js b/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/i18n/jquery.ui.datepicker-fa.js
old mode 100755
new mode 100644
diff --git a/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/i18n/jquery.ui.datepicker-fi.js b/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/i18n/jquery.ui.datepicker-fi.js
old mode 100755
new mode 100644
diff --git a/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/i18n/jquery.ui.datepicker-fo.js b/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/i18n/jquery.ui.datepicker-fo.js
old mode 100755
new mode 100644
diff --git a/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/i18n/jquery.ui.datepicker-fr-CH.js b/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/i18n/jquery.ui.datepicker-fr-CH.js
old mode 100755
new mode 100644
diff --git a/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/i18n/jquery.ui.datepicker-fr.js b/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/i18n/jquery.ui.datepicker-fr.js
old mode 100755
new mode 100644
diff --git a/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/i18n/jquery.ui.datepicker-gl.js b/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/i18n/jquery.ui.datepicker-gl.js
old mode 100755
new mode 100644
diff --git a/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/i18n/jquery.ui.datepicker-he.js b/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/i18n/jquery.ui.datepicker-he.js
old mode 100755
new mode 100644
diff --git a/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/i18n/jquery.ui.datepicker-hr.js b/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/i18n/jquery.ui.datepicker-hr.js
old mode 100755
new mode 100644
diff --git a/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/i18n/jquery.ui.datepicker-hu.js b/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/i18n/jquery.ui.datepicker-hu.js
old mode 100755
new mode 100644
diff --git a/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/i18n/jquery.ui.datepicker-hy.js b/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/i18n/jquery.ui.datepicker-hy.js
old mode 100755
new mode 100644
diff --git a/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/i18n/jquery.ui.datepicker-id.js b/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/i18n/jquery.ui.datepicker-id.js
old mode 100755
new mode 100644
diff --git a/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/i18n/jquery.ui.datepicker-is.js b/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/i18n/jquery.ui.datepicker-is.js
old mode 100755
new mode 100644
diff --git a/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/i18n/jquery.ui.datepicker-it.js b/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/i18n/jquery.ui.datepicker-it.js
old mode 100755
new mode 100644
diff --git a/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/i18n/jquery.ui.datepicker-ja.js b/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/i18n/jquery.ui.datepicker-ja.js
old mode 100755
new mode 100644
diff --git a/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/i18n/jquery.ui.datepicker-ko.js b/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/i18n/jquery.ui.datepicker-ko.js
old mode 100755
new mode 100644
diff --git a/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/i18n/jquery.ui.datepicker-kz.js b/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/i18n/jquery.ui.datepicker-kz.js
old mode 100755
new mode 100644
diff --git a/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/i18n/jquery.ui.datepicker-lt.js b/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/i18n/jquery.ui.datepicker-lt.js
old mode 100755
new mode 100644
diff --git a/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/i18n/jquery.ui.datepicker-lv.js b/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/i18n/jquery.ui.datepicker-lv.js
old mode 100755
new mode 100644
diff --git a/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/i18n/jquery.ui.datepicker-ml.js b/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/i18n/jquery.ui.datepicker-ml.js
old mode 100755
new mode 100644
diff --git a/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/i18n/jquery.ui.datepicker-ms.js b/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/i18n/jquery.ui.datepicker-ms.js
old mode 100755
new mode 100644
diff --git a/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/i18n/jquery.ui.datepicker-nl.js b/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/i18n/jquery.ui.datepicker-nl.js
old mode 100755
new mode 100644
diff --git a/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/i18n/jquery.ui.datepicker-no.js b/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/i18n/jquery.ui.datepicker-no.js
old mode 100755
new mode 100644
diff --git a/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/i18n/jquery.ui.datepicker-pl.js b/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/i18n/jquery.ui.datepicker-pl.js
old mode 100755
new mode 100644
diff --git a/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/i18n/jquery.ui.datepicker-pt-BR.js b/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/i18n/jquery.ui.datepicker-pt-BR.js
old mode 100755
new mode 100644
diff --git a/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/i18n/jquery.ui.datepicker-pt.js b/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/i18n/jquery.ui.datepicker-pt.js
old mode 100755
new mode 100644
diff --git a/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/i18n/jquery.ui.datepicker-rm.js b/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/i18n/jquery.ui.datepicker-rm.js
old mode 100755
new mode 100644
diff --git a/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/i18n/jquery.ui.datepicker-ro.js b/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/i18n/jquery.ui.datepicker-ro.js
old mode 100755
new mode 100644
diff --git a/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/i18n/jquery.ui.datepicker-ru.js b/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/i18n/jquery.ui.datepicker-ru.js
old mode 100755
new mode 100644
diff --git a/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/i18n/jquery.ui.datepicker-sk.js b/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/i18n/jquery.ui.datepicker-sk.js
old mode 100755
new mode 100644
diff --git a/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/i18n/jquery.ui.datepicker-sl.js b/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/i18n/jquery.ui.datepicker-sl.js
old mode 100755
new mode 100644
diff --git a/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/i18n/jquery.ui.datepicker-sq.js b/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/i18n/jquery.ui.datepicker-sq.js
old mode 100755
new mode 100644
diff --git a/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/i18n/jquery.ui.datepicker-sr-SR.js b/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/i18n/jquery.ui.datepicker-sr-SR.js
old mode 100755
new mode 100644
diff --git a/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/i18n/jquery.ui.datepicker-sr.js b/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/i18n/jquery.ui.datepicker-sr.js
old mode 100755
new mode 100644
diff --git a/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/i18n/jquery.ui.datepicker-sv.js b/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/i18n/jquery.ui.datepicker-sv.js
old mode 100755
new mode 100644
diff --git a/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/i18n/jquery.ui.datepicker-ta.js b/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/i18n/jquery.ui.datepicker-ta.js
old mode 100755
new mode 100644
diff --git a/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/i18n/jquery.ui.datepicker-th.js b/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/i18n/jquery.ui.datepicker-th.js
old mode 100755
new mode 100644
diff --git a/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/i18n/jquery.ui.datepicker-tj.js b/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/i18n/jquery.ui.datepicker-tj.js
old mode 100755
new mode 100644
diff --git a/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/i18n/jquery.ui.datepicker-tr.js b/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/i18n/jquery.ui.datepicker-tr.js
old mode 100755
new mode 100644
diff --git a/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/i18n/jquery.ui.datepicker-uk.js b/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/i18n/jquery.ui.datepicker-uk.js
old mode 100755
new mode 100644
diff --git a/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/i18n/jquery.ui.datepicker-vi.js b/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/i18n/jquery.ui.datepicker-vi.js
old mode 100755
new mode 100644
diff --git a/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/i18n/jquery.ui.datepicker-zh-CN.js b/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/i18n/jquery.ui.datepicker-zh-CN.js
old mode 100755
new mode 100644
diff --git a/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/i18n/jquery.ui.datepicker-zh-HK.js b/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/i18n/jquery.ui.datepicker-zh-HK.js
old mode 100755
new mode 100644
diff --git a/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/i18n/jquery.ui.datepicker-zh-TW.js b/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/i18n/jquery.ui.datepicker-zh-TW.js
old mode 100755
new mode 100644
diff --git a/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/jquery-ui-1.8.11.custom.js b/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/jquery-ui-1.8.11.custom.js
old mode 100755
new mode 100644
diff --git a/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/jquery.effects.blind.js b/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/jquery.effects.blind.js
old mode 100755
new mode 100644
diff --git a/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/jquery.effects.bounce.js b/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/jquery.effects.bounce.js
old mode 100755
new mode 100644
diff --git a/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/jquery.effects.clip.js b/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/jquery.effects.clip.js
old mode 100755
new mode 100644
diff --git a/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/jquery.effects.core.js b/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/jquery.effects.core.js
old mode 100755
new mode 100644
diff --git a/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/jquery.effects.drop.js b/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/jquery.effects.drop.js
old mode 100755
new mode 100644
diff --git a/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/jquery.effects.explode.js b/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/jquery.effects.explode.js
old mode 100755
new mode 100644
diff --git a/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/jquery.effects.fade.js b/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/jquery.effects.fade.js
old mode 100755
new mode 100644
diff --git a/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/jquery.effects.fold.js b/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/jquery.effects.fold.js
old mode 100755
new mode 100644
diff --git a/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/jquery.effects.highlight.js b/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/jquery.effects.highlight.js
old mode 100755
new mode 100644
diff --git a/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/jquery.effects.pulsate.js b/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/jquery.effects.pulsate.js
old mode 100755
new mode 100644
diff --git a/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/jquery.effects.scale.js b/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/jquery.effects.scale.js
old mode 100755
new mode 100644
diff --git a/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/jquery.effects.shake.js b/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/jquery.effects.shake.js
old mode 100755
new mode 100644
diff --git a/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/jquery.effects.slide.js b/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/jquery.effects.slide.js
old mode 100755
new mode 100644
diff --git a/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/jquery.effects.transfer.js b/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/jquery.effects.transfer.js
old mode 100755
new mode 100644
diff --git a/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/jquery.ui.accordion.js b/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/jquery.ui.accordion.js
old mode 100755
new mode 100644
diff --git a/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/jquery.ui.autocomplete.js b/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/jquery.ui.autocomplete.js
old mode 100755
new mode 100644
diff --git a/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/jquery.ui.button.js b/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/jquery.ui.button.js
old mode 100755
new mode 100644
diff --git a/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/jquery.ui.core.js b/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/jquery.ui.core.js
old mode 100755
new mode 100644
diff --git a/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/jquery.ui.datepicker.js b/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/jquery.ui.datepicker.js
old mode 100755
new mode 100644
diff --git a/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/jquery.ui.dialog.js b/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/jquery.ui.dialog.js
old mode 100755
new mode 100644
diff --git a/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/jquery.ui.draggable.js b/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/jquery.ui.draggable.js
old mode 100755
new mode 100644
diff --git a/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/jquery.ui.droppable.js b/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/jquery.ui.droppable.js
old mode 100755
new mode 100644
diff --git a/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/jquery.ui.mouse.js b/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/jquery.ui.mouse.js
old mode 100755
new mode 100644
diff --git a/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/jquery.ui.position.js b/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/jquery.ui.position.js
old mode 100755
new mode 100644
diff --git a/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/jquery.ui.progressbar.js b/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/jquery.ui.progressbar.js
old mode 100755
new mode 100644
diff --git a/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/jquery.ui.resizable.js b/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/jquery.ui.resizable.js
old mode 100755
new mode 100644
diff --git a/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/jquery.ui.selectable.js b/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/jquery.ui.selectable.js
old mode 100755
new mode 100644
diff --git a/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/jquery.ui.slider.js b/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/jquery.ui.slider.js
old mode 100755
new mode 100644
diff --git a/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/jquery.ui.sortable.js b/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/jquery.ui.sortable.js
old mode 100755
new mode 100644
diff --git a/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/jquery.ui.tabs.js b/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/jquery.ui.tabs.js
old mode 100755
new mode 100644
diff --git a/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/jquery.ui.widget.js b/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/jquery.ui.widget.js
old mode 100755
new mode 100644
diff --git a/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/minified/jquery.effects.blind.min.js b/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/minified/jquery.effects.blind.min.js
old mode 100755
new mode 100644
diff --git a/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/minified/jquery.effects.bounce.min.js b/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/minified/jquery.effects.bounce.min.js
old mode 100755
new mode 100644
diff --git a/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/minified/jquery.effects.clip.min.js b/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/minified/jquery.effects.clip.min.js
old mode 100755
new mode 100644
diff --git a/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/minified/jquery.effects.core.min.js b/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/minified/jquery.effects.core.min.js
old mode 100755
new mode 100644
diff --git a/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/minified/jquery.effects.drop.min.js b/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/minified/jquery.effects.drop.min.js
old mode 100755
new mode 100644
diff --git a/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/minified/jquery.effects.explode.min.js b/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/minified/jquery.effects.explode.min.js
old mode 100755
new mode 100644
diff --git a/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/minified/jquery.effects.fade.min.js b/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/minified/jquery.effects.fade.min.js
old mode 100755
new mode 100644
diff --git a/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/minified/jquery.effects.fold.min.js b/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/minified/jquery.effects.fold.min.js
old mode 100755
new mode 100644
diff --git a/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/minified/jquery.effects.highlight.min.js b/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/minified/jquery.effects.highlight.min.js
old mode 100755
new mode 100644
diff --git a/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/minified/jquery.effects.pulsate.min.js b/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/minified/jquery.effects.pulsate.min.js
old mode 100755
new mode 100644
diff --git a/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/minified/jquery.effects.scale.min.js b/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/minified/jquery.effects.scale.min.js
old mode 100755
new mode 100644
diff --git a/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/minified/jquery.effects.shake.min.js b/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/minified/jquery.effects.shake.min.js
old mode 100755
new mode 100644
diff --git a/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/minified/jquery.effects.slide.min.js b/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/minified/jquery.effects.slide.min.js
old mode 100755
new mode 100644
diff --git a/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/minified/jquery.effects.transfer.min.js b/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/minified/jquery.effects.transfer.min.js
old mode 100755
new mode 100644
diff --git a/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/minified/jquery.ui.accordion.min.js b/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/minified/jquery.ui.accordion.min.js
old mode 100755
new mode 100644
diff --git a/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/minified/jquery.ui.autocomplete.min.js b/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/minified/jquery.ui.autocomplete.min.js
old mode 100755
new mode 100644
diff --git a/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/minified/jquery.ui.button.min.js b/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/minified/jquery.ui.button.min.js
old mode 100755
new mode 100644
diff --git a/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/minified/jquery.ui.core.min.js b/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/minified/jquery.ui.core.min.js
old mode 100755
new mode 100644
diff --git a/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/minified/jquery.ui.datepicker.min.js b/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/minified/jquery.ui.datepicker.min.js
old mode 100755
new mode 100644
diff --git a/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/minified/jquery.ui.dialog.min.js b/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/minified/jquery.ui.dialog.min.js
old mode 100755
new mode 100644
diff --git a/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/minified/jquery.ui.draggable.min.js b/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/minified/jquery.ui.draggable.min.js
old mode 100755
new mode 100644
diff --git a/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/minified/jquery.ui.droppable.min.js b/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/minified/jquery.ui.droppable.min.js
old mode 100755
new mode 100644
diff --git a/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/minified/jquery.ui.mouse.min.js b/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/minified/jquery.ui.mouse.min.js
old mode 100755
new mode 100644
diff --git a/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/minified/jquery.ui.position.min.js b/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/minified/jquery.ui.position.min.js
old mode 100755
new mode 100644
diff --git a/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/minified/jquery.ui.progressbar.min.js b/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/minified/jquery.ui.progressbar.min.js
old mode 100755
new mode 100644
diff --git a/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/minified/jquery.ui.resizable.min.js b/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/minified/jquery.ui.resizable.min.js
old mode 100755
new mode 100644
diff --git a/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/minified/jquery.ui.selectable.min.js b/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/minified/jquery.ui.selectable.min.js
old mode 100755
new mode 100644
diff --git a/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/minified/jquery.ui.slider.min.js b/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/minified/jquery.ui.slider.min.js
old mode 100755
new mode 100644
diff --git a/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/minified/jquery.ui.sortable.min.js b/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/minified/jquery.ui.sortable.min.js
old mode 100755
new mode 100644
diff --git a/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/minified/jquery.ui.tabs.min.js b/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/minified/jquery.ui.tabs.min.js
old mode 100755
new mode 100644
diff --git a/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/minified/jquery.ui.widget.min.js b/packages/jquery/jquery-ui-1.8.11/development-bundle/ui/minified/jquery.ui.widget.min.js
old mode 100755
new mode 100644
diff --git a/packages/jquery/jquery-ui-1.8.11/development-bundle/version.txt b/packages/jquery/jquery-ui-1.8.11/development-bundle/version.txt
old mode 100755
new mode 100644
diff --git a/packages/jquery/jquery-ui-1.8.11/js/jquery-ui-1.8.11.custom.min.js b/packages/jquery/jquery-ui-1.8.11/js/jquery-ui-1.8.11.custom.min.js
old mode 100755
new mode 100644
diff --git a/packages/jquery/plugins/jquery.menu.js b/packages/jquery/plugins/jquery.menu.js
old mode 100755
new mode 100644
diff --git a/packages/jquery/plugins/jsTree.v.1.0rc2/jquery.jstree.js b/packages/jquery/plugins/jsTree.v.1.0rc2/jquery.jstree.js
old mode 100755
new mode 100644
diff --git a/packages/jquery/plugins/jsTree.v.1.0rc2/jquery.jstree.min.js b/packages/jquery/plugins/jsTree.v.1.0rc2/jquery.jstree.min.js
old mode 100755
new mode 100644
diff --git a/packages/jquery/plugins/jsTree.v.1.0rc2/themes/default/d.gif b/packages/jquery/plugins/jsTree.v.1.0rc2/themes/default/d.gif
old mode 100755
new mode 100644
diff --git a/packages/jquery/plugins/jsTree.v.1.0rc2/themes/default/d.png b/packages/jquery/plugins/jsTree.v.1.0rc2/themes/default/d.png
old mode 100755
new mode 100644
diff --git a/packages/jquery/plugins/jsTree.v.1.0rc2/themes/default/jstree.css b/packages/jquery/plugins/jsTree.v.1.0rc2/themes/default/jstree.css
old mode 100755
new mode 100644
diff --git a/packages/jquery/plugins/jsTree.v.1.0rc2/themes/default/throbber.gif b/packages/jquery/plugins/jsTree.v.1.0rc2/themes/default/throbber.gif
old mode 100755
new mode 100644
diff --git a/packages/tcpdf/fonts/dejavu-fonts-ttf-2.30/AUTHORS b/packages/tcpdf/fonts/dejavu-fonts-ttf-2.30/AUTHORS
old mode 100755
new mode 100644
diff --git a/packages/tcpdf/fonts/dejavu-fonts-ttf-2.30/BUGS b/packages/tcpdf/fonts/dejavu-fonts-ttf-2.30/BUGS
old mode 100755
new mode 100644
diff --git a/packages/tcpdf/fonts/dejavu-fonts-ttf-2.30/LICENSE b/packages/tcpdf/fonts/dejavu-fonts-ttf-2.30/LICENSE
old mode 100755
new mode 100644
diff --git a/packages/tcpdf/fonts/dejavu-fonts-ttf-2.30/NEWS b/packages/tcpdf/fonts/dejavu-fonts-ttf-2.30/NEWS
old mode 100755
new mode 100644
diff --git a/packages/tcpdf/fonts/dejavu-fonts-ttf-2.30/README b/packages/tcpdf/fonts/dejavu-fonts-ttf-2.30/README
old mode 100755
new mode 100644
diff --git a/packages/tcpdf/fonts/dejavu-fonts-ttf-2.30/langcover.txt b/packages/tcpdf/fonts/dejavu-fonts-ttf-2.30/langcover.txt
old mode 100755
new mode 100644
diff --git a/packages/tcpdf/fonts/dejavu-fonts-ttf-2.30/unicover.txt b/packages/tcpdf/fonts/dejavu-fonts-ttf-2.30/unicover.txt
old mode 100755
new mode 100644
diff --git a/sql/civicrm.mysql b/sql/civicrm.mysql
index da50938..67854e1 100644
--- a/sql/civicrm.mysql
+++ b/sql/civicrm.mysql
@@ -4604,4 +4604,72 @@ CREATE TABLE civicrm_pledge_payment (
      CONSTRAINT FK_civicrm_pledge_payment_contribution_id FOREIGN KEY (contribution_id) REFERENCES civicrm_contribution(id) ON DELETE CASCADE  
 )  ENGINE=InnoDB DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci  ;
 
- 
\ No newline at end of file
+-- /*****   Civicrm Multi-Event Registration   ***********/ 
+
+-- /*******************************************************
+-- *
+-- * civicrm_event_carts
+-- *
+-- *******************************************************/
+CREATE TABLE civicrm_event_carts (
+
+
+     id int unsigned NOT NULL AUTO_INCREMENT  COMMENT 'Cart Id',
+     user_id int unsigned    COMMENT 'FK to civicrm_contact who created this
+cart',
+     completed tinyint   DEFAULT 0
+,
+    PRIMARY KEY ( id )
+
+
+,
+     CONSTRAINT FK_civicrm_event_carts_user_id FOREIGN KEY (user_id)
+REFERENCES civicrm_contact(id) ON DELETE SET NULL
+)  ENGINE=InnoDB DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci  ;
+
+-- /*******************************************************
+-- *
+-- * civicrm_events_in_carts
+-- *
+-- *******************************************************/
+CREATE TABLE civicrm_events_in_carts (
+
+
+     id int unsigned NOT NULL AUTO_INCREMENT  COMMENT 'Event In Cart Id',
+     event_id int unsigned    COMMENT 'FK to Event ID',
+     event_cart_id int unsigned    COMMENT 'FK to Event Cart ID'
+,
+    PRIMARY KEY ( id )
+
+
+,
+     CONSTRAINT FK_civicrm_events_in_carts_event_id FOREIGN KEY (event_id)
+REFERENCES civicrm_event(id) ON DELETE CASCADE,
+     CONSTRAINT FK_civicrm_events_in_carts_event_cart_id FOREIGN KEY
+(event_cart_id) REFERENCES civicrm_event_carts(id) ON DELETE CASCADE
+)  ENGINE=InnoDB DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci  ;
+
+-- /*******************************************************
+-- *
+-- * civicrm_events_in_carts_participants
+-- *
+-- *******************************************************/
+CREATE TABLE civicrm_events_in_carts_participants (
+
+
+     id int unsigned  AUTO_INCREMENT  ,
+     event_in_cart_id int unsigned NOT NULL   COMMENT 'FK to Event In Cart Id',
+     discount_amount int unsigned   DEFAULT 0 COMMENT 'Discount Amount',
+     cost int unsigned    COMMENT 'Cost',
+     fee_level int unsigned    COMMENT 'Fee Level',
+     participant_id int unsigned    COMMENT 'FK to civicrm_participant',
+     must_wait tinyint   DEFAULT 0 COMMENT 'On Waiting List'
+,
+    PRIMARY KEY ( id )
+
+
+,
+     CONSTRAINT FK_civicrm_events_in_carts_participants_event_in_cart_id FOREIGN KEY (event_in_cart_id) REFERENCES civicrm_events_in_carts(id) ON DELETE CASCADE,
+     CONSTRAINT FK_civicrm_events_in_carts_participants_participant_id FOREIGN KEY (participant_id) REFERENCES civicrm_participant(id) ON DELETE CASCADE
+)  ENGINE=InnoDB DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci  ;
+
diff --git a/templates/CRM/Activity/Form/Task.tpl b/templates/CRM/Activity/Form/Task.tpl
old mode 100755
new mode 100644
diff --git a/templates/CRM/Activity/Form/Task/Batch.tpl b/templates/CRM/Activity/Form/Task/Batch.tpl
old mode 100755
new mode 100644
diff --git a/templates/CRM/Activity/Form/Task/Delete.tpl b/templates/CRM/Activity/Form/Task/Delete.tpl
old mode 100755
new mode 100644
diff --git a/templates/CRM/Activity/Form/Task/PickProfile.tpl b/templates/CRM/Activity/Form/Task/PickProfile.tpl
old mode 100755
new mode 100644
diff --git a/templates/CRM/Admin/Form/Setting/Event.tpl b/templates/CRM/Admin/Form/Setting/Event.tpl
new file mode 100644
index 0000000..165806b
--- /dev/null
+++ b/templates/CRM/Admin/Form/Setting/Event.tpl
@@ -0,0 +1,44 @@
+{*
+ +--------------------------------------------------------------------+
+ | CiviCRM version 4.0                                                |
+ +--------------------------------------------------------------------+
+ | Copyright CiviCRM LLC (c) 2004-2011                                |
+ +--------------------------------------------------------------------+
+ | This file is a part of CiviCRM.                                    |
+ |                                                                    |
+ | CiviCRM is free software; you can copy, modify, and distribute it  |
+ | under the terms of the GNU Affero General Public License           |
+ | Version 3, 19 November 2007 and the CiviCRM Licensing Exception.   |
+ |                                                                    |
+ | CiviCRM is distributed in the hope that it will be useful, but     |
+ | WITHOUT ANY WARRANTY; without even the implied warranty of         |
+ | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.               |
+ | See the GNU Affero General Public License for more details.        |
+ |                                                                    |
+ | You should have received a copy of the GNU Affero General Public   |
+ | License and the CiviCRM Licensing Exception along                  |
+ | with this program; if not, contact CiviCRM LLC                     |
+ | at info[AT]civicrm[DOT]org. If you have questions about the        |
+ | GNU Affero General Public License or the licensing of CiviCRM,     |
+ | see the CiviCRM license FAQ at http://civicrm.org/licensing        |
+ +--------------------------------------------------------------------+
+*}
+{capture assign=docLink}{docURL page="Cart Checkout" text="CiviEvent Cart Checkout"}{/capture}
+<div class="crm-block crm-form-block">
+<div id="help">
+    {ts 1=$docLink}These settings are used to configure properties for the CiviEvent component. Please read the %1 documentation, and make sure you understand it before modifying default values.{/ts}
+</div>
+<div class="crm-submit-buttons">{include file="CRM/common/formButtons.tpl" location="top"}</div>                         
+      <table class="form-layout-compressed">
+        <tr class="crm-form-block-enable_cart">
+            <td class="label">{$form.enable_cart.label}</td><td>{$form.enable_cart.html}<br />
+            <span class="description">{ts}Check to enable the Event Cart checkout workflow.{/ts}</span></td>
+        </tr>
+        <tr class="crm-form-block-default_participant_profile">
+            <td class="label">{$form.default_participant_profile.label}</td><td>{$form.default_participant_profile.html}<br />
+            <span class="description">{ts}Used for any event not specifying a participant profile.{/ts}</span></td>
+        </tr>
+      </table>
+<div class="crm-submit-buttons">{include file="CRM/common/formButtons.tpl" location="bottom"}</div>     
+<div class="spacer"></div>
+</div>
diff --git a/templates/CRM/Campaign/Form/Gotv.tpl b/templates/CRM/Campaign/Form/Gotv.tpl
old mode 100755
new mode 100644
diff --git a/templates/CRM/Campaign/Form/Search.tpl b/templates/CRM/Campaign/Form/Search.tpl
old mode 100755
new mode 100644
diff --git a/templates/CRM/Campaign/Form/Search/Campaign.tpl b/templates/CRM/Campaign/Form/Search/Campaign.tpl
old mode 100755
new mode 100644
diff --git a/templates/CRM/Campaign/Form/Search/Common.tpl b/templates/CRM/Campaign/Form/Search/Common.tpl
old mode 100755
new mode 100644
diff --git a/templates/CRM/Campaign/Form/Search/EmptyResults.tpl b/templates/CRM/Campaign/Form/Search/EmptyResults.tpl
old mode 100755
new mode 100644
diff --git a/templates/CRM/Campaign/Form/Search/Petition.tpl b/templates/CRM/Campaign/Form/Search/Petition.tpl
old mode 100755
new mode 100644
diff --git a/templates/CRM/Campaign/Form/Search/Survey.tpl b/templates/CRM/Campaign/Form/Search/Survey.tpl
old mode 100755
new mode 100644
diff --git a/templates/CRM/Campaign/Form/Selector.tpl b/templates/CRM/Campaign/Form/Selector.tpl
old mode 100755
new mode 100644
diff --git a/templates/CRM/Campaign/Form/Task/Print.tpl b/templates/CRM/Campaign/Form/Task/Print.tpl
old mode 100755
new mode 100644
diff --git a/templates/CRM/Campaign/Form/Task/Reserve.tpl b/templates/CRM/Campaign/Form/Task/Reserve.tpl
old mode 100755
new mode 100644
diff --git a/templates/CRM/Campaign/Form/Task/Result.tpl b/templates/CRM/Campaign/Form/Task/Result.tpl
old mode 100755
new mode 100644
diff --git a/templates/CRM/Contribute/Form/Contribution/Main.tpl b/templates/CRM/Contribute/Form/Contribution/Main.tpl
index 2512b71..dec43fa 100644
--- a/templates/CRM/Contribute/Form/Contribution/Main.tpl
+++ b/templates/CRM/Contribute/Form/Contribution/Main.tpl
@@ -133,6 +133,7 @@ function clearAmountOther() {
 	    </div>
 	{/if}
 	    {assign var=n value=email-$bltID}
+	    {assign var=conf_n value=conf_email-$bltID}
 	    <div class="crm-section {$form.$n.name}-section">
 	    	<div class="label">{$form.$n.label}</div>
 	    	<div class="content">
@@ -140,6 +141,13 @@ function clearAmountOther() {
 	    	</div>
 	    	<div class="clear"></div> 
 	    </div>
+	    <div class="crm-section {$form.$conf_n.name}-section">
+	    	<div class="label">{$form.$conf_n.label}</div>
+	    	<div class="content">
+	    		{$form.$conf_n.html}
+	    	</div>
+	    	<div class="clear"></div> 
+	    </div>
 	
 	{if $form.is_for_organization}
 		<div class="crm-section {$form.is_for_organization.name}-section">
diff --git a/templates/CRM/Event/Cart/Form/Checkout/ConferenceEvents.tpl b/templates/CRM/Event/Cart/Form/Checkout/ConferenceEvents.tpl
new file mode 100644
index 0000000..9101466
--- /dev/null
+++ b/templates/CRM/Event/Cart/Form/Checkout/ConferenceEvents.tpl
@@ -0,0 +1,54 @@
+{include file="CRM/common/TrackingFields.tpl"}
+
+{capture assign='reqMark'}<span class="marker"  title="{ts}This field is required.{/ts}">*</span>{/capture}
+
+<h3>{ts 1=$mer_participant->display_name 2=$mer_participant->email}Choose Events For %1 (%2){/ts}</h3>
+
+{foreach from=$slot_fields key=slot_name item=field_name}
+  <fieldset>
+    <legend>
+      {$slot_name}
+    </legend>
+    <div class="slot_options">
+      <ul class="indented">
+        {$form.$field_name.html}
+        <span class="crm-clear-link">(<a href="#" title="unselect" onclick="unselectRadio('{$field_name}', '{$form.formName}'); return false;">{ts}clear{/ts}</a>)</span>
+      </ul>
+    </div>
+  </fieldset>
+{/foreach}    
+
+<script type="text/javascript">
+var session_options = {$session_options};
+{literal}
+for (var radio_id in session_options)
+{
+  var info = session_options[radio_id];
+  var label_sel = "label[for=" + radio_id + "]";
+  cj("#"+radio_id +","+ label_sel).wrapAll("<li>");
+  if (info.session_full) {
+    cj("#"+radio_id).attr('disabled', 'disabled');
+    cj("#"+radio_id).after('<span class="error">{/literal}{ts}Session is Full{/ts}{literal}: </span>');
+  }
+  var more = cj('<a href="#">{/literal}{ts}more info{/ts}{literal}</a>').click(function(event) {
+    event.preventDefault();
+    var nfo = cj(this).data("session_info");//F-!
+    cj("<div style='font-size: 90%;'>" + nfo.session_description + "</div>").dialog({
+      title: nfo.session_title,
+      resizable: false,
+      draggable: false,
+      width: 600,
+      modal: true
+    });
+  });
+  more.data("session_info", info);
+  cj(label_sel).append(" ", more);
+}
+{/literal}
+</script>
+
+<div id="crm-submit-buttons" class="crm-submit-buttons">
+  {include file="CRM/common/formButtons.tpl" location="bottom"}
+</div>
+
+{include file="CRM/Event/Cart/Form/viewCartLink.tpl"}
diff --git a/templates/CRM/Event/Cart/Form/Checkout/Participant.tpl b/templates/CRM/Event/Cart/Form/Checkout/Participant.tpl
new file mode 100644
index 0000000..5500c8a
--- /dev/null
+++ b/templates/CRM/Event/Cart/Form/Checkout/Participant.tpl
@@ -0,0 +1,31 @@
+  {assign var=event_id value=$participant->event_id}
+  {assign var=participant_id value=$participant->id}
+  <fieldset class="participant" id="event_{$event_id}_participant_{$participant_id}">
+    <legend>
+      {assign var=name value="event[`$event_id`][participant][`$participant_id`][number]"}
+      {$custom.$name}
+    </legend>
+	<div class="clearfix">
+          {assign var=pre value="event[`$event_id`][participant][`$participant_id`][customPre]"}
+          <div class="profile-group">
+          {include file="CRM/UF/Form/Block.tpl" fields=$custom.$pre form=$form.field.$participant_id}
+          </div>
+
+	  <div class="participant-info crm-section form-item">
+	    <div class="label">
+              {$form.event.$event_id.participant.$participant_id.email.label}
+	    </div>
+	    <div class="edit-value content">
+              {$form.event.$event_id.participant.$participant_id.email.html}
+	    </div>
+	  </div>
+
+          {assign var=post value="event[`$event_id`][participant][`$participant_id`][customPost]"}
+          <div style="clear:left"></div>
+          <div class="profile-group">
+          {include file="CRM/UF/Form/Block.tpl" fields=$custom.$post form=$form.field.$participant_id}
+          </div>
+	</div>
+    <!--if $form_participant->participant_index > 0-->
+    <a class="link-delete" href="#" onclick="delete_participant({$event_id}, {$participant_id}); return false;">{ts}Delete{/ts} {$form->name}</a>
+  </fieldset>
diff --git a/templates/CRM/Event/Cart/Form/Checkout/ParticipantsAndPrices.tpl b/templates/CRM/Event/Cart/Form/Checkout/ParticipantsAndPrices.tpl
new file mode 100644
index 0000000..ceba2ee
--- /dev/null
+++ b/templates/CRM/Event/Cart/Form/Checkout/ParticipantsAndPrices.tpl
@@ -0,0 +1,91 @@
+{include file="CRM/common/TrackingFields.tpl"}
+
+{capture assign='reqMark'}<span class="marker"  title="{ts}This field is required.{/ts}">*</span>{/capture}
+
+{if $contact}
+<div class="messages status">
+    {ts 1=$contact.display_name}Welcome %1{/ts}. (<a href="{crmURL p='civicrm/event/cart_checkout' q="&cid=0&reset=1"}" title="{ts}Click here to register a different person for this event.{/ts}">{ts 1=$contact.display_name}Not %1, or want to register a different person{/ts}</a>?)</div>
+{/if}
+
+{foreach from=$events_in_carts key=index item=event_in_cart}
+ {if !$event_in_cart.main_conference_event_id}
+  {assign var=event_id value=$event_in_cart->event_id}
+  <h3 class="event-title">
+    {$event_in_cart->event->title} ({$event_in_cart->event->start_date|date_format:"%m/%d/%Y %l:%M%p"})
+  </h3>
+  <fieldset class="event_form">
+    <div class="participants crm-section" id="event_{$event_in_cart->event_id}_participants">
+      {foreach from=$event_in_cart->participants item=participant}
+	{include file="CRM/Event/Cart/Form/Checkout/Participant.tpl"}
+      {/foreach}
+      <a class="link-add" href="#" onclick="add_participant({$event_in_cart->event_cart->id}, {$event_in_cart->event_id}); return false;">{ts}Add Another Participant{/ts}</a>
+    </div>
+    {if $event_in_cart->event->is_monetary }
+      <div class="price_choices crm-section">
+	{foreach from=$price_fields_for_event.$event_id key=price_index item=price_field_name}
+	  <div class="label">
+	    {$form.$price_field_name.label}
+	  </div>
+	  <div class="content">
+	    {$form.$price_field_name.html|replace:'/label>&nbsp;':'/label><br>'}
+	  </div>
+	{/foreach}
+      </div>
+    {else}
+      <p>{ts}There is no charge for this event.{/ts}</p>
+    {/if}
+  </fieldset>
+ {/if}
+{/foreach}
+
+<!--<div id="discount-entry" class="discount-entry">
+  <p>{$form.discountcode.label}: {$form.discountcode.html}</p>
+</div>-->
+
+<div id="crm-submit-buttons" class="crm-submit-buttons">
+  {include file="CRM/common/formButtons.tpl" location="bottom"}
+</div>
+
+{include file="CRM/Event/Cart/Form/viewCartLink.tpl"}
+
+{literal}
+<script type="text/javascript">
+//<![CDATA[
+function add_participant( cart_id, event_id ) {
+  var max_index = 0;
+  var matcher = new RegExp("event_" + event_id + "_participant_(\\d+)");
+  
+  cj('#event_' + event_id + '_participants .participant').each(
+    function(index) {
+      matches = matcher.exec(cj(this).attr('id'));
+      index = parseInt(matches[1]);
+      if (index > max_index)
+      {
+        max_index = index;
+      }
+    }
+  );
+
+  cj.get("/civicrm/ajax/event/add_participant_to_cart?&cart_id=" + cart_id + "&event_id=" + event_id, 
+    function(data) {
+      cj('#event_' + event_id + '_participants').append(data);
+    }
+  );
+}
+
+function delete_participant( event_id, participant_id )
+{
+  cj('#event_' + event_id + '_participant_' + participant_id).remove();
+  cj.get("/civicrm/ajax/event/remove_participant_from_cart?id=" + participant_id);
+}
+
+
+//XXX missing
+cj('#ajax_error').ajaxError(
+  function( e, xrh, settings, exception ) {
+    cj(this).append('<div class="error">{/literal}{ts}Error adding a participant at{/ts}{literal} ' + settings.url + ': ' + exception);
+  }
+);
+//]]>
+</script>
+{/literal}
diff --git a/templates/CRM/Event/Cart/Form/Checkout/Payment.tpl b/templates/CRM/Event/Cart/Form/Checkout/Payment.tpl
new file mode 100644
index 0000000..aad0e06
--- /dev/null
+++ b/templates/CRM/Event/Cart/Form/Checkout/Payment.tpl
@@ -0,0 +1,187 @@
+{include file="CRM/common/TrackingFields.tpl"}
+
+<table>
+  <thead>
+    <tr>
+      <th class="event-title">
+	{ts}Event{/ts}
+      </th>
+      <th class="participants-column">
+	{ts}Participants{/ts}
+      </th>
+      <th class="cost">
+	{ts}Price{/ts}
+      </th>
+      <th class="amount">
+	{ts}Total{/ts}
+      </th>
+    </tr>
+  </thead>
+  <tbody>
+    {foreach from=$line_items item=line_item}
+      <tr class="event-line-item {$line_item.class}">
+	<td class="event-title">
+	  {$line_item.event->title} ({$line_item.event->start_date})
+	</td>
+	<td class="participants-column">
+	  {$line_item.num_participants}<br/>
+	  {if $line_item.num_participants > 0}
+	    <div class="participants" style="padding-left: 10px;">
+	      {foreach from=$line_item.participants item=participant}
+			{$participant.display_name}<br />
+	      {/foreach}
+	    </div>
+	  {/if}
+	  {if $line_item.num_waiting_participants > 0}
+	    {ts}Waitlisted:{/ts}<br/>
+	    <div class="participants" style="padding-left: 10px;">
+	      {foreach from=$line_item.waiting_participants item=participant}
+			{$participant.display_name}<br />
+	      {/foreach}
+	    </div>
+	  {/if}
+	</td>
+	<td class="cost">
+	  {$line_item.cost|crmMoney:$currency|string_format:"%10s"}
+	</td>
+	<td class="amount">
+	  &nbsp;{$line_item.amount|crmMoney:$currency|string_format:"%10s"}
+	</td>
+      </tr>
+    {/foreach}
+  </tbody>
+  <tfoot>
+  {if $discounts}
+    <tr>
+      <td>
+      </td>
+      <td>
+      </td>
+      <td>
+	{ts}Subtotal:{/ts}
+      </td>
+      <td>
+	&nbsp;{$sub_total|crmMoney:$currency|string_format:"%10s"}
+      </td>
+    </tr>  
+  {foreach from=$discounts key=myId item=i}
+    <tr>
+      <td>{$i.title}
+      </td>
+      <td>
+      </td>
+      <td>
+      </td>
+      <td>
+   -{$i.amount|crmMoney:$currency|string_format:"%10s"}
+      </td>
+    </tr>
+   {/foreach} 
+   {/if} 
+    <tr>
+      <td>
+      </td>
+      <td>
+      </td>
+      <td class="total">
+	{ts}Total:{/ts}
+      </td>
+      <td class="total">
+	&nbsp;{$total|crmMoney:$currency|string_format:"%10s"}
+      </td>
+    </tr>
+  </tfoot>
+</table>
+{if $payment_required == true}
+<div class="crm-section {$form.is_pay_later.name}-section">	
+  <div class="label">{$form.is_pay_later.label}</div>
+  <div class="content">{$form.is_pay_later.html}
+  </div>
+  <div class="clear"></div> 
+</div>
+<div class="pay-later-instructions" style="display:none">
+  {$pay_later_instructions}
+</div>
+{include file='CRM/Core/BillingBlock.tpl'}
+{/if}
+{if $collect_billing_email == true}
+<div class="crm-section {$form.billing_contact_email.name}-section">	
+  <div class="label">{$form.billing_contact_email.label}</div>
+  <div class="content">{$form.billing_contact_email.html}
+  </div>
+  <div class="clear"></div> 
+</div>
+{/if}
+
+{if $administrator}
+<!--
+<div style="border: 1px solid blue; padding: 5px;">
+<b>{ts}Staff use only{/ts}</b>
+<div class="crm-section {$form.note.name}-section">
+  <div class="label">{$form.note.label}</div>
+  <div class="content">{$form.note.html}
+    <div class="description">{ts}Note that will be sent to the billing customer.{/ts}</div>
+  </div>
+  <div class="clear"></div> 
+</div>
+<div class="crm-section {$form.source.name}-section">
+  <div class="label">{$form.source.label}</div>
+  <div class="content">{$form.source.html}
+    <div class="description">{ts}Description of this transaction.{/ts}</div>
+  </div>
+  <div class="clear"></div> 
+</div>
+<div class="crm-section {$form.payment_type.name}-section">
+  <div class="label">{$form.payment_type.label}</div>
+  <div class="content">{$form.payment_type.html}
+    <span class="crm-clear-link">(<a href="#" title="unselect" onclick="unselectRadio('payment_type', '{$form.formName}'); return false;">{ts}clear{/ts}</a>)</span>
+  </div>
+  <div class="clear"></div> 
+</div>
+<div class="crm-section {$form.check_number.name}-section" style="display: none;">
+  <div class="label">{$form.check_number.label}</div>
+  <div class="content">{$form.check_number.html}</div>
+  <div class="clear"></div> 
+</div>
+<div class="crm-section {$form.is_pending.name}-section">
+  <div class="label">{$form.is_pending.label}</div>
+  <div class="content">{$form.is_pending.html}
+  </div>
+  <div class="clear"></div> 
+</div>
+</div>
+-->
+{/if}
+
+<script type="text/javascript">
+var pay_later_sel = "input#{$form.is_pay_later.name}";
+{literal}
+cj("document").ready(function() {
+  function refresh() {
+    var is_pay_later = cj(pay_later_sel).attr("checked");
+    cj(".credit_card_info-group").toggle(!is_pay_later);
+    cj(".pay-later-instructions").toggle(is_pay_later);
+    cj("div.billingNameInfo-section .description").html(is_pay_later ? "Enter the billing address at which you can be invoiced." : "Enter the name as shown on your credit or debit card, and the billing address for this card.");
+  }
+  cj("input#source").attr('disabled', 'disabled');
+
+  cj(pay_later_sel).change(function() {
+    refresh();
+  });
+  cj(".payment_type-section :radio").change(function() {
+    var sel = cj(this).attr("id");
+    cj(".check_number-section").toggle(
+        cj(this).is(":checked") &&
+        cj("label[for="+sel+"]").html() == "{/literal}{ts}Check{/ts}{literal}"
+    );
+  });
+  refresh();
+});
+{/literal}
+</script>
+
+<div id="crm-submit-buttons" class="crm-submit-buttons">
+  {include file="CRM/common/formButtons.tpl" location="bottom"}
+</div>
+
+{include file="CRM/Event/Cart/Form/viewCartLink.tpl"}
diff --git a/templates/CRM/Event/Cart/Form/Checkout/ThankYou.tpl b/templates/CRM/Event/Cart/Form/Checkout/ThankYou.tpl
new file mode 100644
index 0000000..da8aab9
--- /dev/null
+++ b/templates/CRM/Event/Cart/Form/Checkout/ThankYou.tpl
@@ -0,0 +1,164 @@
+{include file="CRM/common/TrackingFields.tpl"}
+
+<div class="crm-block crm-event-thankyou-form-block">
+  <p>
+    {ts 1=$site_name}This is your receipt of payment made for the following event registration made at %1.{/ts}
+  </p>
+  <p>
+    {ts 1=$transaction->trxn_id 2=$transaction->trxn_date|date_format:"%D %I:%M %p %Z"}Your order number is <strong>#%1</strong>. Please print this confirmation for your records. You will receieve a confirmation email with the information below.  Information about the workshops will be sent separately to each participant. Here's a summary of your transaction placed on %2:{/ts}
+  </p>
+  {if $pay_later_receipt && $is_pay_later}
+  <p>
+  {$pay_later_receipt}
+  </p>
+  {/if}
+  {if $payment_required}
+    <div class="crm-group billing_name_address-group">
+      <div class="header-dark">
+	{ts}Billing Name and Address{/ts}
+      </div>
+      <div class="crm-section no-label billing_name-section">
+		<div class="content">{$billing_name}</div>
+		<div class="clear"></div>
+      </div>
+      <div class="crm-section no-label billing_address-section">
+		<div class="content">
+		  {$billing_street_address}<br/>
+		  {$billing_city}, {$billing_state} {$billing_postal_code}
+		</div>
+		<div class="clear"></div>
+      </div>
+    </div>
+    {if !$is_pay_later}
+      <div class="crm-group credit_card-group">
+        <div class="header-dark">
+                  {ts}Credit Card Information{/ts}
+        </div>
+        <div class="crm-section no-label credit_card_details-section">
+                  <div class="content">{$credit_card_type}</div>
+                  <div class="content">{$credit_card_number}</div>
+                  <div class="content">{ts}Expires{/ts}: {$credit_card_exp_date.M}/{$credit_card_exp_date.Y}
+                    <div class="clear"></div>
+                  </div>
+        </div>
+      </div>
+    {/if}
+  {/if}
+  <table>
+    <thead>
+      <tr style="border-bottom: 1px solid #ccc">
+		<th class="event-title">
+		  {ts}Event{/ts}
+		</th>
+		<th class="participants-column">
+		  {ts}Participants{/ts}
+		</th>
+		<th class="cost">
+		  {ts}Price{/ts}
+		</th>
+		<th class="amount">
+		  {ts}Total{/ts}
+		</th>
+      </tr>
+    </thead>
+    <tbody>
+      {foreach from=$line_items item=line_item}
+      <tr class="event-line-item {$line_item.class}">
+		<td class="event-info">
+		  <div class="event-title"><strong>{$line_item.event->title}</strong></div>
+		  {if $line_item.event->is_show_location}
+		    <div class="event-location">
+			{if $line_item.location.address.1.name}
+			  {$line_item.location.address.1.name}
+			{/if}
+			{if $line_item.location.address.1.street_address}
+			  {$line_item.location.address.1.street_address}
+			{/if}
+			{if $line_item.location.address.1.supplemental_address_1}
+			  {$line_item.location.address.1.supplemental_address_1}
+			{/if}
+			{if $line_item.location.address.1.supplemental_address_2}
+			  {$line_item.location.address.1.supplemental_address_2}
+			{/if}
+			{if $line_item.location.address.1.city}
+			  {$line_item.location.address.1.city} {$line_item.location.address.1.postal_code}
+			{/if}
+		    </div>
+		  {/if}{*End of isShowLocation condition*}
+		  <div class="event-data">
+		    {$line_item.event->start_date|date_format:"%D %I:%M %p"} -
+		    {$line_item.event->end_date|date_format:"%I:%M %p"}
+		  </div>
+		</td>
+		<td class="participants-column">
+		  {$line_item.num_participants}<br />
+		  {if $line_item.num_participants > 0}
+			<div class="participants" style="padding-left: 10px;">
+			  {foreach from=$line_item.participants item=participant}
+			    {$participant.display_name}<br />
+			  {/foreach}
+			</div>
+		  {/if}
+		  {if $line_item.num_waiting_participants > 0}
+			{ts}Waitlisted:{/ts}<br/>
+			<div class="participants" style="padding-left: 10px;">
+			  {foreach from=$line_item.waiting_participants item=participant}
+			    {$participant.display_name}<br />
+			  {/foreach}
+			</div>
+		  {/if}
+		</td>
+		<td class="cost">
+		  {$line_item.cost|crmMoney:$currency|string_format:"%10s"}
+		</td>
+		<td class="amount">
+		  &nbsp;{$line_item.amount|crmMoney:$currency|string_format:"%10s"}
+		</td>
+      </tr>
+      {/foreach}
+    </tbody>
+    <tfoot>
+      {if $discounts}
+	<tr>
+	  <td>
+	  </td>
+	  <td>
+	  </td>
+	  <td>
+	    {ts}Subtotal{/ts}:
+	  </td>
+	  <td>
+	    &nbsp;{$sub_total|crmMoney:$currency|string_format:"%10s"}
+	  </td>
+	</tr>
+	{foreach from=$discounts key=myId item=i}
+	  <tr>
+	    <td>
+	      {$i.title}
+	    </td>
+	    <td>
+	    </td>
+	    <td>
+	    </td>
+	    <td>
+	      -{$i.amount|crmMoney:$currency|string_format:"%10s"}
+	    </td>
+	  </tr>
+	{/foreach}
+      {/if}
+      <tr>
+	<td>
+	</td>
+	<td>
+	</td>
+	<td class="total">
+	  <strong>{ts}Total{/ts}:</strong>
+	</td>
+	<td class="total">
+	  <strong>&nbsp;{$total|crmMoney:$currency|string_format:"%10s"}</strong>
+	</td>
+      </tr>
+    </tfoot>
+  </table>
+  <p>{ts 1=$site_contact}If you have questions about the status of your registration or purchase please contact us at %1.{/ts}</p>
+</div>
diff --git a/templates/CRM/Event/Cart/Form/viewCartLink.tpl b/templates/CRM/Event/Cart/Form/viewCartLink.tpl
new file mode 100644
index 0000000..8273b12
--- /dev/null
+++ b/templates/CRM/Event/Cart/Form/viewCartLink.tpl
@@ -0,0 +1,4 @@
+{capture assign=cartURL}{crmURL p='civicrm/event/view_cart' q="reset=1"}{/capture}
+<div>
+{ts 1=$cartURL}<a href='%1'>Return to Cart</a>{/ts}
+</div>
diff --git a/templates/CRM/Event/Cart/Page/AddToCart.tpl b/templates/CRM/Event/Cart/Page/AddToCart.tpl
new file mode 100644
index 0000000..235e992
--- /dev/null
+++ b/templates/CRM/Event/Cart/Page/AddToCart.tpl
@@ -0,0 +1,3 @@
+<div>
+  Foo!
+</div>
diff --git a/templates/CRM/Event/Cart/Page/ViewCart.tpl b/templates/CRM/Event/Cart/Page/ViewCart.tpl
new file mode 100644
index 0000000..3a01f9d
--- /dev/null
+++ b/templates/CRM/Event/Cart/Page/ViewCart.tpl
@@ -0,0 +1,29 @@
+<table>
+  <thead>
+    <tr>
+      <th>
+      </th>
+	  <th>
+      </th>
+    </tr>
+  </thead>
+  <tbody>
+    {foreach from=$events_in_carts item=event_in_cart}
+     {if !$event_in_cart.main_conference_event_id}
+      <tr>
+	<td>
+	  <a href="{crmURL p='civicrm/event/info' q="reset=1&id=`$event_in_cart.event.id`"}" title="{ts}View event info page{/ts}" class="bold">{$event_in_cart.event.title}</a>
+	</td>
+	<td>
+	  <a title="Remove From Cart" class="action-item" href="{crmURL p='civicrm/event/remove_from_cart' q="reset=1&id=`$event_in_cart.event.id`"}">{ts}Remove{/ts}</a>
+	</td>
+      </tr>
+     {/if}
+    {/foreach}
+  </tbody>
+</table>
+{if $events_count > 0}
+        <a href="{crmURL p='civicrm/event/cart_checkout' }" title="Check Out" class="button crm-check-out-button"><span>{ts}Check Out{/ts}</span></a>
+<br /><br />
+{/if}
+<a href="{crmURL p="civicrm/event/ical" q="reset=1&page=1&html=1"}">&laquo; Back to Event List</a>
diff --git a/templates/CRM/Event/Form/ManageEvent/Conference.tpl b/templates/CRM/Event/Form/ManageEvent/Conference.tpl
new file mode 100644
index 0000000..1ba4e56
--- /dev/null
+++ b/templates/CRM/Event/Form/ManageEvent/Conference.tpl
@@ -0,0 +1,83 @@
+{*
+ +--------------------------------------------------------------------+
+ | CiviCRM version 3.4                                                |
+ +--------------------------------------------------------------------+
+ | Copyright CiviCRM LLC (c) 2004-2011                                |
+ +--------------------------------------------------------------------+
+ | This file is a part of CiviCRM.                                    |
+ |                                                                    |
+ | CiviCRM is free software; you can copy, modify, and distribute it  |
+ | under the terms of the GNU Affero General Public License           |
+ | Version 3, 19 November 2007 and the CiviCRM Licensing Exception.   |
+ |                                                                    |
+ | CiviCRM is distributed in the hope that it will be useful, but     |
+ | WITHOUT ANY WARRANTY; without even the implied warranty of         |
+ | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.               |
+ | See the GNU Affero General Public License for more details.        |
+ |                                                                    |
+ | You should have received a copy of the GNU Affero General Public   |
+ | License and the CiviCRM Licensing Exception along                  |
+ | with this program; if not, contact CiviCRM LLC                     |
+ | at info[AT]civicrm[DOT]org. If you have questions about the        |
+ | GNU Affero General Public License or the licensing of CiviCRM,     |
+ | see the CiviCRM license FAQ at http://civicrm.org/licensing        |
+ +--------------------------------------------------------------------+
+*}
+<div class="crm-block crm-form-block crm-event-conference-form-block">
+<div class="crm-submit-buttons">
+   {include file="CRM/common/formButtons.tpl" location="top"}
+</div>
+
+    <table class="form-layout">
+       <tr class="crm-event-conference-form-block-title">
+	  <td class="label">{$form.title.label}</td>
+	  <td>{$form.title.html}</td>
+       </tr>	
+    </table>
+
+    <div id="parent_event_name">
+      <table id="parent_event_name" class="form-layout">
+          <tr class="crm-event-conference-form-block-parent_event_name">
+             <td class="label">{$form.parent_event_name.label}</td>
+             <td>
+                 {$form.parent_event_name.html|crmReplace:class:huge}
+             </td>
+          </tr>
+      </table>
+    </div>
+
+    <div id="conference_slot_id">
+      <table id="conference_slot_id" class="form-layout">
+          <tr class="crm-event-conference-form-block-slot_label_id">
+             <td class="label">{$form.slot_label_id.label}</td>
+             <td>{if $action == 2}{include file='CRM/Core/I18n/Dialog.tpl' table='civicrm_event' field='slot_label_id' id=$id}{/if}{$form.slot_label_id.html|crmReplace:class:big}
+             </td>
+          </tr>
+      </table>
+    </div>
+    <div class="crm-submit-buttons">
+        {include file="CRM/common/formButtons.tpl" location="bottom"}
+    </div>
+</div>
+
+{include file="CRM/common/formNavigate.tpl"}
+
+{literal}
+<script type="text/javascript"> 
+var eventUrl = "{/literal}{crmURL p='civicrm/ajax/event'}{literal}";
+
+cj('input#parent_event_name').autocomplete(
+    eventUrl,
+    {
+        width : 280,
+        selectFirst : false,
+        matchContains: true,
+    }
+).result( function(event, data, formatted)
+    {
+        cj( "input#parent_event_name" ).val( data[0] );
+        cj( "input[name=parent_event_id]" ).val( data[1] );
+    }
+).bind( 'click', function( ) { cj( "input#parent_event_name" ).val(''); });
+</script>
+{/literal}
diff --git a/templates/CRM/Event/Page/DashBoard.tpl b/templates/CRM/Event/Page/DashBoard.tpl
index cc64e27..bb8906f 100644
--- a/templates/CRM/Event/Page/DashBoard.tpl
+++ b/templates/CRM/Event/Page/DashBoard.tpl
@@ -110,6 +110,7 @@
         		    <li><a title="Location" class="action-item-wrap {if NOT $values.is_show_location} disabled{/if}" href="{crmURL p='civicrm/event/manage/location' q="reset=1&action=update&id=`$id`"}">{ts}Location{/ts}</a></li>
         		    <li><a title="Fees" class="action-item {if NOT $values.is_monetary} disabled{/if}" href="{crmURL p='civicrm/event/manage/fee' q="reset=1&action=update&id=`$id`"}">{ts}Fees{/ts}</a></li>
         		    <li><a title="Online Registration" class="action-item-wrap {if NOT $values.is_online_registration} disabled{/if}" href="{crmURL p='civicrm/event/manage/registration' q="reset=1&action=update&id=`$id`"}">{ts}Online Registration{/ts}</a></li>
+        		    <li><a title="Conference Slots" class="action-item-wrap {if NOT $values.is_subevent} disabled{/if}" href="{crmURL p='civicrm/event/manage/conference' q="reset=1&action=update&id=`$id`"}">{ts}Conference Slots{/ts}</a></li>
         		    <li><a title="Tell a Friend" class="action-item-wrap {if NOT $values.friend} disabled{/if}" href="{crmURL p='civicrm/event/manage/friend' q="reset=1&action=update&id=`$id`"}">{ts}Tell a Friend{/ts}</a></li>
         	 </span>
         	 </div>
diff --git a/templates/CRM/Event/Page/EventInfo.tpl b/templates/CRM/Event/Page/EventInfo.tpl
index 6f2930c..3e8dcfe 100644
--- a/templates/CRM/Event/Page/EventInfo.tpl
+++ b/templates/CRM/Event/Page/EventInfo.tpl
@@ -145,6 +145,7 @@
 	{if $allowRegistration}
         <div class="action-link section register_link-section">
             <a href="{$registerURL}" title="{$registerText}" class="button crm-register-button"><span>{$registerText}</span></a>
+            <a href="{crmURL p='civicrm/event/view_cart' q="reset=1"}" class="button"><span>{ts}View Cart and Check Out{/ts}</span></a>
         </div>
     {/if}
     { if $event.is_public }
diff --git a/templates/CRM/Event/Page/ICalendar.tpl b/templates/CRM/Event/Page/ICalendar.tpl
index 104ad33..80acd47 100644
--- a/templates/CRM/Event/Page/ICalendar.tpl
+++ b/templates/CRM/Event/Page/ICalendar.tpl
@@ -34,6 +34,7 @@
     <th>{ts}Location{/ts}</th>
     <th>{ts}Category{/ts}</th>
     <th>{ts}Email{/ts}</th>
+    {if $registration_links}<th>{ts}Register{/ts}</th>{/if}
 </tr>
 </thead>
 {foreach from=$events key=uid item=event}
@@ -53,6 +54,7 @@
     <td>{if $event.is_show_location EQ 1 AND $event.location}{$event.location}{else}{ts}(not available){/ts}{/if}</td>
     <td>{if $event.event_type}{$event.event_type}{else}&nbsp;{/if}</td>
     <td>{if $event.contact_email}<a href="mailto:{$event.contact_email}">{$event.contact_email}</a>{else}&nbsp;{/if}</td>
+    {if $registration_links}<td><a href="{$event.registration_link}">{$event.registration_link_text}</a></td>{/if}
 </tr>
 {/foreach}
 </table>
diff --git a/templates/CRM/Event/Page/ManageEvent.tpl b/templates/CRM/Event/Page/ManageEvent.tpl
index a2d3777..19387eb 100644
--- a/templates/CRM/Event/Page/ManageEvent.tpl
+++ b/templates/CRM/Event/Page/ManageEvent.tpl
@@ -90,6 +90,7 @@
         		    <li><a title="Location" class="action-item-wrap {if NOT $row.is_show_location} disabled{/if}" href="{crmURL p='civicrm/event/manage/location' q="reset=1&action=update&id=`$row.id`"}">{ts}Location{/ts}</a></li>
         		    <li><a title="Fees" class="action-item {if NOT $row.is_monetary} disabled{/if}" href="{crmURL p='civicrm/event/manage/fee' q="reset=1&action=update&id=`$row.id`"}">{ts}Fees{/ts}</a></li>
         		    <li><a title="Online Registration" class="action-item-wrap {if NOT $row.is_online_registration} disabled{/if}" href="{crmURL p='civicrm/event/manage/registration' q="reset=1&action=update&id=`$row.id`"}">{ts}Online Registration{/ts}</a></li>
+			    <li><a title="Conference Slots" class="action-item-wrap {if NOT $row.slot_label_id} disabled{/if}" href="{crmURL p='civicrm/event/manage/conference' q="reset=1&action=update&id=`$row.id`"}">{ts}Conference Slots{/ts}</a></li>
         		    <li><a title="Tell a Friend" class="action-item-wrap {if NOT $row.friend} disabled{/if}" href="{crmURL p='civicrm/event/manage/friend' q="reset=1&action=update&id=`$row.id`"}">{ts}Tell a Friend{/ts}</a></li>
 			</ul> 
         	    </span>
diff --git a/templates/CRM/common/stateCountry.tpl b/templates/CRM/common/stateCountry.tpl
index 203d117..88834ae 100644
--- a/templates/CRM/common/stateCountry.tpl
+++ b/templates/CRM/common/stateCountry.tpl
@@ -28,11 +28,16 @@
 {foreach from=$config->stateCountryMap item=stateCountryMap}
 {if $stateCountryMap.country && $stateCountryMap.state_province}
 {literal}
+function id_or_name(id)
+{
+    if (cj("#"+id).length) return "#"+id;
+    return "#"+cj("[name='"+id+"']").attr('id');
+}
 cj(function()
 {
 {/literal}
-        countryID       = "#{$stateCountryMap.country}"
-	    stateProvinceID = "#{$stateCountryMap.state_province}"
+        countryID       = id_or_name("{$stateCountryMap.country}");
+	    stateProvinceID = id_or_name("{$stateCountryMap.state_province}");
         callbackURL     = "{crmURL p='civicrm/ajax/jqState' h=0}"
 {literal}
 	cj(countryID).chainSelect(stateProvinceID, callbackURL, null );
@@ -44,8 +49,8 @@ cj(function()
 cj(function()
 {
 {/literal}
-	    stateProvinceID = "#{$stateCountryMap.state_province}"
-        countyID       = "#{$stateCountryMap.county}"
+	    stateProvinceID = id_or_name("{$stateCountryMap.state_province}");
+        countyID       = id_or_name("{$stateCountryMap.county}");
         callbackURL     = "{crmURL p='civicrm/ajax/jqCounty' h=0}"
 {literal}
 	cj(stateProvinceID).chainSelect(countyID, callbackURL, null );

