html.anubis 76.6 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418

 *Project*                            The Anubis Project
 *Title*                         Producing HTML/Javascript code. 

 *Copyright*                    Copyright (c) Alain Prouté 2001. 
 
read tools/basis.anubis
read tools/printable_tree.anubis   
read system/string.anubis



   *** Managing Web Arguments.

   When a client submits a form, he  sends informations to the server. This information is
   transformed by the server into a list of data of type 'Web_arg'. This is the reason why
   a 'web page' operation always has a unique argument of type 'List(Web_arg)'.

   The type 'Web_arg' is defined in 'web/common.anubis' as follows:
     
         public type Web_arg:
           web_arg(String name, 
                   String value),
           upload (String name, 
                   String value, 
                   String temp_file_path). 

read web/common.anubis   
   
   In other words, a  'web argument' is just a pair made of the  name of the argument, and
   the value of  the argument, and both are character strings.  'upload' will be explained
   later.


   The next variable is a multipurpose counter (used to generate unique names). 
   
variable Word32 web_count = 0.

define Word32
  new_web_count 
    =
  web_count <- *web_count+1; 
  *web_count. 
   

   Names for Web colors.
   
public type Web_color_name:
  aliceblue,
  antiquewhite1,
  antiquewhite2,
  antiquewhite3,
  antiquewhite4,
  aquamarine1,
  aquamarine2,
  aquamarine3,
  aquamarine4,
  azure1,
  azure2,
  azure3,
  azure4,
  yellow. 


  and so on ...  (see below why I did not do more).



   Web colors.
   
public type Web_color:
  rgb(Word32,Word32,Word32),    /* give the color by its components */ 
  _(Web_color_name).            /* or by its name */ 


   
   
   The following produces '<meta>' tags, which are put in the head of the document. 
   
public type WebMeta:
  keywords(List(String)), 
  refresh(String url, Word32 delay),                // in seconds
  meta(String name, String content),
  http_equiv(String name, String content), 
  encoding(String). 
   
   
   
   
   
                *******************************************************
                *                      Web items                      *
                *   (the many kinds of things one may put in a page)  *
                *******************************************************

   
public type Web_item:
  [ ],           /* empty (invisible) item */
  ... this is a cross recursive type. 


   
  
   Options for web page body.
   
public type LayerDisposition:
  horizontal, 
  vertical.
   
public type FollowPathCommand:    // this type is used by the Web_body_option 'follow_path'. 
  pos(Word32 x,                    // x coordinate of position
      Word32 y,                    // y coordinate of position
      Word32 image_number,         // the image to display at that position
      Word32 delay).               // wait that milliseconds before leaving this position
      
public type Web_body_option:
  background_color(Web_color),               /* color for the background */
   //
   // 'psychedelic_background' produces a background color which is continuously changing.
   // 'average' is the average luminosity of the color. 'amplitude' is the maximal variation 
   // the luminosity around the average. 'delay' is the number of milliseconds between two
   // color changes. For example, you may try 'psychedelic_background(200,50,1000)', which
   // produces a background whose color changes very slowly (this is not tiring) among rather
   // light pastel colors. 
   //
  psychedelic_background(Word32 average,      /* average light (0 to 255) */
                         Word32 amplitude,    /* amplitude of variation of light */
                         Word32 delay),       /* in milliseconds */
  background_image(String file_name),        /* name of image file for the background */
   //
   // 'scrolling_layer' produces a layer above the page which is scrolling continuously either
   // vertically or horizontally. The 'content' is indefinitly repeated. 
   //
  scrolling_layer(LayerDisposition,       
                  Word32 steps,               /* number of pixels of each move */ 
                  Word32 margin,              /* measured from left or top in pixels */ 
                  Word32 delay,               /* milliseconds for one move */
                  Web_item content,          /* content of layer (will be repeated) */ 
                  Word32 period),             /* number of pixels between two instances of 'content' */ 
   //
   // 'bounce' shows its content above the page and let it move and bounce on the edges of a rectangle.
   // The rectangle is determined by the last 4 arguments. 
   //
  bounce(Web_item content,
         Word32 left,
         Word32 right,
         Word32 top,
         Word32 bottom),
   //
   // put something over the page in any position you want:
   //
  over(Web_item content, 
       Word32 left,
       Word32 top), 
   //
   // follow_path: let a changing image follow a path on the screen. This gadget shows
   //   an image following a polygonal path on the screen. The image may change at regular
   //   intervals, thus providing extra animation. The images are displayed in the order
   //   they are given in the first argument. When the last image has been displayed, the
   //   first image is displayed again, and so on. The path is a sequence of absolute positions
   //   on screen (actually in the browser's window or frame), which is followed in the 
   //   order given in the 'path' argument. If 'loop' is true, the path is followed again and again. 
   //   Otherwise, it is followed only once. If you want to make a closed loop, the last
   //   position must be the same as the first one. 'steps' is the number of pixels of distance
   //   between two successive positions of the image, and 'delay' the number of milliseconds
   //   between two successive positions. 'change_every' is the number of steps (a 'step' is
   //   passing from one position to the next one) after which the displayed image is replaced
   //   by the next image. 
   //
   //   Each position 'pos(x,y,i,d)' has 4 parameters. 'x' and 'y' are the coordinates of the
   //   position in the browser's window or frame. 'i' is the number of the image to display
   //   at this position (i.e. the rank of the image in the list 'filename'. The first one has
   //   rank 0). 'd' is the delay in milliseconds to wait before leaving that position. 
   //
  follow_path(List(String) filenames,     /* the changing images which follows the path */ 
              Word32 change_every,         /* number of steps betwen two changes */ 
              List(FollowPathCommand) path,       /* the polygonal path and commands */ 
              Bool loop,                  /* if true do it repeatedly, otherwise only once */ 
              Word32 steps,                /* approximative distance (in pixels) between two 
                                               successive positions */ 
              Word32 delay),               /* milliseconds between two successive positions */ 
   
  load_image(String name),                /* load an image (for next page), which is not displayed */ 
  left_margin(Word32),                     /* left margin for document */ 
  top_margin(Word32),                      /* top margin for document */ 
  margin_width(Word32), 
  margin_height(Word32), 
  reload_frame(String name,       /* name of target frame */
               String url),       /* url to load in this frame */ 
  onload(String function_name).    /* nom de la fonction javascript (sans les '()') */

public type BodyOnload:
  reload_frame(String name, String url). 
   
variable List(BodyOnload) body_onloads = [ ]. 

define One
  add_body_onload
    (
      BodyOnload item
    ) =
  body_onloads <- [item . *body_onloads]. 
   
define Printable_tree
  format
    (
      BodyOnload item
    ) =
  if item is 
    {
      reload_frame(name,url) then (Printable_tree)
        [ " window.open('",url,"','",name,"');" ]
    }.
   
define Printable_tree
  format
    (
      List(BodyOnload) l
    ) =
  if l is 
    {
      [ ] then (Printable_tree)[ ], 
      [h . t] then (Printable_tree)
        [format(h) . format(t)]
    }.
   

---- Body of a web page. --------------------------------------------
public type Page_body:  
  body(List(Web_body_option),   /* list of body options */
       Web_item content).       /* the content of the page */ 


public type VFrame:
 frame(Word32 height, 
       Printable_tree url,
       String name). 
   
---- Web pages. -----------------------------------------------------
public type Web_page: 
  web_page(String title,             /* title appearing on top of browser */
           List(WebMeta) meta_tags,
           Printable_tree  head_scripts, /* scripts à placer dans la balise head */
           Page_body body),          /* body of page */ 
  standard_frameset(String title,
                    List(WebMeta) meta_tags, 
                    Word32 height,             /* height of 'top menu' (pixels) */ 
                    Word32 width,              /* width of 'left menu' (pixels) */ 
                    Printable_tree main).     /* url for main */ 

   +---------+--------------------------+
   |         |                ^         |
   |<-width->|      top     height      |
   |         |                v         |
   | left    +--------------------------+
   |         |                          |
   |         |     main                 |
   |         |                          |
   |         |                          |
   |         |                          |
   +---------+--------------------------+
   
   Note: top and left frames must be loaded through the Web_body_option 'reload_frame'. 
   

public define Web_page
  web_page
    (
      String title, 
      Page_body body
    ) =
  web_page(title,[],[], body). 

public define Web_page
 web_page
   (
    String          title,
    List(WebMeta)   meta_tags,
    Page_body       body
   ) =

 web_page(title, meta_tags, [], body).

 public define Web_page
web_page
  (
   String         title,
   Printable_tree head_scripts,
   Page_body      body
  ) =

  web_page(title, [], head_scripts, body).

public define Web_page
standard_frameset
    (
      String title,
      Word32 height, 
      Word32 width,  
      Printable_tree main
    ) =

 standard_frameset(title, [], height, width, main).
   
   
variable Printable_tree scripts = []. 
   
define One
  add_script
    (
      Printable_tree script
    ) =
  scripts <- [*scripts . script]. 
   
   
   
   ---- Non empty web items. -------------------------------------------

   We have already seen the empty web item. Together with the following one, it enables to
   make (pseudo-)lists  of web items,  which will be  presented one after the  other (from
   left to right) in the browser's window.

public type Web_item:
  [Web_item . Web_item],...


   A web item may be a simple string or a simple integer:

public type Web_item:
  text(String),          
  text_pt(Printable_tree), 
  text_nowrap(String),          
  text_nowrap_pt(Printable_tree), 
  par(String),
  preformated_text(String text), 
  integer(Word32),
  float(Float,Word32),...


   You may want to center a web item in a page. Just enclose it into
   'center(...)': 

public type Web_item:
  center(Web_item),...


   You may want to write characters of a given item with a big font:

public type Web_item:
  bigger(Word32,Web_item), 
  smaller(Word32,Web_item), 
  bold(Web_item),
  italic(Web_item), 
  big(Web_item),
  very_big(Web_item),...

   
   Most of the previous are subsumed by 'style':
   
public type WebStyle:
  background_image(String file_name),
  background_color(Web_color color), 
  background_transparent, 
  background_repeat_horizontal,    // repeat the background image only horizontally
  background_repeat_vertical,
  background_no_repeat, 
  color(Web_color color), 
  float_to_left,      // the web item will float to the left and text will wrap around 
  float_to_right,
  font_family(String font_name),   // "verdana" "helvetica" "times" etc...
  font_size(Word32 size), 
  italic,
  oblique,
  small_capitals, 
  bold, 
  bolder,
  lighter,
  line_height(Word32 height),
  text_center,
  text_left,
  text_right,
  text_justify,
  text_underline,
  text_blink,
  text_line_through,
  width(Word32 n).
   
  
   
public type Web_item:
  style(List(WebStyle) styles, Web_item content),...
   
   
public type Web_item:
  spacer(Word32 width, Word32 height), 
  image(String file_name),              /* image */ 
  image_d(String file_name, String description), 
  image_pt(Printable_tree file_name),
  on_image(String file_name, Web_item content),
  turning_images(NonEmptyList(String) filenames, Word32 millisecs),...
   
   
   
   A 'rollover' has  the same role as a submit  button or link, but it  is prettier. It is
   made of two images.  The first one  'image_on' determines the aspect of the button when
   the mouse  cursor is on  it.  The  other one 'image_off'  determines the aspect  of the
   button when  the mouse cursor is  anywhere else. The two  images should be  of the same
   size, otherwise bad  effects may occur. The last operand 'description'  is a small text
   which describes the role of the button. It appears in a bubble in the browser's window.
   
public type Web_item:   
  rollover(List(String) preload_images,   // images to preload before the rollover is effective
           String url,                    // URL with possible web arguments
           String target, 
           String image_on,               // file name of 'highlighted' image 
           String image_off,              // file name of 'non highlighted' image
           String description),           // short behavior description
  rollover(List(String) preload_images, 
           String url,    
           String target,        
           String image_on,         
           String image_off,        
           Word32 width, 
           Word32 height, 
           String description), ... 
   

   Mouse  sensitive images  are images  with predefined  zones which  are  clickable. When
   clicking in a  zone, the specified corresponding  URL is loaded by the  browser. If two
   zones overlap, the first one (in the order they are defined) is selected.
   
   Zones  are of  3  sorts: rectangles,  circles  and polygons.   Point's coordinates  are
   specified as  pairs of  integers (of anonymous  agglomeration type  (Word32,Word32)). The
   first coordinate counts pixels from the left of the image. The second coordinate counts
   pixels from  the top of the  image.  With polygons,  you can construct zones  which are
   almost as complicated as you want. You  may also construct a zone as the overlapping of
   several zones with the same URL.
   
public type Mouse_Sensitive_Zone:
  rectangle  
    (   
      (Word32,Word32) left_top, 
      (Word32,Word32) right_bottom,
      String url
    ),
  circle     
    (   
      (Word32,Word32) center,
      Word32 radius,
      String url
    ),
  polygon
    (   
      List((Word32,Word32)) vertices,
      String url
    ). 
   
public type Web_item:
  mouse_sensitive_image(String image_file_name,       // the image itself
                        List(Mouse_Sensitive_Zone) zones),...


   In project: mouse  sensitive images, whose zones behave like  submission buttons (to be
   used within a form).
   
   
public type Web_item:
  background_sound(String sound_file_name, 
                   Bool loop),...
   
   

                        *************************
                        *         FORMS         *
                        *************************


   Use 'forms' in  order to get informations back from the  client. The constructor 'form'
   take 2 arguments:

    - the name of the form, which must be the name of an Anubis web
      page. Indeed, when the user will submit the form, this page will
      be sent to him. 
    - the content of the form, which may be any web item, but which
      normally (amongh other things) contains input fields and a
      submit button.  

public type Web_item:
  form(Printable_tree  name,
       Web_item  content),
  form_target(Printable_tree name,
       Web_item content,
       String target),
  form(Printable_tree  name, 
       String label_name,
       Web_item  content),
  form_name(String          form_name,  // option name de form
            Web_item  content),...

 public define Web_item
form
 (
  Printable_tree  name,
  Web_item        content
 ) =

 form("", name, content).

   Within a form, you may put 'text input fields', that the client may
   edit. The constructor 'text_input' has the following arguments: 

    - name of input field. This will be the name of the correponding
      web argument in the Anubis web page referred to by the form. 
    - size of field (as it appears on client screen), 
    - initial value of field (the text that appears in the field, when
      the client downloads the page). 


 public type Text_Input_Option

public type Web_item:
  text_input(String name,           /* text field to be documented by user */
             Word32 size,
             String initial_value),...

 public define Web_item
 text_input
  (
   String   name,
   Word32    size,
   String   initial_value
  ) =


 text_input( (List(Text_Input_Option)) [], name, size, initial_value).


public type Web_item:
  password_input(String name,
                 Word32 size),
  text_area(String name,
            Word32 columns, 
            Word32 rows,
            String initial_text), 
  upload(String name, Word32 size),...




public type Web_item:
  submit(String button_text),        /* submit button with text on it */
  submit_pt(Printable_tree button_text),
  submit(String name, String text),
  submit_close(String name, String text), 
  submit_pt2(String name, Printable_tree text),
  image_submit(String name, String image_file_name),
  image_submit(String name, String value, String image_file, Web_item content),
  hl_image_submit(String action_name, 
                  String value, 
                  String image_name, 
                  String image_file, 
                  String hl_image_file), 
  text_submit(String name, String value, String text),
  web_submit(String web_args, Web_item content),
  button(String name, String text, String on_click_fonction, Word32 width, Word32 height),...


public type Web_item:                         /* mark the form with an information */ 
  mark(String name, String value),
  mark_pt(String name, Printable_tree value),...

public type Web_item:
  close_button,                               /* button that closes the window */ 
  close_button(String image_file_name), ...
   
   
   
                      *********************************
                      *            LABELS             *
                      *********************************
   
   
   A 'label'  is just  a name  that you may  give to  a position in  a document.   Use the
   following invisible  Web_item 'label' to this end.   Now, you can also  create links in
   the same document,  which, when clicked by  the user, scroll the document,  so that the
   position  whose name is  the given  label is  shown just  at the  top of  the browser's
   window.
   
public type Web_item:
  label(String label_name),       /* give a name to a position in the page */ 
  go_to_label(String label_name,  /* a link for jumping to a label */ 
              Web_item content),...



                     ********************************
                     *           TABLES             *
                     ********************************


   A web item may be a table. A table is produced by the constructor
   'table' from the type 'Web_item'. This constructor takes 2
   arguments: 

    - a list of 'table options', 
    - a list of 'table rows'. 

   Of course, you use as many options as you want, including
   none (if you do not want any option, put the empty list '[ ]' as
   this argument). Some options have precedence over others. For example
   a background image will hide the background color. 

   Table options are defined below:

public type Table_option:

      /* use a color as a background for the table, if you want it to
      be different from the background of the page */ 
   background_color(Web_color),   

      /* or use an image as the background of the table */
   background_image(String file_name),

      /* draw a border line around the table (and around each cell in
      the table). You may also specify a geometry (in pixels) for the
      border. This makes the 'in relief' part of the border appear
      more or less wide. You may also specify a color for the border. */
   border,
   nude,           /* equivalent to 'border(0,0,0)' (below) */ 
   border(Word32,   /* width of exterior (pixels) */ 
          Word32,   /* width of top */
          Word32),  /* width of interior */
   border_color(Web_color),
   absolute_width(Word32). 



   A 'table row' is made of a list of 'row options', and a list of
   'cells'. A 'cell' itself has a list of 'cell options', and a web item,
   which is its content. We begin by the description of options. 


public type Row_option:
     /* following concerns the horizontal positions of items within the
     cells of the row */
   left,
   h_center,
   right, 
     /* the following concerns the vertical positions of items, within
     the cells of the row */
   top,
   v_center,
   bottom,
   absolute_height(Word32), 
   base_line,
     /* set the background color of all cells in the row */ 
   background_color(Web_color).



public type Cell_option:
     /* all row options are available for individual cells, and apply
     here only to one cell. */ 
   left,   
   h_center,
   right, 
   top,
   v_center,
   bottom,
   base_line,
   background_color(Web_color),  
     /* you can set the width of the cell either absolutely (in pixels)
     or as a percentage of the width of the table. */ 
   background_image(String file_name),
   absolute_width(Word32),
   relative_width(Word32),
   absolute_height(Word32),
   relative_height(Word32),
     /* a cell may span over several columns or rows in the table */
   columns(Word32),
   rows(Word32),
   nowrap.


public type Cell:
   cell(List(Cell_option),
        Web_item). 

public type Table_row:
   row(List(Row_option),
       List(Cell)). 
   
public define Table_row row(Web_item i)     = row([],[cell([],i)]). 
public define Table_row row(Cell c)         = row([],[c]). 
public define Table_row row(List(Cell) l)   = row([],l). 
   

public type Web_item:
  table(List(Table_option),
        List(Table_row)),...

public type Web_item: 
  list(List(Web_item)),...

public type Web_item:
  link(String name, Web_item),
  link(String name, String target, Web_item),...

public type Web_item:
  link_for_download(String filename, Web_item),...    // the filename is relative to the public directory
   
public type Web_item:
  mail_to(String addr, Web_item),...


public type Web_item:
  select(String name, 
         Word32 size, 
         List(String) choices),
  select(String name,
         Word32 size,
         List(String) choices,
         String selected),
  immediate_select(String name,         // selection will immediately submit the form 
                   Word32 size,
                   List(String) choices),...


public type Web_item:
  radio_button           (Printable_tree name, String value),
  checked_radio_button   (Printable_tree name, String value),
  check_box              (Printable_tree name, String value),
  checked_box            (Printable_tree name, String value),...


public type Web_item:
  link_to_window(Printable_tree name, Web_item),
  link_to_window(Printable_tree name, String window_name, Web_item),
  link_to_window_with_ticket(String name, 
                             String web_args, 
                             String window_name, 
                             Web_item content,
                             Word32 width, 
                             Word32 height), 
  link_to_window_with_ticket_and_scroll
                            (String name, 
                             String web_args, 
                             String window_name, 
                             Web_item content,
                             Word32 width, 
                             Word32 height), 
  link_to_window_with_ticket_and_scroll
                            (String name, 
                             String label_name, 
                             String web_args, 
                             String window_name,
                             Web_item content,
                             Word32 width, 
                             Word32 height), 
  link_to_frame (Printable_tree name, String frame_name, Web_item). 
  


---- Formating operations (Anubis --> HTML/Javascript) --------------------------- 

   Stupid operation formating a web color name. 

public define String 
  format
    (
      Web_color_name n
    ) =
 if n is
  {
    aliceblue        then   "aliceblue",
    antiquewhite1    then   "antiquewhite1",
    antiquewhite2    then   "antiquewhite2",
    antiquewhite3    then   "antiquewhite3",
    antiquewhite4    then   "antiquewhite4",
    aquamarine1      then   "aquamarine1",
    aquamarine2      then   "aquamarine2",
    aquamarine3      then   "aquamarine3",
    aquamarine4      then   "aquamarine4",
    azure1           then   "azure1",
    azure2           then   "azure2",
    azure3           then   "azure3",
    azure4           then   "azure4",
    yellow           then   "yellow",
  }. 

   Anubis really needs some system of 'macros' to avoid this...


   Formating a web color. 
   
define String
   hexadecimal
     (
       Word32  x, 
       Int     digits
     ) =
   if x is word32(l,_) then 
   if l is word16(y,_) then
   to_hexa(y). 
   
   
public define String
  format
    (
      Web_color wc
    ) =
  if wc is
    {
      rgb(r,g,b) then "\"#" + hexadecimal(r,2) + hexadecimal(g,2) + hexadecimal(b,2) + "\"",          
      _(c) then format(c) 
    }. 

public define String
  format_without_quotes
    (
      Web_color wc
    ) =
  if wc is
    {
      rgb(r,g,b) then "#" + hexadecimal(r,2) + hexadecimal(g,2) + hexadecimal(b,2) + "",          
      _(c) then format(c) 
    }. 

define Printable_tree
  format
    (
      Web_color c
    ) = [(String)format(c)]. 

public define String
  format_without_sharp
    (
      Web_color wc
    ) =
  if wc is
    {
      rgb(r,g,b) then "" + hexadecimal(r,2) + hexadecimal(g,2) + hexadecimal(b,2) + "",          
      _(c) then format(c) 
    }. 

define Printable_tree
  format_without_sharp
    (
      Web_color c
    ) = [(String)format_without_sharp(c)]. 


 define Printable_tree
   [Word32 x . Printable_tree t]
     =
   [to_Int(x) . t].
   
define Printable_tree
  psychedelic_bg
    (
      Word32 average,
      Word32 amplitude,
      Word32 delay
    ) =
  with ampl = if amplitude >=- 120 then 120 else 
              if amplitude -=< 1 then 1 else amplitude, 
  with aver = if average+ampl >=- 254 then 254-ampl 
              else if average-ampl -=< 1 then 1+ampl else average,
  [ "<script>",
    " var psy_t = 0;",
    " function do_psy_bg() { psy_t += 0.05;",
    "   document.bgColor = '#' + ",
    "  (Math.round(",aver,"+",ampl,"*Math.cos(psy_t))).toString(16) + ",
    "  (Math.round(",aver,"+",ampl,"*Math.sin(psy_t))).toString(16) + ",
    "  (Math.round(",aver,"-",ampl,"*Math.cos(2*psy_t))).toString(16); ",
    " setTimeout(\"do_psy_bg()\",",to_Int(delay),"); }",
    " setTimeout(\"do_psy_bg()\",1000);", 
    "</script>"].

   
define List(Web_body_option)
  replace_background_init
    (
      List(Web_body_option) l,
      Word32 average,
      Word32 amplitude,
      Word32 delay
    ) = 
  if l is 
    {
      [ ] then [ ], 
      [h . t] then 
        if h is background_color(_) 
        then [background_color(rgb(average+amplitude,
                                   average,
                                   average-amplitude)) 
              . replace_background_init(t,average,amplitude,delay)]
        else [h . replace_background_init(t,average,amplitude,delay)]
    }.
   
define Maybe((Word32,Word32,Word32))   
  get_psy
    (
      List(Web_body_option) l
    ) = 
  if l is 
    {
      [ ] then failure, 
      [h . t] then 
        if h is psychedelic_background(a,f,d) 
        then success((a,f,d)) 
        else get_psy(t)
    }.
   
define List(Web_body_option)
  prepare
    (
      List(Web_body_option) l
    ) =
  if get_psy(l) is 
    {
      failure then l, 
      success(op) then if op is (a,f,d) then 
        replace_background_init(l,a,f,d)
    }.
   
   
public define Printable_tree
  format
    (
      String c_ticket, 
      String s_ticket,
      Web_item i
    ).   
      
define Printable_tree
  move_layer_command
    (
      String property,
      Word32 n,
      Word32 num,
      Word32 i,
      Word32 period
    ) =
  if i >=- num then [ ] else
  [" if (document.layers)",
   " { document.nslay",n,"_",i,".",property,"=layp",n,"+(",((i-1)),"); } ",
   " else ",
   " { ielay",n,"_",i,".style.",property,"=layp",n,"+(",(i-1)*period,"); } "
   . move_layer_command(property,n,num,i+1,period)].
   
define Printable_tree
  format_layers
    (
      LayerDisposition disp,
      Word32 margin,
      Web_item content,
      Word32 n, 
      Word32 num,
      Word32 i,
      Word32 period
    ) =
  if i >=- num then [ ] else
  ["<layer name=\"nslay",n,"_",i,"\" top=0",
                           " left=0", ">",
    "<div id=ielay",n,"_",i," style=\"position:absolute;top:",
             if disp is vertical then (i-1)*period else margin,
             "px;left:",
             if disp is vertical then margin else (i-1)*period,
             "px\">",
       format("","",content),
   "</div></layer>" . format_layers(disp,margin,content,n,num,i+1,period)]. 
     
define Printable_tree
  s_layer
    (
      LayerDisposition disp,
      Word32 steps,
      Word32 margin,
      Word32 delay, 
      Web_item content,
      Word32 period,
      Word32 num
    ) =
  with n = new_web_count, 
  [ "<script>",
    " var layp",n," = 0;", 
    " function scroll_layer",n,"() {",
    " layp",n,"+=(",steps,"); if (layp",n," ",if steps >- 0 then ">" else "<",
             "= ",if steps >- 0 then period else 0,
             ")   layp",n," = ",if steps >- 0 then 0 else period,";",
    move_layer_command(if disp is vertical then "top" else "left",n,num,0,period),   
    " setTimeout(\"scroll_layer",n,"()\",",delay,");",
    " }",
    " setTimeout(\"scroll_layer",n,"()\",1000);",
    "</script>",
    format_layers(disp,margin,content,n,num,0,period),   
    ].
   
      
define Printable_tree
  over
    (
      Web_item i,
      Word32 left, 
      Word32 top
    ) =
  with n = new_web_count, 
  [ "<layer name=\"nslay",n,"\" top=",top," left=",left,">",
    " <div id=\"ielay",n,"\" style=\"position:absolute;top=",top,"px;left=",left,"px\">",
    format("","",i),
    "</div></layer>"
    ]. 
   
define Printable_tree
  bnce
    (
      Web_item i,
      Word32 left, 
      Word32 right,
      Word32 top,
      Word32 bottom
    ) =
  with n = new_web_count, 
  [ "<script>",
    "  var bncx",n," = ",left,"; var bncy",n," = ",top,"; var bncdx",n," = 1; var bncdy",n," = 1;", 
    " function do_bnc",n,"() {",
    "   if (bncx",n," >= (",right,") || bncx",n," < ",left,") bncdx",n," = -bncdx",n,";", 
    "   if (bncy",n," >= (",bottom,") || bncy",n," < ",top,") bncdy",n," = -bncdy",n,";", 
    "   bncx",n," += bncdx",n,"; bncy",n," += bncdy",n,";", 
    "   if (document.layers)",
    "     { document.nslay",n,".left = bncx",n,"; document.nslay",n,".top = bncy",n,"; } else",
    "     { ielay",n,".style.left = bncx",n,"; ielay",n,".style.top = bncy",n,"; }",
    " setTimeout(\"do_bnc",n,"()\",40); }", 
    " setTimeout(\"do_bnc",n,"()\",1000);",
    "</script>",
    "<layer name=\"nslay",n,"\" top=",top," left=",left,">",
    " <div id=\"ielay",n,"\" style=\"position:absolute;top=",top,"px;left=",left,"px\">",
    format("","",i),
    "</div></layer>"
    ]. 
   
   
define Printable_tree
  folp_switch
    (
      Word32 n, 
      Word32 i, 
      List(FollowPathCommand) path, 
      Bool loop,
      Word32 steps
    ) =
  if path is 
    {
      [ ] then [ ], 
      [p0 . t0] then if p0 is pos(x0,y0,i0,d0) then 
        if t0 is 
          {
            [ ] then if loop
                then ["        default: ",
          "            folpx",n,"=",x0,"; folpy",n,"=",y0,"; ", 
          "            folpseg",n,"=0; ",
          "            folpwait",n,"=",d0,";", 
          "   if(document.layers)",
          "        document.nslay",n,".document.folpim",n,".src=folpimages",n,"[",i0,"].src;", 
          "   else document.folpim",n,".src=folpimages",n,"[",i0,"].src;", 
          "            folpstpmax",n," = 0;",
          "            folpstp",n,"=0;", 
          "            folpdx",n,"=0; ",
          "            folpdy",n,"=0; ",                       
                      "        break;"]
                else ["        default: folpend",n,"=1; break; "], 
            [p1 . t1] then if p1 is pos(x1,y1,i1,d1) then
        [ "          case ",i,": ",
          "            folpx",n,"=",x0,"; folpy",n,"=",y0,"; ", 
          "            folpseg",n,"=",i+1,"; ",
          "            folpwait",n,"=",d0,";", 
          "   if(document.layers)",
          "        document.nslay",n,".document.folpim",n,".src=folpimages",n,"[",i0,"].src;", 
          "   else document.folpim",n,".src=folpimages",n,"[",i0,"].src;", 
          "            folpstpmax",n," = ",
    "Math.round(Math.sqrt(Math.pow(",x1,"-",x0,",2)+Math.pow(",y1,"-",y0,",2))/",steps,");",
          "            folpstp",n,"=0;", 
          "            folpdx",n,"=((",x1,"-",x0,")/folpstpmax",n,"); ",
          "            folpdy",n,"=((",y1,"-",y0,")/folpstpmax",n,"); ", 
          "            break; " 
        . folp_switch(n,i+1,t0,loop,steps) ]
    }}. 
      
define Printable_tree
  set_folpimages
    (
      Word32 n, 
      List(String) filenames,
      Word32 i, 
    ) = 
  if filenames is 
    {
      [ ] then [ ], 
      [h . t] then 
        [ " folpimages",n,"[",i,"].src=\"",h,"\";" 
        . set_folpimages(n,t,i+1)]
    }. 
   
define Printable_tree
  follow_path
    (
      List(String) filenames, 
      Word32 change_every, 
      List(FollowPathCommand) path, 
      Bool loop, 
      Word32 steps,
      Word32 delay
    ) =
  if filenames is 
    {
      [ ] then (print("Error in usage of 'follow_path': 'filenames' must be non empty."); []), 
      [im1 . other_ims] then 
  if steps -< 1 then (print("Error in usage of 'follow_path': 'step' must be >= 1."); [ ]) else
  if path is 
    {
      [ ] then [ ], 
      [p0 . t0] then if p0 is pos(x0,y0,i0,d0) then 
        if t0 is 
          { 
            [ ] then 
              (print("Error in usage of 'follow_path': 'path' must have at least 2 positions."); []),
            [p1 . t1] then if p1 is pos(x1,y1,i1,d1) then  
        with n = new_web_count, 
       [ 
         "<layer name=\"nslay",n,"\" top=",y0," left=",x0,">",
         "<div id=\"ielay",n,"\" style=\"position:absolute;top=",y0,"px;left=",x0,"px\">",
         "<img src=\"",im1,"\" name=\"folpim",n,"\" border=0>",
         "</div></layer>",
         "<script>",
         "  var folpimages",n,"=new Array(",length(filenames),");", 
         "  var folpcurim",n,"=0;", 
         "  var folpx",n," = ",x0,";", 
         "  var folpy",n," = ",y0,";", 
         "  var folpseg",n," = 1;", 
         "  var folpstpmax",n," = ",
   "Math.round(Math.sqrt(Math.pow(",x1,"-",x0,",2)+Math.pow(",y1,"-",y0,",2))/",steps,");", 
         "  var folpdx",n,"=((",x1,"-",x0,")/folpstpmax",n,"); ",
         "  var folpdy",n,"=((",y1,"-",y0,")/folpstpmax",n,"); ", 
         "  var folpstp",n," = 0;", 
         "  var folpchgcnt",n," = 0;", 
         "  var folpwait",n,"=",d0,";",
         "  var folpend",n,"=0;", 
         "  for(var i = 0; i<",length(filenames),"; i++) {",
         "    folpimages",n,"[i]=new Image(); }", 
         set_folpimages(n,filenames,0), 
         "  function dofolp",n,"() {", 
         "    if (folpstp",n," >= folpstpmax",n,")",
         "      { switch(folpseg",n,") {",
         folp_switch(n,0,path,loop,steps),
         "      }} else { folpstp",n,"++; folpx",n," += folpdx",n,"; folpy",n," += folpdy",n,"; };", 
         "  if (document.layers)",
         "  { document.nslay",n,".left=folpx",n,"; document.nslay",n,".top=folpy",n,"; } else",
         "  { ielay",n,".style.left=folpx",n,"; ielay",n,".style.top=folpy",n,"; };",
   
         //--- change image if needed:
         if change_every = 0 then [ ] else 
         if length(filenames) =< 1 then [ ] else
         ["  if (folpchgcnt",n,"==",change_every,") ",
          "    { ", 
          "      folpchgcnt",n,"=0;",
          "      folpcurim",n,"++;", 
          "      if (folpcurim",n,"==",length(filenames),") folpcurim",n,"=0;", 
          "  if (document.layers) ",
          "       document.nslay",n,".document.folpim",n,".src=folpimages",n,"[folpcurim",n,"].src;",
          "  else document.folpim",n,".src=folpimages",n,"[folpcurim",n,"].src;",
          "    }",
          "    else { folpchgcnt",n,"++; };"],
   
         "  if (!folpend",n,")",
         "    if (folpstp",n,") setTimeout(\"dofolp",n,"()\",",delay,"); ",
         "    else setTimeout(\"dofolp",n,"()\",",delay,"+folpwait",n,"); ",
         "     }",
         "  setTimeout(\"dofolp",n,"()\",1000);", 
         "</script>",
         ]
    }}}. 

   
define Word32
   Word32 x / Word32 y
     =
   if (Maybe((Word32,Word32)))(x/y) is 
     {
       failure then 0, 
       success(p) then if p is (q,r) then q
     }.
   
public type ImageToLoad:
  simple(String image_name),
  with_rollover(String image_name,
                String rollover_name). 
   
variable List(ImageToLoad) images_to_load = [].    
   
public define Printable_tree
  format
    (
      Web_body_option o
    ) =
  if o is
    {
      background_color(c)                then [" bgcolor=" , (String)format(c)],
      psychedelic_background(a,f,d)      then add_script(psychedelic_bg(a,f,d)); [ ], 
      background_image(n)                then [" background=", n],
      scrolling_layer(disp,st,m,t,c,p)   then add_script(s_layer(disp,st,m,t,c,p,2000/p)); [ ], 
      bounce(i,l,r,t,b)                  then add_script(bnce(i,l,r,t,b)); [ ], 
      over(i,l,t)                        then add_script(over(i,l,t)); [ ],
      follow_path(li,ns,p,l,s,d)         then add_script(follow_path(li,ns,p,l,s,d)); [ ], 
      load_image(n)                      then images_to_load <- [simple(n) . *images_to_load]; [ ], 
      left_margin(n)                     then [" leftmargin=", n],
      top_margin(n)                      then [" topmargin=", n],
      margin_width(n)                    then [" marginwidth=", n],
      margin_height(n)                   then [" marginheight=", n],
      reload_frame(n,url)                then add_body_onload(reload_frame(n,url)); [ ],
      onload(n)                          then [" onLoad=\"", n, "()\""] 
    }.

define Printable_tree
  preload_list
    (
      List(ImageToLoad) images,
      Word32 n, 
    ) =
  if images is 
    {
      [ ] then [ ], 
      [h . t] then 
        ["   preloaded_images[",n,"].src = '",image_name(h),"';",
         if h is 
           {
             simple(_) then [],
             with_rollover(n1,r) then 
               ["   preloaded_images[",n1,"].onload = 'allow_rollover(\"",r,"\")';"]
           }
         . preload_list(t,n-1)]
    }.

define Printable_tree 
  load_image_script
    (
      List(ImageToLoad) images
    ) =
  if images is 
    {
      [ ] then [ ], 
      [_ . _] then 
        [
          "<script>",
          "  var preloaded_images = new Array(",length(images),");", 
          "  var pi_i = 0;", 
          "  for(pi_i = 0; pi_i < ",length(images),"; pi_i++) {", 
          "    preloaded_images[pi_i] = new Image(); }",
          "  function preload_images() {",
          preload_list(images,truncate_to_Word32(length(images)-1)), 
          "     }</script>"
        ]
    }.

   
public define Printable_tree format(String c_ticket, 
                                    String s_ticket, 
                                    Web_item i). 


public define Printable_tree
 format(List(Table_option) l) =
  if l is 
    {
      [ ] then [ ],
      [h . t] then [if h is 
         {
           background_color(c) then [" bgcolor=", (String)format(c)],
           background_image(f) then [" background=",f],
           border              then [" border"],
           nude                then [" border=\"0\" cellspacing=\"0\" cellpadding=\"0\""],
           border(e,top,i)     then [" border=",e," cellspacing=",top," cellpadding=",i],
           border_color(c)     then [" bordercolor=", (String)format(c)],
           absolute_width(n)   then [" width=",n]
         }, format(t)]
    }. 



public define Printable_tree
  format(List(Row_option) l) =
    if l is
      {
        [ ] then [ ], 
        [first . others] then [if first is
                                 {
                                   left       then [" align=left"],
                                   h_center   then [" align=center"],
                                   right      then [" align=right"],
                                   top        then [" valign=top"],
                                   v_center   then [" valign=center"],
                                   bottom     then [" valign=bottom"],
                           absolute_height(n) then [" height=\"",n,"\""], 
                                   base_line  then [" valign=baseline"],
                                   background_color(c) then [" bgcolor=",(String)format(c)]
                                 },
                               format(others)]
      }.




public define Word32
  percentage(Word32 n) =
         if n -< 0 then 0 
    else if n >- 100 then 100
    else n. 

 public define Word32 percentage(Word32 n) = n. 




public define Printable_tree
  format
    (
      List(Web_body_option) l
    ) =
  if l is 
    {
      [ ] then [ ], 
      [h . t] then [format(h) . format(t)]
    }.  




public define Printable_tree
  format(List(Cell_option) l) =
    if l is
      {
        [ ] then [ ],
        [first . others] then 
          [if first is
             {
               left                then (Printable_tree)[" align=left"],
               h_center            then (Printable_tree)[" align=center"],
               right               then (Printable_tree)[" align=right"],
               top                 then (Printable_tree)[" valign=top"],
               v_center            then (Printable_tree)[" valign=center"],
               bottom              then (Printable_tree)[" valign=bottom"],
               base_line           then (Printable_tree)[" valign=baseline"],
               background_color(c) then (Printable_tree)[" bgcolor=",(String)format(c)],
               background_image(n) then (Printable_tree)[" style=\"background: url(",n,")\""],
               absolute_width(w)   then (Printable_tree)[" width=",w],
               relative_width(r)   then (Printable_tree)[" width=",percentage(r),""],
               absolute_height(h)  then (Printable_tree)[" height=",h],
               relative_height(r)  then (Printable_tree)[" height=",percentage(r),""],
               columns(n)          then (Printable_tree)[" colspan=",n],
               rows(n)             then (Printable_tree)[" rowspan=",n],
               nowrap              then (Printable_tree)[" nowrap"]           
             }
          . format(others)]
      }.



public define Printable_tree
  format
    (
      String c_ticket, 
      String s_ticket, 
      List(Cell) l
    ) =
   if l is
     {
       [ ] then [ ], 
       [first . others] then 
         [if first is cell(options,item) then 
          ["<td",format(options),">",
           format(c_ticket,s_ticket,item),"</td>"],
          format(c_ticket,s_ticket,others)]
     }.


public define Printable_tree
 format
   (
     String c_ticket, 
     String s_ticket, 
     List(Table_row) l
   ) =
  if l is
    {
      [ ] then [ ], 
      [first_row . other_rows] 
        then [if first_row is
                          {
                     row(options,cells) then
                          [ "<tr",format(options),">",
                            format(c_ticket,s_ticket,cells),"</tr>"]
                          },
              format(c_ticket,s_ticket,other_rows)]                    
    }. 


public define Printable_tree
  format_choices
    (
      List(String) l
    ) =
  if l is 
    {
      [ ] then [ ], 
      [h . t] then ["<option>",h . format_choices(t)]
    }.


public define Printable_tree
  format_choices
    (
      List(String) l,
      String selected
    ) =
  if l is 
    {
      [ ] then [ ], 
      [h . t] then if h = selected 
        then ["<option selected>",h . format_choices(t)]
        else ["<option>",h . format_choices(t,selected)]
    }.


public define Printable_tree 
  format_list
    (
      String c_ticket,
      String s_ticket, 
      List(Web_item) l
    ) =
  if l is
    {
      [ ] then [ ],
      [h . t] then ["<li>",format(c_ticket,s_ticket,h),
                           format_list(c_ticket,s_ticket,t)]
    }.

   
public define String
  format
    (
      WebStyle ws
    ) =
  if ws is 
    {
      background_image(fn)          then "background: url("+fn+")",
      background_color(c)           then "background: "+format(c),
      background_transparent        then "background: transparent",
      background_repeat_horizontal  then "background: repeat-x",
      background_repeat_vertical    then "background: repeat-y",
      background_no_repeat          then "background: no-repeat",
      color(wc)                     then if wc is 
                                       {
                                         rgb(r,g,b) then "color: rgb("+r+","+g+","+b+")",
                                         _(c)       then "color: "+format(c)
                                       },
      float_to_left                 then "float: left",
      float_to_right                then "float: right",
      font_family(n)                then "font-family: "+n,
      font_size(n)                  then "font-size: "+to_decimal(n)+"pt",
      italic                        then "font-style: italic",
      oblique                       then "font-style: oblique",
      small_capitals                then "font-variant: small-caps",
      bold                          then "font-weight: bold",
      bolder                        then "font-weight: bolder",
      lighter                       then "font-weight: lighter",
      line_height(h)                then "line-height: "+to_decimal(h),
      text_center                   then "text-align: center",
      text_left                     then "text-align: left",
      text_right                    then "text-align: right",
      text_justify                  then "text-align: justify",
      text_underline                then "text-decoration: underline",
      text_blink                    then "text-decoration: blink",
      text_line_through             then "text-decoration: line-through",
      width(n)                      then "width: "+to_decimal(n),
    }. 
   
   
public define Printable_tree
  format
    (
      List(WebStyle) l
    ) =
  if l is 
    {
      [ ] then [ ], 
      [h . t] then 
        if t is 
          {
            [ ]     then [format(h)], 
            [_ . _] then [format(h), "; " . format(t)]
          }
    }.
   
   
define Printable_tree
  format_polygon_coordinates
    (
      List((Word32,Word32)) vertices
    ) =
  if vertices is 
    {
      [ ] then [ ],
      [h . t] then  
        if h is (x,y) then 
          if t is [] 
          then [ x,",",y ] 
          else [ x,",",y,"," . format_polygon_coordinates(t)]
    }.
   
 define Printable_tree
  format
    (
      List(Mouse_Sensitive_Zone) zones
    ) =
  if zones is 
    {
      [ ] then [ ], 
      [h . t] then 
        [
          if h is 
           {
             rectangle(lt,rb,url) then 
               if lt is (left,top) then 
               if rb is (right,bottom) then 
                 [ "<area shape=rect coords=\"",left,",",top,",",right,",",bottom,
                          "\" href=\"",url,"\">" ],
             circle(c,r,url) then 
               if c is (x,y) then 
                 [ "<area shape=circle coords=\"",x,",",y,",",r,
                          "\" href=\"",url,"\">" ],
             polygon(vs,url) then 
                 [ "<area shape=poly coords=\"",format_polygon_coordinates(vs),
                          "\" href=\"",url,"\">" ]
           }
        . format(t)]
    }. 

define Printable_tree
  format
    (
      List(Mouse_Sensitive_Zone) zones,
      String                     c_ticket,
      String                     s_ticket,
    ) =
  if zones is 
    {
      [ ] then [ ], 
      [h . t] then 
        [
          if h is 
           {
             rectangle(lt,rb,url) then 
               if lt is (left,top) then 
               if rb is (right,bottom) then 
                 [ "<area shape=rect coords=\"",left,",",top,",",right,",",bottom,
                          "\" href=\"", url + "&c_ticket=" + c_ticket + "&s_ticket=" + s_ticket,"\">" ],
             circle(c,r,url) then 
               if c is (x,y) then 
                 [ "<area shape=circle coords=\"",x,",",y,",",r,
                          "\" href=\"", url + "&c_ticket=" + c_ticket + "&s_ticket=" + s_ticket,"\">" ],
             polygon(vs,url) then 
                 [ "<area shape=poly coords=\"",format_polygon_coordinates(vs),
                          "\" href=\"", url + "&c_ticket=" + c_ticket + "&s_ticket=" + s_ticket,"\">" ]
           }
        . format(t, c_ticket, s_ticket)]
    }. 
   
variable Word32 map_number = 0. 

define Printable_tree
  format_mouse_sensitive_image
    (
      String image_file_name, 
      List(Mouse_Sensitive_Zone) zones,
      String c_ticket,
      String s_ticket,
    ) =
  map_number <- (*map_number)+1; 
  [
    "<img src=\"",image_file_name,"\" usemap=\"#imsensmap",*map_number,"\" border=0>",
    "<map name=\"imsensmap",*map_number,"\">",
    format(zones, c_ticket, s_ticket),
    "</map>"
  ]. 
   
  
   Find an 'upload' in a web item. 
   
define Bool
  find_upload
    (
      Web_item i
    ). 
   
define Bool
  find_upload
    (
      List(Web_item) li
    ) =
  if li is 
    {
      [ ] then false, 
      [h . t] then if find_upload(h) then true else find_upload(t)
    }. 
   
define Bool
  find_upload
    (
      Cell c
    ) =
  if c is cell(lo,wi) then find_upload(wi). 
   
define Bool
  find_upload
    (
      List(Cell) lc
    ) =
  if lc is 
    {
      [ ] then false, 
      [h . t] then if find_upload(h) then true else find_upload(t)
    }.
   
   
   
define Bool
  find_upload
    (
      Table_row tr
    ) =
  if tr is 
    {
      row(lo,lc) then find_upload(lc)
    }. 
   
define Bool
  find_upload
    (
      List(Table_row) l
    ) =
  if l is 
    {
      [ ] then false, 
      [h . t] then 
        if find_upload(h) then true else find_upload(t)
    }. 
   
define Bool
  find_upload
    (
      Web_item wi
    ) =
  if wi is 
    {
      [ ]                        then (Bool)false, 
      [a . b]                    then (Bool)if find_upload(a) then true else find_upload(b), 
      text(_)                    then (Bool)false, 
      text_pt(_)                 then (Bool)false, 
      text_nowrap(_)             then (Bool)false, 
      text_nowrap_pt(_)          then (Bool)false, 
      par(_)                     then (Bool)false, 
      preformated_text(_)        then (Bool)false,
      integer(_)                 then (Bool)false, 
      float(_,_)                 then (Bool)false, 
      center(i)                  then (Bool)find_upload(i), 
      bigger(n,i)                then (Bool)find_upload(i), 
      smaller(n,i)               then (Bool)find_upload(i), 
      bold(i)                    then (Bool)find_upload(i), 
      italic(i)                  then (Bool)find_upload(i), 
      big(i)                     then (Bool)find_upload(i), 
      very_big(i)                then (Bool)find_upload(i), 
      style(_,i)                 then (Bool)find_upload(i), 
      spacer(_,_)                then (Bool)false,
      image(_)                   then (Bool)false,
      image_d(_,_)               then (Bool)false, 
      image_pt(_)                then (Bool)false, 
      on_image(_,_)              then (Bool)false, 
      turning_images(_,_)        then (Bool)false, 
      rollover(_,_,_,_,_,_)      then (Bool)false, 
      rollover(_,_,_,_,_,_,_,_)  then (Bool)false, 
      mouse_sensitive_image(_,_) then (Bool)false,
      background_sound(_,_)      then (Bool)false, 
      form(_,c)                  then (Bool)find_upload(c), 
      form_target(_,c,_)         then (Bool)find_upload(c), 
      form(_,_,c)                then (Bool)find_upload(c), 
      form_name(_,c)             then (Bool)find_upload(c), 
      text_input(_,_,_)          then (Bool)false,
      password_input(_,_)        then (Bool)false, 
      text_area(_,_,_,_)         then (Bool)false, 
      upload(_,_)                then (Bool)true, 
      submit(_)                  then (Bool)false, 
      submit_pt(_)                  then (Bool)false, 
      submit(_,_)                then (Bool)false, 
      submit_close(_,_)          then (Bool)false, 
      submit_pt2(_,_)                then (Bool)false, 
      image_submit(_,_)          then (Bool)false, 
      image_submit(_,_,_,_)      then (Bool)false, 
      hl_image_submit(_,_,_,_,_) then (Bool)false,
      text_submit(_,_,_)         then (Bool)false, 
      web_submit(_,c)            then (Bool)find_upload(c), 
      button(_,_,_,_,_)          then (Bool)false, 
      mark(_,_)                  then (Bool)false, 
      mark_pt(_,_)               then (Bool)false, 
      close_button               then (Bool)false, 
      close_button(_)            then (Bool)false, 
      label(_)                   then (Bool)false,
      go_to_label(_,i)           then (Bool)find_upload(i), 
      table(_,rows)              then (Bool)find_upload(rows), 
      list(l)                    then (Bool)find_upload(l), 
      link(_,i)                  then (Bool)find_upload(i), 
      link(_,_,i)                then (Bool)find_upload(i), 
      link_for_download(n,i)     then (Bool)find_upload(i), 
      mail_to(_,i)               then (Bool)find_upload(i), 
      select(_,_,_)              then (Bool)false, 
      select(_,_,_,_)            then (Bool)false,
      immediate_select(_,_,_)    then (Bool)false, 
      radio_button(_,_)          then (Bool)false, 
      checked_radio_button(_,_)  then (Bool)false, 
      check_box(_,_)             then (Bool)false, 
      checked_box(_,_)           then (Bool)false, 
      link_to_window(_,i)        then (Bool)find_upload(i), 
      link_to_window(_,_,i)      then (Bool)find_upload(i), 
      link_to_window_with_ticket(_,_,_,i,_,_) then (Bool)find_upload(i), 
      link_to_window_with_ticket_and_scroll(_,_,_,i,_,_) then (Bool)find_upload(i), 
      link_to_window_with_ticket_and_scroll(_,_,_,_,i,_,_) then (Bool)find_upload(i), 
      link_to_frame(_,_,i)       then (Bool)find_upload(i),
    }.
   
   
   The next function generates "enctype=multipart/form-data" or "", depending on the presence of
   an 'upload' in form-content. 
   
define String
  enctype
    (
      Web_item form_content
    ) =
  if find_upload(form_content)
  then "enctype=multipart/form-data"
  else "". 
     
define Printable_tree
  set_turning_images_sources
    (
      Word32 i, 
      String name, 
      List(String) filenames
    ) =
  if filenames is 
    {
      [ ] then [ ], 
      [h . t] then 
        ["   i",name,"[",i,"].src=\"",h,"\";"
        . set_turning_images_sources(i+1,name,t)]
    }.
    
define Bool
   member
     (
       Word8 x, 
       Printable_tree t
     ) =
   if t is 
     {
       [] then false, 
       str_pt(String _0,Printable_tree _1) then (member(x,_0) | member(x,_1)), 
       ba_pt(ByteArray _0,Printable_tree _1) then (member(x,to_string(_0)) | member(x,_1)), 
       int_pt(Int _0,Printable_tree _1) then (member(x,to_decimal(_0)) | member(x,_1)), 
       pt_pt(Printable_tree _0,Printable_tree _1) then (member(x,_0) | member(x,_1))
     }. 
   
public define Printable_tree
  format
    (
      String c_ticket, 
      String s_ticket,
      Web_item wi
    ) = 
  if wi is
    {
      [ ]            then (Printable_tree)[ ],

      [a . b]        then (Printable_tree)[format(c_ticket,s_ticket,a), " ", 
                                           format(c_ticket,s_ticket,b)],
   
      text(String s)                then (Printable_tree)[s],
   
      text_pt(Printable_tree s)     then (Printable_tree)s,
   
      text_nowrap(String s)         then (Printable_tree)["<table><tr><td nowrap>",s,"</td></tr></table>"],
   
      text_nowrap_pt(Printable_tree s) then 
            (Printable_tree)["<table><tr><td nowrap>",s,"</td></tr></table>"],
   
      par(s)                        then (Printable_tree)        
        [ "<p align=justify>", s, " </p>"],
   
      preformated_text(t) then (Printable_tree) ["<pre>",t,"</pre>"],
   
      integer(n)     then (Printable_tree)[n], 
   
      float(f,p)     then (Printable_tree)[float_to_string(f,to_Int(p))],
   
      center(item)   then (Printable_tree)["<center>", format(c_ticket,s_ticket,item),"</center>"],
   
      bigger(n,item) then (Printable_tree)["<font size=+",n,">",format(c_ticket,s_ticket,item),"</font>"],
   
      smaller(n,item) then (Printable_tree)["<font size=-",n,">",format(c_ticket,s_ticket,item),"</font>"],
   
      bold(item)     then 
        (Printable_tree)["<font style=\"font-weight: bold\">",format(c_ticket,s_ticket,item),"</font>"],
   
      italic(item)   then 
        (Printable_tree)["<font style=\"font-style: italic\">",format(c_ticket,s_ticket,item),"</font>"],
   
      big(item)      then (Printable_tree)["<font size=+1>",format(c_ticket,s_ticket,item),"</font>"],
   
      very_big(item) then (Printable_tree)["<h1>",format(c_ticket,s_ticket,item),"</h1>"],
   
      style(l,i)     then 
        (Printable_tree)["<span style=\"", format(l), "\">", format(c_ticket,s_ticket,i), "</span>"],

      spacer(w,h) then (Printable_tree) 
        ["<img src=\"spacer.gif\" width=\"",w,"\" height=\"",h,"\" border=\"0\">"], 
   
      image(String f)               then (Printable_tree)["<img src=\"", f,"\" border=0>"],
   
      image_d(fn,desc) then (Printable_tree)["<img src=\"", fn,"\" alt=\"",desc,"\" border=0>"],
   
      image_pt(Printable_tree l)       then (Printable_tree)["<img src=\"", l,"\" border=0>"],
   
      on_image(fn,x) then (Printable_tree)
        ["<span style=\"background: url(",fn,")\">",format(c_ticket,s_ticket,x),"</span>"],
   
      turning_images(fns,msec) then if fns is [im0 . imo] then 
        with name = "trni"+to_decimal(new_web_count), n = 1+length(imo), (Printable_tree)
        ["<script>",
         "var i",name,"=new Array(",n,");",
         "var n",name,"=0;", 
         "for(var i=0; i<",n,"; i++) {", 
         "  i",name,"[i]=new Image(); }",
         set_turning_images_sources(0,name,(List(String))[im0 . imo]),
   
         "function a",name,"() {", 
         "if (i",name,"[(n",name,"+1)",n,"].complete)",
         "{n",name,"=(n",name,"+1)",n,";", 
         "document.",name,".src=i",name,"[n",name,"].src; }",
         "setTimeout(\"a",name,"()\",",msec,"); }",
   
         "setTimeout(\"a",name,"()\",",msec,");", 
         "</script>", 
         "<img src=\"",im0,"\" name=",name," border = 0>"], 
      
      rollover(prlim,url,target,ion,ioff,descr) then (Printable_tree)
       (images_to_load <- [simple(ion) . *images_to_load]; 
        with name = "ron_"+to_decimal(new_web_count), 
        ["<a target=\"",target,"\" href=\"",url,
        (if (c_ticket = "" & s_ticket = "") then "" else (if member('?',url) then "&" else "?")),
        (if c_ticket = "" then [ ] else ["c_ticket=",c_ticket]),
        (if s_ticket = "" then [ ] else ["&s_ticket=",s_ticket]),
         "\" onMouseOut=\"",name,".src='",ioff,
         "';\" onMouseOver=\"",name,".src='",ion,"';\"><img src=\"",ioff,
         "\" name=\"",name,"\" alt=\"",descr,"\" border=0></a>"]), 
   
      rollover(prlim,url,target,ion,ioff,w,h,descr) then (Printable_tree)
       (images_to_load <- [simple(ion) . *images_to_load]; 
        with name = "ron_"+to_decimal(new_web_count), 
        ["<a target=\"",target,"\" href=\"",url,
        (if (c_ticket = "" & s_ticket = "") then "" else (if member('?',url) then "&" else "?")),
        (if c_ticket = "" then [ ] else ["c_ticket=",c_ticket]),
        (if s_ticket = "" then [ ] else ["&s_ticket=",s_ticket]),
         "\" onMouseOut=\"",name,".src='",ioff,
         "';\" onMouseOver=\"",name,".src='",ion,"';\"><img src=\"",ioff,
         "\" name=\"",name,"\" width=\"",w,"\" height=\"",h,"\" alt=\"",descr,"\" border=0></a>"]), 
   
      mouse_sensitive_image(fn,lz) then (Printable_tree)  
               format_mouse_sensitive_image(fn,lz, c_ticket, s_ticket), 
   
      background_sound(sfn,loop) then (Printable_tree)
        ["<embed src=\"", sfn, "\" autostart=true loop=", if loop then "true>" else "false>"],
   
      form(n,c)      then (Printable_tree)
        ["<form ",enctype(c)," method=POST action=\"", n, "\">", 
         "<input type=hidden name=s_ticket value=\"",s_ticket,"\">",
         "<input type=hidden name=c_ticket value=\"",c_ticket,"\">",
          format(c_ticket,s_ticket,c),"</form>"],
   
      form_target(n,c,t) then (Printable_tree)
        ["<form ",enctype(c)," method=POST action=\"", n, "\" target=\"", t, "\">", 
         "<input type=hidden name=s_ticket value=\"",s_ticket,"\">",
         "<input type=hidden name=c_ticket value=\"",c_ticket,"\">",
         format(c_ticket,s_ticket,c),"</form>"],
   
      form(n,l,c)    then (Printable_tree)
        ["<form ",enctype(c)," method=POST action=\"", n,"#", l, "\">", 
         "<input type=hidden name=s_ticket value=\"",s_ticket,"\">",
         "<input type=hidden name=c_ticket value=\"",c_ticket,"\">",
         format(c_ticket,s_ticket,c),"</form>"],

      form_name(fn,c)      then (Printable_tree)
        [
         // "<form ",enctype(c), "\" name=\"", fn, "\">", 
          "<form  name=\"", fn, "\">", 
         "<input type=hidden name=s_ticket value=\"",s_ticket,"\">",
         "<input type=hidden name=c_ticket value=\"",c_ticket,"\">",
          format(c_ticket,s_ticket,c),"</form>"],
   
      text_input(n,s,v) then (Printable_tree)
        ["&nbsp; <input type=text name=\"", n, "\" size=", s, " value=\"", v,"\">"],
   
      password_input(n,s) then (Printable_tree)
        ["&nbsp; <input type=password name=\"", n, "\" size=", s,">"],
   
      text_area(name,c,r,i) then (Printable_tree)
        ["<textarea name=",name," cols=",c," rows=",r," wrap=physical>",i,"</textarea>"],
   
      upload(n,size) then (Printable_tree)
       ["<input type=file size=",size," multiple name=",n,">"],
   
      submit(String t)              then (Printable_tree)["<input type=submit value=\"",t,"\">"],
   
      submit_pt(Printable_tree t)      then (Printable_tree)["<input type=submit value=\"",t,"\">"],
   
      submit(n, String t)           then (Printable_tree)
        ["<input type=submit name=",n," value=\"",t,"\">"],
 
      submit_close(n, String t) then (Printable_tree)
        ["<input type=submit name=",n," value=\"",t,"\" onclick=\"window.top.close();\">"],      
   
      submit_pt2(n, Printable_tree t)   then (Printable_tree)
        ["<input type=submit name=",n," value=\"",t,"\">"],
   
      image_submit(n,ifn) then (Printable_tree)
        ["<input type=image name=",n," src=\"",ifn,"\" border=0>"],    
   
      image_submit(n,v,ifn,c) then (Printable_tree)
          ["<img src=\"",ifn,"\" onmousedown=\"document.forms[0].action='",
               n,"=",v,"'; document.forms[0].submit();\">"],
   
      hl_image_submit(n,v,in,ifn,hlifn) then (Printable_tree)
          ["<img src=\"",ifn,"\"",
               //" name=\"",in,"\"",
               " onMouseOver=\"this.src='",hlifn,"'\"",
               " onMouseOut=\"this.src='",ifn,"'\"",
               " onMouseDown=\"document.forms[0].action='",
               n,"=",v,"'; document.forms[0].submit();\">"],
   
      text_submit(n,v,t)            then (Printable_tree)
          ["<a href=\"",n,
           (if (s_ticket = "" & c_ticket = "" & v = "") then "" else "?"),
           (if s_ticket = "" then [ ] else ["s_ticket=",s_ticket,"&"]),
           (if c_ticket = "" then [ ] else ["c_ticket=",c_ticket]),
           v,"\">",t,"</a>"],


      web_submit(wa,i)             then (Printable_tree)
          ["<a href=\"javascript:document.forms[0].action='",
               wa,"'; document.forms[0].submit();\">",format(c_ticket,s_ticket,i),"</a>"],
   
      button(n, String t, String o, Word32 w, Word32 h)  then (Printable_tree)
        ["<input type=button name=",n," value=\"",t,
         "\"style=\"width=",w, ";height=", h, "\" ", "\" onclick=\"", o, "\";\">"],

      mark(n, String v)             then (Printable_tree)
        ["<input type=hidden name=",n," value=\"",v,"\">"],
   
      mark_pt(n, Printable_tree v)     then (Printable_tree)
        ["<input type=hidden name=",n," value=\"",v,"\">"],
   
      close_button     then (Printable_tree)
             ["<form><input type=button value=\" Fermer \" onclick=\"window.top.close();\"></form>"],

      close_button(ifn)     then (Printable_tree)
             ["<form><input type=image name=close src=\"", ifn,
              "\" onclick=\"window.top.close();\"></form>"],

/*
      close_button(ifn)     then (Printable_tree)
             ["<form><input type=button name=close src=\"", ifn,
              "\" onclick=\"window.top.close();\"></form>"],
*/   
      label(name) then (Printable_tree)["<a name=\"",name,"\">"],
   
      go_to_label(name,content) then (Printable_tree)["<a href=#",name,">",
            format(c_ticket,s_ticket,content),"</a>"], 
   
      table(ops,rows)  then (Printable_tree)["<table ",
                                  format(ops), ">",format(c_ticket,s_ticket,rows),"</table>"],
   
      list(l)   then (Printable_tree)["<ul>",format_list(c_ticket,s_ticket,l),"</ul>"],
   
      link(name,i)    then (Printable_tree)["<a href=\"",name,
        (if (c_ticket = "" & s_ticket = "") then "" else (if member('?',name) then "&" else "?")),
        (if c_ticket = "" then [ ] else ["c_ticket=",c_ticket]),
        (if s_ticket = "" then [ ] else [if c_ticket = "" then "" else "&","s_ticket=",s_ticket]),
        "\">",format(c_ticket,s_ticket,i),"</a>"],
   
      link(name,target,i)    then (Printable_tree)["<a target=\"",target,"\" href=\"",name,
        (if (c_ticket = "" & s_ticket = "") then "" else (if member('?',name) then "&" else "?")),
        (if c_ticket = "" then [ ] else ["c_ticket=",c_ticket]),
        (if s_ticket = "" then [ ] else ["&s_ticket=",s_ticket]),
        "\">",format(c_ticket,s_ticket,i),"</a>"],
   
      link_for_download(fname,i) then (Printable_tree)
        ["<a href=\"",fname,"?download\">",format(c_ticket,s_ticket,i),"</a>"],
   
      mail_to(addr,i) then (Printable_tree)["<a href=\"mailto:",addr,"\">",
          format(c_ticket,s_ticket,i),"</a>"],
   
      select(name,size,choices) then (Printable_tree)
         ["<select name=",name," size=",size,">",format_choices(choices),"</select>" ],
   
      select(name,size,choices,selected) then (Printable_tree)
         ["<select name=",name," size=",size,">",format_choices(choices,selected),"</select>" ],
   
      immediate_select(name,size,choices) then (Printable_tree)
         ["<select name=",name," size=",size," onchange=\"submit();\">",
              format_choices(choices),"</select>" ],
   
      radio_button(n,v)           then (Printable_tree)
        ["<input type=radio name=", n, " value=\"", v, "\">"],
   
      checked_radio_button(n,v)   then (Printable_tree)
        ["<input type=radio checked name=", n, " value=\"", v, "\">"],
   
      check_box(n,v)              then (Printable_tree)
        ["<input type=checkbox name=", n, " value=\"", v, "\">"],
   
      checked_box(n,v)            then (Printable_tree)
        ["<input type=checkbox checked name=", n, " value=\"", v, "\">"],
   
      link_to_window(n,i) then (Printable_tree)
        ["<a href=\"javascript:void window.open('",n,"','default','resizable,scrollbars');\">",
            format(c_ticket,s_ticket,i),"</a>"],
   
      link_to_window(n,wn,i) then (Printable_tree)
        ["<a href=\"javascript:void window.open('",n,"','",wn,"','resizable,scrollbars');\">",
             format(c_ticket,s_ticket,i),"</a>"],
   
      link_to_window_with_ticket(n,args,wn,i,w,h) then (Printable_tree)
        ["<a href=\"javascript:void window.open('",n,"?c_ticket=",c_ticket,
          (if s_ticket = "" then [ ] else ["&s_ticket=",s_ticket]),
          "&target=",wn,
          if args="" then "" else "&",
           args,"','",
            wn,"','width=",w,",height=",h,"');\">",
            format(c_ticket,s_ticket,i),"</a>"],

      link_to_window_with_ticket_and_scroll(n,args,wn,i,w,h) then (Printable_tree)
        ["<a href=\"javascript:void window.open('",n,"?c_ticket=",c_ticket,
          (if s_ticket = "" then [ ] else ["&s_ticket=",s_ticket]),
          "&target=",wn,
          if args="" then "" else "&",
           args,"','",
            wn,"','width=",w,",height=",h,", resizable,scrollbars');\">",
            format(c_ticket,s_ticket,i),"</a>"],
   
      link_to_window_with_ticket_and_scroll(n,lab,args,wn,i,w,h) then (Printable_tree)
        ["<a href=\"javascript:void window.open('",n,"?c_ticket=",c_ticket,
          (if s_ticket = "" then [ ] else ["&s_ticket=",s_ticket]),
          "&target=",wn,
          if args="" then "" else "&",
           args,"&#",lab, "','",
            wn,"','width=",w,",height=",h,", resizable,scrollbars');\">",
            format(c_ticket,s_ticket,i),"</a>"],
   
      link_to_frame(n,fn,i) then ["<a href=\"",n,
           (if member('?',n) then "&" else "?"),
           (if c_ticket = "" then [ ] else ["c_ticket=",c_ticket]),
           (if s_ticket = "" then [ ] else ["&s_ticket=",s_ticket]),     
           "\" target=\"",fn,"\">",
           format(c_ticket,s_ticket,i),"</a>"]

   }. 


   
define Printable_tree
  add_tickets
    (
      String c_ticket, 
      String s_ticket,
      String url
    ) =
  if member('?',url)
  then [url , "&c_ticket=", c_ticket, "&s_ticket=", s_ticket ]
  else [url , "?c_ticket=", c_ticket, "&s_ticket=", s_ticket ]. 
   
define Printable_tree
  add_tickets
    (
      String c_ticket, 
      String s_ticket,
      Printable_tree url
    ) =
  if member('?',url)
  then [url , "&c_ticket=", c_ticket, "&s_ticket=", s_ticket ]
  else [url , "?c_ticket=", c_ticket, "&s_ticket=", s_ticket ]. 
   
   
define Printable_tree   
  format
    (
      List(VFrame) frames,
      String c_ticket, 
      String s_ticket
    ) =
  if frames is 
    {
      [ ] then [ ], 
      [h . t] then 
        if h is frame(height,url,name) then 
          [
            "<frame src=\"",add_tickets(c_ticket,s_ticket,url), "\" name=\"",name,"\" frameborder=no>"
          . format(t,c_ticket,s_ticket)]
    }.

   
define String 
  frame_size
    (
      Word32 s
    ) =
  if s -=< 0 then "*" else to_decimal(s). 
   
define String
  frame_stack_rows
    (
      List(VFrame) frames
    ) =
  if frames is 
    {
      [ ] then "", 
      [h . t] then if h is frame (height,url,name) then 
        frame_size(height)+
          if t is 
            {
              [ ] then "", 
              [_ . _] then ","
            }+frame_stack_rows(t)
    }.
   

   
   'crlf' is defined in 'basis.anubis'. 
   
   
   
define Printable_tree
  standard_headers 
    (
      Word32 size
    ) =
  [
    "HTTP/1.0 200 OK" + crlf +
    "Server: Anubis" + crlf +
    "Content-Type: text/html" + crlf +
    "Content-Length: "+to_decimal(size)+crlf+
    crlf
  ].
   
 define Printable_tree
  download_headers
    =
  [
    "HTTP/1.0 200 OK" + crlf +
    "Content-Type: application/octet-stream" + crlf +
    crlf
  ].
   
define Printable_tree
  apache_headers
    = 
  [
    "Content-type: text/html" + crlf + 
    crlf
  ]. 
   
   
define String
  empty_javascript_source
    =
  "javascript:'<html><head></head><body></body></html>';".
   
public type HeaderSort:
  empty,
  anubis, 
  apache. 

   
define Printable_tree
  format_keywords
    (
      List(String) l
    ) =
  if l is 
    {
      [ ] then [ ], 
      [h . t] then if t is [ ]
        then [h]
        else [h , ", " . format_keywords(t)]
    }. 
   
define Printable_tree
  format
    (
      WebMeta m
    ) =
  if m is 
    {
      keywords(l)        then ["<meta name=\"keywords\" content=\"",format_keywords(l),"\">"],
      refresh(url,delay) then ["<meta http-equiv=\"Refresh\" content=\"",delay,"; URL=",url,"\">"], 
      meta(n,c)          then ["<meta name=\"",n,"\" content=\"",c,"\">"], 
      http_equiv(n,c)    then ["<meta http-equiv=\"",n,"\" content=\"",c,"\">"],
      encoding(e)        then ["<meta http-equiv=\"Content-Type\" content=\"text/html; charset=",e,"\">"]
    }.
   
define Printable_tree
  format
    (
      List(WebMeta) metas
    ) =
  if metas is 
    {
      [ ] then [ ],
      [h . t] then [format(h) . format(t)]
    }. 
   
   
   
   
   
   
public define Printable_tree
  format
    (
      HeaderSort hs, 
      String c_ticket, 
      String s_ticket, 
      Web_page p
    ) =
  if p is 
   {
  web_page(title,metas,head_scripts,body1) then
    with body2 =
       [
        "<html>",
        "<head>",
        "<title>", title, "</title>",
        format(metas), 
        head_scripts, 
        "</head>",
        "<body ",
        if body1 is body(options,item) then 
          with b_options = format(prepare(options)),
           [b_options, " onLoad='body_onloads();", 
                       if *images_to_load is [] then "" else " preload_images();",
                       "'>", 
            load_image_script(*images_to_load), 
            reverse(*scripts),
            "<script>",
            "  function body_onloads() {",
                 format(*body_onloads),
            "}</script>",
            format(c_ticket,s_ticket,item)
           ],
        "</body>",
        "</html>"
       ],
      [
        if hs is 
           {
              empty then [ ], 
              anubis then standard_headers(truncate_to_Word32(length(body2))), 
              apache then apache_headers
           } 
        . body2
      ],
  standard_frameset(title,metas,height,width,main) then
    with body2 =
      [
        "<html>",
        "<head>",
        "<title>", title, "</title>",
        format(metas), 
        "</head>",
        "<frameset frameborder=no border=0 framespacing=0",
        "    marginwidth=0 marginheight=0 cols=\"",width,",*\" rows=\"*\">",
        "    <frame src=\"",empty_javascript_source,"\" name=\"left\" frameborder=no",
        "        marginwidth=0 marginheight=0 scrolling=no>",
        "  <frameset frameborder=no border=0 framespacing=0 rows=\"",height,",*\" cols=\"*\">",
        "    <frame src=\"",empty_javascript_source,"\" name=\"top\"",
                " marginwidth=0 marginheight=0 frameborder=no scrolling=no>",
        "    <frame src =\"", add_tickets(c_ticket,s_ticket,main), 
              "\" name=\"main\" marginwidth=0 marginheight=0 frameborder=no>",
        "  </frameset>",
        "</frameset>",
        "</html>"
      ],
      [
        if hs is 
           {
              empty then [ ], 
              anubis then standard_headers(truncate_to_Word32(length(body2))), 
              apache then apache_headers
           }
        . body2
      ]
    }.

   
public define Bool
  print
    (
      String c_ticket, 
      String s_ticket, 
      Web_page p
    ) =
  print(format(anubis,c_ticket,s_ticket,p)).    
   
public define Bool
  print_with_headers
    (
      HeaderSort hs,
      String c_ticket, 
      String s_ticket, 
      Web_page p
    ) =
  print(format(hs,c_ticket,s_ticket,p)).    
   
public define Bool
  print
    (
      Web_page p
    ) =
  print(format(anubis,"","",p)). 
   
   
      
   
public define Bool
  print_with_headers
    (
      HeaderSort hs, 
      Web_page p
    ) =
  print(format(hs,"","",p)).
   

public define Cell
  h_spacer
    (
      Word32 n
    ) =
  cell([absolute_width(n)],text("&nbsp;")). 
   
public define Cell
  v_spacer
    (
      Word32 n
    ) =
   cell([absolute_height(n)],text("&nbsp;")).
   
public define Cell
  empty = cell([],text("&nbsp;")). 
   

   
   *** Below is a simple gadget for counting visitors. It increments a counter (in a file)
   at each call.  The  argument is the name of the file (relative  to the directory of the
   server), and the file is created automatically. It returns the number of the visitor.

public define Word32
  get_visitor_number
    ( 
      String counter_file_name,
    ) =
    protect
    if (RetrieveResult(Word32))retrieve(counter_file_name) is
      {
        cannot_find_file  then 
          //
          // It's time to create the file. 
          //
          if save((Word32)1,counter_file_name) is 
            {
              cannot_open_file then 0, 
              write_error      then 0, 
              ok               then 1
            },
        read_error    then 0, 
        type_error    then 0, 
        ok(n)         then 
          //
          // Increment the counter
          //
          if save(n+1,counter_file_name) is 
            {
              cannot_open_file then n, 
              write_error      then n, 
              ok               then n+1 
            }
      }.