diff --git a/indra/llinventory/llparcel.h b/indra/llinventory/llparcel.h
index dada2cf6d85a0333bf3480136a3b58562608d4f2..7b4647cc5fcf9e52f29276821eb858d4917e4c1a 100644
--- a/indra/llinventory/llparcel.h
+++ b/indra/llinventory/llparcel.h
@@ -595,8 +595,8 @@ class LLParcel
     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; }
+    bool getUsesDefaultDayCycle() const                         { return mIsDefaultDayCycle; }
+    void setUsesDefaultDayCycle(bool isdefault)                { mIsDefaultDayCycle = isdefault; }
     LLSettingsDay::ptr_t getParcelDayCycle() const              { return mDayCycle; }
     void setParcelDayCycle(const LLSettingsDay::ptr_t &pday)    { mDayCycle = pday; }
 
diff --git a/indra/llinventory/llsettingsbase.cpp b/indra/llinventory/llsettingsbase.cpp
index 30b1d66634bb389cb9a0e31c7d3008cd7bf52259..fb9d8de053087f5737ddeb3ff2b32d51eea7c3b7 100644
--- a/indra/llinventory/llsettingsbase.cpp
+++ b/indra/llinventory/llsettingsbase.cpp
@@ -315,49 +315,65 @@ namespace
 
 bool LLSettingsBase::validate()
 {
-    static Validator  validateName(SETTING_NAME, false, LLSD::TypeString);
-    static Validator  validateId(SETTING_ID, false, LLSD::TypeUUID);
-    static Validator  validateHash(SETTING_HASH, false, LLSD::TypeInteger);
-    static Validator  validateType(SETTING_TYPE, false, LLSD::TypeString);
     validation_list_t validations = getValidationList();
-    stringset_t       validated;
-    stringset_t       strip;
 
     if (!mSettings.has(SETTING_TYPE))
     {
         mSettings[SETTING_TYPE] = getSettingType();
     }
 
+    LLSD result = LLSettingsBase::settingValidation(mSettings, validations);
+
+    if (result["errors"].size() > 0)
+    {
+        LL_WARNS("SETTINGS") << "Validation errors: " << result["errors"] << LL_ENDL;
+    }
+    if (result["warnings"].size() > 0)
+    {
+        LL_WARNS("SETTINGS") << "Validation warnings: " << result["errors"] << LL_ENDL;
+    }
+
+    return result["success"].asBoolean();
+}
+
+LLSD LLSettingsBase::settingValidation(LLSD &settings, validation_list_t &validations)
+{
+    static Validator  validateName(SETTING_NAME, false, LLSD::TypeString);
+    static Validator  validateId(SETTING_ID, false, LLSD::TypeUUID);
+    static Validator  validateHash(SETTING_HASH, false, LLSD::TypeInteger);
+    static Validator  validateType(SETTING_TYPE, false, LLSD::TypeString);
+    stringset_t       validated;
+    stringset_t       strip;
+    bool              isValid(true);
+    LLSD              errors(LLSD::emptyArray());
+    LLSD              warnings(LLSD::emptyArray());
+
     // Fields common to all settings.
-    if (!validateName.verify(mSettings))
+    if (!validateName.verify(settings))
     {
-        LL_WARNS("SETTINGS") << "Unable to validate Name." << LL_ENDL;
-        mIsValid = false;
-        return false;
+        errors.append( LLSD::String("Unable to validate 'name'.") );
+        isValid = false;
     }
     validated.insert(validateName.getName());
 
-    if (!validateId.verify(mSettings))
+    if (!validateId.verify(settings))
     {
-        LL_WARNS("SETTINGS") << "Unable to validate Id." << LL_ENDL;
-        mIsValid = false;
-        return false;
+        errors.append( LLSD::String("Unable to validate 'id'.") );
+        isValid = false;
     }
     validated.insert(validateId.getName());
 
-    if (!validateHash.verify(mSettings))
+    if (!validateHash.verify(settings))
     {
-        LL_WARNS("SETTINGS") << "Unable to validate Hash." << LL_ENDL;
-        mIsValid = false;
-        return false;
+        errors.append( LLSD::String("Unable to validate 'hash'.") );
+        isValid = false;
     }
     validated.insert(validateHash.getName());
 
-    if (!validateType.verify(mSettings))
+    if (!validateType.verify(settings))
     {
-        LL_WARNS("SETTINGS") << "Unable to validate Type." << LL_ENDL;
-        mIsValid = false;
-        return false;
+        errors.append( LLSD::String("Unable to validate 'type'.") );
+        isValid = false;
     }
     validated.insert(validateType.getName());
 
@@ -366,47 +382,54 @@ bool LLSettingsBase::validate()
     {
 #ifdef VALIDATION_DEBUG
         LLSD oldvalue;
-        if (mSettings.has((*itv).getName()))
+        if (settings.has((*itv).getName()))
         {
             oldvalue = llsd_clone(mSettings[(*itv).getName()]);
         }
 #endif
 
-        if (!(*itv).verify(mSettings))
+        if (!(*itv).verify(settings))
         {
-            LL_WARNS("SETTINGS") << "Settings LLSD fails validation and could not be corrected for '" << (*itv).getName() << "'!" << LL_ENDL;
-            mIsValid = false;
-            return false;
+            std::stringstream errtext;
+
+            errtext << "Settings LLSD fails validation and could not be corrected for '" << (*itv).getName() << "'!";
+            errors.append( errtext.str() );
+            isValid = false;
         }
         validated.insert((*itv).getName());
 
 #ifdef VALIDATION_DEBUG
         if (!oldvalue.isUndefined())
         {
-            if (!compare_llsd(mSettings[(*itv).getName()], oldvalue))
+            if (!compare_llsd(settings[(*itv).getName()], oldvalue))
             {
-                LL_WARNS("SETTINGS") << "Setting '" << (*itv).getName() << "' was changed: " << oldvalue << " -> " << mSettings[(*itv).getName()] << LL_ENDL;
+                LL_WARNS("SETTINGS") << "Setting '" << (*itv).getName() << "' was changed: " << oldvalue << " -> " << settings[(*itv).getName()] << LL_ENDL;
             }
         }
 #endif
     }
 
     // strip extra entries
-    for (LLSD::map_iterator itm = mSettings.beginMap(); itm != mSettings.endMap(); ++itm)
+    for (LLSD::map_const_iterator itm = settings.beginMap(); itm != settings.endMap(); ++itm)
     {
         if (validated.find((*itm).first) == validated.end())
         {
-            LL_WARNS("SETTINGS") << "Stripping setting '" << (*itm).first << "'" << LL_ENDL;
+            std::stringstream warntext;
+
+            warntext << "Stripping setting '" << (*itm).first << "'";
+            warnings.append( warntext.str() );
             strip.insert((*itm).first);
         }
     }
 
     for (stringset_t::iterator its = strip.begin(); its != strip.end(); ++its)
     {
-        mSettings.erase(*its);
+        settings.erase(*its);
     }
 
-    return true;
+    return LLSDMap("success", LLSD::Boolean(isValid))
+        ("errors", errors)
+        ("warnings", warnings);
 }
 
 //=========================================================================
diff --git a/indra/llinventory/llsettingsbase.h b/indra/llinventory/llsettingsbase.h
index 0a20754ffbb559b9724a2631e066ae4033e1ddd0..fa5fb7a763bbc0962bf3e5db6d12d78fc1075658 100644
--- a/indra/llinventory/llsettingsbase.h
+++ b/indra/llinventory/llsettingsbase.h
@@ -155,7 +155,6 @@ class LLSettingsBase :
 
     virtual bool validate();
 
-protected:
     class Validator
     {
     public:
@@ -192,9 +191,14 @@ class LLSettingsBase :
     };
     typedef std::vector<Validator> validation_list_t;
 
+    static LLSD settingValidation(LLSD &settings, validation_list_t &validations);
+protected:
+
     LLSettingsBase();
     LLSettingsBase(const LLSD setting);
 
+    static LLSD settingValidation(LLSD settings);
+
     typedef std::set<std::string>   stringset_t;
     
     // combining settings objects. Customize for specific setting types
diff --git a/indra/llinventory/llsettingsdaycycle.cpp b/indra/llinventory/llsettingsdaycycle.cpp
index 4207df0924d7fb9a006474146d105a47012b52a1..c7d5c35c60b764fe304e8e6d9e5e99033163d247 100644
--- a/indra/llinventory/llsettingsdaycycle.cpp
+++ b/indra/llinventory/llsettingsdaycycle.cpp
@@ -183,7 +183,7 @@ LLSD LLSettingsDay::getSettings() const
     return settings;
 }
 
-void LLSettingsDay::initialize()
+bool LLSettingsDay::initialize()
 {
     LLSD tracks = mSettings[SETTING_TRACKS];
     LLSD frames = mSettings[SETTING_FRAMES];
@@ -194,21 +194,32 @@ void LLSettingsDay::initialize()
     {
         std::string name = (*itFrame).first;
         LLSD data = (*itFrame).second;
+        LLSettingsBase::ptr_t keyframe;
 
         if (data[SETTING_TYPE].asString() == "sky")
         {
-            used[name] = buildSky(data);
+            keyframe = buildSky(data);
         }
         else if (data[SETTING_TYPE].asString() == "water")
         {
-            used[name] = buildWater(data);
+            keyframe = buildWater(data);
         }
         else
         {
             LL_WARNS("DAYCYCLE") << "Unknown child setting type '" << data[SETTING_TYPE].asString() << "' named '" << name << "'" << LL_ENDL;
         }
+        if (!keyframe)
+        {
+            LL_WARNS("DAYCYCLE") << "Invalid frame data" << LL_ENDL;
+            continue;
+        }
+
+        used[name] = keyframe;
     }
 
+    bool haswater(false);
+    bool hassky(false);
+
     for (S32 i = 0; (i < tracks.size()) && (i < TRACK_MAX); ++i)
     {
         mDayTracks[i].clear();
@@ -246,15 +257,27 @@ void LLSettingsDay::initialize()
             }
 
             if (setting)
+            {
+                if (i == TRACK_WATER)
+                    haswater |= true;
+                else
+                    hassky |= true;
                 mDayTracks[i][keyframe] = setting;
+            }
         }
     }
 
+    if (!haswater || !hassky)
+    {
+        LL_WARNS("DAYCYCLE") << "Must have at least one water and one sky frame!" << LL_ENDL;
+        return false;
+    }
     // these are no longer needed and just take up space now.
     mSettings.erase(SETTING_TRACKS);
     mSettings.erase(SETTING_FRAMES);
 
     mInitialized = true;
+    return true;
 }
 
 
@@ -288,11 +311,14 @@ namespace
             value.erase(value.size() - 1);
         }
 
+        S32 framecount(0);
+
         for (LLSD::array_iterator track = value.beginArray(); track != value.endArray(); ++track)
         {
             S32 index = 0;
             while (index < (*track).size())
             {
+                ++framecount;
                 if (index >= LLSettingsDay::FRAME_MAX)
                 {
                     (*track).erase(index);
@@ -323,22 +349,100 @@ namespace
             }
 
         }
+
+        framecount -= value[0].size();
+
+        if (value[0].size() < 1)
+        {
+            LL_WARNS("SETTINGS") << "Missing water track" << LL_ENDL;
+            return false;
+        }
+
+        if (framecount < 1)
+        {
+            LL_WARNS("SETTINGS") << "Missing sky tracks" << LL_ENDL;
+            return false;
+        }
+        return true;
+    }
+
+    bool validateDayCycleFrames(LLSD &value)
+    {
+        bool hasSky(false);
+        bool hasWater(false);
+
+        for (LLSD::map_iterator itf = value.beginMap(); itf != value.endMap(); ++itf)
+        {
+            LLSD frame = (*itf).second;
+
+            std::string ftype = frame[LLSettingsBase::SETTING_TYPE];
+            if (ftype == "sky")
+            {
+                LLSettingsSky::validation_list_t valid_sky = LLSettingsSky::validationList();
+                LLSD res_sky = LLSettingsSky::settingValidation(frame, valid_sky);
+                LL_WARNS("SETTINGS") << "'" << (*itf).first << "' res=" << res_sky << LL_ENDL;
+                //_WARNS("SETTINGS") << "success=" << res_sky["success"].asBoolean() << "(" << res_sky["success"].asInteger() << ") res=" << res_sky << LL_ENDL;
+                
+                if (res_sky["success"].asInteger() == 0)
+                {
+                    LL_WARNS("SETTINGS") << "Sky setting named '" << (*itf).first << "' validation failed!: " << res_sky << LL_ENDL;
+                    LL_WARNS("SETTINGS") << "Sky: " << frame << LL_ENDL;
+                    continue;
+                }
+                hasSky |= true;
+            }
+            else if (ftype == "water")
+            {
+                LLSettingsWater::validation_list_t valid_h2o = LLSettingsWater::validationList();
+                LLSD res_h2o = LLSettingsWater::settingValidation(frame, valid_h2o);
+                LL_WARNS("SETTINGS") << "'" << (*itf).first << "' res=" << res_h2o << LL_ENDL;
+                //_WARNS("SETTINGS") << "success=" << res_h2o["success"].asBoolean() << LL_ENDL;
+                if (res_h2o["success"].asInteger() == 0)
+                {
+                    LL_WARNS("SETTINGS") << "Water setting named '" << (*itf).first << "' validation failed!: " << res_h2o << LL_ENDL;
+                    LL_WARNS("SETTINGS") << "Water: " << frame << LL_ENDL;
+                    continue;
+                }
+                hasWater |= true;
+            }
+            else
+            {
+                LL_WARNS("SETTINGS") << "Unknown settings block of type '" << ftype << "' named '" << (*itf).first << "'" << LL_ENDL;
+                return false;
+            }
+        }
+
+        if (!hasSky)
+        {
+            LL_WARNS("SETTINGS") << "No skies defined." << LL_ENDL;
+            return false;
+        }
+
+        if (!hasWater)
+        {
+            LL_WARNS("SETTINGS") << "No waters defined." << LL_ENDL;
+            return false;
+        }
+
         return true;
     }
 }
 
 LLSettingsDay::validation_list_t LLSettingsDay::getValidationList() const
+{
+    return LLSettingsDay::validationList();
+}
+
+LLSettingsDay::validation_list_t LLSettingsDay::validationList()
 {
     static validation_list_t validation;
 
     if (validation.empty())
     {
-        validation.push_back(Validator(SETTING_TRACKS, false, LLSD::TypeArray, 
+        validation.push_back(Validator(SETTING_TRACKS, true, LLSD::TypeArray, 
             &validateDayCycleTrack));
-        validation.push_back(Validator(SETTING_FRAMES, false, LLSD::TypeMap));
-        validation.push_back(Validator(SETTING_DAYLENGTH, false, LLSD::TypeInteger,
-            boost::bind(&Validator::verifyIntegerRange, _1, 
-                LLSD(LLSDArray(LLSD::Integer(MINIMUM_DAYLENGTH))(LLSD::Integer(MAXIMUM_DAYLENGTH))))));
+        validation.push_back(Validator(SETTING_FRAMES, true, LLSD::TypeMap, 
+            &validateDayCycleFrames));
     }
 
     return validation;
diff --git a/indra/llinventory/llsettingsdaycycle.h b/indra/llinventory/llsettingsdaycycle.h
index ae47a542708eb5f5b5ed90c3fbf586c163dd2919..b3cf53869fddfaad10dc721affc91bc3608faf52 100644
--- a/indra/llinventory/llsettingsdaycycle.h
+++ b/indra/llinventory/llsettingsdaycycle.h
@@ -61,7 +61,7 @@ class LLSettingsDay : public LLSettingsBase
 
     typedef std::map<F32, LLSettingsBase::ptr_t>    CycleTrack_t;
     typedef std::vector<CycleTrack_t>               CycleList_t;
-    typedef boost::shared_ptr<LLSettingsDay>   ptr_t;
+    typedef boost::shared_ptr<LLSettingsDay>        ptr_t;
     typedef std::vector<S64Seconds>                 TimeList_t;
     typedef std::vector<F32>                        KeyframeList_t;
     typedef std::pair<CycleTrack_t::iterator, CycleTrack_t::iterator> TrackBound_t;
@@ -70,7 +70,7 @@ class LLSettingsDay : public LLSettingsBase
     LLSettingsDay(const LLSD &data);
     virtual ~LLSettingsDay() { };
 
-    void                        initialize();
+    bool                        initialize();
 
     virtual ptr_t               buildClone() = 0;
     virtual LLSD                getSettings() const;
@@ -136,13 +136,14 @@ class LLSettingsDay : public LLSettingsBase
 
     void    setInitialized(bool value = true) { mInitialized = value; }
     CycleTrack_t &              getCycleTrack(S32 track);
+
+    virtual validation_list_t   getValidationList() const;
+    static validation_list_t    validationList();
 protected:
     LLSettingsDay();
 
     virtual void                updateSettings();
 
-    virtual validation_list_t   getValidationList() const;
-
     bool                        mInitialized;
 
 private:
diff --git a/indra/llinventory/llsettingssky.cpp b/indra/llinventory/llsettingssky.cpp
index 7fc9d83cae56adca05dcf2a7ca7f58a7d83f5678..14024cf4f7ed9e13c2aa3dceac657b602336a2b9 100644
--- a/indra/llinventory/llsettingssky.cpp
+++ b/indra/llinventory/llsettingssky.cpp
@@ -145,6 +145,11 @@ LLSettingsSky::stringset_t LLSettingsSky::getSlerpKeys() const
 }
 
 LLSettingsSky::validation_list_t LLSettingsSky::getValidationList() const
+{
+    return LLSettingsSky::validationList();
+}
+
+LLSettingsSky::validation_list_t LLSettingsSky::validationList()
 {
     static validation_list_t validation;
 
diff --git a/indra/llinventory/llsettingssky.h b/indra/llinventory/llsettingssky.h
index 12ea237ef307fcb70612f5dbb7abe73e08e6eb0e..d36de571f641c9644b5fd8101d1272cd1f233f12 100644
--- a/indra/llinventory/llsettingssky.h
+++ b/indra/llinventory/llsettingssky.h
@@ -409,6 +409,9 @@ class LLSettingsSky: public LLSettingsBase
         return mTotalAmbient;
     }
 
+    virtual validation_list_t getValidationList() const;
+    static validation_list_t validationList();
+
 protected:
     static const std::string SETTING_LEGACY_EAST_ANGLE;
     static const std::string SETTING_LEGACY_ENABLE_CLOUD_SCROLL;
@@ -418,8 +421,6 @@ class LLSettingsSky: public LLSettingsBase
 
     virtual stringset_t getSlerpKeys() const;
 
-    virtual validation_list_t getValidationList() const;
-
     virtual void    updateSettings();
 
     static LLSD     translateLegacySettings(LLSD legacy);
diff --git a/indra/llinventory/llsettingswater.cpp b/indra/llinventory/llsettingswater.cpp
index 00f870bbb06c5b448647e6e4e08cf8e4756dbd82..67a9cd39cb48f9ba8ba504967ca83a4d24d1713d 100644
--- a/indra/llinventory/llsettingswater.cpp
+++ b/indra/llinventory/llsettingswater.cpp
@@ -168,6 +168,11 @@ void LLSettingsWater::blend(const LLSettingsBase::ptr_t &end, F64 blendf)
 }
 
 LLSettingsWater::validation_list_t LLSettingsWater::getValidationList() const
+{
+    return LLSettingsWater::validationList();
+}
+
+LLSettingsWater::validation_list_t LLSettingsWater::validationList()
 {
     static validation_list_t validation;
 
diff --git a/indra/llinventory/llsettingswater.h b/indra/llinventory/llsettingswater.h
index d18caf68b199989b67a480fcac664748cf7668c0..94e5583fd753671c7787b66d60dee404faae9123 100644
--- a/indra/llinventory/llsettingswater.h
+++ b/indra/llinventory/llsettingswater.h
@@ -198,6 +198,9 @@ class LLSettingsWater : public LLSettingsBase
         return mWaterFogKS;
     }
 
+    virtual validation_list_t getValidationList() const;
+    static validation_list_t validationList();
+
 protected:
     static const std::string SETTING_LEGACY_BLUR_MULTIPILER;
     static const std::string SETTING_LEGACY_FOG_COLOR;
@@ -214,8 +217,6 @@ class LLSettingsWater : public LLSettingsBase
 
     LLSettingsWater();
 
-    virtual validation_list_t getValidationList() const;
-
     static LLSD         translateLegacySettings(LLSD legacy);
 
     LLVector4           mWaterPlane;
diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp
index b05c9ee871ca043b3ac26db557fa9a8082a007e1..3451b0efefd30153c9d689c49243e1bd428aa878 100644
--- a/indra/newview/llenvironment.cpp
+++ b/indra/newview/llenvironment.cpp
@@ -52,7 +52,7 @@
 
 #include <boost/make_shared.hpp>
 
-#define EXPORT_PRESETS 1
+//define EXPORT_PRESETS 1
 //=========================================================================
 namespace
 {
@@ -154,12 +154,12 @@ void LLEnvironment::onRegionChange()
 
 void LLEnvironment::onParcelChange()
 {
-    LLUUID parcel_id;
+    S32 parcel_id(INVALID_PARCEL_ID);
     LLParcel* parcel = LLViewerParcelMgr::instance().getAgentParcel();
 
     if (parcel)
     {
-        parcel_id = parcel->getID();
+        parcel_id = parcel->getLocalID();
     }
 
     requestParcel(parcel_id);
@@ -167,7 +167,6 @@ void LLEnvironment::onParcelChange()
 
 void LLEnvironment::requestRegionEnvironment()
 {
-//    LLEnvironmentRequest::initiate();
     requestRegion();
 }
 
@@ -243,7 +242,6 @@ void LLEnvironment::update(const LLViewerCamera * cam)
     if (mCurrentWater)
         mCurrentWater->update();
 
-
     F32 camYaw = cam->getYaw();
 
     stop_glerror();
@@ -485,7 +483,7 @@ void LLEnvironment::selectDayCycle(const std::string &name, F32Seconds transitio
 
 void LLEnvironment::selectDayCycle(const LLSettingsDay::ptr_t &daycycle, F32Seconds transition)
 {
-    if (!daycycle)
+    if (!daycycle || (daycycle == mCurrentDay))
     {
         return;
     }
@@ -779,30 +777,81 @@ LLSettingsDay::ptr_t LLEnvironment::findDayCycleByName(std::string name) const
 }
 
 
-void LLEnvironment::applyEnvironment(LLSD environment)
+void LLEnvironment::selectAgentEnvironment()
 {
-    LL_WARNS("ENVIRONMENT") << "Have environment" << LL_ENDL;
+    S64Seconds day_length(LLSettingsDay::DEFAULT_DAYLENGTH);
+    S64Seconds day_offset(LLSettingsDay::DEFAULT_DAYOFFSET);
+    LLSettingsDay::ptr_t pday;
 
-    S32 daylength(LLSettingsDay::DEFAULT_DAYLENGTH);
-    S32 dayoffset(LLSettingsDay::DEFAULT_DAYOFFSET);
+    // TODO: First test if agent has local environment set.
 
-    if (environment.has("day_length"))
-        daylength = environment["day_length"].asInteger();
-    if (environment.has("day_offset"))
-        dayoffset = environment["day_cycle"].asInteger();
+    LLParcel *parcel = LLViewerParcelMgr::instance().getAgentParcel();
+    LLViewerRegion *pRegion = gAgent.getRegion();
 
-    setDayLength(S64Seconds(daylength));
-    setDayOffset(S64Seconds(dayoffset));
+    if (!parcel || parcel->getUsesDefaultDayCycle() || !parcel->getParcelDayCycle())
+    {
+        day_length = pRegion->getDayLength();
+        day_offset = pRegion->getDayOffset();
+        pday = pRegion->getRegionDayCycle();
+    }
+    else
+    {
+        day_length = parcel->getDayLength();
+        day_offset = parcel->getDayOffset();
+        pday = parcel->getParcelDayCycle();
+    }
 
-    if (environment.has("day_cycle"))
+    if (getDayLength() != day_length)
+        setDayLength(day_length);
+
+    if (getDayOffset() != day_offset)
+        setDayOffset(day_offset);
+
+    if (pday)
+        selectDayCycle(pday);
+    
+}
+
+void LLEnvironment::recordEnvironment(S32 parcel_id, LLEnvironment::EnvironmentInfo::ptr_t envinfo)
+{
+    LL_WARNS("ENVIRONMENT") << "Have environment" << LL_ENDL;
+
+    if (parcel_id == INVALID_PARCEL_ID)
     {
-        LLSettingsDay::ptr_t pday = LLSettingsVODay::buildFromEnvironmentMessage(environment["day_cycle"]);
+        LLViewerRegion *pRegion = gAgent.getRegion();
+
+        if (pRegion)
+        {
+            pRegion->setDayLength(envinfo->mDayLength);
+            pRegion->setDayOffset(envinfo->mDayOffset);
+            pRegion->setIsDefaultDayCycle(envinfo->mIsDefault);
+            pRegion->setRegionDayCycle(LLSettingsVODay::buildFromEnvironmentMessage(envinfo->mDaycycleData));
+
+            /*TODO: track_altitudes*/
+        }
+    }
+    else
+    {
+        LLParcel *parcel = LLViewerParcelMgr::instance().getAgentParcel();
+
+        if (parcel->getLocalID() == parcel_id)
+        {
+            parcel->setDayLength(envinfo->mDayLength);
+            parcel->setDayOffset(envinfo->mDayOffset);
+            parcel->setUsesDefaultDayCycle(envinfo->mIsDefault);
+
+            LLSettingsDay::ptr_t pday;
+            if (!envinfo->mIsDefault)
+            {
+                pday = LLSettingsVODay::buildFromEnvironmentMessage(envinfo->mDaycycleData);
+            }
+            parcel->setParcelDayCycle(pday);
 
-        if (pday)
-            selectDayCycle(pday);
+            // select parcel day
+        }
     }
 
-    /*TODO: track_altitudes*/
+    selectAgentEnvironment();
 }
 
 //=========================================================================
@@ -814,7 +863,7 @@ void LLEnvironment::requestRegion()
         return;
     }
 
-    requestParcel(LLUUID::null);
+    requestParcel(INVALID_PARCEL_ID);
 }
 
 void LLEnvironment::updateRegion(LLSettingsDay::ptr_t &pday, S32 day_length, S32 day_offset)
@@ -825,42 +874,45 @@ void LLEnvironment::updateRegion(LLSettingsDay::ptr_t &pday, S32 day_length, S32
         return;
     }
 
-    updateParcel(LLUUID::null, pday, day_length, day_offset);
+    updateParcel(INVALID_PARCEL_ID, pday, day_length, day_offset);
 }
 
 void LLEnvironment::resetRegion()
 {
-    resetParcel(LLUUID::null);
+    resetParcel(INVALID_PARCEL_ID);
 }
 
-void LLEnvironment::requestParcel(const LLUUID &parcel_id)
+void LLEnvironment::requestParcel(S32 parcel_id)
 {
+    environment_apply_fn apply = boost::bind(&LLEnvironment::recordEnvironment, this, _1, _2);
+
     std::string coroname =
         LLCoros::instance().launch("LLEnvironment::coroRequestEnvironment",
-        boost::bind(&LLEnvironment::coroRequestEnvironment, this, parcel_id, 
-        boost::bind(&LLEnvironment::applyEnvironment, this, _1)));
+        boost::bind(&LLEnvironment::coroRequestEnvironment, this, parcel_id, apply));
 
 }
 
-void LLEnvironment::updateParcel(const LLUUID &parcel_id, LLSettingsDay::ptr_t &pday, S32 day_length, S32 day_offset)
+void LLEnvironment::updateParcel(S32 parcel_id, LLSettingsDay::ptr_t &pday, S32 day_length, S32 day_offset)
 {
+    environment_apply_fn apply = boost::bind(&LLEnvironment::recordEnvironment, this, _1, _2);
+
     std::string coroname =
         LLCoros::instance().launch("LLEnvironment::coroUpdateEnvironment",
         boost::bind(&LLEnvironment::coroUpdateEnvironment, this, parcel_id, 
-        pday, day_length, day_offset,
-        boost::bind(&LLEnvironment::applyEnvironment, this, _1)));
+        pday, day_length, day_offset, apply));
 
 }
 
-void LLEnvironment::resetParcel(const LLUUID &parcel_id)
+void LLEnvironment::resetParcel(S32 parcel_id)
 {
+    environment_apply_fn apply = boost::bind(&LLEnvironment::recordEnvironment, this, _1, _2);
+
     std::string coroname =
         LLCoros::instance().launch("LLEnvironment::coroResetEnvironment",
-        boost::bind(&LLEnvironment::coroResetEnvironment, this, parcel_id,
-        boost::bind(&LLEnvironment::applyEnvironment, this, _1)));
+        boost::bind(&LLEnvironment::coroResetEnvironment, this, parcel_id, apply));
 }
 
-void LLEnvironment::coroRequestEnvironment(LLUUID parcel_id, environment_apply_fn apply)
+void LLEnvironment::coroRequestEnvironment(S32 parcel_id, LLEnvironment::environment_apply_fn apply)
 {
     LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID);
     LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t
@@ -871,8 +923,17 @@ void LLEnvironment::coroRequestEnvironment(LLUUID parcel_id, environment_apply_f
     if (url.empty())
         return;
 
-    if (!parcel_id.isNull())
-        url += "?parcelid=" + parcel_id.asString();
+    LL_WARNS("LAPRAS") << "Requesting for parcel_id=" << parcel_id << LL_ENDL;
+
+    if (parcel_id != INVALID_PARCEL_ID)
+    {
+        std::stringstream query;
+
+        query << "?parcelid=" << parcel_id;
+        url += query.str();
+    }
+
+    LL_WARNS("LAPRAS") << "url=" << url << LL_ENDL;
 
     LLSD result = httpAdapter->getAndSuspend(httpRequest, url);
     // results that come back may contain the new settings
@@ -883,7 +944,7 @@ void LLEnvironment::coroRequestEnvironment(LLUUID parcel_id, environment_apply_f
     LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults);
     if (!status)
     {
-        LL_WARNS("WindlightCaps") << "Couldn't retrieve Windlight settings for " << (parcel_id.isNull() ? ("region!") : ("parcel!")) << LL_ENDL;
+        LL_WARNS("WindlightCaps") << "Couldn't retrieve Windlight settings for " << ((parcel_id == INVALID_PARCEL_ID) ? ("region!") : ("parcel!")) << LL_ENDL;
 
         std::stringstream msg;
         msg << status.toString() << " (Code " << status.toTerseString() << ")";
@@ -896,7 +957,8 @@ void LLEnvironment::coroRequestEnvironment(LLUUID parcel_id, environment_apply_f
         LLSD environment = result["environment"];
         if (environment.isDefined() && !apply.empty())
         {
-            apply(environment);
+            EnvironmentInfo::ptr_t envinfo = LLEnvironment::EnvironmentInfo::extract(environment);
+            apply(parcel_id, envinfo);
         }
     }
 
@@ -907,7 +969,7 @@ void LLEnvironment::coroRequestEnvironment(LLUUID parcel_id, environment_apply_f
     }
 }
 
-void LLEnvironment::coroUpdateEnvironment(LLUUID parcel_id, LLSettingsDay::ptr_t pday, S32 day_length, S32 day_offset, environment_apply_fn apply)
+void LLEnvironment::coroUpdateEnvironment(S32 parcel_id, LLSettingsDay::ptr_t pday, S32 day_length, S32 day_offset, LLEnvironment::environment_apply_fn apply)
 {
     LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID);
     LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t
@@ -928,9 +990,17 @@ void LLEnvironment::coroUpdateEnvironment(LLUUID parcel_id, LLSettingsDay::ptr_t
     if (pday)
         body["environment"]["day_cycle"] = pday->getSettings();
 
+    LL_WARNS("LAPRAS") << "Body = " << body << LL_ENDL;
 
-    if (!parcel_id.isNull())
-        url += "?parcelid=" + parcel_id.asString();
+    if (parcel_id != INVALID_PARCEL_ID)
+    {
+        std::stringstream query;
+
+        query << "?parcelid=" << parcel_id;
+        url += query.str();
+    }
+
+    LL_WARNS("LAPRAS") << "url=" << url << LL_ENDL;
 
     LLSD result = httpAdapter->putAndSuspend(httpRequest, url, body);
     // results that come back may contain the new settings
@@ -941,7 +1011,7 @@ void LLEnvironment::coroUpdateEnvironment(LLUUID parcel_id, LLSettingsDay::ptr_t
     LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults);
     if (!status)
     {
-        LL_WARNS("WindlightCaps") << "Couldn't update Windlight settings for " << (parcel_id.isNull() ? ("region!") : ("parcel!")) << LL_ENDL;
+        LL_WARNS("WindlightCaps") << "Couldn't update Windlight settings for " << ((parcel_id == INVALID_PARCEL_ID) ? ("region!") : ("parcel!")) << LL_ENDL;
 
         std::stringstream msg;
         msg << status.toString() << " (Code " << status.toTerseString() << ")";
@@ -953,7 +1023,8 @@ void LLEnvironment::coroUpdateEnvironment(LLUUID parcel_id, LLSettingsDay::ptr_t
         LLSD environment = result["environment"];
         if (environment.isDefined() && !apply.empty())
         {
-            apply(environment);
+            EnvironmentInfo::ptr_t envinfo = LLEnvironment::EnvironmentInfo::extract(environment);
+            apply(parcel_id, envinfo);
         }
     }
 
@@ -964,7 +1035,7 @@ void LLEnvironment::coroUpdateEnvironment(LLUUID parcel_id, LLSettingsDay::ptr_t
     }
 }
 
-void LLEnvironment::coroResetEnvironment(LLUUID parcel_id, environment_apply_fn apply)
+void LLEnvironment::coroResetEnvironment(S32 parcel_id, environment_apply_fn apply)
 {
     LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID);
     LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t
@@ -975,8 +1046,15 @@ void LLEnvironment::coroResetEnvironment(LLUUID parcel_id, environment_apply_fn
     if (url.empty())
         return;
 
-    if (!parcel_id.isNull())
-        url += "?parcelid=" + parcel_id.asString();
+    if (parcel_id != INVALID_PARCEL_ID)
+    {
+        std::stringstream query;
+
+        query << "?parcelid=" << parcel_id;
+        url += query.str();
+    }
+
+    LL_WARNS("LAPRAS") << "url=" << url << LL_ENDL;
 
     LLSD result = httpAdapter->deleteAndSuspend(httpRequest, url);
     // results that come back may contain the new settings
@@ -987,7 +1065,7 @@ void LLEnvironment::coroResetEnvironment(LLUUID parcel_id, environment_apply_fn
     LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults);
     if (!status)
     {
-        LL_WARNS("WindlightCaps") << "Couldn't reset Windlight settings in " << (parcel_id.isNull() ? ("region!") : ("parcel!"))  << LL_ENDL;
+        LL_WARNS("WindlightCaps") << "Couldn't reset Windlight settings in " << ((parcel_id == INVALID_PARCEL_ID) ? ("region!") : ("parcel!"))  << LL_ENDL;
 
         std::stringstream msg;
         msg << status.toString() << " (Code " << status.toTerseString() << ")";
@@ -1000,7 +1078,8 @@ void LLEnvironment::coroResetEnvironment(LLUUID parcel_id, environment_apply_fn
         LLSD environment = result["environment"];
         if (environment.isDefined() && !apply.empty())
         {
-                apply(environment);
+            EnvironmentInfo::ptr_t envinfo = LLEnvironment::EnvironmentInfo::extract(environment);
+            apply(parcel_id, envinfo);
         }
     }
 
@@ -1050,6 +1129,36 @@ void LLEnvironment::UserPrefs::store()
     }
 }
 
+LLEnvironment::EnvironmentInfo::EnvironmentInfo():
+    mParcelId(),
+    mDayLength(LLSettingsDay::DEFAULT_DAYLENGTH),
+    mDayOffset(LLSettingsDay::DEFAULT_DAYOFFSET),
+    mDaycycleData(),
+    mAltitudes(),
+    mIsDefault(false)
+{
+}
+
+LLEnvironment::EnvironmentInfo::ptr_t LLEnvironment::EnvironmentInfo::extract(LLSD environment)
+{
+    ptr_t pinfo = boost::make_shared<EnvironmentInfo>();
+
+    if (environment.has("parcel_id"))
+        pinfo->mParcelId = environment["parcel_id"].asUUID();
+    if (environment.has("day_length"))
+        pinfo->mDayLength = S64Seconds(environment["day_length"].asInteger());
+    if (environment.has("day_offset"))
+        pinfo->mDayOffset = S64Seconds(environment["day_offset"].asInteger());
+    if (environment.has("day_cycle"))
+        pinfo->mDaycycleData = environment["day_cycle"];
+    if (environment.has("is_default"))
+        pinfo->mIsDefault = environment["is_default"].asBoolean();
+    if (environment.has("track_altitudes"))
+        pinfo->mAltitudes = environment["track_altitudes"];
+
+    return pinfo;
+}
+
 //=========================================================================
 // Transitional Code.
 // static
diff --git a/indra/newview/llenvironment.h b/indra/newview/llenvironment.h
index 4f8850683e09257b1a2fa7b57bcdab9c4e553f8e..f5bd9be870c6fc387d09c7a705e57ca0d7ec5315 100644
--- a/indra/newview/llenvironment.h
+++ b/indra/newview/llenvironment.h
@@ -54,6 +54,23 @@ class LLEnvironment : public LLSingleton<LLEnvironment>
     static const F32Seconds     TRANSITION_DEFAULT;
     static const F32Seconds     TRANSITION_SLOW;
 
+    struct EnvironmentInfo
+    {
+        EnvironmentInfo();
+
+        typedef boost::shared_ptr<EnvironmentInfo>  ptr_t;
+
+        LLUUID          mParcelId;
+        S64Seconds      mDayLength;
+        S64Seconds      mDayOffset;
+        LLSD            mDaycycleData;
+        LLSD            mAltitudes;
+        bool            mIsDefault;
+
+        static ptr_t    extract(LLSD);
+
+    };
+
     enum EnvSelection_t
     {
         ENV_LOCAL,
@@ -99,7 +116,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;
+    typedef boost::function<void(S32, EnvironmentInfo::ptr_t)>     environment_apply_fn;
 
     virtual ~LLEnvironment();
 
@@ -198,9 +215,11 @@ class LLEnvironment : public LLSingleton<LLEnvironment>
     void                        requestRegion();
     void                        updateRegion(LLSettingsDay::ptr_t &pday, S32 day_length, S32 day_offset);
     void                        resetRegion();
-    void                        requestParcel(const LLUUID &parcel_id);
-    void                        updateParcel(const LLUUID &parcel_id, LLSettingsDay::ptr_t &pday, S32 day_length, S32 day_offset);
-    void                        resetParcel(const LLUUID &parcel_id);
+    void                        requestParcel(S32 parcel_id);
+    void                        updateParcel(S32 parcel_id, LLSettingsDay::ptr_t &pday, S32 day_length, S32 day_offset);
+    void                        resetParcel(S32 parcel_id);
+
+    void                        selectAgentEnvironment();
 
 protected:
     virtual void                initSingleton();
@@ -280,11 +299,11 @@ class LLEnvironment : public LLSingleton<LLEnvironment>
     void onRegionChange();
     void onParcelChange();
 
-    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 coroRequestEnvironment(S32 parcel_id, environment_apply_fn apply);
+    void coroUpdateEnvironment(S32 parcel_id, LLSettingsDay::ptr_t pday, S32 day_length, S32 day_offset, environment_apply_fn apply);
+    void coroResetEnvironment(S32 parcel_id, environment_apply_fn apply);
 
-    void applyEnvironment(LLSD environment);
+    void recordEnvironment(S32 parcel_id, EnvironmentInfo::ptr_t environment);
 
     //=========================================================================
     void                        legacyLoadAllPresets();
diff --git a/indra/newview/llfloaterland.cpp b/indra/newview/llfloaterland.cpp
index fc4ab0a7a725e5b86696ee7cdbb8ba864be19656..5d6e8885de97ab090fac42c350f1c80c60cc2760 100644
--- a/indra/newview/llfloaterland.cpp
+++ b/indra/newview/llfloaterland.cpp
@@ -139,31 +139,21 @@ class LLPanelLandExperiences
 	LLPanelExperienceListEditor* mBlocked;
 };
 
-#if 0
+
 class LLPanelLandEnvironment
-    : public LLPanel
+    : public LLPanelEnvironmentInfo
 {
 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
@@ -346,6 +336,7 @@ void LLFloaterLand::refresh()
 	mPanelAccess->refresh();
 	mPanelCovenant->refresh();
 	mPanelExperiences->refresh();
+    mPanelEnvironment->refresh();
 }
 
 
@@ -418,7 +409,7 @@ void* LLFloaterLand::createPanelLandExperiences(void* data)
 void* LLFloaterLand::createPanelLandEnvironment(void* data)
 {
     LLFloaterLand* self = (LLFloaterLand*)data;
-    self->mPanelEnvironment = new LLPanelEnvironmentInfo(/*self->mParcel*/);
+    self->mPanelEnvironment = new LLPanelLandEnvironment(self->mParcel);
     return self->mPanelEnvironment;
 }
 
@@ -3247,3 +3238,64 @@ void LLPanelLandExperiences::refresh()
 	refreshPanel(mAllowed, EXPERIENCE_KEY_TYPE_ALLOWED);
 	refreshPanel(mBlocked, EXPERIENCE_KEY_TYPE_BLOCKED);
 }
+
+//=========================================================================
+
+LLPanelLandEnvironment::LLPanelLandEnvironment(LLSafeHandle<LLParcelSelection>& parcelp):
+    LLPanelEnvironmentInfo(),
+    mParcel(parcelp)
+{
+}
+
+BOOL LLPanelLandEnvironment::postBuild()
+{
+    if (!LLPanelEnvironmentInfo::postBuild())
+        return FALSE;
+
+    mAllowOverRide->setVisible(FALSE);
+    return TRUE;
+}
+
+void LLPanelLandEnvironment::refresh()
+{
+    LLParcel* parcel = mParcel->getParcel();
+    if (!parcel)
+    {
+        mRegionSettingsRadioGroup->setEnabled(FALSE);
+        mDayLengthSlider->setEnabled(FALSE);
+        mDayOffsetSlider->setEnabled(FALSE);
+        mAllowOverRide->setEnabled(FALSE);
+
+        return;
+    }
+
+    //BOOL owner_or_god = gAgent.isGodlike() || (parcel owner or group)
+    BOOL owner_or_god = true;
+    //BOOL owner_or_god_or_manager = owner_or_god || (region && region->isEstateManager());
+
+    F64Hours daylength;
+    F64Hours dayoffset;
+
+    daylength = parcel->getDayLength();
+    dayoffset = parcel->getDayOffset();
+
+    if (dayoffset.value() > 12.0)
+        dayoffset = dayoffset - F32Hours(24.0f);
+
+    mDayLengthSlider->setValue(daylength.value());
+    mDayOffsetSlider->setValue(dayoffset.value());
+
+    mRegionSettingsRadioGroup->setSelectedIndex(parcel->getUsesDefaultDayCycle() ? 0 : 1);
+
+    setControlsEnabled(owner_or_god);
+
+    if (!parcel->getUsesDefaultDayCycle())
+        mEditingDayCycle = parcel->getParcelDayCycle()->buildClone();
+    else
+    {
+        LLViewerRegion* regionp = LLViewerParcelMgr::getInstance()->getSelectionRegion();
+        if (regionp)
+            mEditingDayCycle = regionp->getRegionDayCycle()->buildClone();
+    }
+
+}
diff --git a/indra/newview/llfloaterland.h b/indra/newview/llfloaterland.h
index e5837b5a08e7ee860207f984b64a5bb27767b614..0eea46bc5a357ce50a0c0478cb40cdbffe84f2da 100644
--- a/indra/newview/llfloaterland.h
+++ b/indra/newview/llfloaterland.h
@@ -67,8 +67,7 @@ class LLPanelLandRenters;
 class LLPanelLandCovenant;
 class LLParcel;
 class LLPanelLandExperiences;
-//class LLPanelLandEnvironment;
-class LLPanelEnvironmentInfo;
+class LLPanelLandEnvironment;
 
 class LLFloaterLand
 :	public LLFloater
@@ -122,7 +121,7 @@ class LLFloaterLand
 	LLPanelLandAccess*		mPanelAccess;
 	LLPanelLandCovenant*	mPanelCovenant;
 	LLPanelLandExperiences*	mPanelExperiences;
-    LLPanelEnvironmentInfo *mPanelEnvironment;
+    LLPanelLandEnvironment *mPanelEnvironment;
 
 	LLSafeHandle<LLParcelSelection>	mParcel;
 
diff --git a/indra/newview/llfloaterregioninfo.cpp b/indra/newview/llfloaterregioninfo.cpp
index 5ce682fe8c4a6cdfdb8abf3bc0bea449ab1840da..578c85470e64f424ff433f21a6d1e478b4bc0302 100644
--- a/indra/newview/llfloaterregioninfo.cpp
+++ b/indra/newview/llfloaterregioninfo.cpp
@@ -95,6 +95,7 @@
 #include "llexperiencecache.h"
 #include "llpanelexperiences.h"
 #include "llcorehttputil.h"
+#include "llenvironment.h"
 
 const S32 TERRAIN_TEXTURE_COUNT = 4;
 const S32 CORNER_COUNT = 4;
@@ -175,6 +176,24 @@ void unpack_request_params(
 }
 */
 
+class LLPanelRegionEnvironment : public LLPanelEnvironmentInfo
+{
+public:
+    LLPanelRegionEnvironment();
+
+    void refresh();
+
+    bool refreshFromRegion(LLViewerRegion* region);
+
+    virtual BOOL postBuild();
+
+protected:
+    virtual void doApply();
+
+private:
+    LLViewerRegion * mLastRegion;
+};
+
 
 
 bool estate_dispatch_initialized = false;
@@ -3345,25 +3364,22 @@ void LLPanelRegionExperiences::itemChanged( U32 event_type, const LLUUID& id )
 }
 
 //=========================================================================
-class LLPanelRegionEnvironment : public LLPanelEnvironmentInfo
-{
-public:
-    LLPanelRegionEnvironment();
-
-    void refresh();
-
-    bool refreshFromRegion(LLViewerRegion* region);
-
-private:
-    LLViewerRegion * mLastRegion;
-};
-
 LLPanelRegionEnvironment::LLPanelRegionEnvironment():
     LLPanelEnvironmentInfo(),
     mLastRegion(NULL)
 {
 }
 
+
+BOOL LLPanelRegionEnvironment::postBuild()
+{
+    if (!LLPanelEnvironmentInfo::postBuild())
+        return FALSE;
+
+    return TRUE;
+}
+
+
 void LLPanelRegionEnvironment::refresh()
 {
     refreshFromRegion(mLastRegion);
@@ -3374,12 +3390,50 @@ 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());
+    F64Hours daylength;
+    F64Hours dayoffset;
 
+    daylength = region->getDayLength();
+    dayoffset = region->getDayOffset();
+
+    if (dayoffset.value() > 12.0)
+        dayoffset = dayoffset - F32Hours(24.0f);
+
+    mDayLengthSlider->setValue(daylength.value());
+    mDayOffsetSlider->setValue(dayoffset.value());
     
+    mRegionSettingsRadioGroup->setSelectedIndex(region->getIsDefaultDayCycle() ? 0 : 1);
 
     setControlsEnabled(owner_or_god_or_manager);
     mLastRegion = region;
+
+    if (region->getRegionDayCycle())
+        mEditingDayCycle = region->getRegionDayCycle()->buildClone();
+
     return true;
 }
+
+void LLPanelRegionEnvironment::doApply()
+{
+    if (mRegionSettingsRadioGroup->getSelectedIndex() == 0)
+    {
+        LLEnvironment::instance().resetRegion();
+    }
+    else
+    {
+        S64Seconds daylength;
+        F32Hours   dayoffset_h;
+
+        daylength = F32Hours(mDayLengthSlider->getValueF32());
+        dayoffset_h = F32Hours(mDayOffsetSlider->getValueF32());
+
+        if (dayoffset_h.value() < 0)
+        {
+            dayoffset_h = F32Hours(24.0f) + dayoffset_h;
+        }
+
+        S64Seconds dayoffset_s = dayoffset_h;
+
+        LLEnvironment::instance().updateRegion(mEditingDayCycle, daylength.value(), dayoffset_s.value());
+    }
+}
diff --git a/indra/newview/llsettingsvo.cpp b/indra/newview/llsettingsvo.cpp
index cd32aa07a881d671bae1d508cb6e7a7d4fcbfc88..7756d288795706029857e6f32c95f4a5bd63f746 100644
--- a/indra/newview/llsettingsvo.cpp
+++ b/indra/newview/llsettingsvo.cpp
@@ -86,6 +86,14 @@ LLSettingsSky::ptr_t LLSettingsVOSky::buildFromLegacyPreset(const std::string &n
 
     newsettings[SETTING_NAME] = name;
 
+    LLSettingsSky::validation_list_t validations = LLSettingsSky::validationList();
+    LLSD results = LLSettingsSky::settingValidation(newsettings, validations);
+    if (!results["success"].asBoolean())
+    {
+        LL_WARNS("SETTINGS") << "Sky setting validation failed!\n" << results << LL_ENDL;
+        LLSettingsSky::ptr_t();
+    }
+
     LLSettingsSky::ptr_t skyp = boost::make_shared<LLSettingsVOSky>(newsettings);
 
 #ifdef VERIFY_LEGACY_CONVERSION
@@ -100,10 +108,7 @@ LLSettingsSky::ptr_t LLSettingsVOSky::buildFromLegacyPreset(const std::string &n
 
 #endif
 
-    if (skyp->validate())
-        return skyp;
-
-    return LLSettingsSky::ptr_t();
+    return skyp;
 }
 
 LLSettingsSky::ptr_t LLSettingsVOSky::buildDefaultSky()
@@ -111,24 +116,32 @@ LLSettingsSky::ptr_t LLSettingsVOSky::buildDefaultSky()
     LLSD settings = LLSettingsSky::defaults();
     settings[SETTING_NAME] = std::string("_default_");
 
+    LLSettingsSky::validation_list_t validations = LLSettingsSky::validationList();
+    LLSD results = LLSettingsSky::settingValidation(settings, validations);
+    if (!results["success"].asBoolean())
+    {
+        LL_WARNS("SETTINGS") << "Sky setting validation failed!\n" << results << LL_ENDL;
+        LLSettingsSky::ptr_t();
+    }
 
     LLSettingsSky::ptr_t skyp = boost::make_shared<LLSettingsVOSky>(settings);
-    if (skyp->validate())
-        return skyp;
-
-    return LLSettingsSky::ptr_t();
+    return skyp;
 }
 
 LLSettingsSky::ptr_t LLSettingsVOSky::buildClone()
 {
     LLSD settings = cloneSettings();
 
-    LLSettingsSky::ptr_t skyp = boost::make_shared<LLSettingsVOSky>(settings);
-
-    if (skyp->validate())
-        return skyp;
+    LLSettingsSky::validation_list_t validations = LLSettingsSky::validationList();
+    LLSD results = LLSettingsSky::settingValidation(settings, validations);
+    if (!results["success"].asBoolean())
+    {
+        LL_WARNS("SETTINGS") << "Sky setting validation failed!\n" << results << LL_ENDL;
+        LLSettingsSky::ptr_t();
+    }
 
-    return LLSettingsSky::ptr_t();
+    LLSettingsSky::ptr_t skyp = boost::make_shared<LLSettingsVOSky>(settings);
+    return skyp;
 }
 
 LLSD LLSettingsVOSky::convertToLegacy(const LLSettingsSky::ptr_t &psky)
@@ -246,6 +259,13 @@ LLSettingsWater::ptr_t LLSettingsVOWater::buildFromLegacyPreset(const std::strin
     LLSD newsettings(LLSettingsWater::translateLegacySettings(legacy));
 
     newsettings[SETTING_NAME] = name; 
+    LLSettingsWater::validation_list_t validations = LLSettingsWater::validationList();
+    LLSD results = LLSettingsWater::settingValidation(newsettings, validations);
+    if (!results["success"].asBoolean())
+    {
+        LL_WARNS("SETTINGS") << "Water setting validation failed!\n" << results << LL_ENDL;
+        LLSettingsWater::ptr_t();
+    }
 
     LLSettingsWater::ptr_t waterp = boost::make_shared<LLSettingsVOWater>(newsettings);
 
@@ -260,12 +280,7 @@ LLSettingsWater::ptr_t LLSettingsVOWater::buildFromLegacyPreset(const std::strin
     }
 
 #endif
-
-
-    if (waterp->validate())
-        return waterp;
-
-    return LLSettingsWater::ptr_t();
+    return waterp;
 }
 
 LLSettingsWater::ptr_t LLSettingsVOWater::buildDefaultWater()
@@ -273,24 +288,33 @@ LLSettingsWater::ptr_t LLSettingsVOWater::buildDefaultWater()
     LLSD settings = LLSettingsWater::defaults();
     settings[SETTING_NAME] = std::string("_default_");
 
-    LLSettingsWater::ptr_t waterp = boost::make_shared<LLSettingsVOWater>(settings);
+    LLSettingsWater::validation_list_t validations = LLSettingsWater::validationList();
+    LLSD results = LLSettingsWater::settingValidation(settings, validations);
+    if (!results["success"].asBoolean())
+    {
+        LL_WARNS("SETTINGS") << "Water setting validation failed!\n" << results << LL_ENDL;
+        LLSettingsWater::ptr_t();
+    }
 
-    if (waterp->validate())
-        return waterp;
+    LLSettingsWater::ptr_t waterp = boost::make_shared<LLSettingsVOWater>(settings);
 
-    return LLSettingsWater::ptr_t();
+    return waterp;
 }
 
 LLSettingsWater::ptr_t LLSettingsVOWater::buildClone()
 {
     LLSD settings = cloneSettings();
+    LLSettingsWater::validation_list_t validations = LLSettingsWater::validationList();
+    LLSD results = LLSettingsWater::settingValidation(settings, validations);
+    if (!results["success"].asBoolean())
+    {
+        LL_WARNS("SETTINGS") << "Water setting validation failed!\n" << results << LL_ENDL;
+        LLSettingsWater::ptr_t();
+    }
 
     LLSettingsWater::ptr_t waterp = boost::make_shared<LLSettingsVOWater>(settings);
 
-    if (waterp->validate())
-        return waterp;
-
-    return LLSettingsWater::ptr_t();
+    return waterp;
 }
 
 LLSD LLSettingsVOWater::convertToLegacy(const LLSettingsWater::ptr_t &pwater)
@@ -409,6 +433,15 @@ LLSettingsDay::ptr_t LLSettingsVODay::buildFromLegacyPreset(const std::string &n
 
     newsettings[SETTING_TRACKS] = LLSDArray(watertrack)(skytrack);
 
+    LLSettingsDay::validation_list_t validations = LLSettingsDay::validationList();
+    LLSD results = LLSettingsDay::settingValidation(newsettings, validations);
+    if (!results["success"].asBoolean())
+    {
+        LL_WARNS("SETTINGS") << "Day setting validation failed!\n" << results << LL_ENDL;
+        LLSettingsDay::ptr_t();
+    }
+
+
     LLSettingsDay::ptr_t dayp = boost::make_shared<LLSettingsVODay>(newsettings);
 
 #ifdef VERIFY_LEGACY_CONVERSION
@@ -423,20 +456,21 @@ LLSettingsDay::ptr_t LLSettingsVODay::buildFromLegacyPreset(const std::string &n
 
 #endif
 
-    if (dayp->validate())
-    {
-        dayp->initialize();
-        return dayp;
-    }
+    dayp->initialize();
 
-
-
-    return LLSettingsDay::ptr_t();
+    return dayp;
 }
 
 LLSettingsDay::ptr_t LLSettingsVODay::buildFromLegacyMessage(const LLUUID &regionId, LLSD daycycle, LLSD skydefs, LLSD waterdef)
 {
     LLSettingsWater::ptr_t water = LLSettingsVOWater::buildFromLegacyPreset("Region", waterdef);
+
+    if (!water)
+    {
+        LL_WARNS("WindlightCaps") << "Water construction failed." << LL_ENDL;
+        return LLSettingsDay::ptr_t();
+    }
+
     LLEnvironment::namedSettingMap_t skys;
 
     for (LLSD::map_iterator itm = skydefs.beginMap(); itm != skydefs.endMap(); ++itm)
@@ -444,6 +478,12 @@ LLSettingsDay::ptr_t LLSettingsVODay::buildFromLegacyMessage(const LLUUID &regio
         std::string name = (*itm).first;
         LLSettingsSky::ptr_t sky = LLSettingsVOSky::buildFromLegacyPreset(name, (*itm).second);
 
+        if (!sky)
+        {
+            LL_WARNS("WindlightCaps") << "Sky construction failed." << LL_ENDL;
+            return LLSettingsDay::ptr_t();
+        }
+
         skys[name] = sky;
         LL_WARNS("WindlightCaps") << "created region sky '" << name << "'" << LL_ENDL;
     }
@@ -468,12 +508,7 @@ LLSettingsDay::ptr_t LLSettingsVODay::buildFromLegacyMessage(const LLUUID &regio
 
     dayp->setInitialized();
 
-    if (dayp->validate())
-    {
-        return dayp;
-    }
-
-    return LLSettingsDay::ptr_t();
+    return dayp;
 }
 
 LLSettingsDay::ptr_t LLSettingsVODay::buildDefaultDayCycle()
@@ -481,28 +516,34 @@ LLSettingsDay::ptr_t LLSettingsVODay::buildDefaultDayCycle()
     LLSD settings = LLSettingsDay::defaults();
     settings[SETTING_NAME] = std::string("_default_");
 
-    LLSettingsDay::ptr_t dayp = boost::make_shared<LLSettingsVODay>(settings);
-
-    if (dayp->validate())
+    LLSettingsDay::validation_list_t validations = LLSettingsDay::validationList();
+    LLSD results = LLSettingsDay::settingValidation(settings, validations);
+    if (!results["success"].asBoolean())
     {
-        dayp->initialize();
-        return dayp;
+        LL_WARNS("SETTINGS") << "Day setting validation failed!\n" << results << LL_ENDL;
+        LLSettingsDay::ptr_t();
     }
 
-    return LLSettingsDay::ptr_t();
+    LLSettingsDay::ptr_t dayp = boost::make_shared<LLSettingsVODay>(settings);
+
+    dayp->initialize();
+    return dayp;
 }
 
 LLSettingsDay::ptr_t LLSettingsVODay::buildFromEnvironmentMessage(LLSD settings)
 {
-    LLSettingsDay::ptr_t dayp = boost::make_shared<LLSettingsVODay>(settings);
-
-    if (dayp->validate())
+    LLSettingsDay::validation_list_t validations = LLSettingsDay::validationList();
+    LLSD results = LLSettingsDay::settingValidation(settings, validations);
+    if (!results["success"].asBoolean())
     {
-        dayp->initialize();
-        return dayp;
+        LL_WARNS("SETTINGS") << "Day setting validation failed!\n" << results << LL_ENDL;
+        LLSettingsDay::ptr_t();
     }
 
-    return LLSettingsDay::ptr_t();
+    LLSettingsDay::ptr_t dayp = boost::make_shared<LLSettingsVODay>(settings);
+
+    dayp->initialize();
+    return dayp;
 }
 
 
@@ -510,6 +551,15 @@ LLSettingsDay::ptr_t LLSettingsVODay::buildClone()
 {
     LLSD settings = cloneSettings();
 
+    LLSettingsDay::validation_list_t validations = LLSettingsDay::validationList();
+    LLSD results = LLSettingsDay::settingValidation(settings, validations);
+    if (!results["success"].asBoolean())
+    {
+        LL_WARNS("SETTINGS") << "Water setting validation failed!\n" << results << LL_ENDL;
+        LLSettingsDay::ptr_t();
+    }
+
+
     LLSettingsDay::ptr_t dayp = boost::make_shared<LLSettingsVODay>(settings);
 
     return dayp;
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 a11b9b2d8b95dc25817c87957a208847a5610030..21518338ff02ad8c7955e31618bcb213a3062277 100644
--- a/indra/newview/skins/default/xui/en/panel_region_environment.xml
+++ b/indra/newview/skins/default/xui/en/panel_region_environment.xml
@@ -10,8 +10,8 @@
     name="panel_env_info"
     width="530"> 
     <layout_stack 
-            left="0"
-            top="0"
+            left_offset="0"
+            top_offset="0"
             width="420"
             height="250"
             follows="left|right|top|bottom"
@@ -23,9 +23,9 @@
                 min_height="130"
                 background_visible="false">
             <layout_stack 
-                    left="5"
-                    top="5"
-                    right="-5"
+                    left_offset="5"
+                    top_offset="5"
+                    right_offset="-5"
                     follows="left|right|top|bottom"
                     orientation="horizontal">
                 <layout_panel 
@@ -59,11 +59,11 @@
                                 name="use_custom_setting"/>
                     </radio_group>
                     <button
-                            follows="top|left"
+                            follows="top|right"
                             height="23"
                             label="Edit Custom"
-                            left_delta="30"
-                            bottom_delta="30"
+                            right_offset="30"
+                            bottom_offset="30"
                             width="100"
                             name="edit_btn"/>
 
@@ -143,10 +143,10 @@
                 </layout_panel>
             </layout_stack>
         </layout_panel>
-        <layout_panel name="flex"
+        <layout_panel 
                 auto_resize="true"
                 user_resize="true"
-                height="11"
+                height="21"
                 min_height="0"
                 background_visible="false">
     <check_box
@@ -154,20 +154,20 @@
         height="16"
         label="Parcel Owners May Override"
         layout="topleft"
-        left="10"
-        top="10"
+        left_offset="10"
+        top_offset="10"
         name="allow_override_chk"
         width="200" />
     <button
-        follows="bottom|left"
+        follows="top|left"
         height="23"
         label="Apply"
-        right="-160"
-        bottom="-30"
+        left_offset="160"
+        top_offset="60"
         name="apply_btn"
         width="100" />
     <button
-        follows="bottom|left"
+        follows="top|left"
         height="23"
         label="Cancel"
         layout="topleft"