function newsToggle(e) {
 a=e.parentNode.parentNode.childNodes[5];
 if(a.style.display!='block') {
  a.style.display='block';
 } else {
  a.style.display='none';
 }
 return false;
}

function createCookie(name,value) {
 var d = new Date();
 d.setTime(d.getTime()+86400);
 document.cookie = name+"="+value+';expires='+d.toGMTString();
}

function readCookie(name) {
 name += "=";
 var carray = document.cookie.split(';');
 if(carray == '') {
  return null;
 }
 for(i=0; i < carray.length; i++) {
  var c = carray[i];
  while (c.substring(0, 1) == ' ') {
   c = c.substring(1, c.length);
  }
  // alert(name + '/' + c);
  if (c.indexOf(name) == 0) {
   return c.substring(name.length,c.length);
  }
 }
 return(null);
}

function salute(salut) {
 if ((salut != null) && (salut != 'null') && (salut != '')) {
  o = document.getElementById('masterHeading');
  o.innerHTML = 'The ' +  salut + '\'s Road to nowhere';
  currentSalut = salut;
  return true;
 }
 return false;
}

function salutizer() {
 newsalut = currentSalut;
 newsalut = window.prompt('What is your first name?', newsalut);
 return(salute(newsalut));
}

function setStyle(styleId) {
 for(i=1; (a = document.getElementById('style' +i)); i++) {
  if(a.id != styleId) {
   a.disabled = true;
  }
 }
 a = document.getElementById(styleId);
 a.disabled = false;
 return true;
}

setStyle('style1'); // MSIE safety belts
window.onload = function(e){
 var currentStyle = readCookie('ourFamousStyle');
 if (currentStyle == null) {
  setStyle('style1');
 } else {
  setStyle(currentStyle);
 }
 currentSalut = unescape(readCookie('ourFamousSalut'));
 salute(currentSalut);
}

window.onunload = function(e){
 for(i=1; (a = document.getElementById('style' +i)); i++) {
  if(!a.disabled) {
   createCookie('ourFamousStyle', a.id);
  }
 }
 createCookie('ourFamousSalut', escape(currentSalut));
}
