/*
	Optimized for 4+ browsers: Explorer, Netscape, Opera

	Comments: This file is called in pages that open pop-up windows such as quizzes and in the pop-up pages themselves
  
  In the page that opens a pop-up quiz the following is added to the onclick element of the link:
      getQuestion('forward-quiz-page.html', 'forward-to-first-page-after-quiz.html'); return false;
  example: 
      onclick="getQuestion('section_a-7.html','section_a-10.html'); MM_nbGroup('down','navbar1','menu_r2_c9','//images/menu_r2_c9_f3.gif',1); return false;"

  In the quiz question page the following is added to the onclick element of all the navigation 
  bar links and change the '1' to '2' for the next button (note that the next button should 
  point to the first page after the quiz not the answer pages):
      changeWindow('same-as-href.html','1'); return false;
  
  In the quiz answer pages add the following to the onclick element of all the naigation 
  bar links EXCEPT the back button:
      mainWindow('same-as-href.html'); return false;
  Also add it to the "Continue" link.
*/

			// browser variables
			var is4plusIE = ((navigator.appName == "Microsoft Internet Explorer") &&
				(parseInt(navigator.appVersion) >= 4));
			var is4plusNN = ((navigator.appName == "Netscape") && // OP returns as Netscape !!!!!
				(parseInt(navigator.appVersion) >=4 ));

			// hold Opera's hand so he can keep up with Explorer and Netscape
			var notOpera = !(navigator.userAgent.indexOf("Opera") != -1);

			// window variable
			var popupOpened = false;

			function getQuestion(url1, url2) {
			// check to see if question window has been opened
				if (popupOpened == false) {
				// check browser (OP 4+ can advance to next step)
					if ((is4plusIE) || (is4plusNN)) {
							// use pop-up window
						newWindow(url1, url2);
						}
						else {
								// use main window; come this way OP 3 or less
							top.location.href = url1;
						}
					}
					else {
							// quiz-opened == true
						top.location.href = url2;
						popupOpened = false;
						}
				}

			function getComparison(url1) {
			// check browser (OP 4+ can advance to next step)
				if ((is4plusIE) || (is4plusNN)) {
						// use pop-up window
					newWindow2(url1);
					}
					else {
							// use main window; come this way OP 3 or less
						top.location.href = url1;
					}
				}

			function getOpinion(url1) {
			// check browser (OP 4+ can advance to next step)
				if ((is4plusIE) || (is4plusNN)) {
						// use pop-up window
					newWindow3(url1);
					}
					else {
							// use main window; come this way OP 3 or less
						top.location.href = url1;
					}
				}

			function changeWindow(url, situation) {
			// don't allow navigation inside question pop-up windows
					// use this in the header links except for the back link on answer pages
				if (situation == "1") {
					message = "\nYou must close this window to continue.\n\nDo you want to close this window now?\n";
				}
				if (situation == "2") {
					message = "\nDo you want to skip the question and close this window now?\n";
				}
				if ((window.name == "question") && (notOpera))  {
						// pop-up window open
					if (confirm(message)) {
							// open link in parent window
						window.opener.top.location.href = url;
						window.close();
						} else {
								// keep pop-up open
                location.href = document.location;
							}
					} else {
							// no pop-up open; come this way OP
						top.location.href = url;
					}
				}

			function newWindow(url1, url2) {
			// pop-up questions (exclude OP 4+)
					// user can press OK to answer question; CANCEL to skip question
						// OP 4+ can simply hit the NEXT button to skip question
				if (notOpera) {
					if (confirm("\nPlease take a moment to answer the following question.\n")) {
						// answer question
					window.open(url1, "question", "scrollbars=yes,resizable=yes,width=650,height=400,left=70,top=90,screenX=70,screenY=90");
					popupOpened = true;
					} else {
							// skip question
						top.location.href = url2;
						}
 				} else {
						// come this way OP 4+
					top.location.href = url1;
				}
			}

			function newWindow2(url1) {
			// pop-up comparison (exclude OP 4+)
					// user must press OK to advance to comparison
				if (notOpera) {
					alert("\nLet's take a moment to compare questions.\n");
					window.open(url1, "question", "scrollbars=yes,resizable=yes,width=650,height=400,left=70,top=90,screenX=70,screenY=90");
 				} else {
						// come this way OP 4+
					top.location.href = url1;
				}
			}

			function newWindow3(url1) {
			// pop-up opinion (exclude OP 4+)
					// reuse opinion window if not closed
				if (notOpera) {
					opinionWindow = window.open(url1, "question", "scrollbars=yes,resizable=yes,width=650,height=250,left=70,top=90,screenX=70,screenY=90");
					opinionWindow.focus();
 				} else {
						// come this way OP 4+
					top.location.href = url1;
				}
			}

		function mainWindow(url) {
		// allow navigation inside pop-up window if the question has been answered
			if ((window.name == "question") && (notOpera))  {
					// pop-up window open
				window.opener.top.location.href = url; // OP 4 doesn't work; OP 5 buggy !!!!!
				window.close();
				} else {
						// no pop-up open; come this way OP
					top.location.href = url;
				}
			}

		function returnWindow(url) {
		// close pop-up window if open
			if ((window.name == "question") && (notOpera))  {
					// pop-up window open
				window.close();
				} else {
						// no pop-up open; come this way OP
					top.location.href = url;
				}
			}
