fmsystem-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Fmsystem-commits] [9888] svn merge -r 9609:9887


From: Alexander Stevenson
Subject: [Fmsystem-commits] [9888] svn merge -r 9609:9887
Date: Tue, 21 Aug 2012 07:37:51 +0000

Revision: 9888
          http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=9888
Author:   andvare
Date:     2012-08-21 07:37:50 +0000 (Tue, 21 Aug 2012)
Log Message:
-----------
svn merge -r 9609:9887

Modified Paths:
--------------
    branches/stavangerkommune/activitycalendar/inc/class.soactivity.inc.php
    branches/stavangerkommune/activitycalendar/inc/class.soarena.inc.php
    branches/stavangerkommune/activitycalendar/inc/class.socontactperson.inc.php
    branches/stavangerkommune/activitycalendar/inc/class.sogroup.inc.php
    branches/stavangerkommune/activitycalendar/inc/class.soorganization.inc.php
    branches/stavangerkommune/activitycalendar/inc/class.uiactivities.inc.php
    branches/stavangerkommune/activitycalendar/inc/class.uiarena.inc.php
    branches/stavangerkommune/activitycalendar/inc/class.uicommon.inc.php
    branches/stavangerkommune/activitycalendar/inc/class.uiorganization.inc.php
    branches/stavangerkommune/activitycalendar/inc/model/class.activity.inc.php
    branches/stavangerkommune/activitycalendar/inc/model/class.arena.inc.php
    branches/stavangerkommune/activitycalendar/inc/model/class.group.inc.php
    
branches/stavangerkommune/activitycalendar/inc/model/class.organization.inc.php
    branches/stavangerkommune/activitycalendar/setup/phpgw_no.lang
    branches/stavangerkommune/activitycalendar/setup/setup.inc.php
    branches/stavangerkommune/activitycalendar/setup/tables_current.inc.php
    branches/stavangerkommune/activitycalendar/setup/tables_update.inc.php
    branches/stavangerkommune/activitycalendar/templates/base/activity.php
    
branches/stavangerkommune/activitycalendar/templates/base/activity_list_partial.php
    branches/stavangerkommune/activitycalendar/templates/base/dashboard.php
    branches/stavangerkommune/activitycalendar/templates/base/organization.php
    
branches/stavangerkommune/activitycalendar/templates/base/organization_list_changed.php
    
branches/stavangerkommune/activitycalendarfrontend/inc/class.uiactivity.inc.php
    branches/stavangerkommune/activitycalendarfrontend/setup/phpgw_no.lang
    branches/stavangerkommune/activitycalendarfrontend/setup/setup.inc.php
    
branches/stavangerkommune/activitycalendarfrontend/templates/base/activity.php
    
branches/stavangerkommune/activitycalendarfrontend/templates/base/activity_edit.php
    
branches/stavangerkommune/activitycalendarfrontend/templates/base/activity_edit_step_1.php
    
branches/stavangerkommune/activitycalendarfrontend/templates/base/activity_new.php
    
branches/stavangerkommune/activitycalendarfrontend/templates/base/activity_new_step_1.php
    
branches/stavangerkommune/activitycalendarfrontend/templates/base/organization_edit.php
    
branches/stavangerkommune/booking/inc/class.socompleted_reservation_export.inc.php
    
branches/stavangerkommune/booking/inc/class.socompleted_reservation_export_file.inc.php
    branches/stavangerkommune/booking/inc/class.uicommon.inc.php
    branches/stavangerkommune/booking/setup/phpgw_no.lang
    branches/stavangerkommune/booking/setup/setup.inc.php
    branches/stavangerkommune/booking/setup/tables_current.inc.php
    branches/stavangerkommune/booking/setup/tables_update.inc.php
    branches/stavangerkommune/controller/inc/class.menu.inc.php
    branches/stavangerkommune/controller/inc/class.socase.inc.php
    branches/stavangerkommune/controller/inc/class.socheck_item.inc.php
    branches/stavangerkommune/controller/inc/class.socheck_list.inc.php
    branches/stavangerkommune/controller/inc/class.socommon.inc.php
    branches/stavangerkommune/controller/inc/class.socontrol.inc.php
    branches/stavangerkommune/controller/inc/class.socontrol_group.inc.php
    branches/stavangerkommune/controller/inc/class.socontrol_group_list.inc.php
    branches/stavangerkommune/controller/inc/class.socontrol_item.inc.php
    branches/stavangerkommune/controller/inc/class.socontrol_item_list.inc.php
    branches/stavangerkommune/controller/inc/class.socontrol_item_option.inc.php
    branches/stavangerkommune/controller/inc/class.sodocument.inc.php
    branches/stavangerkommune/controller/inc/class.soprocedure.inc.php
    branches/stavangerkommune/controller/inc/class.uicalendar.inc.php
    branches/stavangerkommune/controller/inc/class.uicase.inc.php
    branches/stavangerkommune/controller/inc/class.uicheck_list.inc.php
    
branches/stavangerkommune/controller/inc/class.uicheck_list_for_component.inc.php
    branches/stavangerkommune/controller/inc/class.uicontrol.inc.php
    branches/stavangerkommune/controller/inc/class.uicontrol_group.inc.php
    
branches/stavangerkommune/controller/inc/class.uicontrol_group_component.inc.php
    branches/stavangerkommune/controller/inc/class.uicontrol_item.inc.php
    branches/stavangerkommune/controller/inc/class.uicontrol_location.inc.php
    branches/stavangerkommune/controller/inc/class.uidocument.inc.php
    branches/stavangerkommune/controller/inc/class.uiprocedure.inc.php
    
branches/stavangerkommune/controller/inc/component/class.date_generator.inc.php
    
branches/stavangerkommune/controller/inc/component/class.month_calendar.inc.php
    
branches/stavangerkommune/controller/inc/component/class.year_calendar.inc.php
    branches/stavangerkommune/controller/inc/hook_home.inc.php
    branches/stavangerkommune/controller/inc/model/class.check_list.inc.php
    branches/stavangerkommune/controller/inc/model/class.component.inc.php
    branches/stavangerkommune/controller/inc/model/class.control.inc.php
    branches/stavangerkommune/controller/inc/model/class.control_area.inc.php
    branches/stavangerkommune/controller/inc/model/class.control_item.inc.php
    branches/stavangerkommune/controller/js/controller/ajax.js
    
branches/stavangerkommune/controller/js/controller/ajax_control_to_component.js
    branches/stavangerkommune/controller/js/yahoo/common.js
    
branches/stavangerkommune/controller/js/yahoo/register_control_to_component2.js
    branches/stavangerkommune/controller/setup/phpgw_no.lang
    branches/stavangerkommune/controller/setup/setup.inc.php
    branches/stavangerkommune/controller/setup/tables_current.inc.php
    branches/stavangerkommune/controller/setup/tables_update.inc.php
    
branches/stavangerkommune/controller/templates/base/add_component_to_control.xsl
    
branches/stavangerkommune/controller/templates/base/add_component_to_control_group.xsl
    
branches/stavangerkommune/controller/templates/base/calendar/select_buildings_on_property.xsl
    
branches/stavangerkommune/controller/templates/base/calendar/select_my_locations.xsl
    
branches/stavangerkommune/controller/templates/base/calendar/view_calendar_month.xsl
    
branches/stavangerkommune/controller/templates/base/calendar/view_calendar_month_for_locations.xsl
    
branches/stavangerkommune/controller/templates/base/calendar/view_calendar_year.xsl
    
branches/stavangerkommune/controller/templates/base/calendar/view_calendar_year_for_locations.xsl
    
branches/stavangerkommune/controller/templates/base/case/create_case_message.xsl
    
branches/stavangerkommune/controller/templates/base/case/view_case_message.xsl
    
branches/stavangerkommune/controller/templates/base/check_list/add_check_list.xsl
    
branches/stavangerkommune/controller/templates/base/check_list/check_list_tab_menu.xsl
    
branches/stavangerkommune/controller/templates/base/check_list/edit_check_list.xsl
    
branches/stavangerkommune/controller/templates/base/check_list/view_cases_for_check_list.xsl
    
branches/stavangerkommune/controller/templates/base/check_list/view_control_info.xsl
    
branches/stavangerkommune/controller/templates/base/check_list/view_open_cases.xsl
    branches/stavangerkommune/controller/templates/base/component.xsl
    branches/stavangerkommune/controller/templates/base/control/control.xsl
    branches/stavangerkommune/controller/templates/base/control/control_tabs.xsl
    
branches/stavangerkommune/controller/templates/base/control_group/control_group.xsl
    
branches/stavangerkommune/controller/templates/base/control_group/control_group_items.xsl
    
branches/stavangerkommune/controller/templates/base/control_item/control_item.xsl
    
branches/stavangerkommune/controller/templates/base/control_item/control_item_option.xsl
    
branches/stavangerkommune/controller/templates/base/control_location/control_location_tabs.xsl
    
branches/stavangerkommune/controller/templates/base/control_location/control_locations.xsl
    
branches/stavangerkommune/controller/templates/base/control_location/register_control_to_component.xsl
    
branches/stavangerkommune/controller/templates/base/control_location/register_control_to_location.xsl
    
branches/stavangerkommune/controller/templates/base/control_location/view_locations_for_control.xsl
    branches/stavangerkommune/controller/templates/base/css/base.css
    branches/stavangerkommune/controller/templates/base/datatable.xsl
    
branches/stavangerkommune/controller/templates/base/procedure/procedure_documents.xsl
    
branches/stavangerkommune/controller/templates/base/procedure/procedure_item.xsl
    
branches/stavangerkommune/controller/templates/base/procedure/procedure_tabs.xsl
    
branches/stavangerkommune/controller/templates/base/view_component_for_control.xsl
    
branches/stavangerkommune/controller/templates/base/view_component_for_control_group.xsl
    branches/stavangerkommune/phpgwapi/inc/class.custom_fields.inc.php
    branches/stavangerkommune/phpgwapi/inc/class.translation.inc.php
    branches/stavangerkommune/phpgwapi/inc/functions.inc.php
    branches/stavangerkommune/phpgwapi/setup/phpgw_no.lang
    
branches/stavangerkommune/phpgwapi/templates/activitycalendar/css/frontend.css
    branches/stavangerkommune/phpgwapi/templates/activitycalendar/head.tpl
    branches/stavangerkommune/phpgwapi/templates/base/yui_phpgw_i18n.xsl
    branches/stavangerkommune/property/inc/class.bobudget.inc.php
    branches/stavangerkommune/property/inc/class.bocommon.inc.php
    branches/stavangerkommune/property/inc/class.boentity.inc.php
    branches/stavangerkommune/property/inc/class.bogeneric.inc.php
    branches/stavangerkommune/property/inc/class.boinvoice.inc.php
    branches/stavangerkommune/property/inc/class.bolocation.inc.php
    branches/stavangerkommune/property/inc/class.bolookup.inc.php
    branches/stavangerkommune/property/inc/class.boproject.inc.php
    branches/stavangerkommune/property/inc/class.botts.inc.php
    branches/stavangerkommune/property/inc/class.boworkorder.inc.php
    branches/stavangerkommune/property/inc/class.custom_fields.inc.php
    branches/stavangerkommune/property/inc/class.menu.inc.php
    branches/stavangerkommune/property/inc/class.notify.inc.php
    branches/stavangerkommune/property/inc/class.soXport.inc.php
    branches/stavangerkommune/property/inc/class.sobudget.inc.php
    branches/stavangerkommune/property/inc/class.soentity.inc.php
    branches/stavangerkommune/property/inc/class.sogeneric.inc.php
    branches/stavangerkommune/property/inc/class.soinvoice.inc.php
    branches/stavangerkommune/property/inc/class.solocation.inc.php
    branches/stavangerkommune/property/inc/class.soproject.inc.php
    branches/stavangerkommune/property/inc/class.soresponsible.inc.php
    branches/stavangerkommune/property/inc/class.soworkorder.inc.php
    branches/stavangerkommune/property/inc/class.uibudget.inc.php
    branches/stavangerkommune/property/inc/class.uicommon.inc.php
    branches/stavangerkommune/property/inc/class.uientity.inc.php
    branches/stavangerkommune/property/inc/class.uigeneric.inc.php
    branches/stavangerkommune/property/inc/class.uiinvoice.inc.php
    branches/stavangerkommune/property/inc/class.uilocation.inc.php
    branches/stavangerkommune/property/inc/class.uiproject.inc.php
    branches/stavangerkommune/property/inc/class.uiworkorder.inc.php
    
branches/stavangerkommune/property/inc/custom/default/hent_maaler_nr_til_besikt_rapport.php
    branches/stavangerkommune/property/inc/import/default/Import_fra_BKK_csv
    
branches/stavangerkommune/property/inc/import/default/cvs_import_kunstoversikt_bkb
    branches/stavangerkommune/property/inc/import/default/efaktura_dnb_xml
    branches/stavangerkommune/property/js/yahoo/invoice.consume.js
    branches/stavangerkommune/property/js/yahoo/project.edit.js
    branches/stavangerkommune/property/setup/default_records.inc.php
    branches/stavangerkommune/property/setup/phpgw_no.lang
    branches/stavangerkommune/property/setup/setup.inc.php
    branches/stavangerkommune/property/setup/tables_current.inc.php
    branches/stavangerkommune/property/setup/tables_update.inc.php
    branches/stavangerkommune/property/templates/base/attributes_form.xsl
    branches/stavangerkommune/property/templates/base/generic.xsl
    branches/stavangerkommune/property/templates/base/project.xsl
    branches/stavangerkommune/registration/inc/class.uipending.inc.php
    branches/stavangerkommune/registration/js/yahoo/pending.index.js
    branches/stavangerkommune/registration/templates/base/pending_users.xsl
    branches/stavangerkommune/rental/inc/class.uicommon.inc.php

Added Paths:
-----------
    branches/stavangerkommune/activitycalendar/js/activitycalendar/jquery.js
    branches/stavangerkommune/activitycalendarfrontend/images/
    
branches/stavangerkommune/controller/inc/component/class.check_list_status_info.inc.php
    
branches/stavangerkommune/controller/inc/component/class.check_list_status_manager.inc.php
    
branches/stavangerkommune/controller/inc/component/class.status_agg_month_info.inc.php
    
branches/stavangerkommune/controller/inc/component/class.year_calendar_agg.inc.php
    
branches/stavangerkommune/controller/inc/helper/class.check_list_status_updater.inc.php
    branches/stavangerkommune/controller/js/controller/jquery-ui.custom.min.js
    
branches/stavangerkommune/controller/js/controller/jquery-ui.custom.min_bac.js
    
branches/stavangerkommune/controller/templates/base/calendar/calendar_filters.xsl
    
branches/stavangerkommune/controller/templates/base/calendar/check_list_status_manager.xsl
    
branches/stavangerkommune/controller/templates/base/calendar/nav_calendar_month.xsl
    
branches/stavangerkommune/controller/templates/base/calendar/nav_calendar_year.xsl
    branches/stavangerkommune/controller/templates/base/check_list/add_case.xsl
    branches/stavangerkommune/controller/templates/base/css/jquery-ui.custom.css
    
branches/stavangerkommune/controller/templates/base/css/jquery-ui.custom_bac.css
    branches/stavangerkommune/phpgwapi/inc/class.uicommon.inc.php
    branches/stavangerkommune/phpgwapi/js/yahoo/common.js
    branches/stavangerkommune/phpgwapi/js/yahoo/datatable.js
    
branches/stavangerkommune/phpgwapi/templates/activitycalendar/css/reset-fonts-grids.css
    
branches/stavangerkommune/phpgwapi/templates/activitycalendar/images/hjelp.gif
    branches/stavangerkommune/phpgwapi/templates/base/datatable_common.xsl
    branches/stavangerkommune/property/inc/class.uigeneric_test.inc.php
    branches/stavangerkommune/property/inc/export/default/El_anlegg_LRS

Removed Paths:
-------------
    branches/stavangerkommune/controller/inc/class.socontrol_area.inc.php
    branches/stavangerkommune/controller/inc/class.uicommon.inc.php
    branches/stavangerkommune/controller/inc/class.uicontrol_item_option.inc.php
    
branches/stavangerkommune/controller/inc/helper/class.check_list_status_info.inc.php
    
branches/stavangerkommune/controller/inc/helper/class.check_list_status_manager.inc.php
    
branches/stavangerkommune/controller/inc/helper/class.status_agg_month_info.inc.php
    branches/stavangerkommune/controller/inc/helper/class.status_checker.inc.php
    branches/stavangerkommune/controller/inc/model/class.schedule.inc.php
    
branches/stavangerkommune/controller/js/controller/jquery-ui-1.8.20.custom.min.js
    branches/stavangerkommune/controller/js/controller/jquery-ui.custom.min.js
    
branches/stavangerkommune/controller/templates/base/calendar/check_list_status_checker.xsl
    
branches/stavangerkommune/controller/templates/base/check_list/register_case.xsl
    
branches/stavangerkommune/controller/templates/base/css/jquery-ui-1.8.20.custom.css
    branches/stavangerkommune/controller/templates/base/css/jquery-ui.custom.css
    branches/stavangerkommune/registration/inc/class.uicommon.inc.php
    branches/stavangerkommune/registration/js/yahoo/common.js
    branches/stavangerkommune/registration/templates/base/common.xsl

Property Changed:
----------------
    branches/stavangerkommune/
    
branches/stavangerkommune/property/inc/custom/default/hent_maaler_nr_til_besikt_rapport.php
    branches/stavangerkommune/property/inc/import/default/Import_fra_BKK_csv


Property changes on: branches/stavangerkommune
___________________________________________________________________
Modified: svn:mergeinfo
   - /trunk:9468-9608
   + /trunk:9468-9608,9610-9887

Modified: 
branches/stavangerkommune/activitycalendar/inc/class.soactivity.inc.php
===================================================================
--- branches/stavangerkommune/activitycalendar/inc/class.soactivity.inc.php     
2012-08-21 07:22:01 UTC (rev 9887)
+++ branches/stavangerkommune/activitycalendar/inc/class.soactivity.inc.php     
2012-08-21 07:37:50 UTC (rev 9888)
@@ -66,6 +66,7 @@
                        'get_activities'                => true,
                        'get_organizations'     => true,
                        'get_groups'                    => true,
+                        'remove_old_activities'         => true,
                );
        
        /**
@@ -162,7 +163,7 @@
                if(isset($filters['new_activities']))
                {
                        if(!isset($filters['activity_state']) || 
(isset($filters['activity_state']) && $filters['activity_state'] == 'all')){
-                               $filter_clauses[] = "activity.state=1 OR 
activity.state=2";
+                               $filter_clauses[] = "(activity.state=1 OR 
activity.state=2)";
                        }
                        if(isset($filters['activity_state']) && 
$filters['activity_state'] != 'all'){
                                $activity_state = 
$this->marshal($filters['activity_state'],'int');
@@ -268,7 +269,8 @@
                        $columns[] = 'activity.special_adaptation';
                        $columns[] = 'activity.secret';
                        $columns[] = 'activity.frontend';
-                       $columns[] = 'activity.new_org';                        
+                       $columns[] = 'activity.new_org';
+                       $columns[] = 'activity.new_group';                      
                        
                        $cols = implode(',',$columns);
                }
@@ -341,7 +343,8 @@
                        'contact_person_2_zip = '          . 
$this->marshal($activity->get_contact_person_2_zip(), 'string'),
                        'special_adaptation = '                 
.($activity->get_special_adaptation() ? "true" : "false"),
                        'frontend = '                   
.($activity->get_frontend() ? "true" : "false"),
-                       'new_org = '                    
.($activity->get_new_org() ? "true" : "false")
+                       'new_org = '                    
.($activity->get_new_org() ? "true" : "false"),
+                       'new_group = '                  
.($activity->get_new_group() ? "true" : "false")
                );
                
                //var_dump('UPDATE activity_activity SET ' . join(',', $values) 
. " WHERE id=$id");
@@ -449,10 +452,11 @@
                        
$activity->set_contact_person_2_zip($this->unmarshal($this->db->f('contact_person_2_zip'),
 'string'));
                        
$activity->set_frontend($this->unmarshal($this->db->f('frontend', 'bool')));
                        
$activity->set_new_org($this->unmarshal($this->db->f('new_org', 'bool')));
+                       
$activity->set_new_group($this->unmarshal($this->db->f('new_group', 'bool')));
                        
                        if($activity->get_group_id() && 
$activity->get_group_id() > 0)
                        {
-                               if($activity->get_new_org())
+                               if($activity->get_new_group())
                                {
                                        $contacts = 
activitycalendar_sogroup::get_instance()->get_contacts_local($activity->get_group_id());
                                        
$activity->set_contact_persons($contacts);
@@ -482,6 +486,7 @@
                        }
                        
                }
+
                return $activity;
        }
        
@@ -615,6 +620,20 @@
                return $result;
        }
        
+        function get_office_description($office_id)
+       {
+            $result = "Ingen";
+            if($office_id != null)
+            {
+               $sql = "SELECT description FROM bb_office where id=$office_id";
+                var_dump($sql);
+               $this->db->query($sql, __LINE__, __FILE__);
+               while($this->db->next_record()){
+                    $result = $this->db->f('description');
+               }
+            }
+            return $result;
+       }
        
        function get_target_name($target_id)
        {
@@ -719,22 +738,24 @@
                        $whereclause_date = "AND last_change_date > 
{$from_date}";
                }
                $activities = array();
-               $sql = "SELECT * FROM activity_activity where state in(3,5) 
{$whereclause_date}";
+               $sql = "SELECT * FROM activity_activity where state in (3,5) 
{$whereclause_date}";
                $this->db->query($sql, __LINE__, __FILE__);
                while ($this->db->next_record())
                {                       
+                   $gr = $this->db->f('group_id');
                        $activities[]= array
                        (
                                'id'                            => (int) 
$this->db->f('id'),
                                'title'                         => $soap ? 
$this->db->f('title',true) : utf8_decode($this->db->f('title',true)),
-                               'organization_id'       => 
$this->db->f('organization_id',true),
+                               'organization_id'       => 
$this->db->f('organization_id'),
                                'group_id'                      => 
$this->db->f('group_id'),
-                               'district'                      => 
$this->db->f('district',true),
+                               'district'                      => 
$this->db->f('district'),
                                'category'                      => 
$this->db->f('category'),
-                               'state'                         => 
$this->db->f('state',true),
+                               'state'                         => 
$this->db->f('state'),
                                'target'                        => 
$this->db->f('target'),
                                'arena'                         => 
$this->db->f('arena'),
-                               'time'                          => $soap ? 
$this->db->f('time') : utf8_decode($this->db->f('time')),
+                           'internal_arena'    => 
$this->db->f('internal_arena'),
+                               'time'                          => $soap ? 
$this->db->f('time',true) : utf8_decode($this->db->f('time',true)),
                                'contact_person_1'      => 
$this->db->f('contact_person_1'),
                                'contact_person_2'      => 
$this->db->f('contact_person_2'),
                                'special_adaptation'=> 
$this->db->f('special_adaptation'),
@@ -743,8 +764,8 @@
 
                foreach ($activities as &$activity)
                {
-                               if($activity['group_id'] && 
$activity['group_id'] =! '' && $activity['group_id'] != 0)
-                               {
+                               if($activity['group_id'] && 
!$activity['group_id'] == '' && !$activity['group_id'] == 0)
+                               {   
                                        $activity['group_info']                 
= $this->get_group_info($activity['group_id']);
                                        $activity['organization_info']  = 
$this->get_org_info($activity['group_info']['organization_id']);
                                }
@@ -757,6 +778,7 @@
                                $activity['category_name']              = $soap 
? $this->get_category_name($activity['category']) : 
utf8_decode($this->get_category_name($activity['category']));
                                $activity['description']                = 
$this->get_activity_description($activity['organization_id'],$activity['group_id']);
                                $activity['arena_info']                 = 
$this->get_arena_info($activity['arena']);
+                               $activity['internal_arena_info']= 
$this->get_internal_arena_info($activity['internal_arena']);
                                $activity['contact_person']             = 
$this->get_contact_person($activity['organization_id'],$activity['group_id'],$activity['contact_person_1']);
                }
 //_debug_array($activities);
@@ -929,6 +951,23 @@
                return $result;
        }
        
+       function get_internal_arena_info($arena_id)
+       {
+               $result = array();
+               if($arena_id)
+               {
+                       $arena_id = (int)$arena_id;
+                       $this->db->query("SELECT id, name, street FROM 
bb_building WHERE id={$arena_id}", __LINE__, __FILE__);
+                       $this->db->next_record();
+                       $result = array
+                       (
+                               'arena_name' => $this->soap ? 
$this->db->f('name') : utf8_decode($this->db->f('name')),
+                               'address' => $this->soap ? 
$this->db->f('street') : utf8_decode($this->db->f('street'))
+                       );
+               }
+               return $result;
+       }
+       
        function get_statuscodes()
        {
                $statuscodes[] = array('id' => '0', 'name' => 
utf8_decode('Ingen'));
@@ -1104,17 +1143,9 @@
                $email = $org_info['email'];
                $description = $org_info['description'];
                $street = $org_info['street'];
-               $zip = $org_info['zip'];
-               if($zip && strlen($zip) > 5)
-               {
-                       $zip_code = substr($zip,0,4);
-                       $city = substr($zip, 5);
-               }
-               else
-               {
-                       $zip_code = '';
-                       $city = '';
-               }
+               $streetnumber = $org_info['streetnumber'];
+               $zip_code = $org_info['zip'];
+               $city = $org_info['postaddress'];
                $district = $org_info['district'];
                $status = $org_info['status'];
                $original_org_id = $org_info['original_org_id'];
@@ -1129,8 +1160,9 @@
                $columns[] = 'email';
                $columns[] = 'description';
                $columns[] = 'address';
-               //$columns[] = 'zip_code';
-               //$columns[] = 'city';
+               $columns[] = 'addressnumber';
+               $columns[] = 'zip_code';
+               $columns[] = 'city';
                $columns[] = 'orgno';
                $columns[] = 'district';
                $columns[] = 'change_type';
@@ -1143,8 +1175,9 @@
                $values[] = "'{$email}'";
                $values[] = "'{$description}'";
                $values[] = "'{$street}'";
-               //$values[] = "'{$zip_code}'";
-               //$values[] = "'{$city}'";
+               $values[] = "'{$streetnumber}'";
+               $values[] = "'{$zip_code}'";
+               $values[] = "'{$city}'";
                $values[] = "'{$orgnr}'";
                $values[] = "'{$district}'";
                $values[] = "'{$status}'";
@@ -1344,58 +1377,23 @@
        
        function get_activities_for_update($org_id, $group = false)
        {
-               $activities = array();
+               $activity_ids = array();
                if($group)
                {
-                       $sql = "SELECT * FROM activity_activity WHERE new_org 
AND group_id={$org_id}";
+                       $sql = "SELECT id FROM activity_activity WHERE 
new_group AND group_id={$org_id}";
                }
                else
                {
-                       $sql = "SELECT * FROM activity_activity WHERE new_org 
AND organization_id={$org_id}";
+                       $sql = "SELECT id FROM activity_activity WHERE new_org 
AND organization_id={$org_id}";
                }
-               //var_dump($sql);
+
                $this->db->query($sql, __LINE__, __FILE__);
                while ($this->db->next_record())
-               {                       
-                       $activity = new activitycalendar_activity((int) 
$this->db->f('id'));
-
-                       
$activity->set_title($this->unmarshal($this->db->f('title'), 'string'));
-                       
$activity->set_organization_id($this->unmarshal($this->db->f('organization_id'),
 'int'));
-                       
$activity->set_group_id($this->unmarshal($this->db->f('group_id'), 'int'));
-                       
$activity->set_district($this->unmarshal($this->db->f('district'), 'string'));
-                       
$activity->set_office($this->unmarshal($this->db->f('office'), 'int'));
-                       
$activity->set_category($this->unmarshal($this->db->f('category'), 'int'));
-                       
$activity->set_state($this->unmarshal($this->db->f('state'), 'int'));
-                       
$activity->set_target($this->unmarshal($this->db->f('target'), 'string'));
-                       
$activity->set_description($this->unmarshal($this->db->f('description'), 
'string'));
-                       
$activity->set_arena($this->unmarshal($this->db->f('arena'), 'string'));
-                       
$activity->set_internal_arena($this->unmarshal($this->db->f('internal_arena'), 
'string'));
-                       
$activity->set_time($this->unmarshal($this->db->f('time'), 'string'));
-                       
$activity->set_last_change_date($this->unmarshal($this->db->f('last_change_date'),
 'int'));
-                       
$activity->set_special_adaptation($this->unmarshal($this->db->f('special_adaptation',
 'bool')));
-                       
$activity->set_secret($this->unmarshal($this->db->f('secret'), 'string'));
-                       
$activity->set_contact_person_2_address($this->unmarshal($this->db->f('contact_person_2_address'),
 'string'));
-                       
$activity->set_contact_person_2_zip($this->unmarshal($this->db->f('contact_person_2_zip'),
 'string'));
-                       
$activity->set_frontend($this->unmarshal($this->db->f('frontend', 'bool')));
-                       
$activity->set_new_org($this->unmarshal($this->db->f('new_org', 'bool')));
-                       
-                       if($activity->get_group_id() && 
$activity->get_group_id() > 0)
-                       {
-                               $contacts = 
activitycalendar_sogroup::get_instance()->get_contacts($activity->get_group_id());
-                               $activity->set_contact_persons($contacts);
-                               $org_tmp = 
activitycalendar_sogroup::get_instance()->get_orgid_from_group($activity->get_group_id());
-                               $activity->set_organization_id($org_tmp);
-                       }
-                       else if($activity->get_organization_id() && 
$activity->get_organization_id() > 0)
-                       {
-                               $contacts = 
activitycalendar_soorganization::get_instance()->get_contacts($activity->get_organization_id());
-                               $activity->set_contact_persons($contacts);
-                       }
-                       
-                       $activities[] = $activity;
+               {
+                   $activity_ids[] = $this->db->f('id');
                }
                
-               return $activities;
+               return $activity_ids;
        }
        
        function get_connected_activities($org_id)
@@ -1439,8 +1437,75 @@
                $id = intval($activity_id);
                $org_id = intval($organization_id);
                
-               $result = $this->db->query("UPDATE activity_activity SET 
organization_id={$org_id} WHERE id={$id}", __LINE__,__FILE__);
+                $result = $this->db->query("UPDATE activity_activity SET 
organization_id={$org_id} WHERE id={$id}", __LINE__,__FILE__);
 
                return isset($result);
        }
+        
+        function get_activities_without_groups()
+        {
+            $activities = array();
+            $sql_activities = "select a.*, o.description as org_desc from 
activity_activity a, bb_organization o where (a.group_id is null or a.group_id 
= 0) and o.id = a.organization_id";
+            $this->db->query($sql_activities, __LINE__, __FILE__);
+            while($this->db->next_record())
+            {                
+                $activity_id = $this->db->f('id');
+                $activity_title = $this->db->f('title');
+                $activity_organization = $this->db->f('organization_id');
+                $description = $this->db->f('org_desc');
+                
+                $activities[] = array(
+                    'id'=>$activity_id,
+                    'title'=>$activity_title,
+                    'organization'=>$activity_organization,
+                    'description'=>$description
+                );
+            }
+            return $activities;
+        }
+        
+        /*
+         * Function to be run once.
+         * Generates new groups based on activity where group is not 
registered.
+         * Adds new group to booking
+         */
+        function generate_groups()
+        {
+            //TODO
+        }
+        
+                
+        function remove_old_activities()
+        {
+            $sql = "delete from activity_activity where id in 
(1293,1294,1297,1299)"; //1293,1294,1297,1299
+            $result = $this->db->query($sql, __LINE__, __FILE__);
+            
+            return isset($result);
+        }
+        
+        function save_with_no_changes($activity)
+        {
+            $id = intval($activity->get_id());
+            $ts_now = strtotime('now');
+                       
+            $values = "last_change_date = " . $this->marshal($ts_now, 'int');
+
+            $result = $this->db->query("UPDATE activity_activity SET {$values} 
WHERE id={$id}", __LINE__,__FILE__);
+
+            return isset($result);
+        }
+        
+        function update_activity_group($activity_id, $group_id)
+        {
+            $id = intval($activity_id);
+            $g_id = intval($group_id);
+                       
+            $values = "group_id = " . $g_id;
+            var_dump("UPDATE activity_activity SET {$values} WHERE id={$id}");
+            //die;
+
+            $result = $this->db->query("UPDATE activity_activity SET {$values} 
WHERE id={$id}", __LINE__,__FILE__);
+
+            return isset($result);
+        }
 }

Modified: branches/stavangerkommune/activitycalendar/inc/class.soarena.inc.php
===================================================================
--- branches/stavangerkommune/activitycalendar/inc/class.soarena.inc.php        
2012-08-21 07:22:01 UTC (rev 9887)
+++ branches/stavangerkommune/activitycalendar/inc/class.soarena.inc.php        
2012-08-21 07:37:50 UTC (rev 9888)
@@ -127,6 +127,9 @@
                        $columns[] = 'arena.id';
                        $columns[] = 'arena.arena_name';
                        $columns[] = 'arena.address';
+                       $columns[] = 'arena.addressnumber';
+                       $columns[] = 'arena.zip_code';
+                       $columns[] = 'arena.city';
                        $columns[] = 'arena.internal_arena_id';
                        $columns[] = 'arena.active';
                        
@@ -158,6 +161,9 @@
 
                        
$arena->set_arena_name($this->unmarshal($this->db->f('arena_name'), 'string'));
                        
$arena->set_address($this->unmarshal($this->db->f('address'), 'string'));
+                       
$arena->set_addressnumber($this->unmarshal($this->db->f('addressnumber'), 
'string'));
+                       
$arena->set_zip_code($this->unmarshal($this->db->f('zip_code'), 'string'));
+                       $arena->set_city($this->unmarshal($this->db->f('city'), 
'string'));
                        
$arena->set_internal_arena_id($this->unmarshal($this->db->f('internal_arena_id'),
 'int'));
                        
$arena->set_active($this->unmarshal($this->db->f('active'), 'bool'));
                }
@@ -259,6 +265,9 @@
                $values = array(
                        'arena_name = '         . 
$this->marshal($arena->get_arena_name(), 'string'),
                        'address = '     . 
$this->marshal($arena->get_address(), 'string'),
+               'addressnumber = '     . 
$this->marshal($arena->get_addressnumber(), 'string'),
+               'zip_code = '     . $this->marshal($arena->get_zip_code(), 
'string'),
+               'city = '     . $this->marshal($arena->get_city(), 'string'),
                        'internal_arena_id =  '     . 
$this->marshal($arena->get_internal_arena_id(), 'int'),
                        'active = '     . $this->marshal(($arena->is_active() ? 
'true' : 'false'), 'bool'),
                );

Modified: 
branches/stavangerkommune/activitycalendar/inc/class.socontactperson.inc.php
===================================================================
--- 
branches/stavangerkommune/activitycalendar/inc/class.socontactperson.inc.php    
    2012-08-21 07:22:01 UTC (rev 9887)
+++ 
branches/stavangerkommune/activitycalendar/inc/class.socontactperson.inc.php    
    2012-08-21 07:37:50 UTC (rev 9888)
@@ -406,4 +406,36 @@
        $result = $this->db->query($sql, __LINE__, __FILE__);
                return isset($result);
        }
+        
+        function add_new_group_contact($contact)
+       {
+            $name = $contact->get_name();
+            $phone = $contact->get_phone();
+            $mail = $contact->get_email();
+            $group_id = $contact->get_group_id();
+
+            $columns[] = 'name';
+            $columns[] = 'phone';
+            $columns[] = 'email';
+            $columns[] = 'group_id';
+            $cols = implode(',',$columns);
+
+            $values[] = "'{$name}'";
+            $values[] = "'{$phone}'";
+            $values[] = "'{$mail}'";
+            $values[] = $group_id;
+            $vals = implode(',',$values);
+
+            $sql = "INSERT INTO bb_group_contact ({$cols}) VALUES ({$vals})";
+            $result = $this->db->query($sql, __LINE__, __FILE__);
+            
+            if(isset($result))
+            {
+                return $this->db->get_last_insert_id('bb_group_contact', 'id');
+            }
+            else
+            {
+                return 0;
+            }
+       }
 }
\ No newline at end of file

Modified: branches/stavangerkommune/activitycalendar/inc/class.sogroup.inc.php
===================================================================
--- branches/stavangerkommune/activitycalendar/inc/class.sogroup.inc.php        
2012-08-21 07:22:01 UTC (rev 9887)
+++ branches/stavangerkommune/activitycalendar/inc/class.sogroup.inc.php        
2012-08-21 07:37:50 UTC (rev 9888)
@@ -87,9 +87,9 @@
                if(isset($filters['new_groups'])){
                        $use_local_group = true;
                        unset($filter_clauses);
-                       $filter_clauses[] = "activity_group.change_type = 'new' 
OR activity_group.change_type = 'change' ";
-                       if(isset($filters[$this->get_id_field_name()])){
-                               $id = 
$this->marshal($filters[$this->get_id_field_name()],'int');
+                       $filter_clauses[] = "(activity_group.change_type = 
'new' OR activity_group.change_type = 'change') ";
+                       if(isset($filters['group_id'])){
+                               $id = 
$this->marshal($filters['group_id'],'int');
                                $filter_clauses[] = "activity_group.id = {$id}";
                        }
                }
@@ -115,6 +115,7 @@
                                $columns[] = 'activity_group.organization_id';
                                $columns[] = 'activity_group.change_type';
                                $columns[] = 'activity_group.transferred';
+                               $columns[] = 'activity_group.original_group_id';
                                
                                $dir = $ascending ? 'ASC' : 'DESC';
                                $order = "ORDER BY activity_group.id $dir";
@@ -177,18 +178,92 @@
        {
                return false;
        }
-
+       
+       function update_group_description($group_id, $desc)
+       {
+               $sql = "UPDATE bb_group SET description='{$desc}' WHERE 
ID={$group_id}";
+                $result = $this->db->query($sql, __LINE__, __FILE__);
+               if(isset($result))
+               {
+                       return true;
+               }
+               else
+               {
+                       return false;
+               }
+       }
+       
+       function update_group_contact($contact)
+       {
+           $id=intval($contact['original_id']);
+           $name=$contact['name'];
+           $phone=$contact['phone'];
+           $mail=$contact['mail'];
+           
+           $sql = "UPDATE bb_group_contact SET NAME='{$name}', 
PHONE='{$phone}', EMAIL='{$mail}' WHERE id={$id}";
+           $result = $this->db->query($sql, __LINE__, __FILE__);
+               if(isset($result))
+               {
+                       return true;
+               }
+               else
+               {
+                       return false;
+               }
+       }
+       
+    function add_group_contact_local($contact)
+       {
+               $name = $contact['name'];
+               $phone = $contact['phone'];
+               $mail = $contact['mail'];
+               $original_id = $contact['original_id'];
+               $group_id = $contact['group_id'];
+               
+               $columns[] = 'name';
+               $columns[] = 'phone';
+               $columns[] = 'email';
+               $columns[] = 'organization_id';
+               $columns[] = 'group_id';
+               $columns[] = 'address';
+               $columns[] = 'zipcode'; 
+               $columns[] = 'city';
+               $columns[] = 'original_id';
+               $cols = implode(',',$columns);
+               
+               $values[] = "'{$name}'";
+               $values[] = "'{$phone}'";
+               $values[] = "'{$mail}'";
+               $values[] = "''";
+               $values[] = $group_id;
+               $values[] = "''";
+               $values[] = "''";
+               $values[] = "''";
+               $values[] = $original_id;
+               $vals = implode(',',$values);
+               
+               //var_dump("INSERT INTO activity_contact_person ({$cols}) 
VALUES ({$vals})");
+               $sql = "INSERT INTO activity_contact_person ({$cols}) VALUES 
({$vals})";
+       $result = $this->db->query($sql, __LINE__, __FILE__);
+               return isset($result);
+       }
+       
        public function get_id_field_name($extended_info = false)
        {
                if(!$extended_info)
                {
-                       $ret = 'id';
+                       $ret = array
+                       (
+                               'table'                 => 'activity_group', // 
alias
+                               'field'                 => 'id',
+                               'translated'    => 'id'
+                       );
                }
                else
                {
                        $ret = array
                        (
-                               'table'                 => 'group', // alias
+                               'table'                 => 'activity_group', // 
alias
                                'field'                 => 'id',
                                'translated'    => 'id'
                        );
@@ -238,6 +313,20 @@
                return $result;
        }
        
+       function get_orgid_from_group_local($group_id)
+       {
+               $result = 0;
+       if(isset($group_id)){
+               $q1="SELECT organization_id FROM activity_group WHERE 
id={$group_id}";
+                       $this->db->query($q1, __LINE__, __FILE__);
+                       while($this->db->next_record()){
+                               $result = $this->db->f('organization_id');
+                       }
+       }
+               
+               return $result;
+       }
+       
        function get_contacts($group_id)
        {
                $contacts = array();
@@ -347,6 +436,7 @@
                        
$group->set_show_in_portal($this->unmarshal($this->db->f('show_in_portal'), 
'int'));
                        
$group->set_change_type($this->unmarshal($this->db->f('change_type'), 
'string'));
                        
$group->set_transferred($this->unmarshal($this->db->f('transferred'), 'bool'));
+                       
$group->set_original_group_id($this->unmarshal($this->db->f('original_group_id'),
 'int'));
                }
                return $group;
        }
@@ -383,7 +473,7 @@
                $name = $group_info['name'];
                $orgid = $group_info['organization_id'];
                $description = $group_info['description'];
-               $activity_id = 0;
+               $activity_id = 1;
                $show_in_portal = 1; 
                
                $columns[] = 'name';
@@ -396,7 +486,7 @@
                $values[] = "'{$name}'";
                $values[] = "'{$description}'";
                $values[] = "'{$orgid}'";
-               $values[] = $this->marshal($activity_id, 'int');
+               $values[] = $activity_id;
                $values[] = $show_in_portal;
                $vals = implode(',',$values);
                
@@ -420,6 +510,7 @@
                $columns[] = 'activity_group.organization_id';
                $columns[] = 'activity_group.change_type';
                $columns[] = 'activity_group.transferred';
+               $columns[] = 'activity_group.original_group_id';
                
                $dir = $ascending ? 'ASC' : 'DESC';
                $order = "ORDER BY activity_group.id $dir";
@@ -429,9 +520,9 @@
                
                $sql = "SELECT {$cols} FROM {$table} WHERE 
activity_group.id={$g_id}";
                $result = $this->db->query($sql, __LINE__, __FILE__);
-               if(isset($result))
+               while($this->db->next_record())
                {
-                       $group = new activitycalendar_group((int) $group_id);
+                       $group = new activitycalendar_group((int) $g_id);
 
                        $group->set_name($this->unmarshal($this->db->f('name'), 
'string'));
                        
$group->set_organization_id($this->unmarshal($this->db->f('organization_id'), 
'int'));
@@ -440,10 +531,46 @@
                        
$group->set_show_in_portal($this->unmarshal($this->db->f('show_in_portal'), 
'int'));
                        
$group->set_change_type($this->unmarshal($this->db->f('change_type'), 
'string'));
                        
$group->set_transferred($this->unmarshal($this->db->f('transferred'), 'bool'));
+                       
$group->set_original_group_id($this->unmarshal($this->db->f('original_group_id'),
 'int'));
                        
                        return $group;
                }
                
        }
+        
+        function add_new_group_from_activity($group_info)
+       {
+            $name = $group_info['name'];
+            $orgid = $group_info['organization_id'];
+            $description = $group_info['description'];
+            $activity_id = 1;
+            $show_in_portal = 1; 
+
+            $columns[] = 'name';
+            $columns[] = 'description';
+            $columns[] = 'organization_id';
+            $columns[] = 'activity_id';
+            $columns[] = 'show_in_portal';
+            $cols = implode(',',$columns);
+
+            $values[] = $this->marshal($name, 'string');
+            $values[] = $this->marshal($description, 'string');
+            $values[] = "'{$orgid}'";
+            $values[] = $this->marshal($activity_id, 'int');
+            $values[] = $show_in_portal;
+            $vals = implode(',',$values);
+
+            $sql = "INSERT INTO bb_group ({$cols}) VALUES ({$vals})";
+            $result = $this->db->query($sql, __LINE__, __FILE__);
+            
+            if(isset($result))
+            {
+                return $this->db->get_last_insert_id('bb_group', 'id');
+            }
+            else
+            {
+                return 0;
+            }
+       }
 }
 ?>

Modified: 
branches/stavangerkommune/activitycalendar/inc/class.soorganization.inc.php
===================================================================
--- branches/stavangerkommune/activitycalendar/inc/class.soorganization.inc.php 
2012-08-21 07:22:01 UTC (rev 9887)
+++ branches/stavangerkommune/activitycalendar/inc/class.soorganization.inc.php 
2012-08-21 07:37:50 UTC (rev 9888)
@@ -125,18 +125,6 @@
                        $filter_clauses[] = "org.id IN (SELECT organization_id 
from activity_activity where state = 3 OR state = 4)";
                }
 
-/*
-               // All parties with contracts of type X
-               if(isset($filters['party_type']))
-               {
-                       $party_type = 
$this->marshal($filters['party_type'],'int');
-                       if(isset($party_type) && $party_type > 0)
-                       {
-                               $filter_clauses[] = "contract.location_id = 
{$party_type}";
-                       }
-               }
-*/             
-               
                if(count($filter_clauses))
                {
                        $clauses[] = join(' AND ', $filter_clauses);
@@ -159,6 +147,9 @@
                                $columns[] = 'org.email';
                                $columns[] = 'org.description';
                                $columns[] = 'org.address';
+                                $columns[] = 'org.addressnumber';
+                               $columns[] = 'org.zip_code';
+                               $columns[] = 'org.city';
                                $columns[] = 'org.district';
                                $columns[] = 'org.change_type';
                                $columns[] = 'org.transferred';
@@ -204,9 +195,6 @@
        
                        $tables = "bb_organization org";                        
                }
-
-               //$join_contracts = "   {$this->left_join} 
rental_contract_party c_p ON (c_p.party_id = party.id)
-               //{$this->left_join} rental_contract contract ON (contract.id = 
c_p.contract_id)";
                
                //var_dump("SELECT {$cols} FROM {$tables} WHERE {$condition} 
{$order}");
                return "SELECT {$cols} FROM {$tables} WHERE {$condition} 
{$order}";
@@ -216,7 +204,8 @@
        {
                $result = "Ingen";
        if(isset($org_id)){
-               $q1="SELECT name FROM bb_organization WHERE id={$org_id}";
+               $org_id = intval($org_id);
+           $q1="SELECT name FROM bb_organization WHERE id={$org_id}";
                        $this->db->query($q1, __LINE__, __FILE__);
                        while($this->db->next_record()){
                                $result = $this->db->f('name');
@@ -510,6 +499,9 @@
                $email = $organization->get_email();
                $description = $organization->get_description();
                $street = $organization->get_address();
+               $streetnumber = $organization->get_addressnumber();
+               $zip_code = $organization->get_zip_code();
+               $city = $organization->get_city();
                $district = $organization->get_district();
                $change_type = $organization->get_change_type();
                $transferred = ($organization->get_transferred() == 1 || 
$organization->get_transferred() == true)?'true':'false';
@@ -521,6 +513,9 @@
                $values[] = "EMAIL='{$email}'";
                $values[] = "DESCRIPTION='{$description}'";
                $values[] = "ADDRESS='{$street}'";
+               $values[] = "ADDRESSNUMBER='{$streetnumber}'";
+               $values[] = "ZIP_CODE='{$zip_code}'";
+               $values[] = "CITY='{$city}'";
                $values[] = "ORGNO='{$orgnr}'";
                $values[] = "DISTRICT='{$district}'";
                $values[] = "CHANGE_TYPE='{$change_type}'";
@@ -566,7 +561,10 @@
 
                        
$organization->set_name($this->unmarshal($this->db->f('name'), 'string'));
                        
$organization->set_organization_number($this->unmarshal($this->db->f('organization_number'),
 'int'));
-                       
$organization->set_address($this->unmarshal($this->db->f('address'), 
'string').','.$this->unmarshal($this->db->f('zip_code'), 'string').' 
'.$this->unmarshal($this->db->f('city'), 'string'));
+                       
$organization->set_address($this->unmarshal($this->db->f('address'), 'string'));
+                       
$organization->set_addressnumber($this->unmarshal($this->db->f('addressnumber'),
 'string'));
+                       
$organization->set_zip_code($this->unmarshal($this->db->f('zip_code'), 
'string'));
+                       
$organization->set_city($this->unmarshal($this->db->f('city'), 'string'));
                        
$organization->set_phone($this->unmarshal($this->db->f('phone'), 'string'));
                        
$organization->set_email($this->unmarshal($this->db->f('email'), 'string'));
                        
$organization->set_homepage($this->unmarshal($this->db->f('homepage'), 
'string'));
@@ -585,22 +583,10 @@
                $name = $organization->get_name();
                $orgnr = $organization->get_organization_number();
                $homepage = $organization->get_homepage();
-               $phone = $organization->get_phone();
-               $email = $organization->get_email();
-               $description = $organization->get_description();
                $street = $organization->get_address();
-/*             $zip = $organization->get_();
-               if($zip && strlen($zip) > 5)
-               {
-                       $zip_code = substr($zip,0,4);
-                       $city = substr($zip, 5);
-               }
-               else
-               {
-                       $zip_code = '';
-                       $city = '';
-               }*/
-               $district = $organization->get_district();
+               $streetnumber = $organization->get_address_number();
+               $zip_code = $organization->get_zip_code();
+               $city = $organization->get_city();
                if($organization->get_original_org_id() && 
$organization->get_original_org_id() != '')
                {
                        $original_org_id = 
$organization->get_original_org_id(); 
@@ -613,14 +599,11 @@
                
                $values[] = "NAME='{$name}'";
                $values[] = "HOMEPAGE='{$homepage}'";
-               $values[] = "PHONE='{$phone}'";
-               $values[] = "EMAIL='{$email}'";
-               $values[] = "DESCRIPTION='{$description}'";
-               $values[] = "STREET='{$street}'";
-               //$values[] = "'{$zip_code}'";
-               //$values[] = "'{$city}'";
+               $values[] = "ADDRESS='{$street}'";
+               $values[] = "ADDRESSNUMBER='{$streetnumber}'";
+               $values[] = "ZIP_CODE='{$zip_code}'";
+               $values[] = "CITY='{$city}'";
                $values[] = "ORGNO='{$orgnr}'";
-               $values[] = "DISTRICT='{$district}'";
                $values[] = "ORIGINAL_ORG_ID={$original_org_id}";
                $vals = implode(',',$values);
                
@@ -642,23 +625,12 @@
                $name = $org_info['name'];
                $orgnr = $org_info['orgnr'];
                $homepage = $org_info['homepage'];
-               $phone = $org_info['phone'];
-               $email = $org_info['email'];
-               $description = $org_info['description'];
-               $street = $org_info['street'];
-               $zip = $org_info['zip'];
-               if($zip && strlen($zip) > 5)
-               {
-                       $zip_code = substr($zip,0,5);
-                       $city = substr($zip, 5);
-               }
-               else
-               {
-                       $zip_code = '';
-                       $city = '';
-               }
-               $district = $org_info['district'];
-               $activity_id = $org_info['activity_id'];
+               $street_1 = $org_info['street'];
+               $street_2 = $org_info['streetnumber'];
+               $street = $street_1 . ' ' . $street_2;
+               $zip_code = $org_info['zip'];
+               $city = $org_info['postaddress'];
+               $activity_id = 1;
                $show_in_portal = 1; 
                
                $columns[] = 'name';
@@ -677,13 +649,13 @@
                
                $values[] = "'{$name}'";
                $values[] = "'{$homepage}'";
-               $values[] = "'{$phone}'";
-               $values[] = "'{$email}'";
-               $values[] = "'{$description}'";
+               $values[] = "''";
+               $values[] = "''";
+               $values[] = "''";
                $values[] = "'{$street}'";
                $values[] = "'{$zip_code}'";
                $values[] = "'{$city}'";
-               $values[] = "'{$district}'";
+               $values[] = "''";
                $values[] = "'{$orgnr}'";
                $values[] = $this->marshal($activity_id, 'int');
                $values[] = $show_in_portal;
@@ -713,6 +685,9 @@
                        
$organization->set_name($this->unmarshal($this->db->f('name'), 'string'));
                        
$organization->set_organization_number($this->unmarshal($this->db->f('organization_number'),
 'int'));
                        
$organization->set_address($this->unmarshal($this->db->f('address'), 'string'));
+                       
$organization->set_addressnumber($this->unmarshal($this->db->f('addressnumber'),
 'string'));
+                       
$organization->set_zip_code($this->unmarshal($this->db->f('zip_code'), 
'string'));
+                       
$organization->set_city($this->unmarshal($this->db->f('city'), 'string'));
                        
$organization->set_phone($this->unmarshal($this->db->f('phone'), 'string'));
                        
$organization->set_email($this->unmarshal($this->db->f('email'), 'string'));
                        
$organization->set_homepage($this->unmarshal($this->db->f('homepage'), 
'string'));
@@ -751,22 +726,13 @@
                {
                        $description = '';
                }
-               $street = $org_info['street'];
+               $street = $org_info['street'] . ' ' . $org_info['streetnumber'];
                if(!$street)
                {
                        $street = '';
                }
-               $zip = $org_info['zip'];
-               if($zip && strlen($zip) > 5)
-               {
-                       $zip_code = substr($zip,0,4);
-                       $city = substr($zip, 5);
-               }
-               else
-               {
-                       $zip_code = '';
-                       $city = '';
-               }
+               $zip_code = $org_info['zip_code'];
+               $city = $org_info['city'];
                $district = $org_info['district'];
                if(!$district)
                {

Modified: 
branches/stavangerkommune/activitycalendar/inc/class.uiactivities.inc.php
===================================================================
--- branches/stavangerkommune/activitycalendar/inc/class.uiactivities.inc.php   
2012-08-21 07:22:01 UTC (rev 9887)
+++ branches/stavangerkommune/activitycalendar/inc/class.uiactivities.inc.php   
2012-08-21 07:37:50 UTC (rev 9888)
@@ -9,6 +9,12 @@
 
 class activitycalendar_uiactivities extends activitycalendar_uicommon
 {
+    protected $so_org;
+       protected $so_group;
+       protected $so_contact;
+       protected $so_activity;
+       protected $so_arena;
+
        public $public_functions = array
        (
                'index'                 => true,
@@ -19,7 +25,8 @@
                'edit'                          => true,
                'download'                      => true,
                'send_mail'                     => true,
-               'get_organization_groups'       => true
+               'get_organization_groups'       => true,
+                'create_groups'                 => true
        );
        
        public function __construct()
@@ -27,6 +34,11 @@
                parent::__construct();
                $this->bo_org = CreateObject('booking.boorganization');
                $this->bo_group = CreateObject('booking.bogroup');
+               $this->so_org = activitycalendar_soorganization::get_instance();
+               $this->so_group = activitycalendar_sogroup::get_instance();
+               $this->so_contact = 
activitycalendar_socontactperson::get_instance();
+               $this->so_activity = 
activitycalendar_soactivity::get_instance();
+               $this->so_arena = activitycalendar_soarena::get_instance();
                self::set_active_menu('activitycalendar::activities');
                $config = CreateObject('phpgwapi.config','activitycalendar');
                $config->read();
@@ -75,7 +87,7 @@
                $errorMsgs = array();
                $infoMsgs = array();
 
-               $activity = 
activitycalendar_soactivity::get_instance()->get_single((int)phpgw::get_var('id'));
+               $activity = 
$this->so_activity->get_single((int)phpgw::get_var('id'));
                $cancel_link = self::link(array('menuaction' => 
'activitycalendar.uiactivities.index'));
                $saved_OK = phpgw::get_var('saved_ok');
                if($saved_OK)
@@ -109,53 +121,67 @@
                $GLOBALS['phpgw_info']['flags']['app_header'] .= 
'::'.lang('edit');
                // Get the contract part id
                $activity_id = (int)phpgw::get_var('id');
-               $so_activity = activitycalendar_soactivity::get_instance();
-               $so_arena = activitycalendar_soarena::get_instance();
-               $so_org = activitycalendar_soorganization::get_instance();
-               //var_dump($activity_id);
                $cancel_link = self::link(array('menuaction' => 
'activitycalendar.uiactivities.index'));
-               $categories = $so_activity->get_categories();
-               $targets = $so_activity->get_targets();
-               $offices = $so_activity->select_district_list();
-               $districts = $so_activity->get_districts();
-               $buildings = $so_arena->get_buildings();
-                               
+               $categories = $this->so_activity->get_categories();
+               $targets = $this->so_activity->get_targets();
+               $offices = $this->so_activity->select_district_list();
+               $districts = $this->so_activity->get_districts();
+               $buildings = $this->so_arena->get_buildings();
                // Retrieve the activity object or create a new one
                if(isset($activity_id) && $activity_id > 0)
                {       
-                       $activity = $so_activity->get_single($activity_id); 
+                       $activity = 
$this->so_activity->get_single($activity_id); 
                }
                else
                {
                        $activity = new activitycalendar_activity();
                }
+               $new_group = $activity->get_new_group();
                $g_id = phpgw::get_var('group_id');
                $o_id = phpgw::get_var('organization_id');
-               if(isset($g_id) && $g_id > 0)
+               if($new_group)
                {
-                       $persons = 
activitycalendar_sogroup::get_instance()->get_contacts($g_id);
-                       $desc = 
activitycalendar_sogroup::get_instance()->get_description($g_id);
+                   $persons = 
$this->so_group->get_contacts_local($activity->get_group_id());
+                       $desc = 
$this->so_group->get_description_local($activity->get_group_id());
                }
+               else if(isset($g_id) && $g_id > 0)
+               {
+                       $persons = $this->so_group->get_contacts($g_id);
+                       $desc = $this->so_group->get_description($g_id);
+               }
                else if(isset($o_id) && $o_id > 0)
                {
-                       $persons = $so_org->get_contacts($o_id);
-                       $desc = $so_org->get_description($o_id);
+                       $persons = $this->so_org->get_contacts($o_id);
+                       $desc = $this->so_org->get_description($o_id);
                }
                
                if(strlen($desc) > 254)
                {
                        $desc = substr($desc,0,254);
                }
-               $arenas = $so_arena->get(null, null, 'arena.arena_name', true, 
null, null, null);
+               $arenas = $this->so_arena->get(null, null, 'arena.arena_name', 
true, null, null, null);
                if($activity->get_new_org())
                {
-                       $org_name = 
$so_org->get_organization_name_local($activity->get_organization_id());
+                       $org_name = 
$this->so_org->get_organization_name_local($activity->get_organization_id());
                }
                else
                {
-                       $organizations = $so_org->get(null, null, 'org.name', 
true, null, null, null);
+                       $organizations = $this->so_org->get(null, null, 
'org.name', true, null, null, null);
                }
-               $groups = activitycalendar_sogroup::get_instance()->get(null, 
null, null, null, null, null, null);
+               if($new_group)
+               {
+                   $group_array = $this->so_group->get(null, null, null, null, 
null, null, array('group_id' => $activity->get_group_id(), 'new_groups' => 
'true'));
+                   //var_dump($group_array);
+               if(count($group_array) > 0){
+                       $keys = array_keys($group_array);
+                       $local_group = $group_array[$keys[0]];
+                       //$group_name = $local_group->get_name();
+               }  
+               }
+               else
+               {
+                   $groups = $this->so_group->get(null, null, null, null, 
null, null, null);
+               }
 
                if(isset($_POST['save_activity'])) // The user has pressed the 
save button
                {
@@ -163,7 +189,6 @@
                        {
                                $old_state = $activity->get_state();
                                $new_state = phpgw::get_var('state');
-                               
                                // ... set all parameters
                                $activity->set_title(phpgw::get_var('title'));
                                
$activity->set_organization_id(phpgw::get_var('organization_id'));
@@ -206,8 +231,67 @@
                                
                                if($target_ok && $district_ok)
                                {
-                                       if($so_activity->store($activity)) // 
... and then try to store the object
+                                       
if($this->so_activity->store($activity)) // ... and then try to store the object
                                        {
+                                       if($new_group && $new_state == 3)
+                                   {
+                                       //transfer group to booking
+                                           $group_array = 
$this->so_group->get(null, null, null, null, null, null, array('group_id' => 
$activity->get_group_id(), 'new_groups' => 'true'));
+                                       if(count($group_array) > 0){
+                                           $keys = array_keys($group_array);
+                                               $group = $group_array[$keys[0]];
+                                       } 
+                                       
+                                           $group_info = array();
+                                           $group_info['name'] = 
$group->get_name(); //new
+                                           $group_info['organization_id'] = 
$activity->get_organization_id(); 
+                                           $group_info['description'] = 
$group->get_description();
+                                           
+                                           $contacts = 
$this->so_contact->get_local_contact_persons($group->get_id(), true);
+                                           $contact_1 = $contacts[0];
+    
+                                       $new_group_id = 
$this->so_group->transfer_group($group_info);
+                                           if($new_group_id)
+                                       {
+                                               //update activity with new org 
id
+                                               //add contact persons to booking
+                                               $contact1 = array();
+                                               $contact1['name'] = 
$contact_1->get_name();
+                                               $contact1['phone'] = 
$contact_1->get_phone();
+                                               $contact1['mail'] = 
$contact_1->get_email();
+                                               $contact1['group_id'] = 
$new_group_id;
+                                               
$this->so_activity->add_contact_person_group($contact1);
+                                               
+                                               $message = 
lang('messages_saved_form'); 
+                                               
+                                               //get organization_id for the 
group:
+                                               $group_org_id = 
$this->so_group->get_orgid_from_group($new_group_id);
+                                               
+                                               //get affected activities and 
update with new org id
+                                               $update_activities = 
$this->so_activity->get_activities_for_update($group->get_id(), true);
+
+                                               foreach($update_activities as 
$act_id)
+                                               {
+                                                   $act = 
$this->so_activity->get_single($act_id);
+                                                       
$act->set_organization_id($group_org_id);
+                                                       
$act->set_group_id($new_group_id);
+                                                       
$act->set_new_org(false);
+                                                       
$act->set_new_group(false);
+                                                       
$this->so_activity->store($act);
+                                               }
+                                               
+                                               //set local group as stored
+                                               
$group->set_change_type('added');
+                                               $group->set_transferred(true);
+    
+                                               
$this->so_group->update_local($group);
+                                               $message = 
lang('messages_saved_form');
+                                               //var_dump($new_group_id);
+                                               $contact_persons = 
$this->so_contact->get_booking_contact_persons($new_group_id, true);
+                                               //var_dump(2);
+                                       $cp1 = $contact_persons[0];
+                                   }
+                                   }
                                                $message = 
lang('messages_saved_form'); 
                                        }
                                        else
@@ -217,19 +301,19 @@
        
                                        if($new_state == 3 || $new_state == 5 )
                                        {
-                                               $kontor = 
$so_activity->get_office_name($activity->get_office());
+                                               $kontor = 
$this->so_activity->get_office_name($activity->get_office());
                                                $subject = 
lang('mail_subject_update');
                                                $body = lang('mail_body_state_' 
. $new_state, $kontor);
                                                
-                                               if(isset($g_id) && $g_id > 0)
+                                               if($activity->get_group_id() && 
$activity->get_group_id() > 0)
                                                {
                                                        
$activity->set_contact_persons(activitycalendar_socontactperson::get_instance()->get_booking_contact_persons($activity->get_group_id(),
 true));
-                                                       
activitycalendar_uiactivities::send_mailnotification_to_group($activity->get_contact_person_2(),$subject,$body);
+                                                       
activitycalendar_uiactivities::send_mailnotification_to_group($activity->get_contact_person_1(),$subject,$body);
                                                }
-                                               else if (isset($o_id) && $o_id 
> 0)
+                                               else if 
($activity->get_organization_id() && $activity->get_organization_id() > 0)
                                                {
                                                        
$activity->set_contact_persons(activitycalendar_socontactperson::get_instance()->get_booking_contact_persons($activity->get_organization_id()));
-                                                       
activitycalendar_uiactivities::send_mailnotification_to_organization($activity->get_contact_person_2(),$subject,$body);
+                                                       
activitycalendar_uiactivities::send_mailnotification_to_organization($activity->get_contact_person_1(),$subject,$body);
                                                }
                                        }
                                        
$GLOBALS['phpgw']->redirect_link('/index.php', array('menuaction' => 
'activitycalendar.uiactivities.view', 'id' => $activity->get_id(), 'saved_ok' 
=> 'yes'));
@@ -250,6 +334,7 @@
                                                        'organizations' => 
$organizations,
                                                        'org_name' => $org_name,
                                                        'groups' => $groups,
+                                                   'local_group' => 
$local_group,
                                                        'arenas' => $arenas,
                                                        'buildings' => 
$buildings,
                                                        'categories' => 
$categories,
@@ -271,6 +356,7 @@
                        $error = lang('org_not_transferred');
                        $editable = false;
                }
+               //var_dump($local_group);
 
                return $this->render('activity.php', array
                        (
@@ -278,6 +364,7 @@
                                'organizations' => $organizations,
                                'org_name' => $org_name,
                                'groups' => $groups,
+                               'local_group' => $local_group,
                                'arenas' => $arenas,
                                'buildings' => $buildings,
                                'categories' => $categories,
@@ -434,14 +521,17 @@
                //$link_text = "<a 
href='http://www.bergen.kommune.no/aktivby/registreringsskjema/ny/?menuaction=activitycalendarfrontend.uiactivity.edit&amp;id={$activity->get_id()}&amp;secret={$activity->get_secret()}'>Rediger
 opplysninger for {$activity->get_title()}</a>";
                //$link_text = "<a 
href='{$mailBaseURL}?menuaction=activitycalendarfrontend.uiactivity.edit&amp;id={$activity->get_id()}&amp;secret={$activity->get_secret()}'>Rediger
 opplysninger for {$activity->get_title()}</a>";
                $link_text = "<a 
href='http://www.bergen.kommune.no/aktivitetsoversikt/?menuaction=activitycalendarfrontend.uiactivity.edit&amp;id={$activity->get_id()}&amp;secret={$activity->get_secret()}'>Rediger
 opplysninger for {$activity->get_title()}</a>";
-               $office_name = 
activitycalendar_soactivity::get_instance()->get_office_name($activity->get_office());
+                $office_name = 
activitycalendar_soactivity::get_instance()->get_office_name($activity->get_office());
+                $uid = $GLOBALS['phpgw_info']['user']['account_id'];
+               $user_office_id =  
activitycalendar_soactivity::get_instance()->get_office_from_user($uid);
+                $office_footer = 
activitycalendar_soactivity::get_instance()->get_office_description($user_office_id);
                if($activity->get_state() == 2)
                {
-                       $body = lang('mail_body_update_frontend', 
$activity->get_title(), $link_text, $office_name);
+                       $body = lang('mail_body_update_frontend', 
$activity->get_title(), $link_text, $office_name) . '<br/><br/>'.$office_footer;
                }
                else
                {
-                       $body = lang('mail_body_update', 
$activity->get_title(), $link_text, $office_name);
+                       $body = lang('mail_body_update', 
$activity->get_title(), $link_text, $office_name) . '<br/><br/>'.$office_footer;
                }
                
                //var_dump($subject);
@@ -451,17 +541,19 @@
                if($activity->get_group_id() && $activity->get_group_id() > 0)
                {
                        
$activity->set_contact_persons(activitycalendar_socontactperson::get_instance()->get_booking_contact_persons($activity->get_group_id(),
 true));
-                       if($activity->get_contact_person_2() && 
$activity->get_contact_person_2()->get_email())
+/*                     if($activity->get_contact_person_2() && 
$activity->get_contact_person_2()->get_email())
                                
activitycalendar_uiactivities::send_mailnotification_to_group($activity->get_contact_person_2(),
 $subject, $body);
-                       else if($activity->get_contact_person_1() && 
$activity->get_contact_person_1()->get_email())
+                       else*/ 
+                       if($activity->get_contact_person_1() && 
$activity->get_contact_person_1()->get_email())
                                
activitycalendar_uiactivities::send_mailnotification_to_group($activity->get_contact_person_1(),
 $subject, $body);
                }
                else if($activity->get_organization_id() && 
$activity->get_organization_id() > 0)
                {
                        
$activity->set_contact_persons(activitycalendar_socontactperson::get_instance()->get_booking_contact_persons($activity->get_organization_id()));
-                       if($activity->get_contact_person_2() && 
$activity->get_contact_person_2()->get_email())
+/*                     if($activity->get_contact_person_2() && 
$activity->get_contact_person_2()->get_email())
                                
activitycalendar_uiactivities::send_mailnotification_to_organization($activity->get_contact_person_2(),
 $subject, $body);
-                       else if($activity->get_contact_person_1() && 
$activity->get_contact_person_1()->get_email())
+                       else*/ 
+                       if($activity->get_contact_person_1() && 
$activity->get_contact_person_1()->get_email())
                                
activitycalendar_uiactivities::send_mailnotification_to_organization($activity->get_contact_person_1(),
 $subject, $body);
                }
            }
@@ -506,18 +598,20 @@
        {
                //$contact_person2 = 
activitycalendar_socontactperson::get_instance()->get_group_contact2($activity>get_group_id());
                
$activity->set_contact_persons(activitycalendar_socontactperson::get_instance()->get_booking_contact_persons($activity->get_group_id(),
 true));
-               if($activity->get_contact_person_2() && 
$activity->get_contact_person_2()->get_email())
+/*             if($activity->get_contact_person_2() && 
$activity->get_contact_person_2()->get_email())
                        
activitycalendar_uiactivities::send_mailnotification_to_group($activity->get_contact_person_2(),
 $subject, $body);
-               else if($activity->get_contact_person_1() && 
$activity->get_contact_person_1()->get_email())
+               else */
+               if($activity->get_contact_person_1() && 
$activity->get_contact_person_1()->get_email())
                        
activitycalendar_uiactivities::send_mailnotification_to_group($activity->get_contact_person_1(),
 $subject, $body);
        }
        else if($activity->get_organization_id() && 
$activity->get_organization_id() > 0)
        {
                //$contact_person2 = 
activitycalendar_socontactperson::get_instance()->get_oup_contact2($activity>get_group_id());
                
$activity->set_contact_persons(activitycalendar_socontactperson::get_instance()->get_booking_contact_persons($activity->get_organization_id()));
-               if($activity->get_contact_person_2() && 
$activity->get_contact_person_2()->get_email())
+/*             if($activity->get_contact_person_2() && 
$activity->get_contact_person_2()->get_email())
                                
activitycalendar_uiactivities::send_mailnotification_to_organization($activity->get_contact_person_2(),
 $subject, $body);
-               else if($activity->get_contact_person_1() && 
$activity->get_contact_person_1()->get_email())
+               else */
+               if($activity->get_contact_person_1() && 
$activity->get_contact_person_1()->get_email())
                        
activitycalendar_uiactivities::send_mailnotification_to_organization($activity->get_contact_person_1(),
 $subject, $body);
        }
        
@@ -652,5 +746,35 @@
                
                return $returnHTML;
        }
-}
-?>
+        
+        public function create_groups()
+        {
+            $activities = $this->so_activity->get_activities_without_groups();
+            
+            foreach ($activities as $a)
+            {
+                $group_info = array();
+                $title_new = $a['title'];
+                    if(strlen($title_new) > 50)
+               {
+                       $title_new = substr($title_new,0,49);
+               }
+                $group_info['name'] = $title_new;
+                $group_info['organization_id'] =  $a['organization'];
+                $group_info['description'] = $a['description'];
+                
+                //add new group
+                $new_group_id = 
$this->so_group->add_new_group_from_activity($group_info);
+                var_dump("lagt til gruppen " . $group_info['name'] . " med id 
" . $new_group_id);
+                $this->so_activity->update_activity_group($a['id'], 
$new_group_id);
+                $cp = 
$this->so_contact->get_booking_contact_persons($a['organization']);
+                foreach ($cp as $c)
+                {
+                    $c->set_group_id($new_group_id);
+                    $contact_id = $this->so_contact->add_new_group_contact($c);
+                    var_dump("Lagt til kontaktperson " . $c->get_name() . " på 
gruppe " . $group_info['name']);
+                    //_debug_array($c);
+                }
+            }
+        }
+}
\ No newline at end of file

Modified: branches/stavangerkommune/activitycalendar/inc/class.uiarena.inc.php
===================================================================
--- branches/stavangerkommune/activitycalendar/inc/class.uiarena.inc.php        
2012-08-21 07:22:01 UTC (rev 9887)
+++ branches/stavangerkommune/activitycalendar/inc/class.uiarena.inc.php        
2012-08-21 07:37:50 UTC (rev 9888)
@@ -118,7 +118,10 @@
                                // ... set all parameters
                                
$arena->set_internal_arena_id(phpgw::get_var('internal_arena_id'));
                                
$arena->set_arena_name(phpgw::get_var('arena_name'));
-                               $arena->set_address(phpgw::get_var('address') . 
' ' . phpgw::get_var('address_no'));
+                               $arena->set_address(phpgw::get_var('address'));
+                               
$arena->set_addressnumber(phpgw::get_var('address_no'));
+                               
$arena->set_zip_code(phpgw::get_var('zip_code'));
+                               $arena->set_city(phpgw::get_var('city'));
                                
$arena->set_active(phpgw::get_var('arena_active') == 'yes' ? true : false);
                                
                                
if(activitycalendar_soarena::get_instance()->store($arena)) // ... and then try 
to store the object

Modified: branches/stavangerkommune/activitycalendar/inc/class.uicommon.inc.php
===================================================================
--- branches/stavangerkommune/activitycalendar/inc/class.uicommon.inc.php       
2012-08-21 07:22:01 UTC (rev 9887)
+++ branches/stavangerkommune/activitycalendar/inc/class.uicommon.inc.php       
2012-08-21 07:37:50 UTC (rev 9888)
@@ -63,6 +63,7 @@
                        
self::add_stylesheet('phpgwapi/js/yahoo/treeview/assets/skins/sam/treeview.css');
                        
//self::add_stylesheet('rental/templates/base/css/base.css');
                        self::add_javascript('activitycalendar', 
'activitycalendar', 'common.js');
+                        self::add_javascript('activitycalendar', 
'activitycalendar', 'jquery.js');
                        $this->tmpl_search_path = array();
                        array_push($this->tmpl_search_path, PHPGW_SERVER_ROOT . 
'/phpgwapi/templates/base');
                        array_push($this->tmpl_search_path, PHPGW_SERVER_ROOT . 
'/phpgwapi/templates/' . $GLOBALS['phpgw_info']['server']['template_set']);

Modified: 
branches/stavangerkommune/activitycalendar/inc/class.uiorganization.inc.php
===================================================================
--- branches/stavangerkommune/activitycalendar/inc/class.uiorganization.inc.php 
2012-08-21 07:22:01 UTC (rev 9887)
+++ branches/stavangerkommune/activitycalendar/inc/class.uiorganization.inc.php 
2012-08-21 07:37:50 UTC (rev 9888)
@@ -81,144 +81,6 @@
                unset($org_info);
                unset($contact1);
                unset($contact2);
-               if($type)
-               {
-                       $sogroup = activitycalendar_sogroup::get_instance();
-                       $soactivity = 
activitycalendar_soactivity::get_instance();
-                       $socontact = 
activitycalendar_socontactperson::get_instance();
-                       $group_array = $sogroup->get(null, null, null, null, 
null, null, array('id' => $id, 'changed_groups' => 'true'));
-                       if(count($group_array) > 0){
-                               $keys = array_keys($group_array);
-                               $group = $group_array[$keys[0]];
-                       }
-                       if(isset($_POST['save_group'])) // The user has pressed 
the save button
-                       {
-                               $desc = phpgw::get_var('group_description');
-                               $group->set_description($desc);
-                               
-                               $contact1 = array();
-                               $contact1['id'] = phpgw::get_var('contact1_id');
-                               $contact1['name'] = 
phpgw::get_var('contact1_name');
-                               $contact1['phone'] = 
phpgw::get_var('contact1_phone');
-                               $contact1['mail'] = 
phpgw::get_var('contact1_email');
-                               $contact1['org_id'] = 0;
-                               $contact1['group_id'] = $group->get_id();
-                               
-                               $contact2 = array();
-                               $contact2['id'] = phpgw::get_var('contact2_id');
-                               $contact2['name'] = 
phpgw::get_var('contact2_name');
-                               $contact2['phone'] = 
phpgw::get_var('contact2_phone');
-                               $contact2['mail'] = 
phpgw::get_var('contact2_email');
-                               $contact2['org_id'] = 0;
-                               $contact2['group_id'] = $group->get_id();
-                               
-                               if($sogroup->update_local($group))
-                               {
-                                       
$socontact->update_local_contact_person($contact1);
-                                       
$socontact->update_local_contact_person($contact2);
-                                       $message = lang('messages_saved_form'); 
-                               }
-                               else
-                               {
-                                       $error = lang('messages_form_error');
-                               }
-                               $GLOBALS['phpgw']->redirect_link('/index.php', 
array('menuaction' => 'activitycalendar.uiorganization.show', 'id' => 
$group->get_id(), 'type' => 'group', 'saved_ok' => 'yes'));
-                       }
-                       else if(isset($_POST['store_group'])) // The user has 
pressed the store button
-                       {
-                               $desc = phpgw::get_var('group_description');    
                        
-                               $orgid = $group->get_organization_id();
-                               
-                               $group_info = array();
-                               $group_info['name'] = $group->get_name(); //new
-                               $group_info['organization_id'] = $orgid; 
-                               $group_info['description'] = $desc;
-                               
-                               $contact1_id = phpgw::get_var('contact1_id');
-                               $contact2_id = phpgw::get_var('contact2_id');
-                               
-                               $contact1_name = 
phpgw::get_var('contact1_name');
-                               $contact1_phone = 
phpgw::get_var('contact1_phone');
-                               $contact1_email = 
phpgw::get_var('contact1_email');
-                               
-                               $contact2_name = 
phpgw::get_var('contact2_name');
-                               $contact2_phone = 
phpgw::get_var('contact2_phone');
-                               $contact2_email = 
phpgw::get_var('contact2_email');
-
-                               
-                               $new_group_id = 
$sogroup->transfer_group($group_info);
-                               if($new_group_id)
-                               {
-                                       //update activity with new org id
-                                       //add contact persons to booking
-                                       $contact1 = array();
-                                       $contact1['name'] = $contact1_name;
-                                       $contact1['phone'] = $contact1_phone;
-                                       $contact1['mail'] = $contact1_email;
-                                       $contact1['group_id'] = $new_group_id;
-                                       
$soactivity->add_contact_person_group($contact1);
-                                       
-                                       $contact2 = array();
-                                       $contact2['name'] = $contact2_name;
-                                       $contact2['phone'] = $contact2_phone;
-                                       $contact2['mail'] = $contact2_email;
-                                       $contact2['group_id'] = $new_group_id;
-                                       
$soactivity->add_contact_person_group($contact2);
-                                       
-                                       $message = lang('messages_saved_form'); 
-                                       
-                                       //get organization_id for the group:
-                                       $group_org_id = 
$sogroup->get_orgid_from_group($new_group_id);
-                                       
-                                       //get affected activities and update 
with new org id
-                                       $update_activities = 
$soactivity->get_activities_for_update($id, true);
-                                       var_dump($update_activities);
-                                       foreach($update_activities as $act)
-                                       {
-                                               
$act->set_organization_id($group_org_id);
-                                               
$act->set_group_id($new_group_id);
-                                               $act->set_new_org(false);
-                                               $soactivity->store($act);
-                                               var_dump($act);
-                                       }
-                                       
-                                       //set local group as stored
-                                       $group->set_change_type('added');
-                                       $group->set_transferred(true);
-                                       $sogroup->update_local($group);
-                                       $message = lang('messages_saved_form');
-                                       
-                                       $contact_persons = 
$socontact->get_booking_contact_persons($group->get_id(), true);
-                               $cp1 = $contact_persons[0];
-                               $cp2 = $contact_persons[1];
-                               }
-                               else
-                               {
-                                       $error = lang('messages_form_error');
-                               }
-                               $GLOBALS['phpgw']->redirect_link('/index.php', 
array('menuaction' => 'activitycalendar.uiorganization.show', 'id' => 
$group->get_id(), 'type' => 'group', 'saved_ok' => 'yes'));
-                       }
-                       
-                       $contact_persons = 
$socontact->get_local_contact_persons($group->get_id(), true);
-                       $cp1 = $contact_persons[0];
-                       $cp2 = $contact_persons[1];
-                       
-                       $data = array
-                       (
-                               'group'         => $group,
-                               'contactperson1' => $cp1,
-                               'contactperson2' => $cp2,
-                               'editable' => true,
-                               'cancel_link' => $cancel_link,
-                               'errorMsgs' => $errorMsgs,
-                               'infoMsgs' => $infoMsgs
-                       );
-                       return $this->render('group.php', $data);
-                       
-               }
-               else
-               {
-                       //var_dump('org');
                        $so_org = 
activitycalendar_soorganization::get_instance();
                        $so_activity = 
activitycalendar_soactivity::get_instance();
                        $so_contact = 
activitycalendar_socontactperson::get_instance();
@@ -230,54 +92,18 @@
                        //var_dump($org);
                        $districts = $so_activity->get_districts();
                        
-                       if(isset($_POST['save_organization'])) // The user has 
pressed the save button
+                       if(isset($_POST['store_organization'])) // The user has 
pressed the store button
                        {
-                               
$org->set_organization_number(phpgw::get_var('orgno'));
-                               
$org->set_district(phpgw::get_var('org_district'));
-                               $org->set_homepage(phpgw::get_var('homepage'));
-                               $org->set_email(phpgw::get_var('email'));
-                               $org->set_phone(phpgw::get_var('phone'));
-                               $org->set_address(phpgw::get_var('address'));
-                               
$org->set_description(phpgw::get_var('org_description'));
-                               
-                               $contact1 = array();
-                               $contact1['id'] = phpgw::get_var('contact1_id');
-                               $contact1['name'] = 
phpgw::get_var('contact1_name');
-                               $contact1['phone'] = 
phpgw::get_var('contact1_phone');
-                               $contact1['mail'] = 
phpgw::get_var('contact1_email');
-                               $contact1['org_id'] = $org->get_id();
-                               $contact1['group_id'] = 0;
-                               
-                               $contact2 = array();
-                               $contact2['id'] = phpgw::get_var('contact2_id');
-                               $contact2['name'] = 
phpgw::get_var('contact2_name');
-                               $contact2['phone'] = 
phpgw::get_var('contact2_phone');
-                               $contact2['mail'] = 
phpgw::get_var('contact2_email');
-                               $contact2['org_id'] = $org->get_id();
-                               $contact2['group_id'] = 0;
-                               
-                               if($so_org->update_local($org))
-                               {
-                                       
$so_contact->update_local_contact_person($contact1);
-                                       
$so_contact->update_local_contact_person($contact2);
-                                       $message = lang('messages_saved_form'); 
-                               }
-                               else
-                               {
-                                       $error = lang('messages_form_error');
-                               }
-                               $GLOBALS['phpgw']->redirect_link('/index.php', 
array('menuaction' => 'activitycalendar.uiorganization.show', 'id' => 
$org->get_id(), 'saved_ok' => 'yes'));
-                       }
-                       else if(isset($_POST['store_organization'])) // The 
user has pressed the store button
-                       {
                                $orgno = phpgw::get_var('orgno');
                                $district = phpgw::get_var('org_district');
                                $homepage = phpgw::get_var('homepage');
                                $email = phpgw::get_var('email');
                                $phone = phpgw::get_var('phone');
-                               $address_tmp = phpgw::get_var('address');
+                               $address = phpgw::get_var('address');
+                                $zip = phpgw::get_var('zip_code');
+                                $city = phpgw::get_var('city');
                                //phpgw::get_var('address') . ' ' . 
phpgw::get_var('number') . ', ' . phpgw::get_var('postaddress');
-                               $address_array = explode(",",$address_tmp);
+                               //$address_array = explode(",",$address_tmp);
                                $desc = phpgw::get_var('org_description');
                                
                                $org_info = array();
@@ -293,8 +119,9 @@
                                $org_info['phone'] = $phone;
                                $org_info['email'] = $email;
                                $org_info['description'] = $desc;
-                               $org_info['street'] = $address_array[0];
-                               $org_info['zip'] = $address_array[1];
+                               $org_info['street'] = $address;
+                               $org_info['zip'] = $zip;
+                                $org_info['postaddress'] = $city;
                                $org_info['activity_id'] = '';
                                $org_info['district'] = $district;
                                
@@ -322,20 +149,14 @@
                                        $contact1['org_id'] = $new_org_id;
                                        
$so_activity->add_contact_person_org($contact1);
                                        
-                                       $contact2 = array();
-                                       $contact2['name'] = $contact2_name;
-                                       $contact2['phone'] = $contact2_phone;
-                                       $contact2['mail'] = $contact2_email;
-                                       $contact2['org_id'] = $new_org_id;
-                                       
$so_activity->add_contact_person_org($contact2);
-                                       
                                        $message = lang('messages_saved_form'); 
                                        
                                        //get affected activities and update 
with new org id
                                        $update_activities = 
$so_activity->get_activities_for_update($id);
                                        //var_dump($update_activities);
-                                       foreach($update_activities as $act)
+                                       foreach($update_activities as $act_id)
                                        {
+                                           $act = 
$so_activity->get_single($act_id);
                                                
$act->set_organization_id($new_org_id);
                                                $act->set_new_org(false);
                                                $so_activity->store($act);
@@ -361,9 +182,11 @@
                                $homepage = phpgw::get_var('homepage');
                                $email = phpgw::get_var('email');
                                $phone = phpgw::get_var('phone');
-                               $address_tmp = phpgw::get_var('address');
+                               $address = phpgw::get_var('address');
+                                $zip = phpgw::get_var('zip_code');
+                                $city = phpgw::get_var('city');
                                //phpgw::get_var('address') . ' ' . 
phpgw::get_var('number') . ', ' . phpgw::get_var('postaddress');
-                               $address_array = explode(",",$address_tmp);
+                               //$address_array = explode(",",$address_tmp);
                                $desc = phpgw::get_var('org_description');
                                
                                $org_info = array();
@@ -379,8 +202,9 @@
                                $org_info['phone'] = $phone;
                                $org_info['email'] = $email;
                                $org_info['description'] = $desc;
-                               $org_info['street'] = $address_array[0];
-                               $org_info['zip'] = $address_array[1];
+                               $org_info['street'] = $address;
+                               $org_info['zip_code'] = $zip;
+                                $org_info['city'] = $city;
                                $org_info['activity_id'] = '';
                                $org_info['district'] = $district;
                                
@@ -441,7 +265,6 @@
                        );
                        
                        return $this->render('organization.php', $data);
-               }
        }
        
        public function show()
@@ -451,7 +274,7 @@
                $type = phpgw::get_var('type');
                $cancel_link = self::link(array('menuaction' => 
'activitycalendar.uiorganization.changed_organizations'));
                $socontact = activitycalendar_socontactperson::get_instance();
-               if($type)
+/*             if($type)
                {
                        if(isset($_POST['edit_group'])) // The user has pressed 
the save button
                        {
@@ -488,7 +311,7 @@
                        return $this->render('group.php', $data);
                }
                else
-               {
+               {*/
                        //var_dump('org');
                        if(isset($_POST['edit_organization'])) // The user has 
pressed the save button
                        {
@@ -523,7 +346,7 @@
                        );
                        
                        return $this->render('organization.php', $data);
-               }
+               //}
        }
        
        

Modified: 
branches/stavangerkommune/activitycalendar/inc/model/class.activity.inc.php
===================================================================
--- branches/stavangerkommune/activitycalendar/inc/model/class.activity.inc.php 
2012-08-21 07:22:01 UTC (rev 9887)
+++ branches/stavangerkommune/activitycalendar/inc/model/class.activity.inc.php 
2012-08-21 07:37:50 UTC (rev 9888)
@@ -32,6 +32,7 @@
                protected $internal_arena;
                protected $frontend;
                protected $new_org;
+               protected $new_group;
                
                /**
                 * Constructor.  Takes an optional ID.  If a contract is 
created from outside
@@ -229,6 +230,14 @@
                
                public function get_new_org() { return $this->new_org; }
                
+               public function set_new_group(bool $new_group)
+               {
+                       $this->new_group = (bool)$new_group;
+               }
+               
+               public function get_new_group() { return $this->new_group; }
+               
+               
                /**
                 * Get a static reference to the storage object associated with 
this model object
                 * 
@@ -245,15 +254,23 @@
                
                public function serialize()
                {
+                   $so_org = activitycalendar_soorganization::get_instance();
                        $date_format = 
$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'];
                        if(isset($this->group_id) && $this->get_group_id() > 0)
                        {
-                               if($this->get_new_org())
+                               if($this->get_new_group())
                                {
                                        $group_name = 
activitycalendar_sogroup::get_instance()->get_group_name_local($this->get_group_id());
                                        
$this->set_contact_persons(activitycalendar_socontactperson::get_instance()->get_local_contact_persons($this->get_group_id(),
 true));
                                        $contact_1 = 
activitycalendar_socontactperson::get_instance()->get_group_contact_name_local($this->get_contact_person_1()->get_id());
-                                       $contact_2 = 
activitycalendar_socontactperson::get_instance()->get_group_contact_name_local($this->get_contact_person_2()->get_id());
+                                       if($this->get_contact_person_2())
+                                       {
+                                           $contact_2 = 
activitycalendar_socontactperson::get_instance()->get_group_contact_name_local($this->get_contact_person_2()->get_id());
+                                       }
+                                       else
+                                       {
+                                           $contact_2  = null;
+                                       }
                                        $desc = 
activitycalendar_sogroup::get_instance()->get_description_local($this->get_group_id());
                                }
                                else
@@ -261,10 +278,26 @@
                                        $group_name = 
activitycalendar_sogroup::get_instance()->get_group_name($this->get_group_id());
                                        
$this->set_contact_persons(activitycalendar_socontactperson::get_instance()->get_booking_contact_persons($this->get_group_id(),
 true));
                                        $contact_1 = 
activitycalendar_socontactperson::get_instance()->get_group_contact_name($this->get_contact_person_1()->get_id());
-                                       $contact_2 = 
activitycalendar_socontactperson::get_instance()->get_group_contact_name($this->get_contact_person_2()->get_id());
+                                       if($this->get_contact_person_2())
+                                       {
+                                           $contact_2 = 
activitycalendar_socontactperson::get_instance()->get_group_contact_name($this->get_contact_person_2()->get_id());
+                                       }
+                                       else
+                                       {
+                                           $contact_2  = null;
+                                       }
                                        $desc = 
activitycalendar_sogroup::get_instance()->get_description($this->get_group_id());
                                }
-                               $org_name = 
activitycalendar_soorganization::get_instance()->get_organization_name($this->get_organization_id());
+                               $o_id = $this->get_organization_id(); 
+                               if($this->get_new_org())
+                               {
+                                   $org_name = 
$so_org->get_organization_name_local($o_id);
+                               }
+                               else
+                               {
+                                   $org_name = 
$so_org->get_organization_name($o_id);
+                               }
+                               
                        }
                        else if(isset($this->organization_id) && 
$this->get_organization_id() > 0)
                        {
@@ -273,7 +306,14 @@
                                        $org_name = 
activitycalendar_soorganization::get_instance()->get_organization_name_local($this->get_organization_id());
                                        
$this->set_contact_persons(activitycalendar_socontactperson::get_instance()->get_local_contact_persons($this->get_organization_id()));
                                        $contact_1 = 
activitycalendar_socontactperson::get_instance()->get_org_contact_name_local($this->get_contact_person_1()->get_id());
-                                       $contact_2 = 
activitycalendar_socontactperson::get_instance()->get_org_contact_name_local($this->get_contact_person_2()->get_id());
+                                       if($this->get_contact_person_2())
+                                       {
+                                           $contact_2 = 
activitycalendar_socontactperson::get_instance()->get_org_contact_name_local($this->get_contact_person_2()->get_id());
+                                       }
+                                       else
+                                       {
+                                           $contact_2  = null;
+                                       }
                                        $desc = 
activitycalendar_soorganization::get_instance()->get_description_local($this->get_organization_id());
                                }
                                else
@@ -281,7 +321,14 @@
                                        $org_name = 
activitycalendar_soorganization::get_instance()->get_organization_name($this->get_organization_id());
                                        
$this->set_contact_persons(activitycalendar_socontactperson::get_instance()->get_booking_contact_persons($this->get_organization_id()));
                                        $contact_1 = 
activitycalendar_socontactperson::get_instance()->get_org_contact_name($this->get_contact_person_1()->get_id());
-                                       $contact_2 = 
activitycalendar_socontactperson::get_instance()->get_org_contact_name($this->get_contact_person_2()->get_id());
+                                       if($this->get_contact_person_2())
+                                       {
+                                       $contact_2 = 
activitycalendar_socontactperson::get_instance()->get_org_contact_name($this->get_contact_person_2()->get_id());
+                               }
+                                       else
+                                       {
+                                           $contact_2  = null;
+                                       }
                                        $desc = 
activitycalendar_soorganization::get_instance()->get_description($this->get_organization_id());
                                }
                        } 

Modified: 
branches/stavangerkommune/activitycalendar/inc/model/class.arena.inc.php
===================================================================
--- branches/stavangerkommune/activitycalendar/inc/model/class.arena.inc.php    
2012-08-21 07:22:01 UTC (rev 9887)
+++ branches/stavangerkommune/activitycalendar/inc/model/class.arena.inc.php    
2012-08-21 07:37:50 UTC (rev 9888)
@@ -10,6 +10,9 @@
                protected $arena_name;
                protected $internal_arena_id;
                protected $address;
+               protected $addressnumber;
+               protected $zip_code;
+               protected $city;
                protected $reference;
                protected $active;
                
@@ -68,6 +71,36 @@
                {
                        return $this->address;
                }
+               
+           public function set_addressnumber($addressnumber)
+               {
+                       $this->addressnumber = $addressnumber;
+               }
+       
+               public function get_addressnumber()
+               {
+                       return $this->addressnumber;
+               }
+               
+           public function set_zip_code($zip_code)
+               {
+                       $this->zip_code = $zip_code;
+               }
+       
+               public function get_zip_code()
+               {
+                       return $this->zip_code;
+               }
+               
+           public function set_city($city)
+               {
+                       $this->city = $city;
+               }
+       
+               public function get_city()
+               {
+                       return $this->city;
+               }
 
                /**
                 * Get a static reference to the storage object associated with 
this model object
@@ -89,6 +122,9 @@
                                'id' => $this->get_id(),
                                'arena_name' => $this->get_arena_name(),
                                'address' => $this->get_address(),
+                           'addressnumber' => $this->get_addressnumber(),
+                           'zip_code' => $this->get_zip_code(),
+                           'city' => $this->get_city(),
                                'active' => 
($this->is_active())?'Aktiv':'Inaktiv'
                        );
                }

Modified: 
branches/stavangerkommune/activitycalendar/inc/model/class.group.inc.php
===================================================================
--- branches/stavangerkommune/activitycalendar/inc/model/class.group.inc.php    
2012-08-21 07:22:01 UTC (rev 9887)
+++ branches/stavangerkommune/activitycalendar/inc/model/class.group.inc.php    
2012-08-21 07:37:50 UTC (rev 9888)
@@ -13,6 +13,7 @@
                protected $shortname;
                protected $change_type;
                protected $transferred;
+               protected $original_group_id;
                
                /**
                 * Constructor.  Takes an optional ID.  If a organization is 
created from outside
@@ -81,6 +82,13 @@
                
                public function get_transferred() { return $this->transferred; }
                
+           public function set_original_group_id($original_group_id)
+               {
+                       $this->original_group_id = $original_group_id;
+               }
+               
+               public function get_original_group_id() { return 
$this->original_group_id; }
+               
                public function serialize()
                {
                        return array(

Modified: 
branches/stavangerkommune/activitycalendar/inc/model/class.organization.inc.php
===================================================================
--- 
branches/stavangerkommune/activitycalendar/inc/model/class.organization.inc.php 
    2012-08-21 07:22:01 UTC (rev 9887)
+++ 
branches/stavangerkommune/activitycalendar/inc/model/class.organization.inc.php 
    2012-08-21 07:37:50 UTC (rev 9888)
@@ -18,6 +18,9 @@
                protected $change_type;
                protected $transferred;
                protected $original_org_id;
+                protected $addressnumber;
+                protected $zip_code;
+                protected $city;
                
                /**
                 * Constructor.  Takes an optional ID.  If a organization is 
created from outside
@@ -121,6 +124,36 @@
                
                public function get_original_org_id() { return 
$this->original_org_id; }
                
+           public function set_addressnumber($addressnumber)
+               {
+                       $this->addressnumber = $addressnumber;
+               }
+       
+               public function get_addressnumber()
+               {
+                       return $this->addressnumber;
+               }
+               
+           public function set_zip_code($zip_code)
+               {
+                       $this->zip_code = $zip_code;
+               }
+       
+               public function get_zip_code()
+               {
+                       return $this->zip_code;
+               }
+               
+           public function set_city($city)
+               {
+                       $this->city = $city;
+               }
+       
+               public function get_city()
+               {
+                       return $this->city;
+               }
+               
                public function serialize()
                {
                        $so_org = 
activitycalendar_soorganization::get_instance();
@@ -134,6 +167,9 @@
                                'email' =>      $this->get_email(),
                                'phone' =>      $this->get_phone(),
                                'address'       =>      $this->get_address(),
+                           'addressnumber'     =>      
$this->get_addressnumber(),
+                           'zip_code'  =>      $this->get_zip_code(),
+                           'city'      =>      $this->get_city(),
                                'show_in_portal' => $this->get_show_in_portal(),
                                'change_type' => lang($this->get_change_type()),
                                'transferred' => $this->get_transferred(),

Copied: 
branches/stavangerkommune/activitycalendar/js/activitycalendar/jquery.js (from 
rev 9887, trunk/activitycalendar/js/activitycalendar/jquery.js)
===================================================================
--- branches/stavangerkommune/activitycalendar/js/activitycalendar/jquery.js    
                        (rev 0)
+++ branches/stavangerkommune/activitycalendar/js/activitycalendar/jquery.js    
2012-08-21 07:37:50 UTC (rev 9888)
@@ -0,0 +1,9404 @@
+/*!
+ * jQuery JavaScript Library v1.7.2
+ * http://jquery.com/
+ *
+ * Copyright 2011, John Resig
+ * Dual licensed under the MIT or GPL Version 2 licenses.
+ * http://jquery.org/license
+ *
+ * Includes Sizzle.js
+ * http://sizzlejs.com/
+ * Copyright 2011, The Dojo Foundation
+ * Released under the MIT, BSD, and GPL Licenses.
+ *
+ * Date: Wed Mar 21 12:46:34 2012 -0700
+ */
+(function( window, undefined ) {
+
+// Use the correct document accordingly with window argument (sandbox)
+var document = window.document,
+       navigator = window.navigator,
+       location = window.location;
+var jQuery = (function() {
+
+// Define a local copy of jQuery
+var jQuery = function( selector, context ) {
+               // The jQuery object is actually just the init constructor 
'enhanced'
+               return new jQuery.fn.init( selector, context, rootjQuery );
+       },
+
+       // Map over jQuery in case of overwrite
+       _jQuery = window.jQuery,
+
+       // Map over the $ in case of overwrite
+       _$ = window.$,
+
+       // A central reference to the root jQuery(document)
+       rootjQuery,
+
+       // A simple way to check for HTML strings or ID strings
+       // Prioritize #id over <tag> to avoid XSS via location.hash (#9521)
+       quickExpr = /^(?:[^#<]*(<[\w\W]+>)[^>]*$|#([\w\-]*)$)/,
+
+       // Check if a string has a non-whitespace character in it
+       rnotwhite = /\S/,
+
+       // Used for trimming whitespace
+       trimLeft = /^\s+/,
+       trimRight = /\s+$/,
+
+       // Match a standalone tag
+       rsingleTag = /^<(\w+)\s*\/?>(?:<\/\1>)?$/,
+
+       // JSON RegExp
+       rvalidchars = /^[\],:{}\s]*$/,
+       rvalidescape = /\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,
+       rvalidtokens = 
/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,
+       rvalidbraces = /(?:^|:|,)(?:\s*\[)+/g,
+
+       // Useragent RegExp
+       rwebkit = /(webkit)[ \/]([\w.]+)/,
+       ropera = /(opera)(?:.*version)?[ \/]([\w.]+)/,
+       rmsie = /(msie) ([\w.]+)/,
+       rmozilla = /(mozilla)(?:.*? rv:([\w.]+))?/,
+
+       // Matches dashed string for camelizing
+       rdashAlpha = /-([a-z]|[0-9])/ig,
+       rmsPrefix = /^-ms-/,
+
+       // Used by jQuery.camelCase as callback to replace()
+       fcamelCase = function( all, letter ) {
+               return ( letter + "" ).toUpperCase();
+       },
+
+       // Keep a UserAgent string for use with jQuery.browser
+       userAgent = navigator.userAgent,
+
+       // For matching the engine and version of the browser
+       browserMatch,
+
+       // The deferred used on DOM ready
+       readyList,
+
+       // The ready event handler
+       DOMContentLoaded,
+
+       // Save a reference to some core methods
+       toString = Object.prototype.toString,
+       hasOwn = Object.prototype.hasOwnProperty,
+       push = Array.prototype.push,
+       slice = Array.prototype.slice,
+       trim = String.prototype.trim,
+       indexOf = Array.prototype.indexOf,
+
+       // [[Class]] -> type pairs
+       class2type = {};
+
+jQuery.fn = jQuery.prototype = {
+       constructor: jQuery,
+       init: function( selector, context, rootjQuery ) {
+               var match, elem, ret, doc;
+
+               // Handle $(""), $(null), or $(undefined)
+               if ( !selector ) {
+                       return this;
+               }
+
+               // Handle $(DOMElement)
+               if ( selector.nodeType ) {
+                       this.context = this[0] = selector;
+                       this.length = 1;
+                       return this;
+               }
+
+               // The body element only exists once, optimize finding it
+               if ( selector === "body" && !context && document.body ) {
+                       this.context = document;
+                       this[0] = document.body;
+                       this.selector = selector;
+                       this.length = 1;
+                       return this;
+               }
+
+               // Handle HTML strings
+               if ( typeof selector === "string" ) {
+                       // Are we dealing with HTML string or an ID?
+                       if ( selector.charAt(0) === "<" && selector.charAt( 
selector.length - 1 ) === ">" && selector.length >= 3 ) {
+                               // Assume that strings that start and end with 
<> are HTML and skip the regex check
+                               match = [ null, selector, null ];
+
+                       } else {
+                               match = quickExpr.exec( selector );
+                       }
+
+                       // Verify a match, and that no context was specified 
for #id
+                       if ( match && (match[1] || !context) ) {
+
+                               // HANDLE: $(html) -> $(array)
+                               if ( match[1] ) {
+                                       context = context instanceof jQuery ? 
context[0] : context;
+                                       doc = ( context ? context.ownerDocument 
|| context : document );
+
+                                       // If a single string is passed in and 
it's a single tag
+                                       // just do a createElement and skip the 
rest
+                                       ret = rsingleTag.exec( selector );
+
+                                       if ( ret ) {
+                                               if ( jQuery.isPlainObject( 
context ) ) {
+                                                       selector = [ 
document.createElement( ret[1] ) ];
+                                                       jQuery.fn.attr.call( 
selector, context, true );
+
+                                               } else {
+                                                       selector = [ 
doc.createElement( ret[1] ) ];
+                                               }
+
+                                       } else {
+                                               ret = jQuery.buildFragment( [ 
match[1] ], [ doc ] );
+                                               selector = ( ret.cacheable ? 
jQuery.clone(ret.fragment) : ret.fragment ).childNodes;
+                                       }
+
+                                       return jQuery.merge( this, selector );
+
+                               // HANDLE: $("#id")
+                               } else {
+                                       elem = document.getElementById( 
match[2] );
+
+                                       // Check parentNode to catch when 
Blackberry 4.6 returns
+                                       // nodes that are no longer in the 
document #6963
+                                       if ( elem && elem.parentNode ) {
+                                               // Handle the case where IE and 
Opera return items
+                                               // by name instead of ID
+                                               if ( elem.id !== match[2] ) {
+                                                       return rootjQuery.find( 
selector );
+                                               }
+
+                                               // Otherwise, we inject the 
element directly into the jQuery object
+                                               this.length = 1;
+                                               this[0] = elem;
+                                       }
+
+                                       this.context = document;
+                                       this.selector = selector;
+                                       return this;
+                               }
+
+                       // HANDLE: $(expr, $(...))
+                       } else if ( !context || context.jquery ) {
+                               return ( context || rootjQuery ).find( selector 
);
+
+                       // HANDLE: $(expr, context)
+                       // (which is just equivalent to: $(context).find(expr)
+                       } else {
+                               return this.constructor( context ).find( 
selector );
+                       }
+
+               // HANDLE: $(function)
+               // Shortcut for document ready
+               } else if ( jQuery.isFunction( selector ) ) {
+                       return rootjQuery.ready( selector );
+               }
+
+               if ( selector.selector !== undefined ) {
+                       this.selector = selector.selector;
+                       this.context = selector.context;
+               }
+
+               return jQuery.makeArray( selector, this );
+       },
+
+       // Start with an empty selector
+       selector: "",
+
+       // The current version of jQuery being used
+       jquery: "1.7.2",
+
+       // The default length of a jQuery object is 0
+       length: 0,
+
+       // The number of elements contained in the matched element set
+       size: function() {
+               return this.length;
+       },
+
+       toArray: function() {
+               return slice.call( this, 0 );
+       },
+
+       // Get the Nth element in the matched element set OR
+       // Get the whole matched element set as a clean array
+       get: function( num ) {
+               return num == null ?
+
+                       // Return a 'clean' array
+                       this.toArray() :
+
+                       // Return just the object
+                       ( num < 0 ? this[ this.length + num ] : this[ num ] );
+       },
+
+       // Take an array of elements and push it onto the stack
+       // (returning the new matched element set)
+       pushStack: function( elems, name, selector ) {
+               // Build a new jQuery matched element set
+               var ret = this.constructor();
+
+               if ( jQuery.isArray( elems ) ) {
+                       push.apply( ret, elems );
+
+               } else {
+                       jQuery.merge( ret, elems );
+               }
+
+               // Add the old object onto the stack (as a reference)
+               ret.prevObject = this;
+
+               ret.context = this.context;
+
+               if ( name === "find" ) {
+                       ret.selector = this.selector + ( this.selector ? " " : 
"" ) + selector;
+               } else if ( name ) {
+                       ret.selector = this.selector + "." + name + "(" + 
selector + ")";
+               }
+
+               // Return the newly-formed element set
+               return ret;
+       },
+
+       // Execute a callback for every element in the matched set.
+       // (You can seed the arguments with an array of args, but this is
+       // only used internally.)
+       each: function( callback, args ) {
+               return jQuery.each( this, callback, args );
+       },
+
+       ready: function( fn ) {
+               // Attach the listeners
+               jQuery.bindReady();
+
+               // Add the callback
+               readyList.add( fn );
+
+               return this;
+       },
+
+       eq: function( i ) {
+               i = +i;
+               return i === -1 ?
+                       this.slice( i ) :
+                       this.slice( i, i + 1 );
+       },
+
+       first: function() {
+               return this.eq( 0 );
+       },
+
+       last: function() {
+               return this.eq( -1 );
+       },
+
+       slice: function() {
+               return this.pushStack( slice.apply( this, arguments ),
+                       "slice", slice.call(arguments).join(",") );
+       },
+
+       map: function( callback ) {
+               return this.pushStack( jQuery.map(this, function( elem, i ) {
+                       return callback.call( elem, i, elem );
+               }));
+       },
+
+       end: function() {
+               return this.prevObject || this.constructor(null);
+       },
+
+       // For internal use only.
+       // Behaves like an Array's method, not like a jQuery method.
+       push: push,
+       sort: [].sort,
+       splice: [].splice
+};
+
+// Give the init function the jQuery prototype for later instantiation
+jQuery.fn.init.prototype = jQuery.fn;
+
+jQuery.extend = jQuery.fn.extend = function() {
+       var options, name, src, copy, copyIsArray, clone,
+               target = arguments[0] || {},
+               i = 1,
+               length = arguments.length,
+               deep = false;
+
+       // Handle a deep copy situation
+       if ( typeof target === "boolean" ) {
+               deep = target;
+               target = arguments[1] || {};
+               // skip the boolean and the target
+               i = 2;
+       }
+
+       // Handle case when target is a string or something (possible in deep 
copy)
+       if ( typeof target !== "object" && !jQuery.isFunction(target) ) {
+               target = {};
+       }
+
+       // extend jQuery itself if only one argument is passed
+       if ( length === i ) {
+               target = this;
+               --i;
+       }
+
+       for ( ; i < length; i++ ) {
+               // Only deal with non-null/undefined values
+               if ( (options = arguments[ i ]) != null ) {
+                       // Extend the base object
+                       for ( name in options ) {
+                               src = target[ name ];
+                               copy = options[ name ];
+
+                               // Prevent never-ending loop
+                               if ( target === copy ) {
+                                       continue;
+                               }
+
+                               // Recurse if we're merging plain objects or 
arrays
+                               if ( deep && copy && ( 
jQuery.isPlainObject(copy) || (copyIsArray = jQuery.isArray(copy)) ) ) {
+                                       if ( copyIsArray ) {
+                                               copyIsArray = false;
+                                               clone = src && 
jQuery.isArray(src) ? src : [];
+
+                                       } else {
+                                               clone = src && 
jQuery.isPlainObject(src) ? src : {};
+                                       }
+
+                                       // Never move original objects, clone 
them
+                                       target[ name ] = jQuery.extend( deep, 
clone, copy );
+
+                               // Don't bring in undefined values
+                               } else if ( copy !== undefined ) {
+                                       target[ name ] = copy;
+                               }
+                       }
+               }
+       }
+
+       // Return the modified object
+       return target;
+};
+
+jQuery.extend({
+       noConflict: function( deep ) {
+               if ( window.$ === jQuery ) {
+                       window.$ = _$;
+               }
+
+               if ( deep && window.jQuery === jQuery ) {
+                       window.jQuery = _jQuery;
+               }
+
+               return jQuery;
+       },
+
+       // Is the DOM ready to be used? Set to true once it occurs.
+       isReady: false,
+
+       // A counter to track how many items to wait for before
+       // the ready event fires. See #6781
+       readyWait: 1,
+
+       // Hold (or release) the ready event
+       holdReady: function( hold ) {
+               if ( hold ) {
+                       jQuery.readyWait++;
+               } else {
+                       jQuery.ready( true );
+               }
+       },
+
+       // Handle when the DOM is ready
+       ready: function( wait ) {
+               // Either a released hold or an DOMready/load event and not yet 
ready
+               if ( (wait === true && !--jQuery.readyWait) || (wait !== true 
&& !jQuery.isReady) ) {
+                       // Make sure body exists, at least, in case IE gets a 
little overzealous (ticket #5443).
+                       if ( !document.body ) {
+                               return setTimeout( jQuery.ready, 1 );
+                       }
+
+                       // Remember that the DOM is ready
+                       jQuery.isReady = true;
+
+                       // If a normal DOM Ready event fired, decrement, and 
wait if need be
+                       if ( wait !== true && --jQuery.readyWait > 0 ) {
+                               return;
+                       }
+
+                       // If there are functions bound, to execute
+                       readyList.fireWith( document, [ jQuery ] );
+
+                       // Trigger any bound ready events
+                       if ( jQuery.fn.trigger ) {
+                               jQuery( document ).trigger( "ready" ).off( 
"ready" );
+                       }
+               }
+       },
+
+       bindReady: function() {
+               if ( readyList ) {
+                       return;
+               }
+
+               readyList = jQuery.Callbacks( "once memory" );
+
+               // Catch cases where $(document).ready() is called after the
+               // browser event has already occurred.
+               if ( document.readyState === "complete" ) {
+                       // Handle it asynchronously to allow scripts the 
opportunity to delay ready
+                       return setTimeout( jQuery.ready, 1 );
+               }
+
+               // Mozilla, Opera and webkit nightlies currently support this 
event
+               if ( document.addEventListener ) {
+                       // Use the handy event callback
+                       document.addEventListener( "DOMContentLoaded", 
DOMContentLoaded, false );
+
+                       // A fallback to window.onload, that will always work
+                       window.addEventListener( "load", jQuery.ready, false );
+
+               // If IE event model is used
+               } else if ( document.attachEvent ) {
+                       // ensure firing before onload,
+                       // maybe late but safe also for iframes
+                       document.attachEvent( "onreadystatechange", 
DOMContentLoaded );
+
+                       // A fallback to window.onload, that will always work
+                       window.attachEvent( "onload", jQuery.ready );
+
+                       // If IE and not a frame
+                       // continually check to see if the document is ready
+                       var toplevel = false;
+
+                       try {
+                               toplevel = window.frameElement == null;
+                       } catch(e) {}
+
+                       if ( document.documentElement.doScroll && toplevel ) {
+                               doScrollCheck();
+                       }
+               }
+       },
+
+       // See test/unit/core.js for details concerning isFunction.
+       // Since version 1.3, DOM methods and functions like alert
+       // aren't supported. They return false on IE (#2968).
+       isFunction: function( obj ) {
+               return jQuery.type(obj) === "function";
+       },
+
+       isArray: Array.isArray || function( obj ) {
+               return jQuery.type(obj) === "array";
+       },
+
+       isWindow: function( obj ) {
+               return obj != null && obj == obj.window;
+       },
+
+       isNumeric: function( obj ) {
+               return !isNaN( parseFloat(obj) ) && isFinite( obj );
+       },
+
+       type: function( obj ) {
+               return obj == null ?
+                       String( obj ) :
+                       class2type[ toString.call(obj) ] || "object";
+       },
+
+       isPlainObject: function( obj ) {
+               // Must be an Object.
+               // Because of IE, we also have to check the presence of the 
constructor property.
+               // Make sure that DOM nodes and window objects don't pass 
through, as well
+               if ( !obj || jQuery.type(obj) !== "object" || obj.nodeType || 
jQuery.isWindow( obj ) ) {
+                       return false;
+               }
+
+               try {
+                       // Not own constructor property must be Object
+                       if ( obj.constructor &&
+                               !hasOwn.call(obj, "constructor") &&
+                               !hasOwn.call(obj.constructor.prototype, 
"isPrototypeOf") ) {
+                               return false;
+                       }
+               } catch ( e ) {
+                       // IE8,9 Will throw exceptions on certain host objects 
#9897
+                       return false;
+               }
+
+               // Own properties are enumerated firstly, so to speed up,
+               // if last one is own, then all properties are own.
+
+               var key;
+               for ( key in obj ) {}
+
+               return key === undefined || hasOwn.call( obj, key );
+       },
+
+       isEmptyObject: function( obj ) {
+               for ( var name in obj ) {
+                       return false;
+               }
+               return true;
+       },
+
+       error: function( msg ) {
+               throw new Error( msg );
+       },
+
+       parseJSON: function( data ) {
+               if ( typeof data !== "string" || !data ) {
+                       return null;
+               }
+
+               // Make sure leading/trailing whitespace is removed (IE can't 
handle it)
+               data = jQuery.trim( data );
+
+               // Attempt to parse using the native JSON parser first
+               if ( window.JSON && window.JSON.parse ) {
+                       return window.JSON.parse( data );
+               }
+
+               // Make sure the incoming data is actual JSON
+               // Logic borrowed from http://json.org/json2.js
+               if ( rvalidchars.test( data.replace( rvalidescape, "@" )
+                       .replace( rvalidtokens, "]" )
+                       .replace( rvalidbraces, "")) ) {
+
+                       return ( new Function( "return " + data ) )();
+
+               }
+               jQuery.error( "Invalid JSON: " + data );
+       },
+
+       // Cross-browser xml parsing
+       parseXML: function( data ) {
+               if ( typeof data !== "string" || !data ) {
+                       return null;
+               }
+               var xml, tmp;
+               try {
+                       if ( window.DOMParser ) { // Standard
+                               tmp = new DOMParser();
+                               xml = tmp.parseFromString( data , "text/xml" );
+                       } else { // IE
+                               xml = new ActiveXObject( "Microsoft.XMLDOM" );
+                               xml.async = "false";
+                               xml.loadXML( data );
+                       }
+               } catch( e ) {
+                       xml = undefined;
+               }
+               if ( !xml || !xml.documentElement || xml.getElementsByTagName( 
"parsererror" ).length ) {
+                       jQuery.error( "Invalid XML: " + data );
+               }
+               return xml;
+       },
+
+       noop: function() {},
+
+       // Evaluates a script in a global context
+       // Workarounds based on findings by Jim Driscoll
+       // 
http://weblogs.java.net/blog/driscoll/archive/2009/09/08/eval-javascript-global-context
+       globalEval: function( data ) {
+               if ( data && rnotwhite.test( data ) ) {
+                       // We use execScript on Internet Explorer
+                       // We use an anonymous function so that context is 
window
+                       // rather than jQuery in Firefox
+                       ( window.execScript || function( data ) {
+                               window[ "eval" ].call( window, data );
+                       } )( data );
+               }
+       },
+
+       // Convert dashed to camelCase; used by the css and data modules
+       // Microsoft forgot to hump their vendor prefix (#9572)
+       camelCase: function( string ) {
+               return string.replace( rmsPrefix, "ms-" ).replace( rdashAlpha, 
fcamelCase );
+       },
+
+       nodeName: function( elem, name ) {
+               return elem.nodeName && elem.nodeName.toUpperCase() === 
name.toUpperCase();
+       },
+
+       // args is for internal usage only
+       each: function( object, callback, args ) {
+               var name, i = 0,
+                       length = object.length,
+                       isObj = length === undefined || jQuery.isFunction( 
object );
+
+               if ( args ) {
+                       if ( isObj ) {
+                               for ( name in object ) {
+                                       if ( callback.apply( object[ name ], 
args ) === false ) {
+                                               break;
+                                       }
+                               }
+                       } else {
+                               for ( ; i < length; ) {
+                                       if ( callback.apply( object[ i++ ], 
args ) === false ) {
+                                               break;
+                                       }
+                               }
+                       }
+
+               // A special, fast, case for the most common use of each
+               } else {
+                       if ( isObj ) {
+                               for ( name in object ) {
+                                       if ( callback.call( object[ name ], 
name, object[ name ] ) === false ) {
+                                               break;
+                                       }
+                               }
+                       } else {
+                               for ( ; i < length; ) {
+                                       if ( callback.call( object[ i ], i, 
object[ i++ ] ) === false ) {
+                                               break;
+                                       }
+                               }
+                       }
+               }
+
+               return object;
+       },
+
+       // Use native String.trim function wherever possible
+       trim: trim ?
+               function( text ) {
+                       return text == null ?
+                               "" :
+                               trim.call( text );
+               } :
+
+               // Otherwise use our own trimming functionality
+               function( text ) {
+                       return text == null ?
+                               "" :
+                               text.toString().replace( trimLeft, "" 
).replace( trimRight, "" );
+               },
+
+       // results is for internal usage only
+       makeArray: function( array, results ) {
+               var ret = results || [];
+
+               if ( array != null ) {
+                       // The window, strings (and functions) also have 
'length'
+                       // Tweaked logic slightly to handle Blackberry 4.7 
RegExp issues #6930
+                       var type = jQuery.type( array );
+
+                       if ( array.length == null || type === "string" || type 
=== "function" || type === "regexp" || jQuery.isWindow( array ) ) {
+                               push.call( ret, array );
+                       } else {
+                               jQuery.merge( ret, array );
+                       }
+               }
+
+               return ret;
+       },
+
+       inArray: function( elem, array, i ) {
+               var len;
+
+               if ( array ) {
+                       if ( indexOf ) {
+                               return indexOf.call( array, elem, i );
+                       }
+
+                       len = array.length;
+                       i = i ? i < 0 ? Math.max( 0, len + i ) : i : 0;
+
+                       for ( ; i < len; i++ ) {
+                               // Skip accessing in sparse arrays
+                               if ( i in array && array[ i ] === elem ) {
+                                       return i;
+                               }
+                       }
+               }
+
+               return -1;
+       },
+
+       merge: function( first, second ) {
+               var i = first.length,
+                       j = 0;
+
+               if ( typeof second.length === "number" ) {
+                       for ( var l = second.length; j < l; j++ ) {
+                               first[ i++ ] = second[ j ];
+                       }
+
+               } else {
+                       while ( second[j] !== undefined ) {
+                               first[ i++ ] = second[ j++ ];
+                       }
+               }
+
+               first.length = i;
+
+               return first;
+       },
+
+       grep: function( elems, callback, inv ) {
+               var ret = [], retVal;
+               inv = !!inv;
+
+               // Go through the array, only saving the items
+               // that pass the validator function
+               for ( var i = 0, length = elems.length; i < length; i++ ) {
+                       retVal = !!callback( elems[ i ], i );
+                       if ( inv !== retVal ) {
+                               ret.push( elems[ i ] );
+                       }
+               }
+
+               return ret;
+       },
+
+       // arg is for internal usage only
+       map: function( elems, callback, arg ) {
+               var value, key, ret = [],
+                       i = 0,
+                       length = elems.length,
+                       // jquery objects are treated as arrays
+                       isArray = elems instanceof jQuery || length !== 
undefined && typeof length === "number" && ( ( length > 0 && elems[ 0 ] && 
elems[ length -1 ] ) || length === 0 || jQuery.isArray( elems ) ) ;
+
+               // Go through the array, translating each of the items to their
+               if ( isArray ) {
+                       for ( ; i < length; i++ ) {
+                               value = callback( elems[ i ], i, arg );
+
+                               if ( value != null ) {
+                                       ret[ ret.length ] = value;
+                               }
+                       }
+
+               // Go through every key on the object,
+               } else {
+                       for ( key in elems ) {
+                               value = callback( elems[ key ], key, arg );
+
+                               if ( value != null ) {
+                                       ret[ ret.length ] = value;
+                               }
+                       }
+               }
+
+               // Flatten any nested arrays
+               return ret.concat.apply( [], ret );
+       },
+
+       // A global GUID counter for objects
+       guid: 1,
+
+       // Bind a function to a context, optionally partially applying any
+       // arguments.
+       proxy: function( fn, context ) {
+               if ( typeof context === "string" ) {
+                       var tmp = fn[ context ];
+                       context = fn;
+                       fn = tmp;
+               }
+
+               // Quick check to determine if target is callable, in the spec
+               // this throws a TypeError, but we will just return undefined.
+               if ( !jQuery.isFunction( fn ) ) {
+                       return undefined;
+               }
+
+               // Simulated bind
+               var args = slice.call( arguments, 2 ),
+                       proxy = function() {
+                               return fn.apply( context, args.concat( 
slice.call( arguments ) ) );
+                       };
+
+               // Set the guid of unique handler to the same of original 
handler, so it can be removed
+               proxy.guid = fn.guid = fn.guid || proxy.guid || jQuery.guid++;
+
+               return proxy;
+       },
+
+       // Mutifunctional method to get and set values to a collection
+       // The value/s can optionally be executed if it's a function
+       access: function( elems, fn, key, value, chainable, emptyGet, pass ) {
+               var exec,
+                       bulk = key == null,
+                       i = 0,
+                       length = elems.length;
+
+               // Sets many values
+               if ( key && typeof key === "object" ) {
+                       for ( i in key ) {
+                               jQuery.access( elems, fn, i, key[i], 1, 
emptyGet, value );
+                       }
+                       chainable = 1;
+
+               // Sets one value
+               } else if ( value !== undefined ) {
+                       // Optionally, function values get executed if exec is 
true
+                       exec = pass === undefined && jQuery.isFunction( value );
+
+                       if ( bulk ) {
+                               // Bulk operations only iterate when executing 
function values
+                               if ( exec ) {
+                                       exec = fn;
+                                       fn = function( elem, key, value ) {
+                                               return exec.call( jQuery( elem 
), value );
+                                       };
+
+                               // Otherwise they run against the entire set
+                               } else {
+                                       fn.call( elems, value );
+                                       fn = null;
+                               }
+                       }
+
+                       if ( fn ) {
+                               for (; i < length; i++ ) {
+                                       fn( elems[i], key, exec ? value.call( 
elems[i], i, fn( elems[i], key ) ) : value, pass );
+                               }
+                       }
+
+                       chainable = 1;
+               }
+
+               return chainable ?
+                       elems :
+
+                       // Gets
+                       bulk ?
+                               fn.call( elems ) :
+                               length ? fn( elems[0], key ) : emptyGet;
+       },
+
+       now: function() {
+               return ( new Date() ).getTime();
+       },
+
+       // Use of jQuery.browser is frowned upon.
+       // More details: http://docs.jquery.com/Utilities/jQuery.browser
+       uaMatch: function( ua ) {
+               ua = ua.toLowerCase();
+
+               var match = rwebkit.exec( ua ) ||
+                       ropera.exec( ua ) ||
+                       rmsie.exec( ua ) ||
+                       ua.indexOf("compatible") < 0 && rmozilla.exec( ua ) ||
+                       [];
+
+               return { browser: match[1] || "", version: match[2] || "0" };
+       },
+
+       sub: function() {
+               function jQuerySub( selector, context ) {
+                       return new jQuerySub.fn.init( selector, context );
+               }
+               jQuery.extend( true, jQuerySub, this );
+               jQuerySub.superclass = this;
+               jQuerySub.fn = jQuerySub.prototype = this();
+               jQuerySub.fn.constructor = jQuerySub;
+               jQuerySub.sub = this.sub;
+               jQuerySub.fn.init = function init( selector, context ) {
+                       if ( context && context instanceof jQuery && !(context 
instanceof jQuerySub) ) {
+                               context = jQuerySub( context );
+                       }
+
+                       return jQuery.fn.init.call( this, selector, context, 
rootjQuerySub );
+               };
+               jQuerySub.fn.init.prototype = jQuerySub.fn;
+               var rootjQuerySub = jQuerySub(document);
+               return jQuerySub;
+       },
+
+       browser: {}
+});
+
+// Populate the class2type map
+jQuery.each("Boolean Number String Function Array Date RegExp Object".split(" 
"), function(i, name) {
+       class2type[ "[object " + name + "]" ] = name.toLowerCase();
+});
+
+browserMatch = jQuery.uaMatch( userAgent );
+if ( browserMatch.browser ) {
+       jQuery.browser[ browserMatch.browser ] = true;
+       jQuery.browser.version = browserMatch.version;
+}
+
+// Deprecated, use jQuery.browser.webkit instead
+if ( jQuery.browser.webkit ) {
+       jQuery.browser.safari = true;
+}
+
+// IE doesn't match non-breaking spaces with \s
+if ( rnotwhite.test( "\xA0" ) ) {
+       trimLeft = /^[\s\xA0]+/;
+       trimRight = /[\s\xA0]+$/;
+}
+
+// All jQuery objects should point back to these
+rootjQuery = jQuery(document);
+
+// Cleanup functions for the document ready method
+if ( document.addEventListener ) {
+       DOMContentLoaded = function() {
+               document.removeEventListener( "DOMContentLoaded", 
DOMContentLoaded, false );
+               jQuery.ready();
+       };
+
+} else if ( document.attachEvent ) {
+       DOMContentLoaded = function() {
+               // Make sure body exists, at least, in case IE gets a little 
overzealous (ticket #5443).
+               if ( document.readyState === "complete" ) {
+                       document.detachEvent( "onreadystatechange", 
DOMContentLoaded );
+                       jQuery.ready();
+               }
+       };
+}
+
+// The DOM ready check for Internet Explorer
+function doScrollCheck() {
+       if ( jQuery.isReady ) {
+               return;
+       }
+
+       try {
+               // If IE is used, use the trick by Diego Perini
+               // http://javascript.nwbox.com/IEContentLoaded/
+               document.documentElement.doScroll("left");
+       } catch(e) {
+               setTimeout( doScrollCheck, 1 );
+               return;
+       }
+
+       // and execute any waiting functions
+       jQuery.ready();
+}
+
+return jQuery;
+
+})();
+
+
+// String to Object flags format cache
+var flagsCache = {};
+
+// Convert String-formatted flags into Object-formatted ones and store in cache
+function createFlags( flags ) {
+       var object = flagsCache[ flags ] = {},
+               i, length;
+       flags = flags.split( /\s+/ );
+       for ( i = 0, length = flags.length; i < length; i++ ) {
+               object[ flags[i] ] = true;
+       }
+       return object;
+}
+
+/*
+ * Create a callback list using the following parameters:
+ *
+ *     flags:  an optional list of space-separated flags that will change how
+ *                     the callback list behaves
+ *
+ * By default a callback list will act like an event callback list and can be
+ * "fired" multiple times.
+ *
+ * Possible flags:
+ *
+ *     once:                   will ensure the callback list can only be fired 
once (like a Deferred)
+ *
+ *     memory:                 will keep track of previous values and will 
call any callback added
+ *                                     after the list has been fired right 
away with the latest "memorized"
+ *                                     values (like a Deferred)
+ *
+ *     unique:                 will ensure a callback can only be added once 
(no duplicate in the list)
+ *
+ *     stopOnFalse:    interrupt callings when a callback returns false
+ *
+ */
+jQuery.Callbacks = function( flags ) {
+
+       // Convert flags from String-formatted to Object-formatted
+       // (we check in cache first)
+       flags = flags ? ( flagsCache[ flags ] || createFlags( flags ) ) : {};
+
+       var // Actual callback list
+               list = [],
+               // Stack of fire calls for repeatable lists
+               stack = [],
+               // Last fire value (for non-forgettable lists)
+               memory,
+               // Flag to know if list was already fired
+               fired,
+               // Flag to know if list is currently firing
+               firing,
+               // First callback to fire (used internally by add and fireWith)
+               firingStart,
+               // End of the loop when firing
+               firingLength,
+               // Index of currently firing callback (modified by remove if 
needed)
+               firingIndex,
+               // Add one or several callbacks to the list
+               add = function( args ) {
+                       var i,
+                               length,
+                               elem,
+                               type,
+                               actual;
+                       for ( i = 0, length = args.length; i < length; i++ ) {
+                               elem = args[ i ];
+                               type = jQuery.type( elem );
+                               if ( type === "array" ) {
+                                       // Inspect recursively
+                                       add( elem );
+                               } else if ( type === "function" ) {
+                                       // Add if not in unique mode and 
callback is not in
+                                       if ( !flags.unique || !self.has( elem ) 
) {
+                                               list.push( elem );
+                                       }
+                               }
+                       }
+               },
+               // Fire callbacks
+               fire = function( context, args ) {
+                       args = args || [];
+                       memory = !flags.memory || [ context, args ];
+                       fired = true;
+                       firing = true;
+                       firingIndex = firingStart || 0;
+                       firingStart = 0;
+                       firingLength = list.length;
+                       for ( ; list && firingIndex < firingLength; 
firingIndex++ ) {
+                               if ( list[ firingIndex ].apply( context, args ) 
=== false && flags.stopOnFalse ) {
+                                       memory = true; // Mark as halted
+                                       break;
+                               }
+                       }
+                       firing = false;
+                       if ( list ) {
+                               if ( !flags.once ) {
+                                       if ( stack && stack.length ) {
+                                               memory = stack.shift();
+                                               self.fireWith( memory[ 0 ], 
memory[ 1 ] );
+                                       }
+                               } else if ( memory === true ) {
+                                       self.disable();
+                               } else {
+                                       list = [];
+                               }
+                       }
+               },
+               // Actual Callbacks object
+               self = {
+                       // Add a callback or a collection of callbacks to the 
list
+                       add: function() {
+                               if ( list ) {
+                                       var length = list.length;
+                                       add( arguments );
+                                       // Do we need to add the callbacks to 
the
+                                       // current firing batch?
+                                       if ( firing ) {
+                                               firingLength = list.length;
+                                       // With memory, if we're not firing then
+                                       // we should call right away, unless 
previous
+                                       // firing was halted (stopOnFalse)
+                                       } else if ( memory && memory !== true ) 
{
+                                               firingStart = length;
+                                               fire( memory[ 0 ], memory[ 1 ] 
);
+                                       }
+                               }
+                               return this;
+                       },
+                       // Remove a callback from the list
+                       remove: function() {
+                               if ( list ) {
+                                       var args = arguments,
+                                               argIndex = 0,
+                                               argLength = args.length;
+                                       for ( ; argIndex < argLength ; 
argIndex++ ) {
+                                               for ( var i = 0; i < 
list.length; i++ ) {
+                                                       if ( args[ argIndex ] 
=== list[ i ] ) {
+                                                               // Handle 
firingIndex and firingLength
+                                                               if ( firing ) {
+                                                                       if ( i 
<= firingLength ) {
+                                                                               
firingLength--;
+                                                                               
if ( i <= firingIndex ) {
+                                                                               
        firingIndex--;
+                                                                               
}
+                                                                       }
+                                                               }
+                                                               // Remove the 
element
+                                                               list.splice( 
i--, 1 );
+                                                               // If we have 
some unicity property then
+                                                               // we only need 
to do this once
+                                                               if ( 
flags.unique ) {
+                                                                       break;
+                                                               }
+                                                       }
+                                               }
+                                       }
+                               }
+                               return this;
+                       },
+                       // Control if a given callback is in the list
+                       has: function( fn ) {
+                               if ( list ) {
+                                       var i = 0,
+                                               length = list.length;
+                                       for ( ; i < length; i++ ) {
+                                               if ( fn === list[ i ] ) {
+                                                       return true;
+                                               }
+                                       }
+                               }
+                               return false;
+                       },
+                       // Remove all callbacks from the list
+                       empty: function() {
+                               list = [];
+                               return this;
+                       },
+                       // Have the list do nothing anymore
+                       disable: function() {
+                               list = stack = memory = undefined;
+                               return this;
+                       },
+                       // Is it disabled?
+                       disabled: function() {
+                               return !list;
+                       },
+                       // Lock the list in its current state
+                       lock: function() {
+                               stack = undefined;
+                               if ( !memory || memory === true ) {
+                                       self.disable();
+                               }
+                               return this;
+                       },
+                       // Is it locked?
+                       locked: function() {
+                               return !stack;
+                       },
+                       // Call all callbacks with the given context and 
arguments
+                       fireWith: function( context, args ) {
+                               if ( stack ) {
+                                       if ( firing ) {
+                                               if ( !flags.once ) {
+                                                       stack.push( [ context, 
args ] );
+                                               }
+                                       } else if ( !( flags.once && memory ) ) 
{
+                                               fire( context, args );
+                                       }
+                               }
+                               return this;
+                       },
+                       // Call all the callbacks with the given arguments
+                       fire: function() {
+                               self.fireWith( this, arguments );
+                               return this;
+                       },
+                       // To know if the callbacks have already been called at 
least once
+                       fired: function() {
+                               return !!fired;
+                       }
+               };
+
+       return self;
+};
+
+
+
+
+var // Static reference to slice
+       sliceDeferred = [].slice;
+
+jQuery.extend({
+
+       Deferred: function( func ) {
+               var doneList = jQuery.Callbacks( "once memory" ),
+                       failList = jQuery.Callbacks( "once memory" ),
+                       progressList = jQuery.Callbacks( "memory" ),
+                       state = "pending",
+                       lists = {
+                               resolve: doneList,
+                               reject: failList,
+                               notify: progressList
+                       },
+                       promise = {
+                               done: doneList.add,
+                               fail: failList.add,
+                               progress: progressList.add,
+
+                               state: function() {
+                                       return state;
+                               },
+
+                               // Deprecated
+                               isResolved: doneList.fired,
+                               isRejected: failList.fired,
+
+                               then: function( doneCallbacks, failCallbacks, 
progressCallbacks ) {
+                                       deferred.done( doneCallbacks ).fail( 
failCallbacks ).progress( progressCallbacks );
+                                       return this;
+                               },
+                               always: function() {
+                                       deferred.done.apply( deferred, 
arguments ).fail.apply( deferred, arguments );
+                                       return this;
+                               },
+                               pipe: function( fnDone, fnFail, fnProgress ) {
+                                       return jQuery.Deferred(function( 
newDefer ) {
+                                               jQuery.each( {
+                                                       done: [ fnDone, 
"resolve" ],
+                                                       fail: [ fnFail, 
"reject" ],
+                                                       progress: [ fnProgress, 
"notify" ]
+                                               }, function( handler, data ) {
+                                                       var fn = data[ 0 ],
+                                                               action = data[ 
1 ],
+                                                               returned;
+                                                       if ( jQuery.isFunction( 
fn ) ) {
+                                                               deferred[ 
handler ](function() {
+                                                                       
returned = fn.apply( this, arguments );
+                                                                       if ( 
returned && jQuery.isFunction( returned.promise ) ) {
+                                                                               
returned.promise().then( newDefer.resolve, newDefer.reject, newDefer.notify );
+                                                                       } else {
+                                                                               
newDefer[ action + "With" ]( this === deferred ? newDefer : this, [ returned ] 
);
+                                                                       }
+                                                               });
+                                                       } else {
+                                                               deferred[ 
handler ]( newDefer[ action ] );
+                                                       }
+                                               });
+                                       }).promise();
+                               },
+                               // Get a promise for this deferred
+                               // If obj is provided, the promise aspect is 
added to the object
+                               promise: function( obj ) {
+                                       if ( obj == null ) {
+                                               obj = promise;
+                                       } else {
+                                               for ( var key in promise ) {
+                                                       obj[ key ] = promise[ 
key ];
+                                               }
+                                       }
+                                       return obj;
+                               }
+                       },
+                       deferred = promise.promise({}),
+                       key;
+
+               for ( key in lists ) {
+                       deferred[ key ] = lists[ key ].fire;
+                       deferred[ key + "With" ] = lists[ key ].fireWith;
+               }
+
+               // Handle state
+               deferred.done( function() {
+                       state = "resolved";
+               }, failList.disable, progressList.lock ).fail( function() {
+                       state = "rejected";
+               }, doneList.disable, progressList.lock );
+
+               // Call given func if any
+               if ( func ) {
+                       func.call( deferred, deferred );
+               }
+
+               // All done!
+               return deferred;
+       },
+
+       // Deferred helper
+       when: function( firstParam ) {
+               var args = sliceDeferred.call( arguments, 0 ),
+                       i = 0,
+                       length = args.length,
+                       pValues = new Array( length ),
+                       count = length,
+                       pCount = length,
+                       deferred = length <= 1 && firstParam && 
jQuery.isFunction( firstParam.promise ) ?
+                               firstParam :
+                               jQuery.Deferred(),
+                       promise = deferred.promise();
+               function resolveFunc( i ) {
+                       return function( value ) {
+                               args[ i ] = arguments.length > 1 ? 
sliceDeferred.call( arguments, 0 ) : value;
+                               if ( !( --count ) ) {
+                                       deferred.resolveWith( deferred, args );
+                               }
+                       };
+               }
+               function progressFunc( i ) {
+                       return function( value ) {
+                               pValues[ i ] = arguments.length > 1 ? 
sliceDeferred.call( arguments, 0 ) : value;
+                               deferred.notifyWith( promise, pValues );
+                       };
+               }
+               if ( length > 1 ) {
+                       for ( ; i < length; i++ ) {
+                               if ( args[ i ] && args[ i ].promise && 
jQuery.isFunction( args[ i ].promise ) ) {
+                                       args[ i ].promise().then( 
resolveFunc(i), deferred.reject, progressFunc(i) );
+                               } else {
+                                       --count;
+                               }
+                       }
+                       if ( !count ) {
+                               deferred.resolveWith( deferred, args );
+                       }
+               } else if ( deferred !== firstParam ) {
+                       deferred.resolveWith( deferred, length ? [ firstParam ] 
: [] );
+               }
+               return promise;
+       }
+});
+
+
+
+
+jQuery.support = (function() {
+
+       var support,
+               all,
+               a,
+               select,
+               opt,
+               input,
+               fragment,
+               tds,
+               events,
+               eventName,
+               i,
+               isSupported,
+               div = document.createElement( "div" ),
+               documentElement = document.documentElement;
+
+       // Preliminary tests
+       div.setAttribute("className", "t");
+       div.innerHTML = "   <link/><table></table><a href='/a' 
style='top:1px;float:left;opacity:.55;'>a</a><input type='checkbox'/>";
+
+       all = div.getElementsByTagName( "*" );
+       a = div.getElementsByTagName( "a" )[ 0 ];
+
+       // Can't get basic test support
+       if ( !all || !all.length || !a ) {
+               return {};
+       }
+
+       // First batch of supports tests
+       select = document.createElement( "select" );
+       opt = select.appendChild( document.createElement("option") );
+       input = div.getElementsByTagName( "input" )[ 0 ];
+
+       support = {
+               // IE strips leading whitespace when .innerHTML is used
+               leadingWhitespace: ( div.firstChild.nodeType === 3 ),
+
+               // Make sure that tbody elements aren't automatically inserted
+               // IE will insert them into empty tables
+               tbody: !div.getElementsByTagName("tbody").length,
+
+               // Make sure that link elements get serialized correctly by 
innerHTML
+               // This requires a wrapper element in IE
+               htmlSerialize: !!div.getElementsByTagName("link").length,
+
+               // Get the style information from getAttribute
+               // (IE uses .cssText instead)
+               style: /top/.test( a.getAttribute("style") ),
+
+               // Make sure that URLs aren't manipulated
+               // (IE normalizes it by default)
+               hrefNormalized: ( a.getAttribute("href") === "/a" ),
+
+               // Make sure that element opacity exists
+               // (IE uses filter instead)
+               // Use a regex to work around a WebKit issue. See #5145
+               opacity: /^0.55/.test( a.style.opacity ),
+
+               // Verify style float existence
+               // (IE uses styleFloat instead of cssFloat)
+               cssFloat: !!a.style.cssFloat,
+
+               // Make sure that if no value is specified for a checkbox
+               // that it defaults to "on".
+               // (WebKit defaults to "" instead)
+               checkOn: ( input.value === "on" ),
+
+               // Make sure that a selected-by-default option has a working 
selected property.
+               // (WebKit defaults to false instead of true, IE too, if it's 
in an optgroup)
+               optSelected: opt.selected,
+
+               // Test setAttribute on camelCase class. If it works, we need 
attrFixes when doing get/setAttribute (ie6/7)
+               getSetAttribute: div.className !== "t",
+
+               // Tests for enctype support on a form(#6743)
+               enctype: !!document.createElement("form").enctype,
+
+               // Makes sure cloning an html5 element does not cause problems
+               // Where outerHTML is undefined, this still works
+               html5Clone: document.createElement("nav").cloneNode( true 
).outerHTML !== "<:nav></:nav>",
+
+               // Will be defined later
+               submitBubbles: true,
+               changeBubbles: true,
+               focusinBubbles: false,
+               deleteExpando: true,
+               noCloneEvent: true,
+               inlineBlockNeedsLayout: false,
+               shrinkWrapBlocks: false,
+               reliableMarginRight: true,
+               pixelMargin: true
+       };
+
+       // jQuery.boxModel DEPRECATED in 1.3, use jQuery.support.boxModel 
instead
+       jQuery.boxModel = support.boxModel = (document.compatMode === 
"CSS1Compat");
+
+       // Make sure checked status is properly cloned
+       input.checked = true;
+       support.noCloneChecked = input.cloneNode( true ).checked;
+
+       // Make sure that the options inside disabled selects aren't marked as 
disabled
+       // (WebKit marks them as disabled)
+       select.disabled = true;
+       support.optDisabled = !opt.disabled;
+
+       // Test to see if it's possible to delete an expando from an element
+       // Fails in Internet Explorer
+       try {
+               delete div.test;
+       } catch( e ) {
+               support.deleteExpando = false;
+       }
+
+       if ( !div.addEventListener && div.attachEvent && div.fireEvent ) {
+               div.attachEvent( "onclick", function() {
+                       // Cloning a node shouldn't copy over any
+                       // bound event handlers (IE does this)
+                       support.noCloneEvent = false;
+               });
+               div.cloneNode( true ).fireEvent( "onclick" );
+       }
+
+       // Check if a radio maintains its value
+       // after being appended to the DOM
+       input = document.createElement("input");
+       input.value = "t";
+       input.setAttribute("type", "radio");
+       support.radioValue = input.value === "t";
+
+       input.setAttribute("checked", "checked");
+
+       // #11217 - WebKit loses check when the name is after the checked 
attribute
+       input.setAttribute( "name", "t" );
+
+       div.appendChild( input );
+       fragment = document.createDocumentFragment();
+       fragment.appendChild( div.lastChild );
+
+       // WebKit doesn't clone checked state correctly in fragments
+       support.checkClone = fragment.cloneNode( true ).cloneNode( true 
).lastChild.checked;
+
+       // Check if a disconnected checkbox will retain its checked
+       // value of true after appended to the DOM (IE6/7)
+       support.appendChecked = input.checked;
+
+       fragment.removeChild( input );
+       fragment.appendChild( div );
+
+       // Technique from Juriy Zaytsev
+       // 
http://perfectionkills.com/detecting-event-support-without-browser-sniffing/
+       // We only care about the case where non-standard event systems
+       // are used, namely in IE. Short-circuiting here helps us to
+       // avoid an eval call (in setAttribute) which can cause CSP
+       // to go haywire. See: https://developer.mozilla.org/en/Security/CSP
+       if ( div.attachEvent ) {
+               for ( i in {
+                       submit: 1,
+                       change: 1,
+                       focusin: 1
+               }) {
+                       eventName = "on" + i;
+                       isSupported = ( eventName in div );
+                       if ( !isSupported ) {
+                               div.setAttribute( eventName, "return;" );
+                               isSupported = ( typeof div[ eventName ] === 
"function" );
+                       }
+                       support[ i + "Bubbles" ] = isSupported;
+               }
+       }
+
+       fragment.removeChild( div );
+
+       // Null elements to avoid leaks in IE
+       fragment = select = opt = div = input = null;
+
+       // Run tests that need a body at doc ready
+       jQuery(function() {
+               var container, outer, inner, table, td, offsetSupport,
+                       marginDiv, conMarginTop, style, html, 
positionTopLeftWidthHeight,
+                       paddingMarginBorderVisibility, paddingMarginBorder,
+                       body = document.getElementsByTagName("body")[0];
+
+               if ( !body ) {
+                       // Return for frameset docs that don't have a body
+                       return;
+               }
+
+               conMarginTop = 1;
+               paddingMarginBorder = "padding:0;margin:0;border:";
+               positionTopLeftWidthHeight = 
"position:absolute;top:0;left:0;width:1px;height:1px;";
+               paddingMarginBorderVisibility = paddingMarginBorder + 
"0;visibility:hidden;";
+               style = "style='" + positionTopLeftWidthHeight + 
paddingMarginBorder + "5px solid #000;";
+               html = "<div " + style + "display:block;'><div style='" + 
paddingMarginBorder + "0;display:block;overflow:hidden;'></div></div>" +
+                       "<table " + style + "' cellpadding='0' 
cellspacing='0'>" +
+                       "<tr><td></td></tr></table>";
+
+               container = document.createElement("div");
+               container.style.cssText = paddingMarginBorderVisibility + 
"width:0;height:0;position:static;top:0;margin-top:" + conMarginTop + "px";
+               body.insertBefore( container, body.firstChild );
+
+               // Construct the test element
+               div = document.createElement("div");
+               container.appendChild( div );
+
+               // Check if table cells still have offsetWidth/Height when they 
are set
+               // to display:none and there are still other visible table 
cells in a
+               // table row; if so, offsetWidth/Height are not reliable for 
use when
+               // determining if an element has been hidden directly using
+               // display:none (it is still safe to use offsets if a parent 
element is
+               // hidden; don safety goggles and see bug #4512 for more 
information).
+               // (only IE 8 fails this test)
+               div.innerHTML = "<table><tr><td style='" + paddingMarginBorder 
+ "0;display:none'></td><td>t</td></tr></table>";
+               tds = div.getElementsByTagName( "td" );
+               isSupported = ( tds[ 0 ].offsetHeight === 0 );
+
+               tds[ 0 ].style.display = "";
+               tds[ 1 ].style.display = "none";
+
+               // Check if empty table cells still have offsetWidth/Height
+               // (IE <= 8 fail this test)
+               support.reliableHiddenOffsets = isSupported && ( tds[ 0 
].offsetHeight === 0 );
+
+               // Check if div with explicit width and no margin-right 
incorrectly
+               // gets computed margin-right based on width of container. For 
more
+               // info see bug #3333
+               // Fails in WebKit before Feb 2011 nightlies
+               // WebKit Bug 13343 - getComputedStyle returns wrong value for 
margin-right
+               if ( window.getComputedStyle ) {
+                       div.innerHTML = "";
+                       marginDiv = document.createElement( "div" );
+                       marginDiv.style.width = "0";
+                       marginDiv.style.marginRight = "0";
+                       div.style.width = "2px";
+                       div.appendChild( marginDiv );
+                       support.reliableMarginRight =
+                               ( parseInt( ( window.getComputedStyle( 
marginDiv, null ) || { marginRight: 0 } ).marginRight, 10 ) || 0 ) === 0;
+               }
+
+               if ( typeof div.style.zoom !== "undefined" ) {
+                       // Check if natively block-level elements act like 
inline-block
+                       // elements when setting their display to 'inline' and 
giving
+                       // them layout
+                       // (IE < 8 does this)
+                       div.innerHTML = "";
+                       div.style.width = div.style.padding = "1px";
+                       div.style.border = 0;
+                       div.style.overflow = "hidden";
+                       div.style.display = "inline";
+                       div.style.zoom = 1;
+                       support.inlineBlockNeedsLayout = ( div.offsetWidth === 
3 );
+
+                       // Check if elements with layout shrink-wrap their 
children
+                       // (IE 6 does this)
+                       div.style.display = "block";
+                       div.style.overflow = "visible";
+                       div.innerHTML = "<div style='width:5px;'></div>";
+                       support.shrinkWrapBlocks = ( div.offsetWidth !== 3 );
+               }
+
+               div.style.cssText = positionTopLeftWidthHeight + 
paddingMarginBorderVisibility;
+               div.innerHTML = html;
+
+               outer = div.firstChild;
+               inner = outer.firstChild;
+               td = outer.nextSibling.firstChild.firstChild;
+
+               offsetSupport = {
+                       doesNotAddBorder: ( inner.offsetTop !== 5 ),
+                       doesAddBorderForTableAndCells: ( td.offsetTop === 5 )
+               };
+
+               inner.style.position = "fixed";
+               inner.style.top = "20px";
+
+               // safari subtracts parent border width here which is 5px
+               offsetSupport.fixedPosition = ( inner.offsetTop === 20 || 
inner.offsetTop === 15 );
+               inner.style.position = inner.style.top = "";
+
+               outer.style.overflow = "hidden";
+               outer.style.position = "relative";
+
+               offsetSupport.subtractsBorderForOverflowNotVisible = ( 
inner.offsetTop === -5 );
+               offsetSupport.doesNotIncludeMarginInBodyOffset = ( 
body.offsetTop !== conMarginTop );
+
+               if ( window.getComputedStyle ) {
+                       div.style.marginTop = "1%";
+                       support.pixelMargin = ( window.getComputedStyle( div, 
null ) || { marginTop: 0 } ).marginTop !== "1%";
+               }
+
+               if ( typeof container.style.zoom !== "undefined" ) {
+                       container.style.zoom = 1;
+               }
+
+               body.removeChild( container );
+               marginDiv = div = container = null;
+
+               jQuery.extend( support, offsetSupport );
+       });
+
+       return support;
+})();
+
+
+
+
+var rbrace = /^(?:\{.*\}|\[.*\])$/,
+       rmultiDash = /([A-Z])/g;
+
+jQuery.extend({
+       cache: {},
+
+       // Please use with caution
+       uuid: 0,
+
+       // Unique for each copy of jQuery on the page
+       // Non-digits removed to match rinlinejQuery
+       expando: "jQuery" + ( jQuery.fn.jquery + Math.random() ).replace( 
/\D/g, "" ),
+
+       // The following elements throw uncatchable exceptions if you
+       // attempt to add expando properties to them.
+       noData: {
+               "embed": true,
+               // Ban all objects except for Flash (which handle expandos)
+               "object": "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000",
+               "applet": true
+       },
+
+       hasData: function( elem ) {
+               elem = elem.nodeType ? jQuery.cache[ elem[jQuery.expando] ] : 
elem[ jQuery.expando ];
+               return !!elem && !isEmptyDataObject( elem );
+       },
+
+       data: function( elem, name, data, pvt /* Internal Use Only */ ) {
+               if ( !jQuery.acceptData( elem ) ) {
+                       return;
+               }
+
+               var privateCache, thisCache, ret,
+                       internalKey = jQuery.expando,
+                       getByName = typeof name === "string",
+
+                       // We have to handle DOM nodes and JS objects 
differently because IE6-7
+                       // can't GC object references properly across the 
DOM-JS boundary
+                       isNode = elem.nodeType,
+
+                       // Only DOM nodes need the global jQuery cache; JS 
object data is
+                       // attached directly to the object so GC can occur 
automatically
+                       cache = isNode ? jQuery.cache : elem,
+
+                       // Only defining an ID for JS objects if its cache 
already exists allows
+                       // the code to shortcut on the same path as a DOM node 
with no cache
+                       id = isNode ? elem[ internalKey ] : elem[ internalKey ] 
&& internalKey,
+                       isEvents = name === "events";
+
+               // Avoid doing any more work than we need to when trying to get 
data on an
+               // object that has no data at all
+               if ( (!id || !cache[id] || (!isEvents && !pvt && 
!cache[id].data)) && getByName && data === undefined ) {
+                       return;
+               }
+
+               if ( !id ) {
+                       // Only DOM nodes need a new unique ID for each element 
since their data
+                       // ends up in the global cache
+                       if ( isNode ) {
+                               elem[ internalKey ] = id = ++jQuery.uuid;
+                       } else {
+                               id = internalKey;
+                       }
+               }
+
+               if ( !cache[ id ] ) {
+                       cache[ id ] = {};
+
+                       // Avoids exposing jQuery metadata on plain JS objects 
when the object
+                       // is serialized using JSON.stringify
+                       if ( !isNode ) {
+                               cache[ id ].toJSON = jQuery.noop;
+                       }
+               }
+
+               // An object can be passed to jQuery.data instead of a 
key/value pair; this gets
+               // shallow copied over onto the existing cache
+               if ( typeof name === "object" || typeof name === "function" ) {
+                       if ( pvt ) {
+                               cache[ id ] = jQuery.extend( cache[ id ], name 
);
+                       } else {
+                               cache[ id ].data = jQuery.extend( cache[ id 
].data, name );
+                       }
+               }
+
+               privateCache = thisCache = cache[ id ];
+
+               // jQuery data() is stored in a separate object inside the 
object's internal data
+               // cache in order to avoid key collisions between internal data 
and user-defined
+               // data.
+               if ( !pvt ) {
+                       if ( !thisCache.data ) {
+                               thisCache.data = {};
+                       }
+
+                       thisCache = thisCache.data;
+               }
+
+               if ( data !== undefined ) {
+                       thisCache[ jQuery.camelCase( name ) ] = data;
+               }
+
+               // Users should not attempt to inspect the internal events 
object using jQuery.data,
+               // it is undocumented and subject to change. But does anyone 
listen? No.
+               if ( isEvents && !thisCache[ name ] ) {
+                       return privateCache.events;
+               }
+
+               // Check for both converted-to-camel and non-converted data 
property names
+               // If a data property was specified
+               if ( getByName ) {
+
+                       // First Try to find as-is property data
+                       ret = thisCache[ name ];
+
+                       // Test for null|undefined property data
+                       if ( ret == null ) {
+
+                               // Try to find the camelCased property
+                               ret = thisCache[ jQuery.camelCase( name ) ];
+                       }
+               } else {
+                       ret = thisCache;
+               }
+
+               return ret;
+       },
+
+       removeData: function( elem, name, pvt /* Internal Use Only */ ) {
+               if ( !jQuery.acceptData( elem ) ) {
+                       return;
+               }
+
+               var thisCache, i, l,
+
+                       // Reference to internal data cache key
+                       internalKey = jQuery.expando,
+
+                       isNode = elem.nodeType,
+
+                       // See jQuery.data for more information
+                       cache = isNode ? jQuery.cache : elem,
+
+                       // See jQuery.data for more information
+                       id = isNode ? elem[ internalKey ] : internalKey;
+
+               // If there is already no cache entry for this object, there is 
no
+               // purpose in continuing
+               if ( !cache[ id ] ) {
+                       return;
+               }
+
+               if ( name ) {
+
+                       thisCache = pvt ? cache[ id ] : cache[ id ].data;
+
+                       if ( thisCache ) {
+
+                               // Support array or space separated string 
names for data keys
+                               if ( !jQuery.isArray( name ) ) {
+
+                                       // try the string as a key before any 
manipulation
+                                       if ( name in thisCache ) {
+                                               name = [ name ];
+                                       } else {
+
+                                               // split the camel cased 
version by spaces unless a key with the spaces exists
+                                               name = jQuery.camelCase( name );
+                                               if ( name in thisCache ) {
+                                                       name = [ name ];
+                                               } else {
+                                                       name = name.split( " " 
);
+                                               }
+                                       }
+                               }
+
+                               for ( i = 0, l = name.length; i < l; i++ ) {
+                                       delete thisCache[ name[i] ];
+                               }
+
+                               // If there is no data left in the cache, we 
want to continue
+                               // and let the cache object itself get destroyed
+                               if ( !( pvt ? isEmptyDataObject : 
jQuery.isEmptyObject )( thisCache ) ) {
+                                       return;
+                               }
+                       }
+               }
+
+               // See jQuery.data for more information
+               if ( !pvt ) {
+                       delete cache[ id ].data;
+
+                       // Don't destroy the parent cache unless the internal 
data object
+                       // had been the only thing left in it
+                       if ( !isEmptyDataObject(cache[ id ]) ) {
+                               return;
+                       }
+               }
+
+               // Browsers that fail expando deletion also refuse to delete 
expandos on
+               // the window, but it will allow it on all other JS objects; 
other browsers
+               // don't care
+               // Ensure that `cache` is not a window object #10080
+               if ( jQuery.support.deleteExpando || !cache.setInterval ) {
+                       delete cache[ id ];
+               } else {
+                       cache[ id ] = null;
+               }
+
+               // We destroyed the cache and need to eliminate the expando on 
the node to avoid
+               // false lookups in the cache for entries that no longer exist
+               if ( isNode ) {
+                       // IE does not allow us to delete expando properties 
from nodes,
+                       // nor does it have a removeAttribute function on 
Document nodes;
+                       // we must handle all of these cases
+                       if ( jQuery.support.deleteExpando ) {
+                               delete elem[ internalKey ];
+                       } else if ( elem.removeAttribute ) {
+                               elem.removeAttribute( internalKey );
+                       } else {
+                               elem[ internalKey ] = null;
+                       }
+               }
+       },
+
+       // For internal use only.
+       _data: function( elem, name, data ) {
+               return jQuery.data( elem, name, data, true );
+       },
+
+       // A method for determining if a DOM node can handle the data expando
+       acceptData: function( elem ) {
+               if ( elem.nodeName ) {
+                       var match = jQuery.noData[ elem.nodeName.toLowerCase() 
];
+
+                       if ( match ) {
+                               return !(match === true || 
elem.getAttribute("classid") !== match);
+                       }
+               }
+
+               return true;
+       }
+});
+
+jQuery.fn.extend({
+       data: function( key, value ) {
+               var parts, part, attr, name, l,
+                       elem = this[0],
+                       i = 0,
+                       data = null;
+
+               // Gets all values
+               if ( key === undefined ) {
+                       if ( this.length ) {
+                               data = jQuery.data( elem );
+
+                               if ( elem.nodeType === 1 && !jQuery._data( 
elem, "parsedAttrs" ) ) {
+                                       attr = elem.attributes;
+                                       for ( l = attr.length; i < l; i++ ) {
+                                               name = attr[i].name;
+
+                                               if ( name.indexOf( "data-" ) 
=== 0 ) {
+                                                       name = 
jQuery.camelCase( name.substring(5) );
+
+                                                       dataAttr( elem, name, 
data[ name ] );
+                                               }
+                                       }
+                                       jQuery._data( elem, "parsedAttrs", true 
);
+                               }
+                       }
+
+                       return data;
+               }
+
+               // Sets multiple values
+               if ( typeof key === "object" ) {
+                       return this.each(function() {
+                               jQuery.data( this, key );
+                       });
+               }
+
+               parts = key.split( ".", 2 );
+               parts[1] = parts[1] ? "." + parts[1] : "";
+               part = parts[1] + "!";
+
+               return jQuery.access( this, function( value ) {
+
+                       if ( value === undefined ) {
+                               data = this.triggerHandler( "getData" + part, [ 
parts[0] ] );
+
+                               // Try to fetch any internally stored data first
+                               if ( data === undefined && elem ) {
+                                       data = jQuery.data( elem, key );
+                                       data = dataAttr( elem, key, data );
+                               }
+
+                               return data === undefined && parts[1] ?
+                                       this.data( parts[0] ) :
+                                       data;
+                       }
+
+                       parts[1] = value;
+                       this.each(function() {
+                               var self = jQuery( this );
+
+                               self.triggerHandler( "setData" + part, parts );
+                               jQuery.data( this, key, value );
+                               self.triggerHandler( "changeData" + part, parts 
);
+                       });
+               }, null, value, arguments.length > 1, null, false );
+       },
+
+       removeData: function( key ) {
+               return this.each(function() {
+                       jQuery.removeData( this, key );
+               });
+       }
+});
+
+function dataAttr( elem, key, data ) {
+       // If nothing was found internally, try to fetch any
+       // data from the HTML5 data-* attribute
+       if ( data === undefined && elem.nodeType === 1 ) {
+
+               var name = "data-" + key.replace( rmultiDash, "-$1" 
).toLowerCase();
+
+               data = elem.getAttribute( name );
+
+               if ( typeof data === "string" ) {
+                       try {
+                               data = data === "true" ? true :
+                               data === "false" ? false :
+                               data === "null" ? null :
+                               jQuery.isNumeric( data ) ? +data :
+                                       rbrace.test( data ) ? jQuery.parseJSON( 
data ) :
+                                       data;
+                       } catch( e ) {}
+
+                       // Make sure we set the data so it isn't changed later
+                       jQuery.data( elem, key, data );
+
+               } else {
+                       data = undefined;
+               }
+       }
+
+       return data;
+}
+
+// checks a cache object for emptiness
+function isEmptyDataObject( obj ) {
+       for ( var name in obj ) {
+
+               // if the public data object is empty, the private is still 
empty
+               if ( name === "data" && jQuery.isEmptyObject( obj[name] ) ) {
+                       continue;
+               }
+               if ( name !== "toJSON" ) {
+                       return false;
+               }
+       }
+
+       return true;
+}
+
+
+
+
+function handleQueueMarkDefer( elem, type, src ) {
+       var deferDataKey = type + "defer",
+               queueDataKey = type + "queue",
+               markDataKey = type + "mark",
+               defer = jQuery._data( elem, deferDataKey );
+       if ( defer &&
+               ( src === "queue" || !jQuery._data(elem, queueDataKey) ) &&
+               ( src === "mark" || !jQuery._data(elem, markDataKey) ) ) {
+               // Give room for hard-coded callbacks to fire first
+               // and eventually mark/queue something else on the element
+               setTimeout( function() {
+                       if ( !jQuery._data( elem, queueDataKey ) &&
+                               !jQuery._data( elem, markDataKey ) ) {
+                               jQuery.removeData( elem, deferDataKey, true );
+                               defer.fire();
+                       }
+               }, 0 );
+       }
+}
+
+jQuery.extend({
+
+       _mark: function( elem, type ) {
+               if ( elem ) {
+                       type = ( type || "fx" ) + "mark";
+                       jQuery._data( elem, type, (jQuery._data( elem, type ) 
|| 0) + 1 );
+               }
+       },
+
+       _unmark: function( force, elem, type ) {
+               if ( force !== true ) {
+                       type = elem;
+                       elem = force;
+                       force = false;
+               }
+               if ( elem ) {
+                       type = type || "fx";
+                       var key = type + "mark",
+                               count = force ? 0 : ( (jQuery._data( elem, key 
) || 1) - 1 );
+                       if ( count ) {
+                               jQuery._data( elem, key, count );
+                       } else {
+                               jQuery.removeData( elem, key, true );
+                               handleQueueMarkDefer( elem, type, "mark" );
+                       }
+               }
+       },
+
+       queue: function( elem, type, data ) {
+               var q;
+               if ( elem ) {
+                       type = ( type || "fx" ) + "queue";
+                       q = jQuery._data( elem, type );
+
+                       // Speed up dequeue by getting out quickly if this is 
just a lookup
+                       if ( data ) {
+                               if ( !q || jQuery.isArray(data) ) {
+                                       q = jQuery._data( elem, type, 
jQuery.makeArray(data) );
+                               } else {
+                                       q.push( data );
+                               }
+                       }
+                       return q || [];
+               }
+       },
+
+       dequeue: function( elem, type ) {
+               type = type || "fx";
+
+               var queue = jQuery.queue( elem, type ),
+                       fn = queue.shift(),
+                       hooks = {};
+
+               // If the fx queue is dequeued, always remove the progress 
sentinel
+               if ( fn === "inprogress" ) {
+                       fn = queue.shift();
+               }
+
+               if ( fn ) {
+                       // Add a progress sentinel to prevent the fx queue from 
being
+                       // automatically dequeued
+                       if ( type === "fx" ) {
+                               queue.unshift( "inprogress" );
+                       }
+
+                       jQuery._data( elem, type + ".run", hooks );
+                       fn.call( elem, function() {
+                               jQuery.dequeue( elem, type );
+                       }, hooks );
+               }
+
+               if ( !queue.length ) {
+                       jQuery.removeData( elem, type + "queue " + type + 
".run", true );
+                       handleQueueMarkDefer( elem, type, "queue" );
+               }
+       }
+});
+
+jQuery.fn.extend({
+       queue: function( type, data ) {
+               var setter = 2;
+
+               if ( typeof type !== "string" ) {
+                       data = type;
+                       type = "fx";
+                       setter--;
+               }
+
+               if ( arguments.length < setter ) {
+                       return jQuery.queue( this[0], type );
+               }
+
+               return data === undefined ?
+                       this :
+                       this.each(function() {
+                               var queue = jQuery.queue( this, type, data );
+
+                               if ( type === "fx" && queue[0] !== "inprogress" 
) {
+                                       jQuery.dequeue( this, type );
+                               }
+                       });
+       },
+       dequeue: function( type ) {
+               return this.each(function() {
+                       jQuery.dequeue( this, type );
+               });
+       },
+       // Based off of the plugin by Clint Helfers, with permission.
+       // http://blindsignals.com/index.php/2009/07/jquery-delay/
+       delay: function( time, type ) {
+               time = jQuery.fx ? jQuery.fx.speeds[ time ] || time : time;
+               type = type || "fx";
+
+               return this.queue( type, function( next, hooks ) {
+                       var timeout = setTimeout( next, time );
+                       hooks.stop = function() {
+                               clearTimeout( timeout );
+                       };
+               });
+       },
+       clearQueue: function( type ) {
+               return this.queue( type || "fx", [] );
+       },
+       // Get a promise resolved when queues of a certain type
+       // are emptied (fx is the type by default)
+       promise: function( type, object ) {
+               if ( typeof type !== "string" ) {
+                       object = type;
+                       type = undefined;
+               }
+               type = type || "fx";
+               var defer = jQuery.Deferred(),
+                       elements = this,
+                       i = elements.length,
+                       count = 1,
+                       deferDataKey = type + "defer",
+                       queueDataKey = type + "queue",
+                       markDataKey = type + "mark",
+                       tmp;
+               function resolve() {
+                       if ( !( --count ) ) {
+                               defer.resolveWith( elements, [ elements ] );
+                       }
+               }
+               while( i-- ) {
+                       if (( tmp = jQuery.data( elements[ i ], deferDataKey, 
undefined, true ) ||
+                                       ( jQuery.data( elements[ i ], 
queueDataKey, undefined, true ) ||
+                                               jQuery.data( elements[ i ], 
markDataKey, undefined, true ) ) &&
+                                       jQuery.data( elements[ i ], 
deferDataKey, jQuery.Callbacks( "once memory" ), true ) )) {
+                               count++;
+                               tmp.add( resolve );
+                       }
+               }
+               resolve();
+               return defer.promise( object );
+       }
+});
+
+
+
+
+var rclass = /[\n\t\r]/g,
+       rspace = /\s+/,
+       rreturn = /\r/g,
+       rtype = /^(?:button|input)$/i,
+       rfocusable = /^(?:button|input|object|select|textarea)$/i,
+       rclickable = /^a(?:rea)?$/i,
+       rboolean = 
/^(?:autofocus|autoplay|async|checked|controls|defer|disabled|hidden|loop|multiple|open|readonly|required|scoped|selected)$/i,
+       getSetAttribute = jQuery.support.getSetAttribute,
+       nodeHook, boolHook, fixSpecified;
+
+jQuery.fn.extend({
+       attr: function( name, value ) {
+               return jQuery.access( this, jQuery.attr, name, value, 
arguments.length > 1 );
+       },
+
+       removeAttr: function( name ) {
+               return this.each(function() {
+                       jQuery.removeAttr( this, name );
+               });
+       },
+
+       prop: function( name, value ) {
+               return jQuery.access( this, jQuery.prop, name, value, 
arguments.length > 1 );
+       },
+
+       removeProp: function( name ) {
+               name = jQuery.propFix[ name ] || name;
+               return this.each(function() {
+                       // try/catch handles cases where IE balks (such as 
removing a property on window)
+                       try {
+                               this[ name ] = undefined;
+                               delete this[ name ];
+                       } catch( e ) {}
+               });
+       },
+
+       addClass: function( value ) {
+               var classNames, i, l, elem,
+                       setClass, c, cl;
+
+               if ( jQuery.isFunction( value ) ) {
+                       return this.each(function( j ) {
+                               jQuery( this ).addClass( value.call(this, j, 
this.className) );
+                       });
+               }
+
+               if ( value && typeof value === "string" ) {
+                       classNames = value.split( rspace );
+
+                       for ( i = 0, l = this.length; i < l; i++ ) {
+                               elem = this[ i ];
+
+                               if ( elem.nodeType === 1 ) {
+                                       if ( !elem.className && 
classNames.length === 1 ) {
+                                               elem.className = value;
+
+                                       } else {
+                                               setClass = " " + elem.className 
+ " ";
+
+                                               for ( c = 0, cl = 
classNames.length; c < cl; c++ ) {
+                                                       if ( 
!~setClass.indexOf( " " + classNames[ c ] + " " ) ) {
+                                                               setClass += 
classNames[ c ] + " ";
+                                                       }
+                                               }
+                                               elem.className = jQuery.trim( 
setClass );
+                                       }
+                               }
+                       }
+               }
+
+               return this;
+       },
+
+       removeClass: function( value ) {
+               var classNames, i, l, elem, className, c, cl;
+
+               if ( jQuery.isFunction( value ) ) {
+                       return this.each(function( j ) {
+                               jQuery( this ).removeClass( value.call(this, j, 
this.className) );
+                       });
+               }
+
+               if ( (value && typeof value === "string") || value === 
undefined ) {
+                       classNames = ( value || "" ).split( rspace );
+
+                       for ( i = 0, l = this.length; i < l; i++ ) {
+                               elem = this[ i ];
+
+                               if ( elem.nodeType === 1 && elem.className ) {
+                                       if ( value ) {
+                                               className = (" " + 
elem.className + " ").replace( rclass, " " );
+                                               for ( c = 0, cl = 
classNames.length; c < cl; c++ ) {
+                                                       className = 
className.replace(" " + classNames[ c ] + " ", " ");
+                                               }
+                                               elem.className = jQuery.trim( 
className );
+
+                                       } else {
+                                               elem.className = "";
+                                       }
+                               }
+                       }
+               }
+
+               return this;
+       },
+
+       toggleClass: function( value, stateVal ) {
+               var type = typeof value,
+                       isBool = typeof stateVal === "boolean";
+
+               if ( jQuery.isFunction( value ) ) {
+                       return this.each(function( i ) {
+                               jQuery( this ).toggleClass( value.call(this, i, 
this.className, stateVal), stateVal );
+                       });
+               }
+
+               return this.each(function() {
+                       if ( type === "string" ) {
+                               // toggle individual class names
+                               var className,
+                                       i = 0,
+                                       self = jQuery( this ),
+                                       state = stateVal,
+                                       classNames = value.split( rspace );
+
+                               while ( (className = classNames[ i++ ]) ) {
+                                       // check each className given, space 
seperated list
+                                       state = isBool ? state : 
!self.hasClass( className );
+                                       self[ state ? "addClass" : 
"removeClass" ]( className );
+                               }
+
+                       } else if ( type === "undefined" || type === "boolean" 
) {
+                               if ( this.className ) {
+                                       // store className if set
+                                       jQuery._data( this, "__className__", 
this.className );
+                               }
+
+                               // toggle whole className
+                               this.className = this.className || value === 
false ? "" : jQuery._data( this, "__className__" ) || "";
+                       }
+               });
+       },
+
+       hasClass: function( selector ) {
+               var className = " " + selector + " ",
+                       i = 0,
+                       l = this.length;
+               for ( ; i < l; i++ ) {
+                       if ( this[i].nodeType === 1 && (" " + this[i].className 
+ " ").replace(rclass, " ").indexOf( className ) > -1 ) {
+                               return true;
+                       }
+               }
+
+               return false;
+       },
+
+       val: function( value ) {
+               var hooks, ret, isFunction,
+                       elem = this[0];
+
+               if ( !arguments.length ) {
+                       if ( elem ) {
+                               hooks = jQuery.valHooks[ elem.type ] || 
jQuery.valHooks[ elem.nodeName.toLowerCase() ];
+
+                               if ( hooks && "get" in hooks && (ret = 
hooks.get( elem, "value" )) !== undefined ) {
+                                       return ret;
+                               }
+
+                               ret = elem.value;
+
+                               return typeof ret === "string" ?
+                                       // handle most common string cases
+                                       ret.replace(rreturn, "") :
+                                       // handle cases where value is 
null/undef or number
+                                       ret == null ? "" : ret;
+                       }
+
+                       return;
+               }
+
+               isFunction = jQuery.isFunction( value );
+
+               return this.each(function( i ) {
+                       var self = jQuery(this), val;
+
+                       if ( this.nodeType !== 1 ) {
+                               return;
+                       }
+
+                       if ( isFunction ) {
+                               val = value.call( this, i, self.val() );
+                       } else {
+                               val = value;
+                       }
+
+                       // Treat null/undefined as ""; convert numbers to string
+                       if ( val == null ) {
+                               val = "";
+                       } else if ( typeof val === "number" ) {
+                               val += "";
+                       } else if ( jQuery.isArray( val ) ) {
+                               val = jQuery.map(val, function ( value ) {
+                                       return value == null ? "" : value + "";
+                               });
+                       }
+
+                       hooks = jQuery.valHooks[ this.type ] || 
jQuery.valHooks[ this.nodeName.toLowerCase() ];
+
+                       // If set returns undefined, fall back to normal setting
+                       if ( !hooks || !("set" in hooks) || hooks.set( this, 
val, "value" ) === undefined ) {
+                               this.value = val;
+                       }
+               });
+       }
+});
+
+jQuery.extend({
+       valHooks: {
+               option: {
+                       get: function( elem ) {
+                               // attributes.value is undefined in Blackberry 
4.7 but
+                               // uses .value. See #6932
+                               var val = elem.attributes.value;
+                               return !val || val.specified ? elem.value : 
elem.text;
+                       }
+               },
+               select: {
+                       get: function( elem ) {
+                               var value, i, max, option,
+                                       index = elem.selectedIndex,
+                                       values = [],
+                                       options = elem.options,
+                                       one = elem.type === "select-one";
+
+                               // Nothing was selected
+                               if ( index < 0 ) {
+                                       return null;
+                               }
+
+                               // Loop through all the selected options
+                               i = one ? index : 0;
+                               max = one ? index + 1 : options.length;
+                               for ( ; i < max; i++ ) {
+                                       option = options[ i ];
+
+                                       // Don't return options that are 
disabled or in a disabled optgroup
+                                       if ( option.selected && 
(jQuery.support.optDisabled ? !option.disabled : 
option.getAttribute("disabled") === null) &&
+                                                       
(!option.parentNode.disabled || !jQuery.nodeName( option.parentNode, "optgroup" 
)) ) {
+
+                                               // Get the specific value for 
the option
+                                               value = jQuery( option ).val();
+
+                                               // We don't need an array for 
one selects
+                                               if ( one ) {
+                                                       return value;
+                                               }
+
+                                               // Multi-Selects return an array
+                                               values.push( value );
+                                       }
+                               }
+
+                               // Fixes Bug #2551 -- select.val() broken in IE 
after form.reset()
+                               if ( one && !values.length && options.length ) {
+                                       return jQuery( options[ index ] ).val();
+                               }
+
+                               return values;
+                       },
+
+                       set: function( elem, value ) {
+                               var values = jQuery.makeArray( value );
+
+                               jQuery(elem).find("option").each(function() {
+                                       this.selected = jQuery.inArray( 
jQuery(this).val(), values ) >= 0;
+                               });
+
+                               if ( !values.length ) {
+                                       elem.selectedIndex = -1;
+                               }
+                               return values;
+                       }
+               }
+       },
+
+       attrFn: {
+               val: true,
+               css: true,
+               html: true,
+               text: true,
+               data: true,
+               width: true,
+               height: true,
+               offset: true
+       },
+
+       attr: function( elem, name, value, pass ) {
+               var ret, hooks, notxml,
+                       nType = elem.nodeType;
+
+               // don't get/set attributes on text, comment and attribute nodes
+               if ( !elem || nType === 3 || nType === 8 || nType === 2 ) {
+                       return;
+               }
+
+               if ( pass && name in jQuery.attrFn ) {
+                       return jQuery( elem )[ name ]( value );
+               }
+
+               // Fallback to prop when attributes are not supported
+               if ( typeof elem.getAttribute === "undefined" ) {
+                       return jQuery.prop( elem, name, value );
+               }
+
+               notxml = nType !== 1 || !jQuery.isXMLDoc( elem );
+
+               // All attributes are lowercase
+               // Grab necessary hook if one is defined
+               if ( notxml ) {
+                       name = name.toLowerCase();
+                       hooks = jQuery.attrHooks[ name ] || ( rboolean.test( 
name ) ? boolHook : nodeHook );
+               }
+
+               if ( value !== undefined ) {
+
+                       if ( value === null ) {
+                               jQuery.removeAttr( elem, name );
+                               return;
+
+                       } else if ( hooks && "set" in hooks && notxml && (ret = 
hooks.set( elem, value, name )) !== undefined ) {
+                               return ret;
+
+                       } else {
+                               elem.setAttribute( name, "" + value );
+                               return value;
+                       }
+
+               } else if ( hooks && "get" in hooks && notxml && (ret = 
hooks.get( elem, name )) !== null ) {
+                       return ret;
+
+               } else {
+
+                       ret = elem.getAttribute( name );
+
+                       // Non-existent attributes return null, we normalize to 
undefined
+                       return ret === null ?
+                               undefined :
+                               ret;
+               }
+       },
+
+       removeAttr: function( elem, value ) {
+               var propName, attrNames, name, l, isBool,
+                       i = 0;
+
+               if ( value && elem.nodeType === 1 ) {
+                       attrNames = value.toLowerCase().split( rspace );
+                       l = attrNames.length;
+
+                       for ( ; i < l; i++ ) {
+                               name = attrNames[ i ];
+
+                               if ( name ) {
+                                       propName = jQuery.propFix[ name ] || 
name;
+                                       isBool = rboolean.test( name );
+
+                                       // See #9699 for explanation of this 
approach (setting first, then removal)
+                                       // Do not do this for boolean 
attributes (see #10870)
+                                       if ( !isBool ) {
+                                               jQuery.attr( elem, name, "" );
+                                       }
+                                       elem.removeAttribute( getSetAttribute ? 
name : propName );
+
+                                       // Set corresponding property to false 
for boolean attributes
+                                       if ( isBool && propName in elem ) {
+                                               elem[ propName ] = false;
+                                       }
+                               }
+                       }
+               }
+       },
+
+       attrHooks: {
+               type: {
+                       set: function( elem, value ) {
+                               // We can't allow the type property to be 
changed (since it causes problems in IE)
+                               if ( rtype.test( elem.nodeName ) && 
elem.parentNode ) {
+                                       jQuery.error( "type property can't be 
changed" );
+                               } else if ( !jQuery.support.radioValue && value 
=== "radio" && jQuery.nodeName(elem, "input") ) {
+                                       // Setting the type on a radio button 
after the value resets the value in IE6-9
+                                       // Reset value to it's default in case 
type is set after value
+                                       // This is for element creation
+                                       var val = elem.value;
+                                       elem.setAttribute( "type", value );
+                                       if ( val ) {
+                                               elem.value = val;
+                                       }
+                                       return value;
+                               }
+                       }
+               },
+               // Use the value property for back compat
+               // Use the nodeHook for button elements in IE6/7 (#1954)
+               value: {
+                       get: function( elem, name ) {
+                               if ( nodeHook && jQuery.nodeName( elem, 
"button" ) ) {
+                                       return nodeHook.get( elem, name );
+                               }
+                               return name in elem ?
+                                       elem.value :
+                                       null;
+                       },
+                       set: function( elem, value, name ) {
+                               if ( nodeHook && jQuery.nodeName( elem, 
"button" ) ) {
+                                       return nodeHook.set( elem, value, name 
);
+                               }
+                               // Does not return so that setAttribute is also 
used
+                               elem.value = value;
+                       }
+               }
+       },
+
+       propFix: {
+               tabindex: "tabIndex",
+               readonly: "readOnly",
+               "for": "htmlFor",
+               "class": "className",
+               maxlength: "maxLength",
+               cellspacing: "cellSpacing",
+               cellpadding: "cellPadding",
+               rowspan: "rowSpan",
+               colspan: "colSpan",
+               usemap: "useMap",
+               frameborder: "frameBorder",
+               contenteditable: "contentEditable"
+       },
+
+       prop: function( elem, name, value ) {
+               var ret, hooks, notxml,
+                       nType = elem.nodeType;
+
+               // don't get/set properties on text, comment and attribute nodes
+               if ( !elem || nType === 3 || nType === 8 || nType === 2 ) {
+                       return;
+               }
+
+               notxml = nType !== 1 || !jQuery.isXMLDoc( elem );
+
+               if ( notxml ) {
+                       // Fix name and attach hooks
+                       name = jQuery.propFix[ name ] || name;
+                       hooks = jQuery.propHooks[ name ];
+               }
+
+               if ( value !== undefined ) {
+                       if ( hooks && "set" in hooks && (ret = hooks.set( elem, 
value, name )) !== undefined ) {
+                               return ret;
+
+                       } else {
+                               return ( elem[ name ] = value );
+                       }
+
+               } else {
+                       if ( hooks && "get" in hooks && (ret = hooks.get( elem, 
name )) !== null ) {
+                               return ret;
+
+                       } else {
+                               return elem[ name ];
+                       }
+               }
+       },
+
+       propHooks: {
+               tabIndex: {
+                       get: function( elem ) {
+                               // elem.tabIndex doesn't always return the 
correct value when it hasn't been explicitly set
+                               // 
http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/
+                               var attributeNode = 
elem.getAttributeNode("tabindex");
+
+                               return attributeNode && attributeNode.specified 
?
+                                       parseInt( attributeNode.value, 10 ) :
+                                       rfocusable.test( elem.nodeName ) || 
rclickable.test( elem.nodeName ) && elem.href ?
+                                               0 :
+                                               undefined;
+                       }
+               }
+       }
+});
+
+// Add the tabIndex propHook to attrHooks for back-compat (different case is 
intentional)
+jQuery.attrHooks.tabindex = jQuery.propHooks.tabIndex;
+
+// Hook for boolean attributes
+boolHook = {
+       get: function( elem, name ) {
+               // Align boolean attributes with corresponding properties
+               // Fall back to attribute presence where some booleans are not 
supported
+               var attrNode,
+                       property = jQuery.prop( elem, name );
+               return property === true || typeof property !== "boolean" && ( 
attrNode = elem.getAttributeNode(name) ) && attrNode.nodeValue !== false ?
+                       name.toLowerCase() :
+                       undefined;
+       },
+       set: function( elem, value, name ) {
+               var propName;
+               if ( value === false ) {
+                       // Remove boolean attributes when set to false
+                       jQuery.removeAttr( elem, name );
+               } else {
+                       // value is true since we know at this point it's type 
boolean and not false
+                       // Set boolean attributes to the same name and set the 
DOM property
+                       propName = jQuery.propFix[ name ] || name;
+                       if ( propName in elem ) {
+                               // Only set the IDL specifically if it already 
exists on the element
+                               elem[ propName ] = true;
+                       }
+
+                       elem.setAttribute( name, name.toLowerCase() );
+               }
+               return name;
+       }
+};
+
+// IE6/7 do not support getting/setting some attributes with get/setAttribute
+if ( !getSetAttribute ) {
+
+       fixSpecified = {
+               name: true,
+               id: true,
+               coords: true
+       };
+
+       // Use this for any attribute in IE6/7
+       // This fixes almost every IE6/7 issue
+       nodeHook = jQuery.valHooks.button = {
+               get: function( elem, name ) {
+                       var ret;
+                       ret = elem.getAttributeNode( name );
+                       return ret && ( fixSpecified[ name ] ? ret.nodeValue 
!== "" : ret.specified ) ?
+                               ret.nodeValue :
+                               undefined;
+               },
+               set: function( elem, value, name ) {
+                       // Set the existing or create a new attribute node
+                       var ret = elem.getAttributeNode( name );
+                       if ( !ret ) {
+                               ret = document.createAttribute( name );
+                               elem.setAttributeNode( ret );
+                       }
+                       return ( ret.nodeValue = value + "" );
+               }
+       };
+
+       // Apply the nodeHook to tabindex
+       jQuery.attrHooks.tabindex.set = nodeHook.set;
+
+       // Set width and height to auto instead of 0 on empty string( Bug #8150 
)
+       // This is for removals
+       jQuery.each([ "width", "height" ], function( i, name ) {
+               jQuery.attrHooks[ name ] = jQuery.extend( jQuery.attrHooks[ 
name ], {
+                       set: function( elem, value ) {
+                               if ( value === "" ) {
+                                       elem.setAttribute( name, "auto" );
+                                       return value;
+                               }
+                       }
+               });
+       });
+
+       // Set contenteditable to false on removals(#10429)
+       // Setting to empty string throws an error as an invalid value
+       jQuery.attrHooks.contenteditable = {
+               get: nodeHook.get,
+               set: function( elem, value, name ) {
+                       if ( value === "" ) {
+                               value = "false";
+                       }
+                       nodeHook.set( elem, value, name );
+               }
+       };
+}
+
+
+// Some attributes require a special call on IE
+if ( !jQuery.support.hrefNormalized ) {
+       jQuery.each([ "href", "src", "width", "height" ], function( i, name ) {
+               jQuery.attrHooks[ name ] = jQuery.extend( jQuery.attrHooks[ 
name ], {
+                       get: function( elem ) {
+                               var ret = elem.getAttribute( name, 2 );
+                               return ret === null ? undefined : ret;
+                       }
+               });
+       });
+}
+
+if ( !jQuery.support.style ) {
+       jQuery.attrHooks.style = {
+               get: function( elem ) {
+                       // Return undefined in the case of empty string
+                       // Normalize to lowercase since IE uppercases css 
property names
+                       return elem.style.cssText.toLowerCase() || undefined;
+               },
+               set: function( elem, value ) {
+                       return ( elem.style.cssText = "" + value );
+               }
+       };
+}
+
+// Safari mis-reports the default selected property of an option
+// Accessing the parent's selectedIndex property fixes it
+if ( !jQuery.support.optSelected ) {
+       jQuery.propHooks.selected = jQuery.extend( jQuery.propHooks.selected, {
+               get: function( elem ) {
+                       var parent = elem.parentNode;
+
+                       if ( parent ) {
+                               parent.selectedIndex;
+
+                               // Make sure that it also works with optgroups, 
see #5701
+                               if ( parent.parentNode ) {
+                                       parent.parentNode.selectedIndex;
+                               }
+                       }
+                       return null;
+               }
+       });
+}
+
+// IE6/7 call enctype encoding
+if ( !jQuery.support.enctype ) {
+       jQuery.propFix.enctype = "encoding";
+}
+
+// Radios and checkboxes getter/setter
+if ( !jQuery.support.checkOn ) {
+       jQuery.each([ "radio", "checkbox" ], function() {
+               jQuery.valHooks[ this ] = {
+                       get: function( elem ) {
+                               // Handle the case where in Webkit "" is 
returned instead of "on" if a value isn't specified
+                               return elem.getAttribute("value") === null ? 
"on" : elem.value;
+                       }
+               };
+       });
+}
+jQuery.each([ "radio", "checkbox" ], function() {
+       jQuery.valHooks[ this ] = jQuery.extend( jQuery.valHooks[ this ], {
+               set: function( elem, value ) {
+                       if ( jQuery.isArray( value ) ) {
+                               return ( elem.checked = jQuery.inArray( 
jQuery(elem).val(), value ) >= 0 );
+                       }
+               }
+       });
+});
+
+
+
+
+var rformElems = /^(?:textarea|input|select)$/i,
+       rtypenamespace = /^([^\.]*)?(?:\.(.+))?$/,
+       rhoverHack = /(?:^|\s)hover(\.\S+)?\b/,
+       rkeyEvent = /^key/,
+       rmouseEvent = /^(?:mouse|contextmenu)|click/,
+       rfocusMorph = /^(?:focusinfocus|focusoutblur)$/,
+       rquickIs = /^(\w*)(?:#([\w\-]+))?(?:\.([\w\-]+))?$/,
+       quickParse = function( selector ) {
+               var quick = rquickIs.exec( selector );
+               if ( quick ) {
+                       //   0  1    2   3
+                       // [ _, tag, id, class ]
+                       quick[1] = ( quick[1] || "" ).toLowerCase();
+                       quick[3] = quick[3] && new RegExp( "(?:^|\\s)" + 
quick[3] + "(?:\\s|$)" );
+               }
+               return quick;
+       },
+       quickIs = function( elem, m ) {
+               var attrs = elem.attributes || {};
+               return (
+                       (!m[1] || elem.nodeName.toLowerCase() === m[1]) &&
+                       (!m[2] || (attrs.id || {}).value === m[2]) &&
+                       (!m[3] || m[3].test( (attrs[ "class" ] || {}).value ))
+               );
+       },
+       hoverHack = function( events ) {
+               return jQuery.event.special.hover ? events : events.replace( 
rhoverHack, "mouseenter$1 mouseleave$1" );
+       };
+
+/*
+ * Helper functions for managing events -- not part of the public interface.
+ * Props to Dean Edwards' addEvent library for many of the ideas.
+ */
+jQuery.event = {
+
+       add: function( elem, types, handler, data, selector ) {
+
+               var elemData, eventHandle, events,
+                       t, tns, type, namespaces, handleObj,
+                       handleObjIn, quick, handlers, special;
+
+               // Don't attach events to noData or text/comment nodes (allow 
plain objects tho)
+               if ( elem.nodeType === 3 || elem.nodeType === 8 || !types || 
!handler || !(elemData = jQuery._data( elem )) ) {
+                       return;
+               }
+
+               // Caller can pass in an object of custom data in lieu of the 
handler
+               if ( handler.handler ) {
+                       handleObjIn = handler;
+                       handler = handleObjIn.handler;
+                       selector = handleObjIn.selector;
+               }
+
+               // Make sure that the handler has a unique ID, used to 
find/remove it later
+               if ( !handler.guid ) {
+                       handler.guid = jQuery.guid++;
+               }
+
+               // Init the element's event structure and main handler, if this 
is the first
+               events = elemData.events;
+               if ( !events ) {
+                       elemData.events = events = {};
+               }
+               eventHandle = elemData.handle;
+               if ( !eventHandle ) {
+                       elemData.handle = eventHandle = function( e ) {
+                               // Discard the second event of a 
jQuery.event.trigger() and
+                               // when an event is called after a page has 
unloaded
+                               return typeof jQuery !== "undefined" && (!e || 
jQuery.event.triggered !== e.type) ?
+                                       jQuery.event.dispatch.apply( 
eventHandle.elem, arguments ) :
+                                       undefined;
+                       };
+                       // Add elem as a property of the handle fn to prevent a 
memory leak with IE non-native events
+                       eventHandle.elem = elem;
+               }
+
+               // Handle multiple events separated by a space
+               // jQuery(...).bind("mouseover mouseout", fn);
+               types = jQuery.trim( hoverHack(types) ).split( " " );
+               for ( t = 0; t < types.length; t++ ) {
+
+                       tns = rtypenamespace.exec( types[t] ) || [];
+                       type = tns[1];
+                       namespaces = ( tns[2] || "" ).split( "." ).sort();
+
+                       // If event changes its type, use the special event 
handlers for the changed type
+                       special = jQuery.event.special[ type ] || {};
+
+                       // If selector defined, determine special event api 
type, otherwise given type
+                       type = ( selector ? special.delegateType : 
special.bindType ) || type;
+
+                       // Update special based on newly reset type
+                       special = jQuery.event.special[ type ] || {};
+
+                       // handleObj is passed to all event handlers
+                       handleObj = jQuery.extend({
+                               type: type,
+                               origType: tns[1],
+                               data: data,
+                               handler: handler,
+                               guid: handler.guid,
+                               selector: selector,
+                               quick: selector && quickParse( selector ),
+                               namespace: namespaces.join(".")
+                       }, handleObjIn );
+
+                       // Init the event handler queue if we're the first
+                       handlers = events[ type ];
+                       if ( !handlers ) {
+                               handlers = events[ type ] = [];
+                               handlers.delegateCount = 0;
+
+                               // Only use addEventListener/attachEvent if the 
special events handler returns false
+                               if ( !special.setup || special.setup.call( 
elem, data, namespaces, eventHandle ) === false ) {
+                                       // Bind the global event handler to the 
element

@@ Diff output truncated at 153600 characters. @@



reply via email to

[Prev in Thread] Current Thread [Next in Thread]