/*
	Optimized for 4+ browsers: Explorer, Netscape, Opera

	Comments: Call this file in pages that open pop-up windows and in the pop-up pages themselves
*/

			// 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
							}
					} 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=800,height=600,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=800,height=600,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 opnion window if not closed
				if (notOpera) {
					opinionWindow = window.open(url1, "question", "scrollbars=yes,resizable=yes,width=800,height=280,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;
				}
			}
