<!--

//  script is for the main pages, to be used in conjunction with personaliseDisplay.js
//  retrieves the values and sets variables for use on the main page

function Get_Cookie(name) {
// retrieves the cookie and sets the variable userProfile with the complete string held in the cookie
// called by global var userProfile

    var start = document.cookie.indexOf(name+"=");
    var len = start+name.length+1;
    if ((!start) && (name != document.cookie.substring(0,name.length))) return null;
    if (start == -1) return null;
    var end = document.cookie.indexOf(";",len);
    if (end == -1) end = document.cookie.length;
    return unescape(document.cookie.substring(len,end));
}

function getValues(string,elementName) {
//  string = complete string of userProfile
//  elementName = the elementName whose value is to be returned
//  this function is needed to check the element type, specifically if its an array, before sending to getValue()
//  called by global variable/s and lookup()

var elementValue;
var elementValueArray = new Array();

    if (elementName == "interests") {
    for (var i=0;i<7+1;i++)
       elementValueArray[i]= getValue(string,"i"+i);
    return elementValueArray;
    }
else
    {
    elementValue = getValue(string,elementName);
    return elementValue;
     }
}

function getValue(string,elementName) {
// gets value of elementName from string
// called by getValues()

    var startPos = string.indexOf(elementName + "=")
    if (startPos > -1) {
        startPos = startPos + elementName.length + 1;
        var endPos = string.indexOf("&",startPos);
        if (endPos == -1) endPos = string.length;
        var elementValue = unescape(string.substring(startPos,endPos));
    }
	  else {
	  	  var elementValue = null;
    }
return elementValue;
}

function loadColour() {
// uses the background/text colours selected in personalise.html to display
// called by inline command onload within BODY tag

if (backColour != null) {document.bgColor=backColour;}
if (textColour != null) {document.fgColor=textColour;}
if (backColour == null || textColour == null) {document.bgColor="white"; document.fgColor="black";}
if (backColour == textColour) {document.bgColor="white"; document.fgColor="black";}
}

function lookup(type,value) {
//  my baby database - converts the numerical reference to the text string
//  don't use switch to keep it backward compatible with < ver 4 browsers
//  called by global variables
    if (type == "world") {
       if (value == "0") { value = "UK";}
       if (value == "1") { value = "Rep Ireland";}
       if (value == "2") { value = "USA/Canada";}
       if (value == "3") { value = "Cont.Europe";}
       if (value == "4") { value = "Australasia";}
       if (value == "5") { value = "Asia";}
       if (value == "6") { value = "Africa";}
       if (value == "7") { value = "World";}     
       else {value == "Mars";}
}

else {
       if (value == "0") { value = "white";}
       if (value == "1") { value = "black";}
       if (value == "2") { value = "green";}
       if (value == "3") { value = "olive";}
       if (value == "4") { value = "navy";}
       if (value == "5") { value = "gray";}
       if (value == "6") { value = "yellow";}
       if (value == "7") { value = "blue";}
}
return value;
}

//-->