// nocookies.js

document.cookie = 'test=123; path=/';
document.cookie.indexOf('123') == -1 ? cookies = 'not ' : cookies = '';
$timeNow = new Date();


function setCookies()
{
  document.form.text.value = 'Cookies are reportedly ' + cookies + 'available'; 
  document.form.text2.value = document.cookie;
}

function createCookie()
{
  window.alert ('This will create (or overwrite) a cookie called Test2 \n' +
  		'Intended for use by programmer for debugging');
  document.cookie = 'Test2=' + $timeNow.getSeconds() + '; path=/';
  location.reload(true);
}
  

function delCookies()
{
  s = 'Click OK if you want to delete the cookies listed for this page. \n\n' +
      'This will not do any harm. It may not be possible to delete all  \n' + 
      'the cookies. Some (e.g. test and idx) may be re-created when the \n' +
      'this page is loaded. Others may have an explicit domain setting  \n' +
      'that prevents them from being deleted using this command.        \n\n' +
      'This button is mainly for use during debugging by the programmer.';
  
  if (!window.confirm(s)) return;
  
  c = unescape(document.cookie);
  c = c.split(';');
  
  s = 'Cookie array was broken down as follows...\n ';
  j = 0;
  while (c[j] != null)
  {
    s1 = c[j].split('=');
    s += s1[0] + ' <-- ' + s1[1] + '\n';
    j++;
  }
  
  $timeNow.setTime($timeNow.getTime() - 1000 * 86400 * 1); // 1 day in the past
  $cookieExpires = "; expires=" + $timeNow.toGMTString();
  
  s += '\nCookies over-written with an expiry date of yesterday...\n ';
  j = 0;
  while (c[j] != null)
  {
    s1 = c[j].split('=');
    
    $cookie = s1[0] + '=zapped; expires=' + $timeNow.toGMTString() + '; path=/';
    s += $cookie + '\n';
    document.cookie = $cookie;
    j++;
  }

  s += '\nThe page will now re-load to update the list of cookies\n ';
  
  window.alert(s);
  location.reload(true);
}