<!--

// -- need to stop refresh/reload function --

var blnReturn = false;
var blnLogin = false;
var blnChgFrame = false;
var blnNavBar = false;
var blnTopBar = false;
var blnContent = false;
var blnPage = false;
var blnBotBar = false;

var txtTopTitle = "";
var txtNavImg = "";
var txtBotBtn1 = "Null";
var txtBotBtn2 = "Null";
var txtBotBtn3 = "Null";

var txtCurrPgLoc = "";
var txtPrevPgLoc = "";
var txtTempnum = null;
var txtUsernum = null;
var txtTempCatId = null;
var txtUserCatId = null;
var txtTempname = null;
var txtUsername = null;
var intRowType = 0;
var intColSect = 0;
var intEleTopic = 0;
var intCurPg = 0;
var intPrevColSect = 0;
var intPrevEleTopic = 0;
var intPrevPg = 0;
var intTtlPg = 0;
var intCurrPre = 0;
var intCurrPost = 0;

var txtCho = "";
var txtAns = "";

var dtmPause = 500;
var blnDebug = false;

if (self.location.href.indexOf("success-zone",0) < 0)
{	dtmPause = 200;	}
if (self.location.search == "?d=1")
{	blnDebug = true;	}

function navContent(pgName, blnChgAll)
{
	if (pgName != null)
	{
		blnChgFrame = blnChgAll;
		if (blnChgFrame)
		{	blnBotBar = false;	}
		blnPage = false;
		blnContent = false;
	    top.content.location.replace(pgName);
	}
}

function navPageToFirst()
{
	top.blnPage = false;
    top.content.page.location.replace(dataDefault[rowFirstPage][intColSect][intEleTopic]);
}

function getBookmark(intSection,intTopic)
{
	txtPgName = "page01.htm";
	if (intSection != null && intTopic != null)
	{
		if (intSection == colLearners && intTopic > eleMap && intTopic < eleProfile)
		{	markBeginTime(intTopic);	}
		if (dataPage[rowBookmark][intSection][intTopic] == "")
		{	txtPgName = dataDefault[rowFirstPage][intSection][intTopic];	}
		else if ( dataPage[rowBookmark][intSection][intTopic].indexOf(".htm") != dataPage[rowBookmark][intSection][intTopic].length-4 )
		{	txtPgName = dataDefault[rowFirstPage][intSection][intTopic];	}
		else
		{	txtPgName = dataPage[rowBookmark][intSection][intTopic];	}
	}
    return (txtPgName);
}

function markNavBar()
{
	blnNavBar = true;
	setTimeout("markFrames()", dtmPause);
}

function markTopBar()
{
	blnTopBar = true;
	setTimeout("markFrames()", dtmPause);
}

function markContent()
{
	blnContent = true;
	blnBotBar = false;
	if (top.content.location.href.indexOf("home.htm",0) >= 0)
	{
		intColSect = colUsers;
		intEleTopic = eleHome;
	}
	else if (top.content.location.href.indexOf("info.htm",0) >= 0)
	{
		intColSect = colUsers;
		intEleTopic = eleInfo;
	}
	else if (top.content.location.href.indexOf("contacts.htm",0) >= 0)
	{
		intColSect = colUsers;
		intEleTopic = eleContacts;
	}
	else if (top.content.location.href.indexOf("sitemap.htm",0) >= 0)
	{
		intColSect = colUsers;
		intEleTopic = eleSitemap;
	}
	else if (top.content.location.href.indexOf("copyright.htm",0) >= 0)
	{
		intColSect = colUsers;
		intEleTopic = eleCopyright;
	}
	else if (top.content.location.href.indexOf("disclaimer.htm",0) >= 0)
	{
		intColSect = colUsers;
		intEleTopic = eleDisclaimer;
	}
	else if (top.content.location.href.indexOf("privacy.htm",0) >= 0)
	{
		intColSect = colUsers;
		intEleTopic = elePrivacy;
	}
	else if (top.content.location.href.indexOf("guide/",0) >= 0)
	{
		blnBotBar = true;
		intColSect = colUsers;
		intEleTopic = eleGuide;
	}
	else if (top.content.location.href.indexOf("regi/",0) >= 0)
	{
		blnBotBar = true;
		intColSect = colUsers;
		intEleTopic = eleRegi;
	}
	else if (top.content.location.href.indexOf("login/",0) >= 0)
	{
		blnBotBar = true;
		blnLogin = false;
		intColSect = colUsers;
		intEleTopic = eleLogin;
	}
	else if (top.content.location.href.indexOf("logout/",0) >= 0)
	{
		blnLogin = false;
		intColSect = colUsers;
		intEleTopic = eleLogin;
	}
	else if (top.content.location.href.indexOf("forgot/",0) >= 0)
	{
		blnBotBar = true;
		blnLogin = false;
		intColSect = colUsers;
		intEleTopic = eleForgot;
	}
	else if (top.content.location.href.indexOf("coursemap.htm",0) >= 0)
	{
		intColSect = colLearners;
		intEleTopic = eleMap;
	}
	else if (top.content.location.href.indexOf("profile/",0) >= 0)
	{
		blnBotBar = true;
		intColSect = colLearners;
		intEleTopic = eleProfile;
	}
	else if (top.content.location.href.indexOf("intro/",0) >= 0)
	{
		blnBotBar = true;
		intColSect = colLearners;
		intEleTopic = eleIntro;
	}
	else if (top.content.location.href.indexOf("stat/",0) >= 0)
	{
		blnChgFrame = true;
		blnBotBar = true;
		intColSect = colLearners;
		intEleTopic = eleStat;
	}
	else if (top.content.location.href.indexOf("ethics/",0) >= 0)
	{
		blnChgFrame = true;
		blnBotBar = true;
		intColSect = colLearners;
		intEleTopic = eleEthics;
	}
	else if (top.content.location.href.indexOf("lic/",0) >= 0)
	{
		blnChgFrame = true;
		blnBotBar = true;
		intColSect = colLearners;
		intEleTopic = eleLic;
	}
	else if (top.content.location.href.indexOf("stand/",0) >= 0)
	{
		blnChgFrame = true;
		blnBotBar = true;
		intColSect = colLearners;
		intEleTopic = eleStand;
	}
	else if (top.content.location.href.indexOf("pract/",0) >= 0)
	{
		blnChgFrame = true;
		blnBotBar = true;
		intColSect = colLearners;
		intEleTopic = elePract;
	}
	else if (top.content.location.href.indexOf("refer/",0) >= 0)
	{
		blnChgFrame = true;
		blnBotBar = true;
		intColSect = colLearners;
		intEleTopic = eleRefer;
	}
	else if (top.content.location.href.indexOf("case/",0) >= 0)
	{
		blnChgFrame = true;
		blnBotBar = true;
		intColSect = colLearners;
		intEleTopic = eleCase;
	}
	else if (top.content.location.href.indexOf("concl/",0) >= 0)
	{
		blnBotBar = true;
		intColSect = colLearners;
		intEleTopic = eleConcl;
	}
	if (intColSect == colLearners && blnBotBar)
	{	markSessionCounts(false);	}
	
	markReturn();
	if (blnChgFrame)
	{
		blnChgFrame = false;
		blnNavBar = false;
		blnTopBar = false;
		if (blnLogin && intColSect == colUsers)
		{
			top.navbar.location.replace("../learners/navbar_u.htm");
			top.topbar.location.replace("../learners/topbar_u.htm");
		}
		else
		{
			top.navbar.location.replace(dataDefault[rowFrameDir][intColSect][intEleTopic]+"navbar.htm");
			top.topbar.location.replace(dataDefault[rowFrameDir][intColSect][intEleTopic]+"topbar.htm");
		}
	}
	if (blnLogin && intColSect == colUsers)
	{
		if (intEleTopic == eleGuide)
		{	top.navbase.location.replace("navbase_u.htm");	}
		else
		{	top.navbase.location.replace("../learners/navbase_u.htm");	}
	}
	else
	{	
		top.navbase.location.replace("navbase.htm");
	}
	intTtlPg = dataDefault[rowTtlPages][intColSect][intEleTopic];
	blnContent = true;
	setTimeout("markFrames()", dtmPause);
}

function markReturn()
{
	if (!blnReturn && blnLogin &&  
	    intPrevColSect == colLearners && 
		intPrevEleTopic > eleMap && intPrevEleTopic < eleProfile)
	{	blnReturn = true;	}
	if (blnReturn && blnLogin && intColSect == colLearners && intEleTopic > eleMap && intEleTopic < eleProfile )
	{	blnReturn = false;	}
}

function markFrames()
{
	if (blnNavBar && blnTopBar && blnContent )
	{
		txtNavImg = dataDefault[rowNavImage][intColSect][intEleTopic];
		top.navbar.setUsersNav();
		txtTopTitle = dataDefault[rowTitleImage][intColSect][intEleTopic];
		top.topbar.initTop();
		markBtnsNCounts();
	}
}

function markSeriesPage(intPg,intPre,intPost,txtBtn1,txtBtn2,txtBtn3)
{
	intCurPg = intPg;
	intCurrPre = intPre
	intCurrPost = intPost;
	txtBotBtn1 = txtBtn1;
	txtBotBtn2 = txtBtn2;
	txtBotBtn3 = txtBtn3;
	blnPage = true;
	setTimeout("markBtnsNCounts()", dtmPause);
}


function markBtnsNCounts()
{
	blnContinue = false;
	if (blnNavBar && blnTopBar && blnContent )
	{
		blnContinue = true;
	}
	if (blnContent && blnBotBar && blnPage)
	{
		top.content.botbar.chgBtnImg();
		blnContinue = true;
	}
	if (blnContinue)
	{
		if (intPrevColSect != intColSect || intPrevEleTopic != intEleTopic)
		{
			if (intPrevColSect == colLearners && intPrevEleTopic > eleMap && intPrevEleTopic < eleProfile)
			{	markTopicTime(intPrevEleTopic);	}
		}
		if (intPrevColSect != intColSect || intPrevEleTopic != intEleTopic || intCurPg != intPrevPg)
		{
			if (intColSect == colLearners && intEleTopic > eleMap && intEleTopic < eleProfile)
			{	markEndTime(intEleTopic);	}
			markPageHits();
			markBookmark();
			if (blnContent && blnBotBar && blnPage)
			{
				//markQtnAttempts();
				markCompletion();
			}
		}
		intPrevColSect = intColSect;
		intPrevEleTopic = intEleTopic;
		intPrevPg = intCurPg;
	}
}

function markBeginTime(intLrnrTopic)
{
	var dtmNow = new Date();
	dataTemp[rowBeginTime][intLrnrTopic] = dtmNow;
}

function markEndTime(intLrnrTopic)
{
	var dtmNow = new Date();
	dataTemp[rowEndTime][intLrnrTopic] = dtmNow;
}

function markTopicTime(intLrnrTopic)
{
	var dtmNow = new Date();
	var intDiff = 0;
	var intMinutes = 0;
	if (intPrevColSect == colLearners && intLrnrTopic > eleMap && intLrnrTopic < eleProfile)
	{
		dataTemp[rowEndTime][intLrnrTopic] = dtmNow;
		intDiff = ((dataTemp[rowEndTime][intLrnrTopic].getTime() - dataTemp[rowBeginTime][intLrnrTopic].getTime()) / 1000);
		intMinutes = Math.round((intDiff-30)/60) + 1;
		dataCounts[rowTimeLen][intLrnrTopic] += intMinutes;
		dataTemp[rowEndTime][intLrnrTopic] = dtmNow;
		dataTemp[rowEndTime][intLrnrTopic] = dtmNow;
	}
}

function markPageHits()
{
	dataPage[rowPageHits][intColSect]++;
	dataPage[rowPageHits][colWebsite]++;
}

function markBookmark()
{
	if (intPrevColSect == colLearners && intPrevEleTopic > eleMap && intPrevEleTopic < eleProfile)
	{	txtPrevPgLoc = txtCurrPgLoc;	}
	txtCurrPgLoc = top.content.location.href;
	
	if (top.content.location.href.indexOf("content.htm") < 0)
	{	txtLocName = top.content.location.href;	}
	else
	{	txtLocName = top.content.page.location.href;	}
	txtPgName = txtLocName.substring(txtLocName.lastIndexOf("/",txtLocName.length)+1,txtLocName.length);
	dataPage[rowBookmark][intColSect][intEleTopic] = txtPgName;
}

function markSessionCounts(isLogin)
{
	if (isLogin)
	{
		dataCounts[rowSessions][eleCourse]++;
		dataCounts[rowStarted][eleCourse] = 1;
	}
	else if (intEleTopic < eleProfile)
	{
		dataCounts[rowSessions][intEleTopic]++;
		dataCounts[rowStarted][intEleTopic] = 1;
	}
}

function markQtnAttempts()
{
	if (intCurrPre != 0)
	{
		dataCounts[rowPreTry][intEleTopic][intCurrPre]++;
		sumQtn(rowPreTry);
	}
	else if (intCurrPost != 0)
	{
		dataCounts[rowPostTry][intEleTopic][intCurrPost]++
		sumQtn(rowPostTry);
	}
}

function markQtnScores()
{
	if (intCurrPre != 0)
	{
		if (dataCounts[rowPreTry][intEleTopic][intCurrPre] == 1)
		{
			if (txtCho == dataDefault[rowPreAns][colLearners][intEleTopic][intCurrPre])
			{	dataCounts[rowPreScore1][intEleTopic][intCurrPre] = 1;	}
			else
			{	dataCounts[rowPreScore1][intEleTopic][intCurrPre] = 0;	}
			// special case for question in Referrals
			if (intEleTopic == eleRefer && intCurrPre == 1 && (txtCho == "a" || txtCho == "b") )
			{	dataCounts[rowPreScore1][eleRefer][2] = 1;	}
			sumQtn(rowPreScore1);
		}
	}
	else if (intCurrPost != 0)
	{
		if (txtCho == dataDefault[rowPostAns][colLearners][intEleTopic][intCurrPost])
		{	dataCounts[rowPostScoreN][intEleTopic][intCurrPost] = 1;	}
		else
		{	dataCounts[rowPostScoreN][intEleTopic][intCurrPost] = 0;	}
		sumQtn(rowPostScoreN);
		if (dataCounts[rowPostTry][intEleTopic][intCurrPost] == 1)
		{
			dataCounts[rowPostScore1][intEleTopic][intCurrPost] = dataCounts[rowPostScoreN][intEleTopic][intCurrPost];
			sumQtn(rowPostScore1);
		}
	}
}

function sumQtn(intRow)
{
	var intLen = 0;
	var intTtl = 0;
	if (intRow < rowPostTry)
	{	intLen = dataDefault[rowPreAns][colLearners][intEleTopic].length;	}
	else
	{	intLen = dataDefault[rowPostAns][colLearners][intEleTopic].length;	}
	for (intLoop=1; intLoop<intLen; intLoop++)
	{
		if (intRow == rowPreTry || intRow == rowPostTry)
		{
			if (dataCounts[intRow][intEleTopic][qtnTotal] < dataCounts[intRow][intEleTopic][intLoop])
			{	dataCounts[intRow][intEleTopic][qtnTotal] = dataCounts[intRow][intEleTopic][intLoop];	}
		}
		else
		{
			intTtl += dataCounts[intRow][intEleTopic][intLoop];
		}
	}
	if (intRow != rowPreTry && intRow != rowPostTry)
	{
		if (intTtl == 0)
		{	dataCounts[intRow][intEleTopic][qtnTotal] = intTtl;	}
		else
		{	dataCounts[intRow][intEleTopic][qtnTotal] = Math.ceil(intTtl / (intLen-1) * 100);	}
	}
	var intRowTtl = 0;
	for (intRowLoop=rowPreTry; intRowLoop<=rowPostScoreN; intRowLoop++)
	{
		intRowTtl = 0;
		for (intEleLoop=eleStat; intEleLoop<eleCase; intEleLoop++)
		{	intRowTtl += dataCounts[intRowLoop][intEleLoop][qtnTotal];	}
		dataCounts[intRowLoop][eleCourse] = Math.ceil(intRowTtl / (eleCase-eleStat));
	}
}

function writeTopicScores(intTopic)
{
	var strScores
	strScores = "Your first completion of <strong>What Have You Learned?</strong> in the " + dataDefault[rowTopicName][colLearners][intTopic] + " topic has a score of <strong>" + dataCounts[rowPostScore1][intTopic][qtnTotal] + "%</strong>.";
	if (dataCounts[rowPostTry][intTopic][qtnTotal] > 1)
	{
 		strScores += " Your last attempt has a score of <strong>" + dataCounts[rowPostScoreN][intTopic][qtnTotal] + "%</strong>.";
	}
	return (strScores);
}

function getPostAttempts()
{
	return (dataCounts[rowPostTry][intEleTopic][qtnTotal]);
}

function getPost1Scores()
{
	return (dataCounts[rowPostScore1][intEleTopic][qtnTotal]);
}

function getPostNScores()
{
	return (dataCounts[rowPostScoreN][intEleTopic][qtnTotal]);
}

function getFinalScore()
{
	return (dataCounts[rowPostScore1][eleCourse]);
}

function getNotifyMsg()
{
	if (top.txtUsernum != "")
	{
   		txtNotifyMsg = "The Royal Australian College of General Practitioners will be automatically notified and will update your records within 3 months. [IF APPLICABLE].";
	}
	else
	{
		txtNotifyMsg = "You did not enter your CONTINUING EDUCATION NUMBER when you registered.  The Royal Australian College of General Practitioners will <strong>not</strong> be automatically notified of your result.";
	}
	return (txtNotifyMsg);
}

function markCompletion()
{
	if (intColSect == colLearners && intEleTopic > 0 && intEleTopic < eleProfile && intCurPg == dataDefault[rowTtlPages][colLearners][intEleTopic])
	{	dataCounts[rowFullDone][intEleTopic] = 1;	}
	var intCompletion = 0;
	for (intEleLoop=eleIntro; intEleLoop<eleProfile; intEleLoop++)
	{
		intCompletion += dataCounts[rowFullDone][intEleLoop];
	}
	if (intCompletion == (eleProfile-eleIntro) && dataCounts[rowPartDone][eleCourse] != 1)
	{	dataCounts[rowFullDone][eleCourse] = 1;	}
}

function markAwarded()
{
	// need to program points awarded when sending emails
	// need to mark awarded when sending emails
	// need to mark partially completion when sending emails
}

function showData()
{
	if (blnDebug)
	{	top.content.location = "../reports/data.htm";	}
}

function setUsername()
{
	if (txtTempname == null || txtTempname == "")
	{	txtUsername = "Tricia";	}
	else
	{	txtUsername = txtTempname; txtUserCatId = txtTempCatId; txtUsernum = txtTempnum;	}
	txtTempnum = "";
	txtTempCatId = ""
	txtTempname = "";
}

function getConclReady()
{
	var blnReady = true;
	for (intEleLoop=eleIntro; intEleLoop<eleConcl; intEleLoop++)
	{
		if (dataCounts[rowFullDone][intEleLoop] != 1)
		blnReady = false;
	}
	return (blnReady);
}

function getCertDate()
{
	var today = new Date();
	var mthname = ["January","February","March","April","May","June","July","August","September","October","November","December"];
	return (today.getDate() + ' ' + mthname[today.getMonth()] + ' ' + today.getYear());
}

function getCertPoints()
{
    var pointsgif = [
		"<img src='images/cert_0.gif' alt='' border='0'>",
		"<img src='images/cert_1.gif' alt='' border='0'>",
		"<img src='images/cert_2.gif' alt='' border='0'>",
		"<img src='images/cert_3.gif' alt='' border='0'>",
		"<img src='images/cert_4.gif' alt='' border='0'>",
		"<img src='images/cert_5.gif' alt='' border='0'>",
		"<img src='images/cert_6.gif' alt='' border='0'>",
		"<img src='images/cert_7.gif' alt='' border='0'>",
		"<img src='images/cert_8.gif' alt='' border='0'>"
		];
	//intPoints = Math.ceil(dataCounts[rowPostScoreN][eleCourse] * dataDefault[rowCMEPoints][eleCourse] / 100);
	if (dataCounts[rowPartDone][eleCourse] == 0)
	{
		intPoints = 30;
	}
	else
	{
		for (intEleLoop=eleIntro; intEleLoop<eleProfile; intEleLoop++)
		{
			intPoints += dataCounts[rowPartDone][intEleLoop];
		}
		intPoints = Math.round(intPoints / 31 * 30);
		if (intPoints == 0)
		{	intPoints = 1;	}
		else if (intPoints = 30)
		{	intPoints = 29;	}
	}
	return ( "<img src='images/cert_"+parseInt(intPoints/10)+".gif' alt='' border='0'>" + "<img src='images/cert_"+parseInt(intPoints%10)+".gif' alt='' border='0'>");
}

function writeTick(intTopic,intStatus)
{
	txtHtml = "&nbsp;";
	txtTickHtml = "<img src='images/map_tick.gif' alt='' border='0'>";
	if ( (dataCounts[rowStarted][intTopic]+dataCounts[rowFullDone][intTopic]) == intStatus)
	{	txtHtml = txtTickHtml;	}
	return (txtHtml);
}

function writeTickMap(intTopic,intRow)
{
	txtHtml = "&nbsp;";
	txtTickHtml = "<img src='images/map_tick.gif' alt='' border='0'>";
	if (dataCounts[intRow][intTopic] == 1)
	{	txtHtml = txtTickHtml;	}
	return (txtHtml);
}

function writeYN(intNum)
{
	var txtYN = "No";
	if (intNum == 1)
	{	txtYN = "Yes";	}
	return (txtYN);
}
//-->