<!--hide this script from non-javascript-enabled browsers

//////////////////////////////////////////////////////////
//
// Joint Earth Sciences Education Initiative
//
// Produced by Presenting Science
//  www.PresentingScience.com
//
// Copyright (C) Presenting Science
//
//////////////////////////////////////////////////////////

 /**
  * Read the last loaded fascinating fact and increment cookie
  */
 function loadFact() {
    var index = 1;
    var lastIndex = readCookie("FactNumber");
    if (lastIndex.length>0) {
        var newIndex = 1+(lastIndex-0);
        if (newIndex>0 && newIndex<36)
            index = newIndex;
    }
    location = "../fascinat/fact"+index+".htm";
    writeCookie("FactNumber", index);
 }

 /**
  * General purpose: extract and return the labelled cookie
  */
 function readCookie(label) {
    var c = document.cookie;
    var pos = c.indexOf(label);
    if (pos != -1) {
         var start = pos+label.length;
         var d = c.substring(start, c.length)
         var end = d.indexOf(";");
         if (end == -1) end = d.length;
         var h = d.substring(0, end);
         h = unescape(h);
         if (h.length>0) {
            return h;
        }
    }
    return "";
 }
 
 /**
  * General purpose: write the labelled cookie
  */
 function writeCookie(label, value) {
     var nextYear = new Date();  
     nextYear.setFullYear(nextYear.getFullYear()+1);	// Will last for one year
    
     document.cookie = label+escape(value) + "; expires=" + nextYear.toGMTString();
 }

 /**
  * Set the contents page according to the DefaultContents cookie
  */
 function doContents() {
     var s = readCookie("DefaultContents=");
     var done = false;
     if (s.length>0) {
         var f = s-0;
         switch(f) {
         case 1:
             parent.contentsFrame.location="btopics.htm";
             done = true;
             break;
         case 2:
             parent.contentsFrame.location="ctopics.htm";
             done = true;
             break;
         case 4:
             parent.contentsFrame.location="ptopics.htm";
             done = true;
             break;
         case 100: // Special case for Scottish contents
             parent.contentsFrame.location="stopics.htm";
             done = true;
             break;
         }
     }
     if (!done) parent.contentsFrame.location="topics.htm";    
 }


 /**
  *
  */
 function setDefaultContents(flag) {
    writeCookie("DefaultContents=",flag);
 }

// stop hiding -->
