function popitup(url) {
	newwindow=window.open(url,'name','height=200,width=150');
	if (window.focus) {newwindow.focus()}
	return false;
}


function ClearQuizData()
{
	var msg = "\nThis will reset the quiz scores\n"+
	"Do you wish to continue?";

	if (confirm(msg))
	{
	//clear the cookie
	delCookie("Aldara");
	
	//now reload the UI
	PassQuizScoreToMainMenu(0, 0, 0);
	}
	else
	{
	}
}

function SendQuizScoreToOpener(strData)
{
	arQuizData = strData.split(",");

	whichModule = -1;
	whichChapter = -1;
	quizScore = 0;

	if (arQuizData.length >=2)
	{
		whichModule = arQuizData[0];
		whichChapter = arQuizData[1];
		quizScore = arQuizData[2];
	}

        //send the score to the mainmenu 
        window.opener.PassQuizScoreToMainMenu(whichModule, whichChapter, quizScore);

        //now close the quiz 
        //window.close();
} 

function GetScoreResultsCookie()
{
	var scoreResults = getCookie("Aldara");
	if (scoreResults != null)
	{
		window.document["mainMenu"].SetVariable("QuizScoreFromCookie",scoreResults);
	}
}

function SetScoreResultsCookie(scoreResults)
{
	var expiredays = 360;
	var NameOfCookie = "Aldara";
	var value = scoreResults;

	var ExpireDate = new Date ();
	ExpireDate.setTime(ExpireDate.getTime() + (expiredays * 24 * 3600 * 1000));

	// The next line stores the cookie, simply by assigning 
	// the values to the "document.cookie" object.
	// Note the date is converted to Greenwich Mean time using
	// the "toGMTstring()" function.

	document.cookie = NameOfCookie + "=" + escape(value) + 
	((expiredays == null) ? "" : "; expires=" + ExpireDate.toGMTString());
}

function getCookie(NameOfCookie)
{
	// First we check to see if there is a cookie stored.
	// Otherwise the length of document.cookie would be zero.

	if (document.cookie.length > 0) 
	{ 

	// Second we check to see if the cookie's name is stored in the
	// "document.cookie" object for the page.

	// Since more than one cookie can be set on a
	// single page it is possible that our cookie
	// is not present, even though the "document.cookie" object
	// is not just an empty text.
	// If our cookie name is not present the value -1 is stored
	// in the variable called "begin".

	begin = document.cookie.indexOf(NameOfCookie+"="); 
	if (begin != -1) // Note: != means "is not equal to"
	{ 

	// Our cookie was set. 
	// The value stored in the cookie is returned from the function.

	begin += NameOfCookie.length+1; 
	end = document.cookie.indexOf(";", begin);
	if (end == -1) end = document.cookie.length;
	return unescape(document.cookie.substring(begin, end)); } 
	}
	return null; 

	// Our cookie was not set. 
	// The value "null" is returned from the function.

}

function delCookie (NameOfCookie) 
{
	// The function simply checks to see if the cookie is set.
	// If so, the expiration date is set to Jan. 1st 1970.

	if (getCookie(NameOfCookie)) {
	document.cookie = NameOfCookie + "=" +
	"; expires=Thu, 01-Jan-70 00:00:01 GMT";
	}
}

/*
we need to pass data from quiz into main menu
*/
function PassQuizScoreToMainMenu(whichModule, whichChapter, quizScore)
{

	/*
	quizScore	= The score that was achieved
	*/
	window.document["mainMenu"].SetVariable("SelectedModule",whichModule);
	window.document["mainMenu"].SetVariable("SelectedChapter",whichChapter);
	window.document["mainMenu"].SetVariable("QuizScore",quizScore);
}

/*
open up the courses
*/
function LaunchCourse(url)
{
	var winCourse = window.open(url,'winCourse','width=1010,height=680,resizable=yes,toolbar=yes');
	if (winCourse)
	{
		//focus on the window
		winCourse.focus();	
	}
}
/*
open up the help
*/
function LaunchHelp(url)
{
	var winHelp = window.open(url,'winHelp','width=640,height=680,resizable=yes,toolbar=yes, scrollbars=yes');
	if (winHelp)
	{
		//focus on the window
		winHelp.focus();		
	}
}