:: organFarmOptions [nobr]

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

The fabricator is ready to grow an organ for $object. Extract tissue to begin growing:
<<if $seeDicks != 0 || $makeDicks == 1>>
	<<if $slaveOrgans.penis != 1>>
		<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 ¤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 ¤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 ¤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 ¤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 ¤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 ¤2500//
		<</if>>
	<</if>>
<</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 ¤10000 and requires a vagina for successful implantation//
<</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 ¤5000 and does not require the presence any specific organ 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 ¤10000 and requires a vagina for successful implantation//
	<</if>>
	<<if $slaveOrgans.pigOvaries != 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 ¤10000 and requires a vagina 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 ¤10000 and is imperfect - eyes will lack natural color//
	<</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 ¤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 ¤20000 and the slave must not have female repoductive 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 ¤20000 and the slave must not have female repoductive 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 ¤20000 and the slave must not have female repoductive 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;
			$possessiveCap $organs[_i].type is 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 $possessive $completedOrgans[_i].type.
			<<if $completedOrgans[_i].type == "penis">>
				<<if $activeSlave.dick > 0>>
					<br>&nbsp;&nbsp;&nbsp;&nbsp;
					ERROR: this slave already has a penis.
					<<link "Discard">><<for $i = 0; $i < $completedOrgans.length; $i++>><<if $activeSlave.ID == $completedOrgans[$i].ID>><<set $completedOrgans.deleteAt($i)>><<break>><</if>><</for>><<goto "Remote Surgery">><</link>>
				<<else>>
					<br>&nbsp;&nbsp;&nbsp;&nbsp;
					<<link "Implant">>
						<<set $cash -= $surgeryCost>>
						<<for $i = 0; $i < $completedOrgans.length; $i++>><<if $activeSlave.ID == $completedOrgans[$i].ID>><<set $completedOrgans.deleteAt($i)>><<break>><</if>><</for>>
						<<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">>
						<<goto "Surgery Degradation">>
					<</link>>
					|
					<<link "Discard">><<for $i = 0; $i < $completedOrgans.length; $i++>><<if $activeSlave.ID == $completedOrgans[$i].ID>><<set $completedOrgans.deleteAt($i)>><<break>><</if>><</for>><<goto "Remote Surgery">><</link>>
				<</if>>
			<<elseif $completedOrgans[_i].type == "testicles">>
				<<if $activeSlave.balls > 0>>
					<br>&nbsp;&nbsp;&nbsp;&nbsp;
					ERROR: this slave already has testicles.
					<<link "Discard">><<for $i = 0; $i < $completedOrgans.length; $i++>><<if $activeSlave.ID == $completedOrgans[$i].ID>><<set $completedOrgans.deleteAt($i)>><<break>><</if>><</for>><<goto "Remote Surgery">><</link>>
				<<elseif $activeSlave.dick == 0>>
					<br>&nbsp;&nbsp;&nbsp;&nbsp;
					ERROR: this slave lacks the penis necessary to accept testicles.
					<<link "Discard">><<for $i = 0; $i < $completedOrgans.length; $i++>><<if $activeSlave.ID == $completedOrgans[$i].ID>><<set $completedOrgans.deleteAt($i)>><<break>><</if>><</for>><<goto "Remote Surgery">><</link>>
					<br>You can forgo standard procedure and implant testicles directly into $possessive abdomen.
					<<link "Implant">>
						<<set $cash -= $surgeryCost>>
						<<for $i = 0; $i < $completedOrgans.length; $i++>><<if $activeSlave.ID == $completedOrgans[$i].ID>><<set $completedOrgans.deleteAt($i)>><<break>><</if>><</for>>
						<<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">>
						<<goto "Surgery Degradation">>
					<</link>>
				<<else>>
					<br>&nbsp;&nbsp;&nbsp;&nbsp;
					<<link "Implant">>
						<<set $cash -= $surgeryCost>>
						<<for $i = 0; $i < $completedOrgans.length; $i++>><<if $activeSlave.ID == $completedOrgans[$i].ID>><<set $completedOrgans.deleteAt($i)>><<break>><</if>><</for>>
						<<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">>
						<<goto "Surgery Degradation">>
					<</link>>
					|
					<<link "Discard">><<for $i = 0; $i < $completedOrgans.length; $i++>><<if $activeSlave.ID == $completedOrgans[$i].ID>><<set $completedOrgans.deleteAt($i)>><<break>><</if>><</for>><<goto "Remote Surgery">><</link>>
				<</if>>
			<<elseif $completedOrgans[_i].type == "pigTesticles">>
				<<if $activeSlave.balls > 0>>
					<br>&nbsp;&nbsp;&nbsp;&nbsp;
					ERROR: this slave already has testicles.
					<<link "Discard">><<for $i = 0; $i < $completedOrgans.length; $i++>><<if $activeSlave.ID == $completedOrgans[$i].ID>><<set $completedOrgans.deleteAt($i)>><<break>><</if>><</for>><<goto "Remote Surgery">><</link>>
				<<elseif $activeSlave.dick == 0>>
					<br>&nbsp;&nbsp;&nbsp;&nbsp;
					ERROR: this slave lacks the penis necessary to accept testicles.
					<<link "Discard">><<for $i = 0; $i < $completedOrgans.length; $i++>><<if $activeSlave.ID == $completedOrgans[$i].ID>><<set $completedOrgans.deleteAt($i)>><<break>><</if>><</for>><<goto "Remote Surgery">><</link>>
				<<else>>
					<br>&nbsp;&nbsp;&nbsp;&nbsp;
					<<link "Implant">>
						<<set $cash -= $surgeryCost>>
						<<for $i = 0; $i < $completedOrgans.length; $i++>>
							<<if $activeSlave.ID == $completedOrgans[$i].ID>>
							<<set $completedOrgans.deleteAt($i)>>
							<<break>>
							<</if>>
						<</for>>
						<<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">>
						<<goto "Surgery Degradation">>
					<</link>>
					|
					<<link "Discard">><<for $i = 0; $i < $completedOrgans.length; $i++>><<if $activeSlave.ID == $completedOrgans[$i].ID>><<set $completedOrgans.deleteAt($i)>><<break>><</if>><</for>><<goto "Remote Surgery">><</link>>
				<</if>>
			<<elseif $completedOrgans[_i].type == "dogTesticles">>
				<<if $activeSlave.balls > 0>>
					<br>&nbsp;&nbsp;&nbsp;&nbsp;
					ERROR: this slave already has testicles.
					<<link "Discard">><<for $i = 0; $i < $completedOrgans.length; $i++>><<if $activeSlave.ID == $completedOrgans[$i].ID>><<set $completedOrgans.deleteAt($i)>><<break>><</if>><</for>><<goto "Remote Surgery">><</link>>
				<<elseif $activeSlave.dick == 0>>
					<br>&nbsp;&nbsp;&nbsp;&nbsp;
					ERROR: this slave lacks the penis necessary to accept testicles.
					<<link "Discard">><<for $i = 0; $i < $completedOrgans.length; $i++>><<if $activeSlave.ID == $completedOrgans[$i].ID>><<set $completedOrgans.deleteAt($i)>><<break>><</if>><</for>><<goto "Remote Surgery">><</link>>
				<<else>>
					<br>&nbsp;&nbsp;&nbsp;&nbsp;
					<<link "Implant">>
						<<set $cash -= $surgeryCost>>
						<<for $i = 0; $i < $completedOrgans.length; $i++>>
							<<if $activeSlave.ID == $completedOrgans[$i].ID>>
							<<set $completedOrgans.deleteAt($i)>>
							<<break>>
							<</if>>
						<</for>>
						<<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">><<for $i = 0; $i < $completedOrgans.length; $i++>><<if $activeSlave.ID == $completedOrgans[$i].ID>><<set $completedOrgans.deleteAt($i)>><<break>><</if>><</for>><<goto "Remote Surgery">><</link>>
				<</if>>
			<<elseif $completedOrgans[_i].type == "scrotum">>
				<<if $activeSlave.scrotum > 0>>
					<br>&nbsp;&nbsp;&nbsp;&nbsp;
					ERROR: this slave already has a scrotum.
					<<link "Discard">><<for $i = 0; $i < $completedOrgans.length; $i++>><<if $activeSlave.ID == $completedOrgans[$i].ID>><<set $completedOrgans.deleteAt($i)>><<break>><</if>><</for>><<goto "Remote Surgery">><</link>>
				<<elseif $activeSlave.balls == 0>>
					<br>&nbsp;&nbsp;&nbsp;&nbsp;
					ERROR: this slave lacks the balls necessary to accept a scrotum.
					<<link "Discard">><<for $i = 0; $i < $completedOrgans.length; $i++>><<if $activeSlave.ID == $completedOrgans[$i].ID>><<set $completedOrgans.deleteAt($i)>><<break>><</if>><</for>><<goto "Remote Surgery">><</link>>
				<<else>>
					<br>&nbsp;&nbsp;&nbsp;&nbsp;
					<<link "Graft on">>
						<<set $cash -= $surgeryCost>>
						<<for $i = 0; $i < $completedOrgans.length; $i++>><<if $activeSlave.ID == $completedOrgans[$i].ID>><<set $completedOrgans.deleteAt($i)>><<break>><</if>><</for>>
						<<set $activeSlave.scrotum = $activeSlave.balls>>
						<<set $activeSlave.health -= 10>>
						<<if $organFarmUpgrade == 2>>
							<<set $activeSlave.chem += 10>>
						<</if>>
						<<set $surgeryType = "addScrotum">>
						<<goto "Surgery Degradation">>
					<</link>>
					|
					<<link "Discard">><<for $i = 0; $i < $completedOrgans.length; $i++>><<if $activeSlave.ID == $completedOrgans[$i].ID>><<set $completedOrgans.deleteAt($i)>><<break>><</if>><</for>><<goto "Remote Surgery">><</link>>
				<</if>>
			<<elseif $completedOrgans[_i].type == "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">><<for $i = 0; $i < $completedOrgans.length; $i++>><<if $activeSlave.ID == $completedOrgans[$i].ID>><<set $completedOrgans.deleteAt($i)>><<break>><</if>><</for>><<goto "Remote Surgery">><</link>>
				<<else>>
					<br>&nbsp;&nbsp;&nbsp;&nbsp;
					<<link "Graft on">>
						<<set $cash -= $surgeryCost>>
						<<for $i = 0; $i < $completedOrgans.length; $i++>><<if $activeSlave.ID == $completedOrgans[$i].ID>><<set $completedOrgans.deleteAt($i)>><<break>><</if>><</for>>
						<<if $activeSlave.dick > 0>>
							<<set $activeSlave.foreskin = $activeSlave.penis>>
						<<else>>
							<<set $activeSlave.foreskin = $activeSlave.clit>>
						<</if>>
						<<set $activeSlave.health -= 10>>
						<<if $organFarmUpgrade == 2>>
							<<set $activeSlave.chem += 10>>
						<</if>>
						<<set $surgeryType = "addForeskin">>
						<<goto "Surgery Degradation">>
					<</link>>
					|
					<<link "Discard">><<for $i = 0; $i < $completedOrgans.length; $i++>><<if $activeSlave.ID == $completedOrgans[$i].ID>><<set $completedOrgans.deleteAt($i)>><<break>><</if>><</for>><<goto "Remote Surgery">><</link>>
				<</if>>
			<<elseif $completedOrgans[_i].type == "ovaries">>
				<<if $activeSlave.ovaries > 0>>
					<br>&nbsp;&nbsp;&nbsp;&nbsp;
					ERROR: this slave already has ovaries.
					<<link "Discard">><<for $i = 0; $i < $completedOrgans.length; $i++>><<if $activeSlave.ID == $completedOrgans[$i].ID>><<set $completedOrgans.deleteAt($i)>><<break>><</if>><</for>><<goto "Remote Surgery">><</link>>
				<<elseif $activeSlave.vagina < 0>>
					<br>&nbsp;&nbsp;&nbsp;&nbsp;
					ERROR: this slave lacks the vagina necessary to accept ovaries.
					<<link "Discard">><<for $i = 0; $i < $completedOrgans.length; $i++>><<if $activeSlave.ID == $completedOrgans[$i].ID>><<set $completedOrgans.deleteAt($i)>><<break>><</if>><</for>><<goto "Remote Surgery">><</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">><<for $i = 0; $i < $completedOrgans.length; $i++>><<if $activeSlave.ID == $completedOrgans[$i].ID>><<set $completedOrgans.deleteAt($i)>><<break>><</if>><</for>><<goto "Remote Surgery">><</link>>
				<<else>>
					<br>&nbsp;&nbsp;&nbsp;&nbsp;
					<<link "Implant">>
						<<set $cash -= $surgeryCost>>
						<<for $i = 0; $i < $completedOrgans.length; $i++>><<if $activeSlave.ID == $completedOrgans[$i].ID>><<set $completedOrgans.deleteAt($i)>><<break>><</if>><</for>>
						<<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">>
						<<goto "Surgery Degradation">>
					<</link>>
					|
					<<link "Discard">><<for $i = 0; $i < $completedOrgans.length; $i++>><<if $activeSlave.ID == $completedOrgans[$i].ID>><<set $completedOrgans.deleteAt($i)>><<break>><</if>><</for>><<goto "Remote Surgery">><</link>>
				<</if>>
			<<elseif $completedOrgans[_i].type == "pigOvaries">>
				<<if $activeSlave.ovaries > 0>>
					<br>&nbsp;&nbsp;&nbsp;&nbsp;
					ERROR: this slave already has ovaries.
					<<link "Discard">><<for $i = 0; $i < $completedOrgans.length; $i++>><<if $activeSlave.ID == $completedOrgans[$i].ID>><<set $completedOrgans.deleteAt($i)>><<break>><</if>><</for>><<goto "Remote Surgery">><</link>>
				<<elseif $activeSlave.vagina < 0>>
					<br>&nbsp;&nbsp;&nbsp;&nbsp;
					ERROR: this slave lacks the vagina necessary to accept ovaries.
					<<link "Discard">><<for $i = 0; $i < $completedOrgans.length; $i++>><<if $activeSlave.ID == $completedOrgans[$i].ID>><<set $completedOrgans.deleteAt($i)>><<break>><</if>><</for>><<goto "Remote Surgery">><</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">><<for $i = 0; $i < $completedOrgans.length; $i++>><<if $activeSlave.ID == $completedOrgans[$i].ID>><<set $completedOrgans.deleteAt($i)>><<break>><</if>><</for>><<goto "Remote Surgery">><</link>>
				<<else>>
					<br>&nbsp;&nbsp;&nbsp;&nbsp;
					<<link "Implant">>
						<<set $cash -= $surgeryCost>>
						<<for $i = 0; $i < $completedOrgans.length; $i++>>
							<<if $activeSlave.ID == $completedOrgans[$i].ID>>
							<<set $completedOrgans.deleteAt($i)>>
							<<break>>
							<</if>>
						<</for>>
						<<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">>
						<<goto "Surgery Degradation">>
					<</link>>
					|
					<<link "Discard">><<for $i = 0; $i < $completedOrgans.length; $i++>><<if $activeSlave.ID == $completedOrgans[$i].ID>><<set $completedOrgans.deleteAt($i)>><<break>><</if>><</for>><<goto "Remote Surgery">><</link>>
				<</if>>
			<<elseif $completedOrgans[_i].type == "dogOvaries">>
				<<if $activeSlave.ovaries > 0>>
					<br>&nbsp;&nbsp;&nbsp;&nbsp;
					ERROR: this slave already has ovaries.
					<<link "Discard">><<for $i = 0; $i < $completedOrgans.length; $i++>><<if $activeSlave.ID == $completedOrgans[$i].ID>><<set $completedOrgans.deleteAt($i)>><<break>><</if>><</for>><<goto "Remote Surgery">><</link>>
				<<elseif $activeSlave.vagina < 0>>
					<br>&nbsp;&nbsp;&nbsp;&nbsp;
					ERROR: this slave lacks the vagina necessary to accept ovaries.
					<<link "Discard">><<for $i = 0; $i < $completedOrgans.length; $i++>><<if $activeSlave.ID == $completedOrgans[$i].ID>><<set $completedOrgans.deleteAt($i)>><<break>><</if>><</for>><<goto "Remote Surgery">><</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">><<for $i = 0; $i < $completedOrgans.length; $i++>><<if $activeSlave.ID == $completedOrgans[$i].ID>><<set $completedOrgans.deleteAt($i)>><<break>><</if>><</for>><<goto "Remote Surgery">><</link>>
				<<else>>
					<br>&nbsp;&nbsp;&nbsp;&nbsp;
					<<link "Implant">>
						<<set $cash -= $surgeryCost>>
						<<for $i = 0; $i < $completedOrgans.length; $i++>>
							<<if $activeSlave.ID == $completedOrgans[$i].ID>>
							<<set $completedOrgans.deleteAt($i)>>
							<<break>>
							<</if>>
						<</for>>
						<<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">>
						<<goto "Surgery Degradation">>
					<</link>>
					|
					<<link "Discard">><<for $i = 0; $i < $completedOrgans.length; $i++>><<if $activeSlave.ID == $completedOrgans[$i].ID>><<set $completedOrgans.deleteAt($i)>><<break>><</if>><</for>><<goto "Remote Surgery">><</link>>
				<</if>>
			<<elseif $completedOrgans[_i].type == "prostate">>
				<<if $activeSlave.prostate != 0>>
					<br>&nbsp;&nbsp;&nbsp;&nbsp;
					ERROR: this slave already has a prostate.
					<<link "Discard">><<for $i = 0; $i < $completedOrgans.length; $i++>><<if $activeSlave.ID == $completedOrgans[$i].ID>><<set $completedOrgans.deleteAt($i)>><<break>><</if>><</for>><<goto "Remote Surgery">><</link>>
				<<else>>
					<br>&nbsp;&nbsp;&nbsp;&nbsp;
					<<link "Implant">>
						<<set $cash -= $surgeryCost>>
						<<for $i = 0; $i < $completedOrgans.length; $i++>><<if $activeSlave.ID == $completedOrgans[$i].ID>><<set $completedOrgans.deleteAt($i)>><<break>><</if>><</for>>
						<<set $activeSlave.prostate = 1>>
						<<set $activeSlave.health -= 20>>
						<<if $organFarmUpgrade == 2>>
							<<set $activeSlave.chem += 20>>
						<</if>>
						<<set $surgeryType = "addProstate">>
						<<goto "Surgery Degradation">>
					<</link>>
					|
					<<link "Discard">><<for $i = 0; $i < $completedOrgans.length; $i++>><<if $activeSlave.ID == $completedOrgans[$i].ID>><<set $completedOrgans.deleteAt($i)>><<break>><</if>><</for>><<goto "Remote Surgery">><</link>>
				<</if>>
			<<elseif $completedOrgans[_i].type == "eyes">>
				<<if $activeSlave.eyes > -2 && $activeSlave.origEye != "implant">>
					<br>&nbsp;&nbsp;&nbsp;&nbsp;
					ERROR: this slave has working eyes.
					<<link "Discard">><<for $i = 0; $i < $completedOrgans.length; $i++>><<if $activeSlave.ID == $completedOrgans[$i].ID>><<set $completedOrgans.deleteAt($i)>><<break>><</if>><</for>><<goto "Remote Surgery">><</link>>
				<<elseif $activeSlave.origEye == "implant">>
					<br>&nbsp;&nbsp;&nbsp;&nbsp;
					<<link "Remove ocular implants and implant">>
						<<set $cash -= $surgeryCost>>
						<<for $i = 0; $i < $completedOrgans.length; $i++>><<if $activeSlave.ID == $completedOrgans[$i].ID>><<set $completedOrgans.deleteAt($i)>><<break>><</if>><</for>>
						<<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">>
						<<goto "Surgery Degradation">>
					<</link>>
					|
					<<link "Discard">><<for $i = 0; $i < $completedOrgans.length; $i++>><<if $activeSlave.ID == $completedOrgans[$i].ID>><<set $completedOrgans.deleteAt($i)>><<break>><</if>><</for>><<goto "Remote Surgery">><</link>>		
				<<else>>
					<br>&nbsp;&nbsp;&nbsp;&nbsp;
					<<link "Implant">>
						<<set $cash -= $surgeryCost>>
						<<for $i = 0; $i < $completedOrgans.length; $i++>><<if $activeSlave.ID == $completedOrgans[$i].ID>><<set $completedOrgans.deleteAt($i)>><<break>><</if>><</for>>
						<<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">>
						<<goto "Surgery Degradation">>
					<</link>>
					|
					<<link "Discard">><<for $i = 0; $i < $completedOrgans.length; $i++>><<if $activeSlave.ID == $completedOrgans[$i].ID>><<set $completedOrgans.deleteAt($i)>><<break>><</if>><</for>><<goto "Remote Surgery">><</link>>
				<</if>>
			<<elseif $completedOrgans[_i].type == "mpreg">>
				<<if ($activeSlave.ovaries != 0) && ($activeSlave.vagina > -1) && ($activeSlave.mpreg != 0)>>
					<br>&nbsp;&nbsp;&nbsp;&nbsp;
					ERROR: this slave has existing reproductive completedOrgans.
					<<link "Discard">><<for $i = 0; $i < $completedOrgans.length; $i++>><<if $activeSlave.ID == $completedOrgans[$i].ID>><<set $completedOrgans.deleteAt($i)>><<break>><</if>><</for>><<goto "Remote Surgery">><</link>>
				<<else>>
					<br>&nbsp;&nbsp;&nbsp;&nbsp;
					<<link "Implant">>
						<<set $cash -= $surgeryCost>>
						<<for $i = 0; $i < $completedOrgans.length; $i++>>
							<<if $activeSlave.ID == $completedOrgans[$i].ID>>
							<<set $completedOrgans.deleteAt($i)>>
							<<break>>
							<</if>>
						<</for>>
						<<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">>
						<<goto "Surgery Degradation">>
					<</link>>
					|
					<<link "Discard">><<for $i = 0; $i < $completedOrgans.length; $i++>><<if $activeSlave.ID == $completedOrgans[$i].ID>><<set $completedOrgans.deleteAt($i)>><<break>><</if>><</for>><<goto "Remote Surgery">><</link>>
				<</if>>
			<<elseif $completedOrgans[_i].type == "mpregPig">>
				<<if ($activeSlave.ovaries != 0) && ($activeSlave.vagina > -1) && ($activeSlave.mpreg != 0)>>
					<br>&nbsp;&nbsp;&nbsp;&nbsp;
					ERROR: this slave has existing reproductive completedOrgans.
					<<link "Discard">><<for $i = 0; $i < $completedOrgans.length; $i++>><<if $activeSlave.ID == $completedOrgans[$i].ID>><<set $completedOrgans.deleteAt($i)>><<break>><</if>><</for>><<goto "Remote Surgery">><</link>>
				<<else>>
					<br>&nbsp;&nbsp;&nbsp;&nbsp;
					<<link "Implant">>
						<<set $cash -= $surgeryCost>>
						<<for $i = 0; $i < $completedOrgans.length; $i++>>
							<<if $activeSlave.ID == $completedOrgans[$i].ID>>
							<<set $completedOrgans.deleteAt($i)>>
							<<break>>
							<</if>>
						<</for>>
						<<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">>
						<<goto "Surgery Degradation">>
					<</link>>
					|
					<<link "Discard">><<for $i = 0; $i < $completedOrgans.length; $i++>><<if $activeSlave.ID == $completedOrgans[$i].ID>><<set $completedOrgans.deleteAt($i)>><<break>><</if>><</for>><<goto "Remote Surgery">><</link>>
				<</if>>
			<<elseif $completedOrgans[_i].type == "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">><<for $i = 0; $i < $completedOrgans.length; $i++>><<if $activeSlave.ID == $completedOrgans[$i].ID>><<set $completedOrgans.deleteAt($i)>><<break>><</if>><</for>><<goto "Remote Surgery">><</link>>
				<<else>>
					<br>&nbsp;&nbsp;&nbsp;&nbsp;
					<<link "Implant">>
						<<set $cash -= $surgeryCost>>
						<<for $i = 0; $i < $completedOrgans.length; $i++>>
							<<if $activeSlave.ID == $completedOrgans[$i].ID>>
							<<set $completedOrgans.deleteAt($i)>>
							<<break>>
							<</if>>
						<</for>>
						<<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">>
						<<goto "Surgery Degradation">>
					<</link>>
					|
					<<link "Discard">><<for $i = 0; $i < $completedOrgans.length; $i++>><<if $activeSlave.ID == $completedOrgans[$i].ID>><<set $completedOrgans.deleteAt($i)>><<break>><</if>><</for>><<goto "Remote Surgery">><</link>>
				<</if>>
				
			<<else>>
				<<if $activeSlave.voice > 0>>
					<br>&nbsp;&nbsp;&nbsp;&nbsp;
					ERROR: this slave is not mute.
					<<link "Discard">><<for $i = 0; $i < $completedOrgans.length; $i++>><<if $activeSlave.ID == $completedOrgans[$i].ID>><<set $completedOrgans.deleteAt($i)>><<break>><</if>><</for>><<goto "Remote Surgery">><</link>>
				<<else>>
					<br>&nbsp;&nbsp;&nbsp;&nbsp;
					<<link "Implant">>
						<<set $cash -= $surgeryCost>>
						<<for $i = 0; $i < $completedOrgans.length; $i++>><<if $activeSlave.ID == $completedOrgans[$i].ID>><<set $completedOrgans.deleteAt($i)>><<break>><</if>><</for>>
						<<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">>
						<<goto "Surgery Degradation">>
					<</link>>
					|
					<<link "Discard">><<for $i = 0; $i < $completedOrgans.length; $i++>><<if $activeSlave.ID == $completedOrgans[$i].ID>><<set $completedOrgans.deleteAt($i)>><<break>><</if>><</for>><<goto "Remote Surgery">><</link>>
				<</if>>
			<</if>>
		<</if>>
	<</for>> /* for of the $completedOrgans loop */
<</if>>