diff --git a/indra/newview/llpaneleditwearable.cpp b/indra/newview/llpaneleditwearable.cpp
index 557fb399be0128f1d4967e4632e932fa9c8be4cc..5ad68ea4db7d7cf3ccd4402fbe5fa9eefe951c96 100644
--- a/indra/newview/llpaneleditwearable.cpp
+++ b/indra/newview/llpaneleditwearable.cpp
@@ -50,6 +50,7 @@
 #include "llaccordionctrltab.h"
 #include "llagentwearables.h"
 #include "llscrollingpanelparam.h"
+#include "llradiogroup.h"
 
 #include "llcolorswatch.h"
 #include "lltexturectrl.h"
@@ -615,6 +616,8 @@ BOOL LLPanelEditWearable::postBuild()
 	mPanelTitle = getChild<LLTextBox>("edit_wearable_title");
 	mDescTitle = getChild<LLTextBox>("description_text");
 
+	getChild<LLRadioGroup>("sex_radio")->setCommitCallback(boost::bind(&LLPanelEditWearable::onCommitSexChange, this));
+
 	// The following panels will be shown/hidden based on what wearable we're editing
 	// body parts
 	mPanelShape = getChild<LLPanel>("edit_shape_panel");
@@ -687,6 +690,40 @@ void LLPanelEditWearable::onRevertButtonClicked(void* userdata)
 	panel->revertChanges();
 }
 
+
+void LLPanelEditWearable::onCommitSexChange()
+{
+	if (!isAgentAvatarValid()) return;
+
+	LLWearableType::EType type = mWearablePtr->getType();
+	U32 index = gAgentWearables.getWearableIndex(mWearablePtr);
+
+	if( !gAgentWearables.isWearableModifiable(type, index))
+	{
+		return;
+	}
+
+	LLViewerVisualParam* param = static_cast<LLViewerVisualParam*>(gAgentAvatarp->getVisualParam( "male" ));
+	if( !param )
+	{
+		return;
+	}
+
+	bool is_new_sex_male = (gSavedSettings.getU32("AvatarSex") ? SEX_MALE : SEX_FEMALE) == SEX_MALE;
+	LLWearable*	wearable = gAgentWearables.getWearable(type, index);
+	if (wearable)
+	{
+		wearable->setVisualParamWeight(param->getID(), is_new_sex_male, FALSE);
+	}
+	param->setWeight( is_new_sex_male, FALSE );
+
+	gAgentAvatarp->updateSexDependentLayerSets( FALSE );
+
+	gAgentAvatarp->updateVisualParams();
+
+	updateScrollingPanelUI();
+}
+
 void LLPanelEditWearable::onTexturePickerCommit(const LLUICtrl* ctrl)
 {
 	const LLTextureCtrl* texture_ctrl = dynamic_cast<const LLTextureCtrl*>(ctrl);
@@ -1118,6 +1155,14 @@ void LLPanelEditWearable::updateVerbs()
 
 	mBtnRevert->setEnabled(is_dirty);
 	childSetEnabled("save_as_button", is_dirty && can_copy);
+
+	if(isAgentAvatarValid())
+	{
+		// Update viewer's radio buttons (of RadioGroup with control_name="AvatarSex") of Avatar's gender
+		// with value from "AvatarSex" setting
+		gSavedSettings.setU32("AvatarSex", (gAgentAvatarp->getSex() == SEX_MALE) );
+	}
+
 }
 
 // EOF
diff --git a/indra/newview/llpaneleditwearable.h b/indra/newview/llpaneleditwearable.h
index a5a332019d42adad3b8b7139eaa1dddbbb3668b4..04839ca4514c618785045bc7fc210557e9423c31 100644
--- a/indra/newview/llpaneleditwearable.h
+++ b/indra/newview/llpaneleditwearable.h
@@ -64,6 +64,7 @@ class LLPanelEditWearable : public LLPanel
 	void				revertChanges();
 
 	static void			onRevertButtonClicked(void* userdata);
+	void				onCommitSexChange();
 
 private:
 	typedef std::map<F32, LLViewerVisualParam*> value_map_t;
diff --git a/indra/newview/skins/default/xui/en/panel_edit_wearable.xml b/indra/newview/skins/default/xui/en/panel_edit_wearable.xml
index afcd4550ca02dc42aa1d00f6a30e492e22fbf0a6..40fcc1d76ce9851f598d4a77892ca4b58e406edf 100644
--- a/indra/newview/skins/default/xui/en/panel_edit_wearable.xml
+++ b/indra/newview/skins/default/xui/en/panel_edit_wearable.xml
@@ -175,6 +175,7 @@ left="0"
 		 value="Shape:"
 		 width="150" />
 		 <radio_group
+			 control_name="AvatarSex"
 			 follows="left|top|right"
 			 left="210"
 			 height="20"
@@ -190,6 +191,7 @@ left="0"
 				 left="0"
 				 name="sex_male"
 				 tool_tip="Male"
+				 value="1"
 				 width="40" />
 			 <radio_item
 				 follows="all"
@@ -199,6 +201,7 @@ left="0"
 				 left_pad="10"
 				 name="sex_female"
 				 tool_tip="Female"
+				 value="0"
 				 width="40" />
 		 </radio_group>
 		 <!--  graphical labels for the radio buttons above -->