/*
All javascript included on this page is Copyright (c) TRAUMA.ORG
and may not be used elsewhere in any form without our prior
knowledge and consent.

Email trauma@trauma.org for more information.  

TRAUMA.ORG is a non profit organisation committed to education and
information dissemination of trauma care and injury prevention
issues.  
*/

page = 1
pnew = "01"

hide = 1;
units = 1;

gcs = 6;

globalischaemia = 0
localischaemia = 0

dglobal=0
dlocal=0

globaltime = 0
localtime = 0

pulse = 100									//base values
map = 100
icp = 0
baseicp = 10
cpp = 0
cvp = 8

icpindex = 1

sao2 = 65
sjo2 = 65

paco2 = 6.0
vasoindex = 0

oef = 1
cmro = 1

osmolality = 280
iap = 12

spsao2 = 99									//set points
sppaco2 = 4
sppulse = 110;
spmap = 100;
spcvp = 8
spicp = 30

drifticp = 2								//drifts
driftmap = 5
driftpaco2 = 0.5
driftcvp = 3

dpulse = 0									//temporary deviations
dmap = 0
dicp = 0
dsao2 = 0
dpaco2 = 0.5

tdsao2 = 0									//duration of deviations
tdpaco2 = 4
tdpulse = 0
tdmap = 0
tdicp = 0
tdcvp = 0

mannindex = 1
mannrecent = 0

norepi = 0

mv = 10										// mg/kg (look up) //

barb = 0
barbindex = 1

ctreq = 0
ctindicated = 0
ctresult = ""

haemo = 0;
surgindicated = 0;
surgresult = ""

count = 0;

currentmessage = "";
deadmessage = "";

bled = 0
bleeder = Math.floor(Math.random()*2);		// bleeder

laparotomy = 0

if (bleeder) {
	dpulse = 10		// no!! sp's
	tdpulse = 4
	dmap = -10
	tdmap = 4
	dcvp = -2
	tdcvp = 4
}


haematoma = Math.floor(Math.random()*2);	// haematoma
craniotomy = 0;

function BrainDead() {

if (globalischaemia > 100)
	globalischaemia = 100;

pnew = "dead";

}

function CalcVasoIndex() {

	vasoindex = paco2 * -20 + 80

}

function CalcICP() {							// ICP

	if (vasoindex < 20) {
		if (icp < 30)
			icpindex = 1 + vasoindex/-160;
		else
			icpindex = 1 + vasoindex/-80;

	}
	else
		icpindex = 1;

	icp = baseicp * icpindex * mannindex * barbindex

	if (mannindex > 0 && mannindex < 1)	{
		mannindex = mannindex + 0.1;
		if (mannindex > 1)
			mannindex = 1;
	}
	else
		mannindex = 1


	if (icp<0) icp = 0;

	if (!bleeder) {
		if (icp > 40) {							// cushings
			sppulse = 40
			if (!norepi)
				spmap = 110
		}
		else if (icp > 20) {
			sppulse = 60
			if (!norepi)
				spmap = 100
		}
		else if (icp <= 20) {
			sppulse = 90
			if (!norepi)
				spmap = 90
		}
	}
}

function CalcCPP() {							// CPP

	cpp = map - icp - cvp

	if (cpp<0) cpp = 0;

}

function CalcSjO() {							// SjO2

	oef = (1-globalischaemia/100)*barbindex

	cmro = map/100*(vasoindex+100)/200*sao2/1.5*oef

	sjo2 = sao2 - cmro

	if (sjo2 > 100)
		sjo2 = 100;

}

function Mannitol() {							// Mannitol

	dmap = dmap -10; tdmap = 1;
	osmolality = osmolality + 20;				//when does patient get crispy?//
	dcvp = -5; tdcvp = 1

	if (mannrecent) {
		mannindex = 0.95
	}
	else {
		mannindex = 0.6
	}
	mannrecent = 6;
}

function Norepi() {								// Norepi

	norepi = norepi + 1;
	if (!bleeder) {
		if (map < 120) {
			spmap = 100 + norepi * 10 + 5; map = 100 + norepi * 10;
			if (spmap > 120)
				spmap = 120
			driftmap = 5
		}
		else
			dmap = 5; tdmap = 1
	}

}

function NorepiDown() {							// Wean Norepi

	norepi = norepi - 1;
	if (!bleeder) {
		if (norepi)	{
			spmap = 100 + norepi * 10 - 5; map = 100 + norepi * 10;
			driftmap = 5;
			if (map < spmap)
				map = spmap;
		}
	}
}

function CTScan() {								// CT Scan

	ctreq = ctreq + 1

	if (ctreq == 1)
		ctresult = "You send the patient down for a CT scan.<br>";
	if (ctreq == 2)
		ctresult = "You send the patient down for another CT scan.<br>";
	if (ctreq == 3)
		ctresult = "You send the patient down for yet another CT scan.<br>";
	if (ctreq == 4)
		ctresult = "You are not making friends with the radiology department.<br>";
	if (ctreq > 4)
		ctresult = "With some trepidation you call radiology yet again.<br>";

	if (!ctindicated)
		if (page < 10)
			ctresult = ctresult + "The scan result reads: 'CT scan brain - As expected, the CT scan appearances are essentially unchanged from the previous scan.'";
		else
			ctresult = ctresult + "The scan result reads: 'CT scan brain - There are no acute changes on this brain scan, unsurprisingly.'";
	else {
		if (haematoma)
			ctresult = ctresult + "CT scan brain - Previous craniotomy noted.  There is an acute subdural haematoma. ";
		else
			ctresult = ctresult + "CT scan brain - There is an acute intraparenchymal bleed in the region of the cerebral contusion noted on the original scan. ";
		if (icp > 30)
			ctresult = ctresult + "There is effacement of the ventricles and 1cm midline shift to the left.  Basal cisterns and 4th ventricle are obliterated.";
		else
			ctresult = ctresult + "The is effacement of the ventricles but no midline shift.  The basal cisterns and 4th ventricle are open.";
	}
}


function BarbComa() {							// Barb Coma

	if (!barb) {
		if (icp > 40)
			barbindex = 38/icp
		else
			barbindex = 0.95
	}
	else
		barbindex = 1

	barb = 1 - barb

}

function MVUp() {								// Increase MV
	sppaco2 = sppaco2 - 1;
	tdpaco2 = 0; dpaco2 = 0;
	if (sppaco2 < 1.5)
		sppaco2 = 1.5
	mv = mv + 0.5
}

function MVDown() {								// Decrease MV
	sppaco2 = sppaco2 + 1;
	tdpaco2 = 0; dpaco2 = 0;
	if (sppaco2 > 10)
		sppaco2 = 10
	mv = mv - 0.5

}

function Surgeons() {							// surgeons

	if (page != 13) {
		surgresult = "You call up the surgeons and explain your findings.  You hear them talking amongst themselves, ";
		surgresult = surgresult + "then laughter, then a -click- as they hang up on you!";
	}
	else {
		surgresult = "You get the surgeons on the phone but they're operating on another case at the moment.<p>";
		surgresult = surgresult + "They want you to confirm your diagnosis and get back to them with the results.";
		surgindicated = 1;
	}

}


function UpdateVariables() {

	sao2 = sao2 + dsao2
	paco2 = paco2 + dpaco2
	baseicp = baseicp + dicp + globalischaemia/40
	spicp = spicp + globalischaemia/40
	map = map + dmap
	pulse = pulse + dpulse

	if (map > 120)
		map = 120;

	if (paco2 < 1.5)
		paco2 = 1.5;

	if (tdsao2 > 0) {						//sao2
		tdsao2 = tdsao2 - 1
		if (tdsao2 == 0)
			dsao2 = 0;
	}
	else {
		if (sao2 > spsao2)
			sao2 = sao2 - 1;
		else {
			if (sao2 < spsao2)
				sao2 = sao2 + 2;
		}
	}

	if (tdpaco2 > 0) {						//paco2
		tdpaco2 = tdpaco2 - 1
		if (tdpaco2 == 0)
			dpaco2 = 0;
	}
	else {
		if (paco2 > sppaco2)
			paco2 = paco2 - driftpaco2;
		else {
			if (paco2 < sppaco2)
				paco2 = paco2 + driftpaco2;
		}
	}

	if (tdicp > 0) {						//icp
		tdicp = tdicp - 1
		if (tdicp == 0)
			dicp = 0;
	}
	else {
		if (baseicp > spicp) {
			if ((baseicp - spicp) < drifticp)
				drifticp = drifticp / 2
			else if ((baseicp - spicp) > (drifticp * 2))
				drifticp = drifticp * 2
			baseicp = baseicp - drifticp - Math.floor(Math.random()*3)-1;
		}
		else {
			if (baseicp < spicp) {
				if ((spicp - baseicp) < drifticp)
					drifticp = drifticp / 2
				else if ((spicp - drifticp) > (drifticp * 2))
					drifticp = drifticp * 2
				baseicp = baseicp + drifticp + Math.floor(Math.random()*3)-1;
			}
		}
	}

	if (tdmap > 0) {						//map
		tdmap = tdmap - 1
		if (tdmap == 0)
			dmap = 0;
	}
	else {
		if (map > spmap)
			map = map - driftmap;
		else {
			if (map < spmap)
				map = map + driftmap;
		}
	}

	if (tdpulse > 0) {						//pulse
		tdpulse = tdpulse - 1
		if (tdpulse == 0)
			dpulse = 0;
	}
	else {
		if (pulse > sppulse)
			pulse = pulse - 10;
		else {
			if (pulse < sppulse)
				pulse = pulse + 10;
		}
	}

	if (tdcvp > 0) {						//cvp
		tdcvp = tdcvp - 1
		if (tdcvp == 0)
			dcvp = 0;
	}
	else {
		if (cvp > spcvp)
			cvp = cvp - driftcvp;
		else {
			if (cvp < spcvp)
				cvp = cvp + driftcvp;
		}
	}

	if (mannrecent > 0) {					//osmo
		mannrecent = mannrecent - 1;
	}
	if (osmolality > 280) {
		osmolality = osmolality - 2;
	}
}

function CalcIschaemia() {

	CalcVasoIndex()
	CalcICP()
	CalcCPP()
	CalcSjO()

	if (sao2 > 95)
		dglobal = 0
	if (sao2 <= 95)
		dglobal = (100-sao2)/100;
	if (sao2 < 80)
		dglobal = (100-sao2)/50;

	if (cpp>=75)
		dglobal = dglobal + 0;
	else
		dglobal = dglobal + (-0.02*cpp + 1.6);

	if (vasoindex>0)
		dglobal = dglobal + vasoindex/50

	globalischaemia = 100 * dglobal * barbindex

	if (globalischaemia < 0)
		globalischaemia = 0;

	if (globalischaemia >= 100)
		BrainDead();

	localischaemia = localischaemia + dlocal

	if (localischaemia < 0)
		localischaemia = 0;

}

CalcIschaemia();

function LetsGo() {

	info.location.href = pnew+"info.html";
	visi.location.href = pnew+"vision.html";
	menu.location.href = pnew+"menu.html";
	moni.location.href = pnew+"monitor.html";

}

function LetsMove() {

	if (page == 1) {
		if (menu.choice == 1 || menu.choice == 2) {							//not airway//
			dsao2 = -20;
			tdsao2 = 1;
			deadmessage = "Why is he braindead?  Because you failed dismally at the first hurdle.  First principles - come first!";
		}
		if (menu.choice == 3) {										//airway//
			dsao2 = +23;
			tdsao2 = 1;
		}
		pnew = "02"

	}

	if (page == 2) {
		if (menu.choice == 1) {										//intubate//
			if (bleeder) {
				spmap = 40; dmap = -8; tdmap = 6;
				sppulse = 130; dpulse = 20; tdpulse = 6;
			}
			pnew = "03"
		}
		if (menu.choice == 2 || menu.choice == 3) {							//dead
			dsao2 = -30;
			tdsao2 = 1;
			deadmessage = "So - you identified an airway problem, and then promptly forgot about it. Why?";
		}
	}

	if (page == 3) {
		if (menu.choice == 3) {										//dead//
			icp = icp + 60;
			deadmessage = "The patient's ICP shot through the roof.  It does this when a nasotracheal tube enters the cranial vault";
		}
		else {
			if (menu.choice == 1) {									// tube, no drugs //
				dicp = 15; tdicp = 2;
			}
			if (menu.choice == 2) {									// rsi //
				dicp = 5; tdicp = 1;
			}
			paco2 = 4.5;
			dpaco2 = 0; tdpaco2 = 0;
			sao2 = 95;
			dsao2 = 0; tdsao2 = 0;
			pnew = "04"
		}
	}

	if (page == 4) {
		if (menu.choice == 1) {										//mannitol//
			Mannitol();
			pnew = "05";
		}
		if (menu.choice == 2) {										//hyperventilate//
			dpaco2 = -0.5; tdpaco2 = 4
			pnew = "05";
		}
		if (menu.choice == 3) {										//blood//
			if (!bleeder) {
				dmap = 10; tdmap = 2
				cvp = cvp + 10;
				pnew = "05";
			}
			else {
				dmap = 10; tdmap = 1
				pnew = "05";
			}
		}
		if (menu.choice == 4) {										//none//
			pnew = "05";
		}
	}

	if (page == 5) {
		if (menu.choice == 1) {										//burr holes//
			deadmessage = "You drill holes into the patient's skull.  Three emergency burr holes on the right. Nothing comes out.  Three on the other side.  Nothing.  Idiot." 
			BrainDead();
		}
		if (menu.choice == 2) {										//laparotomy//
			if (bleeder) {
				pulse = 80; sppulse = 80; driftpulse = 10;
				map = 100; spmap = 100;
				cvp = 10;
			}
			else {
			 	icp = icp + 50; dicp = 15; tdicp = 4;
			}
			laparotomy = 1;
			pnew = "06";
		}
		if (menu.choice == 3) {										//CT scan//
			if (bleeder) {
				pulse = 160; map = 30; cvp = -3
			}
			pnew = "06";
		}
	}

	if (page == 6) {
		if (menu.choice == 1) {										//burr holes//
			deadmessage = "You drill holes into the patient's skull.<p>Three emergency burr holes on the right - Nothing comes out. <p> Three on the other side -  Nothing. <p>Idiot." 
			BrainDead();
		}
		if (menu.choice == 2) {										//craniotomy//
			craniotomy = 1;
			sppulse = 90;
			dpulse = 0; tdpulse = 0
			spmap = 95; driftmap = 10
			dmap = 0; tdmap = 0
			spicp = 25;
			dicp = 0; tdicp = 0; drifticp = 5;
			bleeder = 0;
			pnew = "07";
		}
		if (menu.choice == 3) {										//ITU//
			if (haematoma) {
				spicp = spicp + 30; drifticp = 15;
				spmap = 115; driftmap = 10 ;
				dmap = 0; tdmap = 0
			}
			else {
				sppulse = 90;
				dpulse = 0; tdpulse = 0
				spmap = 95; driftmap = 10
				dmap = 0; tdmap = 0
				spicp = 25;
				dicp = 0; tdicp = 0; drifticp = 5;
				bleeder = 0;
			}
			currentmessage = "";
			pnew = "07";
		}
	}

	if (page == 7) {												// needs MAP support - norepi
		if (menu.choice == 1) {
			MVUp();
		}
		if (menu.choice == 3) {
			MVDown();
		}
		if (menu.choice == 6) {
			Norepi();
		}
		if (norepi) {
			if (menu.choice == 7) {
				Surgeons();
			}
			if (menu.choice == 8) {
				NorepiDown();
			}
		}
		else {
			if (menu.choice == 7) {
				NorepiDown();
			}
		}
		if (menu.choice == 2) {
			Mannitol();
		}
		if (menu.choice == 4) {
			BarbComa();
		}
		if (menu.choice == 5) {
			CTScan();
		}
		pnew = "07"
	}


	if (page == 8) {												// ventilatory problem
		if (menu.choice == 1) {
			MVUp();
		}
		if (menu.choice == 3) {
			MVDown();
		}
		if (menu.choice == 6) {
			Norepi();
		}
		if (norepi) {
			if (menu.choice == 7) {
				Surgeons();
			}
			if (menu.choice == 8) {
				NorepiDown();
			}
		}
		else {
			if (menu.choice == 7) {
				NorepiDown();
			}
		}
		if (menu.choice == 2) {
			Mannitol();
		}
		if (menu.choice == 4) {
			BarbComa();
		}
		if (menu.choice == 5) {
			CTScan();
		}
		count = count + 1;
		if (count == 1) {
			sppulse = 90;
			dpulse = 0; tdpulse = 0
			spicp = 25;
			dicp = 0; tdicp = 0; drifticp = 5;
			paco2 = 6
			sppaco2 = 7.5;
			driftpaco2 = 1
			currentmessage = "";
		}
	}

	if (page == 9) {												// icp rise
		if (menu.choice == 1) {
			MVUp();
		}
		if (menu.choice == 3) {
			MVDown();
		}
		if (menu.choice == 6) {
			Norepi();
		}
		if (norepi) {
			if (menu.choice == 7) {
				Surgeons();
			}
			if (menu.choice == 8) {
				NorepiDown();
			}
		}
		else {
			if (menu.choice == 7) {
				NorepiDown();
			}
		}
		if (menu.choice == 2) {
			Mannitol();
		}
		if (menu.choice == 4) {
			BarbComa();
		}
		if (menu.choice == 5) {
			CTScan();
			ctindicated = 0;
			count = 0;
			pnew = "10"
		}
		if (menu.choice != 5) {
			pnew = "09"
		}
		count = count + 1
		if (count == 1) {
			ctindicated = 1
			baseicp = baseicp + 15;
			spicp = spicp + 25;
			drifticp = 5;
		}
	}

	if (page == 10) {												// icp rise
		if (menu.choice == 1) {
			MVUp();
		}
		if (menu.choice == 3) {
			MVDown();
		}
		if (menu.choice == 6) {
			Norepi();
		}
		if (norepi) {
			if (menu.choice == 7) {
				Surgeons();
			}
			if (menu.choice == 8) {
				NorepiDown();
			}
		}
		else {
			if (menu.choice == 7) {
				NorepiDown();
			}
		}
		if (menu.choice == 2) {
			Mannitol();
		}
		if (menu.choice == 4) {
			BarbComa();
		}
		if (menu.choice == 5) {
			CTScan();
		}
		count = count + 1
		if (count == 2) {
			baseicp = 50; spicp = 50;
			pnew = "11"
		}
		else
			pnew = "10"
	}

	if (page == 11) {												// peristent icp - barb coma
		if (menu.choice == 1) {
			MVUp();
		}
		if (menu.choice == 3) {
			MVDown();
		}
		if (menu.choice == 6) {
			Norepi();
		}
		if (menu.choice == 7) {
			NorepiDown();
			}
		if (menu.choice == 2) {
			Mannitol();
		}
		if (menu.choice == 4) {
			BarbComa();
		}
		if (menu.choice == 5) {
			CTScan();
		}
		if (barb) {
			pnew = "12"
			count = 0
			paco2 = 3.5
			sppaco2 = 2.0; driftpaco2 = 0.5
			spicp = 25; drifticp = 5
		}
		else
			pnew = "11"
	}


	if (page == 12) {												// ventilation improves - hypocapnia
		if (menu.choice == 1) {
			MVUp();
		}
		if (menu.choice == 3) {
			MVDown();
		}
		if (menu.choice == 6) {
			Norepi();
		}
		if (norepi) {
			if (menu.choice == 7) {
				Surgeons();
			}
			if (menu.choice == 8) {
				NorepiDown();
			}
		}
		else {
			if (menu.choice == 7) {
				NorepiDown();
			}
		}
		if (menu.choice == 2) {
			Mannitol();
		}
		if (menu.choice == 4) {
			BarbComa();
		}
		if (menu.choice == 5) {
			CTScan();
		}
		if (globalischaemia == 0) {
			pnew = "13"
			sppaco2 = 4;
			count = 0;
			if (!laparotomy)
				bleeder = 1
			else
				bleeder = Math.floor(Math.random()*2);
			if (bleeder) {									// bleeding
				map = 100; spmap = 40; driftmap = 15;
				cvp = -2; spcvp = -2
				pulse = 100; sppulse = 120; driftpulse = 10
			}
			else {									// compartment syndrome
				map = 100; spmap = 90; driftmap = 10;
				cvp = 16; spcvp = 24; driftcvp = 4
				paco2 = 8.5; sppaco2 = 8.5; driftpaco2 = 1
				pulse = 100; sppulse = 120; driftpulse = 10
				spicp = 35; drifticp = 5
			}
		}
		else {
			pnew = "12"
			count = count + 1
			if (count == 1) {
				currentmessage = "The patient's ventilatory status appears to improve"
			}
		}
	}

	if (page == 13) {												// haemodynamic disturbance
		if (menu.choice == 1) {
			MVUp();
		}
		if (menu.choice == 3) {
			MVDown();
		}
		if (menu.choice == 6) {
			Norepi();
		}
		if (norepi) {
			if (menu.choice == 7) {
				Surgeons();
				surgindicated = 1;
			}
			if (menu.choice == 8) {
				NorepiDown();
			}
		}
		else {
			if (menu.choice == 7) {
				NorepiDown();
			}
		}
		if (menu.choice == 2) {
			Mannitol();
		}
		if (menu.choice == 4) {
			BarbComa();
		}
		if (menu.choice == 5) {
			CTScan();
		}
		if (surgindicated) {
			pnew = "14"
			count = 0;
		}
		else {
			pnew = "13"
		}
	}

	if (page == 14) {
		if (menu.choice == 2) {										//ct abdo -> dead
			if (bleeder) {
				map = 30; spmap = 30;
				deadmessage = "You send the patient to the CT scanner.  You send the HAEMODYNAMICALLY UNSTABLE patient to the CT scanner.<p>The patient does not come back." 
				BrainDead();
			}
			else {
				surgresult = "The CT scan shows a very distended abdomen with multiple loops of dilated, oedematous bowel. ";
				surgresult = surgresult + "The inferior vena cava is compressed.  There is no free fluid in the abdomen. ";
			}
		}
		if (menu.choice == 1) {										//ultrasound abdo
			if (bleeder) {
				surgresult = "You get an ultrasound of the abdomen which shows large amounts of free fluid in the ";
				surgresult = surgresult + "abdomen.  You call back the surgeons and insist the patient goes to the ";
				surgresult = surgresult + "operating room for intra-abdominal haemorrhage.<p>";
				if (laparotomy) {
					surgresult = surgresult + "At laparotomy a tie has slipped off the splenic artery stump. ";
					surgresult = surgresult + "Haemorrhage control is achieved rapidly and the patient returned to the ICU. ";
				}
				else {
					surgresult = surgresult + "At laparotomy a subcapsular haematoma has burst and there was a significant ";
					surgresult = surgresult + "amount of intraperitoneal blood.<p>";
					surgresult = surgresult + "Haemorrhage control is achieved rapidly with a splenectomy and the patient returned to the ICU. ";
				}
				count = 1;
			}
			else
				surgresult = "You get an ultrasound of the abdomen which is essentially normal";
		}
		if (menu.choice == 3) {										//measure iabp
			if (!bleeder) {
				surgresult = "You measure intra-abdominal pressure via a bladder catheter.  The pressure is 32 cm water. ";
				surgresult = surgresult + "You call back the surgeons and inform them of your findings.  You ask them to ";
				surgresult = surgresult + "take the patient back to theatre to re-open the abdomen to treat his ";
				surgresult = surgresult + "abdominal compartment syndrome.<p> ";
				surgresult = surgresult + "The abdomen is reopened.  No new injuries are identified and the liver is not bleeding.";
				surgresult = surgresult + "A laparostomy is created with a vacuum-pack technique.";
				count = 1;
			}
			else
				surgresult = "You measure intra-abdominal pressure via a bladder catheter.  The pressure is 12cm water - entirely normal.";
		}
		if (count == 0)
			pnew = "14"
		else {
			currentmessage = "The patient returns from the operating room and appears stable neurologically";
			spicp = 8; baseicp = 25; drifticp = 8;
			spmap = 100 + norepi * 10; map = 100 + norepi * 10; driftmap = 0;
			sppulse = 90; driftpulse = 5;
			paco2 = 4; sppaco2 = 4; driftpaco2 = 0
			cvp = 8; spcvp = 8; driftcvp = 0;
			bleeder = 0;
			pnew = "15"
			count = 0;
		}
	}

	if (page == 15) {												// improvement
		if (menu.choice == 1) {
			MVUp();
		}
		if (menu.choice == 3) {
			MVDown();
		}
		if (menu.choice == 6) {
			Norepi();
		}
		if (norepi) {
			if (menu.choice == 7) {
				Surgeons();
			}
			if (menu.choice == 8) {
				NorepiDown();
			}
		}
		else {
			if (menu.choice == 7) {
				NorepiDown();
			}
		}
		if (menu.choice == 2) {
			Mannitol();
		}
		if (menu.choice == 4) {
			BarbComa();
		}
		if (menu.choice == 5) {
			CTScan();
		}
		if (globalischaemia == 0 && norepi == 0 && !barb) {
			pnew = "16"
			count = 0;
		}
		else {
			count = count +1;
			pnew = "15"
		}
	}

	UpdateVariables();

	CalcIschaemia();

	if (globalischaemia == 0) {
		if (page == 7) {
			count = 0;
			bleeder = 0;
			currentmessage = "The Neur-O-Vision<font size='1'>(TM)</font> monitor confirms that global ischaemia reduced to a minimum ";
			currentmessage = currentmessage + "and you have optimised the cerebral perfusion pressure.";
			pnew = "08"
		}
		if (page == 8 && count > 1 && paco2 < 5) {
			currentmessage = "Increasing the minute ventilation reduces the PaCO<font size='1'>2</font> levels to normal and global ischaemia ";
			currentmessage = currentmessage + "is now minimised (according to the marvellous Neur-O-Vision<font size='1'>(TM)</font> monitor!).";
			count = 0;
			pnew = "09"
		}

	}


	LetsGo();

}
