  var cookie_name="pics_";

  var expire=new Date(2010,3,15);
  expire=expire.toGMTString();

  function get_cookies()
  {
    cookies=new Array;
    stuff=document.cookie.split("; ");
    for(index=0;index<stuff.length;index++)
    {
      stuff_tmp=stuff[index].split("=");
      if(stuff_tmp[0].substring(0,cookie_name.length)==cookie_name)
      {
        cookies[stuff_tmp[0].substring(cookie_name.length)]=stuff_tmp[1];
      }
    }
    if(cookies.length==0)
    {
      cookies[0]="/";
    }
  }

  function change_menu()
  {
    dirNum=document.picture.dir.selectedIndex;
    dirName=document.picture.dir.options[dirNum].value;
    if (dirNum == null) return;
    parent.body.location.href='intro_'+dirName+'.html';
    document.picture.file.length=0;
    
    make_list(0);
  }

  function make_list(selected_pic)
  {
    document.picture.file.options[0]=new Option('','');
    for(var pic_i=1;pic_i<p[dirNum].length;pic_i++)
    {
      found=0;
      for(i=0;i<cookies.length;i++)
      {
        if(cookies[i].indexOf("/"+p[dirNum][pic_i][2]+"/")>=0)
        {
          found=1;
          break;
        }
      }
      if(found)
      {
        new_pic='  ';
      }
      else
      {
        new_pic='* ';
      }
      document.picture.file.options[pic_i]=new Option(new_pic+p[dirNum][pic_i][0],p[dirNum][pic_i][1]);
    }

    document.picture.file.options[selected_pic].selected=true;
  }

  function set_cookie()
  {
    found=0;
    for(cookie_num=0;cookie_num<cookies.length;cookie_num++)
    {
      if(cookies[cookie_num].indexOf("/"+p[dirNum][document.picture.file.selectedIndex][2]+"/")>=0)
      {
        found=1;
        break;
      }
    }
    if(!found)
    {
      if(cookies[--cookie_num].length>3992)
      {
        cookie_num++;
        cookies[cookie_num]="/";
      }
      cookies[cookie_num]+=p[dirNum][document.picture.file.selectedIndex][2]+"/";
      document.cookie=cookie_name+cookie_num+"="+cookies[cookie_num]+"; expires="+expire;
//      alert(document.cookie);
      make_list(document.picture.file.selectedIndex);
    }

  }

  function dir_menu()
  {
    with(document)
    {
      for (i=0;i<d.length;i++)
      {
        writeln('<OPTION VALUE='+d[i][1]+'>'+d[i][0]);
      }
    }
  }

  function check_pic()
  {
    if(!parent.body.the_pic.complete)
    {
      setTimeout("parent.menu.check_pic();",1000);
    }
    else
    {
      parent.menu.set_cookie();
    }
  }

