Christian: indexOf

Hallo, noch jemand wach wenn ja kann jemand mal über das Script schauen?

Mein erster Abschnitt sieht folgendermaßen aus:

function add_folder()
         {
         if(document.folder.folder_description.value=="")
            {
            alert("Please insert description.");
            document.folder.folder_description.focus();
            }
         else
            {
            var old_links = document.cookie;
            var count = old_links.substring(old_links.lastIndexOf(",dir")+4,old_links.lastIndexOf(",dir")+6);
            if(count == "") { count = "01"; }
            else
               {
               count = parseInt(count,10)
               if(count <= 8) { count = "0"+(count+1); }
               else { count = count+1; }
               }

if(old_links.indexOf(",") == false)
               {
               var new_folder = "dir"+count+":"+escape("'.$folder.'");
               }
            else
               {
               var new_folder = ",dir"+count+":"+escape("'.$folder.'");
               }

var new_description = ",des"+count+":"+escape(document.folder.folder_description.value)+",";

datum = new Date();
            einjahr = 1000*60*60*24*365;
            verfall = new Date(datum.getTime() + einjahr);

document.cookie = old_links+new_folder+new_description+"; expires=" + verfall.toGMTString();
            document.location.href = "bookmark.php?f='.urlencode($folder).'&sel='.$sel.'&pass='.$pass.'";

}
         }

Wenn das abgearbeitet ist habe ich einen Cookie mit folgendem Inhalt:

,dir01:g%3A,des01:Home,
127.0.0.1/Projekte/PHP%20Browser/brows/
1600
256098176
29596719
2534674272
29523293
*

Wenn ich nun mit diesem Script :

function add_url()
         {
         if(document.url.url_description.value=="")
            {
            alert("Please insert description.");
            document.url.url_description.focus();
            }
         else
            {
            var old_links = document.cookie;
            var count = old_links.substring(old_links.lastIndexOf(",url")+4,old_links.lastIndexOf(",url")+6);
//            document.write(count);
            if(count == "" || count == "r0") { count = "01"; }
            else
               {
               count = parseInt(count,10)
               if(count <= 8) { count = "0"+(count+1); }
               else { count = count+1; }
               }

if(old_links.indexOf(",") == false)
               {
               var new_url = "url"+count+":" + document.url.url.value;
               }
            else
               {
               var new_url = ",url"+count+":" + document.url.url.value;
               }

var new_description = ",ude"+count+":"+escape(document.url.url_description.value)+",";

datum = new Date();
            einjahr = 1000*60*60*24*365;
            verfall = new Date(datum.getTime() + einjahr);

document.cookie = old_links+new_url+new_description+"; expires=" + verfall.toGMTString();
            // document.location.href = "bookmark.php?f='.urlencode($folder).'&sel='.$sel.'&pass='.$pass.'";

}
         }

weitere Informationen in den Cookie einfügen will gibt mir die Variable count folgenden Wert aus : r0
Ich habe den Verdacht, daß indexOf nicht nach ",url" sucht sonder nur nach ",".