var mySavedColourPreference = Cookie.read('colour-preference');
    if (mySavedColourPreference == 'colourhighvisibility') {
      $$('body').removeClass('high');
      $$('body').addClass('highvisibility');
    }
    else if (mySavedColourPreference == 'colourhighcontrast') {
      $$('body').removeClass('highvisibility');  
      $$('body').addClass('high'); 
    }
    else {
      $$('body').removeClass('high');  
      $$('body').removeClass('highvisibility'); 
    }
  
  var mySavedTextPreference = Cookie.read('text-preference');
    if (mySavedTextPreference == 'textxlarge') {
      $$('body').removeClass('large');
      $$('body').addClass('xlarge');
    }
    else if (mySavedTextPreference == 'textlarge') {
      $$('body').removeClass('xlarge');  
      $$('body').addClass('large'); 
    }
    else {
      $$('body').removeClass('large');  
      $$('body').removeClass('xlarge'); 
    }

window.addEvent('domready', function(){

  //inject textSwitcher buttons
  new Element('p', {id: 'accessibility', html: 'Text size:'}).inject($('textSwitcher'));
  new Element('input', {type: 'button', value: 'T', id: 'textnormal'}).inject($('textSwitcher'));
  new Element('input', {type: 'button', value: 'T', id: 'textbig'}).inject($('textSwitcher'));
  new Element('input', {type: 'button', value: 'T', id: 'textbigger'}).inject($('textSwitcher'));

  //inject colourSwitcher buttons
  new Element('p', {id: 'accessibilitycolour', html: 'Contrast options:'}).inject($('colourSwitcher'));
  new Element('input', {type: 'button', value: 'C', id: 'colournormal'}).inject($('colourSwitcher'));
  new Element('input', {type: 'button', value: 'C', id: 'colourhighcontrast'}).inject($('colourSwitcher'));
  new Element('input', {type: 'button', value: 'C', id: 'colourhighvisibility'}).inject($('colourSwitcher'));

  $$('input#colournormal').addEvent('click', function(){
    colourSwitch('colournormal');
  });
  $$('input#colourhighcontrast').addEvent('click', function(){
    colourSwitch('colourhighcontrast');
  });
  $$('input#colourhighvisibility').addEvent('click', function(){
    colourSwitch('colourhighvisibility');
  });

  $$('input#textnormal').addEvent('click', function(){
    textSwitch('textnormal');
  });
  $$('input#textbig').addEvent('click', function(){
    textSwitch('textlarge');
  });
  $$('input#textbigger').addEvent('click', function(){
    textSwitch('textxlarge');
  });
  
  
  function colourSwitch(myColourPreference) {   
    if (myColourPreference == 'colournormal') {
      $$('body').removeClass('high');
      $$('body').removeClass('highvisibility');
    }
    else if (myColourPreference == 'colourhighcontrast') {
      $$('body').removeClass('highvisibility');  
      $$('body').addClass('high'); 
    }
    else {
      $$('body').removeClass('high');  
      $$('body').addClass('highvisibility'); 
    }
      Cookie.write('colour-preference', myColourPreference, {
        path: '/',
        duration: 1
      });
  };
  
  function textSwitch(myTextPreference) {   
    if (myTextPreference == 'textnormal') {
      $$('body').removeClass('large');
      $$('body').removeClass('xlarge');
    }
    else if (myTextPreference == 'textlarge') {
      $$('body').removeClass('xlarge');  
      $$('body').addClass('large'); 
    }
    else {
      $$('body').removeClass('large');  
      $$('body').addClass('xlarge'); 
    }
      Cookie.write('text-preference', myTextPreference, {
        path: '/',
        duration: 1
      });
  };


});