
var answ_a='';

var answ_b='';

var answ_c='';

var answ_d='';

newwindow=null; //variable to detect whether the window exists

w=0;

h=0;

function openinwindoid(url,wd,ht) //main function
{
    if (newwindow!=null) 
    {                     //then window has been opened before
        if (newwindow.closed)
        {                 //then window has been opened, but user has closed it, so open another
            newwindow=window.open(url,"windoid","toolbar=no,location=no,directories=no,status=no,scrollbars=yes,menubar=no,resizable=no,width="+wd+",height="+ht,'centered=yes');
            w=wd;
            h=ht;
        }
        else
        {   
                          //window has been opened and is still open, so just focus and change location
            if (!((w==wd)&&(h==ht)))
            {
                newwindow.close();
                newwindow=window.open(url,"windoid","toolbar=no,location=no,directories=no,status=no,scrollbars=yes,menubar=no,resizable=no,width="+wd+",height="+ht);
                w=wd;
                h=ht;
            }
            newwindow.location=url;
           newwindow.focus();
        }
    }

    else

    {                     //window's never been opened, opening for the first time

        newwindow=window.open(url,"windoid","toolbar=no,location=no,directories=no,status=no,scrollbars=yes,menubar=no,resizable=no,width="+wd+",height="+ht,'center=yes');

        w=wd;

        h=ht;                                                                                                                                   //width and height are entered here, change as needed

    }

}


function cleanup()        //use this with the onUnload event handler in the <BODY> tag of the document to close the windoid on leaving the page
{
    newwindow.close();
}

function clearanswer() {

  {

    document.askit.feedback.value="  !"

  }

  return

}

function MM_swapImgRestore() { //v3.0

  var i,x,a=document.MM_sr;
  for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) {

    x.src=x.oSrc;
  }

}


function MM_preloadImages() { //v3.0

  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();

    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)

    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}

}



function MM_findObj(n, d) { //v4.0

  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=MM_findObj(n,d.layers[i].document);

  if(!x && document.getElementById) x=document.getElementById(n); return x;

}



function MM_swapImage() { //v3.0

  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)

   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}

}

function setAnswers(a, b, c, d) {
  answ_a = a;
  answ_b = b;
  answ_c = c;
  answ_d = d;
}

function checkClick(thisButton) {
  //assign answers to selected response

  if (thisButton.value == '1' && thisButton.checked == true) {

    document.askit.feedback.value=answ_a;
  }

  if (thisButton.value == '2' && thisButton.checked == true) {

    document.askit.feedback.value=answ_b;
  }

  if (thisButton.value == '3' && thisButton.checked == true) {

    document.askit.feedback.value=answ_c;
  }

  if (thisButton.value == '4' && thisButton.checked == true) {

    document.askit.feedback.value=answ_d;
  }

  return;
}

function fwLoadMenus() {

  if (window.fw_menu_0) return;

  window.fw_menu_0 = new Menu("root",135,21,"Verdana, Arial, Helvetica, sans-serif",14,"#ffffff","#333366","#333366","#ffffcc");

  fw_menu_0.addMenuItem("Intro","location='modintro.html'");

  fw_menu_0.addMenuItem("What's a Type","location='p1.html'");

  fw_menu_0.addMenuItem("Boolean Values","location='p2.html'");

  fw_menu_0.addMenuItem("Operators","location='p3.html'");

  fw_menu_0.addMenuItem("Parentheses","location='p4.html'");

  fw_menu_0.addMenuItem("Precedence","location='p5.html'");

  fw_menu_0.addMenuItem("Boolean Tyro","location='p6.html'");

   fw_menu_0.hideOnMouseOut=true;



  fw_menu_0.writeMenus();

} // fwLoadMenus()

// = URL of current directory

function getDirPath(URL) {

	return unescape(URL.substring(0,(URL.lastIndexOf("."))));

}



// replace this window with p1a.html

function replacewith() {

   window.location.href =  getDirPath(location.href) + "a.html";

}

// Set the feedback area to the empty string

function clearfeedback(){

	document.form2.feedback.value=" ";

	return;

}



// open a new window with page_help.html

function loadHelp() {

	openinwindoid(getDirPath(location.href) + "_help.html",540,380);

}



// Check field1 and field2 for the values true and false and act accordingly

function checkTrueFalse() {

   if ((document.form1.field1.value.toUpperCase()=="TRUE" && document.form1.field2.value.toUpperCase()=="FALSE") ||

       (document.form1.field1.value.toUpperCase()=="FALSE" && document.form1.field2.value.toUpperCase()=="TRUE")) {

        replacewith();

	return;

   }

   if (document.form1.field1.value=="true" || document.form1.field2.value=="true") {

   		document.form2.feedback.value="Yes, 'true' is one of the constants, but the other one is wrong.";

		return;

   }

      if (document.form1.field1.value=="false" || document.form1.field2.value=="false") {

   		document.form2.feedback.value="Yes 'false' is one of the constants, but the other one is wrong.";

		return;

   }



   document.form2.feedback.value="Please try again. If you do not know the answer, then click 'see answer'.";

}

