This file is indexed.

/usr/share/php/xajax/xajax_js/xajax_core_uncompressed.js is in php-xajax 0.5-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

   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
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
/*
	File: xajax_core.js
	
	This file contains the definition of the main xajax javascript core.
	
	This is the client side code which runs on the web browser or similar 
	web enabled application.  Include this in the HEAD of each page for
	which you wish to use xajax.
	
	Title: xajax core javascript library
	
	Please see <copyright.inc.php> for a detailed description, copyright
	and license information.
*/

/*
	@package xajax
	@version $Id: xajax_core_uncompressed.js 327 2007-02-28 16:55:26Z calltoconstruct $
	@copyright Copyright (c) 2005-2007 by Jared White & J. Max Wilson
	@copyright Copyright (c) 2008-2009 by Joseph Woolley, Steffen Konerow, Jared White  & J. Max Wilson
	@license http://www.xajaxproject.org/bsd_license.txt BSD License
*/

/*
	Class: xajax.config
	
	This class contains all the default configuration settings.  These
	are application level settings; however, they can be overridden
	by including a xajax.config definition prior to including the
	<xajax_core.js> file, or by specifying the appropriate configuration
	options on a per call basis.
*/
if ('undefined' == typeof xajax)
	xajax = {};

if ('undefined' == typeof xajax.config)
	xajax.config = {};

/*
	Function: xajax.config.setDefault
	
	This function will set a default configuration option if it is 
	not already set.
	
	Parameters:
	option - (string):
		The name of the option that will be set.
		
	defaultValue - (unknown):
		The value to use if a value was not already set.
*/
xajax.config.setDefault = function(option, defaultValue) {
	if ('undefined' == typeof xajax.config[option])
		xajax.config[option] = defaultValue;
}

/*
	Object: commonHeaders
	
	An array of header entries where the array key is the header
	option name and the associated value is the value that will
	set when the request object is initialized.
	
	These headers will be set for both POST and GET requests.
*/
xajax.config.setDefault('commonHeaders', {
	'If-Modified-Since': 'Sat, 1 Jan 2000 00:00:00 GMT'
	});

/*
	Object: postHeaders
	
	An array of header entries where the array key is the header
	option name and the associated value is the value that will
	set when the request object is initialized.
*/
xajax.config.setDefault('postHeaders', {});

/*
	Object: getHeaders
	
	An array of header entries where the array key is the header
	option name and the associated value is the value that will
	set when the request object is initialized.
*/
xajax.config.setDefault('getHeaders', {});

/*
	Boolean: waitCursor
	
	true - xajax should display a wait cursor when making a request
	false - xajax should not show a wait cursor during a request
*/
xajax.config.setDefault('waitCursor', false);

/*
	Boolean: statusMessages
	
	true - xajax should update the status bar during a request
	false - xajax should not display the status of the request
*/
xajax.config.setDefault('statusMessages', false);

/*
	Object: baseDocument
	
	The base document that will be used throughout the code for
	locating elements by ID.
*/
xajax.config.setDefault('baseDocument', document);

/*
	String: requestURI
	
	The URI that requests will be sent to.
*/
xajax.config.setDefault('requestURI', xajax.config.baseDocument.URL);

/*
	String: defaultMode
	
	The request mode.
	
	'asynchronous' - The request will immediately return, the
		response will be processed when (and if) it is received.
		
	'synchronous' - The request will block, waiting for the
		response.  This option allows the server to return
		a value directly to the caller.
*/
xajax.config.setDefault('defaultMode', 'asynchronous');

/*
	String: defaultHttpVersion
	
	The Hyper Text Transport Protocol version designated in the 
	header of the request.
*/
xajax.config.setDefault('defaultHttpVersion', 'HTTP/1.1');

/*
	String: defaultContentType
	
	The content type designated in the header of the request.
*/
xajax.config.setDefault('defaultContentType', 'application/x-www-form-urlencoded');

/*
	Integer: defaultResponseDelayTime
	
	The delay time, in milliseconds, associated with the 
	<xajax.callback.global.onRequestDelay> event.
*/
xajax.config.setDefault('defaultResponseDelayTime', 1000);

/*
	Integer: defaultExpirationTime
	
	The amount of time to wait, in milliseconds, before a request
	is considered expired.  This is used to trigger the
	<xajax.callback.global.onExpiration event.
*/
xajax.config.setDefault('defaultExpirationTime', 10000);

/*
	String: defaultMethod
	
	The method used to send requests to the server.
	
	'POST' - Generate a form POST request
	'GET' - Generate a GET request; parameters are appended
		to the <xajax.config.requestURI> to form a URL.
*/
xajax.config.setDefault('defaultMethod', 'POST');	// W3C: Method is case sensitive

/*
	Integer: defaultRetry
	
	The number of times a request should be retried
	if it expires.
*/
xajax.config.setDefault('defaultRetry', 5);

/*
	Object: defaultReturnValue
	
	The value returned by <xajax.call> when in asynchronous
	mode, or when a syncrhonous call does not specify the
	return value.
*/
xajax.config.setDefault('defaultReturnValue', false);

/*
	Integer: maxObjectDepth
	
	The maximum depth of recursion allowed when serializing
	objects to be sent to the server in a request.
*/
xajax.config.setDefault('maxObjectDepth', 20);

/*
	Integer: maxObjectSize
	
	The maximum number of members allowed when serializing
	objects to be sent to the server in a request.
*/
xajax.config.setDefault('maxObjectSize', 2000);

xajax.config.setDefault('responseQueueSize', 1000);

/*
	Class: xajax.config.status
	
	Provides support for updating the browser's status bar during
	the request process.  By splitting the status bar functionality
	into an object, the xajax developer has the opportunity to
	customize the status bar messages prior to sending xajax requests.
*/
xajax.config.status = {
	/*
		Function: update
		
		Constructs and returns a set of event handlers that will be
		called by the xajax framework to set the status bar messages.
	*/
	update: function() {
		return {
			onRequest: function() {
				window.status = 'Sending Request...';
			},
			onWaiting: function() {
				window.status = 'Waiting for Response...';
			},
			onProcessing: function() {
				window.status = 'Processing...';
			},
			onComplete: function() {
				window.status = 'Done.';
			}
		}
	},
	/*
		Function: dontUpdate
		
		Constructs and returns a set of event handlers that will be
		called by the xajax framework where status bar updates
		would normally occur.
	*/
	dontUpdate: function() {
		return {
			onRequest: function() {},
			onWaiting: function() {},
			onProcessing: function() {},
			onComplete: function() {}
		}
	}
}

/*
	Class: xajax.config.cursor
	
	Provides the base functionality for updating the browser's cursor
	during requests.  By splitting this functionalityh into an object
	of it's own, xajax developers can now customize the functionality 
	prior to submitting requests.
*/
xajax.config.cursor = {
	/*
		Function: update
		
		Constructs and returns a set of event handlers that will be
		called by the xajax framework to effect the status of the 
		cursor during requests.
	*/
	update: function() {
		return {
			onWaiting: function() {
				if (xajax.config.baseDocument.body)
					xajax.config.baseDocument.body.style.cursor = 'wait';
			},
			onComplete: function() {
				xajax.config.baseDocument.body.style.cursor = 'auto';
			}
		}
	},
	/*
		Function: dontUpdate
		
		Constructs and returns a set of event handlers that will
		be called by the xajax framework where cursor status changes
		would typically be made during the handling of requests.
	*/
	dontUpdate: function() {
		return {
			onWaiting: function() {},
			onComplete: function() {}
		}
	}
}

/*
	Class: xajax.tools
	
	This contains utility functions which are used throughout
	the xajax core.
*/
xajax.tools = {}

/*
	Function: xajax.tools.$

	Shorthand for finding a uniquely named element within 
	the document.

	Parameters:
	sId - (string):
		The unique name of the element (specified by the 
		ID attribute), not to be confused with the name
		attribute on form elements.
		
	Returns:
	
	object - The element found or null.
	
	Note:
		This function uses the <xajax.config.baseDocument>
		which allows <xajax> to operate on the main window
		document as well as documents from contained
		iframes and child windows.
	
	See also:
		<xajax.$> and <xjx.$>
*/
xajax.tools.$ = function(sId) {
	if (!sId)
		return null;
	
	var oDoc = xajax.config.baseDocument;

	var obj = oDoc.getElementById(sId);
	if (obj)
		return obj;
		
	if (oDoc.all)
		return oDoc.all[sId];

	return obj;
}

/*
	Function xajax.tools.arrayContainsValue
	
	Looks for a value within the specified array and, if found, 
	returns true; otherwise it returns false.
	
	Parameters:
	array - (object):
		The array to be searched.
		
	valueToCheck - (object):
		The value to search for.
		
	Returns:
	
	true : The value is one of the values contained in the 
		array.
		
	false : The value was not found in the specified array.
*/
xajax.tools.arrayContainsValue = function(array, valueToCheck) {
	var i = 0;
	var l = array.length;
	while (i < l) {
		if (array[i] == valueToCheck)
			return true;
		++i;
	}
	return false;
}

/*
	Function: xajax.tools.doubleQuotes
	
	Replace all occurances of the single quote character with a double
	quote character.
	
	Parameters:
	
	haystack - The source string to be scanned.
	
	Returns:
	
	string - A new string with the modifications applied.
*/
xajax.tools.doubleQuotes = function(haystack) {
	return haystack.replace(new RegExp("'", 'g'), '"');
}

/*
	Function: xajax.tools.singleQuotes
	
	Replace all occurances of the double quote character with a single
	quote character.
	
	haystack - The source string to be scanned.
	
	Returns:
	
	string - A new string with the modification applied.
*/
xajax.tools.singleQuotes = function(haystack) {
	return haystack.replace(new RegExp('"', 'g'), "'");
}

/*
	Function: xajax.tools._escape
	
	Determine if the specified value contains special characters and
	create a CDATA section so the value can be safely transmitted.
	
	Parameters:
	
	data - (string or other):
		The source string value to be evaluated or an object of unknown
		type.
		
	Returns:
	
	string - The string value, escaped if necessary or the object provided
		if it is not a string.
		
	Note:
		When the specified object is NOT a string, the value is returned
		as is.
*/
xajax.tools._escape = function(data) {
	if ('undefined' == typeof data)
		return data;
	
	// 'object' is handled elsewhere, 
	// 'string' handled below, 
	// 'number' will be returned here
	// 'boolean' will be returned here
	if ('string' != typeof data)
		return data;
	
	var needCDATA = false;
	
	if (encodeURIComponent(data) != data) {
		needCDATA = true;
		
		var segments = data.split('<![CDATA[');
		var segLen = segments.length;
		data = [];
		for (var i = 0; i < segLen; ++i) {
			var segment = segments[i];
			var fragments = segment.split(']]>');
			var fragLen = fragments.length;
			segment = '';
			for (var j = 0; j < fragLen; ++j) {
				if (0 != j)
					segment += ']]]]><![CDATA[>';
				segment += fragments[j];
			}
			if (0 != i)
				data.push('<![]]><![CDATA[CDATA[');
			data.push(segment);
		}
		data = data.join('');
	}
	
	if (needCDATA)
		data = '<![CDATA[' + data + ']]>';
	
	return data;
}

/*
	Function: xajax.tools._objectToXML
	
	Convert a javascript object or array into XML suitable for
	transmission to the server.
	
	Parameters: 
	
	obj - The object or array to convert.
	
	guard - An object used to track the level of recursion
		when encoding javascript objects.  When an object
		contains a reference to it's parent and the parent
		contains a reference to the child, an infinite
		recursion will cause some browsers to crash.
		
	Returns:
	
	string - the xml representation of the object or array.
	
	See also:
	
	<xajax.config.maxObjectDepth> and <xajax.config.maxObjectSize>
*/
xajax.tools._objectToXML = function(obj, guard) {
	var aXml = [];
	aXml.push('<xjxobj>');
	for (var key in obj) {
		++guard.size;
		if (guard.maxSize < guard.size)
			return aXml.join('');
		if ('undefined' != typeof obj[key]) {
			if ('constructor' == key)
				continue;
			if ('function' == typeof obj[key])
				continue;
			aXml.push('<e><k>');
			var val = xajax.tools._escape(key);
			aXml.push(val);
			aXml.push('</k><v>');
			if ('object' == typeof obj[key]) {
				++guard.depth;
				if (guard.maxDepth > guard.depth) {
					try {
						aXml.push(xajax.tools._objectToXML(obj[key], guard));
					} catch (e) {
						// do nothing, if the debug module is installed
						// it will catch the exception and handle it
					}
				}
				--guard.depth;
			} else {
				var val = xajax.tools._escape(obj[key]);
				if ('undefined' == typeof val || null == val) {
					aXml.push('*');
				} else {
					var sType = typeof val;
					if ('string' == sType)
						aXml.push('S');
					else if ('boolean' == sType)
						aXml.push('B');
					else if ('number' == sType)
						aXml.push('N');
					aXml.push(val);
				}
			}
				
			aXml.push('</v></e>');
		}
	}
	aXml.push('</xjxobj>');
	
	return aXml.join('');
}

/*
	Function: xajax.tools._enforceDataType 
	
	Ensure that the javascript variable created is of the correct data type.
	
	Parameters:
		value (string)

	Returns:
		
		(unknown) - The value provided converted to the correct data type.
*/
xajax.tools._enforceDataType = function(value) {
	value = new String(value);
	var type = value.substr(0, 1);
	value = value.substr(1);

	if ('*' == type)
		value = null;
	else if ('N' == type)
		value = value - 0;
	else if ('B' == type)
		value = !!value;
//	else if ('S' == type)
//		value = new String(value);

	return value;
}

/*
	Function: xajax.tools._nodeToObject
	
	Deserialize a javascript object from an XML node.
	
	Parameters:
	
	node - A node, likely from the xml returned by the server.
	
	Returns:
	
		object - The object extracted from the xml node.
*/
xajax.tools._nodeToObject = function(node) {
	if (null == node)
		return '';
		
	if ('undefined' != typeof node.nodeName) {
		if ('#cdata-section' == node.nodeName || '#text' == node.nodeName) {
			var data = '';
			do if (node.data) data += node.data; while (node = node.nextSibling);
			return xajax.tools._enforceDataType(data);
		} else if ('xjxobj' == node.nodeName) {
			var key = null;
			var value = null;
			var data = new Array;
			var child = node.firstChild;
			while (child) {
				if ('e' == child.nodeName) {
					var grandChild = child.firstChild;
					while (grandChild) {
						if ('k' == grandChild.nodeName)
							// Don't support objects here, only number, string, etc...
							key = xajax.tools._enforceDataType(grandChild.firstChild.data);
						else ('v' == grandChild.nodeName)
							// Value might be object, string, number, boolean... even null or undefined
							value = xajax.tools._nodeToObject(grandChild.firstChild);
						grandChild = grandChild.nextSibling;
					}
					// Allow the value to be null or undefined (or a value)
					if (null != key) { // && null != value) {
						data[key] = value;
						key = value = null;
					}
				}
				child = child.nextSibling;
			}
			return data;
		}
	}
	
	throw { code: 10001, data: node.nodeName };
}

/*
	Function: xajax.tools.getRequestObject
	
	Construct an XMLHttpRequest object dependent on the capabilities
	of the browser.
	
	Returns:
	
	object - Javascript XHR object.
*/
xajax.tools.getRequestObject = function() {
	if ('undefined' != typeof XMLHttpRequest) {
		xajax.tools.getRequestObject = function() {
			return new XMLHttpRequest();
		}
	} else if ('undefined' != typeof ActiveXObject) {
		xajax.tools.getRequestObject = function() {
			try {
				return new ActiveXObject('Msxml2.XMLHTTP.4.0');
			} catch (e) {
				xajax.tools.getRequestObject = function() {
					try {
						return new ActiveXObject('Msxml2.XMLHTTP');
					} catch (e2) {
						xajax.tools.getRequestObject = function() {
							return new ActiveXObject('Microsoft.XMLHTTP');
						}
						return xajax.tools.getRequestObject();
					}
				}
				return xajax.tools.getRequestObject();
			}
		}
	} else if (window.createRequest) {
		xajax.tools.getRequestObject = function() {
			return window.createRequest();
		}
	} else {
		xajax.tools.getRequestObject = function() {
			throw { code: 10002 };
		}
	}
	
	// this would seem to cause an infinite loop, however, the function should
	// be reassigned by now and therefore, it will not loop.
	return xajax.tools.getRequestObject();
}

/*
	Function: xajax.tools.getBrowserHTML
	
	Insert the specified string of HTML into the document, then 
	extract it.  This gives the browser the ability to validate
	the code and to apply any transformations it deems appropriate.
	
	Parameters:
	
	sValue - (string):
		A block of html code or text to be inserted into the
		browser's document.
		
	Returns:
	
	The (potentially modified) html code or text.
*/
xajax.tools.getBrowserHTML = function(sValue) {
	var oDoc = xajax.config.baseDocument;
	if (!oDoc.body)
		return '';
		
	var elWorkspace = xajax.$('xajax_temp_workspace');
	if (!elWorkspace)
	{
		elWorkspace = oDoc.createElement('div');
		elWorkspace.setAttribute('id', 'xajax_temp_workspace');
		elWorkspace.style.display = 'none';
		elWorkspace.style.visibility = 'hidden';
		oDoc.body.appendChild(elWorkspace);
	}
	elWorkspace.innerHTML = sValue;
	var browserHTML = elWorkspace.innerHTML;
	elWorkspace.innerHTML = '';	
	
	return browserHTML;
}

/*
	Function: xajax.tools.willChange
	
	Tests to see if the specified data is the same as the current
	value of the element's attribute.
	
	Parameters: 
	element - (string or object):
		The element or it's unique name (specified by the ID attribute)
		
	attribute - (string):
		The name of the attribute.
		
	newData - (string):
		The value to be compared with the current value of the specified
		element.
		
	Returns:
	
	true - The specified value differs from the current attribute value.
	false - The specified value is the same as the current value.
*/
xajax.tools.willChange = function(element, attribute, newData) {
	if ('string' == typeof element)
		element = xajax.$(element);
	if (element) {
		var oldData;		
		eval('oldData=element.'+attribute);
		return (newData != oldData);
	}

	return false;
}

/*
	Function: xajax.tools.getFormValues
	
	Build an associative array of form elements and their values from
	the specified form.
	
	Parameters: 
	
	element - (string): The unique name (id) of the form to be processed.
	disabled - (boolean, optional): Include form elements which are currently disabled.
	prefix - (string, optional): A prefix used for selecting form elements.

	Returns:
	
	An associative array of form element id and value.
*/
xajax.tools.getFormValues = function(parent) {
	var submitDisabledElements = false;
	if (arguments.length > 1 && arguments[1] == true)
		submitDisabledElements = true;
	
	var prefix = '';
	if(arguments.length > 2)
		prefix = arguments[2];
	
	if ('string' == typeof parent)
		parent = xajax.$(parent);
	
	var aFormValues = {};
	
//		JW: Removing these tests so that form values can be retrieved from a specified
//		container element like a DIV, regardless of whether they exist in a form or not.
//
//		if (parent.tagName)
//			if ('FORM' == parent.tagName.toUpperCase())
	if (parent)
		if (parent.childNodes)
			xajax.tools._getFormValues(aFormValues, parent.childNodes, submitDisabledElements, prefix);
	
	return aFormValues;
}

/*
	Function: xajax.tools._getFormValues
	
	Used internally by <xajax.tools.getFormValues> to recursively get the value
	of form elements.  This function will extract all form element values 
	regardless of the depth of the element within the form.
*/
xajax.tools._getFormValues = function(aFormValues, children, submitDisabledElements, prefix)
{
	var iLen = children.length;
	for (var i = 0; i < iLen; ++i) {
		var child = children[i];
		if ('undefined' != typeof child.childNodes)
			xajax.tools._getFormValues(aFormValues, child.childNodes, submitDisabledElements, prefix);
		xajax.tools._getFormValue(aFormValues, child, submitDisabledElements, prefix);
	}
}

/*
	Function: xajax.tools._getFormValue
	
	Used internally by <xajax.tools._getFormValues> to extract a single form value.
	This will detect the type of element (radio, checkbox, multi-select) and 
	add it's value(s) to the form values array.
*/
xajax.tools._getFormValue = function(aFormValues, child, submitDisabledElements, prefix)
{
	if (!child.name)
		return;
		
	if ('PARAM' == child.tagName) return;
		
	if (child.disabled)
		if (true == child.disabled)
			if (false == submitDisabledElements)
				return;
				
	if (prefix != child.name.substring(0, prefix.length))
		return;
		
	if (child.type)
		if (child.type == 'radio' || child.type == 'checkbox')
			if (false == child.checked)
				return;

	var name = child.name;

	var values = [];

 	if ('select-multiple' == child.type) {
 		var jLen = child.length;
 		for (var j = 0; j < jLen; ++j) {
 			var option = child.options[j];
 			if (true == option.selected)
 				values.push(option.value);
 		}
 	} else {
 		values = child.value;
 	}

	var keyBegin = name.indexOf('[');
	if (0 <= keyBegin) {
		var n = name;
		var k = n.substr(0, n.indexOf('['));
		var a = n.substr(n.indexOf('['));
		if (typeof aFormValues[k] == 'undefined')
			aFormValues[k] = [];
		var p = aFormValues; // pointer reset
		while (a.length != 0) {
			var sa = a.substr(0, a.indexOf(']')+1);
			
			var lk = k; //save last key
			var lp = p; //save last pointer
			
			a = a.substr(a.indexOf(']')+1);
			p = p[k];
			k = sa.substr(1, sa.length-2);
			if (k == '') {
				if ('select-multiple' == child.type) {
					k = lk; //restore last key
					p = lp;
				} else {
					k = p.length;
				}
			}
			if (typeof p[k] == 'undefined')
				p[k] = []; 
		}
		p[k] = values;
	} else {
		aFormValues[name] = values;
	}
}

/*
	Function: xajax.tools.stripOnPrefix
	
	Detect, and if found, remove the prefix 'on' from the specified 
	string.  This is used while working with event handlers.
	
	Parameters: 
	
	sEventName - (string): The string to be modified.
	
	Returns:
	
	string - The modified string.
*/
xajax.tools.stripOnPrefix = function(sEventName) {
	sEventName = sEventName.toLowerCase();
	if (0 == sEventName.indexOf('on'))
		sEventName = sEventName.replace(/on/,'');
	
	return sEventName;
}

/*
	Function: xajax.tools.addOnPrefix
	
	Detect, and add if not found, the prefix 'on' from the specified 
	string.  This is used while working with event handlers.
	
	Parameters: 
	
	sEventName - (string): The string to be modified.
	
	Returns:
	
	string - The modified string.
*/
xajax.tools.addOnPrefix = function(sEventName) {
	sEventName = sEventName.toLowerCase();
	if (0 != sEventName.indexOf('on'))
		sEventName = 'on' + sEventName;
	
	return sEventName;
}

/*
	Class: xajax.tools.xml
	
	An object that contains utility function for processing
	xml response packets.
*/
xajax.tools.xml = {};

/*
	Function: xajax.tools.xml.parseAttributes 
	
	Take the parameters passed in the command of the XML response
	and convert them to parameters of the args object.  This will 
	serve as the command object which will be stored in the 
	response command queue.
	
	Parameters: 
	
	child - (object):  The xml child node which contains the 
		attributes for the current response command.
		
	obj - (object):  The current response command that will have the
		attributes applied.
*/
xajax.tools.xml.parseAttributes = function(child, obj) {
	var iLen = child.attributes.length;
	for (var i = 0; i < iLen; ++i) {
		var attr = child.attributes[i];
		obj[attr.name] = attr.value;
	}
}

/*
	Function: xajax.tools.xml.parseChildren
	
	Parses the child nodes of the command of the response XML.  Generally,
	the child nodes contain the data element of the command; this member
	may be an object, which will be deserialized by <xajax._nodeToObject>
	
	Parameters: 
	
	child - (object):   The xml node that contains the child (data) for
		the current response command object.
		
	obj - (object):  The response command object.
*/
xajax.tools.xml.parseChildren = function(child, obj) {
	obj.data = '';
	if (0 < child.childNodes.length) {
		if (1 < child.childNodes.length) {
			var grandChild = child.firstChild;
			do {
				if ('#cdata-section' == grandChild.nodeName || '#text' == grandChild.nodeName) {
					obj.data += grandChild.data;
				}
			} while (grandChild = grandChild.nextSibling);
		} else {
			var grandChild = child.firstChild;
			if ('xjxobj' == grandChild.nodeName) {
				obj.data = xajax.tools._nodeToObject(grandChild);
				return;
			} else if ('#cdata-section' == grandChild.nodeName || '#text' == grandChild.nodeName) {
				obj.data = grandChild.data;
			}
		}
	} else if ('undefined' != typeof child.data) {
		obj.data = child.data;
	}
	
	obj.data = xajax.tools._enforceDataType(obj.data);
}

/*
	Function: xajax.tools.xml.processFragment
	
	Parameters: 
	
	xmlNode - (object):  The first xml node in the xml fragment.
	seq - (number):  A counter used to keep track of the sequence
		of this command in the response.
	oRet - (object):  A variable that is used to return the request
		"return value" for use with synchronous requests.
*/
xajax.tools.xml.processFragment = function(xmlNode, seq, oRet, oRequest) {
	var xx = xajax;
	var xt = xx.tools;
	while (xmlNode) {
		if ('cmd' == xmlNode.nodeName) {
			var obj = {};
			obj.fullName = '*unknown*';
			obj.sequence = seq;
			obj.request = oRequest;
			obj.context = oRequest.context;
			
			xt.xml.parseAttributes(xmlNode, obj);
			xt.xml.parseChildren(xmlNode, obj);
			
			xt.queue.push(xx.response, obj);
		} else if ('xjxrv' == xmlNode.nodeName) {
			oRet = xt._nodeToObject(xmlNode.firstChild);
		} else if ('debugmsg' == xmlNode.nodeName) {
			// txt = xt._nodeToObject(xmlNode.firstChild);
		} else 
			throw { code: 10004, data: xmlNode.nodeName }
			
		++seq;
		xmlNode = xmlNode.nextSibling;
	}
	return oRet;
}

/*
	Class: xajax.tools.queue
	
	This contains the code and variables for building, populating
	and processing First In Last Out (FILO) buffers.
*/
xajax.tools.queue = {}

/*
	Function: create
	
	Construct and return a new queue object.
	
	Parameters: 
	
	size - (integer):
		The number of entries the queue will be able to hold.
*/
xajax.tools.queue.create = function(size) {
	return {
		start: 0,
		size: size,
		end: 0,
		commands: [],
		timeout: null
	}
}

/*
	Function: xajax.tools.queue.retry
	
	Maintains a retry counter for the given object.
	
	Parameters: 
	
	obj - (object):
		The object to track the retry count for.
		
	count - (integer):
		The number of times the operation should be attempted
		before a failure is indicated.
		
	Returns:
	
	true - The object has not exhausted all the retries.
	false - The object has exhausted the retry count specified.
*/
xajax.tools.queue.retry = function(obj, count) {
	var retries = obj.retries;
	if (retries) {
		--retries;
		if (1 > retries)
			return false;
	} else retries = count;
	obj.retries = retries;
	return true;
}

/*
	Function: xajax.tools.queue.rewind
	
	Rewind the buffer head pointer, effectively reinserting the 
	last retrieved object into the buffer.
	
	Parameters: 
	
	theQ - (object):
		The queue to be rewound.
*/
xajax.tools.queue.rewind = function(theQ) {
	if (0 < theQ.start)
		--theQ.start;
	else
		theQ.start = theQ.size;
}

/*
	Function: xajax.tools.queue.setWakeup
	
	Set or reset a timeout that is used to restart processing
	of the queue.  This allows the queue to asynchronously wait
	for an event to occur (giving the browser time to process
	pending events, like loading files)
	
	Parameters: 
	
	theQ - (object):
		The queue to process upon timeout.
		
	when - (integer):
		The number of milliseconds to wait before starting/
		restarting the processing of the queue.
*/
xajax.tools.queue.setWakeup = function(theQ, when) {
	if (null != theQ.timeout) {
		clearTimeout(theQ.timeout);
		theQ.timeout = null;
	}
	theQ.timout = setTimeout(function() { xajax.tools.queue.process(theQ); }, when);
}

/*
	Function: xajax.tools.queue.process
	
	While entries exist in the queue, pull and entry out and
	process it's command.  When a command returns false, the
	processing is halted.
	
	Parameters: 
	
	theQ - (object): The queue object to process.  This should
		have been crated by calling <xajax.tools.queue.create>.
	
	Returns:

	true - The queue was fully processed and is now empty.
	false - The queue processing was halted before the 
		queue was fully processed.
		
	Note:
	
	- Use <xajax.tools.queue.setWakeup> or call this function to 
	cause the queue processing to continue.

	- This will clear the associated timeout, this function is not 
	designed to be reentrant.
	
	- When an exception is caught, do nothing; if the debug module 
	is installed, it will catch the exception and handle it.
*/
xajax.tools.queue.process = function(theQ) {
	if (null != theQ.timeout) {
		clearTimeout(theQ.timeout);
		theQ.timeout = null;
	}
	var obj = xajax.tools.queue.pop(theQ);
	while (null != obj) {
		try {
			if (false == xajax.executeCommand(obj)) 
				return false;
		} catch (e) {
		}
		delete obj;
		
		obj = xajax.tools.queue.pop(theQ);
	}
	return true;
}

/*
	Function: xajax.tools.queue.push
	
	Push a new object into the tail of the buffer maintained by the
	specified queue object.
	
	Parameters: 
	
	theQ - (object):
		The queue in which you would like the object stored.
		
	obj - (object):
		The object you would like stored in the queue.
*/
xajax.tools.queue.push = function(theQ, obj) {
	var next = theQ.end + 1;
	if (next > theQ.size)
		next = 0;
	if (next != theQ.start) {				
		theQ.commands[theQ.end] = obj;
		theQ.end = next;
	} else
		throw { code: 10003 }
}

/*
	Function: xajax.tools.queue.pushFront
	
	Push a new object into the head of the buffer maintained by 
	the specified queue object.  This effectively pushes an object
	to the front of the queue... it will be processed first.
	
	Parameters: 
	
	theQ - (object):
		The queue in which you would like the object stored.
		
	obj - (object):
		The object you would like stored in the queue.
*/
xajax.tools.queue.pushFront = function(theQ, obj) {
	xajax.tools.queue.rewind(theQ);
	theQ.commands[theQ.start] = obj;
}

/*
	Function: xajax.tools.queue.pop
	
	Attempt to pop an object off the head of the queue.
	
	Parameters: 
	
	theQ - (object):
		The queue object you would like to modify.
		
	Returns:
	
	object - The object that was at the head of the queue or
		null if the queue was empty.
*/
xajax.tools.queue.pop = function(theQ) {
	var next = theQ.start;
	if (next == theQ.end)
		return null;
	next++;
	if (next > theQ.size)
		next = 0;
	var obj = theQ.commands[theQ.start];
	delete theQ.commands[theQ.start];
	theQ.start = next;
	return obj;
}

/*
	Class: xajax.responseProcessor
*/
xajax.responseProcessor = {};

/*
	Function: xajax.responseProcessor.xml
	
	Parse the response XML into a series of commands.  The commands
	are constructed by calling <xajax.tools.xml.parseAttributes> and 
	<xajax.tools.xml.parseChildren>.
	
	Parameters: 
	
	oRequest - (object):  The request context object.
*/
xajax.responseProcessor.xml = function(oRequest) {
	var xx = xajax;
	var xt = xx.tools;
	var xcb = xx.callback;
	var gcb = xcb.global;
	var lcb = oRequest.callback;
	
	var oRet = oRequest.returnValue;
	
	if (xt.arrayContainsValue(xx.responseSuccessCodes, oRequest.request.status)) {
		xcb.execute([gcb, lcb], 'onSuccess', oRequest);
		var seq = 0;
		if (oRequest.request.responseXML) {
			var responseXML = oRequest.request.responseXML;
			if (responseXML.documentElement) {
				oRequest.status.onProcessing();
				
				var child = responseXML.documentElement.firstChild;
				oRet = xt.xml.processFragment(child, seq, oRet, oRequest);
			}
		} 
		var obj = {};
		obj.fullName = 'Response Complete';
		obj.sequence = seq;
		obj.request = oRequest;
		obj.context = oRequest.context;
		obj.cmd = 'rcmplt';
		xt.queue.push(xx.response, obj);
		
		// do not re-start the queue if a timeout is set
		if (null == xx.response.timeout)
			xt.queue.process(xx.response);
	} else if (xt.arrayContainsValue(xx.responseRedirectCodes, oRequest.request.status)) {
		xcb.execute([gcb, lcb], 'onRedirect', oRequest);
		window.location = oRequest.request.getResponseHeader('location');
		xx.completeResponse(oRequest);
	} else if (xt.arrayContainsValue(xx.responseErrorsForAlert, oRequest.request.status)) {
		xcb.execute([gcb, lcb], 'onFailure', oRequest);
		xx.completeResponse(oRequest);
	}
	
	return oRet;
}

/*
	Class: xajax.js
	
	Contains the functions for javascript file and function
	manipulation.
*/
xajax.js = {}

/*
	Function: xajax.js.includeScriptOnce
	
	Add a reference to the specified script file if one does not
	already exist in the HEAD of the current document.
	
	This will effecitvely cause the script file to be loaded in
	the browser.

	Parameters: 
	
	fileName - (string):  The URI of the file.
	
	Returns:
	
	true - The reference exists or was added.
*/
xajax.js.includeScriptOnce = function(command) {
	command.fullName = 'includeScriptOnce';
	var fileName = command.data;
	// Check for existing script tag for this file.
	var oDoc = xajax.config.baseDocument;
    var loadedScripts = oDoc.getElementsByTagName('script');
	var iLen = loadedScripts.length;
    for (var i = 0; i < iLen; ++i) {
		var script = loadedScripts[i];
        if (script.src) {
			if (0 <= script.src.indexOf(fileName))
				return true;
		}
    }
	return xajax.js.includeScript(command);
}

/*
	Function: xajax.js.includeScript
	
	Adds a SCRIPT tag referencing the specified file.  This
	effectively causes the script to be loaded in the browser.
	
	Parameters: 
	
	command (object) - Xajax response object
	
	Returns:
	
	true - The reference was added.
*/
xajax.js.includeScript = function(command) {
	command.fullName = 'includeScript';
	var oDoc = xajax.config.baseDocument;
	var objHead = oDoc.getElementsByTagName('head');
	var objScript = oDoc.createElement('script');
	objScript.src = command.data;
	if ('undefined' == typeof command.type) objScript.type = 'text/javascript';
	else objScript.type = command.type;
	if ('undefined' != typeof command.type) objScript.setAttribute('id', command.elm_id);
	objHead[0].appendChild(objScript);
	return true;
}

/*
	Function: xajax.js.removeScript
	
	Locates a SCRIPT tag in the HEAD of the document which references
	the specified file and removes it.
	
	Parameters: 
	
	command (object) - Xajax response object
			
	Returns:
	
	true - The script was not found or was removed.
*/
xajax.js.removeScript = function(command) {
	command.fullName = 'removeScript';
	var fileName = command.data;
	var unload = command.unld;
	var oDoc = xajax.config.baseDocument;
	var loadedScripts = oDoc.getElementsByTagName('script');
	var iLen = loadedScripts.length;
	for (var i = 0; i < iLen; ++i) {
		var script = loadedScripts[i];
		if (script.src) {
			if (0 <= script.src.indexOf(fileName)) {
				if ('undefined' != typeof unload) {
					var args = {};
					args.data = unload;
					args.context = window;
					xajax.js.execute(args);
				}
				var parent = script.parentNode;
				parent.removeChild(script);
			}
		}
	}
	return true;
}

/*
	Function: xajax.js.sleep
	
	Causes the processing of items in the queue to be delayed
	for the specified amount of time.  This is an asynchronous
	operation, therefore, other operations will be given an
	opportunity to execute during this delay.
	
	Parameters:
	
	args - (object):  The response command containing the following
		parameters.
		- args.prop: The number of 10ths of a second to sleep.
	
	Returns:
	
	true - The sleep operation completed.
	false - The sleep time has not yet expired, continue sleeping.
*/
xajax.js.sleep = function(command) {
	command.fullName = 'sleep';
	// inject a delay in the queue processing
	// handle retry counter
	if (xajax.tools.queue.retry(command, command.prop)) {
		xajax.tools.queue.setWakeup(xajax.response, 100);
		return false;
	}
	// wake up, continue processing queue
	return true;
}

/*
	Function: xajax.js.confirmCommands
	
	Prompt the user with the specified text, if the user responds by clicking
	cancel, then skip the specified number of commands in the response command
	queue.  If the user clicks Ok, the command processing resumes normal
	operation.
	
	Parameters:
	
 	command (object) - xajax response object
 		
	Returns:
	
	true - The operation completed successfully.
*/
xajax.js.confirmCommands = function(command) {
	command.fullName = 'confirmCommands';
	var msg = command.data;
	var numberOfCommands = command.id;
	if (false == confirm(msg)) {
		while (0 < numberOfCommands) {
			xajax.tools.queue.pop(xajax.response);
			--numberOfCommands;
		}
	}
	return true;
}

/*
	Function: xajax.js.execute
	
	Execute the specified string of javascript code, using the current
	script context.
	
	Parameters:
	
	args - The response command object containing the following:
		- args.data: (string):  The javascript to be evaluated.
		- args.context: (object):  The javascript object that to be
			referenced as 'this' in the script.
			
	Returns:
	
	unknown - A value set by the script using 'returnValue = '
	true - If the script does not set a returnValue.
*/
xajax.js.execute = function(args) {
	args.fullName = 'execute Javascript';
	var returnValue = true;
	args.context.xajaxDelegateCall = function() {
		eval(args.data);
	}
	args.context.xajaxDelegateCall();
	return returnValue;
}

/*
	Function: xajax.js.waitFor
	
	Test for the specified condition, using the current script
	context; if the result is false, sleep for 1/10th of a
	second and try again.
	
	Parameters:
	
	args - The response command object containing the following:
	
		- args.data: (string):  The javascript to evaluate.
		- args.prop: (integer):  The number of 1/10ths of a
			second to wait before giving up.
		- args.context: (object):  The current script context object
			which is accessable in the javascript being evaulated
			via the 'this' keyword.
	
	Returns:
	
	false - The condition evaulates to false and the sleep time
		has not expired.
	true - The condition evaluates to true or the sleep time has
		expired.
*/
xajax.js.waitFor = function(args) {
	args.fullName = 'waitFor';

	var bResult = false;
	var cmdToEval = 'bResult = (';
	cmdToEval += args.data;
	cmdToEval += ');';
	try {
		args.context.xajaxDelegateCall = function() {
			eval(cmdToEval);
		}
		args.context.xajaxDelegateCall();
	} catch (e) {
	}
	if (false == bResult) {
		// inject a delay in the queue processing
		// handle retry counter
		if (xajax.tools.queue.retry(args, args.prop)) {
			xajax.tools.queue.setWakeup(xajax.response, 100);
			return false;
		}
		// give up, continue processing queue
	}
	return true;
}

/*
	Function: xajax.js.call
	
	Call a javascript function with a series of parameters using 
	the current script context.
	
	Parameters:
	
	args - The response command object containing the following:
		- args.data: (array):  The parameters to pass to the function.
		- args.func: (string):  The name of the function to call.
		- args.context: (object):  The current script context object
			which is accessable in the function name via the 'this'
			keyword.
			
	Returns:
	
	true - The call completed successfully.
*/
xajax.js.call = function(args) {
	args.fullName = 'call js function';
	
	var parameters = args.data;
	
	var scr = new Array();
	scr.push(args.func);
	scr.push('(');
	if ('undefined' != typeof parameters) {
		if ('object' == typeof parameters) {
			var iLen = parameters.length;
			if (0 < iLen) {
				scr.push('parameters[0]');
				for (var i = 1; i < iLen; ++i)
					scr.push(', parameters[' + i + ']');
			}
		}
	}
	scr.push(');');
	args.context.xajaxDelegateCall = function() {
		eval(scr.join(''));
	}
	args.context.xajaxDelegateCall();
	return true;
}

/*
	Function: xajax.js.setFunction

	Constructs the specified function using the specified javascript
	as the body of the function.
	
	Parameters:
	
	args - The response command object which contains the following:
	
		- args.func: (string):  The name of the function to construct.
		- args.data: (string):  The script that will be the function body.
		- args.context: (object):  The current script context object
			which is accessable in the script name via the 'this' keyword.
			
	Returns:
	
	true - The function was constructed successfully.
*/
xajax.js.setFunction = function(args) {
	args.fullName = 'setFunction';

	var code = new Array();
	code.push(args.func);
	code.push(' = function(');
	if ('object' == typeof args.prop) {
		var separator = '';
		for (var m in args.prop) {
			code.push(separator);
			code.push(args.prop[m]);
			separator = ',';
		}
	} else code.push(args.prop);
	code.push(') { ');
	code.push(args.data);
	code.push(' }');
	args.context.xajaxDelegateCall = function() {
		eval(code.join(''));
	}
	args.context.xajaxDelegateCall();
	return true;
}

/*
	Function: xajax.js.wrapFunction
	
	Construct a javascript function which will call the original function with 
	the same name, potentially executing code before and after the call to the
	original function.
	
	Parameters:
	
	args - (object):  The response command object which will contain 
		the following:
		
		- args.func: (string):  The name of the function to be wrapped.
		- args.prop: (string):  List of parameters used when calling the function.
		- args.data: (array):  The portions of code to be called before, after
			or even between calls to the original function.
		- args.context: (object):  The current script context object which is 
			accessable in the function name and body via the 'this' keyword.
			
	Returns:
	
	true - The wrapper function was constructed successfully.
*/
xajax.js.wrapFunction = function(args) {
	args.fullName = 'wrapFunction';

	var code = new Array();
	code.push(args.func);
	code.push(' = xajax.js.makeWrapper(');
	code.push(args.func);
	code.push(', args.prop, args.data, args.type, args.context);');
	args.context.xajaxDelegateCall = function() {
		eval(code.join(''));
	}
	args.context.xajaxDelegateCall();
	return true;
}

/*
	Function: xajax.js.makeWrapper
	

	Helper function used in the wrapping of an existing javascript function.

	Parameters:	
	
	origFun - (string):  The name of the original function.
	args - (string):  The list of parameters used when calling the function.
	codeBlocks - (array):  Array of strings of javascript code to be executed
		before, after and perhaps between calls to the original function.
	returnVariable - (string):  The name of the variable used to retain the
		return value from the call to the original function.
	context - (object):  The current script context object which is accessable
		in the function name and body via the 'this' keyword.
		
	Returns:
	
	object - The complete wrapper function.
*/
xajax.js.makeWrapper = function(origFun, args, codeBlocks, returnVariable, context) {
	var originalCall = '';
	if (0 < returnVariable.length) {
		originalCall += returnVariable;
		originalCall += ' = ';
	}
	var originalCall = 	'origFun(';
	originalCall += args;
	originalCall += '); ';
	
	var code = 'wrapper = function(';
	code += args;
	code += ') { ';
	
	if (0 < returnVariable.length) {
		code += ' var ';
		code += returnVariable;
		code += ' = null;';
	}
	var separator = '';
	var bLen = codeBlocks.length;
	for (var b = 0; b < bLen; ++b) {
		code += separator;
		code += codeBlocks[b];
		separator = originalCall;
	}
	if (0 < returnVariable.length) {
		code += ' return ';
		code += returnVariable;
		code += ';';
	}
	code += ' } ';
	
	var wrapper = null;
	context.xajaxDelegateCall = function() {
		eval(code);
	}
	context.xajaxDelegateCall();
	return wrapper;
}

/*
	Class: xajax.dom
*/
xajax.dom = {}

/*
	Function: xajax.dom.assign
	
	Assign an element's attribute to the specified value.
	
	Parameters:
	
	element - (object):  The HTML element to effect.
	property - (string):  The name of the attribute to set.
	data - (string):  The new value to be applied.
	
	Returns:
	
	true - The operation completed successfully.
*/
xajax.dom.assign = function(element, property, data) {
	if ('string' == typeof element)
		element = xajax.$(element);
	
	switch (property) {
	case 'innerHTML':
			element.innerHTML = data;
		break;
	case 'outerHTML':
		if ('undefined' == typeof element.outerHTML) {
			var r = xajax.config.baseDocument.createRange();
			r.setStartBefore(element);
			var df = r.createContextualFragment(data);
			element.parentNode.replaceChild(df, element);
		} else element.outerHTML = data;
		break;
	default:
		if (xajax.tools.willChange(element, property, data))
			eval('element.' + property + ' = data;');
		break;
	}
	return true;
}

/*
	Function: xajax.dom.append
	
	Append the specified value to an element's attribute.
	
	Parameters:
	
	element - (object):  The HTML element to effect.
	property - (string):  The name of the attribute to append to.
	data - (string):  The new value to be appended.
	
	Returns:
	
	true - The operation completed successfully.
*/
xajax.dom.append = function(element, property, data) {
	if ('string' == typeof element)
		element = xajax.$(element);
	
	eval('element.' + property + ' += data;');
	return true;
}

/*
	Function: xajax.dom.prepend
	
	Prepend the specified value to an element's attribute.
	
	Parameters:
	
	element - (object):  The HTML element to effect.
	property - (string):  The name of the attribute.
	data - (string):  The new value to be prepended.
	
	Returns:
	
	true - The operation completed successfully.
*/
xajax.dom.prepend = function(element, property, data) {
	if ('string' == typeof element)
		element = xajax.$(element);
	
	eval('element.' + property + ' = data + element.' + property);
	return true;
}

/*
	Function: xajax.dom.replace
	
	Search and replace the specified text.
	
	Parameters:
	
	element - (string or object):  The name of, or the element itself which is
		to be modified.
	sAttribute - (string):  The name of the attribute to be set.
	aData - (array):  The search text and replacement text.
	
	Returns:
	
	true - The operation completed successfully.
*/
xajax.dom.replace = function(element, sAttribute, aData) {
	var sSearch = aData['s'];
	var sReplace = aData['r'];
	
	if (sAttribute == 'innerHTML')
		sSearch = xajax.tools.getBrowserHTML(sSearch);
	
	if ('string' == typeof element)
		element = xajax.$(element);
	
	eval('var txt = element.' + sAttribute);
	
	var bFunction = false;
	if ('function' == typeof txt) {
        txt = txt.join('');
        bFunction = true;
    }
	
	var start = txt.indexOf(sSearch);
	if (start > -1) {
		var newTxt = [];
		while (start > -1) {
			var end = start + sSearch.length;
			newTxt.push(txt.substr(0, start));
			newTxt.push(sReplace);
			txt = txt.substr(end, txt.length - end);
			start = txt.indexOf(sSearch);
		}
		newTxt.push(txt);
		newTxt = newTxt.join('');
		
		if (bFunction) {
			eval('element.' + sAttribute + '=newTxt;');
		} else if (xajax.tools.willChange(element, sAttribute, newTxt)) {
			eval('element.' + sAttribute + '=newTxt;');
		}
	}
	return true;
}

/*
	Function: xajax.dom.remove
	
	Delete an element.
	
	Parameters:
	
	element - (string or object):  The name of, or the element itself which
		will be deleted.
		
	Returns:
	
	true - The operation completed successfully.
*/
xajax.dom.remove = function(element) {
	if ('string' == typeof element)
		element = xajax.$(element);
	
	if (element && element.parentNode && element.parentNode.removeChild)
		element.parentNode.removeChild(element);

	return true;
}

/*
	Function: xajax.dom.create
	
	Create a new element and append it to the specified parent element.
	
	Parameters:
	
	objParent - (string or object):  The name of, or the element itself
		which will contain the new element.
	sTag - (string):  The tag name for the new element.
	sId - (string):  The value to be assigned to the id attribute of
		the new element.
		
	Returns:
	
	true - The operation completed successfully.
*/
xajax.dom.create = function(objParent, sTag, sId) {
	if ('string' == typeof objParent)
		objParent = xajax.$(objParent);
	var target = xajax.config.baseDocument.createElement(sTag);
	target.setAttribute('id', sId);
	if (objParent)
		objParent.appendChild(target);
	return true;
}

/*
	Function: xajax.dom.insert
	
	Insert a new element before the specified element.

	Parameters:
	
	objSibling - (string or object):  The name of, or the element itself
		that will be used as the reference point for insertion.
	sTag - (string):  The tag name for the new element.
	sId - (string):  The value that will be assigned to the new element's
		id attribute.
	
	Returns:
	
	true - The operation completed successfully.
*/
xajax.dom.insert = function(objSibling, sTag, sId) {
	if ('string' == typeof objSibling)
		objSibling = xajax.$(objSibling);
	var target = xajax.config.baseDocument.createElement(sTag);
	target.setAttribute('id', sId);
	objSibling.parentNode.insertBefore(target, objSibling);
	return true;
}

/*
	Function: xajax.dom.insertAfter
	
	Insert a new element after the specified element.

	Parameters:
	
	objSibling - (string or object):  The name of, or the element itself
		that will be used as the reference point for insertion.
	sTag - (string):  The tag name for the new element.
	sId - (string):  The value that will be assigned to the new element's
		id attribute.
	
	Returns:
	
	true - The operation completed successfully.
*/
xajax.dom.insertAfter = function(objSibling, sTag, sId) {
	if ('string' == typeof objSibling)
		objSibling = xajax.$(objSibling);
	var target = xajax.config.baseDocument.createElement(sTag);
	target.setAttribute('id', sId);
	objSibling.parentNode.insertBefore(target, objSibling.nextSibling);
	return true;
}

/*
	Function: xajax.dom.contextAssign
	
	Assign a value to a named member of the current script context object.
	
	Parameters:
	
	args - (object):  The response command object which will contain the
		following:
		
		- args.prop: (string):  The name of the member to assign.
		- args.data: (string or object):  The value to assign to the member.
		- args.context: (object):  The current script context object which
			is accessable via the 'this' keyword.
	
	Returns:
	
	true - The operation completed successfully.
*/
xajax.dom.contextAssign = function(args) {
	args.fullName = 'context assign';

	var code = [];
	code.push('this.');
	code.push(args.prop);
	code.push(' = data;');
	code = code.join('');
	args.context.xajaxDelegateCall = function(data) {
		eval(code);
	}
	args.context.xajaxDelegateCall(args.data);
	return true;
}

/*
	Function: xajax.dom.contextAppend
	
	Appends a value to a named member of the current script context object.
	
	Parameters:
	
	args - (object):  The response command object which will contain the
		following:
		
		- args.prop: (string):  The name of the member to append to.
		- args.data: (string or object):  The value to append to the member.
		- args.context: (object):  The current script context object which
			is accessable via the 'this' keyword.
	
	Returns:
	
	true - The operation completed successfully.
*/
xajax.dom.contextAppend = function(args) {
	args.fullName = 'context append';

	var code = [];
	code.push('this.');
	code.push(args.prop);
	code.push(' += data;');
	code = code.join('');
	args.context.xajaxDelegateCall = function(data) {
		eval(code);
	}
	args.context.xajaxDelegateCall(args.data);
	return true;
}

/*
	Function: xajax.dom.contextPrepend
	
	Prepend a value to a named member of the current script context object.
	
	Parameters:
	
	args - (object):  The response command object which will contain the
		following:
		
		- args.prop: (string):  The name of the member to prepend to.
		- args.data: (string or object):  The value to prepend to the member.
		- args.context: (object):  The current script context object which
			is accessable via the 'this' keyword.
	
	Returns:
	
	true - The operation completed successfully.
*/
xajax.dom.contextPrepend = function(args) {
	args.fullName = 'context prepend';

	var code = [];
	code.push('this.');
	code.push(args.prop);
	code.push(' = data + this.');
	code.push(args.prop);
	code.push(';');
	code = code.join('');
	args.context.xajaxDelegateCall = function(data) {
		eval(code);
	}
	args.context.xajaxDelegateCall(args.data);
	return true;
}


/*
	Class: xajax.css
*/
xajax.css = {}

/*
	Function: xajax.css.add
	
	Add a LINK reference to the specified .css file if it does not
	already exist in the HEAD of the current document.
	
	Parameters:
	
	filename - (string):  The URI of the .css file to reference.

	media - (string):  The media type of the css file (print/screen/handheld,..)
	
	Returns:
	
	true - The operation completed successfully.
*/
xajax.css.add = function(fileName, media) {
	var oDoc = xajax.config.baseDocument;
	var oHeads = oDoc.getElementsByTagName('head');
	var oHead = oHeads[0];
	var oLinks = oHead.getElementsByTagName('link');
	
	var found = false;
	var iLen = oLinks.length;
	for (var i = 0; i < iLen && false == found; ++i)
		if (0 <= oLinks[i].href.indexOf(fileName) && oLinks[i].media == media)
			found = true;
	
	if (false == found) {
		var oCSS = oDoc.createElement('link');
		oCSS.rel = 'stylesheet';
		oCSS.type = 'text/css';
		oCSS.href = fileName;
		oCSS.media = media;
		oHead.appendChild(oCSS);
	}
	
	return true;
}

/*
	Function: xajax.css.remove
	
	Locate and remove a LINK reference from the current document's
	HEAD.
	
	Parameters:
	
	filename - (string):  The URI of the .css file.
	
	Returns:
	
	true - The operation completed successfully.
*/
xajax.css.remove = function(fileName, media) {
	var oDoc = xajax.config.baseDocument;
	var oHeads = oDoc.getElementsByTagName('head');
	var oHead = oHeads[0];
	var oLinks = oHead.getElementsByTagName('link');
	
	var i = 0;
	while (i < oLinks.length)
		if (0 <= oLinks[i].href.indexOf(fileName) && oLinks[i].media == media)
			oHead.removeChild(oLinks[i]);
		else ++i;
	
	return true;
}

/*
	Function: xajax.css.waitForCSS
	
	Attempt to detect when all .css files have been loaded once
	they are referenced by a LINK tag in the HEAD of the current
	document.
	
	Parameters:
	
	args - (object):  The response command object which will contain
		the following:
		
		- args.prop - (integer):  The number of 1/10ths of a second
			to wait before giving up.
	
	Returns:
	
	true - The .css files appear to be loaded.
	false - The .css files do not appear to be loaded and the timeout
		has not expired.
*/
xajax.css.waitForCSS = function(args) {
	var oDocSS = xajax.config.baseDocument.styleSheets;
	var ssEnabled = [];
	var iLen = oDocSS.length;
	for (var i = 0; i < iLen; ++i) {
		ssEnabled[i] = 0;
		try {
			ssEnabled[i] = oDocSS[i].cssRules.length;
		} catch (e) {
			try {
				ssEnabled[i] = oDocSS[i].rules.length;
			} catch (e) {
			}
		}
	}
	
	var ssLoaded = true;
	var iLen = ssEnabled.length;
	for (var i = 0; i < iLen; ++i)
		if (0 == ssEnabled[i])
			ssLoaded = false;
	
	if (false == ssLoaded) {
		// inject a delay in the queue processing
		// handle retry counter
		if (xajax.tools.queue.retry(args, args.prop)) {
			xajax.tools.queue.setWakeup(xajax.response, 10);
			return false;
		}
		// give up, continue processing queue
	}
	return true;
}


/*
	Class: xajax.forms
*/
xajax.forms = {}

/*
	Function: xajax.forms.getInput
	
	Create and return a form input element with the specified parameters.
	
	Parameters:
	
	type - (string):  The type of input element desired.
	name - (string):  The value to be assigned to the name attribute.
	id - (string):  The value to be assigned to the id attribute.
	
	Returns:
	
	object - The new input element.
*/
xajax.forms.getInput = function(type, name, id) {
	if ('undefined' == typeof window.addEventListener) {
		xajax.forms.getInput = function(type, name, id) {
			return xajax.config.baseDocument.createElement('<input type="'+type+'" name="'+name+'" id="'+id+'">');
		}
	} else {
		xajax.forms.getInput = function(type, name, id) {
			var oDoc = xajax.config.baseDocument;
			var Obj = oDoc.createElement('input');
			Obj.setAttribute('type', type);
			Obj.setAttribute('name', name);
			Obj.setAttribute('id', id);
			return Obj;
		}
	}
	return xajax.forms.getInput(type, name, id);
}

/*
	Function: xajax.forms.createInput
	
	Create a new input element under the specified parent.
	
	Parameters:
	
	objParent - (string or object):  The name of, or the element itself
		that will be used as the reference for the insertion.
	sType - (string):  The value to be assigned to the type attribute.
	sName - (string):  The value to be assigned to the name attribute.
	sId - (string):  The value to be assigned to the id attribute.
	
	Returns:
	
	true - The operation completed successfully.
*/
xajax.forms.createInput = function(command) {
	command.fullName = 'createInput';
	var objParent = command.id;

	var sType = command.type;
	var sName = command.data;
	var sId = command.prop;
	if ('string' == typeof objParent)
		objParent = xajax.$(objParent);
	var target = xajax.forms.getInput(sType, sName, sId);
	if (objParent && target)
	{
		objParent.appendChild(target);
	}
	return true;
}

/*
	Function: xajax.forms.insertInput
	
	Insert a new input element before the specified element.
	
	Parameters:
	
	objSibling - (string or object):  The name of, or the element itself
		that will be used as the reference for the insertion.
	sType - (string):  The value to be assigned to the type attribute.
	sName - (string):  The value to be assigned to the name attribute.
	sId - (string):  The value to be assigned to the id attribute.
	
	Returns:
	
	true - The operation completed successfully.
*/
xajax.forms.insertInput = function(command) {
	command.fullName = 'insertInput';
	var objSibling = command.id;
	var sType = command.type;
	var sName = command.data;
	var sId = command.prop;
	if ('string' == typeof objSibling)
		objSibling = xajax.$(objSibling);
	var target = xajax.forms.getInput(sType, sName, sId);
	if (target && objSibling && objSibling.parentNode)
		objSibling.parentNode.insertBefore(target, objSibling);
	return true;
}

/*
	Function: xajax.forms.insertInputAfter

	Insert a new input element after the specified element.
	
	Parameters:
	
	objSibling - (string or object):  The name of, or the element itself
		that will be used as the reference for the insertion.
	sType - (string):  The value to be assigned to the type attribute.
	sName - (string):  The value to be assigned to the name attribute.
	sId - (string):  The value to be assigned to the id attribute.
	
	Returns:
	
	true - The operation completed successfully.
*/
xajax.forms.insertInputAfter = function(command) {
	command.fullName = 'insertInputAfter';
	var objSibling = command.id;
	var sType = command.type;
	var sName = command.data;
	var sId = command.prop;
	if ('string' == typeof objSibling)
		objSibling = xajax.$(objSibling);
	var target = xajax.forms.getInput(sType, sName, sId);
	if (target && objSibling && objSibling.parentNode)
		objSibling.parentNode.insertBefore(target, objSibling.nextSibling);
	return true;
}

/*
	Class: xajax.events
*/
xajax.events = {}

/*
	Function: xajax.events.setEvent
	
	Set an event handler.
	
	Parameters:
	
	command - (object): Response command object.
	- id: Element ID
	- prop: Event
	- data: Code	

	Returns:
	
	true - The operation completed successfully.
*/
xajax.events.setEvent = function(command) {
	command.fullName = 'addEvent';
	var element = command.id;
	var sEvent = command.prop;
	var code = command.data;
	if ('string' == typeof element)
		element = xajax.$(element);
	sEvent = xajax.tools.addOnPrefix(sEvent);
	code = xajax.tools.doubleQuotes(code);
	eval('element.' + sEvent + ' = function() { ' + code + '; }');
	return true;
}

/*
	Function: xajax.events.addHandler
	
	Add an event handler to the specified element.
	
	Parameters:
	
	element - (string or object):  The name of, or the element itself
		which will have the event handler assigned.
	sEvent - (string):  The name of the event.
	fun - (string):  The function to be called.
	
	Returns:
	
	true - The operation completed successfully.
*/
xajax.events.addHandler = function(element, sEvent, fun) {
	if (window.addEventListener) {
		xajax.events.addHandler = function(command) {
			command.fullName = 'addHandler';
			var element = command.id;
			var sEvent = command.prop;
			var fun = command.data;
			if ('string' == typeof element)
				element = xajax.$(element);
			sEvent = xajax.tools.stripOnPrefix(sEvent);
			eval('element.addEventListener("' + sEvent + '", ' + fun + ', false);');
			return true;
		}
	} else {
		xajax.events.addHandler = function(command) {
			command.fullName = 'addHandler';
			var element = command.id;
			var sEvent = command.prop;
			var fun = command.data;
			if ('string' == typeof element)
				element = xajax.$(element);
			sEvent = xajax.tools.addOnPrefix(sEvent);
			eval('element.attachEvent("' + sEvent + '", ' + fun + ', false);');
			return true;
		}
	}
	return xajax.events.addHandler(element, sEvent, fun);
}

/*
	Function: xajax.events.removeHandler
	
	Remove an event handler from an element.
	
	Parameters:
	
	element - (string or object):  The name of, or the element itself which
		will have the event handler removed.
	event - (string):  The name of the event for which this handler is 
		associated.
	fun - The function to be removed.
	
	Returns:
	
	true - The operation completed successfully.
*/
xajax.events.removeHandler = function(element, sEvent, fun) {
	if (window.removeEventListener) {
		xajax.events.removeHandler = function(command) {
			command.fullName = 'removeHandler';
			var element = command.id;
			var sEvent = command.prop;
			var fun = command.data;
			if ('string' == typeof element)
				element = xajax.$(element);
			sEvent = xajax.tools.stripOnPrefix(sEvent);
			eval('element.removeEventListener("' + sEvent + '", ' + fun + ', false);');
			return true;
		}
	} else {
		xajax.events.removeHandler = function(command) {
			command.fullName = 'removeHandler';
			var element = command.id;
			var sEvent = command.prop;
			var fun = command.data;
			if ('string' == typeof element)
				element = xajax.$(element);
			sEvent = xajax.tools.addOnPrefix(sEvent);
			eval('element.detachEvent("' + sEvent + '", ' + fun + ', false);');
			return true;
		}
	}
	return xajax.events.removeHandler(element, sEvent, fun);
}

/*
	Class: xajax.callback
*/
xajax.callback = {}

/*
	Function: xajax.callback.create
	
	Create a blank callback object.  Two optional arguments let you 
	set the delay time for the onResponseDelay and onExpiration events.
	
	Returns:
	
	object - The callback object.
*/
xajax.callback.create = function() {
	var xx = xajax;
	var xc = xx.config;
	var xcb = xx.callback;
	
	var oCB = {}
	oCB.timers = {};
	
	oCB.timers.onResponseDelay = xcb.setupTimer(
		(arguments.length > 0) 
			? arguments[0] 
			: xc.defaultResponseDelayTime);
	
	oCB.timers.onExpiration = xcb.setupTimer(
		(arguments.length > 1) 
			? arguments[1] 
			: xc.defaultExpirationTime);

	oCB.onRequest = null;
	oCB.onResponseDelay = null;
	oCB.onExpiration = null;
	oCB.beforeResponseProcessing = null;
	oCB.onFailure = null;
	oCB.onRedirect = null;
	oCB.onSuccess = null;
	oCB.onComplete = null;
	
	return oCB;
}

/*
	Function: xajax.callback.setupTimer
	
	Create a timer to fire an event in the future.  This will
	be used fire the onRequestDelay and onExpiration events.
	
	Parameters:
	
	iDelay - (integer):  The amount of time in milliseconds to delay.
	
	Returns:
	
	object - A callback timer object.
*/
xajax.callback.setupTimer = function(iDelay)
{
	return { timer: null, delay: iDelay };
}

/*
	Function: xajax.callback.clearTimer
	
	Clear a callback timer for the specified function.
	
	Parameters:
	
	oCallback - (object):  The callback object (or objects) that
		contain the specified function timer to be cleared.
	sFunction - (string):  The name of the function associated
		with the timer to be cleared.
*/
xajax.callback.clearTimer = function(oCallback, sFunction)
{
	if ('undefined' != typeof oCallback.timers) {
		if ('undefined' != typeof oCallback.timers[sFunction]) {
			clearTimeout(oCallback.timers[sFunction].timer);
		}
	} else if ('object' == typeof oCallback) {
		var iLen = oCallback.length;
		for (var i = 0; i < iLen; ++i)
			xajax.callback.clearTimer(oCallback[i], sFunction);
	}
}

/*
	Function: xajax.callback.execute
	
	Execute a callback event.
	
	Parameters:
	
	oCallback - (object):  The callback object (or objects) which 
		contain the event handlers to be executed.
	sFunction - (string):  The name of the event to be triggered.
	args - (object):  The request object for this request.
*/
xajax.callback.execute = function(oCallback, sFunction, args) {
	if ('undefined' != typeof oCallback[sFunction]) {
		var func = oCallback[sFunction];
		if ('function' == typeof func) {
			if ('undefined' != typeof oCallback.timers[sFunction]) {
				oCallback.timers[sFunction].timer = setTimeout(function() { 
					func(args);
				}, oCallback.timers[sFunction].delay);
			}
			else {
				func(args);
			}
		}
	} else if ('object' == typeof oCallback) {
		var iLen = oCallback.length;
		for (var i = 0; i < iLen; ++i)
			xajax.callback.execute(oCallback[i], sFunction, args);
	}
}

/*
	Class: xajax.callback.global
	
	The global callback object which is active for every request.
*/
xajax.callback.global = xajax.callback.create();

/*
	Class: xajax
*/

/*
	Object: xajax.response
	
	The response queue that holds response commands, once received
	from the server, until they are processed.
*/	
xajax.response = xajax.tools.queue.create(xajax.config.responseQueueSize);

/*
	Object: responseSuccessCodes
	
	This array contains a list of codes which will be returned from the 
	server upon successful completion of the server portion of the 
	request.
	
	These values should match those specified in the HTTP standard.
*/
xajax.responseSuccessCodes = ['0', '200'];

// 10.4.1 400 Bad Request
// 10.4.2 401 Unauthorized
// 10.4.3 402 Payment Required
// 10.4.4 403 Forbidden
// 10.4.5 404 Not Found
// 10.4.6 405 Method Not Allowed
// 10.4.7 406 Not Acceptable
// 10.4.8 407 Proxy Authentication Required
// 10.4.9 408 Request Timeout
// 10.4.10 409 Conflict
// 10.4.11 410 Gone
// 10.4.12 411 Length Required
// 10.4.13 412 Precondition Failed
// 10.4.14 413 Request Entity Too Large
// 10.4.15 414 Request-URI Too Long
// 10.4.16 415 Unsupported Media Type
// 10.4.17 416 Requested Range Not Satisfiable
// 10.4.18 417 Expectation Failed
// 10.5 Server Error 5xx
// 10.5.1 500 Internal Server Error
// 10.5.2 501 Not Implemented
// 10.5.3 502 Bad Gateway
// 10.5.4 503 Service Unavailable
// 10.5.5 504 Gateway Timeout
// 10.5.6 505 HTTP Version Not Supported

/*
	Object: responseErrorsForAlert
	
	This array contains a list of status codes returned by
	the server to indicate that the request failed for some
	reason.
*/
xajax.responseErrorsForAlert = ['400','401','402','403','404','500','501','502','503'];

// 10.3.1 300 Multiple Choices
// 10.3.2 301 Moved Permanently
// 10.3.3 302 Found
// 10.3.4 303 See Other
// 10.3.5 304 Not Modified
// 10.3.6 305 Use Proxy
// 10.3.7 306 (Unused)
// 10.3.8 307 Temporary Redirect

/*
	Object: responseRedirectCodes
	
	An array of status codes returned from the server to
	indicate a request for redirect to another URL.
	
	Typically, this is used by the server to send the browser
	to another URL.  This does not typically indicate that
	the xajax request should be sent to another URL.
*/
xajax.responseRedirectCodes = ['301','302','307'];

/*
	Class: xajax.command
	
	The object that manages commands and command handlers.
*/
if ('undefined' == typeof xajax.command)
	xajax.command = {};

/*
	Function: xajax.command.create 
	
	Creates a new command (object) that will be populated with
	command parameters and eventually passed to the command handler.
*/
xajax.command.create = function(sequence, request, context) {
	var newCmd = {};
	newCmd.cmd = '*';
	newCmd.fullName = '* unknown command name *';
	newCmd.sequence = sequence;
	newCmd.request = request;
	newCmd.context = context;
	return newCmd;
}

/*
	Class: xajax.command.handler
	
	The object that manages command handlers.
*/
if ('undefined' == typeof xajax.command.handler)
	xajax.command.handler = {};

/*
	Object: handlers
	
	An array that is used internally in the xajax.command.handler object
	to keep track of command handlers that have been registered.
*/
if ('undefined' == typeof xajax.command.handler.handlers)
	xajax.command.handler.handlers = [];

/*
	Function: xajax.command.handler.register
	
	Registers a new command handler.
*/
xajax.command.handler.register = function(shortName, func) {
	xajax.command.handler.handlers[shortName] = func;
}

/*
	Function: xajax.command.handler.unregister
	
	Unregisters and returns a command handler.
	
	Parameters:
		shortName - (string): The name of the command handler.
		
	Returns:
		func - (function): The unregistered function.
*/
xajax.command.handler.unregister = function(shortName) {
	var func = xajax.command.handler.handlers[shortName];
	delete xajax.command.handler.handlers[shortName];
	return func;
}

/*
	Function: xajax.command.handler.isRegistered
	
	
	Parameters:
		command - (object):
			- cmd: The Name of the function.

	Returns:

	boolean - (true or false): depending on whether a command handler has 
	been created for the specified command (object).
		
*/
xajax.command.handler.isRegistered = function(command) {
	var shortName = command.cmd;
	if (xajax.command.handler.handlers[shortName])
		return true;
	return false;
}

/*
	Function: xajax.command.handler.call
	
	Calls the registered command handler for the specified command
	(you should always check isRegistered before calling this function)

	Parameters:
		command - (object):
			- cmd: The Name of the function.

	Returns:
		true - (boolean) :
*/
xajax.command.handler.call = function(command) {
	var shortName = command.cmd;
	return xajax.command.handler.handlers[shortName](command);
}

xajax.command.handler.register('rcmplt', function(args) {
	xajax.completeResponse(args.request);
	return true;
});

xajax.command.handler.register('css', function(args) {
	args.fullName = 'includeCSS';
	if ('undefined' == typeof args.media)
		args.media = 'screen';
	return xajax.css.add(args.data, args.media);
});
xajax.command.handler.register('rcss', function(args) {
	args.fullName = 'removeCSS';
	if ('undefined' == typeof args.media)
		args.media = 'screen';
	return xajax.css.remove(args.data, args.media);
});
xajax.command.handler.register('wcss', function(args) {
	args.fullName = 'waitForCSS';
	return xajax.css.waitForCSS(args);
});

xajax.command.handler.register('as', function(args) {
	args.fullName = 'assign/clear';
	try {
		return xajax.dom.assign(args.target, args.prop, args.data);
	} catch (e) {
		// do nothing, if the debug module is installed it will
		// catch and handle the exception
	}
	return true;
});
xajax.command.handler.register('ap', function(args) {
	args.fullName = 'append';
	return xajax.dom.append(args.target, args.prop, args.data);
});
xajax.command.handler.register('pp', function(args) {
	args.fullName = 'prepend';
	return xajax.dom.prepend(args.target, args.prop, args.data);
});
xajax.command.handler.register('rp', function(args) {
	args.fullName = 'replace';
	return xajax.dom.replace(args.id, args.prop, args.data);
});
xajax.command.handler.register('rm', function(args) {
	args.fullName = 'remove';
	return xajax.dom.remove(args.id);
});
xajax.command.handler.register('ce', function(args) {
	args.fullName = 'create';
	return xajax.dom.create(args.id, args.data, args.prop);
});
xajax.command.handler.register('ie', function(args) {
	args.fullName = 'insert';
	return xajax.dom.insert(args.id, args.data, args.prop);
});
xajax.command.handler.register('ia', function(args) {
	args.fullName = 'insertAfter';
	return xajax.dom.insertAfter(args.id, args.data, args.prop);
});

xajax.command.handler.register('c:as', xajax.dom.contextAssign);
xajax.command.handler.register('c:ap', xajax.dom.contextAppend);
xajax.command.handler.register('c:pp', xajax.dom.contextPrepend);

xajax.command.handler.register('s', xajax.js.sleep);
xajax.command.handler.register('ino', xajax.js.includeScriptOnce);
xajax.command.handler.register('in', xajax.js.includeScript);
xajax.command.handler.register('rjs', xajax.js.removeScript);
xajax.command.handler.register('wf', xajax.js.waitFor);
xajax.command.handler.register('js', xajax.js.execute);
xajax.command.handler.register('jc', xajax.js.call);
xajax.command.handler.register('sf', xajax.js.setFunction);
xajax.command.handler.register('wpf', xajax.js.wrapFunction);
xajax.command.handler.register('al', function(args) {
	args.fullName = 'alert';
	alert(args.data);
	return true;
});
xajax.command.handler.register('cc', xajax.js.confirmCommands);

xajax.command.handler.register('ci', xajax.forms.createInput);
xajax.command.handler.register('ii', xajax.forms.insertInput);
xajax.command.handler.register('iia', xajax.forms.insertInputAfter);

xajax.command.handler.register('ev', xajax.events.setEvent);

xajax.command.handler.register('ah', xajax.events.addHandler);
xajax.command.handler.register('rh', xajax.events.removeHandler);

xajax.command.handler.register('dbg', function(args) {
	args.fullName = 'debug message';
	return true;
});

/*
	Function: xajax.initializeRequest
	
	Initialize a request object, populating default settings, where
	call specific settings are not already provided.
	
	Parameters:
	
	oRequest - (object):  An object that specifies call specific settings
		that will, in addition, be used to store all request related
		values.  This includes temporary values used internally by xajax.
*/
xajax.initializeRequest = function(oRequest) {
	var xx = xajax;
	var xc = xx.config;
	
	oRequest.append = function(opt, def) {
		if ('undefined' != typeof this[opt]) {
			for (var itmName in def)
				if ('undefined' == typeof this[opt][itmName])
					this[opt][itmName] = def[itmName];
		} else this[opt] = def;
	}
	
	oRequest.append('commonHeaders', xc.commonHeaders);
	oRequest.append('postHeaders', xc.postHeaders);
	oRequest.append('getHeaders', xc.getHeaders);

	oRequest.set = function(option, defaultValue) {
		if ('undefined' == typeof this[option])
			this[option] = defaultValue;
	}
	
	oRequest.set('statusMessages', xc.statusMessages);
	oRequest.set('waitCursor', xc.waitCursor);
	oRequest.set('mode', xc.defaultMode);
	oRequest.set('method', xc.defaultMethod);
	oRequest.set('URI', xc.requestURI);
	oRequest.set('httpVersion', xc.defaultHttpVersion);
	oRequest.set('contentType', xc.defaultContentType);
	oRequest.set('retry', xc.defaultRetry);
	oRequest.set('returnValue', xc.defaultReturnValue);
	oRequest.set('maxObjectDepth', xc.maxObjectDepth);
	oRequest.set('maxObjectSize', xc.maxObjectSize);
	oRequest.set('context', window);
	
	var xcb = xx.callback;
	var gcb = xcb.global;
	var lcb = xcb.create();
	
	lcb.take = function(frm, opt) {
		if ('undefined' != typeof frm[opt]) {
			lcb[opt] = frm[opt];
			lcb.hasEvents = true;
		}
		delete frm[opt];
	}
	
	lcb.take(oRequest, 'onRequest');
	lcb.take(oRequest, 'onResponseDelay');
	lcb.take(oRequest, 'onExpiration');
	lcb.take(oRequest, 'beforeResponseProcessing');
	lcb.take(oRequest, 'onFailure');
	lcb.take(oRequest, 'onRedirect');
	lcb.take(oRequest, 'onSuccess');
	lcb.take(oRequest, 'onComplete');
	
	if ('undefined' != typeof oRequest.callback) {
		if (lcb.hasEvents)
			oRequest.callback = [oRequest.callback, lcb];
	} else
		oRequest.callback = lcb;
	
	oRequest.status = (oRequest.statusMessages) 
		? xc.status.update() 
		: xc.status.dontUpdate();
	
	oRequest.cursor = (oRequest.waitCursor) 
		? xc.cursor.update() 
		: xc.cursor.dontUpdate();
	
	oRequest.method = oRequest.method.toUpperCase();
	if ('GET' != oRequest.method)
		oRequest.method = 'POST';	// W3C: Method is case sensitive
	
	oRequest.requestRetry = oRequest.retry;
	
	oRequest.append('postHeaders', {
		'content-type': oRequest.contentType
		});
		
	delete oRequest['append'];
	delete oRequest['set'];
	delete oRequest['take'];

	if ('undefined' == typeof oRequest.URI)
		throw { code: 10005 }
}

/*
	Function: xajax.processParameters
	
	Processes request specific parameters and generates the temporary 
	variables needed by xajax to initiate and process the request.
	
	Parameters:
	
	oRequest - A request object, created initially by a call to
		<xajax.initializeRequest>
	
	Note:
	This is called once per request; upon a request failure, this 
	will not be called for additional retries.
*/
xajax.processParameters = function(oRequest) {
	var xx = xajax;
	var xt = xx.tools;
	
	var rd = [];
	
	var separator = '';
	for (var sCommand in oRequest.functionName) {
		if ('constructor' != sCommand) {
			rd.push(separator);
			rd.push(sCommand);
			rd.push('=');
			rd.push(encodeURIComponent(oRequest.functionName[sCommand]));
			separator = '&';
		}
	}
	var dNow = new Date();
	rd.push('&xjxr=');
	rd.push(dNow.getTime());
	delete dNow;

	if (oRequest.parameters) {
		var i = 0;
		var iLen = oRequest.parameters.length;
		while (i < iLen) {
			var oVal = oRequest.parameters[i];
			if ('object' == typeof oVal && null != oVal) {
				try {
					var oGuard = {};
					oGuard.depth = 0;
					oGuard.maxDepth = oRequest.maxObjectDepth;
					oGuard.size = 0;
					oGuard.maxSize = oRequest.maxObjectSize;
					oVal = xt._objectToXML(oVal, oGuard);
				} catch (e) {
					oVal = '';
					// do nothing, if the debug module is installed
					// it will catch the exception and handle it
				}
				rd.push('&xjxargs[]=');
				oVal = encodeURIComponent(oVal);
				rd.push(oVal);
				++i;
			} else {
				rd.push('&xjxargs[]=');
				oVal = xt._escape(oVal);
				if ('undefined' == typeof oVal || null == oVal) {
					rd.push('*');
				} else {
					var sType = typeof oVal;
					if ('string' == sType)
						rd.push('S');
					else if ('boolean' == sType)
						rd.push('B');
					else if ('number' == sType)
						rd.push('N');
					oVal = encodeURIComponent(oVal);
					rd.push(oVal);
				}
				++i;
			}
		}
	}
	
	oRequest.requestURI = oRequest.URI;
	
	if ('GET' == oRequest.method) {
		oRequest.requestURI += oRequest.requestURI.indexOf('?')== -1 ? '?' : '&';
		oRequest.requestURI += rd.join('');
		rd = [];
	}
	
	oRequest.requestData = rd.join('');
}

/*
	Function: xajax.prepareRequest
	
	Prepares the XMLHttpRequest object for this xajax request.
	
	Parameters:
	
	oRequest - (object):  An object created by a call to <xajax.initializeRequest>
		which already contains the necessary parameters and temporary variables
		needed to initiate and process a xajax request.
	
	Note: 
	This is called each time a request object is being prepared for a 
	call to the server.  If the request is retried, the request must be
	prepared again.
*/
xajax.prepareRequest = function(oRequest) {
	var xx = xajax;
	var xt = xx.tools;
	
	oRequest.request = xt.getRequestObject();
	
	oRequest.setRequestHeaders = function(headers) {
	 	if ('object' == typeof headers) {
			for (var optionName in headers)
				this.request.setRequestHeader(optionName, headers[optionName]);
		}
	}
	oRequest.setCommonRequestHeaders = function() {
		this.setRequestHeaders(this.commonHeaders);
	}
	oRequest.setPostRequestHeaders = function() {
		this.setRequestHeaders(this.postHeaders);
	}
	oRequest.setGetRequestHeaders = function() {
		this.setRequestHeaders(this.getHeaders);
	}
	
	if ('asynchronous' == oRequest.mode) {
		// references inside this function should be expanded
		// IOW, don't use shorthand references like xx for xajax
		oRequest.request.onreadystatechange = function() {
			if (oRequest.request.readyState != 4)
				return;
			xajax.responseReceived(oRequest);
		}
		oRequest.finishRequest = function() {
			return this.returnValue;
		}
	} else {
		oRequest.finishRequest = function() {
			return xajax.responseReceived(oRequest);
		}
	}
	
	if ('undefined' != typeof oRequest.userName && 'undefined' != typeof oRequest.password) {
		oRequest.open = function() {
			this.request.open(
				this.method, 
				this.requestURI, 
				'asynchronous' == this.mode, 
				oRequest.userName, 
				oRequest.password);
		}
	} else {
		oRequest.open = function() {
			this.request.open(
				this.method, 
				this.requestURI, 
				'asynchronous' == this.mode);
		}
	}
	
	if ('POST' == oRequest.method) {	// W3C: Method is case sensitive
		oRequest.applyRequestHeaders = function() {
			this.setCommonRequestHeaders();
			try {
				this.setPostRequestHeaders();
			} catch (e) {
				this.method = 'GET';
				this.requestURI += this.requestURI.indexOf('?')== -1 ? '?' : '&';
				this.requestURI += this.requestData;
				this.requestData = '';
				if (0 == this.requestRetry) this.requestRetry = 1;
				throw e;
			}
		}
	} else {
		oRequest.applyRequestHeaders = function() {
			this.setCommonRequestHeaders();
			this.setGetRequestHeaders();
		}
	}
}

/*
	Function: xajax.request
	
	Initiates a request to the server.

	Parameters:
	
	functionName - (object):  An object containing the name of the function to execute
	on the server. The standard request is: {xjxfun:'function_name'}
		
	oRequest - (object, optional):  A request object which 
		may contain call specific parameters.  This object will be
		used by xajax to store all the request parameters as well
		as temporary variables needed during the processing of the
		request.
	
*/
xajax.request = function() {
	var numArgs = arguments.length;
	if (0 == numArgs)
		return false;
	
	var oRequest = {}
	if (1 < numArgs)
		oRequest = arguments[1];
	
	oRequest.functionName = arguments[0];
	
	var xx = xajax;
	
	xx.initializeRequest(oRequest);
	xx.processParameters(oRequest);
	while (0 < oRequest.requestRetry) {
		try {
			--oRequest.requestRetry;
			xx.prepareRequest(oRequest);
			return xx.submitRequest(oRequest);
		} catch (e) {
			xajax.callback.execute(
				[xajax.callback.global, oRequest.callback], 
				'onFailure', oRequest);
			if (0 == oRequest.requestRetry)
				throw e;
		}
	}
}

/*
	Function: xajax.call
	
	Initiates a call to the server.
	
	Parameters:
	
	sFunctionName - (string):  The name of the function to execute
		on the server.
		
	oRequestOptions - (object, optional):  A request object which 
		may contain call specific parameters.  This object will be
		used by xajax to store all the request parameters as well
		as temporary variables needed during the processing of the
		request.
		
	Returns:
	
	unknown - For asynchronous calls, the return value will always
		be the value set for <xajax.config.defaultReturnValue>
*/
xajax.call = function() {
	var numArgs = arguments.length;
	if (0 == numArgs)
		return false;
	
	var oRequest = {}
	if (1 < numArgs)
		oRequest = arguments[1];
	
	oRequest.functionName = { xjxfun: arguments[0] };
	
	var xx = xajax;
	
	xx.initializeRequest(oRequest);
	xx.processParameters(oRequest);
	
	while (0 < oRequest.requestRetry) {
		try {
			--oRequest.requestRetry;
			xx.prepareRequest(oRequest);
			return xx.submitRequest(oRequest);
		} catch (e) {
			xajax.callback.execute(
				[xajax.callback.global, oRequest.callback], 
				'onFailure', oRequest);
			if (0 == oRequest.requestRetry)
				throw e;
		}
	}
}

/*
	Function: xajax.submitRequest
	
	Create a request object and submit the request using the specified
	request type; all request parameters should be finalized by this 
	point.  Upon failure of a POST, this function will fall back to a 
	GET request.
	
	Parameters:
	
	oRequest - (object):  The request context object.
*/
xajax.submitRequest = function(oRequest) {
	oRequest.status.onRequest();
	
	var xcb = xajax.callback;
	var gcb = xcb.global;
	var lcb = oRequest.callback;
	
	xcb.execute([gcb, lcb], 'onResponseDelay', oRequest);
	xcb.execute([gcb, lcb], 'onExpiration', oRequest);
	xcb.execute([gcb, lcb], 'onRequest', oRequest);
	
	oRequest.open();
	oRequest.applyRequestHeaders();

	oRequest.cursor.onWaiting();
	oRequest.status.onWaiting();
	
	xajax._internalSend(oRequest);
	
	// synchronous mode causes response to be processed immediately here
	return oRequest.finishRequest();
}

/*
	Function: xajax._internalSend
	
	This function is used internally by xajax to initiate a request to the
	server.
	
	Parameters:
	
	oRequest - (object):  The request context object.
*/
xajax._internalSend = function(oRequest) {
	// this may block if synchronous mode is selected
	oRequest.request.send(oRequest.requestData);
}

/*
	Function: xajax.abortRequest
	
	Abort the request.
	
	Parameters:
	
	oRequest - (object):  The request context object.
*/
xajax.abortRequest = function(oRequest)
{
	oRequest.aborted = true;
	oRequest.request.abort();
	xajax.completeResponse(oRequest);
}

/*
	Function: xajax.responseReceived
	
	Process the response.
	
	Parameters:
	
	oRequest - (object):  The request context object.
*/
xajax.responseReceived = function(oRequest) {
	var xx = xajax;
	var xcb = xx.callback;
	var gcb = xcb.global;
	var lcb = oRequest.callback;
	// sometimes the responseReceived gets called when the
	// request is aborted
	if (oRequest.aborted)
		return;
	
	xcb.clearTimer([gcb, lcb], 'onExpiration');
	xcb.clearTimer([gcb, lcb], 'onResponseDelay');
	
	xcb.execute([gcb, lcb], 'beforeResponseProcessing', oRequest);
	
	var fProc = xx.getResponseProcessor(oRequest);
	if ('undefined' == typeof fProc) {
		xcb.execute([gcb, lcb], 'onFailure', oRequest);
		xx.completeResponse(oRequest);
		return;
	}
	
	return fProc(oRequest);
}

/*
	Function: xajax.getResponseProcessor
	
	This function attempts to determine, based on the content type of the
	reponse, what processor should be used for handling the response data.
	
	The default xajax response will be text/xml which will invoke the
	xajax xml response processor.  Other response processors may be added
	in the future.  The user can specify their own response processor on
	a call by call basis.
	
	Parameters:
	
	oRequest - (object):  The request context object.
*/
xajax.getResponseProcessor = function(oRequest) {
	var fProc;
	
	if ('undefined' == typeof oRequest.responseProcessor) {
		var cTyp = oRequest.request.getResponseHeader('content-type');
		if (cTyp) {
			if (0 <= cTyp.indexOf('text/xml')) {
				fProc = xajax.responseProcessor.xml;
	//		} else if (0 <= cTyp.indexOf('application/json')) {
	//			fProc = xajax.responseProcessor.json;
			}
		}
	} else fProc = oRequest.responseProcessor;
	
	return fProc;
}

/*
	Function: xajax.executeCommand 
	
	Perform a lookup on the command specified by the response command
	object passed in the first parameter.  If the command exists, the
	function checks to see if the command references a DOM object by
	ID; if so, the object is located within the DOM and added to the 
	command data.  The command handler is then called.
	
	If the command handler returns true, it is assumed that the command 
	completed successfully.  If the command handler returns false, then the
	command is considered pending; xajax enters a wait state.  It is up
	to the command handler to set an interval, timeout or event handler
	which will restart the xajax response processing.
	
	Parameters:
	
	obj - (object):  The response command to be executed.
	
	Returns:
	
	true - The command completed successfully.
	false - The command signalled that it needs to pause processing.
*/
xajax.executeCommand = function(command) {
	if (xajax.command.handler.isRegistered(command)) {
		// it is important to grab the element here as the previous command
		// might have just created the element
		if (command.id)
			command.target = xajax.$(command.id);
		// process the command
		if (false == xajax.command.handler.call(command)) {
			xajax.tools.queue.pushFront(xajax.response, command);
			return false;
		}
	}
	return true;
}

/*
	Function: xajax.completeResponse
	
	Called by the response command queue processor when all commands have 
	been processed.
	
	Parameters:
	
	oRequest - (object):  The request context object.
*/
xajax.completeResponse = function(oRequest) {
	xajax.callback.execute(
		[xajax.callback.global, oRequest.callback], 
		'onComplete', oRequest);
	oRequest.cursor.onComplete();
	oRequest.status.onComplete();
	// clean up -- these items are restored when the request is initiated
	delete oRequest['functionName'];
	delete oRequest['requestURI'];
	delete oRequest['requestData'];
	delete oRequest['requestRetry'];
	delete oRequest['request'];
	delete oRequest['set'];
	delete oRequest['open'];
	delete oRequest['setRequestHeaders'];
	delete oRequest['setCommonRequestHeaders'];
	delete oRequest['setPostRequestHeaders'];
	delete oRequest['setGetRequestHeaders'];
	delete oRequest['applyRequestHeaders'];
	delete oRequest['finishRequest'];
	delete oRequest['status'];	
	delete oRequest['cursor'];	
}

/*
	Function: xajax.$
	
	Shortcut to <xajax.tools.$>.
*/
xajax.$ = xajax.tools.$;

/*
	Function: xajax.getFormValues
	
	Shortcut to <xajax.tools.getFormValues>.
*/
xajax.getFormValues = xajax.tools.getFormValues;

/*
	Boolean: xajax.isLoaded
	
	true - xajax module is loaded.
*/
xajax.isLoaded = true;


/*
	Class: xjx
	
	Contains shortcut's to frequently used functions.
*/
xjx = {}

/*
	Function: xjx.$
	
	Shortcut to <xajax.tools.$>.
*/
xjx.$ = xajax.tools.$;

/*
	Function: xjx.getFormValues
	
	Shortcut to <xajax.tools.getFormValues>.
*/
xjx.getFormValues = xajax.tools.getFormValues;

/*
	Function: xjx.call
	
	Shortcut to <xajax.call>.
*/
xjx.call = xajax.call;

xjx.request = xajax.request;