diff --git a/indra/llinventory/llparcel.cpp b/indra/llinventory/llparcel.cpp
index 0908613c105b2114276c47f2559103bd5ff54e7d..f53ef5e0ffaf0db20d090a603baf643f779b245a 100644
--- a/indra/llinventory/llparcel.cpp
+++ b/indra/llinventory/llparcel.cpp
@@ -231,6 +231,11 @@ void LLParcel::init(const LLUUID &owner_id,
 	setAllowGroupAVSounds(TRUE);
 	setAllowAnyAVSounds(TRUE);
 	setHaveNewParcelLimitData(FALSE);
+
+    mDayLength = S64Seconds(LLSettingsDay::DEFAULT_DAYLENGTH);
+    mDayOffset = S64Seconds(LLSettingsDay::DEFAULT_DAYOFFSET);
+    mIsDefaultDayCycle = true;
+    mDayCycle.reset();
 }
 
 void LLParcel::overrideOwner(const LLUUID& owner_id, BOOL is_group_owned)
diff --git a/indra/llinventory/llparcel.h b/indra/llinventory/llparcel.h
index 135d0ca7b937bd7a17f62537dc39fb02528797f3..dada2cf6d85a0333bf3480136a3b58562608d4f2 100644
--- a/indra/llinventory/llparcel.h
+++ b/indra/llinventory/llparcel.h
@@ -34,6 +34,7 @@
 #include "llpermissions.h"
 #include "lltimer.h"
 #include "v3math.h"
+#include "llsettingsdaycycle.h"
 
 // Grid out of which parcels taken is stepped every 4 meters.
 const F32 PARCEL_GRID_STEP_METERS	= 4.f;
@@ -590,7 +591,15 @@ class LLParcel
 	BOOL	getPreviouslyGroupOwned() const	{ return mPreviouslyGroupOwned; }
 	BOOL	getSellWithObjects() const		{ return (mParcelFlags & PF_SELL_PARCEL_OBJECTS) ? TRUE : FALSE; }
 	
-	
+    S64Seconds getDayLength() const                             { return mDayLength; }
+    void setDayLength(S64SecondsImplicit seconds)              { mDayLength = seconds; }
+    S64Seconds getDayOffset() const                             { return mDayOffset; }
+    void setDayOffset(S64SecondsImplicit seconds)              { mDayOffset = seconds; }
+    bool getIsDefaultDayCycle() const                           { return mIsDefaultDayCycle; }
+    void setIsDefaultDayCycle(bool isdefault)                  { mIsDefaultDayCycle = isdefault; }
+    LLSettingsDay::ptr_t getParcelDayCycle() const              { return mDayCycle; }
+    void setParcelDayCycle(const LLSettingsDay::ptr_t &pday)    { mDayCycle = pday; }
+
 protected:
 	LLUUID mID;
 	LLUUID				mOwnerID;
@@ -665,7 +674,11 @@ class LLParcel
 	BOOL				mAllowGroupAVSounds;
 	BOOL				mAllowAnyAVSounds;
 	
-	
+    S64Seconds          mDayLength;
+    S64Seconds          mDayOffset;
+    bool                mIsDefaultDayCycle;
+    LLSettingsDay::ptr_t mDayCycle;
+
 public:
 	// HACK, make private
 	S32					mLocalID;
diff --git a/indra/llinventory/llsettingsdaycycle.cpp b/indra/llinventory/llsettingsdaycycle.cpp
index 180992cd2951dbdb16d1d81ecee1a64fa0384edc..4207df0924d7fb9a006474146d105a47012b52a1 100644
--- a/indra/llinventory/llsettingsdaycycle.cpp
+++ b/indra/llinventory/llsettingsdaycycle.cpp
@@ -432,7 +432,6 @@ void LLSettingsDay::updateSettings()
 {
     static LLFrameTimer timer;
 
-
     F64Seconds delta(timer.getElapsedTimeAndResetF32());
 
     if (mSkyBlender)
diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt
index 4579ef14e2b53e30010600a92aaaef79cafc19fe..673f251da2260a35c2959fc0303ee8c144988e63 100644
--- a/indra/newview/CMakeLists.txt
+++ b/indra/newview/CMakeLists.txt
@@ -419,6 +419,7 @@ set(viewer_SOURCE_FILES
     llpanelclassified.cpp
     llpanelcontents.cpp
     llpaneleditwearable.cpp
+    llpanelenvironment.cpp
     llpanelexperiencelisteditor.cpp
     llpanelexperiencelog.cpp
     llpanelexperiencepicker.cpp
@@ -1026,6 +1027,7 @@ set(viewer_HEADER_FILES
     llpanelclassified.h
     llpanelcontents.h
     llpaneleditwearable.h
+    llpanelenvironment.h
     llpanelexperiencelisteditor.h
     llpanelexperiencelog.h
     llpanelexperiencepicker.h
diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp
index e14265d950d1771425e985bb9afe6730033c2250..b05c9ee871ca043b3ac26db557fa9a8082a007e1 100644
--- a/indra/newview/llenvironment.cpp
+++ b/indra/newview/llenvironment.cpp
@@ -41,6 +41,9 @@
 
 #include "llviewershadermgr.h"
 
+#include "llparcel.h"
+#include "llviewerparcelmgr.h"
+
 #include "llsdserialize.h"
 #include "lldiriterator.h"
 
@@ -106,6 +109,7 @@ void LLEnvironment::initSingleton()
 
     requestRegionEnvironment();
     gAgent.addRegionChangedCallback(boost::bind(&LLEnvironment::onRegionChange, this));
+    gAgent.addParcelChangedCallback(boost::bind(&LLEnvironment::onParcelChange, this));
 }
 
 LLEnvironment::~LLEnvironment()
@@ -143,12 +147,24 @@ LLEnvironment::connection_t LLEnvironment::setDayCycleListChange(const LLEnviron
     return mDayCycleListChange.connect(cb);
 }
 
-
 void LLEnvironment::onRegionChange()
 {
     requestRegionEnvironment();
 }
 
+void LLEnvironment::onParcelChange()
+{
+    LLUUID parcel_id;
+    LLParcel* parcel = LLViewerParcelMgr::instance().getAgentParcel();
+
+    if (parcel)
+    {
+        parcel_id = parcel->getID();
+    }
+
+    requestParcel(parcel_id);
+}
+
 void LLEnvironment::requestRegionEnvironment()
 {
 //    LLEnvironmentRequest::initiate();
@@ -821,7 +837,8 @@ void LLEnvironment::requestParcel(const LLUUID &parcel_id)
 {
     std::string coroname =
         LLCoros::instance().launch("LLEnvironment::coroRequestEnvironment",
-        boost::bind(&LLEnvironment::coroRequestEnvironment, this, parcel_id));
+        boost::bind(&LLEnvironment::coroRequestEnvironment, this, parcel_id, 
+        boost::bind(&LLEnvironment::applyEnvironment, this, _1)));
 
 }
 
@@ -829,7 +846,9 @@ void LLEnvironment::updateParcel(const LLUUID &parcel_id, LLSettingsDay::ptr_t &
 {
     std::string coroname =
         LLCoros::instance().launch("LLEnvironment::coroUpdateEnvironment",
-        boost::bind(&LLEnvironment::coroUpdateEnvironment, this, parcel_id, pday, day_length, day_offset));
+        boost::bind(&LLEnvironment::coroUpdateEnvironment, this, parcel_id, 
+        pday, day_length, day_offset,
+        boost::bind(&LLEnvironment::applyEnvironment, this, _1)));
 
 }
 
@@ -837,11 +856,11 @@ void LLEnvironment::resetParcel(const LLUUID &parcel_id)
 {
     std::string coroname =
         LLCoros::instance().launch("LLEnvironment::coroResetEnvironment",
-        boost::bind(&LLEnvironment::coroResetEnvironment, this, parcel_id));
-
+        boost::bind(&LLEnvironment::coroResetEnvironment, this, parcel_id,
+        boost::bind(&LLEnvironment::applyEnvironment, this, _1)));
 }
 
-void LLEnvironment::coroRequestEnvironment(LLUUID parcel_id)
+void LLEnvironment::coroRequestEnvironment(LLUUID parcel_id, environment_apply_fn apply)
 {
     LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID);
     LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t
@@ -875,9 +894,9 @@ void LLEnvironment::coroRequestEnvironment(LLUUID parcel_id)
     else
     {
         LLSD environment = result["environment"];
-        if (environment.isDefined())
+        if (environment.isDefined() && !apply.empty())
         {
-            applyEnvironment(environment);
+            apply(environment);
         }
     }
 
@@ -888,7 +907,7 @@ void LLEnvironment::coroRequestEnvironment(LLUUID parcel_id)
     }
 }
 
-void LLEnvironment::coroUpdateEnvironment(LLUUID parcel_id, LLSettingsDay::ptr_t pday, S32 day_length, S32 day_offset)
+void LLEnvironment::coroUpdateEnvironment(LLUUID parcel_id, LLSettingsDay::ptr_t pday, S32 day_length, S32 day_offset, environment_apply_fn apply)
 {
     LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID);
     LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t
@@ -932,9 +951,9 @@ void LLEnvironment::coroUpdateEnvironment(LLUUID parcel_id, LLSettingsDay::ptr_t
     else
     {
         LLSD environment = result["environment"];
-        if (environment.isDefined())
+        if (environment.isDefined() && !apply.empty())
         {
-            applyEnvironment(environment);
+            apply(environment);
         }
     }
 
@@ -945,7 +964,7 @@ void LLEnvironment::coroUpdateEnvironment(LLUUID parcel_id, LLSettingsDay::ptr_t
     }
 }
 
-void LLEnvironment::coroResetEnvironment(LLUUID parcel_id)
+void LLEnvironment::coroResetEnvironment(LLUUID parcel_id, environment_apply_fn apply)
 {
     LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID);
     LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t
@@ -979,10 +998,10 @@ void LLEnvironment::coroResetEnvironment(LLUUID parcel_id)
     else
     {
         LLSD environment = result["environment"];
-        if (environment.isDefined())
+        if (environment.isDefined() && !apply.empty())
         {
-            applyEnvironment(environment);
-        }        
+                apply(environment);
+        }
     }
 
     if (!notify.isUndefined())
diff --git a/indra/newview/llenvironment.h b/indra/newview/llenvironment.h
index 9e9c05b19480adbdf5381950d86a05c20e398d5e..4f8850683e09257b1a2fa7b57bcdab9c4e553f8e 100644
--- a/indra/newview/llenvironment.h
+++ b/indra/newview/llenvironment.h
@@ -99,6 +99,7 @@ class LLEnvironment : public LLSingleton<LLEnvironment>
     typedef std::pair<std::string, LLUUID>                  name_id_t;
     typedef std::vector<name_id_t>                          list_name_id_t;
     typedef boost::signals2::signal<void()>                 change_signal_t;
+    typedef boost::function<void(const LLSD &)>             environment_apply_fn;
 
     virtual ~LLEnvironment();
 
@@ -233,20 +234,6 @@ class LLEnvironment : public LLSingleton<LLEnvironment>
     WaterList_t                 mSetWater;
     DayList_t                   mSetDays;
 
-#if 0
-    LLSettingsSky::ptr_t        mRegionFixedSky;
-    LLSettingsWater::ptr_t      mRegionFixedWater;
-    LLSettingsDay::ptr_t        mRegionDay;
-
-    LLSettingsSky::ptr_t        mParcelFixedSky;
-    LLSettingsWater::ptr_t      mParcelFixedWater;
-    LLSettingsDay::ptr_t        mParcelDay;
-
-    LLSettingsSky::ptr_t        mUserSky;
-    LLSettingsWater::ptr_t      mUserWater;
-    LLSettingsDay::ptr_t        mUserDay;
-#endif
-
     namedSettingMap_t           mSkysByName;
     AssetSettingMap_t           mSkysById;
 
@@ -291,10 +278,11 @@ class LLEnvironment : public LLSingleton<LLEnvironment>
     void updateCloudScroll();
 
     void onRegionChange();
+    void onParcelChange();
 
-    void coroRequestEnvironment(LLUUID parcel_id);
-    void coroUpdateEnvironment(LLUUID parcel_id, LLSettingsDay::ptr_t pday, S32 day_length, S32 day_offset);
-    void coroResetEnvironment(LLUUID parcel_id);
+    void coroRequestEnvironment(LLUUID parcel_id, environment_apply_fn apply);
+    void coroUpdateEnvironment(LLUUID parcel_id, LLSettingsDay::ptr_t pday, S32 day_length, S32 day_offset, environment_apply_fn apply);
+    void coroResetEnvironment(LLUUID parcel_id, environment_apply_fn apply);
 
     void applyEnvironment(LLSD environment);
 
diff --git a/indra/newview/llfloaterland.cpp b/indra/newview/llfloaterland.cpp
index 88b3fb7b9681f7af464beabb007f05086decf15e..fc4ab0a7a725e5b86696ee7cdbb8ba864be19656 100644
--- a/indra/newview/llfloaterland.cpp
+++ b/indra/newview/llfloaterland.cpp
@@ -78,6 +78,7 @@
 #include "lltrans.h"
 #include "llpanelexperiencelisteditor.h"
 #include "llpanelexperiencepicker.h"
+#include "llpanelenvironment.h"
 #include "llexperiencecache.h"
 
 #include "llgroupactions.h"
@@ -138,6 +139,32 @@ class LLPanelLandExperiences
 	LLPanelExperienceListEditor* mBlocked;
 };
 
+#if 0
+class LLPanelLandEnvironment
+    : public LLPanel
+{
+public:
+    LLPanelLandEnvironment(LLSafeHandle<LLParcelSelection>& parcelp);
+    // TODO: LAPRAS
+#if 0
+    virtual BOOL postBuild();
+    void refresh();
+
+    void experienceAdded(const LLUUID& id, U32 xp_type, U32 access_type);
+    void experienceRemoved(const LLUUID& id, U32 access_type);
+protected:
+    LLPanelExperienceListEditor* setupList(const char* control_name, U32 xp_type, U32 access_type);
+    void refreshPanel(LLPanelExperienceListEditor* panel, U32 xp_type);
+
+    LLSafeHandle<LLParcelSelection>&	mParcel;
+
+
+    LLPanelExperienceListEditor* mAllowed;
+    LLPanelExperienceListEditor* mBlocked;
+#endif
+};
+#endif
+
 // inserts maturity info(icon and text) into target textbox 
 // names_floater - pointer to floater which contains strings with maturity icons filenames
 // str_to_parse is string in format "txt1[MATURITY]txt2" where maturity icon and text will be inserted instead of [MATURITY]
@@ -277,6 +304,7 @@ LLFloaterLand::LLFloaterLand(const LLSD& seed)
 	mFactoryMap["land_media_panel"] =	LLCallbackMap(createPanelLandMedia, this);
 	mFactoryMap["land_access_panel"] =	LLCallbackMap(createPanelLandAccess, this);
 	mFactoryMap["land_experiences_panel"] =	LLCallbackMap(createPanelLandExperiences, this);
+    mFactoryMap["land_environment_panel"] = LLCallbackMap(createPanelLandEnvironment, this);
 
 	sObserver = new LLParcelSelectionObserver();
 	LLViewerParcelMgr::getInstance()->addObserver( sObserver );
@@ -386,6 +414,14 @@ void* LLFloaterLand::createPanelLandExperiences(void* data)
 	return self->mPanelExperiences;
 }
 
+//static 
+void* LLFloaterLand::createPanelLandEnvironment(void* data)
+{
+    LLFloaterLand* self = (LLFloaterLand*)data;
+    self->mPanelEnvironment = new LLPanelEnvironmentInfo(/*self->mParcel*/);
+    return self->mPanelEnvironment;
+}
+
 
 //---------------------------------------------------------------------------
 // LLPanelLandGeneral
diff --git a/indra/newview/llfloaterland.h b/indra/newview/llfloaterland.h
index 0540ddb88010a518f07ce68f1e6f26c07a44b1e7..e5837b5a08e7ee860207f984b64a5bb27767b614 100644
--- a/indra/newview/llfloaterland.h
+++ b/indra/newview/llfloaterland.h
@@ -67,6 +67,8 @@ class LLPanelLandRenters;
 class LLPanelLandCovenant;
 class LLParcel;
 class LLPanelLandExperiences;
+//class LLPanelLandEnvironment;
+class LLPanelEnvironmentInfo;
 
 class LLFloaterLand
 :	public LLFloater
@@ -103,7 +105,8 @@ class LLFloaterLand
 	static void* createPanelLandMedia(void* data);
 	static void* createPanelLandAccess(void* data);
 	static void* createPanelLandExperiences(void* data);
-	static void* createPanelLandBan(void* data);
+    static void* createPanelLandEnvironment(void* data);
+    static void* createPanelLandBan(void* data);
 
 
 protected:
@@ -119,6 +122,7 @@ class LLFloaterLand
 	LLPanelLandAccess*		mPanelAccess;
 	LLPanelLandCovenant*	mPanelCovenant;
 	LLPanelLandExperiences*	mPanelExperiences;
+    LLPanelEnvironmentInfo *mPanelEnvironment;
 
 	LLSafeHandle<LLParcelSelection>	mParcel;
 
diff --git a/indra/newview/llfloaterregioninfo.cpp b/indra/newview/llfloaterregioninfo.cpp
index e0a56b9412c602c250d81d3e5bd767357c31ae2b..5ce682fe8c4a6cdfdb8abf3bc0bea449ab1840da 100644
--- a/indra/newview/llfloaterregioninfo.cpp
+++ b/indra/newview/llfloaterregioninfo.cpp
@@ -189,7 +189,8 @@ LLUUID LLFloaterRegionInfo::sRequestInvoice;
 
 
 LLFloaterRegionInfo::LLFloaterRegionInfo(const LLSD& seed)
-	: LLFloater(seed)
+	: LLFloater(seed),
+    mEnvironmentPanel(NULL)
 {}
 
 BOOL LLFloaterRegionInfo::postBuild()
@@ -220,10 +221,9 @@ BOOL LLFloaterRegionInfo::postBuild()
 	panel->buildFromFile("panel_region_terrain.xml");
 	mTab->addTabPanel(panel);
 
-	panel = new LLPanelEnvironmentInfo;
-	mInfoPanels.push_back(panel);
-	panel->buildFromFile("panel_region_environment.xml");
-	mTab->addTabPanel(panel);
+    mEnvironmentPanel = new LLPanelRegionEnvironment;
+    mEnvironmentPanel->buildFromFile("panel_region_environment.xml");
+    mTab->addTabPanel(mEnvironmentPanel);
 
 	panel = new LLPanelRegionDebugInfo;
 	mInfoPanels.push_back(panel);
@@ -242,7 +242,7 @@ BOOL LLFloaterRegionInfo::postBuild()
 		panel->buildFromFile("panel_region_experiences.xml");
 		mTab->addTabPanel(panel);
 	}
-	
+
 	gMessageSystem->setHandlerFunc(
 		"EstateOwnerMessage", 
 		&processEstateOwnerRequest);
@@ -540,6 +540,7 @@ void LLFloaterRegionInfo::refreshFromRegion(LLViewerRegion* region)
 			std::mem_fun(&LLPanelRegionInfo::refreshFromRegion),
 #endif
 			region));
+    mEnvironmentPanel->refreshFromRegion(region);
 }
 
 // public
@@ -550,6 +551,7 @@ void LLFloaterRegionInfo::refresh()
 	{
 		(*iter)->refresh();
 	}
+    mEnvironmentPanel->refresh();
 }
 
 void LLFloaterRegionInfo::enableTopButtons()
@@ -3083,630 +3085,6 @@ bool LLDispatchSetEstateExperience::operator()(
 }
 
 
-
-LLPanelEnvironmentInfo::LLPanelEnvironmentInfo()
-:	mEnableEditing(false),
-	mRegionSettingsRadioGroup(NULL),
- 	mDayCycleSettingsRadioGroup(NULL),
- 	mWaterPresetCombo(NULL),
- 	mSkyPresetCombo(NULL),
- 	mDayCyclePresetCombo(NULL)
-{
-}
-
-// virtual
-BOOL LLPanelEnvironmentInfo::postBuild()
-{
-	mRegionSettingsRadioGroup = getChild<LLRadioGroup>("region_settings_radio_group");
-	mRegionSettingsRadioGroup->setCommitCallback(boost::bind(&LLPanelEnvironmentInfo::onSwitchRegionSettings, this));
-
-	mDayCycleSettingsRadioGroup = getChild<LLRadioGroup>("sky_dayc_settings_radio_group");
-	mDayCycleSettingsRadioGroup->setCommitCallback(boost::bind(&LLPanelEnvironmentInfo::onSwitchDayCycle, this));
-
-	mWaterPresetCombo = getChild<LLComboBox>("water_settings_preset_combo");
-	mWaterPresetCombo->setCommitCallback(boost::bind(&LLPanelEnvironmentInfo::onSelectWaterPreset, this));
-
-	mSkyPresetCombo = getChild<LLComboBox>("sky_settings_preset_combo");
-	mSkyPresetCombo->setCommitCallback(boost::bind(&LLPanelEnvironmentInfo::onSelectSkyPreset, this));
-
-	mDayCyclePresetCombo = getChild<LLComboBox>("dayc_settings_preset_combo");
-	mDayCyclePresetCombo->setCommitCallback(boost::bind(&LLPanelEnvironmentInfo::onSelectDayCycle, this));
-
-    childSetCommitCallback("apply_btn", boost::bind(&LLPanelEnvironmentInfo::onBtnApply, this), NULL);
-//	getChild<LLButton>("apply_btn")->setRightMouseDownCallback(boost::bind(&LLEnvManagerNew::dumpUserPrefs, LLEnvManagerNew::getInstance()));
-	childSetCommitCallback("cancel_btn", boost::bind(&LLPanelEnvironmentInfo::onBtnCancel, this), NULL);
-//	getChild<LLButton>("cancel_btn")->setRightMouseDownCallback(boost::bind(&LLEnvManagerNew::dumpPresets, LLEnvManagerNew::getInstance()));
-
-// 	LLEnvManagerNew::instance().setRegionSettingsChangeCallback(boost::bind(&LLPanelEnvironmentInfo::onRegionSettingschange, this));
-// 	LLEnvManagerNew::instance().setRegionSettingsAppliedCallback(boost::bind(&LLPanelEnvironmentInfo::onRegionSettingsApplied, this, _1));
-
-// 	LLDayCycleManager::instance().setModifyCallback(boost::bind(&LLPanelEnvironmentInfo::populateDayCyclesList, this));
-// 	LLWLParamManager::instance().setPresetListChangeCallback(boost::bind(&LLPanelEnvironmentInfo::populateSkyPresetsList, this));
-// 	LLWaterParamManager::instance().setPresetListChangeCallback(boost::bind(&LLPanelEnvironmentInfo::populateWaterPresetsList, this));
-
-	return TRUE;
-}
-
-// virtual
-void LLPanelEnvironmentInfo::onOpen(const LLSD& key)
-{
-	LL_DEBUGS("Windlight") << "Panel opened, refreshing" << LL_ENDL;
-	refresh();
-}
-
-// virtual
-void LLPanelEnvironmentInfo::onVisibilityChange(BOOL new_visibility)
-{
-	// If hiding (user switched to another tab or closed the floater),
-	// display user's preferred environment.
-	if (!new_visibility)
-	{
-//		LLEnvManagerNew::instance().usePrefs();
-	}
-}
-
-// virtual
-bool LLPanelEnvironmentInfo::refreshFromRegion(LLViewerRegion* region)
-{
-	LL_DEBUGS("Windlight") << "Region updated, enabling/disabling controls" << LL_ENDL;
-	BOOL owner_or_god = gAgent.isGodlike() || (region && (region->getOwner() == gAgent.getID()));
-	BOOL owner_or_god_or_manager = owner_or_god || (region && region->isEstateManager());
-
-	// Don't refresh from region settings to avoid flicker after applying new region settings.
-	mEnableEditing = owner_or_god_or_manager;
-	setControlsEnabled(mEnableEditing);
-
-	return LLPanelRegionInfo::refreshFromRegion(region);
-}
-
-void LLPanelEnvironmentInfo::refresh()
-{
-#if 0
-	if(gDisconnected)
-	{
-		return;
-	}
-
-	populateWaterPresetsList();
-	populateSkyPresetsList();
-	populateDayCyclesList();
-
-	// Init radio groups.
-	const LLEnvironmentSettings& settings = LLEnvManagerNew::instance().getRegionSettings();
-	const LLSD& dc = settings.getWLDayCycle();
-	LLSD::Real first_frame_time = dc.size() > 0 ? dc[0][0].asReal() : 0.0f;
-	const bool use_fixed_sky = dc.size() == 1 && first_frame_time < 0;
-	mRegionSettingsRadioGroup->setSelectedIndex(settings.getSkyMap().size() == 0 ? 0 : 1);
-	mDayCycleSettingsRadioGroup->setSelectedIndex(use_fixed_sky ? 0 : 1);
-
-	setControlsEnabled(mEnableEditing);
-
-	setDirty(false);
-#endif
-}
-
-void LLPanelEnvironmentInfo::setControlsEnabled(bool enabled)
-{
-	mRegionSettingsRadioGroup->setEnabled(enabled);
-	mDayCycleSettingsRadioGroup->setEnabled(enabled);
-
-	mWaterPresetCombo->setEnabled(false);
-	mSkyPresetCombo->setEnabled(false);
-	mDayCyclePresetCombo->setEnabled(false);
-
-	getChildView("apply_btn")->setEnabled(enabled);
-	getChildView("cancel_btn")->setEnabled(enabled);
-
-	if (enabled)
-	{
-		// Enable/disable some controls based on currently selected radio buttons.
-		bool use_defaults = mRegionSettingsRadioGroup->getSelectedIndex() == 0;
-		getChild<LLView>("user_environment_settings")->setEnabled(!use_defaults);
-
-		bool is_fixed_sky = mDayCycleSettingsRadioGroup->getSelectedIndex() == 0;
-		mSkyPresetCombo->setEnabled(is_fixed_sky);
-		mDayCyclePresetCombo->setEnabled(!is_fixed_sky);
-	}
-}
-
-void LLPanelEnvironmentInfo::setApplyProgress(bool started)
-{
-	LLLoadingIndicator* indicator = getChild<LLLoadingIndicator>("progress_indicator");
-
-	indicator->setVisible(started);
-
-	if (started)
-	{
-		indicator->start();
-	}
-	else
-	{
-		indicator->stop();
-	}
-}
-
-void LLPanelEnvironmentInfo::setDirty(bool dirty)
-{
-	getChildView("apply_btn")->setEnabled(dirty);
-	getChildView("cancel_btn")->setEnabled(dirty);
-}
-
-void LLPanelEnvironmentInfo::sendRegionSunUpdate()
-{
-#if 0
-	LLRegionInfoModel& region_info = LLRegionInfoModel::instance();
-
-	// If the region is being switched to fixed sky,
-	// change the region's sun hour according to the (fixed) sun position.
-	// This is needed for llGetSunDirection() LSL function to work properly (STORM-1330).
-	const LLSD& sky_map = mNewRegionSettings.getSkyMap();
-	bool region_use_fixed_sky = sky_map.size() == 1;
-	if (region_use_fixed_sky)
-	{
-		LLWLParamSet param_set;
-		llassert(sky_map.isMap());
-		param_set.setAll(sky_map.beginMap()->second);
-		F32 sun_angle = param_set.getSunAngle();
-
-		LL_DEBUGS("Windlight Sync") << "Old sun hour: " << region_info.mSunHour << LL_ENDL;
-		// convert value range from 0..2pi to 6..30
-		region_info.mSunHour = fmodf((sun_angle / F_TWO_PI) * 24.f, 24.f) + 6.f;
-	}
-
-	region_info.setUseFixedSun(region_use_fixed_sky);
-	region_info.mUseEstateSun = !region_use_fixed_sky;
-	LL_DEBUGS("Windlight Sync") << "Sun hour: " << region_info.mSunHour << LL_ENDL;
-
-	region_info.sendRegionTerrain(LLFloaterRegionInfo::getLastInvoice());
-#endif
-}
-
-void LLPanelEnvironmentInfo::fixEstateSun()
-{
-	// We don't support fixed sun estates anymore and need to fix
-	// such estates for region day cycle to take effect.
-	// *NOTE: Assuming that current estate settings have arrived already.
-	LLEstateInfoModel& estate_info = LLEstateInfoModel::instance();
-	if (estate_info.getUseFixedSun())
-	{
-		LL_INFOS() << "Switching estate to global sun" << LL_ENDL;
-		estate_info.setUseFixedSun(false);
-		estate_info.sendEstateInfo();
-	}
-}
-
-void LLPanelEnvironmentInfo::populateWaterPresetsList()
-{
-#if 0
-	mWaterPresetCombo->removeall();
-
-	// If the region already has water params, add them to the list.
-	const LLEnvironmentSettings& region_settings = LLEnvManagerNew::instance().getRegionSettings();
-	if (region_settings.getWaterParams().size() != 0)
-	{
-		const std::string& region_name = gAgent.getRegion()->getName();
-		mWaterPresetCombo->add(region_name, LLWLParamKey(region_name, LLEnvKey::SCOPE_REGION).toLLSD());
-		mWaterPresetCombo->addSeparator();
-	}
-
-	std::list<std::string> user_presets, system_presets;
-	LLWaterParamManager::instance().getPresetNames(user_presets, system_presets);
-
-	// Add local user presets first.
-	for (std::list<std::string>::const_iterator it = user_presets.begin(); it != user_presets.end(); ++it)
-	{
-		mWaterPresetCombo->add(*it, LLWLParamKey(*it, LLEnvKey::SCOPE_LOCAL).toLLSD());
-	}
-
-	if (user_presets.size() > 0)
-	{
-		mWaterPresetCombo->addSeparator();
-	}
-
-	// Add local system presets.
-	for (std::list<std::string>::const_iterator it = system_presets.begin(); it != system_presets.end(); ++it)
-	{
-		mWaterPresetCombo->add(*it, LLWLParamKey(*it, LLEnvKey::SCOPE_LOCAL).toLLSD());
-	}
-
-	// There's no way to select current preset because its name is not stored on server.
-#endif
-}
-
-void LLPanelEnvironmentInfo::populateSkyPresetsList()
-{
-#if 0
-	mSkyPresetCombo->removeall();
-
-	LLWLParamManager::preset_name_list_t region_presets;
-	LLWLParamManager::preset_name_list_t user_presets, sys_presets;
-	LLWLParamManager::instance().getPresetNames(region_presets, user_presets, sys_presets);
-
-	// Add region presets.
-	std::string region_name = gAgent.getRegion() ? gAgent.getRegion()->getName() : LLTrans::getString("Unknown");
-	for (LLWLParamManager::preset_name_list_t::const_iterator it = region_presets.begin(); it != region_presets.end(); ++it)
-	{
-		std::string preset_name = *it;
-		std::string item_title = preset_name + " (" + region_name + ")";
-		mSkyPresetCombo->add(item_title, LLWLParamKey(preset_name, LLEnvKey::SCOPE_REGION).toStringVal());
-	}
-
-	if (!region_presets.empty())
-	{
-		mSkyPresetCombo->addSeparator();
-	}
-
-	// Add user presets.
-	for (LLWLParamManager::preset_name_list_t::const_iterator it = user_presets.begin(); it != user_presets.end(); ++it)
-	{
-		mSkyPresetCombo->add(*it, LLWLParamKey(*it, LLEnvKey::SCOPE_LOCAL).toStringVal());
-	}
-
-	if (!user_presets.empty())
-	{
-		mSkyPresetCombo->addSeparator();
-	}
-
-	// Add system presets.
-	for (LLWLParamManager::preset_name_list_t::const_iterator it = sys_presets.begin(); it != sys_presets.end(); ++it)
-	{
-		mSkyPresetCombo->add(*it, LLWLParamKey(*it, LLEnvKey::SCOPE_LOCAL).toStringVal());
-	}
-
-	// Select current preset.
-	LLSD sky_map = LLEnvManagerNew::instance().getRegionSettings().getSkyMap();
-	if (sky_map.size() == 1) // if the region is set to fixed sky
-	{
-		std::string preset_name = sky_map.beginMap()->first;
-		mSkyPresetCombo->selectByValue(LLWLParamKey(preset_name, LLEnvKey::SCOPE_REGION).toStringVal());
-	}
-#endif
-}
-
-void LLPanelEnvironmentInfo::populateDayCyclesList()
-{
-#if 0
-	mDayCyclePresetCombo->removeall();
-
-	// If the region already has env. settings, add its day cycle to the list.
-	const LLSD& cur_region_dc = LLEnvManagerNew::instance().getRegionSettings().getWLDayCycle();
-	if (cur_region_dc.size() != 0)
-	{
-		LLViewerRegion* region = gAgent.getRegion();
-		llassert(region != NULL);
-
-		LLWLParamKey key(region->getName(), LLEnvKey::SCOPE_REGION);
-		mDayCyclePresetCombo->add(region->getName(), key.toStringVal());
-		mDayCyclePresetCombo->addSeparator();
-	}
-
-	// Add local user day cycles.
-	LLDayCycleManager::preset_name_list_t user_days, sys_days;
-	LLDayCycleManager::instance().getPresetNames(user_days, sys_days);
-	for (LLDayCycleManager::preset_name_list_t::const_iterator it = user_days.begin(); it != user_days.end(); ++it)
-	{
-		mDayCyclePresetCombo->add(*it, LLWLParamKey(*it, LLEnvKey::SCOPE_LOCAL).toStringVal());
-	}
-
-	if (user_days.size() > 0)
-	{
-		mDayCyclePresetCombo->addSeparator();
-	}
-
-	// Add local system day cycles.
-	for (LLDayCycleManager::preset_name_list_t::const_iterator it = sys_days.begin(); it != sys_days.end(); ++it)
-	{
-		mDayCyclePresetCombo->add(*it, LLWLParamKey(*it, LLEnvKey::SCOPE_LOCAL).toStringVal());
-	}
-
-	// Current day cycle is already selected.
-#endif
-}
-
-bool LLPanelEnvironmentInfo::getSelectedWaterParams(LLSD& water_params)
-{
-#if 0
-	LLWLParamKey water_key(mWaterPresetCombo->getSelectedValue());
-
-	if (water_key.scope == LLEnvKey::SCOPE_REGION)
-	{
-		water_params = LLEnvManagerNew::instance().getRegionSettings().getWaterParams();
-	}
-	else
-	{
-		LLWaterParamSet param_set;
-		if (!LLWaterParamManager::instance().getParamSet(water_key.name, param_set))
-		{
-			LL_WARNS() << "Error getting water preset: " << water_key.name << LL_ENDL;
-			return false;
-		}
-
-		water_params = param_set.getAll();
-	}
-
-	return true;
-#endif
-    return false;
-}
-
-bool LLPanelEnvironmentInfo::getSelectedSkyParams(LLSD& sky_params, std::string& preset_name)
-{
-#if 0
-	std::string preset_key(mSkyPresetCombo->getValue().asString());
-	LLWLParamKey preset(preset_key);
-
-	// Get the preset sky params.
-	LLWLParamSet param_set;
-	if (!LLWLParamManager::instance().getParamSet(preset, param_set))
-	{
-		LL_WARNS() << "Error getting sky params: " << preset.toLLSD() << LL_ENDL;
-		return false;
-	}
-
-	sky_params = param_set.getAll();
-	preset_name = preset.name;
-	return true;
-#endif 
-    return false;
-}
-
-bool LLPanelEnvironmentInfo::getSelectedDayCycleParams(LLSD& day_cycle, LLSD& sky_map, short& scope)
-{
-#if 0
-	std::string preset_key(mDayCyclePresetCombo->getValue().asString());
-	LLWLParamKey dc(preset_key);
-	LL_DEBUGS("Windlight") << "Use day cycle: " << dc.toLLSD() << LL_ENDL;
-
-	if (dc.scope == LLEnvKey::SCOPE_REGION) // current region day cycle
-	{
-		const LLEnvironmentSettings& cur_region_settings = LLEnvManagerNew::instance().getRegionSettings();
-		day_cycle = cur_region_settings.getWLDayCycle();
-		sky_map = cur_region_settings.getSkyMap();
-	}
-	else // a local day cycle
-	{
-		if (!LLDayCycleManager::instance().getPreset(dc.name, day_cycle))
-		{
-			LL_WARNS() << "Error getting day cycle " << dc.name << LL_ENDL;
-			return false;
-		}
-
-		// Create sky map from the day cycle.
-		{
-			LLWLDayCycle tmp_day;
-			tmp_day.loadDayCycle(day_cycle, dc.scope);
-			tmp_day.getSkyMap(sky_map);
-		}
-	}
-
-	scope = dc.scope;
-
-	return true;
-#endif
-    return false;
-}
-void LLPanelEnvironmentInfo::onSwitchRegionSettings()
-{
-	bool use_defaults = mRegionSettingsRadioGroup->getSelectedIndex() == 0;
-	getChild<LLView>("user_environment_settings")->setEnabled(!use_defaults);
-
-	if (use_defaults)
-	{
-//		LLEnvManagerNew::instance().useDefaults();
-	}
-	else
-	{
-		onSelectWaterPreset();
-		onSwitchDayCycle();
-	}
-
-	setDirty(true);
-}
-
-void LLPanelEnvironmentInfo::onSwitchDayCycle()
-{
-	bool is_fixed_sky = mDayCycleSettingsRadioGroup->getSelectedIndex() == 0;
-
-	mSkyPresetCombo->setEnabled(is_fixed_sky);
-	mDayCyclePresetCombo->setEnabled(!is_fixed_sky);
-
-	if (is_fixed_sky)
-	{
-		onSelectSkyPreset();
-	}
-	else
-	{
-		onSelectDayCycle();
-	}
-
-	setDirty(true);
-}
-
-void LLPanelEnvironmentInfo::onSelectWaterPreset()
-{
-	LLSD water_params;
-
-	if (getSelectedWaterParams(water_params))
-	{
-//		LLEnvManagerNew::instance().useWaterParams(water_params);
-	}
-
-	setDirty(true);
-}
-
-void LLPanelEnvironmentInfo::onSelectSkyPreset()
-{
-	LLSD params;
-	std::string dummy;
-
-	if (getSelectedSkyParams(params, dummy))
-	{
-//		LLEnvManagerNew::instance().useSkyParams(params);
-	}
-
-	setDirty(true);
-}
-
-void LLPanelEnvironmentInfo::onSelectDayCycle()
-{
-	LLSD day_cycle;
-	LLSD sky_map; // unused
-	short scope;
-
-	if (getSelectedDayCycleParams(day_cycle, sky_map, scope))
-	{
-//		LLEnvManagerNew::instance().useDayCycleParams(day_cycle, (LLEnvKey::EScope) scope);
-	}
-
-	setDirty(true);
-}
-
-void LLPanelEnvironmentInfo::onBtnApply()
-{
-	const bool use_defaults = mRegionSettingsRadioGroup->getSelectedIndex() == 0;
-	const bool use_fixed_sky = mDayCycleSettingsRadioGroup->getSelectedIndex() == 0;
-
-	LLSD day_cycle;
-	LLSD sky_map;
-	LLSD water_params;
-
-	if (use_defaults)
-	{
-		// settings will be empty
-		LL_DEBUGS("Windlight") << "Defaults" << LL_ENDL;
-	}
-	else // use custom region settings
-	{
-		if (use_fixed_sky)
-		{
-			LL_DEBUGS("Windlight") << "Use fixed sky" << LL_ENDL;
-
-#if 0
-			// Get selected sky params.
-			LLSD params;
-			std::string preset_name;
-			if (!getSelectedSkyParams(params, preset_name))
-			{
-				return;
-			}
-
-			// Create a day cycle consisting of a single sky preset.
-			LLSD key(LLSD::emptyArray());
-			key.append(-1.0f); // indicate that user preference is actually fixed sky, not a day cycle
-			key.append(preset_name);
-			day_cycle.append(key);
-
-			// Create a sky map consisting of only the sky preset.
-			std::map<LLWLParamKey, LLWLParamSet> refs;
-			LLWLParamSet param_set;
-			param_set.setAll(params);
-			refs[LLWLParamKey(preset_name, LLEnvKey::SCOPE_LOCAL)] = param_set; // scope doesn't matter here
-			sky_map = LLWLParamManager::createSkyMap(refs);
-#endif
-		}
-		else // use day cycle
-		{
-			LL_DEBUGS("Windlight") << "Use day cycle" << LL_ENDL;
-
-			short scope; // unused
-			if (!getSelectedDayCycleParams(day_cycle, sky_map, scope))
-			{
-				return;
-			}
-
-			// If it's a special single-preset day cycle meaning using a fixed sky,
-			// reset the frame time to a non-negative value,
-			// so that the region setting is displayed in the floater as
-			// a day cycle, not a preset. (STORM-1289)
-			if (day_cycle.size() == 1 && day_cycle[0][0].asReal() < 0.0f)
-			{
-				LL_DEBUGS("Windlight") << "Fixing negative time" << LL_ENDL;
-				day_cycle[0][0] = 0.0f;
-			}
-		}
-
-		// Get water params.
-		if (!getSelectedWaterParams(water_params))
-		{
-			// *TODO: show a notification?
-			return;
-		}
-	}
-
-#if 0
-	// Send settings apply request.
-	LLEnvironmentSettings new_region_settings;
-	new_region_settings.saveParams(day_cycle, sky_map, water_params, 0.0f);
-	if (!LLEnvManagerNew::instance().sendRegionSettings(new_region_settings))
-	{
-		LL_WARNS() << "Error applying region environment settings" << LL_ENDL;
-		return;
-	}
-
-	// When the settings get applied, we'll also send the region sun position update.
-	// To determine the sun angle we're going to need the new settings.
-	mNewRegionSettings = new_region_settings;
-#endif
-
-	// Start spinning the progress indicator.
-	setApplyProgress(true);
-}
-
-void LLPanelEnvironmentInfo::onBtnCancel()
-{
-	// Reload last saved region settings.
-	refresh();
-
-#if 0
-    LLEnvironment::instance().applyChosenEnvironment();
-	// Apply them.
-	LLEnvManagerNew& env_mgr = LLEnvManagerNew::instance();
-	const LLEnvironmentSettings& cur_settings = env_mgr.getRegionSettings();
-	const LLSD& region_day_cycle = cur_settings.getWLDayCycle();
-	const LLSD& region_water = cur_settings.getWaterParams();
-	env_mgr.useWaterParams(region_water);
-	env_mgr.useDayCycleParams(region_day_cycle, LLEnvKey::SCOPE_REGION);
-#endif
-}
-
-void LLPanelEnvironmentInfo::onRegionSettingschange()
-{
-	LL_DEBUGS("Windlight") << "Region settings changed, refreshing" << LL_ENDL;
-	refresh();
-
-	// Stop applying progress indicator (it may be running if it's us who initiated settings update).
-	setApplyProgress(false);
-}
-
-void LLPanelEnvironmentInfo::onRegionSettingsApplied(bool ok)
-{
-	// If applying new settings has failed, stop the indicator right away.
-	// Otherwise it will be stopped when we receive the updated settings from server.
-	if (ok)
-	{
-		// Set the region sun phase/flags according to the chosen new preferences.
-		//
-		// If we do this earlier we may get jerky transition from fixed sky to a day cycle (STORM-1481).
-		// That is caused by the simulator re-sending the region info, which in turn makes us
-		// re-request and display old region environment settings while the new ones haven't been applied yet.
-		sendRegionSunUpdate();
-
-		// Switch estate to not using fixed sun for the region day cycle to work properly (STORM-1506).
-		fixEstateSun();
-	}
-	else
-	{
-		setApplyProgress(false);
-
-		// We need to re-request environment setting here,
-		// otherwise our subsequent attempts to change region settings will fail with the following error:
-		// "Unable to update environment settings because the last update your viewer saw was not the same
-		// as the last update sent from the simulator.  Try sending your update again, and if this
-		// does not work, try leaving and returning to the region."
-//		LLEnvManagerNew::instance().requestRegionSettings();
-	}
-}
-
 BOOL LLPanelRegionExperiences::postBuild()
 {
 	mAllowed = setupList("panel_allowed", ESTATE_EXPERIENCE_ALLOWED_ADD, ESTATE_EXPERIENCE_ALLOWED_REMOVE);
@@ -3965,3 +3343,43 @@ void LLPanelRegionExperiences::itemChanged( U32 event_type, const LLUUID& id )
 
 	onChangeAnything();
 }
+
+//=========================================================================
+class LLPanelRegionEnvironment : public LLPanelEnvironmentInfo
+{
+public:
+    LLPanelRegionEnvironment();
+
+    void refresh();
+
+    bool refreshFromRegion(LLViewerRegion* region);
+
+private:
+    LLViewerRegion * mLastRegion;
+};
+
+LLPanelRegionEnvironment::LLPanelRegionEnvironment():
+    LLPanelEnvironmentInfo(),
+    mLastRegion(NULL)
+{
+}
+
+void LLPanelRegionEnvironment::refresh()
+{
+    refreshFromRegion(mLastRegion);
+}
+
+bool LLPanelRegionEnvironment::refreshFromRegion(LLViewerRegion* region)
+{
+    BOOL owner_or_god = gAgent.isGodlike() || (region && (region->getOwner() == gAgent.getID()));
+    BOOL owner_or_god_or_manager = owner_or_god || (region && region->isEstateManager());
+
+    mDayLengthSlider->setValue(region->getDayLength().value());
+    mDayOffsetSlider->setValue(region->getDayOffset().value());
+
+    
+
+    setControlsEnabled(owner_or_god_or_manager);
+    mLastRegion = region;
+    return true;
+}
diff --git a/indra/newview/llfloaterregioninfo.h b/indra/newview/llfloaterregioninfo.h
index bbdff84bf6a7922a42707796abc402806ccb45e0..61bf33af2ff69d018852186b8e218b5cea68343a 100644
--- a/indra/newview/llfloaterregioninfo.h
+++ b/indra/newview/llfloaterregioninfo.h
@@ -34,6 +34,7 @@
 #include "llhost.h"
 #include "llpanel.h"
 #include "llextendedstatus.h"
+#include "llpanelenvironment.h"
 
 #include "lleventcoro.h"
 
@@ -63,6 +64,7 @@ class LLPanelEstateCovenant;
 class LLPanelExperienceListEditor;
 class LLPanelExperiences;
 class LLPanelRegionExperiences;
+class LLPanelRegionEnvironment;
 
 class LLEventTimer;
 
@@ -115,6 +117,7 @@ class LLFloaterRegionInfo : public LLFloater
 	LLTabContainer* mTab;
 	typedef std::vector<LLPanelRegionInfo*> info_panels_t;
 	info_panels_t mInfoPanels;
+    LLPanelRegionEnvironment *mEnvironmentPanel;
 	//static S32 sRequestSerial;	// serial # of last EstateOwnerRequest
 	static LLUUID sRequestInvoice;
 };
@@ -409,6 +412,7 @@ class LLPanelEstateCovenant : public LLPanelRegionInfo
 
 /////////////////////////////////////////////////////////////////////////////
 
+#if 0
 class LLPanelEnvironmentInfo : public LLPanelRegionInfo
 {
 	LOG_CLASS(LLPanelEnvironmentInfo);
@@ -468,10 +472,11 @@ class LLPanelEnvironmentInfo : public LLPanelRegionInfo
 	LLComboBox*		mSkyPresetCombo;
 	LLComboBox*		mDayCyclePresetCombo;
 };
+#endif
 
 class LLPanelRegionExperiences : public LLPanelRegionInfo
 {
-	LOG_CLASS(LLPanelEnvironmentInfo);
+    LOG_CLASS(LLPanelRegionExperiences);
 
 public:
 	LLPanelRegionExperiences(){}
diff --git a/indra/newview/llviewerregion.cpp b/indra/newview/llviewerregion.cpp
index 81be645c6abb06aaa376ffe2ba6f796224d6c57f..1dda516ca4d5ea3b23b1a81a5cfa8a6de6c121dc 100644
--- a/indra/newview/llviewerregion.cpp
+++ b/indra/newview/llviewerregion.cpp
@@ -78,6 +78,7 @@
 #include "llcoros.h"
 #include "lleventcoro.h"
 #include "llcorehttputil.h"
+#include "llsettingsdaycycle.h"
 
 #ifdef LL_WINDOWS
 	#pragma warning(disable:4355)
@@ -534,7 +535,9 @@ LLViewerRegion::LLViewerRegion(const U64 &handle,
 	mInvisibilityCheckHistory(-1),
 	mPaused(FALSE),
 	mRegionCacheHitCount(0),
-	mRegionCacheMissCount(0)
+	mRegionCacheMissCount(0),
+    mDayLength(LLSettingsDay::DEFAULT_DAYLENGTH),
+    mDayOffset(LLSettingsDay::DEFAULT_DAYOFFSET)
 {
 	mWidth = region_width_meters;
 	mImpl->mOriginGlobal = from_region_handle(handle); 
diff --git a/indra/newview/llviewerregion.h b/indra/newview/llviewerregion.h
index 69fb9c4d4e41d04bf83cac38e7492cc07ecbe8d5..fef78e29a99308d1f47a6fe36e5639cac3dfb73f 100644
--- a/indra/newview/llviewerregion.h
+++ b/indra/newview/llviewerregion.h
@@ -42,6 +42,8 @@
 #include "m4math.h"					// LLMatrix4
 #include "llframetimer.h"
 
+#include "llsettingsdaycycle.h"
+
 // Surface id's
 #define LAND  1
 #define WATER 2
@@ -71,320 +73,331 @@ class LLViewerRegionImpl;
 class LLViewerOctreeGroup;
 class LLVOCachePartition;
 
-class LLViewerRegion: public LLCapabilityProvider // implements this interface
+class LLViewerRegion : public LLCapabilityProvider // implements this interface
 {
 public:
-	//MUST MATCH THE ORDER OF DECLARATION IN CONSTRUCTOR
-	typedef enum 
-	{
-		PARTITION_HUD=0,
-		PARTITION_TERRAIN,
-		PARTITION_VOIDWATER,
-		PARTITION_WATER,
-		PARTITION_TREE,
-		PARTITION_PARTICLE,
-		PARTITION_GRASS,
-		PARTITION_VOLUME,
-		PARTITION_BRIDGE,
-		PARTITION_HUD_PARTICLE,
-		PARTITION_VO_CACHE,
-		PARTITION_NONE,
-		NUM_PARTITIONS
-	} eObjectPartitions;
-
-	typedef boost::signals2::signal<void(const LLUUID& region_id)> caps_received_signal_t;
-
-	LLViewerRegion(const U64 &handle,
-				   const LLHost &host,
-				   const U32 surface_grid_width,
-				   const U32 patch_grid_width,
-				   const F32 region_width_meters);
-	~LLViewerRegion();
-
-	// Call this after you have the region name and handle.
-	void loadObjectCache();
-	void saveObjectCache();
-
-	void sendMessage(); // Send the current message to this region's simulator
-	void sendReliableMessage(); // Send the current message to this region's simulator
-
-	void setOriginGlobal(const LLVector3d &origin);
-	//void setAgentOffset(const LLVector3d &offset);
-	void updateRenderMatrix();
-
-	void setAllowDamage(BOOL b) { setRegionFlag(REGION_FLAGS_ALLOW_DAMAGE, b); }
-	void setAllowLandmark(BOOL b) { setRegionFlag(REGION_FLAGS_ALLOW_LANDMARK, b); }
-	void setAllowSetHome(BOOL b) { setRegionFlag(REGION_FLAGS_ALLOW_SET_HOME, b); }
-	void setResetHomeOnTeleport(BOOL b) { setRegionFlag(REGION_FLAGS_RESET_HOME_ON_TELEPORT, b); }
-	void setSunFixed(BOOL b) { setRegionFlag(REGION_FLAGS_SUN_FIXED, b); }
-	//void setBlockFly(BOOL b) { setRegionFlag(REGION_FLAGS_BLOCK_FLY, b); }		Never used
-	void setAllowDirectTeleport(BOOL b) { setRegionFlag(REGION_FLAGS_ALLOW_DIRECT_TELEPORT, b); }
-
-
-	inline BOOL getAllowDamage()			const;
-	inline BOOL getAllowLandmark()			const;
-	inline BOOL getAllowSetHome()			const;
-	inline BOOL getResetHomeOnTeleport()	const;
-	inline BOOL getSunFixed()				const;
-	inline BOOL getBlockFly()				const;
-	inline BOOL getAllowDirectTeleport()	const;
-	inline BOOL isPrelude()					const;
-	inline BOOL getAllowTerraform() 		const;
-	inline BOOL getRestrictPushObject()		const;
-	inline BOOL getReleaseNotesRequested()		const;
-
-	bool isAlive(); // can become false if circuit disconnects
-
-	void setWaterHeight(F32 water_level);
-	F32 getWaterHeight() const;
-
-	BOOL isVoiceEnabled() const;
-
-	void setBillableFactor(F32 billable_factor) { mBillableFactor = billable_factor; }
-	F32 getBillableFactor() 		const 	{ return mBillableFactor; }
-
-	// Maximum number of primitives allowed, regardless of object
-	// bonus factor.
-	U32 getMaxTasks() const { return mMaxTasks; }
-	void setMaxTasks(U32 max_tasks) { mMaxTasks = max_tasks; }
-
-	// Draw lines in the dirt showing ownership. Return number of 
-	// vertices drawn.
-	S32 renderPropertyLines();
-
-	// Call this whenever you change the height data in the region.
-	// (Automatically called by LLSurfacePatch's update routine)
-	void dirtyHeights();
-
-	LLViewerParcelOverlay *getParcelOverlay() const
-			{ return mParcelOverlay; }
-
-	inline void setRegionFlag(U64 flag, BOOL on);
-	inline BOOL getRegionFlag(U64 flag) const;
-	void setRegionFlags(U64 flags);
-	U64 getRegionFlags() const					{ return mRegionFlags; }
-
-	inline void setRegionProtocol(U64 protocol, BOOL on);
-	BOOL getRegionProtocol(U64 protocol) const;
-	void setRegionProtocols(U64 protocols)			{ mRegionProtocols = protocols; }
-	U64 getRegionProtocols() const					{ return mRegionProtocols; }
-
-	void setTimeDilation(F32 time_dilation);
-	F32  getTimeDilation() const				{ return mTimeDilation; }
-
-	// Origin height is at zero.
-	const LLVector3d &getOriginGlobal() const;
-	LLVector3 getOriginAgent() const;
-
-	// Center is at the height of the water table.
-	const LLVector3d &getCenterGlobal() const;
-	LLVector3 getCenterAgent() const;
-
-	void setRegionNameAndZone(const std::string& name_and_zone);
-	const std::string& getName() const				{ return mName; }
-	const std::string& getZoning() const			{ return mZoning; }
-
-	void setOwner(const LLUUID& owner_id);
-	const LLUUID& getOwner() const;
-
-	// Is the current agent on the estate manager list for this region?
-	void setIsEstateManager(BOOL b) { mIsEstateManager = b; }
-	BOOL isEstateManager() const { return mIsEstateManager; }
-	BOOL canManageEstate() const;
-
-	void setSimAccess(U8 sim_access)			{ mSimAccess = sim_access; }
-	U8 getSimAccess() const						{ return mSimAccess; }
-	const std::string getSimAccessString() const;
-	
-	// Homestead-related getters; there are no setters as nobody should be
-	// setting them other than the individual message handler which is a member
-	S32 getSimClassID()                    const { return mClassID; }
-	S32 getSimCPURatio()                   const { return mCPURatio; }
-	const std::string& getSimColoName()    const { return mColoName; }
-	const std::string& getSimProductSKU()  const { return mProductSKU; }
-	std::string getLocalizedSimProductName() const;
-
-	// Returns "Sandbox", "Expensive", etc.
-	static std::string regionFlagsToString(U64 flags);
-
-	// Returns translated version of "Mature", "PG", "Adult", etc.
-	static std::string accessToString(U8 sim_access);
-
-	// Returns "M", "PG", "A" etc.
-	static std::string accessToShortString(U8 sim_access);
-	static U8          shortStringToAccess(const std::string &sim_access);
-
-	// Return access icon name
-	static std::string getAccessIcon(U8 sim_access);
-	
-	// helper function which just makes sure all interested parties
-	// can process the message.
-	static void processRegionInfo(LLMessageSystem* msg, void**);
+    //MUST MATCH THE ORDER OF DECLARATION IN CONSTRUCTOR
+    typedef enum
+    {
+        PARTITION_HUD = 0,
+        PARTITION_TERRAIN,
+        PARTITION_VOIDWATER,
+        PARTITION_WATER,
+        PARTITION_TREE,
+        PARTITION_PARTICLE,
+        PARTITION_GRASS,
+        PARTITION_VOLUME,
+        PARTITION_BRIDGE,
+        PARTITION_HUD_PARTICLE,
+        PARTITION_VO_CACHE,
+        PARTITION_NONE,
+        NUM_PARTITIONS
+    } eObjectPartitions;
+
+    typedef boost::signals2::signal<void(const LLUUID& region_id)> caps_received_signal_t;
+
+    LLViewerRegion(const U64 &handle,
+        const LLHost &host,
+        const U32 surface_grid_width,
+        const U32 patch_grid_width,
+        const F32 region_width_meters);
+    ~LLViewerRegion();
+
+    // Call this after you have the region name and handle.
+    void loadObjectCache();
+    void saveObjectCache();
+
+    void sendMessage(); // Send the current message to this region's simulator
+    void sendReliableMessage(); // Send the current message to this region's simulator
+
+    void setOriginGlobal(const LLVector3d &origin);
+    //void setAgentOffset(const LLVector3d &offset);
+    void updateRenderMatrix();
+
+    void setAllowDamage(BOOL b) { setRegionFlag(REGION_FLAGS_ALLOW_DAMAGE, b); }
+    void setAllowLandmark(BOOL b) { setRegionFlag(REGION_FLAGS_ALLOW_LANDMARK, b); }
+    void setAllowSetHome(BOOL b) { setRegionFlag(REGION_FLAGS_ALLOW_SET_HOME, b); }
+    void setResetHomeOnTeleport(BOOL b) { setRegionFlag(REGION_FLAGS_RESET_HOME_ON_TELEPORT, b); }
+    void setSunFixed(BOOL b) { setRegionFlag(REGION_FLAGS_SUN_FIXED, b); }
+    //void setBlockFly(BOOL b) { setRegionFlag(REGION_FLAGS_BLOCK_FLY, b); }		Never used
+    void setAllowDirectTeleport(BOOL b) { setRegionFlag(REGION_FLAGS_ALLOW_DIRECT_TELEPORT, b); }
+
+
+    inline BOOL getAllowDamage()			const;
+    inline BOOL getAllowLandmark()			const;
+    inline BOOL getAllowSetHome()			const;
+    inline BOOL getResetHomeOnTeleport()	const;
+    inline BOOL getSunFixed()				const;
+    inline BOOL getBlockFly()				const;
+    inline BOOL getAllowDirectTeleport()	const;
+    inline BOOL isPrelude()					const;
+    inline BOOL getAllowTerraform() 		const;
+    inline BOOL getRestrictPushObject()		const;
+    inline BOOL getReleaseNotesRequested()		const;
+
+    bool isAlive(); // can become false if circuit disconnects
+
+    void setWaterHeight(F32 water_level);
+    F32 getWaterHeight() const;
+
+    BOOL isVoiceEnabled() const;
+
+    void setBillableFactor(F32 billable_factor) { mBillableFactor = billable_factor; }
+    F32 getBillableFactor() 		const 	{ return mBillableFactor; }
+
+    // Maximum number of primitives allowed, regardless of object
+    // bonus factor.
+    U32 getMaxTasks() const { return mMaxTasks; }
+    void setMaxTasks(U32 max_tasks) { mMaxTasks = max_tasks; }
+
+    // Draw lines in the dirt showing ownership. Return number of 
+    // vertices drawn.
+    S32 renderPropertyLines();
+
+    // Call this whenever you change the height data in the region.
+    // (Automatically called by LLSurfacePatch's update routine)
+    void dirtyHeights();
+
+    LLViewerParcelOverlay *getParcelOverlay() const
+    {
+        return mParcelOverlay;
+    }
+
+    inline void setRegionFlag(U64 flag, BOOL on);
+    inline BOOL getRegionFlag(U64 flag) const;
+    void setRegionFlags(U64 flags);
+    U64 getRegionFlags() const					{ return mRegionFlags; }
+
+    inline void setRegionProtocol(U64 protocol, BOOL on);
+    BOOL getRegionProtocol(U64 protocol) const;
+    void setRegionProtocols(U64 protocols)			{ mRegionProtocols = protocols; }
+    U64 getRegionProtocols() const					{ return mRegionProtocols; }
+
+    void setTimeDilation(F32 time_dilation);
+    F32  getTimeDilation() const				{ return mTimeDilation; }
+
+    // Origin height is at zero.
+    const LLVector3d &getOriginGlobal() const;
+    LLVector3 getOriginAgent() const;
+
+    // Center is at the height of the water table.
+    const LLVector3d &getCenterGlobal() const;
+    LLVector3 getCenterAgent() const;
+
+    void setRegionNameAndZone(const std::string& name_and_zone);
+    const std::string& getName() const				{ return mName; }
+    const std::string& getZoning() const			{ return mZoning; }
+
+    void setOwner(const LLUUID& owner_id);
+    const LLUUID& getOwner() const;
+
+    // Is the current agent on the estate manager list for this region?
+    void setIsEstateManager(BOOL b) { mIsEstateManager = b; }
+    BOOL isEstateManager() const { return mIsEstateManager; }
+    BOOL canManageEstate() const;
+
+    void setSimAccess(U8 sim_access)			{ mSimAccess = sim_access; }
+    U8 getSimAccess() const						{ return mSimAccess; }
+    const std::string getSimAccessString() const;
+
+    // Homestead-related getters; there are no setters as nobody should be
+    // setting them other than the individual message handler which is a member
+    S32 getSimClassID()                    const { return mClassID; }
+    S32 getSimCPURatio()                   const { return mCPURatio; }
+    const std::string& getSimColoName()    const { return mColoName; }
+    const std::string& getSimProductSKU()  const { return mProductSKU; }
+    std::string getLocalizedSimProductName() const;
+
+    // Returns "Sandbox", "Expensive", etc.
+    static std::string regionFlagsToString(U64 flags);
+
+    // Returns translated version of "Mature", "PG", "Adult", etc.
+    static std::string accessToString(U8 sim_access);
+
+    // Returns "M", "PG", "A" etc.
+    static std::string accessToShortString(U8 sim_access);
+    static U8          shortStringToAccess(const std::string &sim_access);
+
+    // Return access icon name
+    static std::string getAccessIcon(U8 sim_access);
 
-	//check if the viewer camera is static
-	static BOOL isViewerCameraStatic();
-	static void calcNewObjectCreationThrottle();
+    // helper function which just makes sure all interested parties
+    // can process the message.
+    static void processRegionInfo(LLMessageSystem* msg, void**);
+
+    //check if the viewer camera is static
+    static BOOL isViewerCameraStatic();
+    static void calcNewObjectCreationThrottle();
 
-	void setCacheID(const LLUUID& id);
+    void setCacheID(const LLUUID& id);
 
-	F32	getWidth() const						{ return mWidth; }
+    F32	getWidth() const						{ return mWidth; }
 
-	void idleUpdate(F32 max_update_time);
-	void lightIdleUpdate();
-	bool addVisibleGroup(LLViewerOctreeGroup* group);
-	void addVisibleChildCacheEntry(LLVOCacheEntry* parent, LLVOCacheEntry* child);
-	void addActiveCacheEntry(LLVOCacheEntry* entry);
-	void removeActiveCacheEntry(LLVOCacheEntry* entry, LLDrawable* drawablep);	
-	void killCacheEntry(U32 local_id); //physically delete the cache entry	
+    void idleUpdate(F32 max_update_time);
+    void lightIdleUpdate();
+    bool addVisibleGroup(LLViewerOctreeGroup* group);
+    void addVisibleChildCacheEntry(LLVOCacheEntry* parent, LLVOCacheEntry* child);
+    void addActiveCacheEntry(LLVOCacheEntry* entry);
+    void removeActiveCacheEntry(LLVOCacheEntry* entry, LLDrawable* drawablep);
+    void killCacheEntry(U32 local_id); //physically delete the cache entry	
 
-	// Like idleUpdate, but forces everything to complete regardless of
-	// how long it takes.
-	void forceUpdate();
+    // Like idleUpdate, but forces everything to complete regardless of
+    // how long it takes.
+    void forceUpdate();
 
-	void connectNeighbor(LLViewerRegion *neighborp, U32 direction);
+    void connectNeighbor(LLViewerRegion *neighborp, U32 direction);
 
-	void updateNetStats();
+    void updateNetStats();
 
-	U32	getPacketsLost() const;
+    U32	getPacketsLost() const;
 
-	S32 getHttpResponderID() const;
+    S32 getHttpResponderID() const;
 
-	// Get/set named capability URLs for this region.
-	void setSeedCapability(const std::string& url);
-	S32 getNumSeedCapRetries();
-	void setCapability(const std::string& name, const std::string& url);
-	void setCapabilityDebug(const std::string& name, const std::string& url);
-	bool isCapabilityAvailable(const std::string& name) const;
-	// implements LLCapabilityProvider
+    // Get/set named capability URLs for this region.
+    void setSeedCapability(const std::string& url);
+    S32 getNumSeedCapRetries();
+    void setCapability(const std::string& name, const std::string& url);
+    void setCapabilityDebug(const std::string& name, const std::string& url);
+    bool isCapabilityAvailable(const std::string& name) const;
+    // implements LLCapabilityProvider
     virtual std::string getCapability(const std::string& name) const;
     std::string getCapabilityDebug(const std::string& name) const;
 
 
-	// has region received its final (not seed) capability list?
-	bool capabilitiesReceived() const;
-	void setCapabilitiesReceived(bool received);
-	boost::signals2::connection setCapabilitiesReceivedCallback(const caps_received_signal_t::slot_type& cb);
+    // has region received its final (not seed) capability list?
+    bool capabilitiesReceived() const;
+    void setCapabilitiesReceived(bool received);
+    boost::signals2::connection setCapabilitiesReceivedCallback(const caps_received_signal_t::slot_type& cb);
 
-	static bool isSpecialCapabilityName(const std::string &name);
-	void logActiveCapabilities() const;
+    static bool isSpecialCapabilityName(const std::string &name);
+    void logActiveCapabilities() const;
 
     /// implements LLCapabilityProvider
-	/*virtual*/ const LLHost& getHost() const;
-	const U64 		&getHandle() const 			{ return mHandle; }
+    /*virtual*/ const LLHost& getHost() const;
+    const U64 		&getHandle() const 			{ return mHandle; }
 
-	LLSurface		&getLand() const;
+    LLSurface		&getLand() const;
 
-	// set and get the region id
-	const LLUUID& getRegionID() const;
-	void setRegionID(const LLUUID& region_id);
+    // set and get the region id
+    const LLUUID& getRegionID() const;
+    void setRegionID(const LLUUID& region_id);
 
-	BOOL pointInRegionGlobal(const LLVector3d &point_global) const;
-	LLVector3	getPosRegionFromGlobal(const LLVector3d &point_global) const;
-	LLVector3	getPosRegionFromAgent(const LLVector3 &agent_pos) const;
-	LLVector3	getPosAgentFromRegion(const LLVector3 &region_pos) const;
-	LLVector3d	getPosGlobalFromRegion(const LLVector3 &offset) const;
+    BOOL pointInRegionGlobal(const LLVector3d &point_global) const;
+    LLVector3	getPosRegionFromGlobal(const LLVector3d &point_global) const;
+    LLVector3	getPosRegionFromAgent(const LLVector3 &agent_pos) const;
+    LLVector3	getPosAgentFromRegion(const LLVector3 &region_pos) const;
+    LLVector3d	getPosGlobalFromRegion(const LLVector3 &offset) const;
 
-	LLVLComposition *getComposition() const;
-	F32 getCompositionXY(const S32 x, const S32 y) const;
+    LLVLComposition *getComposition() const;
+    F32 getCompositionXY(const S32 x, const S32 y) const;
 
-	BOOL isOwnedSelf(const LLVector3& pos);
+    BOOL isOwnedSelf(const LLVector3& pos);
 
-	// Owned by a group you belong to?  (officer OR member)
-	BOOL isOwnedGroup(const LLVector3& pos);
+    // Owned by a group you belong to?  (officer OR member)
+    BOOL isOwnedGroup(const LLVector3& pos);
 
-	// deal with map object updates in the world.
-	void updateCoarseLocations(LLMessageSystem* msg);
+    // deal with map object updates in the world.
+    void updateCoarseLocations(LLMessageSystem* msg);
 
-	F32 getLandHeightRegion(const LLVector3& region_pos);
+    F32 getLandHeightRegion(const LLVector3& region_pos);
 
-	U8 getCentralBakeVersion() { return mCentralBakeVersion; }
+    U8 getCentralBakeVersion() { return mCentralBakeVersion; }
 
-	void getInfo(LLSD& info);
-	
-	bool meshRezEnabled() const;
-	bool meshUploadEnabled() const;
+    void getInfo(LLSD& info);
 
-	// has region received its simulator features list? Requires an additional query after caps received.
-	void setSimulatorFeaturesReceived(bool);
-	bool simulatorFeaturesReceived() const;
-	boost::signals2::connection setSimulatorFeaturesReceivedCallback(const caps_received_signal_t::slot_type& cb);
-	
-	void getSimulatorFeatures(LLSD& info) const;	
-	void setSimulatorFeatures(const LLSD& info);
+    bool meshRezEnabled() const;
+    bool meshUploadEnabled() const;
 
-	
-	bool dynamicPathfindingEnabled() const;
+    // has region received its simulator features list? Requires an additional query after caps received.
+    void setSimulatorFeaturesReceived(bool);
+    bool simulatorFeaturesReceived() const;
+    boost::signals2::connection setSimulatorFeaturesReceivedCallback(const caps_received_signal_t::slot_type& cb);
 
-	bool avatarHoverHeightEnabled() const;
+    void getSimulatorFeatures(LLSD& info) const;
+    void setSimulatorFeatures(const LLSD& info);
 
-	typedef enum
-	{
-		CACHE_MISS_TYPE_FULL = 0,
-		CACHE_MISS_TYPE_CRC,
-		CACHE_MISS_TYPE_NONE
-	} eCacheMissType;
 
-	typedef enum
-	{
-		CACHE_UPDATE_DUPE = 0,
-		CACHE_UPDATE_CHANGED,
-		CACHE_UPDATE_ADDED,
-		CACHE_UPDATE_REPLACED
-	} eCacheUpdateResult;
-
-	// handle a full update message
-	eCacheUpdateResult cacheFullUpdate(LLDataPackerBinaryBuffer &dp, U32 flags);
-	eCacheUpdateResult cacheFullUpdate(LLViewerObject* objectp, LLDataPackerBinaryBuffer &dp, U32 flags);	
-	LLVOCacheEntry* getCacheEntryForOctree(U32 local_id);
-	LLVOCacheEntry* getCacheEntry(U32 local_id, bool valid = true);
-	bool probeCache(U32 local_id, U32 crc, U32 flags, U8 &cache_miss_type);
-	U64 getRegionCacheHitCount() { return mRegionCacheHitCount; }
-	U64 getRegionCacheMissCount() { return mRegionCacheMissCount; }
-	void requestCacheMisses();
-	void addCacheMissFull(const U32 local_id);
-	//update object cache if the object receives a full-update or terse update
-	LLViewerObject* updateCacheEntry(U32 local_id, LLViewerObject* objectp, U32 update_type);
-	void findOrphans(U32 parent_id);
-	void clearCachedVisibleObjects();
-	void dumpCache();
-
-	void unpackRegionHandshake();
-
-	void calculateCenterGlobal();
-	void calculateCameraDistance();
-
-	friend std::ostream& operator<<(std::ostream &s, const LLViewerRegion &region);
+    bool dynamicPathfindingEnabled() const;
+
+    bool avatarHoverHeightEnabled() const;
+
+    typedef enum
+    {
+        CACHE_MISS_TYPE_FULL = 0,
+        CACHE_MISS_TYPE_CRC,
+        CACHE_MISS_TYPE_NONE
+    } eCacheMissType;
+
+    typedef enum
+    {
+        CACHE_UPDATE_DUPE = 0,
+        CACHE_UPDATE_CHANGED,
+        CACHE_UPDATE_ADDED,
+        CACHE_UPDATE_REPLACED
+    } eCacheUpdateResult;
+
+    // handle a full update message
+    eCacheUpdateResult cacheFullUpdate(LLDataPackerBinaryBuffer &dp, U32 flags);
+    eCacheUpdateResult cacheFullUpdate(LLViewerObject* objectp, LLDataPackerBinaryBuffer &dp, U32 flags);
+    LLVOCacheEntry* getCacheEntryForOctree(U32 local_id);
+    LLVOCacheEntry* getCacheEntry(U32 local_id, bool valid = true);
+    bool probeCache(U32 local_id, U32 crc, U32 flags, U8 &cache_miss_type);
+    U64 getRegionCacheHitCount() { return mRegionCacheHitCount; }
+    U64 getRegionCacheMissCount() { return mRegionCacheMissCount; }
+    void requestCacheMisses();
+    void addCacheMissFull(const U32 local_id);
+    //update object cache if the object receives a full-update or terse update
+    LLViewerObject* updateCacheEntry(U32 local_id, LLViewerObject* objectp, U32 update_type);
+    void findOrphans(U32 parent_id);
+    void clearCachedVisibleObjects();
+    void dumpCache();
+
+    void unpackRegionHandshake();
+
+    void calculateCenterGlobal();
+    void calculateCameraDistance();
+
+    friend std::ostream& operator<<(std::ostream &s, const LLViewerRegion &region);
     /// implements LLCapabilityProvider
     virtual std::string getDescription() const;
     std::string getViewerAssetUrl() const { return mViewerAssetUrl; }
 
-	U32 getNumOfVisibleGroups() const;
-	U32 getNumOfActiveCachedObjects() const;
-	LLSpatialPartition* getSpatialPartition(U32 type);
-	LLVOCachePartition* getVOCachePartition();
+    U32 getNumOfVisibleGroups() const;
+    U32 getNumOfActiveCachedObjects() const;
+    LLSpatialPartition* getSpatialPartition(U32 type);
+    LLVOCachePartition* getVOCachePartition();
 
-	bool objectIsReturnable(const LLVector3& pos, const std::vector<LLBBox>& boxes) const;
-	bool childrenObjectReturnable( const std::vector<LLBBox>& boxes ) const;
-	bool objectsCrossParcel(const std::vector<LLBBox>& boxes) const;
+    bool objectIsReturnable(const LLVector3& pos, const std::vector<LLBBox>& boxes) const;
+    bool childrenObjectReturnable(const std::vector<LLBBox>& boxes) const;
+    bool objectsCrossParcel(const std::vector<LLBBox>& boxes) const;
 
-	void getNeighboringRegions( std::vector<LLViewerRegion*>& uniqueRegions );
-	void getNeighboringRegionsStatus( std::vector<S32>& regions );
-	const LLViewerRegionImpl * getRegionImpl() const { return mImpl; }
-	LLViewerRegionImpl * getRegionImplNC() { return mImpl; }
+    void getNeighboringRegions(std::vector<LLViewerRegion*>& uniqueRegions);
+    void getNeighboringRegionsStatus(std::vector<S32>& regions);
+    const LLViewerRegionImpl * getRegionImpl() const { return mImpl; }
+    LLViewerRegionImpl * getRegionImplNC() { return mImpl; }
 
-	// implements the materials capability throttle
-	bool materialsCapThrottled() const { return !mMaterialsCapThrottleTimer.hasExpired(); }
-	void resetMaterialsCapThrottle();
-	
-	U32 getMaxMaterialsPerTransaction() const;
+    // implements the materials capability throttle
+    bool materialsCapThrottled() const { return !mMaterialsCapThrottleTimer.hasExpired(); }
+    void resetMaterialsCapThrottle();
+
+    U32 getMaxMaterialsPerTransaction() const;
 
-	void removeFromCreatedList(U32 local_id);
-	void addToCreatedList(U32 local_id);	
+    void removeFromCreatedList(U32 local_id);
+    void addToCreatedList(U32 local_id);
 
-	BOOL isPaused() const {return mPaused;}
-	S32  getLastUpdate() const {return mLastUpdate;}
+    BOOL isPaused() const { return mPaused; }
+    S32  getLastUpdate() const { return mLastUpdate; }
 
-	static BOOL isNewObjectCreationThrottleDisabled() {return sNewObjectCreationThrottle < 0;}
+    static BOOL isNewObjectCreationThrottleDisabled() { return sNewObjectCreationThrottle < 0; }
+
+    S64Seconds getDayLength() const { return mDayLength; }
+    void setDayLength(S64SecondsImplicit seconds) { mDayLength = seconds; }
+    S64Seconds getDayOffset() const { return mDayOffset; }
+    void setDayOffset(S64SecondsImplicit seconds) { mDayOffset = seconds; }
+    bool getIsDefaultDayCycle() const { return mIsDefaultDayCycle; }
+    void setIsDefaultDayCycle(bool isdefault) { mIsDefaultDayCycle = isdefault; }
+    LLSettingsDay::ptr_t getRegionDayCycle() const { return mDayCycle; }
+    void setRegionDayCycle(const LLSettingsDay::ptr_t &pday) { mDayCycle = pday; }
 
 private:
 	void addToVOCacheTree(LLVOCacheEntry* entry);
@@ -525,6 +538,11 @@ class LLViewerRegion: public LLCapabilityProvider // implements this interface
 	typedef std::map<U32, std::vector<U32> > orphan_list_t;
 	orphan_list_t mOrphanMap;
 
+    S64Seconds            mDayLength;
+    S64Seconds            mDayOffset;
+    bool                  mIsDefaultDayCycle;
+    LLSettingsDay::ptr_t  mDayCycle;
+
 	class CacheMissItem
 	{
 	public:
diff --git a/indra/newview/skins/default/xui/en/floater_about_land.xml b/indra/newview/skins/default/xui/en/floater_about_land.xml
index 535af317d991f072f4f72567655aa0fa09c2fd54..334de8e3dbf4a1528720ecf0e9dac10c0e082ac0 100644
--- a/indra/newview/skins/default/xui/en/floater_about_land.xml
+++ b/indra/newview/skins/default/xui/en/floater_about_land.xml
@@ -2109,5 +2109,17 @@ Only large parcels can be listed in search.
             class="land_experiences_panel"
           filename="panel_region_experiences.xml">
        </panel>
+       <panel
+          border="true"
+          follows="all"
+          label="ENVIRONMENT"
+          layout="topleft"
+          left="0"
+          top="0"
+          help_topic="land_environment_tab"
+          name="land_environment_panel"
+            class="land_environment_panel"
+          filename="panel_region_environment.xml">
+       </panel>
     </tab_container>
 </floater>
diff --git a/indra/newview/skins/default/xui/en/floater_test_layout_stacks.xml b/indra/newview/skins/default/xui/en/floater_test_layout_stacks.xml
index a04050e7eb7987c5b30ccc65c44a66ea999ab07e..82ad031959fedc22f569c2ecba692ab0c9ad22c7 100644
--- a/indra/newview/skins/default/xui/en/floater_test_layout_stacks.xml
+++ b/indra/newview/skins/default/xui/en/floater_test_layout_stacks.xml
@@ -1,226 +1,181 @@
 <?xml version="1.0" encoding="utf-8" standalone="yes" ?>
 <floater
- can_resize="true"
- can_close="true"
- bevel_style="in"
- height="300"
- layout="topleft"
- min_height="40"
- min_width="420"
- name="Test Floater"
- title="LAYOUTSTACK TESTS"
- width="420">
-  <layout_stack name="test_stack"
-              left="0"
-              top="0"
-              width="100"
-              height="250"
-              follows="left|top|bottom"
-              orientation="vertical">
-    <layout_panel name="flex"
-                  auto_resize="true"
-                  user_resize="true"
-                  bg_alpha_color="blue"
-                  height="11"
-                  min_height="0"
-                  background_visible="true">
-      <text follows="top|left|right" halign="center" text_color="white">flex</text>
-    </layout_panel>
-    <layout_panel name="flex"
-                  auto_resize="true"
-                  user_resize="true"
-                  bg_alpha_color="blue"
-                  height="11"
-                  min_height="0"
-                  visible="false"
-                  background_visible="true">
-      <text follows="top|left|right" halign="center" text_color="white">flex</text>
-    </layout_panel>
-    <layout_panel name="flex"
-                  auto_resize="true"
-                  user_resize="true"
-                  bg_alpha_color="blue"
-                  height="11"
-                  min_height="0"
-                  visible="true"
-                  background_visible="true">
-      <text follows="top|left|right" halign="center" text_color="white">flex</text>
-    </layout_panel>
-    <layout_panel name="flex"
-                  auto_resize="true"
-                  user_resize="true"
-                  bg_alpha_color="blue"
-                  height="11"
-                  min_height="0"
-                  background_visible="true">
-      <text follows="top|left|right" halign="center" text_color="white">flex</text>
-    </layout_panel>
-  </layout_stack>
-  <layout_stack name="test_stack"
-              left_pad="5"
-              top="0"
-              width="100"
-              height="250"
-              follows="left|top|bottom"
-              orientation="vertical">
-    <layout_panel name="flex"
-                  auto_resize="true"
-                  user_resize="true"
-                  bg_alpha_color="blue"
-                  height="100"
-                  background_visible="true">
-      <text follows="top|left|right" halign="center" text_color="white">flex</text>
-    </layout_panel>
-    <layout_panel name="flex"
-                  auto_resize="true"
-                  user_resize="true"
-                  visible="false"
-                  bg_alpha_color="blue"
-                  height="100"
-                  background_visible="true">
-      <text follows="top|left|right" halign="center" text_color="white">flex</text>
-    </layout_panel>
-    <layout_panel name="fixed"
-                  auto_resize="false"
-                  user_resize="true"
-                  height="50"
-                  min_height="10"
-                  bg_alpha_color="green"
-                  background_visible="true">
-      <text follows="top|left|right" halign="center" text_color="black">fixed</text>
-    </layout_panel>
-    <layout_panel name="fixed"
-                auto_resize="false"
-                  user_resize="true"
-                height="50"
-                min_height="10"
-                bg_alpha_color="green"
-                background_visible="true">
-      <text follows="top|left|right" halign="center" text_color="black">fixed</text>
-    </layout_panel>
-    <layout_panel name="flex"
-                  auto_resize="true"
-                  user_resize="true"
-                  bg_alpha_color="blue"
-                  height="100"
-                  background_visible="true">
-      <text follows="top|left|right" halign="center" text_color="white">flex</text>
-    </layout_panel>
-    <layout_panel name="flex"
-                  auto_resize="true"
-                  user_resize="true"
-                  bg_alpha_color="blue"
-                  height="100"
-                  background_visible="true">
-      <text follows="top|left|right" halign="center" text_color="white">flex</text>
-    </layout_panel>
-    <layout_panel name="flex"
-                  auto_resize="true"
-                  user_resize="true"
-                  bg_alpha_color="blue"
-                  height="100"
-                  background_visible="true">
-      <text follows="top|left|right" halign="center" text_color="white">flex</text>
-    </layout_panel>
-    <layout_panel name="flex"
-                  auto_resize="true"
-                  user_resize="true"
-                  bg_alpha_color="blue"
-                  height="100"
-                  visible="true"
-                  background_visible="true">
-      <text follows="top|left|right" halign="center" text_color="white">flex</text>
-    </layout_panel>
-  </layout_stack>
-  <layout_stack name="test_stack"
-               left_pad="5"
-               top="0"
-               width="100"
-               height="250"
-               follows="left|top|bottom"
-               orientation="vertical">
-    <layout_panel name="flex"
-                  auto_resize="true"
-                  user_resize="true"
-                  height="11"
-                  bg_alpha_color="blue"
-                  background_visible="true">
-      <text follows="top|left|right" halign="center" text_color="white">flex</text>
-    </layout_panel>
-    <layout_panel name="fixed"
-                auto_resize="false"
-                  user_resize="true"
-                height="50"
-                bg_alpha_color="green"
-                background_visible="true">
-      <text follows="top|left|right" halign="center" text_color="black">fixed</text>
-    </layout_panel>
-    <layout_panel name="flex"
-                  auto_resize="true"
-                  user_resize="true"
-                  bg_alpha_color="blue"
-                  height="11"
-                  background_visible="true">
-      <text follows="top|left|right" halign="center" text_color="white">flex</text>
-    </layout_panel>
-  </layout_stack>
-  <layout_stack name="test_stack"
-               left_pad="5"
-               top="0"
-               width="100"
-               height="250"
-               follows="left|top|bottom"
-               orientation="vertical">
-    <layout_panel name="fixed"
-                auto_resize="false"
-                  user_resize="true"
-                height="50"
-                bg_alpha_color="green"
-                background_visible="true">
-      <text follows="top|left|right" halign="center" text_color="black">fixed</text>
-    </layout_panel>
-    <layout_panel name="fixed"
-                auto_resize="false"
-                  user_resize="true"
-                height="50"
-                bg_alpha_color="green"
-                background_visible="true">
-      <text follows="top|left|right" halign="center" text_color="black">fixed</text>
-    </layout_panel>
-    <layout_panel name="fixed"
-                auto_resize="false"
-                  user_resize="true"
-                height="50"
-                bg_alpha_color="green"
-                background_visible="true">
-      <text follows="top|left|right" halign="center" text_color="black">fixed</text>
-    </layout_panel>
-    <layout_panel name="flex"
-                  auto_resize="true"
-                  user_resize="true"
-                  bg_alpha_color="blue"
-                  height="11"
-                  min_height="0"
-                  background_visible="true">
-      <text follows="top|left|right" halign="center" text_color="white">flex</text>
-    </layout_panel>
-    <layout_panel name="flex"
-                  auto_resize="true"
-                  user_resize="true"
-                  bg_alpha_color="blue"
-                  height="11"
-                  min_height="0"
-                  background_visible="true">
-      <text follows="top|left|right" halign="center" text_color="white">flex</text>
-    </layout_panel>
-    <layout_panel name="flex"
-                  auto_resize="true"
-                  user_resize="true"
-                  bg_alpha_color="blue"
-                  height="11"
-                  min_height="0"
-                  background_visible="true">
-      <text follows="top|left|right" halign="center" text_color="white">flex</text>
-    </layout_panel>
-  </layout_stack>
+        can_resize="true"
+        can_close="true"
+        bevel_style="in"
+        height="300"
+        layout="topleft"
+        min_height="40"
+        min_width="420"
+        name="Test Floater"
+        title="LAYOUTSTACK TESTS"
+        width="420">
+    <layout_stack 
+            left="0"
+            top="0"
+            width="420"
+            height="250"
+            follows="left|right|top|bottom"
+            orientation="vertical">
+        <layout_panel 
+                auto_resize="true"
+                user_resize="true"
+                bg_alpha_color="red"
+                max_height="200"
+                background_visible="false">
+            <layout_stack 
+                    left="5"
+                    top="5"
+                    right="-5"
+                    follows="left|right|top|bottom"
+                    orientation="horizontal">
+                <layout_panel 
+                        border="true"
+                        bevel_style="in"
+                        auto_resize="false"
+                        user_resize="false"
+                        width="160"
+                        background_visible="true">
+                    <text follows="top|left"
+                            halign="left"
+                            text_color="white">Environment Source</text>
+                    <radio_group
+                            follows="top|left"
+                            height="45"
+                            layout="topleft"
+                            left_delta="10"
+                            name="environment_select_radio_group"
+                            bottom_delta="50"
+                            max_width="200"
+                            width="200">
+                        <radio_item
+                                label="Default Environment"
+                                layout="topleft"
+                                name="use_default_setting"
+                                height="20"/>
+                        <radio_item
+                                label="Custom Environment"
+                                layout="topleft"
+                                height="20"
+                                name="use_custom_setting"/>
+                    </radio_group>
+                    <button
+                            follows="top|left"
+                            height="23"
+                            label="Edit Custom"
+                            left_delta="30"
+                            bottom_delta="30"
+                            width="100"
+                            name="edit_btn"/>
+
+                </layout_panel>
+                <layout_panel 
+                        border="true"
+                        bevel_style="in"
+                        auto_resize="false"
+                        user_resize="true"
+                        height="11"
+                        width="220"
+                        background_visible="true">
+                    <text follows="top|left|right"
+                            halign="left"
+                            text_color="white">Day Settings</text>
+                    <text
+                            type="string"
+                            length="1"
+                            follows="left|top"
+                            height="12"
+                            layout="topleft"
+                            left_delta="10"
+                            top_pad="10"
+                            width="200">
+                        Day Length (hours)
+                    </text>
+                    <slider
+                            can_edit_text="true"
+                            control_name="DayLengthSLD"
+                            decimal_digits="1"
+                            follows="left|top"
+                            height="20"
+                            increment="0.5"
+                            initial_value="4"
+                            layout="topleft"
+                            left_delta="0"
+                            top_pad="6"
+                            name="day_length_sld"
+                            min_val="4"
+                            max_val="178"
+                            width="200" />
+                    <text
+                            type="string"
+                            length="1"
+                            follows="left|top"
+                            height="12"
+                            layout="topleft"
+                            left_delta="0"
+                            top_pad="10"
+                            width="200">
+                        Day Offset (hours)
+                    </text>
+                    <slider
+                            can_edit_text="true"
+                            control_name="DayOffsetSLD"
+                            decimal_digits="1"
+                            follows="left|top"
+                            height="20"
+                            increment="0.5"
+                            initial_value="-8"
+                            layout="topleft"
+                            left_delta="0"
+                            top_pad="6"
+                            name="day_offset_sld"
+                            min_val="-12"
+                            max_val="12"
+                            width="200" />
+
+                </layout_panel>
+                <layout_panel name="flex"
+                        auto_resize="true"
+                        user_resize="true"
+                        visible="false"
+                        bg_alpha_color="blue"
+                        height="100"
+                        background_visible="true">
+                </layout_panel>
+            </layout_stack>
+        </layout_panel>
+        <layout_panel name="flex"
+                auto_resize="true"
+                user_resize="true"
+                height="11"
+                min_height="0"
+                background_visible="false">
+    <check_box
+        control_name="may_override_chk"
+        height="16"
+        label="Parcel Owners May Override"
+        layout="topleft"
+        left="10"
+        top="10"
+        name="allow_override_chk"
+        width="200" />
+    <button
+        follows="bottom|left"
+        height="23"
+        label="Apply"
+        right="-160"
+        bottom="-30"
+        name="apply_btn"
+        width="100" />
+    <button
+        follows="bottom|left"
+        height="23"
+        label="Cancel"
+        layout="topleft"
+        left_pad="10"
+        name="cancel_btn"
+        width="100" /> 
+                
+        </layout_panel>
+    </layout_stack>
 </floater>
diff --git a/indra/newview/skins/default/xui/en/panel_region_environment.xml b/indra/newview/skins/default/xui/en/panel_region_environment.xml
index aa38c49fae13d65d6b297ae0e621cb69ba64666d..a11b9b2d8b95dc25817c87957a208847a5610030 100644
--- a/indra/newview/skins/default/xui/en/panel_region_environment.xml
+++ b/indra/newview/skins/default/xui/en/panel_region_environment.xml
@@ -1,149 +1,180 @@
 <?xml version="1.0" encoding="utf-8" standalone="yes" ?>
 
 <panel
- border="true"
- follows="top|left"
- height="300"
- label="Environment"
- layout="topleft"
- help_topic="panel_region_environment_tab"
- name="panel_env_info"
- width="530"> 
- <text
-  name="water_settings_title"
-  follows="top|left"
-  height="30"
-  layout="topleft"
-  left="50"
-  top_pad="20"
-  width="430"
-  wrap="true">
-  Select the Water and Sky/Day Cycle Settings you would like all visitors to your region to see.  More info
- </text> 
- <view_border
-  bevel_style="none"
-  follows="top|left"
-  height="237"
-  layout="topleft"
-  left="50"
-  name="border"
-  top="60"
-  width="430"/>
- <radio_group
-  follows="top|left"
-  height="45"
-  layout="topleft"
-  left_delta="10"
-  name="region_settings_radio_group"
-  top_delta="20"
-  width="200">
-  <radio_item
-   label="Use Second Life default"
-   layout="topleft"
-   name="use_sl_default_settings"/>
-  <radio_item
-   label="Use the following settings"
-   layout="topleft"
-   name="use_my_settings"
-   top_pad="20"/>
-  </radio_group>
- <panel
-  follows="top|left"
-  height="150"
-  layout="topleft"
-  left="50"
-  name="user_environment_settings"
-  top_pad="20"
-  width="430">
-   <text
-    name="water_settings_title"
+    border="true"
     follows="top|left"
-    height="16"
+    height="300"
+    label="Environment"
     layout="topleft"
-    left="50"
-    top_pad="0"
-    width="160">
-    Water Setting
-   </text>
-   <combo_box
-    follows="top|left"
-    left_pad="2"
-    name="water_settings_preset_combo"
-    top_delta="-7"
-    width="200">
-    <combo_box.item
-     label="-Select a preset-"
-     name="item0"/>
-   </combo_box>
-   <text
-    name="sky_dayc_settings_title"
-    follows="top|left"
-    height="16"
-    layout="topleft"
-    left="50"
-    top_pad="30"
-    width="100">
-    Sky / Day Cycle
-   </text>
-   <radio_group
-    layout="topleft"
-    left_delta="50"
-    name="sky_dayc_settings_radio_group"
-    top_pad="10"
-    height="50"
-    width="110">
-    <radio_item
-     layout="topleft"
-     label="Fixed sky"
-     name="my_sky_settings"/>
-    <radio_item
-     layout="topleft"
-     label="Day cycle"
-     name="my_dayc_settings"
-     top_pad="25"/>  	
-    </radio_group>
-   <combo_box
-    follows="top|left"
-    left_pad="2"
-    name="sky_settings_preset_combo"
-    top_delta="-7"
-    width="200">
-    <combo_box.item
-     label="-Select a preset-"
-     name="item0"/>
-   </combo_box>
-   <combo_box
-    follows="top|left"
-    name="dayc_settings_preset_combo"
-    top_delta="36"
-    width="200">
-    <combo_box.item
-     label="-Select a preset-"
-     name="item0"/>
-   </combo_box>
- </panel>
- <button
-  follows="left|top"
-  height="23"
-  label="Apply"
-  layout="topleft"
-  right="-160"
-  name="apply_btn"
-  top_pad="10"
-  width="100" />
- <button
-  follows="left|top"
-  height="23"
-  label="Cancel"
-  layout="topleft"
-  left_pad="10"
-  name="cancel_btn"
-  width="100" /> 
- <loading_indicator
-  height="23"
-  left="50"
-  name="progress_indicator"
-  top_delta="0"
-  visible="false"
-  width="23" />
+    help_topic="panel_region_environment_tab"
+    name="panel_env_info"
+    width="530"> 
+    <layout_stack 
+            left="0"
+            top="0"
+            width="420"
+            height="250"
+            follows="left|right|top|bottom"
+            orientation="vertical">
+        <layout_panel 
+                auto_resize="false"
+                user_resize="true"
+                bg_alpha_color="red"
+                min_height="130"
+                background_visible="false">
+            <layout_stack 
+                    left="5"
+                    top="5"
+                    right="-5"
+                    follows="left|right|top|bottom"
+                    orientation="horizontal">
+                <layout_panel 
+                        border="true"
+                        bevel_style="in"
+                        auto_resize="false"
+                        user_resize="false"
+                        width="160"
+                        background_visible="true">
+                    <text follows="top|left"
+                            halign="left"
+                            text_color="white">Environment Source</text>
+                    <radio_group
+                            follows="top|left"
+                            height="45"
+                            layout="topleft"
+                            left_delta="10"
+                            name="environment_select_radio_group"
+                            bottom_delta="50"
+                            max_width="200"
+                            width="200">
+                        <radio_item
+                                label="Default Environment"
+                                layout="topleft"
+                                name="use_default_setting"
+                                height="20"/>
+                        <radio_item
+                                label="Custom Environment"
+                                layout="topleft"
+                                height="20"
+                                name="use_custom_setting"/>
+                    </radio_group>
+                    <button
+                            follows="top|left"
+                            height="23"
+                            label="Edit Custom"
+                            left_delta="30"
+                            bottom_delta="30"
+                            width="100"
+                            name="edit_btn"/>
+
+                </layout_panel>
+                <layout_panel 
+                        border="true"
+                        bevel_style="in"
+                        auto_resize="false"
+                        user_resize="true"
+                        height="11"
+                        width="220"
+                        background_visible="true">
+                    <text follows="top|left|right"
+                            halign="left"
+                            text_color="white">Day Settings</text>
+                    <text
+                            type="string"
+                            length="1"
+                            follows="left|top"
+                            height="12"
+                            layout="topleft"
+                            left_delta="10"
+                            top_pad="10"
+                            width="200">
+                        Day Length (hours)
+                    </text>
+                    <slider
+                            can_edit_text="true"
+                            control_name="DayLengthSLD"
+                            decimal_digits="1"
+                            follows="left|top"
+                            height="20"
+                            increment="0.5"
+                            initial_value="4"
+                            layout="topleft"
+                            left_delta="0"
+                            top_pad="6"
+                            name="day_length_sld"
+                            min_val="4"
+                            max_val="178"
+                            width="200" />
+                    <text
+                            type="string"
+                            length="1"
+                            follows="left|top"
+                            height="12"
+                            layout="topleft"
+                            left_delta="0"
+                            top_pad="10"
+                            width="200">
+                        Day Offset (hours)
+                    </text>
+                    <slider
+                            can_edit_text="true"
+                            control_name="DayOffsetSLD"
+                            decimal_digits="1"
+                            follows="left|top"
+                            height="20"
+                            increment="0.5"
+                            initial_value="-8"
+                            layout="topleft"
+                            left_delta="0"
+                            top_pad="6"
+                            name="day_offset_sld"
+                            min_val="-12"
+                            max_val="12"
+                            width="200" />
+
+                </layout_panel>
+                <layout_panel name="flex"
+                        auto_resize="true"
+                        user_resize="true"
+                        visible="false"
+                        bg_alpha_color="blue"
+                        height="100"
+                        background_visible="true">
+                </layout_panel>
+            </layout_stack>
+        </layout_panel>
+        <layout_panel name="flex"
+                auto_resize="true"
+                user_resize="true"
+                height="11"
+                min_height="0"
+                background_visible="false">
+    <check_box
+        control_name="may_override_chk"
+        height="16"
+        label="Parcel Owners May Override"
+        layout="topleft"
+        left="10"
+        top="10"
+        name="allow_override_chk"
+        width="200" />
+    <button
+        follows="bottom|left"
+        height="23"
+        label="Apply"
+        right="-160"
+        bottom="-30"
+        name="apply_btn"
+        width="100" />
+    <button
+        follows="bottom|left"
+        height="23"
+        label="Cancel"
+        layout="topleft"
+        left_pad="10"
+        name="cancel_btn"
+        width="100" /> 
+                
+        </layout_panel>
+    </layout_stack>
 </panel>