<!--hide this script from non-javascript-enabled browsers

//////////////////////////////////////////////////////////
//
// Afl Chemistry
//
// Produced by Presenting Science
//  www.PresentingScience.com
//
// Copyright (C) Royal Society of Chemistry &
//		 Presenting Science 2005
//
//////////////////////////////////////////////////////////


var label = "ShowWelcomePage=";	// The name of the cookie

/**
 * Redirect if welcome page is not required - called on load in redirect.htm
 */
 function doRedirect(i) {
    var welcomeCookie = readWelcomeCookie();
    location = (welcomeCookie=="0")? "chapind.htm" : i==2? "home2.htm" : "home.htm";	 
 }

/**
 * Update the checkbox from the cookie - called on load in home.htm
 */
function updateWelcomeCheckBox() {
    var welcomeCookie = readWelcomeCookie();
    document.form.WelcomePage.checked = (welcomeCookie=="0");
}

/**
 * Update the cookie from the checkbox - called when checkbox is clicked
 */
function updateWelcomeCookie() {
    var c = document.form.WelcomePage.checked? "0" : "1";
    writeWelcomeCookie(c);
}


/**
 * Extract and return the welcome cookie
 */
 function readWelcomeCookie() {
    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 "";
}
 
/**
 * Write the Welcome cookie
 */
 function writeWelcomeCookie(value) {
     var nextYear = new Date();
     nextYear.setFullYear(nextYear.getFullYear()+1);	// Will last for one year
     document.cookie = label+escape(value) + "; expires=" + nextYear.toGMTString();
 }

// stop hiding -->


