code:
:: organFarmOptions [nobr]

<<set _newOrgan = {type: "0", weeksToCompletion: "0", ID: 0}>>
<<set $slaveOrgans = {
	penis: 0,
	testicles: 0,
	scrotum: 0,
	pigTesticles: 0,
	dogTesticles: 0,
	foreskin: 0,
	ovaries: 0,
	freshOvaries: 0,
	prostate: 0,
	pigOvaries: 0,
	dogOvaries: 0,
	eyes: 0,
	voicebox: 0,
	mpreg: 0,
	mpregPig: 0,
	mpregDog: 0}>>
<<for _i = 0; _i < $organs.length; _i++>>
	<<if $activeSlave.ID == $organs[_i].ID>>
		<<if $organs[_i].type == "penis">>
			<<set $slaveOrgans.penis = 1>>
		<<elseif $organs[_i].type == "testicles">>
			<<set $slaveOrgans.testicles = 1>>
		<<elseif $organs[_i].type == "scrotum">>
			<<set $slaveOrgans.scrotum = 1>>
		<<elseif $organs[_i].type == "pigTesticles">>
			<<set $slaveOrgans.pigTesticles = 1>>
		<<elseif $organs[_i].type == "dogTesticles">>
			<<set $slaveOrgans.dogTesticles = 1>>
		<<elseif $organs[_i].type == "foreskin">>
			<<set $slaveOrgans.foreskin = 1>>
		<<elseif $organs[_i].type == "ovaries">>
			<<set $slaveOrgans.ovaries = 1>>
		<<elseif $organs[_i].type == "prostate">>
			<<set $slaveOrgans.prostate = 1>>
		<<elseif $organs[_i].type == "pigOvaries">>
			<<set $slaveOrgans.pigOvaries = 1>>
		<<elseif $organs[_i].type == "dogOvaries">>
			<<set $slaveOrgans.dogOvaries = 1>>
		<<elseif $organs[_i].type == "eyes">>
			<<set $slaveOrgans.eyes = 1>>
		<<elseif $organs[_i].type == "voicebox">>
			<<set $slaveOrgans.voicebox = 1>>
		<<elseif $organs[_i].type == "mpreg">>
			<<set $slaveOrgans.mpreg = 1>>
		<<elseif $organs[_i].type == "mpregPig">>
			<<set $slaveOrgans.mpregPig = 1>>
		<<elseif $organs[_i].type == "mpregDog">>
			<<set $slaveOrgans.mpregDog = 1>>
		<<elseif $organs[_i].type == "freshOvaries">>
			<<set $slaveOrgans.freshOvaries = 1>>
		<</if>>
	<</if>>
<</for>>

The fabricator is ready to grow an organ for $object. Extract tissue to begin growing:
<<if $seeDicks != 0 || $makeDicks == 1>>
	<<if $slaveOrgans.penis != 1>>

		<<link "Penis">>
			<<set $cash -= 5000>>
			<<set _newOrgan = {type: "penis", weeksToCompletion: "5", ID: 0}>>
			<<set _newOrgan.ID = $activeSlave.ID>>
			<<set $organs.push(_newOrgan)>>
			<<goto "Remote Surgery">>
		<</link>> //Costs <<print cashFormat(5000)>> and will add a prostate if one is not already present//
	<</if>>
	<<if $slaveOrgans.testicles != 1>>

		<<link "Testicles">>
			<<set $cash -= 5000>>
			<<set _newOrgan = {type: "testicles", weeksToCompletion: "10", ID: 0}>>
			<<set _newOrgan.ID = $activeSlave.ID>>
			<<set $organs.push(_newOrgan)>>
			<<goto "Remote Surgery">>
		<</link>> //Costs <<print cashFormat(5000)>> and will add a prostate if one is not already present; requires a penis for successful implantation//
	<</if>>
	<<if $slaveOrgans.scrotum != 1>>
		<<if $activeSlave.scrotum == 0>>

			<<link "Scrotum">>
				<<set $cash -= 2500>>
				<<set _newOrgan = {type: "scrotum", weeksToCompletion: "5", ID: 0}>>
				<<set _newOrgan.ID = $activeSlave.ID>>
				<<set $organs.push(_newOrgan)>>
				<<goto "Remote Surgery">>
			<</link>> //Costs <<print cashFormat(2500)>> and requires balls for successful implantation//
		<</if>>
	<</if>>
	<<if $animalParts != 0>>
		<<if $slaveOrgans.pigTesticles != 1>>

			<<link "Pig testicles">>
				<<set $cash -= 5000>>
				<<set _newOrgan = {type: "pigTesticles", weeksToCompletion: "10", ID: 0}>>
				<<set _newOrgan.ID = $activeSlave.ID>>
				<<set $organs.push(_newOrgan)>>
				<<goto "Remote Surgery">>
			<</link>> //Costs <<print cashFormat(5000)>> and requires a penis for successful implantation//
		<</if>>
		<<if $slaveOrgans.dogTesticles != 1>>

			<<link "Dog testicles">>
				<<set $cash -= 5000>>
				<<set _newOrgan = {type: "dogTesticles", weeksToCompletion: "10", ID: 0}>>
				<<set _newOrgan.ID = $activeSlave.ID>>
				<<set $organs.push(_newOrgan)>>
				<<goto "Remote Surgery">>
			<</link>> //Costs <<print cashFormat(5000)>> and requires a penis for successful implantation//
		<</if>>
	<</if>>
	<<if $slaveOrgans.foreskin != 1>>
		<<if $activeSlave.foreskin <= 0>>

			<<link "Foreskin">>
				<<set $cash -= 2500>>
				<<set _newOrgan = {type: "foreskin", weeksToCompletion: "5", ID: 0}>>
				<<set _newOrgan.ID = $activeSlave.ID>>
				<<set $organs.push(_newOrgan)>>
				<<goto "Remote Surgery">>
			<</link>> //Costs <<print cashFormat(2500)>>//
		<</if>>
	<</if>>
<</if>>
<<if $slaveOrgans.prostate != 1>>

	<<link "Prostate">>
		<<set $cash -= 5000>>
		<<set _newOrgan = {type: "prostate", weeksToCompletion: "5", ID: 0}>>
		<<set _newOrgan.ID = $activeSlave.ID>>
		<<set $organs.push(_newOrgan)>>
		<<goto "Remote Surgery">>
	<</link>> //Costs <<print cashFormat(5000)>> and does not require the presence any specific organ for successful implantation//
<</if>>
<<if $slaveOrgans.ovaries != 1>>

	<<link "Ovaries">>
		<<set $cash -= 10000>>
		<<set _newOrgan = {type: "ovaries", weeksToCompletion: "10", ID: 0}>>
		<<set _newOrgan.ID = $activeSlave.ID>>
		<<set $organs.push(_newOrgan)>>
		<<goto "Remote Surgery">>
	<</link>> //Costs <<print cashFormat(10000)>> and requires a vagina for successful implantation//
<</if>>
<<if $animalParts != 0>>
	<<if $slaveOrgans.pigOvaries != 1>>

			<<link "Pig ovaries">>
			<<set $cash -= 10000>>
			<<set _newOrgan = {type: "pigOvaries", weeksToCompletion: "10", ID: 0}>>
			<<set _newOrgan.ID = $activeSlave.ID>>
			<<set $organs.push(_newOrgan)>>
			<<goto "Remote Surgery">>
		<</link>> //Costs <<print cashFormat(10000)>> and requires a vagina for successful implantation//
	<</if>>
	<<if $slaveOrgans.dogOvaries != 1>>

		<<link "Dog ovaries">>
			<<set $cash -= 10000>>
			<<set _newOrgan = {type: "dogOvaries", weeksToCompletion: "10", ID: 0}>>
			<<set _newOrgan.ID = $activeSlave.ID>>
			<<set $organs.push(_newOrgan)>>
			<<goto "Remote Surgery">>
		<</link>> //Costs <<print cashFormat(10000)>> and requires a vagina for successful implantation//
	<</if>>
<</if>>
<<if $youngerOvaries == 1>>
	<<if $slaveOrgans.freshOvaries != 1>>

		<<link "Younger Ovaries">>
			<<set $cash -= 10000>>
			<<set _newOrgan = {type: "freshOvaries", weeksToCompletion: "10", ID: 0}>>
			<<set _newOrgan.ID = $activeSlave.ID>>
			<<set $organs.push(_newOrgan)>>
			<<goto "Remote Surgery">>
		<</link>> //Costs <<print cashFormat(10000)>> and requires a womb for successful implantation//
	<</if>>
<</if>>
<<if $slaveOrgans.eyes != 1>>
	<<if $activeSlave.eyes <= -2 && $activeSlave.eyes != "implant">>

		<<link "Eyes">>
			<<set $cash -= 10000>>
			<<set _newOrgan = {type: "eyes", weeksToCompletion: "10", ID: 0}>>
			<<set _newOrgan.ID = $activeSlave.ID>>
			<<set $organs.push(_newOrgan)>>
			<<goto "Remote Surgery">>
		<</link>> //Costs <<print cashFormat(10000)>> and is imperfect - eyes will lack natural color//
	<</if>>
<</if>>
<<if $slaveOrgans.voicebox != 1>>
	<<if ($activeSlave.voice == 0)>>

		<<link "Vocal cords">>
			<<set $cash -= 5000>>
			<<set _newOrgan = {type: "voicebox", weeksToCompletion: "5", ID: 0}>>
			<<set _newOrgan.ID = $activeSlave.ID>>
			<<set $organs.push(_newOrgan)>>
			<<goto "Remote Surgery">>
		<</link>> //Costs <<print cashFormat(5000)>>//
	<</if>>
<</if>>
<<if $arcologies[0].FSGenderRadicalistResearch == 1>>
	<<if $slaveOrgans.mpreg != 1>>

		<<link "Anal womb and ovaries">>
			<<set $cash -= 20000>>
			<<set _newOrgan = {type: "mpreg", weeksToCompletion: "10", ID: 0}>>
			<<set _newOrgan.ID = $activeSlave.ID>>
			<<set $organs.push(_newOrgan)>>
			<<goto "Remote Surgery">>
		<</link>> //Costs <<print cashFormat(20000)>> and the slave must not have female reproductive organs for successful implantation//
	<</if>>
	<<if $animalParts != 0>>
		<<if $slaveOrgans.mpregPig != 1>>

			<<link "Anal pig womb and ovaries">>
				<<set $cash -= 20000>>
				<<set _newOrgan = {type: "mpregPig", weeksToCompletion: "10", ID: 0}>>
				<<set _newOrgan.ID = $activeSlave.ID>>
				<<set $organs.push(_newOrgan)>>
				<<goto "Remote Surgery">>
			<</link>> //Costs <<print cashFormat(20000)>> and the slave must not have female reproductive organs for successful implantation//
		<</if>>
		<<if $slaveOrgans.mpregDog != 1>>

			<<link "Anal dog womb and ovaries">>
				<<set $cash -= 20000>>
				<<set _newOrgan = {type: "mpregDog", weeksToCompletion: "10", ID: 0}>>
				<<set _newOrgan.ID = $activeSlave.ID>>
				<<set $organs.push(_newOrgan)>>
				<<goto "Remote Surgery">>
			<</link>> //Costs <<print cashFormat(20000)>> and the slave must not have female reproductive organs for successful implantation//
		<</if>>
	<</if>>
<</if>>

<<if $organs.length > 0>>
	<<for _i = 0; _i < $organs.length; _i++>>
		<<if $organs[_i].ID == $activeSlave.ID>>

			$possessiveCap
			<<switch $organs[_i].type>>
			<<case "penis" "scrotum" "foreskin" "prostate" "voicebox">>
				$organs[_i].type is
			<<case "testicles" "ovaries" "eyes">>
				$organs[_i].type are
			<<case "pigTesticles">>
				pig testicles are
			<<case "dogTesticles">>
				dog testicles are
			<<case "freshOvaries">>
				revitalized ovaries are
			<<case "pigOvaries">>
				pig ovaries are
			<<case "dogOvaries">>
				dog ovaries are
			<<case "mpreg">>
				anal womb and ovaries are
			<<case "mpregPig">>
				anal womb and pig ovaries are
			<<case "mpregDog">>
				anal womb and dog ovaries are
			<</switch>>
			expected to be ready in <<if $organFarmUpgrade == 1>><<print $organs[_i].weeksToCompletion>><<elseif $organFarmUpgrade == 2>><<print Math.ceil($organs[_i].weeksToCompletion/2)>><<elseif $organFarmUpgrade == 3>><<print Math.ceil($organs[_i].weeksToCompletion/4)>><</if>> weeks.
		<</if>>
	<</for>>
<</if>>

<<if $completedOrgans.length > 0>>
	<<for _i = 0; _i < $completedOrgans.length; _i++>>
		<<if $completedOrgans[_i].ID == $activeSlave.ID>>

The fabricator has completed $possessive $completedOrgans[_i].type.
			<<if $completedOrgans[_i].type == "penis">>
				<<if $activeSlave.dick > 0>>

					ERROR: this slave already has a penis.
					<<link "Discard" "Remote Surgery">>
						<<set _ofo = $completedOrgans.findIndex(function(s) { return $activeSlave.ID == s.ID && s.type == "penis"; })>>
						<<if _ofo != -1>>
							<<set $completedOrgans.deleteAt(_ofo)>>
						<<else>>
							@@.red;Organ not found for deletion!@@
						<</if>>
					<</link>>
				<<else>>

					<<link "Implant" "Surgery Degradation">>
						<<set $cash -= $surgeryCost>>
						<<set _ofo = $completedOrgans.findIndex(function(s) { return $activeSlave.ID == s.ID && s.type == "penis"; })>>
						<<if _ofo != -1>>
							<<set $completedOrgans.deleteAt(_ofo)>>
						<<else>>
							@@.red;Organ not found for deletion!@@
						<</if>>
						<<if $activeSlave.prostate == 0>>
							<<set $activeSlave.prostate = 1>>
						<</if>>
						<<set $activeSlave.dick = 2>>
						<<set $activeSlave.clit = 0>>
						<<set $activeSlave.foreskin = $activeSlave.dick>>
						<<set $activeSlave.health -= 20>>
						<<if $organFarmUpgrade == 2>>
							<<set $activeSlave.chem += 20>>
						<</if>>
						<<set $surgeryType = "addDick">>
					<</link>>
					|
					<<link "Discard" "Remote Surgery">>
						<<set _ofo = $completedOrgans.findIndex(function(s) { return $activeSlave.ID == s.ID && s.type == "penis"; })>>
						<<if _ofo != -1>>
							<<set $completedOrgans.deleteAt(_ofo)>>
						<<else>>
							@@.red;Organ not found for deletion!@@
						<</if>>
					<</link>>
				<</if>>
			<<elseif $completedOrgans[_i].type == "testicles">>
				<<if $activeSlave.balls > 0>>

					ERROR: this slave already has testicles.
					<<link "Discard" "Remote Surgery">>
						<<set _ofo = $completedOrgans.findIndex(function(s) { return $activeSlave.ID == s.ID && s.type == "testicles"; })>>
						<<if _ofo != -1>>
							<<set $completedOrgans.deleteAt(_ofo)>>
						<<else>>
							@@.red;Organ not found for deletion!@@
						<</if>>
					<</link>>
				<<elseif $activeSlave.dick == 0>>

					ERROR: this slave lacks the penis necessary to accept testicles.
					<<link "Discard" "Remote Surgery">>
						<<set _ofo = $completedOrgans.findIndex(function(s) { return $activeSlave.ID == s.ID && s.type == "testicles"; })>>
						<<if _ofo != -1>>
							<<set $completedOrgans.deleteAt(_ofo)>>
						<<else>>
							@@.red;Organ not found for deletion!@@
						<</if>>
					<</link>>

You can forgo standard procedure and implant testicles directly into $possessive abdomen.
					<<link "Implant" "Surgery Degradation">>
						<<set $cash -= $surgeryCost>>
						<<set _ofo = $completedOrgans.findIndex(function(s) { return $activeSlave.ID == s.ID && s.type == "testicles"; })>>
						<<if _ofo != -1>>
							<<set $completedOrgans.deleteAt(_ofo)>>
						<<else>>
							@@.red;Organ not found for deletion!@@
						<</if>>
						<<if $activeSlave.prostate < 1>><<set $activeSlave.prostate = 1>><</if>>
						<<set $activeSlave.balls = 2>>
						<<set $activeSlave.ballType = "human">>
						<<set $activeSlave.health -= 20>>
						<<if $organFarmUpgrade == 2>>
							<<set $activeSlave.chem += 20>>
						<</if>>
						<<if $activeSlave.pubertyXY == 0>>
							<<if $precociousPuberty == 1>>
								<<if $activeSlave.physicalAge >= $potencyAge>>
									<<set $activeSlave.pubertyAgeXY = ($activeSlave.physicalAge+1)>>
								<</if>>
							<<else>>
								<<if $activeSlave.physicalAge >= $potencyAge>>
									<<set $activeSlave.pubertyXY = 1>>
								<</if>>
							<</if>>
						<</if>>
						<<set $surgeryType = "addTesticles">>
					<</link>>
				<<else>>

					<<link "Implant" "Surgery Degradation">>
						<<set $cash -= $surgeryCost>>
						<<set _ofo = $completedOrgans.findIndex(function(s) { return $activeSlave.ID == s.ID && s.type == "testicles"; })>>
						<<if _ofo != -1>>
							<<set $completedOrgans.deleteAt(_ofo)>>
						<<else>>
							@@.red;Organ not found for deletion!@@
						<</if>>
						<<if $activeSlave.prostate == 0>>
							<<set $activeSlave.prostate = 1>>
						<</if>>
						<<set $activeSlave.balls = 2>>
						<<set $activeSlave.ballType = "human">>
						<<set $activeSlave.scrotum = 2>>
						<<set $activeSlave.health -= 20>>
						<<if $organFarmUpgrade == 2>>
							<<set $activeSlave.chem += 20>>
						<</if>>
						<<if $activeSlave.pubertyXY == 0>>
							<<if $precociousPuberty == 1>>
								<<if $activeSlave.physicalAge >= $potencyAge>>
									<<set $activeSlave.pubertyAgeXY = ($activeSlave.physicalAge+1)>>
								<</if>>
							<<else>>
								<<if $activeSlave.physicalAge >= $potencyAge>>
									<<set $activeSlave.pubertyXY = 1>>
								<</if>>
							<</if>>
						<</if>>
						<<set $surgeryType = "addBalls">>
					<</link>>
					|
					<<link "Discard" "Remote Surgery">>
						<<set _ofo = $completedOrgans.findIndex(function(s) { return $activeSlave.ID == s.ID && s.type == "testicles"; })>>
						<<if _ofo != -1>>
							<<set $completedOrgans.deleteAt(_ofo)>>
						<<else>>
							@@.red;Organ not found for deletion!@@
						<</if>>
					<</link>>
				<</if>>
			<<elseif $completedOrgans[_i].type == "pigTesticles">>
				<<if $activeSlave.balls > 0>>

					ERROR: this slave already has testicles.
					<<link "Discard" "Remote Surgery">>
						<<set _ofo = $completedOrgans.findIndex(function(s) { return $activeSlave.ID == s.ID && s.type == "pigTesticles"; })>>
						<<if _ofo != -1>>
							<<set $completedOrgans.deleteAt(_ofo)>>
						<<else>>
							@@.red;Organ not found for deletion!@@
						<</if>>
					<</link>>
				<<elseif $activeSlave.dick == 0>>

					ERROR: this slave lacks the penis necessary to accept testicles.
					<<link "Discard" "Remote Surgery">>
						<<set _ofo = $completedOrgans.findIndex(function(s) { return $activeSlave.ID == s.ID && s.type == "pigTesticles"; })>>
						<<if _ofo != -1>>
							<<set $completedOrgans.deleteAt(_ofo)>>
						<<else>>
							@@.red;Organ not found for deletion!@@
						<</if>>
					<</link>>

You can forgo standard procedure and implant testicles directly into $possessive abdomen.
					<<link "Implant" "Surgery Degradation">>
						<<set $cash -= $surgeryCost>>
						<<set _ofo = $completedOrgans.findIndex(function(s) { return $activeSlave.ID == s.ID && s.type == "pigTesticles"; })>>
						<<if _ofo != -1>>
							<<set $completedOrgans.deleteAt(_ofo)>>
						<<else>>
							@@.red;Organ not found for deletion!@@
						<</if>>
						<<if $activeSlave.prostate < 1>><<set $activeSlave.prostate = 1>><</if>>
						<<set $activeSlave.balls = 2>>
						<<set $activeSlave.ballType = "pig">>
						<<set $activeSlave.health -= 20>>
						<<if $organFarmUpgrade == 2>>
							<<set $activeSlave.chem += 20>>
						<</if>>
						<<if $activeSlave.pubertyXY == 0>>
							<<if $precociousPuberty == 1>>
								<<if $activeSlave.physicalAge >= $potencyAge>>
									<<set $activeSlave.pubertyAgeXY = ($activeSlave.physicalAge+1)>>
								<</if>>
							<<else>>
								<<if $activeSlave.physicalAge >= $potencyAge>>
									<<set $activeSlave.pubertyXY = 1>>
								<</if>>
							<</if>>
						<</if>>
						<<set $surgeryType = "addPigBalls">>
					<</link>>
				<<else>>

					<<link "Implant" "Surgery Degradation">>
						<<set $cash -= $surgeryCost>>
						<<set _ofo = $completedOrgans.findIndex(function(s) { return $activeSlave.ID == s.ID && s.type == "pigTesticles"; })>>
						<<if _ofo != -1>>
							<<set $completedOrgans.deleteAt(_ofo)>>
						<<else>>
							@@.red;Organ not found for deletion!@@
						<</if>>
						<<set $activeSlave.balls = 3>>
						<<set $activeSlave.scrotum = 3>>
						<<set $activeSlave.ballType = "pig">>
						<<set $activeSlave.health -= 20>>
						<<if $organFarmUpgrade == 2>>
							<<set $activeSlave.chem += 20>>
						<</if>>
						<<if $activeSlave.pubertyXY == 0>>
							<<if $precociousPuberty == 1>>
								<<if $activeSlave.physicalAge >= $potencyAge>>
									<<set $activeSlave.pubertyAgeXY = ($activeSlave.physicalAge+1)>>
								<</if>>
							<<else>>
								<<if $activeSlave.physicalAge >= $potencyAge>>
									<<set $activeSlave.pubertyXY = 1>>
								<</if>>
							<</if>>
						<</if>>
						<<set $surgeryType = "addPigBalls">>
					<</link>>
					|
					<<link "Discard" "Remote Surgery">>
						<<set _ofo = $completedOrgans.findIndex(function(s) { return $activeSlave.ID == s.ID && s.type == "pigTesticles"; })>>
						<<if _ofo != -1>>
							<<set $completedOrgans.deleteAt(_ofo)>>
						<<else>>
							@@.red;Organ not found for deletion!@@
						<</if>>
					<</link>>
				<</if>>
			<<elseif $completedOrgans[_i].type == "dogTesticles">>
				<<if $activeSlave.balls > 0>>

					ERROR: this slave already has testicles.
					<<link "Discard" "Remote Surgery">>
						<<set _ofo = $completedOrgans.findIndex(function(s) { return $activeSlave.ID == s.ID && s.type == "dogTesticles"; })>>
						<<if _ofo != -1>>
							<<set $completedOrgans.deleteAt(_ofo)>>
						<<else>>
							@@.red;Organ not found for deletion!@@
						<</if>>
					<</link>>
				<<elseif $activeSlave.dick == 0>>

					ERROR: this slave lacks the penis necessary to accept testicles.
					<<link "Discard" "Remote Surgery">>
						<<set _ofo = $completedOrgans.findIndex(function(s) { return $activeSlave.ID == s.ID && s.type == "dogTesticles"; })>>
						<<if _ofo != -1>>
							<<set $completedOrgans.deleteAt(_ofo)>>
						<<else>>
							@@.red;Organ not found for deletion!@@
						<</if>>
					<</link>>

You can forgo standard procedure and implant testicles directly into $possessive abdomen.
					<<link "Implant" "Surgery Degradation">>
						<<set $cash -= $surgeryCost>>
						<<set _ofo = $completedOrgans.findIndex(function(s) { return $activeSlave.ID == s.ID && s.type == "dogTesticles"; })>>
						<<if _ofo != -1>>
							<<set $completedOrgans.deleteAt(_ofo)>>
						<<else>>
							@@.red;Organ not found for deletion!@@
						<</if>>
						<<if $activeSlave.prostate < 1>><<set $activeSlave.prostate = 1>><</if>>
						<<set $activeSlave.balls = 2>>
						<<set $activeSlave.ballType = "dog">>
						<<set $activeSlave.health -= 20>>
						<<if $organFarmUpgrade == 2>>
							<<set $activeSlave.chem += 20>>
						<</if>>
						<<if $activeSlave.pubertyXY == 0>>
							<<if $precociousPuberty == 1>>
								<<if $activeSlave.physicalAge >= $potencyAge>>
									<<set $activeSlave.pubertyAgeXY = ($activeSlave.physicalAge+1)>>
								<</if>>
							<<else>>
								<<if $activeSlave.physicalAge >= $potencyAge>>
									<<set $activeSlave.pubertyXY = 1>>
								<</if>>
							<</if>>
						<</if>>
						<<set $surgeryType = "addDogBalls">>
					<</link>>
				<<else>>

					<<link "Implant">>
						<<set $cash -= $surgeryCost>>
						<<set _ofo = $completedOrgans.findIndex(function(s) { return $activeSlave.ID == s.ID && s.type == "dogTesticles"; })>>
						<<if _ofo != -1>>
							<<set $completedOrgans.deleteAt(_ofo)>>
						<<else>>
							@@.red;Organ not found for deletion!@@
						<</if>>
						<<set $activeSlave.balls = 2>>
						<<set $activeSlave.ballType = "dog">>
						<<set $activeSlave.scrotum = 2>>
						<<set $activeSlave.health -= 20>>
						<<if $organFarmUpgrade == 2>>
							<<set $activeSlave.chem += 20>>
						<</if>>
						<<if $activeSlave.pubertyXY == 0>>
							<<if $precociousPuberty == 1>>
								<<if $activeSlave.physicalAge >= $potencyAge>>
									<<set $activeSlave.pubertyAgeXY = ($activeSlave.physicalAge+1)>>
								<</if>>
							<<else>>
								<<if $activeSlave.physicalAge >= $potencyAge>>
									<<set $activeSlave.pubertyXY = 1>>
								<</if>>
							<</if>>
						<</if>>
						<<set $surgeryType = "addDogBalls">>
						<<goto "Surgery Degradation">>
					<</link>>
					|
					<<link "Discard" "Remote Surgery">>
						<<set _ofo = $completedOrgans.findIndex(function(s) { return $activeSlave.ID == s.ID && s.type == "dogTesticles"; })>>
						<<if _ofo != -1>>
							<<set $completedOrgans.deleteAt(_ofo)>>
						<<else>>
							@@.red;Organ not found for deletion!@@
						<</if>>
					<</link>>
				<</if>>
			<<elseif $completedOrgans[_i].type == "scrotum">>
				<<if $activeSlave.scrotum > 0>>

					ERROR: this slave already has a scrotum.
					<<link "Discard" "Remote Surgery">>
						<<set _ofo = $completedOrgans.findIndex(function(s) { return $activeSlave.ID == s.ID && s.type == "scrotum"; })>>
						<<if _ofo != -1>>
							<<set $completedOrgans.deleteAt(_ofo)>>
						<<else>>
							@@.red;Organ not found for deletion!@@
						<</if>>
					<</link>>
				<<elseif $activeSlave.balls == 0>>

					ERROR: this slave lacks the balls necessary to accept a scrotum.
					<<link "Discard" "Remote Surgery">>
						<<set _ofo = $completedOrgans.findIndex(function(s) { return $activeSlave.ID == s.ID && s.type == "scrotum"; })>>
						<<if _ofo != -1>>
							<<set $completedOrgans.deleteAt(_ofo)>>
						<<else>>
							@@.red;Organ not found for deletion!@@
						<</if>>
					<</link>>
				<<else>>

					<<link "Graft on" "Surgery Degradation">>
						<<set $cash -= $surgeryCost>>
						<<set _ofo = $completedOrgans.findIndex(function(s) { return $activeSlave.ID == s.ID && s.type == "scrotum"; })>>
						<<if _ofo != -1>>
							<<set $completedOrgans.deleteAt(_ofo)>>
						<<else>>
							@@.red;Organ not found for deletion!@@
						<</if>>
						<<set $activeSlave.scrotum = $activeSlave.balls>>
						<<set $activeSlave.health -= 10>>
						<<if $organFarmUpgrade == 2>>
							<<set $activeSlave.chem += 10>>
						<</if>>
						<<set $surgeryType = "addScrotum">>
					<</link>>
					|
					<<link "Discard" "Remote Surgery">>
						<<set _ofo = $completedOrgans.findIndex(function(s) { return $activeSlave.ID == s.ID && s.type == "scrotum"; })>>
						<<if _ofo != -1>>
							<<set $completedOrgans.deleteAt(_ofo)>>
						<<else>>
							@@.red;Organ not found for deletion!@@
						<</if>>
					<</link>>
				<</if>>
			<<elseif $completedOrgans[_i].type == "foreskin">>
				<<if $activeSlave.foreskin > 0>>

					ERROR: this slave already has a <<if $activeSlave.dick > 0>>foreskin<<else>>clitoral hood<</if>>.
					<<link "Discard" "Remote Surgery">>
						<<set _ofo = $completedOrgans.findIndex(function(s) { return $activeSlave.ID == s.ID && s.type == "foreskin"; })>>
						<<if _ofo != -1>>
							<<set $completedOrgans.deleteAt(_ofo)>>
						<<else>>
							@@.red;Organ not found for deletion!@@
						<</if>>
					<</link>>
				<<else>>

					<<link "Graft on" "Surgery Degradation">>
						<<set $cash -= $surgeryCost>>
						<<set _ofo = $completedOrgans.findIndex(function(s) { return $activeSlave.ID == s.ID && s.type == "foreskin"; })>>
						<<if _ofo != -1>>
							<<set $completedOrgans.deleteAt(_ofo)>>
						<<else>>
							@@.red;Organ not found for deletion!@@
						<</if>>
						<<if $activeSlave.dick > 0>>
							<<set $activeSlave.foreskin = $activeSlave.dick>>
						<<else>>
							<<set $activeSlave.foreskin = $activeSlave.clit>>
						<</if>>
						<<set $activeSlave.health -= 10>>
						<<if $organFarmUpgrade == 2>>
							<<set $activeSlave.chem += 10>>
						<</if>>
						<<set $surgeryType = "addForeskin">>
					<</link>>
					|
					<<link "Discard" "Remote Surgery">>
						<<set _ofo = $completedOrgans.findIndex(function(s) { return $activeSlave.ID == s.ID && s.type == "foreskin"; })>>
						<<if _ofo != -1>>
							<<set $completedOrgans.deleteAt(_ofo)>>
						<<else>>
							@@.red;Organ not found for deletion!@@
						<</if>>
					<</link>>
				<</if>>
			<<elseif $completedOrgans[_i].type == "ovaries">>
				<<if $activeSlave.ovaries > 0>>

					ERROR: this slave already has ovaries.
					<<link "Discard" "Remote Surgery">>
						<<set _ofo = $completedOrgans.findIndex(function(s) { return $activeSlave.ID == s.ID && s.type == "ovaries"; })>>
						<<if _ofo != -1>>
							<<set $completedOrgans.deleteAt(_ofo)>>
						<<else>>
							@@.red;Organ not found for deletion!@@
						<</if>>
					<</link>>
				<<elseif $activeSlave.vagina < 0>>

					ERROR: this slave lacks the vagina necessary to accept ovaries.
					<<link "Discard" "Remote Surgery">>
						<<set _ofo = $completedOrgans.findIndex(function(s) { return $activeSlave.ID == s.ID && s.type == "ovaries"; })>>
						<<if _ofo != -1>>
							<<set $completedOrgans.deleteAt(_ofo)>>
						<<else>>
							@@.red;Organ not found for deletion!@@
						<</if>>
					<</link>>
				<<elseif $activeSlave.mpreg != 0 || $activeSlave.bellyImplant != -1>>

					ERROR: this slave's body cavity is filled with another organ.
					<<link "Discard" "Remote Surgery">>
						<<set _ofo = $completedOrgans.findIndex(function(s) { return $activeSlave.ID == s.ID && s.type == "ovaries"; })>>
						<<if _ofo != -1>>
							<<set $completedOrgans.deleteAt(_ofo)>>
						<<else>>
							@@.red;Organ not found for deletion!@@
						<</if>>
					<</link>>
				<<else>>

					<<link "Implant" "Surgery Degradation">>
						<<set $cash -= $surgeryCost>>
						<<set _ofo = $completedOrgans.findIndex(function(s) { return $activeSlave.ID == s.ID && s.type == "ovaries"; })>>
						<<if _ofo != -1>>
							<<set $completedOrgans.deleteAt(_ofo)>>
						<<else>>
							@@.red;Organ not found for deletion!@@
						<</if>>
						<<set $activeSlave.ovaries = 1>>
						<<set $activeSlave.eggType = "human">>
						<<set $activeSlave.preg = 0>>
						<<set $activeSlave.health -= 20>>
						<<if $organFarmUpgrade == 2>>
							<<set $activeSlave.chem += 20>>
						<</if>>
						<<if $activeSlave.pubertyXX == 0>>
							<<if $precociousPuberty == 1>>
								<<if $activeSlave.physicalAge >= $fertilityAge>>
									<<set $activeSlave.pubertyAgeXX = ($activeSlave.physicalAge+1)>>
								<</if>>
							<<else>>
								<<if $activeSlave.physicalAge >= $fertilityAge>>
									<<set $activeSlave.pubertyXX = 1>>
								<</if>>
							<</if>>
						<</if>>
						<<set $surgeryType = "addOvaries">>
					<</link>>
					|
					<<link "Discard" "Remote Surgery">>
						<<set _ofo = $completedOrgans.findIndex(function(s) { return $activeSlave.ID == s.ID && s.type == "ovaries"; })>>
						<<if _ofo != -1>>
							<<set $completedOrgans.deleteAt(_ofo)>>
						<<else>>
							@@.red;Organ not found for deletion!@@
						<</if>>
					<</link>>
				<</if>>
			<<elseif $completedOrgans[_i].type == "pigOvaries">>
				<<if $activeSlave.ovaries > 0>>

					ERROR: this slave already has ovaries.
					<<link "Discard" "Remote Surgery">>
						<<set _ofo = $completedOrgans.findIndex(function(s) { return $activeSlave.ID == s.ID && s.type == "pigOvaries"; })>>
						<<if _ofo != -1>>
							<<set $completedOrgans.deleteAt(_ofo)>>
						<<else>>
							@@.red;Organ not found for deletion!@@
						<</if>>
					<</link>>
				<<elseif $activeSlave.vagina < 0>>

					ERROR: this slave lacks the vagina necessary to accept ovaries.
					<<link "Discard" "Remote Surgery">>
						<<set _ofo = $completedOrgans.findIndex(function(s) { return $activeSlave.ID == s.ID && s.type == "pigOvaries"; })>>
						<<if _ofo != -1>>
							<<set $completedOrgans.deleteAt(_ofo)>>
						<<else>>
							@@.red;Organ not found for deletion!@@
						<</if>>
					<</link>>
				<<elseif $activeSlave.mpreg != 0 || $activeSlave.bellyImplant != -1>>

					ERROR: this slave's body cavity is filled with another organ.
					<<link "Discard" "Remote Surgery">>
						<<set _ofo = $completedOrgans.findIndex(function(s) { return $activeSlave.ID == s.ID && s.type == "pigOvaries"; })>>
						<<if _ofo != -1>>
							<<set $completedOrgans.deleteAt(_ofo)>>
						<<else>>
							@@.red;Organ not found for deletion!@@
						<</if>>
					<</link>>
				<<else>>

					<<link "Implant" "Surgery Degradation">>
						<<set $cash -= $surgeryCost>>
						<<set _ofo = $completedOrgans.findIndex(function(s) { return $activeSlave.ID == s.ID && s.type == "pigOvaries"; })>>
						<<if _ofo != -1>>
							<<set $completedOrgans.deleteAt(_ofo)>>
						<<else>>
							@@.red;Organ not found for deletion!@@
						<</if>>
						<<set $activeSlave.ovaries = 1>>
						<<set $activeSlave.eggType = "pig">>
						<<set $activeSlave.preg = 0>>
						<<set $activeSlave.health -= 20>>
						<<if $organFarmUpgrade == 2>>
							<<set $activeSlave.chem += 20>>
						<</if>>
						<<if $activeSlave.pubertyXX == 0>>
							<<if $precociousPuberty == 1>>
								<<if $activeSlave.physicalAge >= $fertilityAge>>
									<<set $activeSlave.pubertyAgeXX = ($activeSlave.physicalAge+1)>>
								<</if>>
							<<else>>
								<<if $activeSlave.physicalAge >= $fertilityAge>>
									<<set $activeSlave.pubertyXX = 1>>
								<</if>>
							<</if>>
						<</if>>
						<<set $surgeryType = "addPigOvaries">>
					<</link>>
					|
					<<link "Discard" "Remote Surgery">>
						<<set _ofo = $completedOrgans.findIndex(function(s) { return $activeSlave.ID == s.ID && s.type == "pigOvaries"; })>>
						<<if _ofo != -1>>
							<<set $completedOrgans.deleteAt(_ofo)>>
						<<else>>
							@@.red;Organ not found for deletion!@@
						<</if>>
					<</link>>
				<</if>>
			<<elseif $completedOrgans[_i].type == "dogOvaries">>
				<<if $activeSlave.ovaries > 0>>

					ERROR: this slave already has ovaries.
					<<link "Discard" "Remote Surgery">>
						<<set _ofo = $completedOrgans.findIndex(function(s) { return $activeSlave.ID == s.ID && s.type == "dogOvaries"; })>>
						<<if _ofo != -1>>
							<<set $completedOrgans.deleteAt(_ofo)>>
						<<else>>
							@@.red;Organ not found for deletion!@@
						<</if>>
					<</link>>
				<<elseif $activeSlave.vagina < 0>>

					ERROR: this slave lacks the vagina necessary to accept ovaries.
					<<link "Discard" "Remote Surgery">>
						<<set _ofo = $completedOrgans.findIndex(function(s) { return $activeSlave.ID == s.ID && s.type == "dogOvaries"; })>>
						<<if _ofo != -1>>
							<<set $completedOrgans.deleteAt(_ofo)>>
						<<else>>
							@@.red;Organ not found for deletion!@@
						<</if>>
					<</link>>
				<<elseif $activeSlave.mpreg != 0 || $activeSlave.bellyImplant != -1>>

					ERROR: this slave's body cavity is filled with another organ.
					<<link "Discard" "Remote Surgery">>
						<<set _ofo = $completedOrgans.findIndex(function(s) { return $activeSlave.ID == s.ID && s.type == "dogOvaries"; })>>
						<<if _ofo != -1>>
							<<set $completedOrgans.deleteAt(_ofo)>>
						<<else>>
							@@.red;Organ not found for deletion!@@
						<</if>>
					<</link>>
				<<else>>

					<<link "Implant" "Surgery Degradation">>
						<<set $cash -= $surgeryCost>>
						<<set _ofo = $completedOrgans.findIndex(function(s) { return $activeSlave.ID == s.ID && s.type == "dogOvaries"; })>>
						<<if _ofo != -1>>
							<<set $completedOrgans.deleteAt(_ofo)>>
						<<else>>
							@@.red;Organ not found for deletion!@@
						<</if>>
						<<set $activeSlave.ovaries = 1>>
						<<set $activeSlave.eggType = "dog">>
						<<set $activeSlave.preg = 0>>
						<<set $activeSlave.health -= 20>>
						<<if $organFarmUpgrade == 2>>
							<<set $activeSlave.chem += 20>>
						<</if>>
						<<if $activeSlave.pubertyXX == 0>>
							<<if $precociousPuberty == 1>>
								<<if $activeSlave.physicalAge >= $fertilityAge>>
									<<set $activeSlave.pubertyAgeXX = ($activeSlave.physicalAge+1)>>
								<</if>>
							<<else>>
								<<if $activeSlave.physicalAge >= $fertilityAge>>
									<<set $activeSlave.pubertyXX = 1>>
								<</if>>
							<</if>>
						<</if>>
						<<set $surgeryType = "addDogOvaries">>
					<</link>>
					|
					<<link "Discard" "Remote Surgery">>
						<<set _ofo = $completedOrgans.findIndex(function(s) { return $activeSlave.ID == s.ID && s.type == "dogOvaries"; })>>
						<<if _ofo != -1>>
							<<set $completedOrgans.deleteAt(_ofo)>>
						<<else>>
							@@.red;Organ not found for deletion!@@
						<</if>>
					<</link>>
				<</if>>
			<<elseif $completedOrgans[_i].type == "freshOvaries">>
				<<if ($activeSlave.mpreg == 0 && $activeSlave.ovaries == 0) || $activeSlave.bellyImplant != -1>>

					ERROR: this slave lacks a viable womb.
					<<link "Discard" "Remote Surgery">>
						<<set _ofo = $completedOrgans.findIndex(function(s) { return $activeSlave.ID == s.ID && s.type == "freshOvaries"; })>>
						<<if _ofo != -1>>
							<<set $completedOrgans.deleteAt(_ofo)>>
						<<else>>
							@@.red;Organ not found for deletion!@@
						<</if>>
					<</link>>
				<<elseif $activeSlave.physicalAge >= 70>>
					ERROR: this slave's body is too old to handle pregnancy.
					<<link "Discard" "Remote Surgery">>
						<<set _ofo = $completedOrgans.findIndex(function(s) { return $activeSlave.ID == s.ID && s.type == "freshOvaries"; })>>
						<<if _ofo != -1>>
							<<set $completedOrgans.deleteAt(_ofo)>>
						<<else>>
							@@.red;Organ not found for deletion!@@
						<</if>>
					<</link>>
				<<else>>

					<<link "Implant" "Surgery Degradation">>
						<<set $cash -= $surgeryCost>>
						<<set _ofo = $completedOrgans.findIndex(function(s) { return $activeSlave.ID == s.ID && s.type == "freshOvaries"; })>>
						<<if _ofo != -1>>
							<<set $completedOrgans.deleteAt(_ofo)>>
						<<else>>
							@@.red;Organ not found for deletion!@@
						<</if>>
						<<if $activeSlave.ovaryAge >= 47>>
							<<set $activeSlave.ovaryAge = 45>>
						<<else>>
							<<set $activeSlave.ovaryAge -= 2>> /* It shouldn't matter if this goes negative as it is just a signal for menopause to occur. */
						<</if>>
						<<if $activeSlave.preg < 0>>
							<<set $activeSlave.preg = 0>>
						<</if>>
						<<set $activeSlave.health -= 20>>
						<<if $organFarmUpgrade == 2>>
							<<set $activeSlave.chem += 20>>
						<</if>>
						<<if $activeSlave.pubertyXX == 0>>
							<<if $precociousPuberty == 1>>
								<<if $activeSlave.physicalAge >= $fertilityAge>>
									<<set $activeSlave.pubertyAgeXX = ($activeSlave.physicalAge+1)>>
								<</if>>
							<<else>>
								<<if $activeSlave.physicalAge >= $fertilityAge>>
									<<set $activeSlave.pubertyXX = 1>>
								<</if>>
							<</if>>
						<</if>>
						<<set $surgeryType = "freshOvaries">>
					<</link>>
					|
					<<link "Discard" "Remote Surgery">>
						<<set _ofo = $completedOrgans.findIndex(function(s) { return $activeSlave.ID == s.ID && s.type == "freshOvaries"; })>>
						<<if _ofo != -1>>
							<<set $completedOrgans.deleteAt(_ofo)>>
						<<else>>
							@@.red;Organ not found for deletion!@@
						<</if>>
					<</link>>
				<</if>>
			<<elseif $completedOrgans[_i].type == "prostate">>
				<<if $activeSlave.prostate != 0>>

					ERROR: this slave already has a prostate.
					<<link "Discard" "Remote Surgery">>
						<<set _ofo = $completedOrgans.findIndex(function(s) { return $activeSlave.ID == s.ID && s.type == "prostate"; })>>
						<<if _ofo != -1>>
							<<set $completedOrgans.deleteAt(_ofo)>>
						<<else>>
							@@.red;Organ not found for deletion!@@
						<</if>>
					<</link>>
				<<else>>

					<<link "Implant" "Surgery Degradation">>
						<<set $cash -= $surgeryCost>>
						<<set _ofo = $completedOrgans.findIndex(function(s) { return $activeSlave.ID == s.ID && s.type == "prostate"; })>>
						<<if _ofo != -1>>
							<<set $completedOrgans.deleteAt(_ofo)>>
						<<else>>
							@@.red;Organ not found for deletion!@@
						<</if>>
						<<set $activeSlave.prostate = 1>>
						<<set $activeSlave.health -= 20>>
						<<if $organFarmUpgrade == 2>>
							<<set $activeSlave.chem += 20>>
						<</if>>
						<<set $surgeryType = "addProstate">>
					<</link>>
					|
					<<link "Discard" "Remote Surgery">>
						<<set _ofo = $completedOrgans.findIndex(function(s) { return $activeSlave.ID == s.ID && s.type == "prostate"; })>>
						<<if _ofo != -1>>
							<<set $completedOrgans.deleteAt(_ofo)>>
						<<else>>
							@@.red;Organ not found for deletion!@@
						<</if>>
					<</link>>
				<</if>>
			<<elseif $completedOrgans[_i].type == "eyes">>
				<<if $activeSlave.eyes > -2 && $activeSlave.origEye != "implant">>

					ERROR: this slave has working eyes.
					<<link "Discard" "Remote Surgery">>
						<<set _ofo = $completedOrgans.findIndex(function(s) { return $activeSlave.ID == s.ID && s.type == "eyes"; })>>
						<<if _ofo != -1>>
							<<set $completedOrgans.deleteAt(_ofo)>>
						<<else>>
							@@.red;Organ not found for deletion!@@
						<</if>>
					<</link>>
				<<elseif $activeSlave.origEye == "implant">>

					<<link "Remove ocular implants and implant" "Surgery Degradation">>
						<<set $cash -= $surgeryCost>>
						<<set _ofo = $completedOrgans.findIndex(function(s) { return $activeSlave.ID == s.ID && s.type == "eyes"; })>>
						<<if _ofo != -1>>
							<<set $completedOrgans.deleteAt(_ofo)>>
						<<else>>
							@@.red;Organ not found for deletion!@@
						<</if>>
						<<set $stockpile.ocularImplant++>>
						<<set $activeSlave.eyes = 1>>
						<<set _oldEyes = $genePool.find(function(s) { return s.ID = $activeSlave.ID; })>>
						<<set $activeSlave.origEye = _oldEyes.origEye>>
						<<set $activeSlave.eyeColor = $activeSlave.origEye>>
						<<set $activeSlave.health -= 20>>
						<<if $organFarmUpgrade == 2>>
							<<set $activeSlave.chem += 20>>
						<</if>>
						<<set $surgeryType = "newEyes">>
					<</link>>
					|
					<<link "Discard" "Remote Surgery">>
						<<set _ofo = $completedOrgans.findIndex(function(s) { return $activeSlave.ID == s.ID && s.type == "eyes"; })>>
						<<if _ofo != -1>>
							<<set $completedOrgans.deleteAt(_ofo)>>
						<<else>>
							@@.red;Organ not found for deletion!@@
						<</if>>
					<</link>>
				<<else>>

					<<link "Implant" "Surgery Degradation">>
						<<set $cash -= $surgeryCost>>
						<<set _ofo = $completedOrgans.findIndex(function(s) { return $activeSlave.ID == s.ID && s.type == "eyes"; })>>
						<<if _ofo != -1>>
							<<set $completedOrgans.deleteAt(_ofo)>>
						<<else>>
							@@.red;Organ not found for deletion!@@
						<</if>>
						<<set $activeSlave.eyes = 1>>
						<<set $activeSlave.eyeColor = $activeSlave.origEye>>
						/* no way to salvage original eye color */
						<<set $activeSlave.health -= 20>>
						<<if $organFarmUpgrade == 2>>
							<<set $activeSlave.chem += 20>>
						<</if>>
						<<set $surgeryType = "unblind">>
					<</link>>
					|
					<<link "Discard" "Remote Surgery">>
						<<set _ofo = $completedOrgans.findIndex(function(s) { return $activeSlave.ID == s.ID && s.type == "eyes"; })>>
						<<if _ofo != -1>>
							<<set $completedOrgans.deleteAt(_ofo)>>
						<<else>>
							@@.red;Organ not found for deletion!@@
						<</if>>
					<</link>>
				<</if>>
			<<elseif $completedOrgans[_i].type == "mpreg">>
				<<if ($activeSlave.ovaries != 0) && ($activeSlave.vagina > -1) && ($activeSlave.mpreg != 0)>>

					ERROR: this slave has existing reproductive Organs.
					<<link "Discard" "Remote Surgery">>
						<<set _ofo = $completedOrgans.findIndex(function(s) { return $activeSlave.ID == s.ID && s.type == "mpreg"; })>>
						<<if _ofo != -1>>
							<<set $completedOrgans.deleteAt(_ofo)>>
						<<else>>
							@@.red;Organ not found for deletion!@@
						<</if>>
					<</link>>
				<<else>>

					<<link "Implant" "Surgery Degradation">>
						<<set $cash -= $surgeryCost>>
						<<set _ofo = $completedOrgans.findIndex(function(s) { return $activeSlave.ID == s.ID && s.type == "mpreg"; })>>
						<<if _ofo != -1>>
							<<set $completedOrgans.deleteAt(_ofo)>>
						<<else>>
							@@.red;Organ not found for deletion!@@
						<</if>>
						<<set $activeSlave.mpreg = 1>>
						<<set $activeSlave.eggType = "human">>
						<<set $activeSlave.preg = 0>>
						<<set $activeSlave.health -= 40>>
						<<if $organFarmUpgrade == 2>>
							<<set $activeSlave.chem += 20>>
						<</if>>
						<<if $activeSlave.pubertyXX == 0>>
							<<if $precociousPuberty == 1>>
								<<if $activeSlave.physicalAge >= $fertilityAge>>
									<<set $activeSlave.pubertyAgeXX = ($activeSlave.physicalAge+1)>>
								<</if>>
							<<else>>
								<<if $activeSlave.physicalAge >= $fertilityAge>>
									<<set $activeSlave.pubertyXX = 1>>
								<</if>>
							<</if>>
						<</if>>
						<<set $surgeryType = "mpreg">>
					<</link>>
					|
					<<link "Discard" "Remote Surgery">>
						<<set _ofo = $completedOrgans.findIndex(function(s) { return $activeSlave.ID == s.ID && s.type == "mpreg"; })>>
						<<if _ofo != -1>>
							<<set $completedOrgans.deleteAt(_ofo)>>
						<<else>>
							@@.red;Organ not found for deletion!@@
						<</if>>
					<</link>>
				<</if>>
			<<elseif $completedOrgans[_i].type == "mpregPig">>
				<<if ($activeSlave.ovaries != 0) && ($activeSlave.vagina > -1) && ($activeSlave.mpreg != 0)>>

					ERROR: this slave has existing reproductive Organs.
					<<link "Discard" "Remote Surgery">>
						<<set _ofo = $completedOrgans.findIndex(function(s) { return $activeSlave.ID == s.ID && s.type == "mpregPig"; })>>
						<<if _ofo != -1>>
							<<set $completedOrgans.deleteAt(_ofo)>>
						<<else>>
							@@.red;Organ not found for deletion!@@
						<</if>>
					<</link>>
				<<else>>

					<<link "Implant" "Surgery Degradation">>
						<<set $cash -= $surgeryCost>>
						<<set _ofo = $completedOrgans.findIndex(function(s) { return $activeSlave.ID == s.ID && s.type == "mpregPig"; })>>
						<<if _ofo != -1>>
							<<set $completedOrgans.deleteAt(_ofo)>>
						<<else>>
							@@.red;Organ not found for deletion!@@
						<</if>>
						<<set $activeSlave.mpreg = 1>>
						<<set $activeSlave.eggType = "pig">>
						<<set $activeSlave.preg = 0>>
						<<set $activeSlave.health -= 40>>
						<<if $organFarmUpgrade == 2>>
							<<set $activeSlave.chem += 20>>
						<</if>>
						<<if $activeSlave.pubertyXX == 0>>
							<<if $precociousPuberty == 1>>
								<<if $activeSlave.physicalAge >= $fertilityAge>>
									<<set $activeSlave.pubertyAgeXX = ($activeSlave.physicalAge+1)>>
								<</if>>
							<<else>>
								<<if $activeSlave.physicalAge >= $fertilityAge>>
									<<set $activeSlave.pubertyXX = 1>>
								<</if>>
							<</if>>
						<</if>>
						<<set $surgeryType = "mpregPig">>
					<</link>>
					|
					<<link "Discard" "Remote Surgery">>
						<<set _ofo = $completedOrgans.findIndex(function(s) { return $activeSlave.ID == s.ID && s.type == "mpregPig"; })>>
						<<if _ofo != -1>>
							<<set $completedOrgans.deleteAt(_ofo)>>
						<<else>>
							@@.red;Organ not found for deletion!@@
						<</if>>
					<</link>>
				<</if>>
			<<elseif $completedOrgans[_i].type == "mpregDog">>
				<<if ($activeSlave.ovaries != 0) && ($activeSlave.vagina > -1) && ($activeSlave.mpreg != 0)>>

					ERROR: this slave has existing reproductive completedOrgans.
					<<link "Discard" "Remote Surgery">>
						<<set _ofo = $completedOrgans.findIndex(function(s) { return $activeSlave.ID == s.ID && s.type == "mpregDog"; })>>
						<<if _ofo != -1>>
							<<set $completedOrgans.deleteAt(_ofo)>>
						<<else>>
							@@.red;Organ not found for deletion!@@
						<</if>>
					<</link>>
				<<else>>

					<<link "Implant" "Surgery Degradation">>
						<<set $cash -= $surgeryCost>>
						<<set _ofo = $completedOrgans.findIndex(function(s) { return $activeSlave.ID == s.ID && s.type == "mpregDog"; })>>
						<<if _ofo != -1>>
							<<set $completedOrgans.deleteAt(_ofo)>>
						<<else>>
							@@.red;Organ not found for deletion!@@
						<</if>>
						<<set $activeSlave.mpreg = 1>>
						<<set $activeSlave.eggType = "dog">>
						<<set $activeSlave.preg = 0>>
						<<set $activeSlave.health -= 40>>
						<<if $organFarmUpgrade == 2>>
							<<set $activeSlave.chem += 20>>
						<</if>>
						<<if $activeSlave.pubertyXX == 0>>
							<<if $precociousPuberty == 1>>
								<<if $activeSlave.physicalAge >= $fertilityAge>>
									<<set $activeSlave.pubertyAgeXX = ($activeSlave.physicalAge+1)>>
								<</if>>
							<<else>>
								<<if $activeSlave.physicalAge >= $fertilityAge>>
									<<set $activeSlave.pubertyXX = 1>>
								<</if>>
							<</if>>
						<</if>>
						<<set $surgeryType = "mpregDog">>
					<</link>>
					|
					<<link "Discard" "Remote Surgery">>
						<<set _ofo = $completedOrgans.findIndex(function(s) { return $activeSlave.ID == s.ID && s.type == "mpregDog"; })>>
						<<if _ofo != -1>>
							<<set $completedOrgans.deleteAt(_ofo)>>
						<<else>>
							@@.red;Organ not found for deletion!@@
						<</if>>
					<</link>>
				<</if>>

			<<else>>
				<<if $activeSlave.voice > 0>>

					ERROR: this slave is not mute.
					<<link "Discard" "Remote Surgery">>
						<<set _ofo = $completedOrgans.findIndex(function(s) { return $activeSlave.ID == s.ID && s.type == "voicebox"; })>>
						<<if _ofo != -1>>
							<<set $completedOrgans.deleteAt(_ofo)>>
						<<else>>
							@@.red;Organ not found for deletion!@@
						<</if>>
					<</link>>
				<<else>>

					<<link "Implant" "Surgery Degradation">>
						<<set $cash -= $surgeryCost>>
						<<set _ofo = $completedOrgans.findIndex(function(s) { return $activeSlave.ID == s.ID && s.type == "voicebox"; })>>
						<<if _ofo != -1>>
							<<set $completedOrgans.deleteAt(_ofo)>>
						<<else>>
							@@.red;Organ not found for deletion!@@
						<</if>>
						<<if $activeSlave.ovaries == 1 && $activeSlave.hormoneBalance >= 200>>
							<<set $activeSlave.voice = 3>>
						<<elseif ($activeSlave.balls > 0) || ($activeSlave.hormoneBalance < -20)>>
							<<set $activeSlave.voice = 1>>
						<<else>>
							<<set $activeSlave.voice = 2>>
						<</if>>
						<<set $activeSlave.health -= 10>>
						<<if $organFarmUpgrade == 2>>
							<<set $activeSlave.chem += 10>>
						<</if>>
						<<set $surgeryType = "restoreVoice">>
					<</link>>
					|
					<<link "Discard" "Remote Surgery">>
						<<set _ofo = $completedOrgans.findIndex(function(s) { return $activeSlave.ID == s.ID && s.type == "voicebox"; })>>
						<<if _ofo != -1>>
							<<set $completedOrgans.deleteAt(_ofo)>>
						<<else>>
							@@.red;Organ not found for deletion!@@
						<</if>>
					<</link>>
				<</if>>
			<</if>>
		<</if>>
	<</for>> /* for of the $completedOrgans loop */
<</if>>


code:
:: P Bodyswap Reveal [nobr]

<<set $nextButton = "Continue", $nextLink = "Random Nonindividual Event">>

<<set $bodyswapAnnounced = 1>>

You receive countless messages throughout the day; mostly worthless spam, several uninteresting business offers and the occasional enslavement request. This one catches your eye however. It's an offer from a top surgeon who has recently been experimenting with radical new surgeries. You've been loosely following their work for the last few weeks, ever since they successfully swapped the consciousness from one slave to another with minimal side effects, assuming they are kept on a special suppressant, and it seems they are now offering their work to anyone with a surgical suite capable of performing the surgery and willing to undertake the risk.

It's an interesting offer and your remote surgery will suffice should you want to change up your slaves' bodies more than any drug or implant ever could. You'll need a slave to swap them with, however. Perhaps one of the mindless slaves from the Flesh Heap will suit your needs, should you not wish to use your own stock.

repo_name: PresidentConvert/fc


code:
:: PC Appearance Intro [nobr]

Race and appearance are largely irrelevant in the free cities; there are only the free and the enslaved.

//Appearance only, no effect on gameplay (unless you make a big deal out of it).//

@@.orange;What nationality are you?@@

You are $PC.nationality.

<<textbox "$PC.nationality" $PC.nationality "PC Appearance Intro">>//Capitalize it//

@@.orange;What race are you?@@

You're $PC.race.

<<link "White">>
	<<set $PC.race = "white">>
	<<PlayerRace>>
<</link>>
|
<<link "Asian">>
	<<set $PC.race = "asian">>
	<<PlayerRace>>
<</link>>
|
<<link "Latina">>
	<<set $PC.race = "latina">>
	<<PlayerRace>>
<</link>>
|
<<link "Middle Eastern">>
	<<set $PC.race = "middle eastern">>
	<<PlayerRace>>
<</link>>
|
<<link "Black">>
	<<set $PC.race = "black">>
	<<PlayerRace>>
<</link>>
|
<<link "Semitic">>
	<<set $PC.race = "semitic">>
	<<PlayerRace>>
<</link>>
|
<<link "Southern European">>
	<<set $PC.race = "southern european">>
	<<PlayerRace>>
<</link>>
|
<<link "Indo-Aryan">>
	<<set $PC.race = "indo-aryan">>
	<<PlayerRace>>
<</link>>
|
<<link "Amerindian">>
	<<set $PC.race = "amerindian">>
	<<PlayerRace>>
<</link>>
|
<<link "Pacific Islander">>
	<<set $PC.race = "pacific islander">>
	<<PlayerRace>>
<</link>>
|
<<link "Malay">>
	<<set $PC.race = "malay">>
	<<PlayerRace>>
<</link>>
|
<<link "Mixed Race">>
	<<set $PC.race = "mixed race">>
	<<PlayerRace>>
<</link>>

@@.orange;What is your skin tone?@@

You have $PC.skin skin.

<<link "White">>
	<<set $PC.skin = "white">>
	<<PlayerSkin>>
<</link>>
|
<<link "Extremely Pale">>
	<<set $PC.skin = "extremely pale">>
	<<PlayerSkin>>
<</link>>
|
<<link "Pale">>
	<<set $PC.skin = "pale">>
	<<PlayerSkin>>
<</link>>
|
<<link "Fair">>
	<<set $PC.skin = "fair">>
	<<PlayerSkin>>
<</link>>
|
<<link "Light">>
	<<set $PC.skin = "light">>
	<<PlayerSkin>>
<</link>>
|
<<link "Light Olive">>
	<<set $PC.skin = "light olive">>
	<<PlayerSkin>>
<</link>>
|
<<link "Tanned">>
	<<set $PC.skin = "tanned">>
	<<PlayerSkin>>
<</link>>
|
<<link "Dark Olive">>
	<<set $PC.skin = "dark olive">>
	<<PlayerSkin>>
<</link>>
|
<<link "Dark">>
	<<set $PC.skin = "dark">>
	<<PlayerSkin>>
<</link>>
|
<<link "Brown">>
	<<set $PC.skin = "brown">>
	<<PlayerSkin>>
<</link>>
|
<<link "Dark Brown">>
	<<set $PC.skin = "dark brown">>
	<<PlayerSkin>>
<</link>>
|
<<link "Black">>
	<<set $PC.skin = "black">>
	<<PlayerSkin>>
<</link>>

@@.orange;Some people have freckles.@@

	<<if $PC.markings == "none">>
		Your skin is pure and clear of any freckles.
	<<elseif $PC.markings == "freckles">>
		You have some freckles on your cheeks and elsewhere.
	<<elseif $PC.markings == "heavily freckled">>
		You have dense freckles on your cheeks and elsewhere.
	<</if>>

<<link "No Freckles">>
	<<set $PC.markings = "none">>
	<<PlayerMarkings>>
<</link>>
|
<<link "Light Freckles">>
	<<set $PC.markings = "freckles">>
	<<PlayerMarkings>>
<</link>>
|
<<link "Heavy Freckles">>
	<<set $PC.markings = "heavily freckled">>
	<<PlayerMarkings>>
<</link>>

@@.orange;What color are your eyes?@@

You have $PC.eyeColor eyes.

<<textbox "$PC.eyeColor" $PC.eyeColor "PC Appearance Intro">>

@@.orange;What color is your hair?@@

You have $PC.hColor hair.

<<textbox "$PC.hColor" $PC.hColor "PC Appearance Intro">>

[[Finish player character customization|PC Experience Intro]]


code:
:: PC Preg Intro [nobr]

You have a working female reproductive system, and thus, a menstrual cycle. Women already face hardships as slaveowners and arcology owners, and being pregnant, coupled with a strong societal aversion to the dominant being penetrated, leads most pregnant owners to find themselves in dire situations. As an added precaution, since nothing stops an owner from hooking up with another owner, contraceptives are common amongst free women.

@@.orange;What's your stance on taking contraceptives?@@

You're
<<if $PC.preg == -1>>
	not interested in being a mother.
	[[Risky|PC Preg Intro][$PC.preg = 0]]
<<elseif $PC.preg == 0>>
	fertile and you know the risks.
	[[Safe|PC Preg Intro][$PC.preg = -1]] | [[About that...|PC Preg Intro][$PC.preg = 10]]
<<else>>
	already pregnant.
	[[Fertile|PC Preg Intro][$PC.preg = 0]]
<</if>>

//Being or becoming pregnant will raise difficulty.//

@@.orange;Hormones can be an interesting thing, how do they affect you?@@

You're
<<if $PC.pregMood == 1>>
	gentle and motherly when you're hormonal.
	[[Normal|PC Preg Intro][$PC.pregMood = 0]] | [[Aggressive|PC Preg Intro][$PC.pregMood = 2]]
<<elseif $PC.pregMood == 0>>
	in complete control of yourself.
	[[Motherly|PC Preg Intro][$PC.pregMood = 1]] | [[Aggressive|PC Preg Intro][$PC.pregMood = 2]]
<<else>>
	aggressive and domineering when you're hormonal.
	[[Normal|PC Preg Intro][$PC.pregMood = 0]] | [[Motherly|PC Preg Intro][$PC.pregMood = 1]]
<</if>>

//Hormone induced moods may alter some sex scenes, as well as change slaves' reactions to you.//

[[Confirm player character customization|PC Appearance Intro]]


code:
:: PC Skin Workaround [nobr]

<<set $nextButton = "Get in", $nextLink = "PC Surgery Degradation">>

You can enter any color for your skin to be changed to. Once you have chosen, you just have to get in and let the machine do its thing.
<br><<textbox "$PC.skin" $PC.skin "PC Surgery Degradation">>


code:
:: Personal Notes [nobr]

<<if $useTabs == 0>>__Personal Notes__<</if>>
<br>
<<if ($playerAging != 0)>>Your birthday is <<if $PC.birthWeek == 51>>next week<<if $playerAging == 2>>; you'll be turning <<print $PC.actualAge+1>><</if>><<else>>in <<print 52-$PC.birthWeek>> weeks<</if>>.<</if>>
<<PlayerBoobs>>
<<PlayerBelly>>
<<PlayerCrotch>>
<<PlayerButt>>
<<if $PC.boobs == 1 && $PC.boobsImplant == 0>>
	<<if $PC.preg == 31>>
		<<if $PC.boobsBonus == 0>>
			<<if random(1,100) > 75>>
				Your breasts have @@.lime;grown larger@@ to feed your coming child. Quick measurements show you've gone up a cup size over the course of your pregnancy.
				<<set $PC.boobsBonus++>>
			<</if>>
		<<elseif $PC.boobsBonus == -1>>
			<<if random(1,100) > 80>>
				Your breasts have been really @@.lime;swollen@@ lately with your new pregnancy. Quick measurements show you've gone up nearly two cup sizes. You may want to consider getting a breast reduction.
				<<set $PC.boobsBonus++>>
			<</if>>
		<<elseif $PC.boobsBonus == 1>>
			<<if random(1,100) > 75>>
				Your already large breasts have @@.lime;grown even larger@@ with your new pregnancy. Quick measurements show you've gone up another cup size or so over the course of your pregnancy.
				<<set $PC.boobsBonus++>>
			<</if>>
		<<elseif $PC.boobsBonus == 2>>
			<<if random(1,100) > 90>>
				Your already huge breasts have @@.lime;grown even more enormous@@ with your new pregnancy. Quick measurements show you've gone up yet another a cup size over the course of your pregnancy.
				<<set $PC.boobsBonus++>>
			<</if>>
		<</if>>
	<</if>>
<</if>>