:: 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,
	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>>
		<</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>>
		<br>&nbsp;&nbsp;&nbsp;&nbsp;
		<<link "Penis">>
			<<set $cash -= 5000>>
			<<set _newOrgan = {type: "penis", weeksToCompletion: "5", ID: 0}>>
			<<set _newOrgan.ID = $activeSlave.ID>>
			<<set $organs.push(_newOrgan)>>
			<<goto "Remote Surgery">>
		<</link>> //Costs <<print cashFormat(5000)>> and will add a prostate if one is not already present//
	<</if>>
	<<if $slaveOrgans.testicles != 1>>
		<br>&nbsp;&nbsp;&nbsp;&nbsp;
		<<link "Testicles">>
			<<set $cash -= 5000>>
			<<set _newOrgan = {type: "testicles", weeksToCompletion: "10", ID: 0}>>
			<<set _newOrgan.ID = $activeSlave.ID>>
			<<set $organs.push(_newOrgan)>>
			<<goto "Remote Surgery">>
		<</link>> //Costs <<print cashFormat(5000)>> and will add a prostate if one is not already present; requires a penis for successful implantation//
	<</if>>
	<<if $slaveOrgans.scrotum != 1>>
		<<if $activeSlave.scrotum == 0>>
			<br>&nbsp;&nbsp;&nbsp;&nbsp;
			<<link "Scrotum">>
				<<set $cash -= 2500>>
				<<set _newOrgan = {type: "scrotum", weeksToCompletion: "5", ID: 0}>>
				<<set _newOrgan.ID = $activeSlave.ID>>
				<<set $organs.push(_newOrgan)>>
				<<goto "Remote Surgery">>
			<</link>> //Costs <<print cashFormat(2500)>> and requires balls for successful implantation//
		<</if>>
	<</if>>
	<<if $animalParts != 0>>
		<<if $slaveOrgans.pigTesticles != 1>>
			<br>&nbsp;&nbsp;&nbsp;&nbsp;
			<<link "Pig testicles">>
				<<set $cash -= 5000>>
				<<set _newOrgan = {type: "pigTesticles", weeksToCompletion: "10", ID: 0}>>
				<<set _newOrgan.ID = $activeSlave.ID>>
				<<set $organs.push(_newOrgan)>>
				<<goto "Remote Surgery">>
			<</link>> //Costs <<print cashFormat(5000)>> and requires a penis for successful implantation//
		<</if>>
		<<if $slaveOrgans.dogTesticles != 1>>
			<br>&nbsp;&nbsp;&nbsp;&nbsp;
			<<link "Dog testicles">>
				<<set $cash -= 5000>>
				<<set _newOrgan = {type: "dogTesticles", weeksToCompletion: "10", ID: 0}>>
				<<set _newOrgan.ID = $activeSlave.ID>>
				<<set $organs.push(_newOrgan)>>
				<<goto "Remote Surgery">>
			<</link>> //Costs <<print cashFormat(5000)>> and requires a penis for successful implantation//
		<</if>>
		<<if $slaveOrgans.horseTesticles != 1>>
			<br>&nbsp;&nbsp;&nbsp;&nbsp;
			<<link "Horse testicles">>
				<<set $cash -= 5000>>
				<<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>>
			<br>&nbsp;&nbsp;&nbsp;&nbsp;
			<<link "Cow testicles">>
				<<set $cash -= 5000>>
				<<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>>
			<br>&nbsp;&nbsp;&nbsp;&nbsp;
			<<link "Foreskin">>
				<<set $cash -= 2500>>
				<<set _newOrgan = {type: "foreskin", weeksToCompletion: "5", ID: 0}>>
				<<set _newOrgan.ID = $activeSlave.ID>>
				<<set $organs.push(_newOrgan)>>
				<<goto "Remote Surgery">>
			<</link>> //Costs <<print cashFormat(2500)>>//
		<</if>>
	<</if>>
<</if>>
<<if $slaveOrgans.prostate != 1>>
	<br>&nbsp;&nbsp;&nbsp;&nbsp;
	<<link "Prostate">>
		<<set $cash -= 5000>>
		<<set _newOrgan = {type: "prostate", weeksToCompletion: "5", ID: 0}>>
		<<set _newOrgan.ID = $activeSlave.ID>>
		<<set $organs.push(_newOrgan)>>
		<<goto "Remote Surgery">>
	<</link>> //Costs <<print cashFormat(5000)>> and does not require the presence any specific organ for successful implantation//
<</if>>
<<if $slaveOrgans.ovaries != 1>>
	<br>&nbsp;&nbsp;&nbsp;&nbsp;
	<<link "Ovaries">>
		<<set $cash -= 10000>>
		<<set _newOrgan = {type: "ovaries", weeksToCompletion: "10", ID: 0}>>
		<<set _newOrgan.ID = $activeSlave.ID>>
		<<set $organs.push(_newOrgan)>>
		<<goto "Remote Surgery">>
	<</link>> //Costs <<print cashFormat(10000)>> and requires a vagina for successful implantation//
<</if>>
<<if $animalParts != 0>>
	<<if $slaveOrgans.pigOvaries != 1>>
		<br>&nbsp;&nbsp;&nbsp;&nbsp;
			<<link "Pig ovaries">>
			<<set $cash -= 10000>>
			<<set _newOrgan = {type: "pigOvaries", weeksToCompletion: "10", ID: 0}>>
			<<set _newOrgan.ID = $activeSlave.ID>>
			<<set $organs.push(_newOrgan)>>
			<<goto "Remote Surgery">>
		<</link>> //Costs <<print cashFormat(10000)>> and requires a vagina for successful implantation//
	<</if>>
	<<if $slaveOrgans.dogOvaries != 1>>
		<br>&nbsp;&nbsp;&nbsp;&nbsp;
		<<link "Dog ovaries">>
			<<set $cash -= 10000>>
			<<set _newOrgan = {type: "dogOvaries", weeksToCompletion: "10", ID: 0}>>
			<<set _newOrgan.ID = $activeSlave.ID>>
			<<set $organs.push(_newOrgan)>>
			<<goto "Remote Surgery">>
		<</link>> //Costs <<print cashFormat(10000)>> and requires a vagina for successful implantation//
	<</if>>
	<<if $slaveOrgans.horseOvaries != 1>>
		<br>&nbsp;&nbsp;&nbsp;&nbsp;
		<<link "Horse ovaries">>
			<<set $cash -= 10000>>
			<<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>>
		<br>&nbsp;&nbsp;&nbsp;&nbsp;
		<<link "Cow ovaries">>
			<<set $cash -= 10000>>
			<<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>>
		<br>&nbsp;&nbsp;&nbsp;&nbsp;
		<<link "Younger Ovaries">>
			<<set $cash -= 10000>>
			<<set _newOrgan = {type: "freshOvaries", weeksToCompletion: "10", ID: 0}>>
			<<set _newOrgan.ID = $activeSlave.ID>>
			<<set $organs.push(_newOrgan)>>
			<<goto "Remote Surgery">>
		<</link>> //Costs <<print cashFormat(10000)>> and requires a womb for successful implantation//
	<</if>>
<</if>>
<<if $slaveOrgans.eyes != 1>>
	<<if $activeSlave.eyes <= -2 && $activeSlave.eyes != "implant">>
		<br>&nbsp;&nbsp;&nbsp;&nbsp;
		<<link "Eyes">>
			<<set $cash -= 10000>>
			<<set _newOrgan = {type: "eyes", weeksToCompletion: "10", ID: 0}>>
			<<set _newOrgan.ID = $activeSlave.ID>>
			<<set $organs.push(_newOrgan)>>
			<<goto "Remote Surgery">>
		<</link>> //Costs <<print cashFormat(10000)>> and is imperfect - eyes will lack natural color//
	<</if>>
<</if>>
<<if $slaveOrgans.cochleae != 1>>
	<<if $activeSlave.hears <= -2 && $activeSlave.earImplant != 1>>
		<br>&nbsp;&nbsp;&nbsp;&nbsp;
		<<link "Cochleae">>
			<<set $cash -= 10000>>
			<<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)>>
		<br>&nbsp;&nbsp;&nbsp;&nbsp;
		<<link "Vocal cords">>
			<<set $cash -= 5000>>
			<<set _newOrgan = {type: "voicebox", weeksToCompletion: "5", ID: 0}>>
			<<set _newOrgan.ID = $activeSlave.ID>>
			<<set $organs.push(_newOrgan)>>
			<<goto "Remote Surgery">>
		<</link>> //Costs <<print cashFormat(5000)>>//
	<</if>>
<</if>>
<<if $arcologies[0].FSGenderRadicalistResearch == 1>>
	<<if $slaveOrgans.mpreg != 1>>
		<br>&nbsp;&nbsp;&nbsp;&nbsp;
		<<link "Anal womb and ovaries">>
			<<set $cash -= 20000>>
			<<set _newOrgan = {type: "mpreg", weeksToCompletion: "10", ID: 0}>>
			<<set _newOrgan.ID = $activeSlave.ID>>
			<<set $organs.push(_newOrgan)>>
			<<goto "Remote Surgery">>
		<</link>> //Costs <<print cashFormat(20000)>> and the slave must not have female reproductive organs for successful implantation//
	<</if>>
	<<if $animalParts != 0>>
		<<if $slaveOrgans.mpregPig != 1>>
			<br>&nbsp;&nbsp;&nbsp;&nbsp;
			<<link "Anal pig womb and ovaries">>
				<<set $cash -= 20000>>
				<<set _newOrgan = {type: "mpregPig", weeksToCompletion: "10", ID: 0}>>
				<<set _newOrgan.ID = $activeSlave.ID>>
				<<set $organs.push(_newOrgan)>>
				<<goto "Remote Surgery">>
			<</link>> //Costs <<print cashFormat(20000)>> and the slave must not have female reproductive organs for successful implantation//
		<</if>>
		<<if $slaveOrgans.mpregDog != 1>>
			<br>&nbsp;&nbsp;&nbsp;&nbsp;
			<<link "Anal dog womb and ovaries">>
				<<set $cash -= 20000>>
				<<set _newOrgan = {type: "mpregDog", weeksToCompletion: "10", ID: 0}>>
				<<set _newOrgan.ID = $activeSlave.ID>>
				<<set $organs.push(_newOrgan)>>
				<<goto "Remote Surgery">>
			<</link>> //Costs <<print cashFormat(20000)>> and the slave must not have female reproductive organs for successful implantation//
		<</if>>
		<<if $slaveOrgans.mpregHorse != 1>>
			<br>&nbsp;&nbsp;&nbsp;&nbsp;
			<<link "Anal horse womb and ovaries">>
				<<set $cash -= 20000>>
				<<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>>
			<br>&nbsp;&nbsp;&nbsp;&nbsp;
			<<link "Anal cow womb and ovaries">>
				<<set $cash -= 20000>>
				<<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>>
			<br>&nbsp;&nbsp;&nbsp;&nbsp;
			$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
			<</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>>
			<br>The fabricator has completed $his $completedOrgans[_i].type.
			<<switch $completedOrgans[_i].type>>
			<<case "penis">>
				<<if $activeSlave.dick > 0>>
					<br>&nbsp;&nbsp;&nbsp;&nbsp;
					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>>
					<br>&nbsp;&nbsp;&nbsp;&nbsp;
					<<link "Implant" "Surgery Degradation">>
						<<set $cash -= $surgeryCost>>
						<<set _ofo = $completedOrgans.findIndex(function(s) { return $activeSlave.ID == s.ID && s.type == "penis"; })>>
						<<if _ofo != -1>>
							<<set $completedOrgans.deleteAt(_ofo)>>
						<<else>>
							@@.red;Organ not found for deletion!@@
						<</if>>
						<<if $activeSlave.prostate == 0>>
							<<set $activeSlave.prostate = 1>>
						<</if>>
						<<set $activeSlave.dick = 2>>
						<<set $activeSlave.clit = 0>>
						<<set $activeSlave.foreskin = $activeSlave.dick>>
						<<set $activeSlave.health -= 20>>
						<<if $organFarmUpgrade == 2>>
							<<set $activeSlave.chem += 20>>
						<</if>>
						<<set $surgeryType = "addDick">>
					<</link>>
					|
					<<link "Discard" "Remote Surgery">>
						<<set _ofo = $completedOrgans.findIndex(function(s) { return $activeSlave.ID == s.ID && s.type == "penis"; })>>
						<<if _ofo != -1>>
							<<set $completedOrgans.deleteAt(_ofo)>>
						<<else>>
							@@.red;Organ not found for deletion!@@
						<</if>>
					<</link>>
				<</if>>
			<<case "testicles">>
				<<if $activeSlave.balls > 0 && $activeSlave.ballType == "human">>
					<br>&nbsp;&nbsp;&nbsp;&nbsp;
					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>>
					<br>&nbsp;&nbsp;&nbsp;&nbsp;
					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>>
					<br>You can replace $his existing testicles with a new pair.
					<<link "Implant" "Surgery Degradation">>
						<<set $cash -= $surgeryCost>>
						<<set _ofo = $completedOrgans.findIndex(function(s) { return $activeSlave.ID == s.ID && s.type == "testicles"; })>>
						<<if _ofo != -1>>
							<<set $completedOrgans.deleteAt(_ofo)>>
						<<else>>
							@@.red;Organ not found for deletion!@@
						<</if>>
						<<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>>
					<br>&nbsp;&nbsp;&nbsp;&nbsp;
					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>>
					<br>You can forgo standard procedure and implant testicles directly into $his abdomen.
					<<link "Implant" "Surgery Degradation">>
						<<set $cash -= $surgeryCost>>
						<<set _ofo = $completedOrgans.findIndex(function(s) { return $activeSlave.ID == s.ID && s.type == "testicles"; })>>
						<<if _ofo != -1>>
							<<set $completedOrgans.deleteAt(_ofo)>>
						<<else>>
							@@.red;Organ not found for deletion!@@
						<</if>>
						<<if $activeSlave.prostate < 1>><<set $activeSlave.prostate = 1>><</if>>
						<<set $activeSlave.balls = 2>>
						<<set $activeSlave.ballType = "human">>
						<<set $activeSlave.health -= 20>>
						<<if $organFarmUpgrade == 2>>
							<<set $activeSlave.chem += 20>>
						<</if>>
						<<if $activeSlave.pubertyXY == 0>>
							<<if $precociousPuberty == 1>>
								<<if $activeSlave.physicalAge >= $potencyAge>>
									<<set $activeSlave.pubertyAgeXY = ($activeSlave.physicalAge+1)>>
								<</if>>
							<<else>>
								<<if $activeSlave.physicalAge >= $potencyAge>>
									<<set $activeSlave.pubertyXY = 1>>
								<</if>>
							<</if>>
						<</if>>
						<<set $surgeryType = "addTesticles">>
					<</link>>
				<<else>>
					<br>&nbsp;&nbsp;&nbsp;&nbsp;
					<<link "Implant" "Surgery Degradation">>
						<<set $cash -= $surgeryCost>>
						<<set _ofo = $completedOrgans.findIndex(function(s) { return $activeSlave.ID == s.ID && s.type == "testicles"; })>>
						<<if _ofo != -1>>
							<<set $completedOrgans.deleteAt(_ofo)>>
						<<else>>
							@@.red;Organ not found for deletion!@@
						<</if>>
						<<if $activeSlave.prostate == 0>>
							<<set $activeSlave.prostate = 1>>
						<</if>>
						<<set $activeSlave.balls = 2>>
						<<set $activeSlave.ballType = "human">>
						<<set $activeSlave.scrotum = 2>>
						<<set $activeSlave.health -= 20>>
						<<if $organFarmUpgrade == 2>>
							<<set $activeSlave.chem += 20>>
						<</if>>
						<<if $activeSlave.pubertyXY == 0>>
							<<if $precociousPuberty == 1>>
								<<if $activeSlave.physicalAge >= $potencyAge>>
									<<set $activeSlave.pubertyAgeXY = ($activeSlave.physicalAge+1)>>
								<</if>>
							<<else>>
								<<if $activeSlave.physicalAge >= $potencyAge>>
									<<set $activeSlave.pubertyXY = 1>>
								<</if>>
							<</if>>
						<</if>>
						<<set $surgeryType = "addBalls">>
					<</link>>
					|
					<<link "Discard" "Remote Surgery">>
						<<set _ofo = $completedOrgans.findIndex(function(s) { return $activeSlave.ID == s.ID && s.type == "testicles"; })>>
						<<if _ofo != -1>>
							<<set $completedOrgans.deleteAt(_ofo)>>
						<<else>>
							@@.red;Organ not found for deletion!@@
						<</if>>
					<</link>>
				<</if>>
			<<case "pigTesticles">>
				<<if $activeSlave.balls > 0 && $activeSlave.ballType == "pig">>
					<br>&nbsp;&nbsp;&nbsp;&nbsp;
					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>>
					<br>&nbsp;&nbsp;&nbsp;&nbsp;
					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>>
					<br>You can replace $his existing testicles with a new pair.
					<<link "Implant" "Surgery Degradation">>
						<<set $cash -= $surgeryCost>>
						<<set _ofo = $completedOrgans.findIndex(function(s) { return $activeSlave.ID == s.ID && s.type == "pigTesticles"; })>>
						<<if _ofo != -1>>
							<<set $completedOrgans.deleteAt(_ofo)>>
						<<else>>
							@@.red;Organ not found for deletion!@@
						<</if>>
						<<set $activeSlave.balls = 2>>
						<<set $activeSlave.ballType = "pig">>
						<<set $activeSlave.health -= 20>>
						<<if $organFarmUpgrade == 2>>
							<<set $activeSlave.chem += 20>>
						<</if>>
						<<if $activeSlave.pubertyXY == 0>>
							<<if $precociousPuberty == 1>>
								<<if $activeSlave.physicalAge >= $potencyAge>>
									<<set $activeSlave.pubertyAgeXY = ($activeSlave.physicalAge+1)>>
								<</if>>
							<<else>>
								<<if $activeSlave.physicalAge >= $potencyAge>>
									<<set $activeSlave.pubertyXY = 1>>
								<</if>>
							<</if>>
						<</if>>
						<<set $surgeryType = "addPigBalls">>
					<</link>>
				<<elseif $activeSlave.dick == 0>>
					<br>&nbsp;&nbsp;&nbsp;&nbsp;
					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>>
					<br>You can forgo standard procedure and implant testicles directly into $his abdomen.
					<<link "Implant" "Surgery Degradation">>
						<<set $cash -= $surgeryCost>>
						<<set _ofo = $completedOrgans.findIndex(function(s) { return $activeSlave.ID == s.ID && s.type == "pigTesticles"; })>>
						<<if _ofo != -1>>
							<<set $completedOrgans.deleteAt(_ofo)>>
						<<else>>
							@@.red;Organ not found for deletion!@@
						<</if>>
						<<if $activeSlave.prostate < 1>><<set $activeSlave.prostate = 1>><</if>>
						<<set $activeSlave.balls = 2>>
						<<set $activeSlave.ballType = "pig">>
						<<set $activeSlave.health -= 20>>
						<<if $organFarmUpgrade == 2>>
							<<set $activeSlave.chem += 20>>
						<</if>>
						<<if $activeSlave.pubertyXY == 0>>
							<<if $precociousPuberty == 1>>
								<<if $activeSlave.physicalAge >= $potencyAge>>
									<<set $activeSlave.pubertyAgeXY = ($activeSlave.physicalAge+1)>>
								<</if>>
							<<else>>
								<<if $activeSlave.physicalAge >= $potencyAge>>
									<<set $activeSlave.pubertyXY = 1>>
								<</if>>
							<</if>>
						<</if>>
						<<set $surgeryType = "addPigBalls">>
					<</link>>
				<<else>>
					<br>&nbsp;&nbsp;&nbsp;&nbsp;
					<<link "Implant" "Surgery Degradation">>
						<<set $cash -= $surgeryCost>>
						<<set _ofo = $completedOrgans.findIndex(function(s) { return $activeSlave.ID == s.ID && s.type == "pigTesticles"; })>>
						<<if _ofo != -1>>
							<<set $completedOrgans.deleteAt(_ofo)>>
						<<else>>
							@@.red;Organ not found for deletion!@@
						<</if>>
						<<set $activeSlave.balls = 3>>
						<<set $activeSlave.scrotum = 3>>
						<<set $activeSlave.ballType = "pig">>
						<<set $activeSlave.health -= 20>>
						<<if $organFarmUpgrade == 2>>
							<<set $activeSlave.chem += 20>>
						<</if>>
						<<if $activeSlave.pubertyXY == 0>>
							<<if $precociousPuberty == 1>>
								<<if $activeSlave.physicalAge >= $potencyAge>>
									<<set $activeSlave.pubertyAgeXY = ($activeSlave.physicalAge+1)>>
								<</if>>
							<<else>>
								<<if $activeSlave.physicalAge >= $potencyAge>>
									<<set $activeSlave.pubertyXY = 1>>
								<</if>>
							<</if>>
						<</if>>
						<<set $surgeryType = "addPigBalls">>
					<</link>>
					|
					<<link "Discard" "Remote Surgery">>
						<<set _ofo = $completedOrgans.findIndex(function(s) { return $activeSlave.ID == s.ID && s.type == "pigTesticles"; })>>
						<<if _ofo != -1>>
							<<set $completedOrgans.deleteAt(_ofo)>>
						<<else>>
							@@.red;Organ not found for deletion!@@
						<</if>>
					<</link>>
				<</if>>
			<<case "dogTesticles">>
				<<if $activeSlave.balls > 0 && $activeSlave.ballType == "dog">>
					<br>&nbsp;&nbsp;&nbsp;&nbsp;
					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>>
					<br>&nbsp;&nbsp;&nbsp;&nbsp;
					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>>
					<br>You can replace $his existing testicles with a new pair.
					<<link "Implant" "Surgery Degradation">>
						<<set $cash -= $surgeryCost>>
						<<set _ofo = $completedOrgans.findIndex(function(s) { return $activeSlave.ID == s.ID && s.type == "dogTesticles"; })>>
						<<if _ofo != -1>>
							<<set $completedOrgans.deleteAt(_ofo)>>
						<<else>>
							@@.red;Organ not found for deletion!@@
						<</if>>
						<<set $activeSlave.balls = 2>>
						<<set $activeSlave.ballType = "dog">>
						<<set $activeSlave.health -= 20>>
						<<if $organFarmUpgrade == 2>>
							<<set $activeSlave.chem += 20>>
						<</if>>
						<<if $activeSlave.pubertyXY == 0>>
							<<if $precociousPuberty == 1>>
								<<if $activeSlave.physicalAge >= $potencyAge>>
									<<set $activeSlave.pubertyAgeXY = ($activeSlave.physicalAge+1)>>
								<</if>>
							<<else>>
								<<if $activeSlave.physicalAge >= $potencyAge>>
									<<set $activeSlave.pubertyXY = 1>>
								<</if>>
							<</if>>
						<</if>>
						<<set $surgeryType = "addDogBalls">>
					<</link>>
				<<elseif $activeSlave.dick == 0>>
					<br>&nbsp;&nbsp;&nbsp;&nbsp;
					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>>
					<br>You can forgo standard procedure and implant testicles directly into $his abdomen.
					<<link "Implant" "Surgery Degradation">>
						<<set $cash -= $surgeryCost>>
						<<set _ofo = $completedOrgans.findIndex(function(s) { return $activeSlave.ID == s.ID && s.type == "dogTesticles"; })>>
						<<if _ofo != -1>>
							<<set $completedOrgans.deleteAt(_ofo)>>
						<<else>>
							@@.red;Organ not found for deletion!@@
						<</if>>
						<<if $activeSlave.prostate < 1>><<set $activeSlave.prostate = 1>><</if>>
						<<set $activeSlave.balls = 2>>
						<<set $activeSlave.ballType = "dog">>
						<<set $activeSlave.health -= 20>>
						<<if $organFarmUpgrade == 2>>
							<<set $activeSlave.chem += 20>>
						<</if>>
						<<if $activeSlave.pubertyXY == 0>>
							<<if $precociousPuberty == 1>>
								<<if $activeSlave.physicalAge >= $potencyAge>>
									<<set $activeSlave.pubertyAgeXY = ($activeSlave.physicalAge+1)>>
								<</if>>
							<<else>>
								<<if $activeSlave.physicalAge >= $potencyAge>>
									<<set $activeSlave.pubertyXY = 1>>
								<</if>>
							<</if>>
						<</if>>
						<<set $surgeryType = "addDogBalls">>
					<</link>>
				<<else>>
					<br>&nbsp;&nbsp;&nbsp;&nbsp;
					<<link "Implant">>
						<<set $cash -= $surgeryCost>>
						<<set _ofo = $completedOrgans.findIndex(function(s) { return $activeSlave.ID == s.ID && s.type == "dogTesticles"; })>>
						<<if _ofo != -1>>
							<<set $completedOrgans.deleteAt(_ofo)>>
						<<else>>
							@@.red;Organ not found for deletion!@@
						<</if>>
						<<set $activeSlave.balls = 2>>
						<<set $activeSlave.ballType = "dog">>
						<<set $activeSlave.scrotum = 2>>
						<<set $activeSlave.health -= 20>>
						<<if $organFarmUpgrade == 2>>
							<<set $activeSlave.chem += 20>>
						<</if>>
						<<if $activeSlave.pubertyXY == 0>>
							<<if $precociousPuberty == 1>>
								<<if $activeSlave.physicalAge >= $potencyAge>>
									<<set $activeSlave.pubertyAgeXY = ($activeSlave.physicalAge+1)>>
								<</if>>
							<<else>>
								<<if $activeSlave.physicalAge >= $potencyAge>>
									<<set $activeSlave.pubertyXY = 1>>
								<</if>>
							<</if>>
						<</if>>
						<<set $surgeryType = "addDogBalls">>
						<<goto "Surgery Degradation">>
					<</link>>
					|
					<<link "Discard" "Remote Surgery">>
						<<set _ofo = $completedOrgans.findIndex(function(s) { return $activeSlave.ID == s.ID && s.type == "dogTesticles"; })>>
						<<if _ofo != -1>>
							<<set $completedOrgans.deleteAt(_ofo)>>
						<<else>>
							@@.red;Organ not found for deletion!@@
						<</if>>
					<</link>>
				<</if>>
			<<case "horseTesticles">>
				<<if $activeSlave.balls > 0 && $activeSlave.ballType == "horse">>
					<br>&nbsp;&nbsp;&nbsp;&nbsp;
					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>>
					<br>&nbsp;&nbsp;&nbsp;&nbsp;
					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>>
					<br>You can replace $his existing testicles with a new pair.
					<<link "Implant" "Surgery Degradation">>
						<<set $cash -= $surgeryCost>>
						<<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 = "addHorseBalls">>
					<</link>>
				<<elseif $activeSlave.dick == 0>>
					<br>&nbsp;&nbsp;&nbsp;&nbsp;
					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>>
					<br>You can forgo standard procedure and implant testicles directly into $his abdomen.
					<<link "Implant" "Surgery Degradation">>
						<<set $cash -= $surgeryCost>>
						<<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 = "addHorseBalls">>
					<</link>>
				<<else>>
					<br>&nbsp;&nbsp;&nbsp;&nbsp;
					<<link "Implant" "Surgery Degradation">>
						<<set $cash -= $surgeryCost>>
						<<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 = "addHorseBalls">>
					<</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">>
					<br>&nbsp;&nbsp;&nbsp;&nbsp;
					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>>
					<br>&nbsp;&nbsp;&nbsp;&nbsp;
					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>>
					<br>You can replace $his existing testicles with a new pair.
					<<link "Implant" "Surgery Degradation">>
						<<set $cash -= $surgeryCost>>
						<<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 = "addCowBalls">>
					<</link>>
				<<elseif $activeSlave.dick == 0>>
					<br>&nbsp;&nbsp;&nbsp;&nbsp;
					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>>
					<br>You can forgo standard procedure and implant testicles directly into $his abdomen.
					<<link "Implant" "Surgery Degradation">>
						<<set $cash -= $surgeryCost>>
						<<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 = "addCowBalls">>
					<</link>>
				<<else>>
					<br>&nbsp;&nbsp;&nbsp;&nbsp;
					<<link "Implant" "Surgery Degradation">>
						<<set $cash -= $surgeryCost>>
						<<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 = "addCowBalls">>
					<</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>>
					<br>&nbsp;&nbsp;&nbsp;&nbsp;
					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>>
					<br>&nbsp;&nbsp;&nbsp;&nbsp;
					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>>
					<br>&nbsp;&nbsp;&nbsp;&nbsp;
					<<link "Graft on" "Surgery Degradation">>
						<<set $cash -= $surgeryCost>>
						<<set _ofo = $completedOrgans.findIndex(function(s) { return $activeSlave.ID == s.ID && s.type == "scrotum"; })>>
						<<if _ofo != -1>>
							<<set $completedOrgans.deleteAt(_ofo)>>
						<<else>>
							@@.red;Organ not found for deletion!@@
						<</if>>
						<<set $activeSlave.scrotum = $activeSlave.balls>>
						<<set $activeSlave.health -= 10>>
						<<if $organFarmUpgrade == 2>>
							<<set $activeSlave.chem += 10>>
						<</if>>
						<<set $surgeryType = "addScrotum">>
					<</link>>
					|
					<<link "Discard" "Remote Surgery">>
						<<set _ofo = $completedOrgans.findIndex(function(s) { return $activeSlave.ID == s.ID && s.type == "scrotum"; })>>
						<<if _ofo != -1>>
							<<set $completedOrgans.deleteAt(_ofo)>>
						<<else>>
							@@.red;Organ not found for deletion!@@
						<</if>>
					<</link>>
				<</if>>
			<<case "foreskin">>
				<<if $activeSlave.foreskin > 0>>
					<br>&nbsp;&nbsp;&nbsp;&nbsp;
					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>>
					<br>&nbsp;&nbsp;&nbsp;&nbsp;
					<<link "Graft on" "Surgery Degradation">>
						<<set $cash -= $surgeryCost>>
						<<set _ofo = $completedOrgans.findIndex(function(s) { return $activeSlave.ID == s.ID && s.type == "foreskin"; })>>
						<<if _ofo != -1>>
							<<set $completedOrgans.deleteAt(_ofo)>>
						<<else>>
							@@.red;Organ not found for deletion!@@
						<</if>>
						<<if $activeSlave.dick > 0>>
							<<set $activeSlave.foreskin = $activeSlave.dick>>
						<<else>>
							<<set $activeSlave.foreskin = $activeSlave.clit>>
						<</if>>
						<<set $activeSlave.health -= 10>>
						<<if $organFarmUpgrade == 2>>
							<<set $activeSlave.chem += 10>>
						<</if>>
						<<set $surgeryType = "addForeskin">>
					<</link>>
					|
					<<link "Discard" "Remote Surgery">>
						<<set _ofo = $completedOrgans.findIndex(function(s) { return $activeSlave.ID == s.ID && s.type == "foreskin"; })>>
						<<if _ofo != -1>>
							<<set $completedOrgans.deleteAt(_ofo)>>
						<<else>>
							@@.red;Organ not found for deletion!@@
						<</if>>
					<</link>>
				<</if>>
			<<case "ovaries">>
				<<if $activeSlave.ovaries > 0 && $activeSlave.eggType == "human">>
					<br>&nbsp;&nbsp;&nbsp;&nbsp;
					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>>
					<br>&nbsp;&nbsp;&nbsp;&nbsp;
					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>>
					<br>You can replace $his existing ovaries with a new pair.
					<<link "Implant" "Surgery Degradation">>
						<<set $cash -= $surgeryCost>>
						<<set _ofo = $completedOrgans.findIndex(function(s) { return $activeSlave.ID == s.ID && s.type == "ovaries"; })>>
						<<if _ofo != -1>>
							<<set $completedOrgans.deleteAt(_ofo)>>
						<<else>>
							@@.red;Organ not found for deletion!@@
						<</if>>
						<<set $activeSlave.eggType = "human">>
						<<set $activeSlave.preg = 0>>
						<<set $activeSlave.health -= 20>>
						<<if $organFarmUpgrade == 2>>
							<<set $activeSlave.chem += 20>>
						<</if>>
						<<if $activeSlave.pubertyXX == 0>>
							<<if $precociousPuberty == 1>>
								<<if $activeSlave.physicalAge >= $fertilityAge>>
									<<set $activeSlave.pubertyAgeXX = ($activeSlave.physicalAge+1)>>
								<</if>>
							<<else>>
								<<if $activeSlave.physicalAge >= $fertilityAge>>
									<<set $activeSlave.pubertyXX = 1>>
								<</if>>
							<</if>>
						<</if>>
						<<set $surgeryType = "addOvaries">>
					<</link>>
				<<elseif $activeSlave.vagina < 0>>
					<br>&nbsp;&nbsp;&nbsp;&nbsp;
					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>>
					<br>&nbsp;&nbsp;&nbsp;&nbsp;
					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>>
					<br>&nbsp;&nbsp;&nbsp;&nbsp;
					<<link "Implant" "Surgery Degradation">>
						<<set $cash -= $surgeryCost>>
						<<set _ofo = $completedOrgans.findIndex(function(s) { return $activeSlave.ID == s.ID && s.type == "ovaries"; })>>
						<<if _ofo != -1>>
							<<set $completedOrgans.deleteAt(_ofo)>>
						<<else>>
							@@.red;Organ not found for deletion!@@
						<</if>>
						<<set $activeSlave.ovaries = 1>>
						<<set $activeSlave.eggType = "human">>
						<<set $activeSlave.preg = 0>>
						<<set $activeSlave.health -= 20>>
						<<if $organFarmUpgrade == 2>>
							<<set $activeSlave.chem += 20>>
						<</if>>
						<<if $activeSlave.pubertyXX == 0>>
							<<if $precociousPuberty == 1>>
								<<if $activeSlave.physicalAge >= $fertilityAge>>
									<<set $activeSlave.pubertyAgeXX = ($activeSlave.physicalAge+1)>>
								<</if>>
							<<else>>
								<<if $activeSlave.physicalAge >= $fertilityAge>>
									<<set $activeSlave.pubertyXX = 1>>
								<</if>>
							<</if>>
						<</if>>
						<<set $surgeryType = "addOvaries">>
					<</link>>
					|
					<<link "Discard" "Remote Surgery">>
						<<set _ofo = $completedOrgans.findIndex(function(s) { return $activeSlave.ID == s.ID && s.type == "ovaries"; })>>
						<<if _ofo != -1>>
							<<set $completedOrgans.deleteAt(_ofo)>>
						<<else>>
							@@.red;Organ not found for deletion!@@
						<</if>>
					<</link>>
				<</if>>
			<<case "pigOvaries">>
				<<if $activeSlave.ovaries > 0 && $activeSlave.eggType == "pig">>
					<br>&nbsp;&nbsp;&nbsp;&nbsp;
					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>>
					<br>&nbsp;&nbsp;&nbsp;&nbsp;
					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>>
					<br>You can replace $his existing ovaries with a new pair.
					<<link "Implant" "Surgery Degradation">>
						<<set $cash -= $surgeryCost>>
						<<set _ofo = $completedOrgans.findIndex(function(s) { return $activeSlave.ID == s.ID && s.type == "pigOvaries"; })>>
						<<if _ofo != -1>>
							<<set $completedOrgans.deleteAt(_ofo)>>
						<<else>>
							@@.red;Organ not found for deletion!@@
						<</if>>
						<<set $activeSlave.eggType = "pig">>
						<<set $activeSlave.preg = 0>>
						<<set $activeSlave.health -= 20>>
						<<if $organFarmUpgrade == 2>>
							<<set $activeSlave.chem += 20>>
						<</if>>
						<<if $activeSlave.pubertyXX == 0>>
							<<if $precociousPuberty == 1>>
								<<if $activeSlave.physicalAge >= $fertilityAge>>
									<<set $activeSlave.pubertyAgeXX = ($activeSlave.physicalAge+1)>>
								<</if>>
							<<else>>
								<<if $activeSlave.physicalAge >= $fertilityAge>>
									<<set $activeSlave.pubertyXX = 1>>
								<</if>>
							<</if>>
						<</if>>
						<<set $surgeryType = "addPigOvaries">>
					<</link>>
				<<elseif $activeSlave.vagina < 0>>
					<br>&nbsp;&nbsp;&nbsp;&nbsp;
					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>>
					<br>&nbsp;&nbsp;&nbsp;&nbsp;
					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>>
					<br>&nbsp;&nbsp;&nbsp;&nbsp;
					<<link "Implant" "Surgery Degradation">>
						<<set $cash -= $surgeryCost>>
						<<set _ofo = $completedOrgans.findIndex(function(s) { return $activeSlave.ID == s.ID && s.type == "pigOvaries"; })>>
						<<if _ofo != -1>>
							<<set $completedOrgans.deleteAt(_ofo)>>
						<<else>>
							@@.red;Organ not found for deletion!@@
						<</if>>
						<<set $activeSlave.ovaries = 1>>
						<<set $activeSlave.eggType = "pig">>
						<<set $activeSlave.preg = 0>>
						<<set $activeSlave.health -= 20>>
						<<if $organFarmUpgrade == 2>>
							<<set $activeSlave.chem += 20>>
						<</if>>
						<<if $activeSlave.pubertyXX == 0>>
							<<if $precociousPuberty == 1>>
								<<if $activeSlave.physicalAge >= $fertilityAge>>
									<<set $activeSlave.pubertyAgeXX = ($activeSlave.physicalAge+1)>>
								<</if>>
							<<else>>
								<<if $activeSlave.physicalAge >= $fertilityAge>>
									<<set $activeSlave.pubertyXX = 1>>
								<</if>>
							<</if>>
						<</if>>
						<<set $surgeryType = "addPigOvaries">>
					<</link>>
					|
					<<link "Discard" "Remote Surgery">>
						<<set _ofo = $completedOrgans.findIndex(function(s) { return $activeSlave.ID == s.ID && s.type == "pigOvaries"; })>>
						<<if _ofo != -1>>
							<<set $completedOrgans.deleteAt(_ofo)>>
						<<else>>
							@@.red;Organ not found for deletion!@@
						<</if>>
					<</link>>
				<</if>>
			<<case "dogOvaries">>
				<<if $activeSlave.ovaries > 0 && $activeSlave.eggType == "dog">>
					<br>&nbsp;&nbsp;&nbsp;&nbsp;
					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>>
					<br>&nbsp;&nbsp;&nbsp;&nbsp;
					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>>
					<br>You can replace $his existing ovaries with a new pair.
					<<link "Implant" "Surgery Degradation">>
						<<set $cash -= $surgeryCost>>
						<<set _ofo = $completedOrgans.findIndex(function(s) { return $activeSlave.ID == s.ID && s.type == "dogOvaries"; })>>
						<<if _ofo != -1>>
							<<set $completedOrgans.deleteAt(_ofo)>>
						<<else>>
							@@.red;Organ not found for deletion!@@
						<</if>>
						<<set $activeSlave.eggType = "dog">>
						<<set $activeSlave.preg = 0>>
						<<set $activeSlave.health -= 20>>
						<<if $organFarmUpgrade == 2>>
							<<set $activeSlave.chem += 20>>
						<</if>>
						<<if $activeSlave.pubertyXX == 0>>
							<<if $precociousPuberty == 1>>
								<<if $activeSlave.physicalAge >= $fertilityAge>>
									<<set $activeSlave.pubertyAgeXX = ($activeSlave.physicalAge+1)>>
								<</if>>
							<<else>>
								<<if $activeSlave.physicalAge >= $fertilityAge>>
									<<set $activeSlave.pubertyXX = 1>>
								<</if>>
							<</if>>
						<</if>>
						<<set $surgeryType = "addDogOvaries">>
					<</link>>
				<<elseif $activeSlave.vagina < 0>>
					<br>&nbsp;&nbsp;&nbsp;&nbsp;
					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>>
					<br>&nbsp;&nbsp;&nbsp;&nbsp;
					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>>
					<br>&nbsp;&nbsp;&nbsp;&nbsp;
					<<link "Implant" "Surgery Degradation">>
						<<set $cash -= $surgeryCost>>
						<<set _ofo = $completedOrgans.findIndex(function(s) { return $activeSlave.ID == s.ID && s.type == "dogOvaries"; })>>
						<<if _ofo != -1>>
							<<set $completedOrgans.deleteAt(_ofo)>>
						<<else>>
							@@.red;Organ not found for deletion!@@
						<</if>>
						<<set $activeSlave.ovaries = 1>>
						<<set $activeSlave.eggType = "dog">>
						<<set $activeSlave.preg = 0>>
						<<set $activeSlave.health -= 20>>
						<<if $organFarmUpgrade == 2>>
							<<set $activeSlave.chem += 20>>
						<</if>>
						<<if $activeSlave.pubertyXX == 0>>
							<<if $precociousPuberty == 1>>
								<<if $activeSlave.physicalAge >= $fertilityAge>>
									<<set $activeSlave.pubertyAgeXX = ($activeSlave.physicalAge+1)>>
								<</if>>
							<<else>>
								<<if $activeSlave.physicalAge >= $fertilityAge>>
									<<set $activeSlave.pubertyXX = 1>>
								<</if>>
							<</if>>
						<</if>>
						<<set $surgeryType = "addDogOvaries">>
					<</link>>
					|
					<<link "Discard" "Remote Surgery">>
						<<set _ofo = $completedOrgans.findIndex(function(s) { return $activeSlave.ID == s.ID && s.type == "dogOvaries"; })>>
						<<if _ofo != -1>>
							<<set $completedOrgans.deleteAt(_ofo)>>
						<<else>>
							@@.red;Organ not found for deletion!@@
						<</if>>
					<</link>>
				<</if>>
			<<case "horseOvaries">>
				<<if $activeSlave.ovaries > 0 && $activeSlave.eggType == "horse">>
					<br>&nbsp;&nbsp;&nbsp;&nbsp;
					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>>
					<br>&nbsp;&nbsp;&nbsp;&nbsp;
					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>>
					<br>You can replace $his existing ovaries with a new pair.
					<<link "Implant" "Surgery Degradation">>
						<<set $cash -= $surgeryCost>>
						<<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>>
						<<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 = "addHorseOvaries">>
					<</link>>
				<<elseif $activeSlave.vagina < 0>>
					<br>&nbsp;&nbsp;&nbsp;&nbsp;
					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>>
					<br>&nbsp;&nbsp;&nbsp;&nbsp;
					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>>
					<br>&nbsp;&nbsp;&nbsp;&nbsp;
					<<link "Implant" "Surgery Degradation">>
						<<set $cash -= $surgeryCost>>
						<<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>>
						<<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 = "addHorseOvaries">>
					<</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">>
					<br>&nbsp;&nbsp;&nbsp;&nbsp;
					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>>
					<br>&nbsp;&nbsp;&nbsp;&nbsp;
					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>>
					<br>You can replace $his existing ovaries with a new pair.
					<<link "Implant" "Surgery Degradation">>
						<<set $cash -= $surgeryCost>>
						<<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 = "addCowOvaries">>
					<</link>>
				<<elseif $activeSlave.vagina < 0>>
					<br>&nbsp;&nbsp;&nbsp;&nbsp;
					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>>
					<br>&nbsp;&nbsp;&nbsp;&nbsp;
					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>>
					<br>&nbsp;&nbsp;&nbsp;&nbsp;
					<<link "Implant" "Surgery Degradation">>
						<<set $cash -= $surgeryCost>>
						<<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 = "addCowOvaries">>
					<</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>>
					<br>&nbsp;&nbsp;&nbsp;&nbsp;
					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>>
					<br>&nbsp;&nbsp;&nbsp;&nbsp;
					<<link "Implant" "Surgery Degradation">>
						<<set $cash -= $surgeryCost>>
						<<set _ofo = $completedOrgans.findIndex(function(s) { return $activeSlave.ID == s.ID && s.type == "freshOvaries"; })>>
						<<if _ofo != -1>>
							<<set $completedOrgans.deleteAt(_ofo)>>
						<<else>>
							@@.red;Organ not found for deletion!@@
						<</if>>
						<<if $activeSlave.ovaryAge >= 47>>
							<<set $activeSlave.ovaryAge = 45>>
						<<else>>
							<<set $activeSlave.ovaryAge -= 2>> /* It shouldn't matter if this goes negative as it is just a signal for menopause to occur. */
						<</if>>
						<<if $activeSlave.preg < 0>>
							<<set $activeSlave.preg = 0>>
						<</if>>
						<<set $activeSlave.health -= 20>>
						<<if $organFarmUpgrade == 2>>
							<<set $activeSlave.chem += 20>>
						<</if>>
						<<if $activeSlave.pubertyXX == 0>>
							<<if $precociousPuberty == 1>>
								<<if $activeSlave.physicalAge >= $fertilityAge>>
									<<set $activeSlave.pubertyAgeXX = ($activeSlave.physicalAge+1)>>
								<</if>>
							<<else>>
								<<if $activeSlave.physicalAge >= $fertilityAge>>
									<<set $activeSlave.pubertyXX = 1>>
								<</if>>
							<</if>>
						<</if>>
						<<set $surgeryType = "freshOvaries">>
					<</link>>
					|
					<<link "Discard" "Remote Surgery">>
						<<set _ofo = $completedOrgans.findIndex(function(s) { return $activeSlave.ID == s.ID && s.type == "freshOvaries"; })>>
						<<if _ofo != -1>>
							<<set $completedOrgans.deleteAt(_ofo)>>
						<<else>>
							@@.red;Organ not found for deletion!@@
						<</if>>
					<</link>>
				<</if>>
			<<case "prostate">>
				<<if $activeSlave.prostate != 0>>
					<br>&nbsp;&nbsp;&nbsp;&nbsp;
					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>>
					<br>&nbsp;&nbsp;&nbsp;&nbsp;
					<<link "Implant" "Surgery Degradation">>
						<<set $cash -= $surgeryCost>>
						<<set _ofo = $completedOrgans.findIndex(function(s) { return $activeSlave.ID == s.ID && s.type == "prostate"; })>>
						<<if _ofo != -1>>
							<<set $completedOrgans.deleteAt(_ofo)>>
						<<else>>
							@@.red;Organ not found for deletion!@@
						<</if>>
						<<set $activeSlave.prostate = 1>>
						<<set $activeSlave.health -= 20>>
						<<if $organFarmUpgrade == 2>>
							<<set $activeSlave.chem += 20>>
						<</if>>
						<<set $surgeryType = "addProstate">>
					<</link>>
					|
					<<link "Discard" "Remote Surgery">>
						<<set _ofo = $completedOrgans.findIndex(function(s) { return $activeSlave.ID == s.ID && s.type == "prostate"; })>>
						<<if _ofo != -1>>
							<<set $completedOrgans.deleteAt(_ofo)>>
						<<else>>
							@@.red;Organ not found for deletion!@@
						<</if>>
					<</link>>
				<</if>>
			<<case "eyes">>
				<<if $activeSlave.eyes > -2 && $activeSlave.origEye != "implant">>
					<br>&nbsp;&nbsp;&nbsp;&nbsp;
					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">>
					<br>&nbsp;&nbsp;&nbsp;&nbsp;
					<<link "Remove ocular implants and implant" "Surgery Degradation">>
						<<set $cash -= $surgeryCost>>
						<<set _ofo = $completedOrgans.findIndex(function(s) { return $activeSlave.ID == s.ID && s.type == "eyes"; })>>
						<<if _ofo != -1>>
							<<set $completedOrgans.deleteAt(_ofo)>>
						<<else>>
							@@.red;Organ not found for deletion!@@
						<</if>>
						<<set $stockpile.ocularImplant++>>
						<<set $activeSlave.eyes = 1>>
						<<set _oldEyes = $genePool.find(function(s) { return s.ID = $activeSlave.ID; })>>
						<<set $activeSlave.origEye = _oldEyes.origEye>>
						<<set $activeSlave.eyeColor = $activeSlave.origEye>>
						<<set $activeSlave.health -= 20>>
						<<if $organFarmUpgrade == 2>>
							<<set $activeSlave.chem += 20>>
						<</if>>
						<<set $surgeryType = "newEyes">>
					<</link>>
					|
					<<link "Discard" "Remote Surgery">>
						<<set _ofo = $completedOrgans.findIndex(function(s) { return $activeSlave.ID == s.ID && s.type == "eyes"; })>>
						<<if _ofo != -1>>
							<<set $completedOrgans.deleteAt(_ofo)>>
						<<else>>
							@@.red;Organ not found for deletion!@@
						<</if>>
					<</link>>	
				<<else>>
					<br>&nbsp;&nbsp;&nbsp;&nbsp;
					<<link "Implant" "Surgery Degradation">>
						<<set $cash -= $surgeryCost>>
						<<set _ofo = $completedOrgans.findIndex(function(s) { return $activeSlave.ID == s.ID && s.type == "eyes"; })>>
						<<if _ofo != -1>>
							<<set $completedOrgans.deleteAt(_ofo)>>
						<<else>>
							@@.red;Organ not found for deletion!@@
						<</if>>
						<<set $activeSlave.eyes = 1>>
						<<set $activeSlave.eyeColor = $activeSlave.origEye>>
						/* no way to salvage original eye color */
						<<set $activeSlave.health -= 20>>
						<<if $organFarmUpgrade == 2>>
							<<set $activeSlave.chem += 20>>
						<</if>>
						<<set $surgeryType = "unblind">>
					<</link>>
					|
					<<link "Discard" "Remote Surgery">>
						<<set _ofo = $completedOrgans.findIndex(function(s) { return $activeSlave.ID == s.ID && s.type == "eyes"; })>>
						<<if _ofo != -1>>
							<<set $completedOrgans.deleteAt(_ofo)>>
						<<else>>
							@@.red;Organ not found for deletion!@@
						<</if>>
					<</link>>
				<</if>>
			<<case "cochleae">>
				<<if $activeSlave.hears > -2 && $activeSlave.earImplant != 1>>
					<br>&nbsp;&nbsp;&nbsp;&nbsp;
					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>>
					<br>&nbsp;&nbsp;&nbsp;&nbsp;
					<<link "Remove cochlear implants and implant" "Surgery Degradation">>
						<<set $cash -= $surgeryCost>>
						<<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>>
					<br>&nbsp;&nbsp;&nbsp;&nbsp;
					<<link "Implant" "Surgery Degradation">>
						<<set $cash -= $surgeryCost>>
						<<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)>>
					<br>&nbsp;&nbsp;&nbsp;&nbsp;
					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>>
					<br>&nbsp;&nbsp;&nbsp;&nbsp;
					<<link "Implant" "Surgery Degradation">>
						<<set $cash -= $surgeryCost>>
						<<set _ofo = $completedOrgans.findIndex(function(s) { return $activeSlave.ID == s.ID && s.type == "mpreg"; })>>
						<<if _ofo != -1>>
							<<set $completedOrgans.deleteAt(_ofo)>>
						<<else>>
							@@.red;Organ not found for deletion!@@
						<</if>>
						<<set $activeSlave.mpreg = 1>>
						<<set $activeSlave.eggType = "human">>
						<<set $activeSlave.preg = 0>>
						<<set $activeSlave.health -= 40>>
						<<if $organFarmUpgrade == 2>>
							<<set $activeSlave.chem += 20>>
						<</if>>
						<<if $activeSlave.pubertyXX == 0>>
							<<if $precociousPuberty == 1>>
								<<if $activeSlave.physicalAge >= $fertilityAge>>
									<<set $activeSlave.pubertyAgeXX = ($activeSlave.physicalAge+1)>>
								<</if>>
							<<else>>
								<<if $activeSlave.physicalAge >= $fertilityAge>>
									<<set $activeSlave.pubertyXX = 1>>
								<</if>>
							<</if>>
						<</if>>
						<<set $surgeryType = "mpreg">>
					<</link>>
					|
					<<link "Discard" "Remote Surgery">>
						<<set _ofo = $completedOrgans.findIndex(function(s) { return $activeSlave.ID == s.ID && s.type == "mpreg"; })>>
						<<if _ofo != -1>>
							<<set $completedOrgans.deleteAt(_ofo)>>
						<<else>>
							@@.red;Organ not found for deletion!@@
						<</if>>
					<</link>>
				<</if>>
			<<case "mpregPig">>
				<<if ($activeSlave.ovaries != 0) && ($activeSlave.vagina > -1) && ($activeSlave.mpreg != 0)>>
					<br>&nbsp;&nbsp;&nbsp;&nbsp;
					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>>
					<br>&nbsp;&nbsp;&nbsp;&nbsp;
					<<link "Implant" "Surgery Degradation">>
						<<set $cash -= $surgeryCost>>
						<<set _ofo = $completedOrgans.findIndex(function(s) { return $activeSlave.ID == s.ID && s.type == "mpregPig"; })>>
						<<if _ofo != -1>>
							<<set $completedOrgans.deleteAt(_ofo)>>
						<<else>>
							@@.red;Organ not found for deletion!@@
						<</if>>
						<<set $activeSlave.mpreg = 1>>
						<<set $activeSlave.eggType = "pig">>
						<<set $activeSlave.preg = 0>>
						<<set $activeSlave.health -= 40>>
						<<if $organFarmUpgrade == 2>>
							<<set $activeSlave.chem += 20>>
						<</if>>
						<<if $activeSlave.pubertyXX == 0>>
							<<if $precociousPuberty == 1>>
								<<if $activeSlave.physicalAge >= $fertilityAge>>
									<<set $activeSlave.pubertyAgeXX = ($activeSlave.physicalAge+1)>>
								<</if>>
							<<else>>
								<<if $activeSlave.physicalAge >= $fertilityAge>>
									<<set $activeSlave.pubertyXX = 1>>
								<</if>>
							<</if>>
						<</if>>
						<<set $surgeryType = "mpregPig">>
					<</link>>
					|
					<<link "Discard" "Remote Surgery">>
						<<set _ofo = $completedOrgans.findIndex(function(s) { return $activeSlave.ID == s.ID && s.type == "mpregPig"; })>>
						<<if _ofo != -1>>
							<<set $completedOrgans.deleteAt(_ofo)>>
						<<else>>
							@@.red;Organ not found for deletion!@@
						<</if>>
					<</link>>
				<</if>>
			<<case "mpregDog">>
				<<if ($activeSlave.ovaries != 0) && ($activeSlave.vagina > -1) && ($activeSlave.mpreg != 0)>>
					<br>&nbsp;&nbsp;&nbsp;&nbsp;
					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>>
					<br>&nbsp;&nbsp;&nbsp;&nbsp;
					<<link "Implant" "Surgery Degradation">>
						<<set $cash -= $surgeryCost>>
						<<set _ofo = $completedOrgans.findIndex(function(s) { return $activeSlave.ID == s.ID && s.type == "mpregDog"; })>>
						<<if _ofo != -1>>
							<<set $completedOrgans.deleteAt(_ofo)>>
						<<else>>
							@@.red;Organ not found for deletion!@@
						<</if>>
						<<set $activeSlave.mpreg = 1>>
						<<set $activeSlave.eggType = "dog">>
						<<set $activeSlave.preg = 0>>
						<<set $activeSlave.health -= 40>>
						<<if $organFarmUpgrade == 2>>
							<<set $activeSlave.chem += 20>>
						<</if>>
						<<if $activeSlave.pubertyXX == 0>>
							<<if $precociousPuberty == 1>>
								<<if $activeSlave.physicalAge >= $fertilityAge>>
									<<set $activeSlave.pubertyAgeXX = ($activeSlave.physicalAge+1)>>
								<</if>>
							<<else>>
								<<if $activeSlave.physicalAge >= $fertilityAge>>
									<<set $activeSlave.pubertyXX = 1>>
								<</if>>
							<</if>>
						<</if>>
						<<set $surgeryType = "mpregDog">>
					<</link>>
					|
					<<link "Discard" "Remote Surgery">>
						<<set _ofo = $completedOrgans.findIndex(function(s) { return $activeSlave.ID == s.ID && s.type == "mpregDog"; })>>
						<<if _ofo != -1>>
							<<set $completedOrgans.deleteAt(_ofo)>>
						<<else>>
							@@.red;Organ not found for deletion!@@
						<</if>>
					<</link>>
				<</if>>
			<<case "mpregHorse">>
				<<if ($activeSlave.ovaries != 0) && ($activeSlave.vagina > -1) && ($activeSlave.mpreg != 0)>>
					<br>&nbsp;&nbsp;&nbsp;&nbsp;
					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>>
					<br>&nbsp;&nbsp;&nbsp;&nbsp;
					<<link "Implant" "Surgery Degradation">>
						<<set $cash -= $surgeryCost>>
						<<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>>
						<<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)>>
					<br>&nbsp;&nbsp;&nbsp;&nbsp;
					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>>
					<br>&nbsp;&nbsp;&nbsp;&nbsp;
					<<link "Implant" "Surgery Degradation">>
						<<set $cash -= $surgeryCost>>
						<<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>>
					<br>&nbsp;&nbsp;&nbsp;&nbsp;
					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>>
					<br>&nbsp;&nbsp;&nbsp;&nbsp;
					<<link "Remove electrolarynx and implant" "Surgery Degradation">>
						<<set $cash -= $surgeryCost>>
						<<set _ofo = $completedOrgans.findIndex(function(s) { return $activeSlave.ID == s.ID && s.type == "voicebox"; })>>
						<<if _ofo != -1>>
							<<set $completedOrgans.deleteAt(_ofo)>>
						<<else>>
							@@.red;Organ not found for deletion!@@
						<</if>>
						<<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>>
					<br>&nbsp;&nbsp;&nbsp;&nbsp;
					<<link "Implant" "Surgery Degradation">>
						<<set $cash -= $surgeryCost>>
						<<set _ofo = $completedOrgans.findIndex(function(s) { return $activeSlave.ID == s.ID && s.type == "voicebox"; })>>
						<<if _ofo != -1>>
							<<set $completedOrgans.deleteAt(_ofo)>>
						<<else>>
							@@.red;Organ not found for deletion!@@
						<</if>>
						<<if $activeSlave.ovaries == 1 && $activeSlave.hormoneBalance >= 200>>
							<<set $activeSlave.voice = 3>>
						<<elseif ($activeSlave.balls > 0) || ($activeSlave.hormoneBalance < -20)>>
							<<set $activeSlave.voice = 1>>
						<<else>>
							<<set $activeSlave.voice = 2>>
						<</if>>
						<<set $activeSlave.health -= 10>>
						<<if $organFarmUpgrade == 2>>
							<<set $activeSlave.chem += 10>>
						<</if>>
						<<set $surgeryType = "restoreVoice">>
					<</link>>
					|
					<<link "Discard" "Remote Surgery">>
						<<set _ofo = $completedOrgans.findIndex(function(s) { return $activeSlave.ID == s.ID && s.type == "voicebox"; })>>
						<<if _ofo != -1>>
							<<set $completedOrgans.deleteAt(_ofo)>>
						<<else>>
							@@.red;Organ not found for deletion!@@
						<</if>>
					<</link>>
				<</if>>
			<</switch>>
		<</if>>
	<</for>> /* for of the $completedOrgans loop */
<</if>>
