<!--hide this script from non-javascript-enabled browsers

//////////////////////////////////////////////////////////
//
// Periodic Table of Data
//
// Produced by Presenting Science
//  www.PresentingScience.com
//
// Copyright (C) Royal Society of Chemistry &
//		 Presenting Science 2004-2006
//
//////////////////////////////////////////////////////////


var label = "STARTPAGE=";	// The name of the cookie

function initStartPage() {
	updateStartUpCheckBox();
}

// Set up version applet
function initSystemInfo() {
	
	if (document.SystemInfo.isLoaded()==1) {
		// Initialise fonts, colours etc.
		document.SystemInfo.setJavascript();
	}
	else
		setTimeout("initSystemInfo()", 100);

}

/**
 * Do the redirect depending on the cookie, called when the main frameset is (re)loaded
 */
function doStartUpRedirect() {
    var startupCookie = readStartUpCookie() - 0;    
	
	//startupCookie = 0;
	
	switch (startupCookie) {
	case 0:
		// no action required
		break;
	case 1:
		if (navigator.javaEnabled()) bottomFrame.document.location="sindex.htm";
		break;
	case 2:
		bottomFrame.document.location="vindex.htm";
		break;
	case 3:
		bottomFrame.document.location="sias.htm";
		break;
	}
	
}

/**
 * Update the radio from the cookie - called on load of home page
 */
function updateStartUpCheckBox() {
    var startUpCookie = readStartUpCookie() - 0;    

    document.form.startUpPage[0].checked = startUpCookie==0;
    document.form.startUpPage[1].checked = startUpCookie==1;
    document.form.startUpPage[2].checked = startUpCookie==2;
    document.form.startUpPage[3].checked = startUpCookie==3;
}

/**
 * Update the cookie from the radio- called when radio is clicked
 */
function updateStartUpCookie(i) {
	
	document.form.startUpPage[0].checked = i==0;
	document.form.startUpPage[1].checked = i==1;
	document.form.startUpPage[2].checked = i==2;
	document.form.startUpPage[3].checked = i==3;
	
    var c = ""+i;
    writeStartUpCookie(c);
}


/**
 * Extract and return the startup cookie
 */
 function readStartUpCookie() {
    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 startup cookie
 */
 function writeStartUpCookie(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 -->

