
<!--

	function showFeedback(n,f) {
		var width = 240, height = 180, scrolling = "no";
		popFeedback(f,width,height,scrolling)
	}


	function showFeedback_mch1(n,c,f1,f2) {
		var width = 240, height = 180, scrolling = "no";
		
		c = c.toString().substring(0,1);
		
		if ((c!="0") && (eval("document.Q" + n + "Form.Q" + n + "Choice[" + (c-1) + "].checked") == true))
			f=f1;
		else
			f=f2;
			
		popFeedback(f,width,height,scrolling)
	}

	function showFeedback_mch2(n,c,flist) {
		var width = 240, height = 180, scrolling = "no";
		var chosen = 0, f = "";
		
		for (i = 1; i < (c+1); i++) {
      		if (eval("document.Q" + n + "Form.Q" + n + "Choice[" + (i-1) + "].checked") == true)
        			chosen = i;
  		}

		var farray = flist.split("|");
		farray[0] = "Please select an answer.";
		f  = farray[chosen];
		
		popFeedback(f,width,height,scrolling)
	}


	function showFeedback_chb2(n,c,p,f1,f2) {
		var width = 240, height = 180, scrolling = "no";
		var parray = p.split("|"), f1array = f1.split("|"), f2array = f2.split("|"), f = "<ol class='numbered'>", score = 0;

		for (i = 0; i < (c); i++) {
      		if (eval("document.Q" + n + "Form.Q" + n + "Choice[" + i + "].checked") == parray[i]) {
				f += "<li>" + f1array[i] + "</li>";
				score += 1;
			}
			else
				f += "<li>" + f2array[i] + "</li>";
  		}

		f += "</ol>" + "<p>You got " + score + " right out of " + c + ".</p>";

		popFeedback(f,width,height,scrolling)
	}


	function showFeedback_chb3(n,c,p,f1,f2) {
		var width = 240, height = 180, scrolling = "no";
		var parray = p.split("|"), correct=0;

		for (i = 0; i < (c); i++) {
      		if (eval("document.Q" + n + "Form.Q" + n + "Choice[" + i + "].checked") != parray[i])
        		correct+= 1;
  		}

		if (correct == 0) f=f1; else f=f2;
		
		popFeedback(f,width,height,scrolling)
	}


	function showFeedback_txt2(n,a,fb) {
		var width = 135, height = 100, scrolling = "no";
		
		var f = '<table width="100%" summary="Layout table"><tr><td>You answered:</td><td>' + eval("document.Q" + n + "Form.Q" + n + "TextEntry.value") + '</td></tr>'
		f += '<tr><td>The correct answer is:</td><td>' + a + '</td></tr></table><br/><br/><p>' + fb + '</p>'
		
		popFeedback(f,width,height,scrolling)
	}


	function showFeedback_txt3(n,a,f1,f2) {
		var width = 240, height = 180, scrolling = "no";
		var ans_array = a.split("|"), c = ans_array.length - 1, correct=0;

		for (i = 0; i < (c); i++) {
      		if (trim(eval("document.Q" + n + "Form.Q" + n + "TextEntry.value")).toLowerCase() == trim(ans_array[i]).toLowerCase())
        		correct = 1;
  		}

		if (correct == 0) f=f2; else f=f1;

		popFeedback(f,width,height,scrolling)
	}


	function showFeedback_match2(n,c,p,f1,f2) {
		var width = 240, height = 180, scrolling = "no";
		var parray = p.split("|"), correct=0;

		for (i = 1; i < (c+1); i++) {
      		if ((eval("document.Q" + n + "Form.Q" + n + "Combo" + i + ".selectedIndex")) != parray[i-1])
        		correct+= 1;
  		}

		if (correct == 0) f=f1; else f=f2;
		
		popFeedback(f,width,height,scrolling)
	}


	function showFeedback_gap1(n,a,f) {
		var width = 240, height = 180, scrolling = "no";
		f = a + "<br/><br/>" + f;
		popFeedback(f,width,height,scrolling)
	}


	function showFeedback_gap2(n,g,as,al,f1,f2) {
		var width = 240, height = 180, scrolling = "no";
		var ans_array = al.split("|"), correct=0;

		for (i = 0; i < (g); i++) {
      		if (trim(eval("document.Q" + n + "Form.Q" + n + "TextEntry" + (i+1) + ".value")).toLowerCase() == trim(ans_array[i]).toLowerCase())
        		correct += 1;
  		}

		if (correct == g) f=f1; else f=f2;
		
		as = "You got " + correct + " right out of " + g + "."
		
		f = as + "<br/><br/>" + f;
		popFeedback(f,width,height,scrolling)
	}


	function showFeedback_gap4(n,g,as,al,f1,f2) {
		var width = 240, height = 180, scrolling = "no";
		var ans_array = al.split("|"), correct=0;

		for (i = 0; i < (g); i++) {
      		if (eval("document.Q" + n + "Form.Q" + n + "Combo" + (i+1) + ".options[document.Q" + n + "Form.Q" + n + "Combo" + (i+1) + ".selectedIndex].text") == ans_array[i])
        		correct += 1;
  		}

		if (correct == g) f=f1; else f=f2;
		
		as = "You got " + correct + " right out of " + g + "."
		
		f = as + "<br/><br/>" + f;
		popFeedback(f,width,height,scrolling)
	}


	function trim(s) {
	    while (s.substring(0,1) == ' ') s= s.substring(1,s.length);
	    while (s.substring(s.length-1,s.length) == ' ') s = s.substring(0,s.length-1);
	    return s;
	}


	function popFeedback(popText,myWidth,myHeight,myScroll) {
	
		popText=popText+"<br/><br/>"
		myWidth += Math.round((popText.length - 100)/3);
		if (popText.indexOf("<p") != -1) myWidth=myWidth*1.3;
		if (popText.indexOf("<ol") != -1) myWidth=myWidth*1.4;
		if (popText.indexOf("<ul") != -1) myWidth=myWidth*1.4;
		if (popText.indexOf("<table") != -1) myWidth=myWidth*1.7;
		if (popText.indexOf("<img") != -1) myWidth=640;
		if (myWidth>640) {myWidth=640;myScroll="yes";}
		myHeight = Math.round(myWidth * 3 / 4);
	
		var head1='<html><head><title>Feedback</title><link rel="stylesheet" href="cg.css" type="text/css"/></head>';
		
		var body1='<body onBlur="self.focus()"><table width="100%" height="100%" border="0" cellspacing="0" cellpadding="2" summary="Layout table"><tr> <td align="right" height="4" width="100%"><table width="100%" border="0" cellspacing="0" cellpadding="0" summary="Layout table"><tr><td height="2" align="left" valign="middle" bgcolor="#CCCCCC"></td></tr></table></td><td align="right" width="80"><a href="javascript://" onClick="self.close(); return false;"><img name="Close" border="0" src="buttons/btn_close_up.gif" width="64" height="21" alt="Close this window"></a></td></tr><tr><td colspan="2" id="feedback">';

		var body2= popText ;
		
		var body3='</td></tr><tr> <td align="right" width="100%"><table width="100%" border="0" cellspacing="0" cellpadding="0" summary="Layout table"><tr><td height="2" align="left" valign="middle" bgcolor="#CCCCCC"></td></tr></table></td><td align="right" width="80"><a href="javascript://" onClick="self.close(); return false;"><img name="Close" border="0" src="buttons/btn_close_up.gif" width="64" height="21" alt="Close this window"></a></td></tr></table></body></html>'
		
		popWin=window.open("","popupWindow","width="+myWidth+",height="+myHeight+",menubar=no,scrollbars="+myScroll+",resizable=yes");
		popWin.document.write(head1+body1+body2+body3);
		popWin.document.close();  
		popWin.focus();
		return true;
	}

	function winPop1(popText,myWidth,myHeight) {
		var head1="<head><title>courseGenie Popup</title></head>";
		var body1="<body onBlur='self.focus()'>";
		var body2=popText;
		var body3="<img src='foo'/></body>";
		popWin=window.open("","popupWindow","width="+myWidth+",height="+myHeight+",menubar=no");
		popWin.document.write(head1+body1+body2+body3);
		popWin.document.close();  
		popWin.focus();
		return true;
	}

	function winPop2(popUrl,myWidth,myHeight,myScroll) {
		popWin=window.open(""+popUrl,"popupWindow","width="+myWidth+",height="+myHeight+",scrollbars="+myScroll+",menubar=no");
		return true;
	}
	
	function winOpen(winUrl) { 
	 popWin=window.open(winUrl,"linkWindow","width=640,height=480,status=yes,toolbar=yes,menubar=yes,resizable=yes,location=yes,scrollbars=yes");
	}

	function swapImgRestore() {
	  var i,x,a=document.cg_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
	}

	function findObj(n, d) {
	  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
	    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
	  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
	  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=findObj(n,d.layers[i].document); return x;
	}

	function swapImage() {
	  var i,j=0,x,a=swapImage.arguments; document.cg_sr=new Array; for(i=0;i<(a.length-2);i+=3)
	   if ((x=findObj(a[i]))!=null){document.cg_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
	}
	
// -->	
