quest item_change_sex begin
	state start begin
		when 71048.use begin 
			if pc.get_level() < 50 then 
				say_title(gameforge.change_empire._50_sayTitle)
				say(gameforge.item_change_sex._10_sayReward)
				return
			end
			
			if pc.is_engaged() then
				say_title(gameforge.change_empire._50_sayTitle)
				say(gameforge.item_change_sex._30_sayReward)
				return
			end

			if pc.is_married() then
				say_title(gameforge.change_empire._50_sayTitle)
				say(gameforge.item_change_sex._30_sayReward)
				return
			end

			if pc.is_polymorphed() then
				say_title(gameforge.change_empire._50_sayTitle)
				say(gameforge.item_change_sex._60_sayReward)
				return
			end

			if get_time() < pc.getqf("next_time") then
				say_title(gameforge.change_empire._50_sayTitle)
				say(gameforge.item_change_sex._80_sayReward)
				say(gameforge.item_change_sex._90_say)

				if pc.is_gm() then
					say(string.format(gameforge.item_change_sex._100_say, time_to_str(pc.getqf("next_time"))))
					say(gameforge.item_change_sex._110_say)
					local s =  select(gameforge.locale.guild.yes, gameforge.locale.guild.no)
					if s == 1 then
						say(gameforge.change_empire._80_say)
						pc.setqf("next_time", 0)
					end
				end
				return

			end

			say_title(gameforge.item_change_sex._120_sayTitle)
			say(gameforge.item_change_sex._130_say)
			wait()
			say_title(gameforge.item_change_sex._120_sayTitle)
			say(gameforge.item_change_sex._140_say)
			local s= select(gameforge.locale.guild.yes, gameforge.locale.guild.no)

			if 1==s then
				say_title(gameforge.item_change_sex._120_sayTitle)
				say(gameforge.item_change_sex._150_say)
				say_reward(gameforge.change_empire._230_sayReward)
				
				pc.remove_item("71048",1)
				pc.setqf("next_time", get_time() + 86400 * 3)

				pc.change_sex()

				local m_sex = pc.get_sex()

				if m_sex == 0 then
				    char_log(0, "CHANGE_SEX", "F -> M")
				else
				    char_log(0, "CHANGE_SEX", "M -> F")
				end

			elseif 2==s then
				say(gameforge.item_change_sex._160_say)
			end
		end
	end
end		


