code:
:: organFarmOptions [nobr]

<<set _newOrgan = {type: "0", weeksToCompletion: "0", ID: 0}>>
<<set $slaveOrgans = {
	penis: 0,
	testicles: 0,
	scrotum: 0,
	pigTesticles: 0,
	dogTesticles: 0,
	horseTesticles: 0,
	cowTesticles: 0,
	foreskin: 0,
	ovaries: 0,
	freshOvaries: 0,
	asexualReproOvaries: 0,
	prostate: 0,
	pigOvaries: 0,
	dogOvaries: 0,
	horseOvaries: 0,
	cowOvaries: 0,
	eyes: 0,
	cochleae: 0,
	voicebox: 0,
	mpreg: 0,
	mpregPig: 0,
	mpregDog: 0,
	mpregHorse: 0,
	mpregCow: 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 == "horseTesticles">>
			<<set $slaveOrgans.horseTesticles = 1>>
		<<elseif $organs[_i].type == "cowTesticles">>
			<<set $slaveOrgans.cowTesticles = 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 == "horseOvaries">>
			<<set $slaveOrgans.horseOvaries = 1>>
		<<elseif $organs[_i].type == "cowOvaries">>
			<<set $slaveOrgans.cowOvaries = 1>>
		<<elseif $organs[_i].type == "eyes">>
			<<set $slaveOrgans.eyes = 1>>
		<<elseif $organs[_i].type == "cochleae">>
			<<set $slaveOrgans.cochleae = 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 == "mpregHorse">>
			<<set $slaveOrgans.mpregHorse = 1>>
		<<elseif $organs[_i].type == "mpregCow">>
			<<set $slaveOrgans.mpregCow = 1>>
		<<elseif $organs[_i].type == "freshOvaries">>
			<<set $slaveOrgans.freshOvaries = 1>>
		<<elseif $organs[_i].type == "asexualReproOvaries">>
			<<set $slaveOrgans.asexualReproOvaries = 1>>
		<</if>>
	<</if>>
<</for>>

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

		<<link "Penis">>
			<<run cashX(-5000, "slaveSurgery", $activeSlave)>>
			<<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">>
			<<run cashX(-5000, "slaveSurgery", $activeSlave)>>
			<<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">>
				<<run cashX(-2500, "slaveSurgery", $activeSlave)>>
				<<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 $animalTesticles > 0>>
		<<if $slaveOrgans.pigTesticles != 1>>

			<<link "Pig testicles">>
				<<run cashX(-5000, "slaveSurgery", $activeSlave)>>
				<<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">>
				<<run cashX(-5000, "slaveSurgery", $activeSlave)>>
				<<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 $slaveOrgans.horseTesticles != 1>>

			<<link "Horse testicles">>
				<<run cashX(-5000, "slaveSurgery", $activeSlave)>>
				<<set _newOrgan = {type: "horseTesticles", 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.cowTesticles != 1>>

			<<link "Cow testicles">>
				<<run cashX(-5000, "slaveSurgery", $activeSlave)>>
				<<set _newOrgan = {type: "cowTesticles", 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">>
				<<run cashX(-2500, "slaveSurgery", $activeSlave)>>
				<<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">>
		<<run cashX(-5000, "slaveSurgery", $activeSlave)>>
		<<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">>
		<<run cashX(-10000, "slaveSurgery", $activeSlave)>>
		<<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 $asexualReproduction == 1>>
	<<if $slaveOrgans.asexualReproOvaries != 1>>

		<<link "Asexual reproduction modification">>
			<<run cashX(-10000, "slaveSurgery", $activeSlave)>>
			<<set _newOrgan = {type: "asexualReproOvaries", weeksToCompletion: "10", ID: 0}>>
			<<set _newOrgan.ID = $activeSlave.ID>>
			<<set $organs.push(_newOrgan)>>
			<<goto "Remote Surgery">>
		<</link>> //Costs <<print cashFormat(10000)>> and requires existing ovaries for successful implantation//
	<</if>>
<</if>>
<<if $animalOvaries > 0>>
	<<if $slaveOrgans.pigOvaries != 1>>

			<<link "Pig ovaries">>
			<<run cashX(-10000, "slaveSurgery", $activeSlave)>>
			<<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">>
			<<run cashX(-10000, "slaveSurgery", $activeSlave)>>
			<<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 $slaveOrgans.horseOvaries != 1>>

		<<link "Horse ovaries">>
			<<run cashX(-10000, "slaveSurgery", $activeSlave)>>
			<<set _newOrgan = {type: "horseOvaries", 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.cowOvaries != 1>>

		<<link "Cow ovaries">>
			<<run cashX(-10000, "slaveSurgery", $activeSlave)>>
			<<set _newOrgan = {type: "cowOvaries", 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">>
			<<run cashX(-10000, "slaveSurgery", $activeSlave)>>
			<<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">>
			<<run cashX(-10000, "slaveSurgery", $activeSlave)>>
			<<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.cochleae != 1>>
	<<if $activeSlave.hears <= -2 && $activeSlave.earImplant != 1>>

		<<link "Cochleae">>
			<<run cashX(-10000, "slaveSurgery", $activeSlave)>>
			<<set _newOrgan = {type: "cochleae", weeksToCompletion: "6", ID: 0}>>
			<<set _newOrgan.ID = $activeSlave.ID>>
			<<set $organs.push(_newOrgan)>>
			<<goto "Remote Surgery">>
		<</link>> //Costs <<print cashFormat(8000)>>//
	<</if>>
<</if>>
<<if $slaveOrgans.voicebox != 1>>
	<<if ($activeSlave.voice == 0)>>

		<<link "Vocal cords">>
			<<run cashX(-5000, "slaveSurgery", $activeSlave)>>
			<<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">>
			<<run cashX(-20000, "slaveSurgery", $activeSlave)>>
			<<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 $animalMpreg > 0>>
		<<if $slaveOrgans.mpregPig != 1>>

			<<link "Anal pig womb and ovaries">>
				<<run cashX(-20000, "slaveSurgery", $activeSlave)>>
				<<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">>
				<<run cashX(-20000, "slaveSurgery", $activeSlave)>>
				<<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 $slaveOrgans.mpregHorse != 1>>

			<<link "Anal horse womb and ovaries">>
				<<run cashX(-20000, "slaveSurgery", $activeSlave)>>
				<<set _newOrgan = {type: "mpregHorse", 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.mpregCow != 1>>

			<<link "Anal cow womb and ovaries">>
				<<run cashX(-20000, "slaveSurgery", $activeSlave)>>
				<<set _newOrgan = {type: "mpregCow", 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>>

			$His
			<<switch $organs[_i].type>>
			<<case "penis" "scrotum" "foreskin" "prostate" "voicebox">>
				$organs[_i].type is
			<<case "testicles" "ovaries" "eyes" "cochleae">>
				$organs[_i].type are
			<<case "pigTesticles">>
				pig testicles are
			<<case "dogTesticles">>
				dog testicles are
			<<case "horseTesticles">>
				horse testicles are
			<<case "cowTesticles">>
				cow testicles are
			<<case "freshOvaries">>
				revitalized ovaries are
			<<case "pigOvaries">>
				pig ovaries are
			<<case "dogOvaries">>
				dog ovaries are
			<<case "horseOvaries">>
				horse ovaries are
			<<case "cowOvaries">>
				cow 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
			<<case "mpregHorse">>
				anal womb and horse ovaries are
			<<case "mpregCow">>
				anal womb and cow ovaries are
			<<case "asexualReproOvaries">>
				sperm producing ovary replacement is
			<</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 $his $completedOrgans[_i].type.
			<<switch $completedOrgans[_i].type>>
			<<case "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">>
						<<run cashX(forceNeg($surgeryCost), "slaveSurgery", $activeSlave)>>
						<<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>>
			<<case "testicles">>
				<<if $activeSlave.balls > 0 && $activeSlave.ballType == "human">>

					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.balls > 0>>

					ERROR: this slave already has $activeSlave.ballType 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 replace $his existing testicles with a new pair.
					<<link "Implant" "Surgery Degradation">>
						<<run cashX(forceNeg($surgeryCost), "slaveSurgery", $activeSlave)>>
						<<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>>
						<<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>>
				<<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 $his abdomen.
					<<link "Implant" "Surgery Degradation">>
						<<run cashX(forceNeg($surgeryCost), "slaveSurgery", $activeSlave)>>
						<<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">>
						<<run cashX(forceNeg($surgeryCost), "slaveSurgery", $activeSlave)>>
						<<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>>
			<<case "pigTesticles">>
				<<if $activeSlave.balls > 0 && $activeSlave.ballType == "pig">>

					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.balls > 0>>

					ERROR: this slave already has $activeSlave.ballType 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 replace $his existing testicles with a new pair.
					<<link "Implant" "Surgery Degradation">>
						<<run cashX(forceNeg($surgeryCost), "slaveSurgery", $activeSlave)>>
						<<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 = 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 = "addAnimalBalls">>
					<</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 $his abdomen.
					<<link "Implant" "Surgery Degradation">>
						<<run cashX(forceNeg($surgeryCost), "slaveSurgery", $activeSlave)>>
						<<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 = "addAnimalBalls">>
					<</link>>
				<<else>>

					<<link "Implant" "Surgery Degradation">>
						<<run cashX(forceNeg($surgeryCost), "slaveSurgery", $activeSlave)>>
						<<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 = "addAnimalBalls">>
					<</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>>
			<<case "dogTesticles">>
				<<if $activeSlave.balls > 0 && $activeSlave.ballType == "dog">>

					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.balls > 0>>

					ERROR: this slave already has $activeSlave.ballType 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 replace $his existing testicles with a new pair.
					<<link "Implant" "Surgery Degradation">>
						<<run cashX(forceNeg($surgeryCost), "slaveSurgery", $activeSlave)>>
						<<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.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 = "addAnimalBalls">>
					<</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 $his abdomen.
					<<link "Implant" "Surgery Degradation">>
						<<run cashX(forceNeg($surgeryCost), "slaveSurgery", $activeSlave)>>
						<<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 = "addAnimalBalls">>
					<</link>>
				<<else>>

					<<link "Implant">>
						<<run cashX(forceNeg($surgeryCost), "slaveSurgery", $activeSlave)>>
						<<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 = "addAnimalBalls">>
						<<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>>
			<<case "horseTesticles">>
				<<if $activeSlave.balls > 0 && $activeSlave.ballType == "horse">>

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

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

You can replace $his existing testicles with a new pair.
					<<link "Implant" "Surgery Degradation">>
						<<run cashX(forceNeg($surgeryCost), "slaveSurgery", $activeSlave)>>
						<<set _ofo = $completedOrgans.findIndex(function(s) { return $activeSlave.ID == s.ID && s.type == "horseTesticles"; })>>
						<<if _ofo != -1>>
							<<set $completedOrgans.deleteAt(_ofo)>>
						<<else>>
							@@.red;Organ not found for deletion!@@
						<</if>>
						<<set $activeSlave.balls = 2>>
						<<set $activeSlave.ballType = "horse">>
						<<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 = "addAnimalBalls">>
					<</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 == "horseTesticles"; })>>
						<<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 $his abdomen.
					<<link "Implant" "Surgery Degradation">>
						<<run cashX(forceNeg($surgeryCost), "slaveSurgery", $activeSlave)>>
						<<set _ofo = $completedOrgans.findIndex(function(s) { return $activeSlave.ID == s.ID && s.type == "horseTesticles"; })>>
						<<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 = "horse">>
						<<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 = "addAnimalBalls">>
					<</link>>
				<<else>>

					<<link "Implant" "Surgery Degradation">>
						<<run cashX(forceNeg($surgeryCost), "slaveSurgery", $activeSlave)>>
						<<set _ofo = $completedOrgans.findIndex(function(s) { return $activeSlave.ID == s.ID && s.type == "horseTesticles"; })>>
						<<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 = "horse">>
						<<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 = "addAnimalBalls">>
					<</link>>
					|
					<<link "Discard" "Remote Surgery">>
						<<set _ofo = $completedOrgans.findIndex(function(s) { return $activeSlave.ID == s.ID && s.type == "horseTesticles"; })>>
						<<if _ofo != -1>>
							<<set $completedOrgans.deleteAt(_ofo)>>
						<<else>>
							@@.red;Organ not found for deletion!@@
						<</if>>
					<</link>>
				<</if>>
			<<case "cowTesticles">>
				<<if $activeSlave.balls > 0 && $activeSlave.ballType == "cow">>

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

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

You can replace $his existing testicles with a new pair.
					<<link "Implant" "Surgery Degradation">>
						<<run cashX(forceNeg($surgeryCost), "slaveSurgery", $activeSlave)>>
						<<set _ofo = $completedOrgans.findIndex(function(s) { return $activeSlave.ID == s.ID && s.type == "cowTesticles"; })>>
						<<if _ofo != -1>>
							<<set $completedOrgans.deleteAt(_ofo)>>
						<<else>>
							@@.red;Organ not found for deletion!@@
						<</if>>
						<<set $activeSlave.balls = 2>>
						<<set $activeSlave.ballType = "cow">>
						<<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 = "addAnimalBalls">>
					<</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 == "cowTesticles"; })>>
						<<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 $his abdomen.
					<<link "Implant" "Surgery Degradation">>
						<<run cashX(forceNeg($surgeryCost), "slaveSurgery", $activeSlave)>>
						<<set _ofo = $completedOrgans.findIndex(function(s) { return $activeSlave.ID == s.ID && s.type == "cowTesticles"; })>>
						<<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 = "cow">>
						<<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 = "addAnimalBalls">>
					<</link>>
				<<else>>

					<<link "Implant" "Surgery Degradation">>
						<<run cashX(forceNeg($surgeryCost), "slaveSurgery", $activeSlave)>>
						<<set _ofo = $completedOrgans.findIndex(function(s) { return $activeSlave.ID == s.ID && s.type == "cowTesticles"; })>>
						<<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 = "cow">>
						<<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 = "addAnimalBalls">>
					<</link>>
					|
					<<link "Discard" "Remote Surgery">>
						<<set _ofo = $completedOrgans.findIndex(function(s) { return $activeSlave.ID == s.ID && s.type == "cowTesticles"; })>>
						<<if _ofo != -1>>
							<<set $completedOrgans.deleteAt(_ofo)>>
						<<else>>
							@@.red;Organ not found for deletion!@@
						<</if>>
					<</link>>
				<</if>>
			<<case "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">>
						<<run cashX(forceNeg($surgeryCost), "slaveSurgery", $activeSlave)>>
						<<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>>
			<<case "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">>
						<<run cashX(forceNeg($surgeryCost), "slaveSurgery", $activeSlave)>>
						<<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>>
			<<case "ovaries">>
				<<if $activeSlave.ovaries > 0 && $activeSlave.eggType == "human">>

					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.ovaries > 0>>

					ERROR: this slave already has $activeSlave.eggType 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>>

You can replace $his existing ovaries with a new pair.
					<<link "Implant" "Surgery Degradation">>
						<<run cashX(forceNeg($surgeryCost), "slaveSurgery", $activeSlave)>>
						<<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.eggType = "human">>
						<<set $activeSlave.preg = 0>>
						<<set $activeSlave.health -= 20>>
						<<set $activeSlave.pregData = clone(setup.pregData.human)>>
						<<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>>
				<<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">>
						<<run cashX(forceNeg($surgeryCost), "slaveSurgery", $activeSlave)>>
						<<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>>
						<<set $activeSlave.pregData = clone(setup.pregData.human)>>
						<<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>>
			<<case "pigOvaries">>
				<<if $activeSlave.ovaries > 0 && $activeSlave.eggType == "pig">>

					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.ovaries > 0>>

					ERROR: this slave already has $activeSlave.eggType 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>>

You can replace $his existing ovaries with a new pair.
					<<link "Implant" "Surgery Degradation">>
						<<run cashX(forceNeg($surgeryCost), "slaveSurgery", $activeSlave)>>
						<<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.eggType = "pig">>
						<<set $activeSlave.preg = 0>>
						<<set $activeSlave.health -= 20>>
						<<set $activeSlave.pregData = clone(setup.pregData.pig)>>
						<<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 = "addAnimalOvaries">>
					<</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">>
						<<run cashX(forceNeg($surgeryCost), "slaveSurgery", $activeSlave)>>
						<<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>>
						<<set $activeSlave.pregData = clone(setup.pregData.pig)>>
						<<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 = "addAnimalOvaries">>
					<</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>>
			<<case "dogOvaries">>
				<<if $activeSlave.ovaries > 0 && $activeSlave.eggType == "dog">>

					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.ovaries > 0>>

					ERROR: this slave already has $activeSlave.eggType 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>>

You can replace $his existing ovaries with a new pair.
					<<link "Implant" "Surgery Degradation">>
						<<run cashX(forceNeg($surgeryCost), "slaveSurgery", $activeSlave)>>
						<<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.eggType = "dog">>
						<<set $activeSlave.preg = 0>>
						<<set $activeSlave.health -= 20>>
						<<set $activeSlave.pregData = clone(setup.pregData.canineM)>>
						<<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 = "addAnimalOvaries">>
					<</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">>
						<<run cashX(forceNeg($surgeryCost), "slaveSurgery", $activeSlave)>>
						<<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>>
						<<set $activeSlave.pregData = clone(setup.pregData.canineM)>>
						<<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 = "addAnimalOvaries">>
					<</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>>
			<<case "horseOvaries">>
				<<if $activeSlave.ovaries > 0 && $activeSlave.eggType == "horse">>

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

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

You can replace $his existing ovaries with a new pair.
					<<link "Implant" "Surgery Degradation">>
						<<run cashX(forceNeg($surgeryCost), "slaveSurgery", $activeSlave)>>
						<<set _ofo = $completedOrgans.findIndex(function(s) { return $activeSlave.ID == s.ID && s.type == "horseOvaries"; })>>
						<<if _ofo != -1>>
							<<set $completedOrgans.deleteAt(_ofo)>>
						<<else>>
							@@.red;Organ not found for deletion!@@
						<</if>>
						<<set $activeSlave.eggType = "horse">>
						<<set $activeSlave.preg = 0>>
						<<set $activeSlave.health -= 20>>
						<<set $activeSlave.pregData = clone(setup.pregData.equine)>>
						<<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 = "addAnimalOvaries">>
					<</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 == "horseOvaries"; })>>
						<<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 == "horseOvaries"; })>>
						<<if _ofo != -1>>
							<<set $completedOrgans.deleteAt(_ofo)>>
						<<else>>
							@@.red;Organ not found for deletion!@@
						<</if>>
					<</link>>
				<<else>>

					<<link "Implant" "Surgery Degradation">>
						<<run cashX(forceNeg($surgeryCost), "slaveSurgery", $activeSlave)>>
						<<set _ofo = $completedOrgans.findIndex(function(s) { return $activeSlave.ID == s.ID && s.type == "horseOvaries"; })>>
						<<if _ofo != -1>>
							<<set $completedOrgans.deleteAt(_ofo)>>
						<<else>>
							@@.red;Organ not found for deletion!@@
						<</if>>
						<<set $activeSlave.ovaries = 1>>
						<<set $activeSlave.eggType = "horse">>
						<<set $activeSlave.preg = 0>>
						<<set $activeSlave.health -= 20>>
						<<set $activeSlave.pregData = clone(setup.pregData.equine)>>
						<<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 = "addAnimalOvaries">>
					<</link>>
					|
					<<link "Discard" "Remote Surgery">>
						<<set _ofo = $completedOrgans.findIndex(function(s) { return $activeSlave.ID == s.ID && s.type == "horseOvaries"; })>>
						<<if _ofo != -1>>
							<<set $completedOrgans.deleteAt(_ofo)>>
						<<else>>
							@@.red;Organ not found for deletion!@@
						<</if>>
					<</link>>
				<</if>>
			<<case "cowOvaries">>
				<<if $activeSlave.ovaries > 0 && $activeSlave.eggType == "cow">>

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

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

You can replace $his existing ovaries with a new pair.
					<<link "Implant" "Surgery Degradation">>
						<<run cashX(forceNeg($surgeryCost), "slaveSurgery", $activeSlave)>>
						<<set _ofo = $completedOrgans.findIndex(function(s) { return $activeSlave.ID == s.ID && s.type == "cowOvaries"; })>>
						<<if _ofo != -1>>
							<<set $completedOrgans.deleteAt(_ofo)>>
						<<else>>
							@@.red;Organ not found for deletion!@@
						<</if>>
						<<set $activeSlave.eggType = "cow">>
						<<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 = "addAnimalOvaries">>
					<</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 == "cowOvaries"; })>>
						<<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 == "cowOvaries"; })>>
						<<if _ofo != -1>>
							<<set $completedOrgans.deleteAt(_ofo)>>
						<<else>>
							@@.red;Organ not found for deletion!@@
						<</if>>
					<</link>>
				<<else>>

					<<link "Implant" "Surgery Degradation">>
						<<run cashX(forceNeg($surgeryCost), "slaveSurgery", $activeSlave)>>
						<<set _ofo = $completedOrgans.findIndex(function(s) { return $activeSlave.ID == s.ID && s.type == "cowOvaries"; })>>
						<<if _ofo != -1>>
							<<set $completedOrgans.deleteAt(_ofo)>>
						<<else>>
							@@.red;Organ not found for deletion!@@
						<</if>>
						<<set $activeSlave.ovaries = 1>>
						<<set $activeSlave.eggType = "cow">>
						<<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 = "addAnimalOvaries">>
					<</link>>
					|
					<<link "Discard" "Remote Surgery">>
						<<set _ofo = $completedOrgans.findIndex(function(s) { return $activeSlave.ID == s.ID && s.type == "cowOvaries"; })>>
						<<if _ofo != -1>>
							<<set $completedOrgans.deleteAt(_ofo)>>
						<<else>>
							@@.red;Organ not found for deletion!@@
						<</if>>
					<</link>>
				<</if>>
			<<case "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">>
						<<run cashX(forceNeg($surgeryCost), "slaveSurgery", $activeSlave)>>
						<<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>>
			<<case "asexualReproOvaries">>
				<<if ($activeSlave.mpreg == 0 && $activeSlave.ovaries == 0)>>

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

					<<link "Implant" "Surgery Degradation">>
						<<run cashX(forceNeg($surgeryCost), "slaveSurgery", $activeSlave)>>
						<<set _ofo = $completedOrgans.findIndex(function(s) { return $activeSlave.ID == s.ID && s.type == "asexualReproOvaries"; })>>
						<<if _ofo != -1>>
							<<set $completedOrgans.deleteAt(_ofo)>>
						<<else>>
							@@.red;Organ not found for deletion!@@
						<</if>>
						<<if $activeSlave.preg < 0>>
							<<set $activeSlave.preg = 0>>
						<</if>>
						<<set $activeSlave.eggType = "human">>
						<<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 $activeSlave.ovaImplant = "asexual">>
						<<set $surgeryType = "asexualReproOvaries">>
					<</link>>
					|
					<<link "Discard" "Remote Surgery">>
						<<set _ofo = $completedOrgans.findIndex(function(s) { return $activeSlave.ID == s.ID && s.type == "asexualReproOvaries"; })>>
						<<if _ofo != -1>>
							<<set $completedOrgans.deleteAt(_ofo)>>
						<<else>>
							@@.red;Organ not found for deletion!@@
						<</if>>
					<</link>>
				<</if>>
			<<case "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">>
						<<run cashX(forceNeg($surgeryCost), "slaveSurgery", $activeSlave)>>
						<<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>>
			<<case "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">>
						<<run cashX(forceNeg($surgeryCost), "slaveSurgery", $activeSlave)>>
						<<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">>
						<<run cashX(forceNeg($surgeryCost), "slaveSurgery", $activeSlave)>>
						<<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>>
			<<case "cochleae">>
				<<if $activeSlave.hears > -2 && $activeSlave.earImplant != 1>>

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

					<<link "Remove cochlear implants and implant" "Surgery Degradation">>
						<<run cashX(forceNeg($surgeryCost), "slaveSurgery", $activeSlave)>>
						<<set _ofo = $completedOrgans.findIndex(function(s) { return $activeSlave.ID == s.ID && s.type == "cochleae"; })>>
						<<if _ofo != -1>>
							<<set $completedOrgans.deleteAt(_ofo)>>
						<<else>>
							@@.red;Organ not found for deletion!@@
						<</if>>
						<<set $stockpile.cochlearImplant++>>
						<<set $activeSlave.hears = 0>>
						<<set $activeSlave.health -= 20>>
						<<if $organFarmUpgrade == 2>>
							<<set $activeSlave.chem += 20>>
						<</if>>
						<<set $surgeryType = "newEars">>
					<</link>>
					|
					<<link "Discard" "Remote Surgery">>
						<<set _ofo = $completedOrgans.findIndex(function(s) { return $activeSlave.ID == s.ID && s.type == "cochleae"; })>>
						<<if _ofo != -1>>
							<<set $completedOrgans.deleteAt(_ofo)>>
						<<else>>
							@@.red;Organ not found for deletion!@@
						<</if>>
					<</link>>
				<<else>>

					<<link "Implant" "Surgery Degradation">>
						<<run cashX(forceNeg($surgeryCost), "slaveSurgery", $activeSlave)>>
						<<set _ofo = $completedOrgans.findIndex(function(s) { return $activeSlave.ID == s.ID && s.type == "cochleae"; })>>
						<<if _ofo != -1>>
							<<set $completedOrgans.deleteAt(_ofo)>>
						<<else>>
							@@.red;Organ not found for deletion!@@
						<</if>>
						<<set $activeSlave.hears = 0>>
						<<set $activeSlave.health -= 20>>
						<<if $organFarmUpgrade == 2>>
							<<set $activeSlave.chem += 20>>
						<</if>>
						<<set $surgeryType = "undeafen">>
					<</link>>
					|
					<<link "Discard" "Remote Surgery">>
						<<set _ofo = $completedOrgans.findIndex(function(s) { return $activeSlave.ID == s.ID && s.type == "cochleae"; })>>
						<<if _ofo != -1>>
							<<set $completedOrgans.deleteAt(_ofo)>>
						<<else>>
							@@.red;Organ not found for deletion!@@
						<</if>>
					<</link>>
				<</if>>
			<<case "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">>
						<<run cashX(forceNeg($surgeryCost), "slaveSurgery", $activeSlave)>>
						<<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>>
						<<set $activeSlave.pregData = clone(setup.pregData.human)>>
						<<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>>
			<<case "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">>
						<<run cashX(forceNeg($surgeryCost), "slaveSurgery", $activeSlave)>>
						<<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>>
						<<set $activeSlave.pregData = clone(setup.pregData.pig)>>
						<<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>>
			<<case "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">>
						<<run cashX(forceNeg($surgeryCost), "slaveSurgery", $activeSlave)>>
						<<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>>
						<<set $activeSlave.pregData = clone(setup.pregData.canineM)>>
						<<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>>
			<<case "mpregHorse">>
				<<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 == "mpregHorse"; })>>
						<<if _ofo != -1>>
							<<set $completedOrgans.deleteAt(_ofo)>>
						<<else>>
							@@.red;Organ not found for deletion!@@
						<</if>>
					<</link>>
				<<else>>

					<<link "Implant" "Surgery Degradation">>
						<<run cashX(forceNeg($surgeryCost), "slaveSurgery", $activeSlave)>>
						<<set _ofo = $completedOrgans.findIndex(function(s) { return $activeSlave.ID == s.ID && s.type == "mpregHorse"; })>>
						<<if _ofo != -1>>
							<<set $completedOrgans.deleteAt(_ofo)>>
						<<else>>
							@@.red;Organ not found for deletion!@@
						<</if>>
						<<set $activeSlave.mpreg = 1>>
						<<set $activeSlave.eggType = "horse">>
						<<set $activeSlave.preg = 0>>
						<<set $activeSlave.health -= 40>>
						<<set $activeSlave.pregData = clone(setup.pregData.equine)>>
						<<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 = "mpregHorse">>
					<</link>>
					|
					<<link "Discard" "Remote Surgery">>
						<<set _ofo = $completedOrgans.findIndex(function(s) { return $activeSlave.ID == s.ID && s.type == "mpregHorse"; })>>
						<<if _ofo != -1>>
							<<set $completedOrgans.deleteAt(_ofo)>>
						<<else>>
							@@.red;Organ not found for deletion!@@
						<</if>>
					<</link>>
				<</if>>
			<<case "mpregCow">>
				<<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 == "mpregCow"; })>>
						<<if _ofo != -1>>
							<<set $completedOrgans.deleteAt(_ofo)>>
						<<else>>
							@@.red;Organ not found for deletion!@@
						<</if>>
					<</link>>
				<<else>>

					<<link "Implant" "Surgery Degradation">>
						<<run cashX(forceNeg($surgeryCost), "slaveSurgery", $activeSlave)>>
						<<set _ofo = $completedOrgans.findIndex(function(s) { return $activeSlave.ID == s.ID && s.type == "mpregCow"; })>>
						<<if _ofo != -1>>
							<<set $completedOrgans.deleteAt(_ofo)>>
						<<else>>
							@@.red;Organ not found for deletion!@@
						<</if>>
						<<set $activeSlave.mpreg = 1>>
						<<set $activeSlave.eggType = "cow">>
						<<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 = "mpregCow">>
					<</link>>
					|
					<<link "Discard" "Remote Surgery">>
						<<set _ofo = $completedOrgans.findIndex(function(s) { return $activeSlave.ID == s.ID && s.type == "mpregCow"; })>>
						<<if _ofo != -1>>
							<<set $completedOrgans.deleteAt(_ofo)>>
						<<else>>
							@@.red;Organ not found for deletion!@@
						<</if>>
					<</link>>
				<</if>>
			<<case "voicebox">>
				<<if $activeSlave.voice > 0 && $activeSlave.electrolarynx != 1>>

					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>>
				<<elseif $activeSlave.electrolarynx == 1>>

					<<link "Remove electrolarynx and implant" "Surgery Degradation">>
						<<run cashX(forceNeg($surgeryCost), "slaveSurgery", $activeSlave)>>
						<<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>>
						<<set $stockpile.electrolarynx++>>
						<<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 -= 20>>
						<<if $organFarmUpgrade == 2>>
							<<set $activeSlave.chem += 20>>
						<</if>>
						<<set $surgeryType = "newVoice">>
					<</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>>
				<<else>>

					<<link "Implant" "Surgery Degradation">>
						<<run cashX(forceNeg($surgeryCost), "slaveSurgery", $activeSlave)>>
						<<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>>
			<</switch>>
		<</if>>
	<</for>> /* for of the $completedOrgans loop */
<</if>>


code:
:: Ova Transplant Workaround [nobr]

<<set $nextButton = "Cancel", $receptrix = 0, _eligibility = 0>>

//You've decided which fertilized ovum is to be transplanted; now you must select who's womb will be its new home.//

__Select a slave to serve as the host__

<<for _otw = 0; _otw < $slaves.length; _otw++>>
<<capture _otw>>
	<<if ($donatrix.ID != $slaves[_otw].ID && $slaves[_otw].ovaries > 0 || $slaves[_otw].mpreg > 0) && isSlaveAvailable($slaves[_otw]) && $slaves[_otw].preg >= 0 && $slaves[_otw].preg < $slaves[_otw].pregData.normalBirth/10 && $slaves[_otw].pregWeek >= 0 && $slaves[_otw].pubertyXX == 1 && $slaves[_otw].pregType < 12 && $slaves[_otw].bellyImplant == -1 && $slaves[_otw].broodmother == 0 && $slaves[_otw].inflation <= 2 && $slaves[_otw].physicalAge < 70>>
		<<set _name = SlaveFullName($slaves[_otw])>>

[[_name|Surrogacy][$receptrix = $slaves[_otw], cashX(forceNeg($surgeryCost*2), "slaveSurgery"), $surgeryType = "transplant"]] <<if $slaves[_otw].pregType >= 4>>//Using a slave carrying multiples is unadvisable//<</if>>
		<<set _eligibility = 1>>
	<</if>>
<</capture>>
<</for>>
<<if (_eligibility == 0)>>

//You have no slaves capable of acting as a surrogate.//
<</if>>

<<if $PC.vagina == 1 && $donatrix.ID != -1 && $PC.preg >= 0 && $PC.preg < 4 && $PC.pregType < 8 && $PC.physicalAge < 70>>

	[[Use your own womb|Surrogacy][$receptrix = $PC, cashX(forceNeg($surgeryCost*2), "slaveSurgery"), $surgeryType = 'transplant']]
<</if>>

repo_name: Echoart/fc


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.


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 "Pure White">>
	<<set $PC.skin = "pure white">>
	<<PlayerSkin>>
<</link>>
|
<<link "Extremely Pale">>
	<<set $PC.skin = "extremely pale">>
	<<PlayerSkin>>
<</link>>
|
<<link "Pale">>
	<<set $PC.skin = "pale">>
	<<PlayerSkin>>
<</link>>
|
<<link "Extremely Fair">>
	<<set $PC.skin = "extremely fair">>
	<<PlayerSkin>>
<</link>>
|
<<link "Very Fair">>
	<<set $PC.skin = "very fair">>
	<<PlayerSkin>>
<</link>>
|
<<link "Fair">>
	<<set $PC.skin = "fair">>
	<<PlayerSkin>>
<</link>>
|
<<link "White">>
	<<set $PC.skin = "white">>
	<<PlayerSkin>>
<</link>>
|
<<link "Light">>
	<<set $PC.skin = "light">>
	<<PlayerSkin>>
<</link>>
|
<<link "Lightened">>
	<<set $PC.skin = "lightened">>
	<<PlayerSkin>>
<</link>>
|
<<link "Light Olive">>
	<<set $PC.skin = "light olive">>
	<<PlayerSkin>>
<</link>>
|
<<link "Olive">>
	<<set $PC.skin = "olive">>
	<<PlayerSkin>>
<</link>>
|
<<link "Natural">>
	<<set $PC.skin = "natural">>
	<<PlayerSkin>>
<</link>>
|
<<link "Tanned">>
	<<set $PC.skin = "tanned">>
	<<PlayerSkin>>
<</link>>
|
<<link "Bronzed">>
	<<set $PC.skin = "bronzed">>
	<<PlayerSkin>>
<</link>>
|
<<link "Dark Olive">>
	<<set $PC.skin = "dark olive">>
	<<PlayerSkin>>
<</link>>
|
<<link "Dark">>
	<<set $PC.skin = "dark">>
	<<PlayerSkin>>
<</link>>
|
<<link "Light Brown">>
	<<set $PC.skin = "light brown">>
	<<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>>
|
<<link "Ebony">>
	<<set $PC.skin = "ebony">>
	<<PlayerSkin>>
<</link>>
|
<<link "Pure Black">>
	<<set $PC.skin = "pure 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]]