function show_hide(id) {
  if (document.getElementById(id).style.visibility=='hidden'){
    document.getElementById(id).style.visibility='visible';
    document.getElementById(id).style.display='block';
  }
 else{
    document.getElementById(id).style.visibility='hidden';
    document.getElementById(id).style.display='none';
 }
return;
}


var OSName="Unknown OS";
if (navigator.appVersion.indexOf("Win")!=-1) OSName="Windows";
if (navigator.appVersion.indexOf("Mac")!=-1) OSName="MacOS";
if (navigator.appVersion.indexOf("X11")!=-1) OSName="UNIX";
if (navigator.appVersion.indexOf("Linux")!=-1) OSName="Linux";

if (document.layers) {n=1;ie=0}
if (document.all) {n=0;ie=1}

function addressbook(){
        adwindow=window.open('/cgi-bin/addressbook.pl','address','location=no,menubar=no,status=no,scrollbars=yes,toolbar=no,height=450,width=300');
        if (adwindow.opener == null) adwindow.opener = self;
        }

function save(){
window.open('','composed','location=no,menubar=no,status=no,scrollbars=no,resize=no,toolbar=no,height=200,width=400');
document.messenger.typevalue.value="save";	
document.messenger.submit();
}

function share(){
//window.open('','composed','location=no,menubar=no,status=no,scrollbars=no,resize=no,toolbar=no,height=200,width=400');
document.messenger.typevalue.value="post";	
document.messenger.submit();
}


function popup(URL)  {
  var ran_number=Math.round(Math.random()*100);
  var winname = "win"+ran_number;
  var popupwin = window.open (URL, winname, "toolbar=yes,width=520,height=550,status=no,scrollbars=yes,resize=no,menubar=no,location=no"); 
  if (popupwin.focus) popupwin.focus();
} 

function initpoptext(count) {
 tabShow = new Array();
 tab = new Array();
 poptext = new Array();

if (document["poptextDiv0"] || window["poptextDiv0"]) {  // page contains poptext)

  for(i=0;i<=count;i++){
        if (n) tab[i] = document["tabDiv"+i];
//alert("init"+i+tab[i].visibility);
        if (n) poptext[i] = document["poptextDiv"+i];
        if (ie) tab[i] = window["tabDiv"+i].style
        if (ie) poptext[i] = window["poptextDiv"+i].style

        tabShow[i]=0;  // start as hidden
  }
 }
}

function hidepoptext(id) {
//Hide-Show Layer
        if (tabShow[id] == 1) {
                if (n) {
                tab[id].visibility = "hide";
                tab[id].left = 0;
                tab[id].visibility = "show";
                poptext[id].visibility = "hide";
                tabShow[id] = 0;
                return;
                }
                        if (ie) {
                tab[id].visibility = "hidden";
                tab[id].left = 0;
                tab[id].visibility = "visible";
                poptext[id].visibility = "hidden";
                tabShow[id] = 0;
		return;
		}
 		}
        if (tabShow[id] == 0) {
                if (n) {
//alert("show"+id);
                tab[id].visibility = "hide";
                tab[id].left = 223;
                tab[id].visibility = "show";
                poptext[id].visibility = "show";
                tabShow[id] = 1;
                           }
                        if (ie) {
                                tab[id].visibility = "hidden";
                tab[id].left = 223;
                tab[id].visibility = "visible";
                poptext[id].visibility = "visible";
                tabShow[id] = 1;
                                }
}
}

// --------------------------------------
var imgArray = new Array();

function imgLoad(iname,id,source) {
// set up the imgArray for use in the imgSwitch function
// also preloads images into browser
 if (! imgArray[iname]) {
  imgArray[iname] = new Array();
 }

  imgArray[iname][id] = new Image();
  imgArray[iname][id].src = source;
}
 
function imgSwitch(iname,id) {
// replace the source of the image identified by iname with that in the imgArray keyed by id
 if (document.images[iname]) {
  document.images[iname].src = imgArray[iname][id].src;
 }
}

// --------------------------------------
function click_hottext(text,session) {
 var link = "/cgi-bin/dictionary.pl?hottext=" + escape(text) + ";session=" +session;
 dictionarywindow = open(link, "dictionary", "scrollbars,resizable,height=200,width=430");
 dictionarywindow.focus();
}

var soundwindow;

function hearpage(pagecode) {
 var link = "/sound/pages/page"+pagecode+".mov";
 soundwindow = open(link, "sound", "resizable,height=30,width=130");
 soundwindow.focus();
}

function listenWindow(src) {
//defunct function
 var extension = '.mov';
 var dir = '/audio/';
 var link = dir + src + extension;
 soundwindow = open(link, "sound", "resizable,height=30,width=130");
 soundwindow.focus();
}

function playMovie(movieName,src) {
// day Fri Mar  2 03:40:17 EST 2001
if (!src) {
alert('Audio for this page is not available.');
return;
}
// jd mar 2 4:53 EST
//if (document[movieName]) {

// cheap fix until we find something better
//browsername=navigator.userAgent.toLowerCase();
//if (browsername.indexOf("msie")!=-1 || OSName != "Windows") 
//{
//EXPLORER and assorted other non netscape+windoze combos

//day added screenx,screeny (left,top) Thu May 17 04:48:30 EDT 2001
// IE uses top,left; NN uses screeny,screenx
var top = 30; 
var left = 20;
soundwindow = open(src,"sound","resizable,height=30,width=130,screenx="+left+",screeny="+top+",left="+left+",top="+top);

//soundwindow.focus();

//}
// else {
   //NETSCAPE
//document[movieName].Play();
//  };



//}
}

function dictionary(pageid,session) {
 var link = "/cgi-bin/dictionary.pl?pageid=" +pageid+ ";session=" +session;
 var dictionarywindow = open(link, "dictionary", "scrollbars,resizable,height=520,width=360");
 dictionarywindow.focus();
}

rolloverImagesOn=new Array();
rolloverImagesOff=new Array();
rolloverPeekImagesOn=new Array();
rolloverPeekImagesOff=new Array();

function rolloverOn(name) {
 if (! document.images)return;
 if (document.images[name]) {
      document.images[name].src=rolloverImagesOn[name].src;
 }
}

function rolloverOff(name) {
 if (! document.images)return;
 if (document.images[name]) {
       document.images[name].src=rolloverImagesOff[name].src;
 }
}

function rolloverLoad(name,on,off) {
  rolloverImagesOn[name]=new Image();
  rolloverImagesOn[name].src=on;
  rolloverImagesOff[name]=new Image();
  rolloverImagesOff[name].src=off;
}

function rolloverOn2(name,peek) {
 if (! document.images)return;
 if (document.images[name]) {
      document.images[name].src=rolloverImagesOn[name].src;
       }
 if (document.images[peek]){
   document.images[peek].src=rolloverPeekImagesOn[name].src; 
 }
}

function rolloverOff2(name,peek) {
 if (! document.images)return;
 if (document.images[name]) {
       document.images[name].src=rolloverImagesOff[name].src;
 }
 if (document.images[peek]){
   document.images[peek].src=rolloverPeekImagesOff[name].src; 
 }
}

function rolloverLoad2(name,on,off,peek_on,peek_off) {
  rolloverLoad(name,on,off);
  rolloverPeekImagesOn[name]=new Image();
  rolloverPeekImagesOn[name].src=peek_on;
  rolloverPeekImagesOff[name]=new Image();
  rolloverPeekImagesOff[name].src=peek_off;
}


function preloadImages() {
//var doc=document; if(doc.images){ if(!doc.newarray) doc.newarray=new Array();
//var x,y=doc.newarray.length,a=preloadImages.arguments; for(x=0; x<a.length; x++)
//if (a[x].indexOf("#")!=0){ doc.newarray[y]=new Image; doc.newarray[y++].src=a[x];}}
}

function feedback(id,answer) {
if (
(document.testform[id][0].checked &&
document.testform[id][0].value == answer)
||
(document.testform[id][1].checked &&
document.testform[id][1].value == answer)
) {
document.testform[id+"_feedback"].value = "Correct!";
} else {
document.testform[id+"_feedback"].value = "Try again.";
}
}

function feedback_fitb(test) {
 for(qnum=1;qnum<=5;qnum++){
  for(pnum=1;pnum<=2;pnum++){
    if (document.testform[test+"q"+qnum+"p"+pnum+"_feedback"]) {
      document.testform[test+"q"+qnum+"p"+pnum+"_feedback"].value = document.testform[test+"q"+qnum+"p"+pnum+"_answer"].value;
    } 
  }
 }
}


function openScript(url, width, height) {
if (url == "/cgi-bin/portal/forum/messagecenter.cgi"){
url= url+window.location.search;
}
        var Win = window.open(url,"openScript",'width=' + width + ',height=' + height + ',resizable=1,scrollbars=yes,menubar=yes,status=yes' );

Win.focus();
}

function openMinimal(url, width, height) {

        var Win = window.open(url,"openScript",'width=' + width + ',height=' + height + ',resizable=yes,scrollbars=yes,menubar=no,status=no' );
Win.focus();
}












