function SetCookie(sName, sValue, days , domain, path ) {

  var expiry; 
  if (days==null || days==0) 
  {
      expiry = "; expires=Mon, 31 Dec 2099 23:59:59 UTC;"
  }
  else
  {
     var expire = new Date();
     var today = new Date();
     expire.setTime(today.getTime() + 3600000*24*days);
     expiry = "; expires="+expire.toGMTString();
  }

  date = new Date();

  
  var cookie_string = sName + "=" + escape(sValue) + expiry;
  if( path ) 
  {
    cookie_string += ' path='+path+';';
  }
  else
  {
    cookie_string += ' path=/;';
  }

  if( domain ) { cookie_string += ' domain='+escape(domain)+';';}

  document.cookie = cookie_string;
}


function GetCookie(sName) {
  // cookies are separated by semicolons
  var aCookie = document.cookie.split("; ");
  for (var i=0; i < aCookie.length; i++)   {
    // a name/value pair (a crumb) is separated by an equal sign
    var aCrumb = aCookie[i].split("=");
    if (sName == aCrumb[0]) 
      return unescape(aCrumb[1]);
  }
  // a cookie with the requested name does not exist
  return null;
}

function expand_spec(id) {
  if(document.all) { // IE
      document.all[id].style.display = '';
  }
  if(!document.all && document.getElementById) { // Netscape 6
 
    document.getElementById(id).style.display = '';
  }
}

function collapse_spec(id) {
  if(document.all) { // IE
      document.all[id].style.display = 'block';
  }
  if(!document.all && document.getElementById) { // Netscape 6
    document.getElementById(id).style.display = 'block';
//alert( document.getElementById(id).style.display );
  }
}

function show_by_state(id, def) {
   value = GetCookie(id);
   if( ! value  )
   {
     value = def;
     SetCookie(id, def);
   }

   if( value == 'ON' ) 
   {
      expand_spec(id);
   }
   else
   {
      collapse_spec(id);
   }

}


function showSpec(id) {
   value = GetCookie(id);
   if( value == 'ON' )
   {
       value = 'OFF';
   }
   else
   {
       value = 'ON';
   }
   SetCookie(id, value);
   show_by_state(id, value);
}

function showSpec10days(id, domain) {

   SetCookie(id, '', -1 , false , '/perl/' );
   SetCookie(id, '', -1 , false  );

   value = GetCookie(id);
   if( value == 'ON' )
   {
       value = 'OFF';
   }
   else
   {
       value = 'ON';
   }
   SetCookie(id, value, 10, domain);
   show_by_state(id, value);
}

