// JavaScript Document

var DivTotal=20,DivDisplay=1;

function toggleFAQ(theFaq) {
	 if (!theFaq || theFaq == "") return;
	   document.getElementById(theFaq).style.display=(document.getElementById(theFaq).style.display=='block')?'none':'block';
	   frames['iframe2'].location.href = 'interaction/toggle.htm?'+thisPage+'-'+theFaq; 
	   }
	   
function _toggleFAQ(theFaq) {
	if (!document.getElementById) return;
	var o=toggleFAQ.arguments;
	   document.getElementById(o[0]).style.display=(document.getElementById(o[0]).style.display=='block')?'none':'block';
	   frames['iframe2'].location.href = 'interaction/toggle.htm?'+thisPage+'-'+o[0]; 
	   }

function collapseFAQs() {
	if (!document.getElementById || !DivTotal) return;
	for (var i=0; i<=DivTotal; i++) {
		if (document.getElementById('hint_'+i)) document.getElementById('hint_'+i).style.display = 'none';
		if (document.getElementById('soln_'+i)) document.getElementById('soln_'+i).style.display = 'none';
		}
	DivDisplay=0
	}
function expandFAQs() {
	if (!document.getElementById || !DivTotal) return;
	for (var i=0; i<=DivTotal; i++) {
		if (document.getElementById('hint_'+i)) document.getElementById('hint_'+i).style.display = 'block';
		if (document.getElementById('soln_'+i)) document.getElementById('soln_'+i).style.display = 'block';
		}
	DivDisplay=0
	}
function RecordInteraction(destinationPage) {
   frames['iframe2'].location.href = 'interaction/interaction.htm?'+destinationPage;
   }

function Correct(theProblem,theAnswer) {
   alert("Correct");
   frames['iframe2'].location.href = 'interaction/correct.htm?'+thisPage+'-'+theProblem;
   }
function Incorrect(theProblem,theAnswer) {
   if (!theAnswer || theAnswer == "") 
     { 
	   alert('No value found: Please enter a numerical value into the field to the right of the button you just pressed.') 
	   return; 
	 }
   if (readCookie(theProblem) == theAnswer)
    { 
     alert("Insanity: Doing the same thing twice and expecting different results.");
	 return;
    }
   document.cookie=theProblem+'='+theAnswer;
   alert("Incorrect");
   frames['iframe2'].location.href = 'interaction/incorrect.htm?'+thisPage+'-'+theProblem;
   (new Image()).src="interaction/incorrect-guess"+thisPage+'-'+theProblem+'-'+theAnswer;
   }
   
function readCookie(cookieName){
   var searchName = cookieName + "="
   var cookies = document.cookie
   var start = cookies.indexOf(cookieName)
   if (start == -1){ // cookie not found 
     return ""
     }
   start += searchName.length //start of the cookie data
   var end = cookies.indexOf(";", start)
   if (end == -1){
     end = cookies.length
     }
   return cookies.substring(start, end)
   }
function submitIt() {
		 document.email_form.recipient.value = '@';
	     document.email_form.recipient.value = 'nickvautierwebsite'+document.email_form.recipient.value;
         document.email_form.recipient.value = document.email_form.recipient.value+'gmail.com';
	     document.email_form.submit();
  }
