//
//
//    This script is Copyright Noetic Holdings - noeticweb@yahoo.ca
//              http://www.noeticholdings.com/
//    Please use it freely, but don't abuse the privilege, thank you.
//
//
//
common_words = "a about after against all almost also am an and another any are around as at b be because been before behind being both but by c came come comes could d did do does done e each either etc ever every example f few for from g go h had has have here how however i if ii iii in include included including into is it its iv ix j just k l m many may midst might my n nbsp neither never next no nor not now o of often on once or other others our over p put q r s same shall should since so some something sometimes soon such t than that the their them then there these they this those through to too toward u under underneath until us use used uses using usually v very vi vii viii w was we went were what when where whether which while who why with within without would x xi xii xiii xiv xix xv xvi xvii xviii xx y you your z";
//
   function extract() {
        var common_w = new Array();
        common_w = common_words.split(" ");
        common_w.sort();
        var full = " ";
        var fulls = " ";
        var found_all = new Array(1);
        var found_all_s = new Array(1);
        found_all[0] = "";
        found_all_s[0] = "";
        full = " ";
        fulls = " ";
//
        found_all.length = 1;
        found_all_s.length = 1;
        var full_1 = document.form1.in1.value;         //  retrieve raw data
        var full_2 = full_1;
//  remove html tags
     if (document.form1.htmltag.checked) {
            full_2 = full_1.replace(/<{1}[^>^<]+>{1}/g,'') }
        var full_3 = full_2;
     if (document.form1.lowercase.checked) {
          full_3 = full_2.toLowerCase(); }       //  switch to lowercase characters
        found_all = full_3.match(/[\w']+/g);  //  find all alphanumeric words, place in an array
        found_all.sort();                     //  sort these words in place
     if (document.form1.duplic.checked) {
        for (x=found_all.length-1;x>0;x--) { 
                if (found_all[x-1] == found_all[x]) {     //  remove duplicates
                       found_all.splice(x,1);
                       }
                document.form1.out1.value = found_all[x];
                }
        }
        y=common_w.length-1;
        for (x=found_all.length-1;x>-1;x--) {
           if (found_all[x].indexOf("'") != -1) {                 //  remove contracted words
                if (document.form1.contracted.checked) { found_all.splice(x,1); }
                }
           else {                                       //  remove common non-searchable words
            if (document.form1.comname.checked) {
             while (common_w[y] > found_all[x] && y > -1) { y--; }
             if (found_all[x] == common_w[y]) {
                       found_all.splice(x,1);
                       }
             }
            }
           document.form1.out1.value = found_all[x];
           }
         full = '<meta name="keywords" content="';
         full = full + found_all[0];                            // create list for display
         for (x=1;x<found_all.length;x++) { full = full + ", " + found_all[x];}
         full = full + '">';
         document.form1.out1.value = full;
     if (document.form1.plural.checked) {
         y = 0;
         for (x=0;x<found_all.length;x++) {
             n = found_all[x].substr(found_all[x].length-1,1);
             if ("sses" == found_all[x].substr(found_all[x].length-4,4)) {
                  found_all_s[y] = found_all[x].substring(0,found_all[x].length-2);
                }
             else if ("ss" == found_all[x].substr(found_all[x].length-2,2)) {
                  found_all_s[y] = found_all[x].substring(0,found_all[x].length) + "es";
                }
             else if ("ch" == found_all[x].substr(found_all[x].length-2,2)) {
                  found_all_s[y] = found_all[x].substring(0,found_all[x].length) + "es";
                }
             else if ("sh" == found_all[x].substr(found_all[x].length-2,2)) {
                  found_all_s[y] = found_all[x].substring(0,found_all[x].length) + "es";
                }
             else if ("xes" == found_all[x].substr(found_all[x].length-3,3)) {
                  found_all_s[y] = found_all[x].substring(0,found_all[x].length-2);
                }
             else if ("x" == found_all[x].substr(found_all[x].length-1,1)) {
                  found_all_s[y] = found_all[x].substring(0,found_all[x].length) + "es";
                }
             else if ("ies" == found_all[x].substr(found_all[x].length-3,3)) {
                  found_all_s[y] = found_all[x].substring(0,found_all[x].length-3) + "y";
                }
             else if ("ed" == found_all[x].substr(found_all[x].length-2,2)) {
                  y--;
                }
             else if ("ing" == found_all[x].substr(found_all[x].length-3,3)) {
                  y--;
                }
             else if ("1" == n || "2" == n || "3" == n || "4" == n || "5" == n || "6" == n || "7" == n || "8" == n || "9" == n || "0" == n) {
                  y--;
                }
             else if ("s" == found_all[x].substr(found_all[x].length-1,1)) {
                  found_all_s[y] = found_all[x].substring(0,found_all[x].length-1);
                }
             else {
                  found_all_s[y] = found_all[x].substring(0,found_all[x].length) + "s";
                }
             y++;
             }
           found_all_s.sort();
           y=found_all_s.length-1;                 // now remove duplicate entries in plural
           var flagfound = true;
           for (x=found_all.length-1;x>-1;x--) {
             while (found_all[x] < found_all_s[y] && flagfound) { if (y > 0) { y--; } else {flagfound = false} }
             if (found_all[x] == found_all_s[y]) {
                       found_all_s.splice(y,1);
                       if (y > 0) { y--;}
                       }
             }
           fulls = found_all_s[0];                            // create list for display
           for (y=1;y<found_all_s.length;y++) { fulls = fulls + ", " + found_all_s[y];}
           }
           document.form1.out2.value = fulls;
         }
//
      function resetme() {
         document.form1.in1.value= "";
         document.form1.out1.value= "";
         document.form1.out2.value= "";
         document.form1.in1.focus();
         }
//
      function show_common() {
         common = window.open('','common','screenX=40,left=40,screenY=60,top=60,width=700,height=400,resizable,scrollbars');
         with (common) {
              document.open();
              document.write('<!doctype html public "-//w3c//dtd html 4.0 transitional//en">');
              document.write('<html><head>');
              document.write('<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">');
              document.write('<title>Common Words not included in results</title>');
              document.write('</head>');
              document.write('<BODY bgcolor="#000000" text="#CCCC00" link="#009900" vlink="#666600" alink="#FF6666">');
              document.write('<font color="#CCCCCC">The Following Common Words are NOT included in the resulting list:</font><p>');
              document.write(common_words);
              document.write('<p><font color="#CCCCCC">Be certain that you do not need any of these words as keywords.</font>');
              document.write('</body></html>');
              document.close();
          }
         common.focus();
         }
//
//
      function show_plural() {
         common = window.open('','common','screenX=40,left=40,screenY=60,top=60,width=700,height=400,resizable,scrollbars');
         with (common) {
              document.open();
              document.write('<!doctype html public "-//w3c//dtd html 4.0 transitional//en">');
              document.write('<html><head>');
              document.write('<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">');
              document.write('<title>Plurals and Singulars</title>');
              document.write('</head>');
              document.write('<BODY bgcolor="#000000" text="#CCCC00" link="#009900" vlink="#666600" alink="#FF6666">');
              document.write('The rules for creating plural and singular words are complicated and there are many exceptions to the rule.&nbsp; For simplicity, we did not try to account for every possible situation.');
              document.write('<p>Words are pluralized usually by adding s to any word not ending in s.');
              document.write('<p>Words are singularized by removing the s from the end of words ending in s.');
              document.write('<p>Obviously, many of the words that get created by this method will not be REAL words at all, so please be careful if you choose to use this option.');
              document.write('</body></html>');
              document.close();
          }
         common.focus();
         }
//
//
      function show_html() {
         common = window.open('','common','screenX=40,left=40,screenY=60,top=60,width=700,height=400,resizable,scrollbars');
         with (common) {
              document.open();
              document.write('<!doctype html public "-//w3c//dtd html 4.0 transitional//en">');
              document.write('<html><head>');
              document.write('<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">');
              document.write('<title>Common Words not included in results</title>');
              document.write('</head>');
              document.write('<BODY bgcolor="#000000" text="#CCCC00" link="#009900" vlink="#666600" alink="#FF6666">');
              document.write('HTML tags are removed by searching for the start and end tags (namely < and >) and removing all characters between those two tags.');
              document.write('<p>This has potential problems if you use the "less than" or "greater than" symbols within the text of your web page.');
              document.write('<p>You may not want to use this option if you use < or > symbols.');
              document.write('</body></html>');
              document.close();
          }
         common.focus();
         }
//
