

//<![CDATA[

<!--


function Client(){
//if not a DOM browser, hopeless
	this.min = false; if (document.getElementById){this.min = true;};

	this.ua = navigator.userAgent;
	this.name = navigator.appName;
	this.ver = navigator.appVersion;  

//Get data about the browser
	this.mac = (this.ver.indexOf('Mac') != -1);
	this.win = (this.ver.indexOf('Windows') != -1);

//Look for Gecko
	this.gecko = (this.ua.indexOf('Gecko') > 1);
	if (this.gecko){
		this.geckoVer = parseInt(this.ua.substring(this.ua.indexOf('Gecko')+6, this.ua.length));
		if (this.geckoVer < 20020000){this.min = false;}
	}
	
//Look for Firebird
	this.firebird = (this.ua.indexOf('Firebird') > 1);
	
//Look for Safari
	this.safari = (this.ua.indexOf('Safari') > 1);
	if (this.safari){
		this.gecko = false;
	}
	
//Look for IE
	this.ie = (this.ua.indexOf('MSIE') > 0);
	if (this.ie){
		this.ieVer = parseFloat(this.ua.substring(this.ua.indexOf('MSIE')+5, this.ua.length));
		if (this.ieVer < 5.5){this.min = false;}
	}
	
//Look for Opera
	this.opera = (this.ua.indexOf('Opera') > 0);
	if (this.opera){
		this.operaVer = parseFloat(this.ua.substring(this.ua.indexOf('Opera')+6, this.ua.length));
		if (this.operaVer < 7.04){this.min = false;}
	}
	if (this.min == false){
		alert('Your browser may not be able to handle this page.');
	}
	
//Special case for the horrible ie5mac
	this.ie5mac = (this.ie&&this.mac&&(this.ieVer<6));
}

var C = new Client();

//for (prop in C){
//	alert(prop + ': ' + C[prop]);
//}



//CODE FOR HANDLING NAV BUTTONS AND FUNCTION BUTTONS

//[strNavBarJS]
function NavBtnOver(Btn){
	if (Btn.className != 'NavButtonDown'){Btn.className = 'NavButtonUp';}
}

function NavBtnOut(Btn){
	Btn.className = 'NavButton';
}

function NavBtnDown(Btn){
	Btn.className = 'NavButtonDown';
}
//[/strNavBarJS]

function FuncBtnOver(Btn){
	if (Btn.className != 'FuncButtonDown'){Btn.className = 'FuncButtonUp';}
}

function FuncBtnOut(Btn){
	Btn.className = 'FuncButton';
}

function FuncBtnDown(Btn){
	Btn.className = 'FuncButtonDown';
}

function FocusAButton(){
	if (document.getElementById('CheckButton1') != null){
		document.getElementById('CheckButton1').focus();
	}
	else{
		if (document.getElementById('CheckButton2') != null){
			document.getElementById('CheckButton2').focus();
		}
		else{
			document.getElementsByTagName('button')[0].focus();
		}
	}
}




//CODE FOR HANDLING DISPLAY OF POPUP FEEDBACK BOX

var topZ = 1000;

function ShowMessage(Feedback){
	var Output = Feedback + '<br /><br />';
	document.getElementById('FeedbackContent').innerHTML = Output;
	var FDiv = document.getElementById('FeedbackDiv');
	topZ++;
	FDiv.style.zIndex = topZ;
	FDiv.style.top = TopSettingWithScrollOffset(30) + 'px';

	FDiv.style.display = 'block';

	ShowElements(false, 'input');
	ShowElements(false, 'select');
	ShowElements(false, 'object');

//Focus the OK button
	setTimeout("document.getElementById('FeedbackOKButton').focus()", 50);
	
//
}

function ShowElements(Show, TagName){
//Special for IE bug -- hide all the form elements that will show through the popup
	if (C.ie){
		var Els = document.getElementsByTagName(TagName);
		for (var i=0; i<Els.length; i++){
			if (Show == true){
				Els[i].style.display = 'inline';
			}
			else{
				Els[i].style.display = 'none';
			}
		}
	} 
}

function HideFeedback(){
	document.getElementById('FeedbackDiv').style.display = 'none';
	ShowElements(true, 'input');
	ShowElements(true, 'select');
	ShowElements(true, 'object');
	if (Finished == true){
		Finish();
	}
}


//GENERAL UTILITY FUNCTIONS AND VARIABLES

//PAGE DIMENSION FUNCTIONS
function PageDim(){
//Get the page width and height
	this.W = 600;
	this.H = 400;
	this.W = document.getElementsByTagName('body')[0].clientWidth;
	this.H = document.getElementsByTagName('body')[0].clientHeight;
}

var pg = null;

function GetPageXY(El) {
	var XY = {x: 0, y: 0};
	while(El){
		XY.x += El.offsetLeft;
		XY.y += El.offsetTop;
		El = El.offsetParent;
	}
	return XY;
}

function GetScrollTop(){
	if (document.documentElement && document.documentElement.scrollTop){
		return document.documentElement.scrollTop;
	}
	else{
		if (document.body){
 			return document.body.scrollTop;
		}
		else{
			return window.pageYOffset;
		}
	}
}

function GetViewportHeight(){
	if (window.innerHeight){
		return window.innerHeight;
	}
	else{
		return document.getElementsByTagName('body')[0].clientHeight;
	}
}

function TopSettingWithScrollOffset(TopPercent){
	var T = Math.floor(GetViewportHeight() * (TopPercent/100));
	return GetScrollTop() + T; 
}

//CODE FOR AVOIDING LOSS OF DATA WHEN BACKSPACE KEY INVOKES history.back()
var InTextBox = false;

function SuppressBackspace(e){ 
	if (InTextBox == true){return;}
	if (C.ie) {
		thisKey = window.event.keyCode;
	}
	else {
		thisKey = e.keyCode;
	}

	var Suppress = false;

	if (thisKey == 8) {
		Suppress = true;
	}

	if (Suppress == true){
		if (C.ie){
			window.event.returnValue = false;	
			window.event.cancelBubble = true;
		}
		else{
			e.preventDefault();
		}
	}
}

if (C.ie){
	document.attachEvent('onkeydown',SuppressBackspace);
	window.attachEvent('onkeydown',SuppressBackspace);
}
else{
	if (window.addEventListener){
		window.addEventListener('keypress',SuppressBackspace,false);
	}
}

function ReduceItems(InArray, ReduceToSize){
	var ItemToDump=0;
	var j=0;
	while (InArray.length > ReduceToSize){
		ItemToDump = Math.floor(InArray.length*Math.random());
		InArray.splice(ItemToDump, 1);
	}
}

function Shuffle(InArray){
	var Num;
	var Temp = new Array();
	var Len = InArray.length;

	var j = Len;

	for (var i=0; i<Len; i++){
		Temp[i] = InArray[i];
	}

	for (i=0; i<Len; i++){
		Num = Math.floor(j  *  Math.random());
		InArray[i] = Temp[Num];

		for (var k=Num; k < (j-1); k++) {
			Temp[k] = Temp[k+1];
		}
		j--;
	}
	return InArray;
}

function WriteToInstructions(Feedback) {
	document.getElementById('InstructionsDiv').innerHTML = Feedback;

}




function EscapeDoubleQuotes(InString){
	return InString.replace(/"/g, '&quot;')
}

function TrimString(InString){
        var x = 0;

        if (InString.length != 0) {
                while ((InString.charAt(InString.length - 1) == '\u0020') || (InString.charAt(InString.length - 1) == '\u000A') || (InString.charAt(InString.length - 1) == '\u000D')){
                        InString = InString.substring(0, InString.length - 1)
                }

                while ((InString.charAt(0) == '\u0020') || (InString.charAt(0) == '\u000A') || (InString.charAt(0) == '\u000D')){
                        InString = InString.substring(1, InString.length)
                }

                while (InString.indexOf('  ') != -1) {
                        x = InString.indexOf('  ')
                        InString = InString.substring(0, x) + InString.substring(x+1, InString.length)
                 }

                return InString;
        }

        else {
                return '';
        }
}

function FindLongest(InArray){
	if (InArray.length < 1){return -1;}

	var Longest = 0;
	for (var i=1; i<InArray.length; i++){
		if (InArray[i].length > InArray[Longest].length){
			Longest = i;
		}
	}
	return Longest;
}

//UNICODE CHARACTER FUNCTIONS
function IsCombiningDiacritic(CharNum){
	var Result = (((CharNum >= 0x0300)&&(CharNum <= 0x370))||((CharNum >= 0x20d0)&&(CharNum <= 0x20ff)));
	Result = Result || (((CharNum >= 0x3099)&&(CharNum <= 0x309a))||((CharNum >= 0xfe20)&&(CharNum <= 0xfe23)));
	return Result;
}

function IsCJK(CharNum){
	return ((CharNum >= 0x3000)&&(CharNum < 0xd800));
}

//SETUP FUNCTIONS
//BROWSER WILL REFILL TEXT BOXES FROM CACHE IF NOT PREVENTED
function ClearTextBoxes(){
	var NList = document.getElementsByTagName('input');
	for (var i=0; i<NList.length; i++){
		if ((NList[i].id.indexOf('Guess') > -1)||(NList[i].id.indexOf('Gap') > -1)){
			NList[i].value = '';
		}
		if (NList[i].id.indexOf('Chk') > -1){
			NList[i].checked = '';
		}
	}
}

//EXTENSION TO ARRAY OBJECT
function Array_IndexOf(Input){
	var Result = -1;
	for (var i=0; i<this.length; i++){
		if (this[i] == Input){
			Result = i;
		}
	}
	return Result;
}
Array.prototype.indexOf = Array_IndexOf;

//IE HAS RENDERING BUG WITH BOTTOM NAVBAR
function RemoveBottomNavBarForIE(){
	if ((C.ie)&&(document.getElementById('Reading') != null)){
		if (document.getElementById('BottomNavBar') != null){
			document.getElementById('TheBody').removeChild(document.getElementById('BottomNavBar'));
		}
	}
}




//HOTPOTNET-RELATED CODE

var HPNStartTime = (new Date()).getTime();
var SubmissionTimeout = 30000;
var Detail = ''; //Global that is used to submit tracking data

function Finish(){
//If there's a form, fill it out and submit it
	if (document.store != null){
		Frm = document.store;
		Frm.starttime.value = HPNStartTime;
		Frm.endtime.value = (new Date()).getTime();
		Frm.mark.value = Score;
		Frm.detail.value = Detail;
		Frm.submit();
	}
}



//JQUIZ CORE JAVASCRIPT CODE

var CurrQNum = 0;
var CorrectIndicator = ':-)';
var IncorrectIndicator = 'X';
var YourScoreIs = 'Your score is ';
var ContinuousScoring = true;
var CorrectFirstTime = 'Questions answered correctly first time: ';
var ShowCorrectFirstTime = true;
var ShuffleQs = false;
var ShuffleAs = false;
var DefaultRight = '*********';
var DefaultWrong = 'Sorry! Try again.';
var QsToShow = 36;
var Score = 0;
var Finished = false;
var Qs = null;
var QArray = new Array();
var ShowingAllQuestions = false;
var ShowAllQuestionsCaption = 'Show all questions';
var ShowOneByOneCaption = 'Show questions one by one';
var State = new Array();
var Feedback = '';
var TimeOver = false;
var strInstructions = '';

//The following variable can be used to add a message explaining that
//the question is finished, so no further marking will take place.
var strQuestionFinished = '';

function CompleteEmptyFeedback(){
	var QNum, ANum;
	for (QNum=0; QNum<I.length; QNum++){
//Only do this if not multi-select
		if (I[QNum][2] != '3'){
  		for (ANum = 0; ANum<I[QNum][3].length; ANum++){
  			if (I[QNum][3][ANum][1].length < 1){
  				if (I[QNum][3][ANum][2] > 0){
  					I[QNum][3][ANum][1] = DefaultRight;
  				}
  				else{
  					I[QNum][3][ANum][1] = DefaultWrong;
  				}
  			}
  		}
		}
	}
}

function SetUpQuestions(){
	var AList = new Array(); 
	var QList = new Array();
	var i, j;
	Qs = document.getElementById('Questions');
	while (Qs.getElementsByTagName('li').length > 0){
		QList.push(Qs.removeChild(Qs.getElementsByTagName('li')[0]));
	}
	var DumpItem = 0;
	if (QsToShow > QList.length){
		QsToShow = QList.length;
	}
	while (QsToShow < QList.length){
		DumpItem = Math.floor(QList.length*Math.random());
		for (j=DumpItem; j<(QList.length-1); j++){
			QList[j] = QList[j+1];
		}
		QList.length = QList.length-1;
	}
	if (ShuffleQs == true){
		QList = Shuffle(QList);
	}
	if (ShuffleAs == true){
		var As;
		for (var i=0; i<QList.length; i++){
			As = QList[i].getElementsByTagName('ol')[0];
			if (As != null){
  			AList.length = 0;
				while (As.getElementsByTagName('li').length > 0){
					AList.push(As.removeChild(As.getElementsByTagName('li')[0]));
				}
				AList = Shuffle(AList);
				for (j=0; j<AList.length; j++){
					As.appendChild(AList[j]);
				}
			}
		}
	}
	
	for (i=0; i<QList.length; i++){
		Qs.appendChild(QList[i]);
		QArray[QArray.length] = QList[i];
	}

//Show the first item
	QArray[0].style.display = '';
	
//Now hide all except the first item
	for (i=1; i<QArray.length; i++){
		QArray[i].style.display = 'none';
	}		
	SetQNumReadout();
	
	SetFocusToTextbox();
}

function SetFocusToTextbox(){
//if there's a textbox, set the focus in it
	if (QArray[CurrQNum].getElementsByTagName('input')[0] != null){
		QArray[CurrQNum].getElementsByTagName('input')[0].focus();
//and show a keypad if there is one
		if (document.getElementById('CharacterKeypad') != null){
			document.getElementById('CharacterKeypad').style.display = 'block';
		}
	}
	else{
  	if (QArray[CurrQNum].getElementsByTagName('textarea')[0] != null){
  		QArray[CurrQNum].getElementsByTagName('textarea')[0].focus();	
//and show a keypad if there is one
			if (document.getElementById('CharacterKeypad') != null){
				document.getElementById('CharacterKeypad').style.display = 'block';
			}
		}
//This added for 6.0.4.11: hide accented character buttons if no textbox
		else{
			if (document.getElementById('CharacterKeypad') != null){
				document.getElementById('CharacterKeypad').style.display = 'none';
			}
		}
	}
}

function ChangeQ(ChangeBy){
//The following line prevents moving to another question until the current
//question is answered correctly. Uncomment it to enable this behaviour. 
//	if (State[CurrQNum][0] == -1){return;}
	if (((CurrQNum + ChangeBy) < 0)||((CurrQNum + ChangeBy) >= QArray.length)){return;}
	QArray[CurrQNum].style.display = 'none';
	CurrQNum += ChangeBy;
	QArray[CurrQNum].style.display = '';
//Undocumented function added 10/12/2004
	ShowSpecialReadingForQuestion();
	SetQNumReadout();
	SetFocusToTextbox();
}

var HiddenReadingShown = false;
function ShowSpecialReadingForQuestion(){
//Undocumented function for showing specific reading text elements which change with each question
//Added on 10/12/2004
	if (document.getElementById('ReadingDiv') != null){
		if (HiddenReadingShown == true){
			document.getElementById('ReadingDiv').innerHTML = '';
		}
		if (QArray[CurrQNum] != null){
			var Children = QArray[CurrQNum].childNodes;
			for (var i=0; i<Children.length; i++){
			if (Children[i].className=="HiddenReading"){
					document.getElementById('ReadingDiv').innerHTML = Children[i].innerHTML;
					HiddenReadingShown = true;
//Hide the ShowAllQuestions button to avoid confusion
					if (document.getElementById('ShowMethodButton') != null){
						document.getElementById('ShowMethodButton').style.display = 'none';
					}
				}
			}	
		}
	}
}

function SetQNumReadout(){
	document.getElementById('QNumReadout').innerHTML = (CurrQNum+1) + ' / ' + QArray.length;
	if ((CurrQNum+1) >= QArray.length){
		if (document.getElementById('NextQButton') != null){
			document.getElementById('NextQButton').style.visibility = 'hidden';
		}
	}
	else{
		if (document.getElementById('NextQButton') != null){
			document.getElementById('NextQButton').style.visibility = 'visible';
		}
	}
	if (CurrQNum <= 0){
		if (document.getElementById('PrevQButton') != null){
			document.getElementById('PrevQButton').style.visibility = 'hidden';
		}
	}
	else{
		if (document.getElementById('PrevQButton') != null){
			document.getElementById('PrevQButton').style.visibility = 'visible';
		}
	}
}

I=new Array();
I[0]=new Array();I[0][0]=100;
I[0][1]='';
I[0][2]='0';
I[0][3]=new Array();
I[0][3][0]=new Array('Posterior wall myocardial infarction.','',1,0,1);
I[0][3][1]=new Array('RBBB.','',1,0,1);
I[0][3][2]=new Array('Mirror image dextrocardia.','',1,0,1);
I[0][3][3]=new Array('Wolf-Parkinson-White Syndron  type A.','',1,0,1);
I[0][3][4]=new Array('Wolf-Parkinson-White Syndrom type B.','Correct Answer:- All others are the causes and also: HOCM ,RVH. Remember TRUE and isolated posterior wall MI is very rare...But usually associated with inferior MI\u2026.so look also  at lead II,III,aVF( ie RCA occlusion ) Remember always mirror image dextrocardia and wrong Lead connection.',1,100,1);
I[1]=new Array();I[1][0]=100;
I[1][1]='';
I[1][2]='0';
I[1][3]=new Array();
I[1][3][0]=new Array('LVH','',1,0,1);
I[1][3][1]=new Array('RVH','',1,0,1);
I[1][3][2]=new Array('Digoxin effect','',1,0,1);
I[1][3][3]=new Array('early repolarization after an attack of angina','Correct Answer:- All others are associated with ST segment depression. Causes of ST elevation:  A-full thickness myocardial infarction   B-early repolarization after and attack of angina   C-acute pericarditis   D-ventricular aneurysm   E-transiently during cardiac and coronary angiography   F-Prinzmetal angina',1,100,1);
I[1][3][4]=new Array('subendocardial infarction','',1,0,1);
I[2]=new Array();I[2][0]=100;
I[2][1]='';
I[2][2]='0';
I[2][3]=new Array();
I[2][3][0]=new Array('Vnetricular Tachycardia','',1,0,1);
I[2][3][1]=new Array('Ventricular Fibrillation','',1,0,1);
I[2][3][2]=new Array('Ventricualr Premature Complexes','',1,0,1);
I[2][3][3]=new Array('Atrial Ectopics','',1,0,1);
I[2][3][4]=new Array('AV Nodal Re-entry Tachycardia','Correct Answer:- Remember, ventricular arrhythmias in WPW (apart from VF degenerated from AF) are highly atypical and suggest either an alternative diagnosis or co-existent pathology( eg amiodaron give in this patient in the long term causing long QT interval and then torsades depointes VT ) .',1,100,1);
I[3]=new Array();I[3][0]=100;
I[3][1]='';
I[3][2]='0';
I[3][3]=new Array();
I[3][3][0]=new Array('mental retardation','',1,0,1);
I[3][3][1]=new Array('pumonary artery stenosis','',1,0,1);
I[3][3][2]=new Array('branch pulmonary artery stenosis','',1,0,1);
I[3][3][3]=new Array('HOCM','',1,0,1);
I[3][3][4]=new Array('Mitral stenosis','Correct Answer:- Left sided cardiac lesions are not part of Noonan\'s syndrome and suggest an acquired defect e.g. Mitral Stenosis   Following Rheumatic fever. Remember ..short stature may be seen as is  full Turner\'s phenotype \u2026so be ware of a FEMALE with right sided cardiac lesions\u2026 it may be Noonan\'s as it is autosomal disease ( male=female )',1,100,1);
I[4]=new Array();I[4][0]=100;
I[4][1]='';
I[4][2]='0';
I[4][3]=new Array();
I[4][3][0]=new Array('Hypokalaemia','',1,0,1);
I[4][3][1]=new Array('Hypocalcaemia','',1,0,1);
I[4][3][2]=new Array('Hypomagnesaemia','',1,0,1);
I[4][3][3]=new Array('Hypermagnesaemia','Correct Answer:- Remember, long QT Syndrom is a risk for Torsades De pointes VT\u2026.Caused by: 1-Inherited Syndroms (Congenital Long QT syndromes)  2-Electrolyte imbalance (see above) 3-MVP  4-Rheumatic carditis 5-Drugs (like Class Ic and III antiarrhythmics \u2026LONG LISTED) 6-Bardycardia associated: any cause of bradycardia \u2026hence the use of isoprenalin infusion in such cases (be ware it is contraindicated in congenital cases).',1,100,1);
I[4][3][4]=new Array('Rheumatic carditis','',1,0,1);
I[5]=new Array();I[5][0]=100;
I[5][1]='';
I[5][2]='0';
I[5][3]=new Array();
I[5][3][0]=new Array('Caused by mutation in Na channels','',1,0,1);
I[5][3][1]=new Array('25% are associated with a positive family history','',1,0,1);
I[5][3][2]=new Array('30% are associated with left ventricular outflow obstruction','Correct Answer:- 1-Sarcolemmal contractile proteins gene mutation . 2- 50%. 4-many are asymptomatic .5- asymmetric septal type.',1,100,1);
I[5][3][3]=new Array('all patients are symptomatic','',1,0,1);
I[5][3][4]=new Array('the commonest type of hypertrophy is the Apical type.','',1,0,1);
I[6]=new Array();I[6][0]=100;
I[6][1]='';
I[6][2]='0';
I[6][3]=new Array();
I[6][3][0]=new Array('the commonest cause is the idiopathic type (may be viral)','',1,0,1);
I[6][3][1]=new Array('the majority progresses to tamponade','Correct Answer:- 1-yes\u2026.the usually seen type. 2-false rarely progresses\u2026most are benign  3- Yes with risk of bleeding into it  4-be ware of this \u2026.disappearance of the rub...Either:    a-transient...off on. which very common in clinical practice     b-resolution of the process     c-fluid collection in the sac   5-yes...Usualy came with pericardial constriction',1,100,1);
I[6][3][2]=new Array('in uraemic pericarditis, there is a risk of tamponade formation','',1,0,1);
I[6][3][3]=new Array('the rub is usually transient','',1,0,1);
I[6][3][4]=new Array('TB pericarditis is rarely an acute one','',1,0,1);
I[7]=new Array();I[7][0]=100;
I[7][1]='';
I[7][2]='0';
I[7][3]=new Array();
I[7][3][0]=new Array('70year old hypertensive male with acute chest pain and new diastolic murmur in the left lower sternum and ST elevation in lead II,III and aVF','Correct Answer:- 1-type A aortic dissection  2-pregnancy is considered a relative contraindication recently (was absolute previously  ...so update your readings) 3-proliferative diabetic retinopathy is a relative contraindication. 4-relative  5-STRONGLY indicated here.',1,100,1);
I[7][3][1]=new Array('40 year old lady with 7 missed periods and abdominal distension','',1,0,1);
I[7][3][2]=new Array('34 old diabetic male recently underwent "LASER Retinal therapy " as he said ..came with shock ,raised JVP and clear lungs.','',1,0,1);
I[7][3][3]=new Array('ST elevation in lead V1,V2,V3 with a blood pressure of 180/100 easily controlled with antihypertensive medications','',1,0,1);
I[7][3][4]=new Array('60 year old male who is a known case of ischemic heart disease presents with new LBBB and chest pain for 2 hours with ST elevation in V4, V5, and V6','',1,0,1);
I[8]=new Array();I[8][0]=100;
I[8][1]='';
I[8][2]='0';
I[8][3]=new Array();
I[8][3][0]=new Array('development of heart failure','',1,0,1);
I[8][3][1]=new Array('prolonged chest pain','',1,0,1);
I[8][3][2]=new Array('ST elevation','',1,0,1);
I[8][3][3]=new Array('high cardiac troponin T','',1,0,1);
I[8][3][4]=new Array('intermittent chest pain','Correct Answer:- 1,2,3 and 4 indicate bad outcome \u2026.Be ware of Risk stratification in unstable angina',1,100,1);
I[9]=new Array();I[9][0]=100;
I[9][1]='';
I[9][2]='0';
I[9][3]=new Array();
I[9][3][0]=new Array('the right coronary artery supplies  the AV node in 90 % of cases','',1,0,1);
I[9][3][1]=new Array('the right coronary artery supplies the SA nose in 60 % of cases','',1,0,1);
I[9][3][2]=new Array('left main stem coronary artery is easily dilated by at PTCA in atheromatous narrowing and should be routinely done in such cases.','Correct Answer:- 1 and 2 are true and indicates the predominance of the RCA system in cases of RCA occlusion causing  AV blocks like CHB in inferior MI . 3-false..although used by many PTCA Centers \u2026such an approach should be done only by those who are highly experienced in it ...otherwise CABG should be used .',1,100,1);
I[9][3][3]=new Array('Prinzmatal angina usually occurs at night','',1,0,1);
I[9][3][4]=new Array('Prinzmetal angina may occur with coronary atheroma','',1,0,1);
I[10]=new Array();I[10][0]=100;
I[10][1]='';
I[10][2]='0';
I[10][3]=new Array();
I[10][3][0]=new Array('40 % of it is iodine ..hence the risk of either hypo or hyperthyroidism','',1,0,1);
I[10][3][1]=new Array('potentiates the effect of warfarine','',1,0,1);
I[10][3][2]=new Array('potentiates the effect of digoxin','',1,0,1);
I[10][3][3]=new Array('corneal deposits of the drug are usually irreversible.','Correct Answer:- Usually reversible \u2026.be ware of other toxicities like pulmonary fibrosis , slate grey skin pigmentation ,hepatotoxicity\u2026\u2026Always be ware of drug interactions in any combinations .',1,100,1);
I[10][3][4]=new Array('prolonges the plataue phase of action potential .','',1,0,1);
I[11]=new Array();I[11][0]=100;
I[11][1]='';
I[11][2]='0';
I[11][3]=new Array();
I[11][3][0]=new Array('mediastinal lumphoma','',1,0,1);
I[11][3][1]=new Array('mediastinal irradiation 2 years previously .','',1,0,1);
I[11][3][2]=new Array('ST elevation in  lead rV4 and chest pain','',1,0,1);
I[11][3][3]=new Array('Liver Cirrhosis','Correct Answer:- 1-supeiror vena cava obstruction causes FIXED elevation  2-periccardical constriction  3-Right Ventricular  infarction  4-False\u2026..Hypovolemia causing low JVP( unless there is a coexsistent pathology like heavy alcoholism causing  Cirrhosis and cardiomyopathy \u2026..Also the JVP is useful in differentiating Cirrhosis from pericardial constriction  in established cases ) 5-Ebstein Anomaly and TR and right sided heart failure.',1,100,1);
I[11][3][4]=new Array('Atrialization of the right ventricle','',1,0,1);
I[12]=new Array();I[12][0]=100;
I[12][1]='';
I[12][2]='0';
I[12][3]=new Array();
I[12][3][0]=new Array('in adults usually causes and presents as hypertension','',1,0,1);
I[12][3][1]=new Array('BICUSPID AORTIC VALAVE is a common association','',1,0,1);
I[12][3][2]=new Array('Rib notching is usually seen from the 3rd rib till 9th rib in infancy','Correct Answer:- 1-the usual story (but heart failure in infancy) 2-true \u2026in certain series may reach 50 % 3-False \u2026usually seen after the age of 6  4- and 5 are true \u2026.hence in any young patient  with SAH and previous "high" blood pressure ..you must exclude coarctation of the aorta.',1,100,1);
I[12][3][3]=new Array('Dissection is a recognized complication','',1,0,1);
I[12][3][4]=new Array('Subarachnoid hemorrhage may occur.','',1,0,1);
I[13]=new Array();I[13][0]=100;
I[13][1]='';
I[13][2]='0';
I[13][3]=new Array();
I[13][3][0]=new Array('bisprolol','',1,0,1);
I[13][3][1]=new Array('metaprolol','',1,0,1);
I[13][3][2]=new Array('carvidolol','',1,0,1);
I[13][3][3]=new Array('spironolactone','',1,0,1);
I[13][3][4]=new Array('atenolol','Correct Answer:- Atenolol had not been studied in these trials. Other drugs that   improve the survival figure in chronic congestive heart failure are ACE inhibitors ( AT receptor blockers are still in the way of study may have the same effect !! )  Remember: Diuretics and Digoxin do not improve the survival figure in chronic congestive heart failure',1,100,1);
I[14]=new Array();I[14][0]=100;
I[14][1]='';
I[14][2]='0';
I[14][3]=new Array();
I[14][3][0]=new Array('streptococcus viridans is the cause of up to 50% of naitive valve endocarditis','',1,0,1);
I[14][3][1]=new Array('staph species  may be the cause in 50% of prosthetic valve endocarditis','',1,0,1);
I[14][3][2]=new Array('the commonest cause of culture negative endocarditis is partial treatment with antibiotics','',1,0,1);
I[14][3][3]=new Array('3 negative serial blood cultures  usually exclude infective endocarditis in the appropriate clinical setting','Correct Answer:- Causes of culture -ve endocarditis :  a-the commonest is prior antibiotic treatment   b-fastidious organism like HACEK group or a difficulty in culturing like brucella species .   c-fungal endocarditis, Q fever    d-marantic and libman sacks endocarditis   e-poor lab techniques and errors in collection of the blood samples ( staph epidermidis colonies FREQUENTLY reported by the lab as a NORMAL skin commensal  .',1,100,1);
I[14][3][4]=new Array('the sensitivity of transesophageal Echocardiography here is 95% versus 65% in the transthoracic approach .','',1,0,1);
I[15]=new Array();I[15][0]=100;
I[15][1]='';
I[15][2]='0';
I[15][3]=new Array();
I[15][3][0]=new Array('Ventricular septal defect','',1,0,1);
I[15][3][1]=new Array('HOCM','',1,0,1);
I[15][3][2]=new Array('combined mitral valve disease','',1,0,1);
I[15][3][3]=new Array('MVP with significant mitral regurgitation by Echo study','',1,0,1);
I[15][3][4]=new Array('Mitral stenosis','Correct Answer:- Any cardiac lesion that is associated with a  "JET" lesion due to high flow indicates a high risk.,\u2026so mitral stenosis is actually associated with a SLOW flow across the valve so low risk \u2026\u2026 Remember the highest risk is seen in : a-previous history of infective endicarditis whatever the original cause and predisposing factor was .b-Prosthetic Valves .',1,100,1);
I[16]=new Array();I[16][0]=100;
I[16][1]='';
I[16][2]='0';
I[16][3]=new Array();
I[16][3][0]=new Array('persistent fever may indicates a non bacterial cause like fugal cause .','',1,0,1);
I[16][3][1]=new Array('cidal drugs rather than statics should be used .','',1,0,1);
I[16][3][2]=new Array('always await the culture results before giving any treatment.','Correct Answer:- Always GUESS the "best treatment" based on risk factors and history eg staph or fungal endocarditis in iv drug addicts  and give the treatment accordingly pending the culture results . Always remember that persistent FEVER  may indicate failure of medical treatment and persistent infection so  the need for surgery ,YET other causes should always excluded :  a-resistant organism .eg staph aureus to benzyl penicillin   b-non bacterial cause like fungal organisms   c-superficial thrombophlebitis as these drugs are given by an iv rout .  d-"Drug Fever "  e-coexsistent pathology like wound infection or a visceral abscess that is difficult to be treated which may be actually the cause of the endocrditis eg staph abscess disseminating to produce metastatic lesions including the  heart valves.',1,100,1);
I[16][3][3]=new Array('intravenous route is always preferred .','',1,0,1);
I[16][3][4]=new Array('persistent fever may indicate a drug fever .','',1,0,1);
I[17]=new Array();I[17][0]=100;
I[17][1]='';
I[17][2]='0';
I[17][3]=new Array();
I[17][3][0]=new Array('malar flush may be seen','',1,0,1);
I[17][3][1]=new Array('low cardiac output state','',1,0,1);
I[17][3][2]=new Array('rarely congenital','',1,0,1);
I[17][3][3]=new Array('S3 sound is commonly seen','Correct Answer:- S3 indicate rapid early ventricular filling and /or high flow across  the mitral valve ( or tricuspid valve in right sided S3) \u2026so it is not the case in PURE mitral stenosis as the flow is already impeded across the calve \u2026.if you are sure that it is mitral stenosis and you heard  left ventricular S3 sound ..so this indicates MIXED mitral valve disease with the regurgitation is the predominant lesion or an associated aortic regurgitation ( always remember that rheumatic heart disease is frequently associated with multiple valvular lesions \u2026\u2026\u2026.but be sure it is not a right ventricular S3 as this may be seen in PURE mitral stenosis due to right sided heart failure\u2026.so BE CAREFUL .',1,100,1);
I[17][3][4]=new Array('20 % stays in sinus rhythm despite severe stenosis','',1,0,1);
I[18]=new Array();I[18][0]=100;
I[18][1]='';
I[18][2]='0';
I[18][3]=new Array();
I[18][3][0]=new Array('Carotid shudder is common','',1,0,1);
I[18][3][1]=new Array('syncpoe indicates an urgent need for intervention','',1,0,1);
I[18][3][2]=new Array('it is sub-valvular in William\'s Syndrom','Correct Answer:- It is supravalvular in William\'s (with mental retardation and hypercalcaemia and elfin faces) . The thrill is commonly felt at the neck (carotid shudder) and once symptoms appear you have to intervene..Usually ending with valve replacement Remember: always see the age of the patient as this may indicate the cause and always see features of HOCM as the management is totally different and AS per se is a risk factor for infective endocarditis before and after surgery.',1,100,1);
I[18][3][3]=new Array('marked LVH per se is a risk factor for angina and arrhythmias','',1,0,1);
I[18][3][4]=new Array('valve replacement is the usual mode of treatment','',0,0,1);
I[19]=new Array();I[19][0]=100;
I[19][1]='';
I[19][2]='0';
I[19][3]=new Array();
I[19][3][0]=new Array('Reduction of the after load','',1,0,1);
I[19][3][1]=new Array('optimization of the preload','',1,0,1);
I[19][3][2]=new Array('augmentation of the cardiac contractility','',1,0,1);
I[19][3][3]=new Array('controlloing the heart rate','',1,0,1);
I[19][3][4]=new Array('aggressive diuresis to remove all edemas','Correct Answer:- Always LEAVE some leg edema (ie one plus edema ) as total DRYNESS means profound hypovolemia and many complication eg prerenal failure and electrolyte imbalance.',1,100,1);
I[20]=new Array();I[20][0]=100;
I[20][1]='';
I[20][2]='0';
I[20][3]=new Array();
I[20][3][0]=new Array('aortic regurgitation usually causes diastolic dysfunction','',1,0,1);
I[20][3][1]=new Array('till now there is no general consensus about the optimal medical management for it','Correct Answer:- The objectives of treatment in this diastolic heart failure differs from  the congestive heart failure states with systolic dysfynction \u2026\u2026targets :  a-control rate\u2026to give time for the ventricle to fill properly hence tachycardias have a deleterious effect .  b-control edema ..eg diuretic  c-control hypertension and the original disease ..eg Aortic stenosis   Till now and unfortunately there  is no general consensus about the optimal medical management for it and ACE inhibitors have NO effect on the overall mortality  figure ( cf systolic congestive heart failure ). Aortic stenosis not regurgitation is a cause .',1,100,1);
I[20][3][2]=new Array('myocardial ischemia starts with systolic dysfunction','',1,0,1);
I[20][3][3]=new Array('tachycardia is needed to compensate for the defect and hence the heart rate should be kept above 90 beats/minutes','',1,0,1);
I[20][3][4]=new Array('ACE inhibitors had been shown to improve the overall mortality figure','',1,0,1);
I[21]=new Array();I[21][0]=100;
I[21][1]='';
I[21][2]='0';
I[21][3]=new Array();
I[21][3][0]=new Array('rapidly developing','',1,0,1);
I[21][3][1]=new Array('poor response to standard medical therapy','',1,0,1);
I[21][3][2]=new Array('age blow 20 and  above 50 years','',1,0,1);
I[21][3][3]=new Array('certain physical signs like mooning of the face and abdominal striae','',1,0,1);
I[21][3][4]=new Array('strong family history of hypertension','Correct Answer:- But be ware that secondary hypertension may develop in the way of long standing essential hypertension like the development of  atherosclerorotic renal artery stenosis and causing deterioration in the in the control. So keep this in mind. Remember: renal artery stenosis is both a cause and effect of hypertension  Remember: renal failure is both a cause and an effect of hypertension',1,100,1);
I[22]=new Array();I[22][0]=100;
I[22][1]='';
I[22][2]='0';
I[22][3]=new Array();
I[22][3][0]=new Array('very weak effect on the coronary arteries','',1,0,1);
I[22][3][1]=new Array('a strong risk factor for the development of intracerebral bleeding','Correct Answer:- The most important risk is the intracerebral bleeding \u2026..and diuretics are the first line agent in old people with essential hypertension   and in diabetic nephropathy the target is blow  125 / 72 mmHg .',1,100,1);
I[22][3][2]=new Array('in diabetic nephropathy the target blood pressure should be  140 / 85mmHg','',1,0,1);
I[22][3][3]=new Array('ACE inhibitors should be routinely prescribed','',1,0,1);
I[22][3][4]=new Array('Diuretics are usually not effective in elderly','',1,0,1);
I[23]=new Array();I[23][0]=100;
I[23][1]='';
I[23][2]='0';
I[23][3]=new Array();
I[23][3][0]=new Array('hyperhomocystenemia','',1,0,1);
I[23][3][1]=new Array('obesity','',1,0,1);
I[23][3][2]=new Array('sedentary life style','',1,0,1);
I[23][3][3]=new Array('high blood fibrinogen','',1,0,1);
I[23][3][4]=new Array('diet rich in vegetables .','Correct Answer:- Review the risk factors well .',1,100,1);
I[24]=new Array();I[24][0]=100;
I[24][1]='';
I[24][2]='0';
I[24][3]=new Array();
I[24][3][0]=new Array('Diastolic heart failure','',1,0,1);
I[24][3][1]=new Array('Coronary artery disease','',1,0,1);
I[24][3][2]=new Array('Stroke','',1,0,1);
I[24][3][3]=new Array('peripheral vascular disease','',1,0,1);
I[24][3][4]=new Array('Systolic heart  failure','Correct Answer:- Isolated systolic heart failure is highly unusual in long standing hypertension and suggests a coexistent pathology like toxic causes .',1,100,1);
I[25]=new Array();I[25][0]=100;
I[25][1]='';
I[25][2]='0';
I[25][3]=new Array();
I[25][3][0]=new Array('may present as  an SBE like picture','',0,0,1);
I[25][3][1]=new Array('may present as a vasculitis like picture','',0,0,1);
I[25][3][2]=new Array('high recurrence following surgery in sporadic cases','Correct Answer:- High incidence of Recurrence following surgery  indicates familial predisposition . Remember the commonest site is the fossa  ovaslis area of the left side of the interatrial septum (70 %) ..atypical sites indicates and  occurs in familial cases.',1,100,1);
I[25][3][3]=new Array('high recurrence following surgery in familial cases','',0,0,1);
I[25][3][4]=new Array('when arises from the right side of the heart we should think of familiar predisposition','',0,0,1);
I[26]=new Array();I[26][0]=100;
I[26][1]='';
I[26][2]='0';
I[26][3]=new Array();
I[26][3][0]=new Array('rapid  x descent and steep  y descent occurs in pericardial constriction','',1,0,1);
I[26][3][1]=new Array('rapid x descent and blunted y descent occurs in pericardial tamopnade','',1,0,1);
I[26][3][2]=new Array('lagre CV wave occurs in tricuspid regurgitation','',1,0,1);
I[26][3][3]=new Array('hepatojugular reflux is important only if it sustains with continuous pressure on the abdomen','',1,0,1);
I[26][3][4]=new Array('regular cannon A waves indicates complete heart block','Correct Answer:- The JVP is a good " window " to see what is happening in the heart \u2026. In heart block the cannon a waves are irregular \u2026if regular it may indicate a Nodal rhythm .',1,100,1);
I[27]=new Array();I[27][0]=100;
I[27][1]='';
I[27][2]='0';
I[27][3]=new Array();
I[27][3][0]=new Array('early phase acute anterior wall MI','',1,0,1);
I[27][3][1]=new Array('WPW syndrome','Correct Answer:- WPW has many diverse and atypical ECG manifestations like psudo- MI pattern  ,pseudo-LVH pattern  Posterior MI has a prominent R in lead V1 .. Other causes of pathological Q : HOCM and error in leading',1,100,1);
I[27][3][2]=new Array('established subendocarial infarction','',1,0,1);
I[27][3][3]=new Array('established acute phase isolated posterior MI','',1,0,1);
I[27][3][4]=new Array('during Prinzmetal angina','',1,0,1);
I[28]=new Array();I[28][0]=100;
I[28][1]='';
I[28][2]='0';
I[28][3]=new Array();
I[28][3][0]=new Array('aspirin per se reduces the mortality by 30%','',1,0,1);
I[28][3][1]=new Array('thrombolysis reduces the overall mortality by 25-50%','',1,0,1);
I[28][3][2]=new Array('beta blockers like iv metoprolol greatly reduces the susceptibility to arrhythmias','',1,0,1);
I[28][3][3]=new Array('iv nitroglycerin have no effect on the overall mortality figure','',1,0,1);
I[28][3][4]=new Array('Morphin better to be given by a subcutaneous rout rather than iv because this confers a longer half life','Correct Answer:- Morphin should be given  iv as there is a risk of hematoma formation in SC rout (remember the patient will be on thrombolytics, aspirin and heparin ) Aspirin per se enhances the effect of the thrombolytic therapy .',1,100,1);
I[29]=new Array();I[29][0]=100;
I[29][1]='';
I[29][2]='0';
I[29][3]=new Array();
I[29][3][0]=new Array('ACE inhibitors have a favorable effect by many independent  mechanisms','',1,0,1);
I[29][3][1]=new Array('Bata blocker are important if no contraindication to it','',1,0,1);
I[29][3][2]=new Array('Statins had been shown to produce regression of the atherosclerotic plaques','',1,0,1);
I[29][3][3]=new Array('cardiac rehabilitation programs should not be forgotten','',1,0,1);
I[29][3][4]=new Array('Digoxin had been shown to have a favorable effect','Correct Answer:- No place for  Digoxin in secondary prophylaxis of MI  Remember the 4 drugs in this topic : Aspirin  ACE inhibitors  Beta blockers  Statins',1,100,1);
I[30]=new Array();I[30][0]=100;
I[30][1]='';
I[30][2]='0';
I[30][3]=new Array();
I[30][3][0]=new Array('uncontrolled hypertension','',1,0,1);
I[30][3][1]=new Array('fever or a febrile illness','',1,0,1);
I[30][3][2]=new Array('severe aortic stenosis','',1,0,1);
I[30][3][3]=new Array('acute pericarditis','',1,0,1);
I[30][3][4]=new Array('subjective feeling weakness','Correct Answer:- There are many contraindications to exercise testing but just feeling weak may interfere with interpretation of the test but not a contraindication',1,100,1);
I[31]=new Array();I[31][0]=100;
I[31][1]='';
I[31][2]='0';
I[31][3]=new Array();
I[31][3][0]=new Array('deep ST depression','',1,0,1);
I[31][3][1]=new Array('wide spread ECG changes upon exercise','',1,0,1);
I[31][3][2]=new Array('prolonged ST depression after finishing  the test','',1,0,1);
I[31][3][3]=new Array('ST elevation  per se','',1,0,1);
I[31][3][4]=new Array('Mild -moderate ST T segment abnormalities in middle aged woman with chest pain with no risk factors for ischemic heart disease','Correct Answer:- Such  changes in middle aged woman  with chest pain usually are seen  and unfortunately affect  the interpretation  of the test as "false positive"  No1,2,3and 4 and also development of such changes at an early stage of Bruce protocol indicate a STRONG +ve test',1,100,1);
I[32]=new Array();I[32][0]=100;
I[32][1]='';
I[32][2]='0';
I[32][3]=new Array();
I[32][3][0]=new Array('prior treatment with digoxin','',1,0,1);
I[32][3][1]=new Array('treatment with beta blockers','',1,0,1);
I[32][3][2]=new Array('marked LVH per se','',1,0,1);
I[32][3][3]=new Array('early development of wide spread ECG changes in stage I Bruce protocol','Correct Answer:- Item 4  indicates a strong positive exercise ECG and should be followed by angiography  Others are truly a cause of such a false positive results and also electrolyte disturbances ,myocarditis ,HOCM.',1,100,1);
I[32][3][4]=new Array('MVP','',1,0,1);
I[33]=new Array();I[33][0]=100;
I[33][1]='';
I[33][2]='0';
I[33][3]=new Array();
I[33][3][0]=new Array('pulmonary thromboembolism','',1,0,1);
I[33][3][1]=new Array('tension pneumothorax','',1,0,1);
I[33][3][2]=new Array('profound shock   due to bleeding','',1,0,1);
I[33][3][3]=new Array('hypokalemia','',1,0,1);
I[33][3][4]=new Array('treatment with xylocain','Correct Answer:- This is  pulseless electrical activity ( PEA ) previously called electromechanical dissociation \u2026\u2026 So don\u2019t jump to DC the MI patient in the CCU .."cardiac arrest " is not always due to VF / VT causing death like appearance and no pulse ..so always check the monitor first and be calm \u2026this is the objective of the CCU monitors !!!',1,100,1);
I[34]=new Array();I[34][0]=100;
I[34][1]='';
I[34][2]='0';
I[34][3]=new Array();
I[34][3][0]=new Array('had been shown to decrease ventricular remodeling and hence aneurismal formation','',1,0,1);
I[34][3][1]=new Array('prevent the onset of overt heart failure in asymptomatic patient','',1,0,1);
I[34][3][2]=new Array('reduce the hospitalization rate','',1,0,1);
I[34][3][3]=new Array('should be given to all patient if tolerated and no contraindication','',1,0,1);
I[34][3][4]=new Array('contraindicated in post MI patient with a chronic renal failure','Correct Answer:- ACE inhibitors  in item 5 had been shown to be greatly effective and of great benefit \u2026don\u2019t be afraid of the " RENAL effect of ACE inhibitors" here \u2026actually  it is the drug of choice in uremia with  hypertension  post MI secondary prophylaxis states',1,100,1);
I[35]=new Array();I[35][0]=100;
I[35][1]='';
I[35][2]='0';
I[35][3]=new Array();
I[35][3][0]=new Array('loop diuretics are preferred because of its powerful effect .','Correct Answer:- Thiazides are the first line agents \u2026loop diuretics are the first line agents in heart failure . Be ware of long term complications of diuretic use\u2026like acid base and electrolyte disturbamce..hyperlipdemia, hyperurecemia .etc',1,100,1);
I[35][3][1]=new Array('Diuretics in the treatment of hypertension uncommonly produces acid base and electrolyte disturbances compared when used in the treatment of heart failure states','',1,0,1);
I[35][3][2]=new Array('As an anti- hypertensive medication \u2026..they work by an independent mechanism of their  DIURETIC action .','',1,0,1);
I[35][3][3]=new Array('first line agents in an elderly  with systolic hypertension','',1,0,1);
I[35][3][4]=new Array('may worsen the lipid profile','',1,0,1);


function StartUp(){
	RemoveBottomNavBarForIE();

//If there's only one question, no need for question navigation controls
	if (QsToShow < 2){
		document.getElementById('QNav').style.display = 'none';
	}
	
//Stash the instructions so they can be redisplayed
	strInstructions = document.getElementById('InstructionsDiv').innerHTML;
	

	

	
	CompleteEmptyFeedback();

	SetUpQuestions();
	ClearTextBoxes();
	CreateStatusArray();
	

	setTimeout('StartTimer()', 50);

	
//Check search string for q parameter
	if (document.location.search.length > 0){
		if (ShuffleQs == false){
			var JumpTo = parseInt(document.location.search.substring(1,document.location.search.length))-1;
			if (JumpTo <= QsToShow){
				ChangeQ(JumpTo);
			}
		}
	}
//Undocumented function added 10/12/2004
	ShowSpecialReadingForQuestion();
}

function ShowHideQuestions(){
	FuncBtnOut(document.getElementById('ShowMethodButton'));
	document.getElementById('ShowMethodButton').style.display = 'none';
	if (ShowingAllQuestions == false){
		for (var i=0; i<QArray.length; i++){
				QArray[i].style.display = '';
			}
		document.getElementById('Questions').style.listStyleType = 'decimal';
		document.getElementById('OneByOneReadout').style.display = 'none';
		document.getElementById('ShowMethodButton').innerHTML = ShowOneByOneCaption;
		ShowingAllQuestions = true;
	}
	else{
		for (var i=0; i<QArray.length; i++){
				if (i != CurrQNum){
					QArray[i].style.display = 'none';
				}
			}
		document.getElementById('Questions').style.listStyleType = 'none';
		document.getElementById('OneByOneReadout').style.display = '';
		document.getElementById('ShowMethodButton').innerHTML = ShowAllQuestionsCaption;
		ShowingAllQuestions = false;	
	}
	document.getElementById('ShowMethodButton').style.display = 'inline';
}

function CreateStatusArray(){
	var QNum, ANum;
//For each item in the item array
	for (QNum=0; QNum<I.length; QNum++){
//Check if the question still exists (hasn't been nuked by showing a random selection)
		if (document.getElementById('Q_' + QNum) != null){
			State[QNum] = new Array();
			State[QNum][0] = -1; //Score for this q; -1 shows question not done yet
			State[QNum][1] = new Array(); //answers
			for (ANum = 0; ANum<I[QNum][3].length; ANum++){
				State[QNum][1][ANum] = 0; //answer not chosen yet; when chosen, will store its position in the series of choices
			}
			State[QNum][2] = 0; //tries at this q so far
			State[QNum][3] = 0; //incrementing percent-correct values of selected answers
			State[QNum][4] = 0; //penalties incurred for hints
			State[QNum][5] = ''; //Sequence of answers chosen by number
		}
		else{
			State[QNum] = null;
		}
	}
}



function CheckMCAnswer(QNum, ANum, Btn){
//if question doesn't exist, bail
	if (State[QNum].length < 1){return;}
	
//Get the feedback
	Feedback = I[QNum][3][ANum][1];
	
//Now show feedback and bail if question already complete
	if (State[QNum][0] > -1){
//Add an extra message explaining that the question
// is finished if defined by the user
		if (strQuestionFinished.length > 0){Feedback += '<br />' + strQuestionFinished;}
//Show the feedback
		ShowMessage(Feedback);
		return;
	}
	
//Hide the button while processing
	Btn.style.display = 'none';

//Increment the number of tries
	State[QNum][2]++;
	
//Add the percent-correct value of this answer
	State[QNum][3] += I[QNum][3][ANum][3];
	
//Store the try number in the answer part of the State array, for tracking purposes
	State[QNum][1][ANum] = State[QNum][2];
	State[QNum][5] += String.fromCharCode(65+ANum) + ',';
	
//Should this answer be accepted as correct?
	if (I[QNum][3][ANum][2] < 1){
//It's wrong

//Mark the answer
		Btn.innerHTML = IncorrectIndicator;
		
//Remove any previous score unless exercise is finished (6.0.3.8+)
		if (Finished == false){
			WriteToInstructions(strInstructions);
		}	
		
//Check whether this leaves just one MC answer unselected, in which case the Q is terminated
		var RemainingAnswer = FinalAnswer(QNum);
		if (RemainingAnswer > -1){
//Behave as if the last answer had been selected, but give no credit for it
//Increment the number of tries
			State[QNum][2]++;		
		
//Calculate the score for this question
			CalculateMCQuestionScore(QNum);

//Get the overall score and add it to the feedback
			CalculateOverallScore();
			if ((ContinuousScoring == true)||(Finished == true)){
				Feedback += '<br />' + YourScoreIs + ' ' + Score + '%.';
				WriteToInstructions(YourScoreIs + ' ' + Score + '%.');
			}
		}
	}
	else{
//It's right
//Mark the answer
		Btn.innerHTML = CorrectIndicator;
				
//Calculate the score for this question
		CalculateMCQuestionScore(QNum);

//Get the overall score and add it to the feedback
		if (ContinuousScoring == true){
			CalculateOverallScore();
			if ((ContinuousScoring == true)||(Finished == true)){
				Feedback += '<br />' + YourScoreIs + ' ' + Score + '%.';
				WriteToInstructions(YourScoreIs + ' ' + Score + '%.');
			}
		}
	}
	
//Show the button again
	Btn.style.display = 'inline';
	
//Finally, show the feedback	
	ShowMessage(Feedback);
	
//Check whether all questions are now done
	CheckFinished();
}

function CalculateMCQuestionScore(QNum){
	var Tries = State[QNum][2] + State[QNum][4]; //include tries and hint penalties
	var PercentCorrect = State[QNum][3];
	var TotAns = GetTotalMCAnswers(QNum);
	var HintPenalties = State[QNum][4];
	
//Make sure it's not already complete

	if (State[QNum][0] < 0){
//Allow for Hybrids
		if (HintPenalties >= 1){
			State[QNum][0] = 0;
		}
		else{
//This line calculates the score for this question
			if (TotAns == 1){
				State[QNum][0] = 1;
			}
			else{
				State[QNum][0] = ((TotAns-((Tries*100)/State[QNum][3]))/(TotAns-1));
			}
		}
//Fix for Safari bug added for version 6.0.3.42 (negative infinity problem)
		if ((State[QNum][0] < 0)||(State[QNum][0] == Number.NEGATIVE_INFINITY)){
			State[QNum][0] = 0;
		}
	}
}

function GetTotalMCAnswers(QNum){
	var Result = 0;
	for (var ANum=0; ANum<I[QNum][3].length; ANum++){
		if (I[QNum][3][ANum][4] == 1){ //This is an MC answer
			Result++;
		}
	}
	return Result;
}

function FinalAnswer(QNum){
	var UnchosenAnswers = 0;
	var FinalAnswer = -1;
	for (var ANum=0; ANum<I[QNum][3].length; ANum++){
		if (I[QNum][3][ANum][4] == 1){ //This is an MC answer
			if (State[QNum][1][ANum] < 1){ //This answer hasn't been chosen yet
				UnchosenAnswers++;
				FinalAnswer = ANum;
			}
		}
	}
	if (UnchosenAnswers == 1){
		return FinalAnswer;
	}
	else{
		return -1;
	}
}





function CalculateOverallScore(){
	var TotalWeighting = 0;
	var TotalScore = 0;
	
	for (var QNum=0; QNum<State.length; QNum++){
		if (State[QNum] != null){
			if (State[QNum][0] > -1){
				TotalWeighting += I[QNum][0];
				TotalScore += (I[QNum][0] * State[QNum][0]);
			}
		}
	}
	if (TotalWeighting > 0){
		Score = Math.floor((TotalScore/TotalWeighting)*100);
	}
	else{
//if TotalWeighting is 0, no questions so far have any value, so 
//no penalty should be shown.
		Score = 100; 
	}
}

function CheckFinished(){
	var FB = '';
	var AllDone = true;
	for (var QNum=0; QNum<State.length; QNum++){
		if (State[QNum] != null){
			if (State[QNum][0] < 0){
				AllDone = false;
			}
		}
	}
	if (AllDone == true){
	
//Report final score and submit if necessary
		CalculateOverallScore();
		FB = YourScoreIs + ' ' + Score + '%.';
		if (ShowCorrectFirstTime == true){
			var CFT = 0;
			for (QNum=0; QNum<State.length; QNum++){
				if (State[QNum] != null){
					if (State[QNum][0] >= 1){
						CFT++;
					}
				}
			}
			FB += '<br />' + CorrectFirstTime + ' ' + CFT + '/' + QsToShow;
		}
		WriteToInstructions(FB);
		
		Finished == true;

		window.clearInterval(Interval);

		TimeOver = true;
		Locked = true;
		


		Finished = true;
		Detail = '<?xml version="1.0"?><hpnetresult><fields>';
		for (QNum=0; QNum<State.length; QNum++){
			if (State[QNum] != null){
				if (State[QNum][5].length > 0){
					Detail += '<field><fieldname>Question #' + (QNum+1) + '</fieldname><fieldtype>question-tracking</fieldtype><fieldlabel>Q ' + (QNum+1) + '</fieldlabel><fieldlabelid>QuestionTrackingField</fieldlabelid><fielddata>' + State[QNum][5] + '</fielddata></field>';
				}
			}
		}
		Detail += '</fields></hpnetresult>';
		setTimeout('Finish()', SubmissionTimeout);
	}
}


function TimesUp(){
	document.getElementById('Timer').innerHTML = 'Your time is over!';

	TimeOver = true;
	Finished = true;
	ShowMessage('Your time is over!');
	
//Set all remaining scores to 0
	for (var QNum=0; QNum<State.length; QNum++){
		if (State[QNum] != null){
			if (State[QNum][0] < 0){
				State[QNum][0] = 0;
			}
		}
	}
	CheckFinished();
}








//CODE FOR HANDLING TIMER
//Timer code
var Seconds = 2700;
var Interval = null;

function StartTimer(){
	Interval = window.setInterval('DownTime()',1000);
	document.getElementById('TimerText').style.display = 'inline';
}

function DownTime(){
	var ss = Seconds % 60;
	if (ss<10){
		ss='0' + ss + '';
	}

	var mm = Math.floor(Seconds / 60);

	if (document.getElementById('Timer') == null){
		return;
	}

	document.getElementById('TimerText').innerHTML = mm + ':' + ss;
	if (Seconds < 1){
		window.clearInterval(Interval);
		TimeOver = true;
		TimesUp();
	}
	Seconds--;
}






//-->

//]]>


