funcoes.js 152 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 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 3554 3555 3556 3557 3558 3559 3560 3561 3562 3563 3564 3565 3566 3567 3568 3569 3570 3571 3572 3573 3574 3575 3576 3577 3578 3579 3580 3581 3582 3583 3584 3585 3586 3587 3588 3589 3590 3591 3592 3593 3594 3595 3596 3597 3598 3599 3600 3601 3602 3603 3604 3605 3606 3607 3608 3609 3610 3611 3612 3613 3614 3615 3616 3617 3618 3619 3620 3621 3622 3623 3624 3625 3626 3627 3628 3629 3630 3631 3632 3633 3634 3635 3636 3637 3638 3639 3640 3641 3642 3643 3644 3645 3646 3647 3648 3649 3650 3651 3652 3653 3654 3655 3656 3657 3658 3659 3660 3661 3662 3663 3664 3665 3666 3667 3668 3669 3670 3671 3672 3673 3674 3675 3676 3677 3678 3679 3680 3681 3682 3683 3684 3685 3686 3687 3688 3689 3690 3691 3692 3693 3694 3695 3696 3697 3698 3699 3700 3701 3702 3703 3704 3705 3706 3707 3708 3709 3710 3711 3712 3713 3714 3715 3716 3717 3718 3719 3720 3721 3722 3723 3724 3725 3726 3727 3728 3729 3730 3731 3732 3733 3734 3735 3736 3737 3738 3739 3740 3741 3742 3743 3744 3745 3746 3747 3748 3749 3750 3751 3752 3753 3754 3755 3756 3757 3758 3759 3760 3761 3762 3763 3764 3765 3766 3767 3768 3769 3770 3771 3772 3773 3774 3775 3776 3777 3778 3779 3780 3781 3782 3783 3784 3785 3786 3787 3788 3789 3790 3791 3792 3793 3794 3795 3796 3797 3798 3799 3800 3801 3802 3803 3804 3805 3806 3807 3808 3809 3810 3811 3812 3813 3814 3815 3816 3817 3818 3819 3820 3821 3822 3823 3824 3825 3826 3827 3828 3829 3830 3831 3832 3833 3834 3835 3836 3837 3838 3839 3840 3841 3842 3843 3844 3845 3846 3847 3848 3849 3850 3851 3852 3853 3854 3855 3856 3857 3858 3859 3860 3861 3862 3863 3864 3865 3866 3867 3868 3869 3870 3871 3872 3873 3874 3875 3876 3877 3878 3879 3880 3881 3882 3883 3884 3885 3886 3887 3888 3889 3890 3891 3892 3893 3894 3895 3896 3897 3898 3899 3900 3901 3902 3903 3904 3905 3906 3907 3908 3909 3910 3911 3912 3913 3914 3915 3916 3917 3918 3919 3920 3921 3922 3923 3924 3925 3926 3927 3928 3929 3930 3931 3932 3933 3934 3935 3936 3937 3938 3939 3940 3941 3942 3943 3944 3945 3946 3947 3948 3949 3950 3951 3952 3953 3954 3955 3956 3957 3958 3959 3960 3961 3962 3963 3964 3965 3966 3967 3968 3969 3970 3971 3972 3973 3974 3975 3976 3977 3978 3979 3980 3981 3982 3983 3984 3985 3986 3987 3988 3989 3990 3991 3992 3993 3994 3995 3996 3997 3998 3999 4000 4001 4002 4003 4004 4005 4006 4007 4008 4009 4010 4011 4012 4013 4014 4015 4016 4017 4018 4019 4020 4021 4022 4023 4024 4025 4026 4027 4028 4029 4030 4031 4032 4033 4034 4035 4036 4037 4038 4039 4040 4041 4042 4043 4044 4045 4046 4047 4048 4049 4050 4051 4052 4053 4054 4055 4056 4057 4058 4059 4060 4061 4062 4063 4064 4065 4066 4067 4068 4069 4070 4071 4072 4073 4074 4075 4076 4077 4078 4079 4080 4081 4082 4083 4084 4085 4086 4087 4088 4089 4090 4091 4092 4093 4094 4095 4096 4097 4098 4099 4100 4101 4102 4103 4104 4105 4106 4107 4108 4109 4110 4111 4112 4113 4114 4115 4116 4117 4118 4119 4120 4121 4122 4123 4124 4125 4126 4127 4128 4129 4130 4131 4132 4133 4134 4135 4136 4137 4138 4139 4140 4141 4142 4143 4144 4145 4146 4147 4148 4149 4150 4151 4152 4153 4154 4155 4156 4157 4158 4159 4160 4161 4162 4163 4164 4165 4166 4167 4168 4169 4170 4171 4172 4173 4174 4175 4176 4177 4178 4179 4180 4181 4182 4183 4184 4185 4186 4187 4188 4189 4190 4191 4192 4193 4194 4195 4196 4197 4198 4199 4200 4201 4202 4203 4204 4205 4206 4207 4208 4209 4210 4211 4212 4213 4214 4215 4216 4217 4218 4219 4220 4221 4222 4223 4224 4225 4226 4227 4228 4229 4230 4231 4232 4233 4234 4235 4236 4237 4238 4239 4240 4241 4242 4243 4244 4245 4246 4247 4248 4249 4250 4251 4252 4253 4254 4255 4256 4257 4258 4259 4260 4261 4262 4263 4264 4265 4266 4267 4268 4269 4270 4271 4272 4273 4274 4275 4276 4277 4278 4279 4280 4281 4282 4283 4284 4285 4286 4287 4288 4289 4290 4291 4292 4293 4294 4295 4296 4297 4298 4299 4300 4301 4302 4303 4304 4305 4306 4307 4308 4309 4310 4311 4312 4313 4314 4315 4316 4317 4318 4319 4320 4321 4322 4323 4324 4325 4326 4327 4328 4329 4330 4331 4332 4333 4334 4335 4336 4337 4338 4339 4340 4341 4342 4343 4344 4345 4346 4347 4348 4349 4350 4351 4352 4353 4354 4355 4356 4357 4358 4359 4360 4361 4362 4363 4364 4365 4366 4367 4368 4369 4370 4371 4372 4373 4374 4375 4376 4377 4378 4379 4380 4381 4382 4383 4384 4385 4386 4387 4388 4389 4390 4391 4392 4393 4394 4395 4396 4397 4398 4399 4400 4401 4402 4403 4404 4405 4406 4407 4408 4409 4410 4411 4412 4413 4414 4415 4416 4417 4418 4419 4420 4421 4422 4423 4424 4425 4426 4427 4428 4429 4430 4431 4432 4433 4434 4435 4436 4437 4438 4439 4440 4441 4442 4443 4444 4445 4446 4447 4448 4449 4450 4451 4452 4453 4454 4455 4456 4457 4458 4459 4460 4461 4462 4463 4464 4465 4466 4467 4468 4469 4470 4471 4472 4473 4474 4475 4476 4477 4478 4479 4480 4481 4482 4483 4484 4485 4486 4487 4488 4489 4490 4491 4492 4493 4494 4495 4496 4497 4498 4499 4500 4501 4502 4503 4504 4505 4506 4507 4508 4509 4510 4511 4512 4513 4514 4515 4516 4517 4518 4519 4520 4521 4522 4523 4524 4525 4526 4527 4528 4529 4530 4531 4532 4533 4534 4535 4536 4537 4538 4539 4540 4541 4542 4543 4544 4545 4546 4547 4548 4549 4550 4551 4552 4553 4554 4555 4556 4557 4558 4559 4560 4561 4562 4563 4564 4565 4566 4567 4568 4569 4570 4571 4572 4573 4574 4575 4576 4577 4578 4579 4580 4581 4582 4583 4584 4585 4586 4587 4588 4589 4590 4591 4592 4593 4594 4595 4596 4597 4598 4599 4600 4601 4602 4603 4604 4605 4606 4607 4608 4609 4610 4611 4612 4613 4614 4615 4616 4617 4618 4619 4620 4621 4622 4623 4624 4625 4626 4627 4628 4629 4630 4631 4632 4633 4634 4635 4636 4637 4638 4639 4640 4641 4642 4643 4644 4645 4646 4647 4648 4649 4650 4651 4652 4653 4654 4655 4656 4657 4658 4659 4660 4661 4662 4663 4664 4665 4666 4667 4668 4669 4670 4671 4672 4673 4674 4675 4676 4677 4678 4679 4680 4681 4682 4683 4684 4685 4686 4687 4688 4689 4690 4691 4692 4693 4694 4695 4696 4697 4698 4699 4700 4701 4702 4703 4704 4705 4706 4707 4708 4709 4710 4711 4712 4713 4714 4715 4716 4717 4718 4719 4720 4721 4722 4723 4724 4725 4726 4727 4728 4729 4730 4731 4732 4733 4734 4735 4736 4737 4738 4739 4740 4741 4742 4743 4744 4745 4746 4747 4748 4749 4750 4751 4752 4753 4754 4755 4756 4757 4758 4759 4760 4761 4762 4763 4764 4765 4766 4767 4768 4769 4770 4771 4772 4773 4774 4775 4776 4777 4778 4779 4780 4781 4782 4783 4784 4785 4786 4787 4788 4789 4790 4791 4792 4793 4794 4795 4796 4797 4798 4799 4800 4801 4802 4803 4804 4805 4806 4807 4808 4809 4810 4811 4812 4813 4814 4815 4816 4817 4818 4819 4820 4821 4822 4823 4824 4825 4826 4827 4828 4829 4830 4831 4832 4833 4834 4835 4836 4837 4838 4839 4840 4841 4842 4843 4844 4845 4846 4847 4848 4849 4850 4851 4852 4853 4854 4855 4856 4857 4858 4859 4860 4861 4862 4863 4864 4865 4866 4867 4868 4869 4870 4871 4872 4873 4874 4875 4876 4877 4878 4879 4880 4881 4882 4883 4884 4885 4886 4887 4888 4889 4890 4891 4892 4893 4894 4895 4896 4897 4898 4899 4900 4901 4902 4903 4904 4905 4906 4907 4908 4909 4910 4911 4912 4913 4914 4915 4916 4917 4918 4919 4920 4921 4922 4923 4924 4925 4926 4927 4928 4929 4930 4931 4932 4933 4934 4935 4936 4937 4938 4939 4940 4941 4942 4943 4944 4945 4946 4947 4948 4949 4950 4951 4952 4953 4954 4955 4956 4957 4958 4959 4960 4961 4962 4963 4964 4965 4966 4967 4968 4969 4970 4971 4972 4973 4974 4975 4976 4977 4978 4979 4980 4981 4982 4983 4984 4985 4986 4987 4988 4989 4990 4991 4992 4993 4994 4995 4996 4997 4998 4999 5000 5001 5002 5003 5004 5005 5006 5007 5008 5009 5010 5011 5012 5013 5014 5015 5016 5017 5018 5019 5020 5021 5022 5023 5024 5025 5026 5027 5028 5029 5030 5031 5032 5033 5034 5035 5036 5037 5038 5039 5040 5041 5042 5043 5044 5045 5046 5047 5048 5049 5050 5051 5052 5053 5054 5055 5056 5057 5058 5059 5060 5061 5062 5063 5064 5065 5066 5067 5068 5069 5070 5071 5072 5073 5074 5075 5076 5077 5078 5079 5080 5081 5082 5083 5084 5085 5086 5087 5088 5089 5090 5091 5092 5093 5094 5095 5096 5097 5098 5099 5100 5101 5102 5103 5104 5105 5106 5107 5108 5109 5110 5111 5112 5113 5114 5115 5116 5117 5118 5119 5120 5121 5122 5123 5124 5125 5126 5127 5128 5129 5130 5131 5132 5133 5134 5135 5136
/*
Title: funcoes.js

Funções de uso geral para processamento de dados

File: i3geo/classesjs/funcoes.js

About: Licençamento

I3Geo Interface Integrada de Ferramentas de Geoprocessamento para Internet

Direitos Autorais Reservados (c) 2006 Ministério do Meio Ambiente Brasil
Desenvolvedor: Edmar Moretti edmar.moretti@mma.gov.br

Este programa é software livre; você pode redistribuí-lo
e/ou modificá-lo sob os termos da Licença Pública Geral
GNU conforme publicada pela Free Software Foundation;
tanto a versão 2 da Licença.
Este programa é distribuído na expectativa de que seja útil,
porém, SEM NENHUMA GARANTIA; nem mesmo a garantia implícita
de COMERCIABILIDADE OU ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA.
Consulte a Licença Pública Geral do GNU para mais detalhes.
Você deve ter recebido uma cópia da Licença Pública Geral do
GNU junto com este programa; se não, escreva para a
Free Software Foundation, Inc., no endereço
59 Temple Street, Suite 330, Boston, MA 02111-1307 USA.
*/
//
//verifica se $i existe, se não cria.
//isso é necessário nos casos em que funcoes.js é utilizado separadamente
//
try
{
	$i("i3geo");
}
catch(e)
{
	$i = function(i)
	{return document.getElementById(i);};
}
/*
Function: $im

Retorna o caminho correto de uma imagem incluindo o endereço da aplicação e do visual em uso.

Exemplo: $im("imagem.png")

Parâmetros:

g - nome da imagem

Retorno:

string - caminho para a imagem
*/
$im = function(g)
{return g_locaplic+"/imagens/visual/"+g_visual+"/"+g;};
/*
Function $inputText

Cria um elemento html do tipo input text com formatação especial.

Parameters:

idPai - id do elemento pai do input

larguraIdPai - largura em pixel

idInput - id do objeto input

titulo - texto que vai no title

digitos - numero de dígitos do input

valor - valor do input
*/
$inputText = function (idPai,larguraIdPai,idInput,titulo,digitos,valor)
{
	if(idPai != "")
	{
		if(larguraIdPai != "")
		{$i(idPai).style.width=larguraIdPai+"px";}
		$i(idPai).style.padding="3";
		$i(idPai).style.textAlign="center";
		$i(idPai).onmouseover = function()
		{this.className = "digitarMouseover";};
		$i(idPai).onmouseout = function()
		{this.className = "";};	
	}
	var i = "<input onmouseover='javascript:this.className=\"digitarOver\";' onmouseout='javascript:this.className=\"digitar\";' onclick='javascript:this.className=\"digitarMouseclick\";' id="+idInput+" title='"+titulo+"' type=text size="+digitos+" class=digitar value='"+valor+"' />";
	return i;
};
/*
Function: $top

Muda a posição (superior) de um objeto tanto no IE como no Firefox.

Exemplo: $top("imagem",100)

Parâmetros:

id - identificador do objeto

valor - posição em relação ao topo.
*/
$top = function(id,valor)
{
	if (document.getElementById(id).style)
	{
		if (document.getElementById(id).style.pixelTop)
		{document.getElementById(id).style.pixelTop=valor;}
		else
		{document.getElementById(id).style.top=valor+"px";}
	}
};
/*
Function: $left

Muda a posição (esquerda) de um objeto tanto no IE como no Firefox.

Exemplo: $left("imagem",100)

Parâmetros:

id - identificador do objeto

valor - posição em relação a esquerda.
*/
$left = function(id,valor)
{
	if (document.getElementById(id).style)
	{
		if (document.getElementById(id).style.pixelLeft)
		{document.getElementById(id).style.pixelLeft=valor;}
		else
		{document.getElementById(id).style.left=valor+"px";}
	}
};
/*
Function: trataErro

Fecha o objeto aguarde quando ocorre um erro.
*/
function trataErro()
{
	objaguarde.fecha("ajaxdestaca");
	objaguarde.fecha("ajaxabrelente");
	objaguarde.fecha("ajaxiniciaParametros");
	objaguarde.fecha("ajaxredesenha");
	objaguarde.fecha("ajaxCorpoMapaEntorno");
	objaguarde.fecha("ajaxCorpoMapa");
	objaguarde.fecha("ajaxLegenda");
	objaguarde.fecha("ajaxReferencia");
	objaguarde.fecha("ajaxEscalaGrafica");
	objaguarde.fecha("montaMapa");
	objaguarde.fecha("aguardedoc");
	objaguarde.fecha("ajaxCorpoMapa1");
}
/*
Function: iCookie

Cria um cookie.
*/
function iCookie(nome,valor)
{
	document.cookie = nome+"="+valor;
}
/*
Function: pCookie

Pega o valor de um cookie.
*/
function pCookie(nome)
{
	var cookies = document.cookie;
	var i = cookies.indexOf(nome);
	if(i == -1)
	{return null;}
	var fim = cookies.indexOf(";",i);
	if (fim == -1)
	{var fim = cookies.length;}
	return (unescape(cookies.substring(i,fim))).split("=")[1];
}
/*
Section: interface
*/
/*
Function: ativaMensagemBanner

Ativa o letreiro móvel.

A mensagem é incluída em um elemento HTML com id = "bannerMensagem"

As mensagens são obtidas do METADATA "MENSAGEM" que pode ser incluída na configuração dos layers adicionados ao mapa atual.

Veja a função mensagemBanner
*/
function ativaMensagemBanner()
{
	if($i("bannerMensagem"))
	{
		try
		{
			clearTimeout(BTempo);
		}
		catch(e){BTempo = "";}
		if($i("bannerMensagem").style.display=="none"){return;}
		$i("bannerMensagem").style.cursor="pointer";
		var monta = function(retorno)
		{
			if ($i("bannerMensagem").size == 1)
			{$i("bannerMensagem").size = objmapa.w / 8;}
			BMessage = retorno.data + " ---Clique para parar--- ";
			$i("bannerMensagem").onclick = function()
			{$i("bannerMensagem").style.display = "none";};
			if (BMessage != " ---Clique para parar--- ")
			{
				BQuantas = 0;
				BSize = $i("bannerMensagem").size;
				BPos=BSize;
				BSpeed = 1;
				BSpaces = "";
				mensagemBanner();
			}
		};
		var p = g_locaplic+"/classesphp/mapa_controle.php?funcao=pegaMensagens&g_sid="+g_sid;
		cpObj.call(p,"pegaMensagem",monta);	
	}
}

/*
Function: mensagemBanner

Mostra uma mensagem na tela como um letriro móvel.

As mensagens são obtidas no metadata MENSAGEM que pode ser colocado nos layers disponíveis no i3geo.

Veja a função ativaMensagemBanner
*/
function mensagemBanner()
{
	if($i("bannerMensagem"))
	{
		for (count=0; count<BPos; count++)
		BSpaces+= " ";
		if (BPos < 1)
		{
			$i("bannerMensagem").value = BMessage.substring(Math.abs(BPos), BMessage.length);
			if (BPos+BMessage.length < 1)
			{BPos = BSize;BQuantas = BQuantas + 1;}
		}
		else
		$i("bannerMensagem").value = BSpaces + BMessage;
		BPos-=BSpeed;
		if (BQuantas < 2)
		BTempo = setTimeout('mensagemBanner();', 140);
	}
}
/*
Function: sobeferramentas

Sobe a pilha de ícones na barra de ferramentas.

Utilizado na barra de ferramentas 2 quando o usuário clica no ícone para subir a lista de ícones.
*/
function sobeferramentas()
{
	if($i("maisBotoes2"))
	{
		var elementos = $i("maisBotoes2").getElementsByTagName("div");
		if(elementos[0].style.display == "inline")
		{return;}
		if(elementos.length > 0)
		{
			//mostra o primeiro botão
			var mostra = elementos[0];
			var i = 0;
			do
			{
				if(elementos[i].style)
				{
					if(elementos[i].style.display == "inline")
					{break;}
					if(elementos[i].style.display == "none")
					{var mostra = elementos[i];}
				}
				var i = i + 1;
			}
			while(i < elementos.length)
			mostra.style.display="inline";
			//esconde o último botao
			var i = elementos.length - 1;
			var mostra = elementos[i];
			do
			{
				if(elementos[i].style)
				{
					if(elementos[i].style.display == "inline")
					{var mostra = elementos[i];break;}
				}
				var i = i - 1;
			}
			while(i >= 0)
			mostra.style.display="none";
		}
	}
}
/*
Function: desceferramentas

Desce a pilha de ícones na barra de ferramentas.

Utilizado na barra de ferramentas 2 quando o usuário clica no ícone para descer a lista de ícones.
*/
function desceferramentas()
{
	var tipo = "inline";
	if($i("maisBotoes2"))
	{
		var elementos = $i("maisBotoes2").getElementsByTagName("div");
		if(elementos[elementos.length - 1].style.display == tipo)
		{return;}
		if(elementos.length > 0)
		{
			//esconde o primeiro botao
			var i = 0;
			do
			{
				if(elementos[i].style)
				{
					if((elementos[i].style.display == "block") || (elementos[i].style.display == "inline") || (elementos[i].style.display == ""))
					{elementos[i].style.display="none";break;}
				}
				var i = i + 1;
			}
			while(i < elementos.length)
			//mostra o último botao
			var i = elementos.length-1;
			var mostra = elementos[i];
			do
			{
				if(elementos[i].style)
				{
					if(elementos[i].style.display == tipo)
					{break;}
					if(elementos[i].style.display == "none")
					{var mostra = elementos[i];}
				}
				var i = i - 1;
			}
			while(i >= 0)
			mostra.style.display=tipo;
		}
	}
}
/*
Function: trocalingua

Troca o idioma atual utilizado na interface principal.

O código atual da linguagem é armazenado em um Cookie. Essa função troca o valor do Cookie e redesenha o mapa.

A troca de linguagem é ativada pelo clique nas bandeiras inseridas na parte superior do menu suspenso.

Os termos utilizados em cada idioma é definido em configura.js

Adefinição do termo a ser utilizado é definido pela função $trad

See: <configura.js>

Parameters:

l - código da lingua
*/
function trocalingua(l)
{
	try
	{
		iCookie("i3geolingua",l);
		window.location.reload(true)	
	}
	catch(e){alert("Erro ao mudar lingua");}
}
/*
Function: criaContainerRichdraw

Cria os elementos 'dom' necessários ao uso das funções de desenho sobre o mapa.

As ferramentas de cálculo de distâncias e áreas utilizam esse container.

Richdraw é uma biblioteca utilizada pelo i3geo para abstrair as diferenças entre as linguagens svg e vml.

Essa abstração é necessária devido às diferenças entre os navegadores.
*/
function criaContainerRichdraw()
{
	try
	{
		//
		//cria o container para uso da função de desenho usando
		//svg ou vml
		//esse container é sobreposto exatamente sobre o mapa
		//O id do containner é divGeometriasTemp
		//
		if (!$i("divGeometriasTemp"))
		{
			//
			//pega a posição da imagem do mapa para posicionar corretamente o container
			//
			var pos = [0,0];
			if($i("img"))
			var pos = pegaPosicaoObjeto($i("img"));
			//
			//cria o container
			//
			var novoel = document.createElement("div");
			novoel.id = "divGeometriasTemp";
			var ne = novoel.style;
			ne.cursor="crosshair";
			ne.zIndex=0;
			ne.position="absolute";
			ne.width=objmapa.w;
			ne.height=objmapa.h;
			ne.border="1px solid black";
			ne.display="none";
			ne.top=pos[1];
			ne.left=pos[0];
			document.body.appendChild(novoel);
		}
		//
		//como o container já poderia ter sido criado antes é necessário esvaziá-lo
		//
		var divgeo = $i("divGeometriasTemp");
		divgeo.innerHTML = "";
		var renderer;
		//
		//cria o objeto renderer conforme o browser em uso
		//esse objeto será utilizado nas funções de desenho
		//mais detalhes, veja em pacotes/richdraw
		//Conforme a resposta do navegador, utiliza-se a criação VML ou SVG
		//
		try
		{
			renderer = new VMLRenderer();
			richdraw = new RichDrawEditor(divgeo, renderer);
		}
		catch(e)
		{
			renderer = new SVGRenderer();
			richdraw = new RichDrawEditor(divgeo, renderer);
		}
		//
		//definição dos símbolos default para os elementos gráficos
		//
		richdraw.editCommand('fillcolor', 'red');
		richdraw.editCommand('linecolor', 'gray');
		richdraw.editCommand('linewidth', '1px');
		richdraw.editCommand('mode', 'line');
		divgeo.style.display="block";
		//
		//após o container ser criado, é necessário que as funções
		//de clique sobre o mapa sejam ativadas
		//para funcionarem sobre o container
		//
		ativaClicks(divgeo);
		
	}
	catch(e){alert("Erro ao tentar criar container richdraw");}
}
/*
Function: mudaVisual

Muda o visual do mapa atual (ícones).

Busca as imagens existentes na interface aberta e substituí pelas imagens existentes no diretório
correspondente ao visual selecionado.

As imagens existentes no mapa são comparadas com as existentes no diretório i3geo/imagens/visual/<visual> 
caso ocorra correspondência são então substituídas.

A lista de visuais disponíveis é obtida na inicialização do i3geo e corresponde à lista de diretórios existentes em i3geo/imagens/visual

Parameters:

visual - nome do novo visual. Obtido na inicialização do I3Geo e armazenado na variável objmapa.listavisual
*/
function mudaVisual(visual)
{
	//
	//refaz o layout conforme os parâmetros obtidos da chamada ajax
	//
	var monta = function(retorno)
	{
		try
		{
			objaguarde.fecha("ajaxredesenha");
			//
			//pega todas as imagens da interface
			//
			var imgstemp = retorno.data.arquivos;
			var imgs = new Array();
			var i = imgstemp.length-1;
			if(i >= 0)
			{
				do
				{
					var temp = imgstemp[i].split(".");
					if ((temp[1] == "png") || (temp[1] == "gif") || (temp[1] == "jpg"))
					{
						imgs.push(imgstemp[i]);
					}
				}
				while(i--)
			}
			var elementos = document.getElementsByTagName("img");
			var elt = elementos.length;
			var caminho = g_locaplic+"/imagens/visual/"+visual+"/";
			//faz a troca em imagens
			var j = imgs.length-1;
			if(j >= 0)
			{
				do
				{
					for (var i=0;i < elt; i++)
					{
						if ((elementos[i].src.search("branco") > -1) && ((elementos[i].className != "") || (elementos[i].id != "")))
						{elementos[i].src = caminho+"branco.gif";}
						if (elementos[i].src.search("visual") > -1)
						{elementos[i].style.backgroundImage = "url('"+caminho+imgs[j]+"')";}
					}
				}
				while(j--)
			}	
			//faz a troca em ids
			var j = imgs.length-1;
			if(j >= 0)
			{
				do
				{
					var busca = imgs[j].split(".");
					if ($i(busca[0]))
					{$i(busca[0]).src = caminho+imgs[j];}
				}
				while(j--)
			}
			//faz a troca em bg
			var elementos = new Array("vertMaisZoom","vertMenosZoom","foldermapa","foldermapa1","tic");
			var i = elementos.length-1;
			if(i >= 0)
			{
				do
				{
					if ($i(elementos[i]))
					{
						$i(elementos[i]).style.backgroundImage = "url('"+caminho+"sprite.png')";
						for (var j=0;j < imgs.length; j++)
						{
							var busca = imgs[j].split(".");
							if (busca[0] == elementos[i])
							{$i(elementos[i]).style.backgroundImage = "url('"+caminho+imgs[j]+"')";}
						}				
					}
				}
				while(i--)
			}
			g_visual = visual;
		}
		catch(e){alert("Ocorreu um erro. mudaVisual"+e);objaguarde.fecha("ajaxredesenha");}
	};
	//
	//pega a lista de imagens no diretório do i3geo correspondente ao visual selecionado
	//
	objaguarde.abre("ajaxredesenha",$trad("o1"));
	var p = g_locaplic+"/classesphp/mapa_controle.php?funcao=listaArquivos&g_sid="+g_sid+"&diretorio=imagens/visual/"+visual;
	cpObj.call(p,"mudaQS",monta);
}
/*
Function: initJanelaMen

Abre a janela com as mensagens de ajuda ao usuário. Essa janela é mostrada no canto inferior esquerdo e mostra textos de ajuda quando o usuário passa omouse sobre uma opção do i3geo.

Quando essa janela estiver aberta, o resultado da função de etiquetas e de ajuda é mostrado nessa janela.

Se o usuário fechar a janela de mensagens, é definido um cookie para controlar a abertura da janela ou não na próxima vez que oi3geo for utilizado.
*/
function initJanelaMen()
{
	try
	{
		//
		//cria a janela flutuante caso não exista
		//
		if (!$i("janelaMen"))
		{
			var novoel = document.createElement("div");
			novoel.id = "janelaMen";
			novoel.style.display="block";
			novoel.style.border="1px solid rgb(170,170,170)";
			novoel.innerHTML = '<div class="hd">&nbsp;</div><div class="bd" ><div id="janelaMenTexto" style="color:rgb(170,170,170)">'+g_mensagempadrao+'</div></div>';
			if($i("i3geo"))
			{$i("i3geo").appendChild(novoel);}
			else
			{document.body.appendChild(novoel);}
			var i = ($i("janelaMenTexto")).style;
			i.textAlign="left";
			i.fontSize="10px";
			YAHOO.namespace("janelaMen.xp");
			YAHOO.janelaMen.xp.panel = new YAHOO.widget.Panel("janelaMen", { width:"266px", height:"auto", fixedcenter: false, constraintoviewport: true, underlay:"none", close:true, visible:true, draggable:true, modal:false } );
			YAHOO.janelaMen.xp.panel.render();
			var escondeMen = function()
			{
				YAHOO.util.Event.removeListener(YAHOO.janelaMen.xp.panel.close, "click");
				YAHOO.janelaMen.xp.panel.destroy();	
				iCookie("g_janelaMen","nao");	
			};
			YAHOO.util.Event.addListener(YAHOO.janelaMen.xp.panel.close, "click", escondeMen);
			iCookie("g_janelaMen","sim");
		}
		//
		//abre a janela
		//
		YAHOO.janelaMen.xp.panel.show();
		var pos = pegaPosicaoObjeto($i("img"));
		YAHOO.janelaMen.xp.panel.moveTo(pos[0] - 267 ,objmapa.h - 70);
	}
	catch(e){alert("Nao foi possivel criar a janela de mensagens. initJanelaMen"+e);}
}
/*
Function: docaguias

Coloca as guias de navegação em uma janela interna do mapa e altera o tamanho do mapa para ajustá-lo à nova situação.

O conteúdo da nova janela é aquele que estiver dentro de um DIV com id= "contemFerramentas"
*/
function docaguias()
{
	if (!$i("conteudojanelaguias"))
	{
		if($i("guiasYUI")){$i("guiasYUI").style.display="none";}
		if (!$i("contemFerramentas")){return;}
		var novono = $i("contemFerramentas").innerHTML;
		$i("contemFerramentas").innerHTML = "";
		var wef = 0;
		if ($i("encolheFerramentas"))
		{wef = parseInt($i("encolheFerramentas").style.width);}
		var w = parseInt($i("contemFerramentas").style.width) - wef;
		$i("contemFerramentas").style.width="0px";
		if ($i("visual"))
		{$i("visual").style.width="0px";$i("visual").innerHTML="";}
		var pos = "px";
		var a = objmapa.h;
		var l = objmapa.w + w;
		objmapa.h = a;
		objmapa.w = l;
		if (navm){pos = "";}
		$i("img").style.width= l+pos;
		$i("img").style.height= a+pos;
		$i("corpoMapa").style.width= l+pos;
		$i("corpoMapa").style.height= a+pos;
		$i("corpoMapa").style.clip = 'rect('+0+" "+(l*1+2)+" "+(a*1+2)+" "+0+')';
		$i("mst").style.width = l + 1 + wef + pos;
		$i("contemImg").style.height= a+pos;
		$i("contemImg").style.width= l+pos;
		// entorno
		if (g_entorno == "sim")
		{
			var letras=["L","O"];
			for (var l=0;l<2; l++)
			{
				if ($i("img"+letras[l]))
				{
					$i("img"+letras[l]).style.width = objmapa.w+pos;
					$i("img"+letras[l]).style.height = objmapa.h+pos;
					$i("corpoMapa"+letras[l]).style.width=objmapa.w+pos;
					$i("corpoMapa"+letras[l]).style.height=objmapa.h+pos+pos;
					$i("corpoMapa"+letras[l]).style.clip = 'rect(0 0 0 0)';
				}
			}
			var letras=["N","S"];
			for (var l=0;l<2; l++)
			{
				if ($i("img"+letras[l]))
				{
					$i("img"+letras[l]).style.width = objmapa.w * 2+pos;
					$i("img"+letras[l]).style.height = objmapa.h * 2+pos;
					$i("corpoMapa"+letras[l]).style.width=objmapa.w * 3+pos;
					$i("corpoMapa"+letras[l]).style.height=objmapa.h+pos;
					$i("corpoMapa"+letras[l]).style.clip = 'rect(0 0 0 0)';
				}
			}
		}
		calcposf();
		var temp = function()
		{
			//carrega janela
			var novoel = document.createElement("div");
			novoel.id = "janelaguias";
			novoel.style.display="block";
			var temp = '<div class="hd">Guias</div>';
			temp += '<div class="bd" id="conteudojanelaguias"></div>';
			novoel.innerHTML = temp;
			if($i("i3geo"))
			{$i("i3geo").appendChild(novoel);}
			else
			{document.body.appendChild(novoel);}
			$i("conteudojanelaguias").innerHTML = novono;
			YAHOO.namespace("janelaguias.xp");
			YAHOO.janelaguias.xp.panel = new YAHOO.widget.Panel("janelaguias", {width:"268px", fixedcenter: true, constraintoviewport: false, underlay:"none", close:true, visible:true, draggable:true, modal:false } );
			YAHOO.janelaguias.xp.panel.render();
			if($i(objmapa.guiaMenu+"obj"))
			{
				$i(objmapa.guiaMenu+"obj").innerHTML = "";
			}
			//ativaGuias();
			if($i("listaTemas"))
			{$i("listaTemas").innerHTML = "";}
			if($i("listaPropriedades"))
			{$i("listaPropriedades").innerHTML = "";objmapa.ativaListaPropriedades("listaPropriedades");}
			remapaf();
		};	
		objaguarde.abre("ajaxredesenha",$trad("o1"));
		var p = g_locaplic+"/classesphp/mapa_controle.php?funcao=mudatamanho&altura="+a+"&largura="+l+"&g_sid="+g_sid;
		var cp = new cpaint();
		//cp.set_debug(2)
		cp.set_response_type("JSON");
		cp.call(p,"mudaQS",temp);
	}
	else
	{
		YAHOO.janelaguias.xp.panel.render();
		YAHOO.janelaguias.xp.panel.show();
	}
}
/*
Function: ativaGuias

Ativa as guias principais do mapa, definindo as funções que serão executadas quando a guia é escolhida.

Quando o usuário clica em uma guia, todas as guias são escondidas e a guia clicada é ativada.

Algumas guias só são preenchidas quando o usuário clicar nelas pela primeira vez.

O preenchimento sob demanda dessas guias torna necessário a definição da função que será executada quando o clique ocorrer.

Essas funções são definidas por default nas guias principais.

As guias principais são definidas nos objetos

objmapa.guiaTemas

objmapa.guiaMenu

objmapa.guiaLegenda

objmapa.guiaListaMapas

*/
function ativaGuias()
{
	//ajusta as guias da versão antiga do YUI para a nova
	//
	//pega o elemento onde as guias serão colocadas
	//
	for(var g=0;g<12;g++)
	{
		if ($i("guia"+g))
		var gpai = $i("guia"+g).parentNode;
	}
	//
	//monta as guias
	//
	if(gpai)
	{
		gpai.id = "guiasYUI";
		gpai.className = "yui-navset";
		var ins = '<ul class="yui-nav" style="border-width:0pt 0pt 2px;border-color:rgb(240,240,240)">';
		//
		//define os títulos das guias padrão
		//
		if($i(objmapa.guiaTemas))
		{$i(objmapa.guiaTemas).innerHTML = $trad("g1");}
		if($i(objmapa.guiaMenu))
		{$i(objmapa.guiaMenu).innerHTML = $trad("g2");}
		if($i(objmapa.guiaLegenda))
		{$i(objmapa.guiaLegenda).innerHTML = $trad("g3");}
		if($i(objmapa.guiaListaMapas))
		{$i(objmapa.guiaListaMapas).innerHTML = $trad("g4");}
		//
		//
		for(var g=0;g<12;g++)
		{
			if ($i("guia"+g))
			{
				//
				//pega os títulos das guias, inclusive as que não são padrão
				//
				var tituloguia = $i("guia"+g).innerHTML;
				//
				//remove os espaços em branco 
				//necessário para manter compatibilidade com versões antigas do i3geo
				//
				var re = new RegExp("&nbsp;", "g");
				var tituloguia = tituloguia.replace(re,'');
				//
				//monta o título das guias
				//
				ins += '<li><a href="#"><em><div id="guia'+g+'" >'+tituloguia+'</div></em></a></li>';
			}
		}
		ins += "</ul>";
		//
		//insere as guias em gpai
		//
		gpai.innerHTML = ins;
		for(var g=0;g<12;g++)
		{
			if ($i("guia"+g))
			{
				eval('$i("guia'+g+'").onclick = function(){g_guiaativa = "guia'+g+'";mostraguiaf('+g+');}');
				if($i("guia"+g+"obj"))
				{
					$i("guia"+g+"obj").style.overflow="auto";
					$i("guia"+g+"obj").style.height = objmapa.h;
				}
			}
		}
	}
	//
	//define a função que será executada quando o usuário clica em uma guia padrão
	//
	if ($i(objmapa.guiaTemas))
	{
		$i(objmapa.guiaTemas).onclick = function()
		{g_guiaativa = objmapa.guiaTemas;mostraguiaf(1);};
	}
	if ($i(objmapa.guiaMenu))
	{
		$i(objmapa.guiaMenu).onclick = function()
		{
			g_guiaativa = objmapa.guiaMenu;
			mostraguiaf(2);
			if (!$i("buscatema"))
			{
				//pega a lista de árvores que devem ser montadas
				//é executado apenas se não existir o id=arvoreAdicionaTema
				//caso contrário, a árvore é montada na inicialização do i3geo
				var p = g_locaplic+"/classesphp/mapa_controle.php?funcao=pegalistademenus&g_sid="+g_sid;
				cpObj.call(p,"pegalistademenus",pegalistademenus);
			}
		};
	}
	if ($i(objmapa.guiaLegenda))
	{
		$i(objmapa.guiaLegenda).onclick = function()
		{g_guiaativa = objmapa.guiaLegenda;mostraguiaf(4);objmapa.atualizaLegendaHTML();};
	}
	if ($i(objmapa.guiaListaMapas))
	{
		$i(objmapa.guiaListaMapas).onclick = function()
		{
			g_guiaativa = objmapa.guiaListaMapas;
			mostraguiaf(5);
			if ($i("banners"))
			{
				$i("banners").innerHTML == $trad("o1");
				var p = g_locaplic+"/classesphp/mapa_controle.php?funcao=pegaMapas&g_sid="+g_sid;
				cpObj.call(p,"pegaMapas",pegaMapas);
			}
			else
			{alert("id banners nao encontrado");}
		};
	}
}
/* 
Function: pegalistademenus

Pega a lista de menus que deverão compor a árvore de adição de temas e cria/adiciona os elementos raiz para cada árvore

A lista de menus é definida em ms_configura.php ou no sistema de administração.

Para cada menu é montada uma árvore com os grupos e sub-grupos de temas.

Parameters:

retorno - objeto JSON no formato CPAINT com a lista de menus
*/
function pegalistademenus(retorno)
{
	//
	//quando retorno for vazio, significa que será usado o menu default(menutemas.xml) e será mostrado sempre aberto
	//essa verificação é necessária para efeitos de compatibilidade com versões antigas do i3geo que não permitiam mais de um menu
	//
	if (retorno.data == "")
	{pegaListaDeGrupos("","sim","aberto");}
	else
	{
		var j = retorno.data.length;
		var i = 0;
		if(j >= 0)
		{
			do
			{
				//
				//o parâmetro status define se a árvre será montada aberta ou fechada
				//esse parâmetro foi adicionado na versão 4.0 do i3geo
				//por isso a verificação é necessária
				//se o parâmetro não existir na variável $menutemas definida em ms_configura.php,
				//será utilizado aberto
				//
				if(retorno.data[i].nomemenu)
				var nome = retorno.data[i].nomemenu;
				else
				var nome = retorno.data[i].idmenu;
				//
				//muda a cor se o menu não estiver publicado
				//
				if(retorno.data[i].publicado)
				{
					if(retorno.data[i].publicado == "NAO")
					{var nome = "<s>"+nome+"</s>";}
				}
				var status = "aberto";
				if(retorno.data[i].status)
				{var status = retorno.data[i].status;}
				else
				{var status = "fechado";}
				if(i == j-1)
				{pegaListaDeGrupos(retorno.data[i].idmenu,"sim",status,nome);}
				else
				{pegaListaDeGrupos(retorno.data[i].idmenu,"nao",status,nome);}
				i++;
			}
			while(i < j)
		}
	}
}
/*
Function: mensagemf

Abre uma mensagem na tela em um DIV.

A mensagem é incluída em um elemento HTML com id ="mensagem"

Parameters:

m - mensagem que será mostrada.
*/
function mensagemf(m)
{
	try
	{
		//insere o div para mensagens
		if (!$i("mensagem"))
		{
			var novoel = document.createElement("div");
			novoel.id = 'mensagem';
			novoel.innerHTML = '<table width="50" style="border: 1px solid #000000;"> <tr> <td onclick="mensagemf()" style="text-align:left;cursor:pointer" class="tdclara"> <img src="'+g_locaplic+'/imagens/excluir.png" /> </td> <td style="text-align:left" class="tdclara"> <input style="text-align:left" class="textocb" type="text" id="mensagemt" size="70" value="" /> </td></tr> </table>';
			if($i("i3geo"))
			{$i("i3geo").appendChild(novoel);}
			else
			{document.body.appendChild(novoel);}
		}
		if (m == null)
		{$i("mensagem").style.visibility = "hidden";}
		else
		{
			$i("mensagemt").value = m;
			$i("mensagem").style.visibility = "visible";
		}
		var pos = pegaPosicaoObjeto($i("img"));
		pos[1] = pos[1] + parseInt($i("img").style.height) - 22;
		eval ('document.getElementById("mensagem").style.' + g_tipoleft + ' = pos[0] + g_postpx');
		eval ('document.getElementById("mensagem").style.' + g_tipotop + ' = pos[1] + g_postpx');
	}
	catch(e){alert("Impossivel criar mensagem."+e);}
}
/*
Function: wdocaf

Abre a janela flutuante para executar algum programa.

A janela flutuante contém um iframe onde o programa, definido no parâmetro wsrc, será carregado.

A janela é criada por meio da biblioteca YUI

Parameters:

wlargura - largura da nova janela

waltura - altura da nova janela

wsrc - endereço do conteúdo que será aberto

nx - posição da janela em x. Pode ser definido como "center"

ny - posição da janela em y

texto - texto que será mostrado no título da janela
*/
function wdocaf(wlargura,waltura,wsrc,nx,ny,texto)
{
	//
	//esconde o objeto flamingo (flash) caso a interface atual seja a flamingo.htm
	//
	if($i("flamingoi")){$i("flamingoi").style.display="none";}
	try
	{
		//
		//esconde o box de zoom e outros objetos temporários se estiverem visíveis
		//
		if($i("boxg"))
		{$i("boxg").style.display = "none";}
		if($i("boxpin"))
		{$i("boxpin").style.display = "none";}
		var wlargura_ = parseInt(wlargura)+0+"px";
		YAHOO.namespace("janelaDoca.xp");
		if ($i("wdoca"))
		{YAHOO.janelaDoca.xp.panel.destroy();}
		var ins = '<div class="hd">'+texto+'</div><div class="bd"><iframe name="wdocai" id="wdocai" valign="top" style="border:0px white solid"></iframe></div>';
		var novoel = document.createElement("div");
		novoel.id = "wdoca";
		novoel.style.display="block";
		novoel.innerHTML = ins;
		if($i("i3geo"))
		{$i("i3geo").appendChild(novoel);}
		else
		{document.body.appendChild(novoel);}
		if ($i("wdocai"))
		{
			with ($i("wdocai").style){width = "100%";height=waltura;};
			$i("wdoca").style.display = "block";
			$i("wdocai").src = wsrc;
		}
		var fix = false;
		var pos = pegaPosicaoObjeto($i("img"));
		if(nx == "center"){var fix = true;}
		YAHOO.janelaDoca.xp.panel = new YAHOO.widget.ResizePanel("wdoca", { width: wlargura_, fixedcenter: fix, constraintoviewport: false, visible: true, iframe:false} );
		YAHOO.janelaDoca.xp.panel.moveTo(pos[0],pos[1]+50);
		YAHOO.janelaDoca.xp.panel.render();
		var escondeWdoca = function()
		{
			$i("wdoca").style.display = "none";
			$i("wdocai").src = "";
			YAHOO.util.Event.removeListener(YAHOO.janelaDoca.xp.panel.close, "click");
			YAHOO.janelaDoca.xp.panel.destroy();
			if ((g_tipoacao == "selecaobox") || (g_tipoacao == "inseregrafico") || (g_tipoacao == "selecao") || (g_tipoacao == "inserexy") || (g_tipoacao == "textofid"))
			{mudaiconf("pan");}
			//esconde o box do google
			if ($i("boxg"))
			{$i("boxg").style.display = "none";}
			if ($i("boxpin"))
			{$i("boxpin").style.display = "none";}
			//fecha o container de desenho de elementos na tela
			if($i("divGeometriasTemp"))
			{richdraw.fecha();}
			limpacontainerf();
			if($i("flamingoi")){$i("flamingoi").style.display="block";}
		};
		YAHOO.util.Event.addListener(YAHOO.janelaDoca.xp.panel.close, "click", escondeWdoca);
	}
	catch(e){alert("Ocorreu um erro. wdocaf"+e);}
}
/*
Function: redimwdocaf

Redimensiona a janela flutuante.

Parameters:

wlargura - largura da nova janela

waltura - altura da nova janela

*/
function redimwdocaf(wlargura,waltura)
{
	try
	{
		if ($i("wdoca"))
		{
			var i = $i("wdoca");
			i.style.width = wlargura;
			i.style.height = waltura;
		}
	}
	catch(e){alert("Ocorreu um erro. redimwdocaf"+e);}
}
/*
Function: wdocaf2

Abre uma segunda janela flutuante.

Parameters:

wlargura - largura da nova janela

waltura - altura da nova janela

wsrc - endereço do conteúdo que será aberto

nx - posição da janela em x

ny - posição da janela em y

texto - texto que será mostrado no título da janela
*/
function wdocaf2(wlargura,waltura,wsrc,nx,ny,texto)
{
	try
	{
		if (!$i("wdoca2"))
		{
			var ins = '<div class="hd">&nbsp;</div><div class="bd"><iframe name="wdocai2" id="wdocai2"  valign="top" ></iframe></div></div>';
			var novoel = document.createElement("div");
			novoel.id = "wdoca2";
			novoel.style.display="none";
			novoel.innerHTML = ins;
			document.body.appendChild(novoel);
		}
		var pos = pegaPosicaoObjeto($i("img"));
		YAHOO.namespace("janelaDoca2.xp");
		YAHOO.janelaDoca2.xp.panel = new YAHOO.widget.Panel("wdoca2", {width:wlargura, fixedcenter: false, constraintoviewport: true, underlay:"none", close:true, visible:true, draggable:true, modal:true } );
		YAHOO.janelaDoca2.xp.panel.moveTo(pos[0],pos[1]);
		YAHOO.janelaDoca2.xp.panel.render();
		YAHOO.janelaDoca2.xp.panel.show();
		with ($i("wdocai2").style){width = "100%";height = waltura;}
		$i("wdoca2").style.display = "block";
		$i("wdocai2").src = wsrc;
		var escondeWdoca2 = function()
		{
			$i("wdoca2").style.display = "none";
			$i("wdocai2").src = "";
			YAHOO.util.Event.removeListener(YAHOO.janelaDoca2.xp.panel.close, "click");
		};
		YAHOO.util.Event.addListener(YAHOO.janelaDoca2.xp.panel.close, "click", escondeWdoca2);
	}
	catch(e){alert("Ocorreu um erro. wdocaf2"+e);}
}
/*
Function: wdocafechaf

Fecha uma janela flutuante.

Depreciado

Parameters:

odoca - objeto janela
*/
function wdocafechaf(odoca)
{
	try
	{
		$i(odoca).style.display="none";
		if ((odoca != "wdocaref") && (odoca != "wdocac"))
		{
			if($i("wdocain")){$i("wdocain").value = "";}
			if($i("wdocadiv")){$i("wdocadiv").innerHTML = "";$i("wdocadiv").display="none";}
			if ($i("temp")){$i("temp").value == "";}
			$i("wdocai").src = "";
			$i("imgh").style.visibility="visible";
		}
		if ((g_tipoacao == "selecaobox") || (g_tipoacao == "inseregrafico") || (g_tipoacao == "selecao") || (g_tipoacao == "inserexy") || (g_tipoacao == "textofid"))
		{mudaiconf("pan");}
	}
	catch(e){alert("Ocorreu um erro. wdocafechaf"+e);}
}
/*
Function: mostradicasf

Mostra dicas sobre uma função quando o mouse passa sobre um botão ou outra opção qualquer.

O texto da dica pode ser obtido com a função $trad

Se a janela de mensagens estiver aberta, o texto será colocado nela.

Parameters:

objeto - objeto sobre o qual o mouse está sobreposto.

dica - dica que aparece no mapa.

hlpt - depreciado
*/
function mostradicasf(objeto,dica,hlpt)
{
	try
	{
		if ($i("ajuda"))
		{
			if (dica == ""){$i("ajuda").innerHTML="-";}
			else
			{
				g_hlpt = hlpt;
				$i("ajuda").innerHTML= "<b>"+dica+" </b>";
			}
		}
		if ($i("janelaMenTexto"))
		{
			if (dica == ""){dica = g_mensagempadrao;}
			$i("janelaMenTexto").innerHTML= "<b>"+dica+" </b>";
		}
	}
	catch(e){alert("Ocorreu um erro. mostradicasf"+e);}
}	
/**
Function: mudaiconf

Muda as bordas dos ícones de ferramentas, passando todos para normal.
Aplica uma borda sobre um ícone específico e executa outras operações.

Utilizado para indicar que uma determinada opção está em uso.

Como esta função é executada quando um ícone é clicado, algumas operações são definidas aqui
como por exemplo, definir o ícone que segue o mouse. 

Parameters:

i - id do ícone que receberá a borda.
*/
function mudaiconf(i)
{
	try
	{
		//limpa o container com os tips fixos na tela
		if(objmapa.objtips.length > 0)
		{
			var ot = objmapa.objtips.length-1;
			if(ot >= 0)
			{
				do
				{
					if (objmapa.objtips[ot])
					{
						objmapa.objtips[ot].innerHTML = "";
						objmapa.objtips[ot].style.display="none";
					}
				}
				while(ot--)
			}
		}
		objmapa.objtips = new Array();
		limpacontainerf();
		var objetos=["area","inseregrafico","textofid","zoomli","zoomlo","zoomiauto","zoomoauto","pan","identifica","mede","inserexy","selecao"];
		var ko = objetos.length-1;
		if(ko >= 0)
		{
			do
			{
				if ($i(objetos[ko]))
				{
					var ist = $i(objetos[ko]).style;
					ist.borderWidth=0;
					ist.borderBottomWidth=1;
					ist.borderLeftWidth=1;
					ist.borderColor='rgb(50,50,50)';
				}
			}
			while(ko--)
		}
		g_tipoacao = i;
		if($i(i))
		{
			with ($i(i).style){borderLeftWidth='0px';borderBottomWidth='0px';borderColor='black';}
		}
		$i("imgh").style.display="block";
		if ($i("divGeometriasTemp"))
		{$i("divGeometriasTemp").style.display = "none";}
		switch(i)
		{
			case "zoomli":
			$i("imgh").src= g_localimg + "/" + "ic_zoom.png";
			if($i("img")){$i("img").title = "";}
			break;
			case "pan":
			$i("imgh").src= g_localimg + "/" + "icon_pan.gif";
			if($i("img")){$i("img").title = "";}
			break;
			case "mede":
			$i("imgh").src= g_localimg + "/" + "mede.gif";
			case "area":
			$i("imgh").src= g_localimg + "/" + "mede.gif";
			break;
			case "inserexy":
			$i("imgh").src= g_localimg + "/" + "ic_xy.png";
			if($i("img")){$i("img").title = "clique para inserir um ponto";}
			break;
			case "textofid":
			$i("imgh").src= g_localimg + "/" + "ic_xy.png";
			if($i("img")){$i("img").title = "clique para inserir o texto";}
			break;
			case "selecao":
			$i("imgh").src= g_localimg + "/" + "ic_seleciona.png";
			if($i("img")){$i("img").title = "";}
			break;
			case "inseregrafico":
			$i("imgh").src= g_localimg + "/" + "ic_seleciona.png";
			if($i("img")){$i("img").title = "clique para incluir o gráfico";}
			break;
			case "identifica":
			$i("imgh").src= g_localimg + "/" + "ic_identifica.png";
			if($i("img")){$i("img").title = "";}
			break;
		}
	}
	catch(e){alert("Ocorreu um erro. mudaiconf"+e);}
}
/*
Function: mostraguiaf

Ativa a visualização de uma determinada guia.

A ativação consiste em tornar visível os elementos correspondentes a uma determinada guia.
Esses elementos devem estar contidos em um DIV cujo id deve ser composto pela palavra "guia" seguida do número da
guia e a palavra "obj", por exemplo, guia9obj.

Parâmetros:

guia - número da guia que será ativada.
*/
function mostraguiaf(guia)
{
	if ($i("guia"+guia))
	{
		var fs=[1,2,3,4,5,6,7,8,9,10,11,12];
		for (var j=0;j<10; j++)
		{
			if ($i("guia"+fs[j]))
			{
				jj = fs[j];
				if ($i("guia"+jj+"obj"))
				{$i("guia"+jj+"obj").style.display="none";}
			}
		}
		if ($i("guia"+guia+"obj"))
		{$i("guia"+guia+"obj").style.display="block";}
		else
		{alert("O objeto guia"+guia+"obj nao existe.");}
	}
}
/*
Function: aguarde

Cria um objeto aguarde.
O objeto é um banner mostrado na tela quando uma função ajax é executada.

Method:

abre - abre o banner

Parâmetros:

aguardeId - identificador do banner

texto - texto do banner

Method:

fecha - fecha o banner

Parâmetros:

aguardeId - identificador do banner

*/
function aguarde()
{
	this.abre = function(aguardeId,texto)
	{
		if($i("wait_mask"))
		{
			document.body.removeChild($i("wait_mask"));
		}
		if($i("wait_c"))
		{
			document.body.removeChild($i("wait_c"));
		}
		YAHOO.namespace("aguarde."+aguardeId);
		var pos = [0,0];
		if($i("corpoMapa"))
		{var pos = pegaPosicaoObjeto($i("corpoMapa"));}
		else if ($i("contemImg"))
		{var pos = pegaPosicaoObjeto($i("contemImg"));}
		eval ('YAHOO.aguarde.'+aguardeId+' = new YAHOO.widget.Panel("wait",{width:"240px",fixedcenter:false,underlay:"none",close:true,draggable:false,modal:true})');
		eval ('YAHOO.aguarde.'+aguardeId+'.setBody("<span style=font-size:12px; >"+texto+"</span>")');
		eval ('YAHOO.aguarde.'+aguardeId+'.body.style.height="20px"');
		eval ('YAHOO.aguarde.'+aguardeId+'.setHeader("<span><img src=\'"+g_locaplic+"/imagens/aguarde.gif\' /></span>")');
		eval ('YAHOO.aguarde.'+aguardeId+'.render(document.body)');
		if($i("flamingo"))
		{
			eval ('YAHOO.aguarde.'+aguardeId+'.moveTo(0,0)');
		}
		else
		{eval ('YAHOO.aguarde.'+aguardeId+'.moveTo('+pos[0]+','+pos[1]+')');}
		eval ('YAHOO.aguarde.'+aguardeId+'.show()');
		if($i("wait_mask"))
		{$i("wait_mask").style.zIndex=5000;}
		if($i("wait_c"))
		{$i("wait_c").style.zIndex=6000;}
		
	};
	this.fecha = function(aguardeId)
	{
		if ($i("wait"))
		{
			if (eval('YAHOO.aguarde.'+aguardeId))
			{
				if ($i(eval('YAHOO.aguarde.'+aguardeId+".id")))
				{eval('YAHOO.aguarde.'+aguardeId+'.destroy()');}
			}
		}
	};
}
/**
Function: ativaClicks

Ativa as operações de clique sobre o mapa

Define o que será executado quando o mouse é clicado ou movido sobre o mapa.

Além das funções padrão,são ativadas aquelas definidas nas variáveis de configuração (veja configura.js)

Parameters:

docMapa - objeto que será alvo da ativação dos cliques
*/
function ativaClicks(docMapa)
{
	docMapa.onmouseover = function()
	{
		try
		{
			if ($i("imgh")){$i("imgh").style.display="block";}
			if ($i("janelaMenu"))
			{$i("janelaMenu").style.display="none";}
			this.src=g_quadrooriginal;
			//verifica se o mouse esta parado
			if (objmapa.parado!="cancela")
			{
				objmapa.parado="nao";
			}
			if ($i("tip"))
			{$i("tip").style.display="none";}
		}
		catch(e){var e = "";}
		this.onmousemove=function(exy)
		{
			try
			{
				if ($i("mostraUTM")){$i("mostraUTM").style.display="none";}
				if ($i("tip"))
				{$i("tip").style.display="none";}
				capturaposicao(exy);
				if (g_destaca != "")
				{$i("imgh").style.display="none";$i("div_d").style.clip = 'rect('+(objposicaocursor.imgy - destacaTamanho)+" "+(objposicaocursor.imgx - 10)+" "+(objposicaocursor.imgy - 10)+" "+(objposicaocursor.imgx - destacaTamanho)+')';}
				if ($i("img") && (g_panM == "sim"))
				{
					var nx = objposicaocursor.telax - leftinicial - clicinicialx;
					var ny = objposicaocursor.telay - topinicial - clicinicialy;
					if (g_entorno == "nao")
					{
						var l = 0;
						if (parseInt($i("i3geo").style.left))
						{var l = parseInt($i("i3geo").style.left);}
						$i("img").style.left = nx - l;
						var t = 0;
						if (parseInt($i("i3geo").style.top))
						{var t = parseInt($i("i3geo").style.top);}
						$i("img").style.top = ny - t;
					}
					else
					{
						$left("img",objmapa.w*-1 + nx);
						$left("imgS",objmapa.w*-1 + nx);
						$left("imgL",objmapa.w + nx);
						$left("imgO",objmapa.w*-3 + nx);
						$left("imgN",objmapa.w*-1 + nx);
						$top("img",objmapa.h*-1 + ny);
						$top("imgS",objmapa.h*-1 + ny);
						$top("imgL",objmapa.h*-1 + ny);
						$top("imgN",objmapa.h*-1 + ny);
						$top("imgO",objmapa.h*-1 + ny);
					}
				}
			}
			catch(e){var e = "";}
			try
			{objmapa.verificaMousemoveMapa();}
			catch(e){var e = "";}
		};
	};
	docMapa.onmouseout = function()
	{
		try
		{
			objmapa.parado="parar";
			mostradicasf(this,'');
			if ($i("imgh")){$i("imgh").style.display="none";}
		}
		catch(e){var e = "";}
	};
	docMapa.onmousedown = function(exy)
	{
		try
		{
			capturaposicao(exy);
			if ($i("imgh"))
			$i("imgh").style.display="none";
			//verifica se esta na op�o de zoom box
			if ((g_tipoacao == "zoomli") || (g_tipoacao == "selecaobox"))
			{
				// inicia ret�gulo de zoom
				if ($i("imgh"))
				$i("imgh").style.display="none";
				if($i("box1"))
				{
					var i = $i("box1").style;
					i.width=0;
					i.height=0;
					i.visibility="visible";
					i.display="none";
				}
				boxxini = objposicaocursor.telax;
				boxyini = objposicaocursor.telay;
				tamanhox = 0;
				tamanhoy = 0;
			}
			if ($i("img") && (g_tipoacao == "pan"))
			{
				g_panM = "sim";
				if($i("corpoMapa"))
				{
					leftinicial = parseInt($i("corpoMapa").style.left);
					topinicial = parseInt($i("corpoMapa").style.top);
				}
				clicinicialx = objposicaocursor.imgx;
				clicinicialy = objposicaocursor.imgy;
				ddinicialx = objposicaocursor.ddx;
				ddinicialy = objposicaocursor.ddy;
			}
		}
		catch(e){var e = "";}
	};
	docMapa.onclick = function()
	{
		try
		{
			objmapa.verificaClickMapa();
		}
		catch(e){var e = "";}
	};
	docMapa.onmouseup = function()
	{
		try
		{
			if (g_tipoacao == "zoomli"){zoomboxf("termina");}
			if (g_tipoacao == "selecaobox"){zoomboxf("termina");}
			//
			//realiza o pan (deslocamento) do mapa em função de dois pontos
			//
			if ($i("img") && (g_tipoacao == "pan"))
			{
				g_panM = "nao";
				var disty = (ddinicialy * -1) + objposicaocursor.ddy; //teladd[1]
				var distx = (ddinicialx * -1) + objposicaocursor.ddx; //teladd[0]
				var ex = objmapa.extent;
				var ex = ex.split(" ");
				var novoxi = (ex[0] * 1) - distx;
				var novoxf = (ex[2] * 1) - distx;
				var novoyi = (ex[1] * 1) - disty;
				var novoyf = (ex[3] * 1) - disty;	
				if ((distx == 0)||(disty == 0))
				{
					objaguarde.abre("ajaxredesenha",$trad("o1"));
					var p = g_locaplic+"/classesphp/mapa_controle.php?funcao=pan&x="+objposicaocursor.imgx+"&y="+objposicaocursor.imgy+"&g_sid="+g_sid;
					cpObj.call(p,"pan",ajaxredesenha);
					return;
				}
				var nex = novoxi+" "+novoyi+" "+novoxf+" "+novoyf;
				objaguarde.abre("ajaxredesenha",$trad("o1"));
				var p = g_locaplic+"/classesphp/mapa_controle.php?funcao=mudaext&tipoimagem="+g_tipoimagem+"&ext="+nex+"&g_sid="+g_sid;
				cpObj.call(p,"mudaExtensao",ajaxredesenha);
			}
		}
		catch(e){var e = "";}
	};
}
/*
Section: navegação
*/
/*
Function: zoomAnterior

Retorna ao zoom anterior do mapa.

A memória das extensões geográficas são mantidas nos quador s de animação (objeto quadrosfilme).
*/
function zoomAnterior()
{
	try
	{
		var n = quadrosfilme.length;
		//
		//pega o quadro anterior com extensão diferente da atual
		//
		var muda = 0;
		for (var i = (n - 1); i > 0; i--)
		{
			if (quadrosfilme[i].extensao != ' ' && quadrosfilme[i].extensao == objmapa.extent)
			{
				var muda = i - 1;break;
			}
		}
		function retorna(retorno)
		{
			ajaxredesenha(retorno);
			//
			//zera os novos quadros adicionados
			//
			for (var i = n-1; i > muda; i--)
			{
				$i("f"+(i)).className = "quadro";
				var qu = new quadrofilme();
				quadrosfilme[i] = qu;
			}
		}
		if(quadrosfilme[muda].extensao != " ")
		{
			g_zoomProximo.push(objmapa.extent);
			var p = g_locaplic+"/classesphp/mapa_controle.php?funcao=mudaext&tipoimagem="+g_tipoimagem+"&ext="+quadrosfilme[muda].extensao+"&g_sid="+g_sid;
			objaguarde.abre("ajaxredesenha",$trad("o1"));
			cpObj.call(p,"mudaExtensao",retorna);
		}
	}
	catch(e){var e = "";}
}
/*
Function: zoomProximo

Avança para o zoom definido antes de aplciar o zoom anterior.

A memória das extensões geográficas são mantidas no array g_zoomProximo.
*/
function zoomProximo()
{
	try
	{
		var n = g_zoomProximo.length;
		if (n > 0 && g_zoomProximo[n-1] != objmapa.extent)
		{
			var p = g_locaplic+"/classesphp/mapa_controle.php?funcao=mudaext&tipoimagem="+g_tipoimagem+"&ext="+g_zoomProximo[n-1]+"&g_sid="+g_sid;
			objaguarde.abre("ajaxredesenha",$trad("o1"));
			cpObj.call(p,"mudaExtensao",ajaxredesenha);
			g_zoomProximo.pop();
		}
	}
	catch(e){var e = "";}	
}
/*
Function: pegaCoordenadaUTM

Mostra as coordenadas do mouse em UTM.

Disparada apenas quando o mouse é estacionado por alguns instantes sobre o mapa.<b> 

Para que esta função seja executada, é necessário existir um DIV com id=mostraUTM
*/
function pegaCoordenadaUTM()
{
	if (objmapa.parado != "sim"){return;}
	if (!$i("mostraUTM")){return;}
	var mostra = function(retorno)
	{
		$i("mostraUTM").style.display="block";
		$i("mostraUTM").innerHTML = "UTM: x="+retorno.data.x+" y="+retorno.data.y+" zona="+retorno.data.zona+" datum="+retorno.data.datum;
	};
	var p = g_locaplic+"/classesphp/mapa_controle.php?funcao=geo2utm&x="+objposicaocursor.ddx+"&y="+objposicaocursor.ddy+"&g_sid="+g_sid;
	var cp = new cpaint();
	//cp.set_debug(2)
	cp.set_persistent_connection(true);
	cp.set_response_type("JSON");
	cp.call(p,"geo2utm",mostra);
}
/*
Function: mostraRosaDosVentos

Mostra a rosa dos ventos quando o mouse é estacionado por alguns instantes sobre o mapa.

Executado apenas se a variável g_mostraRosa = "sim"
*/
function mostraRosaDosVentos()
{
	if ((objmapa.parado == "parar") || (objmapa.parado=="cancela") || g_mostraRosa == "nao"){return;}
	//mostra opção sobre o mouse quando está na função pan
	if (($i("box1")) && (objmapa.parado == "sim") && (document.getElementById("imgh").style.display=="block") && ($i("box1").style.visibility != "visible"))
	{
		if ((g_tipoacao == "zoomli") || (g_tipoacao == "zoomlo") || (g_tipoacao == "pan"))
		{
			if(g_mostraRosa == "sim")
			{
				if($i("tip").style.opacity)
				{$i("tip").style.opacity=".7";}
				else
				{$i("tip").style.filter = "alpha(opacity=70)";}		
				var setas = "<table id='rosaV' ><tr>";
				setas += "<td><img class='rosanoroeste' title='noroeste' src='"+$im("branco.gif")+"' onclick=\"panFixo('noroeste')\" /></td>";
				setas += "<td><img class='rosanorte' title='norte' src='"+$im("branco.gif")+"' onclick=\"panFixo('norte')\" /></td>";
				setas += "<td><img class='rosanordeste' title='nordeste' src='"+$im("branco.gif")+"' onclick=\"panFixo('nordeste')\" /></td></tr>";
				setas += "<tr><td><img class='rosaoeste' title='oeste' src='"+$im("branco.gif")+"' onclick=\"panFixo('oeste')\" /></td>";
				setas += "<td><table><tr>";
				setas += "<td><img class='rosamais' title='aproxima' onclick='zoomiauto()' src='"+$im("branco.gif")+"' </td>";
				setas += "<td><img class='rosamenos' title='afasta' onclick='zoomoauto()' src='"+$im("branco.gif")+"' </td>";
				setas += "</tr></table></td>";
				setas += "<td><img class='rosaleste' title='leste' src='"+$im("branco.gif")+"' onclick=\"panFixo('leste')\" /></td></tr>";
				setas += "<tr><td><img class='rosasudoeste' title='sudoeste' src='"+$im("branco.gif")+"' onclick=\"panFixo('sudoeste')\" /></td>";
				setas += "<td><img class='rosasul' title='sul' src='"+$im("branco.gif")+"' onclick=\"panFixo('sul')\" /></td>";
				setas += "<td><img class='rosasudeste' title='sudeste' src='"+$im("branco.gif")+"' onclick=\"panFixo('sudeste')\" /></td></tr></table>";
				var i = $i("tip");
				i.innerHTML = setas;
				i.style.top = objposicaocursor.telay - 27;
				i.style.left = objposicaocursor.telax - 27;
				i.style.display="block";
				mostradicasf('','Clique nas pontas da rosa para navegar no mapa. Clique em x para parar de mostrar essa opção.','');
				return;
			}
		}
	}
}
/*
Function: initJanelaZoom

Abre a janela com as ferramentas de zoom

Parametros:

qual - Qual janela (1 ou 2)
*/
function initJanelaZoom(qual)
{
	//janela de botoes 1
	var wj = "36px";
	var recuo = "0px";
	if ((qual == 1) && (!$i("maisBotoes1"))  && ($i("barraDeBotoes1")))
	{
		var novoel = document.createElement("div");
		novoel.id = "janelaBotoes1";
		novoel.style.display="block";
		novoel.style.border="1px solid gray";
		if (navm)
		{novoel.style.filter='alpha(opacity=90)';}
		else
		{novoel.style.opacity= .85;}
		var temp = '<div class="hd">&nbsp;</div>';
		temp += '<div class="bd" style="background-color:rgb(250,250,250);width='+wj+'px"  >';
		//barra de zoom
		if ($i("zoomli"))
		{
			if (navn){temp += '<div style="text-align:center;position:relative;left:9px" >';}
			temp += '<div id="vertMaisZoom" onmouseover="mostradicasf(this,\'Amplia o mapa mantendo o centro atual.\',\'\')" onclick="zoomiauto()" ></div><div id="vertBGDiv" name="vertBGDiv" tabindex="0" x2:role="role:slider" state:valuenow="0" state:valuemin="0" state:valuemax="200" title="Zoom" >';
			temp += '<div id="vertHandleDiv" ><img alt="" class="slider" src="'+$im("branco.gif")+'" /></div></div>';
			temp += '<div id=vertMenosZoom onmouseover="mostradicasf(this,\'Reduz o mapa mantendo o centro atual.\',\'\')" onclick="zoomoauto()"  ></div>';
			if (navn){temp += '</div>';}
		}
		temp += '<div id="maisBotoes1" style="left:'+recuo+'" ></div></div>';
		novoel.innerHTML = temp;
		document.body.appendChild(novoel);
		//copia os botoes do HTML para a janela
		if ($i("barraDeBotoes1"))
		{
			$i("maisBotoes1").innerHTML = $i("barraDeBotoes1").innerHTML+"<table><tr><td>&nbsp;</td></tr></table>";
			$i("barraDeBotoes1").innerHTML = "";
		}
		YAHOO.namespace("janelaBotoes1.xp");
		YAHOO.janelaBotoes1.xp.panel = new YAHOO.widget.Panel("janelaBotoes1", {width:wj, fixedcenter: false, constraintoviewport: false, underlay:"none", close:true, visible:true, draggable:true, modal:false } );
		YAHOO.janelaBotoes1.xp.panel.render();
		verticalSlider = YAHOO.widget.Slider.getVertSlider("vertBGDiv","vertHandleDiv", 0, 70);
		verticalSlider.onChange = function(offsetFromStart)
		{g_fatordezoom = (offsetFromStart - 35) / 5;};
		verticalSlider.setValue(35,true);
		if ($i("vertBGDiv"))
		{
			$i("vertBGDiv").onmouseup = function()
			{
				aplicaescala();
				g_fatordezoom = 0;
				verticalSlider.setValue(35,true);
			};
		}
		//altera o tamanho da imagem do mapa
		if($i("vertHandleDiv"))
		{
			$i("vertHandleDiv").onmousemove = function()
			{
				var nw = objmapa.w;
				var nh = objmapa.h;
				var nt = 0;
				var nl = 0;
				var ns = parseInt(objmapa.scale);
				if ((g_fatordezoom > 0) && (g_fatordezoom < 7))
				{
					g_fatordezoom = g_fatordezoom + 1;
					var velhoh = parseInt($i("img").style.height);
					var velhow = parseInt($i("img").style.width);
					nh = objmapa.h / g_fatordezoom;
					nw = objmapa.w / g_fatordezoom;
					var t = parseInt($i("img").style.top);
					var l = parseInt($i("img").style.left);
					nt=t + ((velhoh - nh)*.5);
					if (navm){nl=0;}
					else
					{nl=l + ((velhow - nw)*.5);}
					var fatorEscala = nh/objmapa.h;
					ns=parseInt(objmapa.scale / fatorEscala);
				}
				if ((g_fatordezoom < 0) && (g_fatordezoom > -7))
				{
					g_fatordezoom = g_fatordezoom - 1;
					var velhoh = parseInt($i("img").style.height);
					var velhow = parseInt($i("img").style.width);
					nh = objmapa.h * g_fatordezoom * -1;
					nw = objmapa.w * g_fatordezoom * -1;
					var t = parseInt($i("img").style.top);
					var l = parseInt($i("img").style.left);
					nt = t - ((nh - velhoh)*.5);
					nl = l - ((nw - velhow)*.5);
					var fatorEscala = nh/objmapa.h;
					ns=parseInt(objmapa.scale / fatorEscala);
				}
				$i("img").style.width = nw;
				$i("img").style.height = nh;
				$top("img",nt);
				$left("img",nl);
				if ($i("escalanum"))
				{$i("escalanum").value=ns;}
			};
		}		
		return;
	}
	if ((qual == 1) && ($i("maisBotoes1")) )
	{YAHOO.janelaBotoes1.xp.panel.show();}
	//janela de botoes 2
	if ((qual == 2) && (!$i("maisBotoes2"))  && ($i("barraDeBotoes2")))
	{
		var novoel = document.createElement("div");
		novoel.id = "janelaBotoes2";
		novoel.style.display="block";
		novoel.style.border="1px solid gray";
		if (navm)
		{novoel.style.filter='alpha(opacity=90)';}
		else
		{novoel.style.opacity= .85;}
		var temp = '<div class="hd">&nbsp;</div>';
		temp += '<div class="bd" style="background-color:rgb(250,250,250);width='+wj+'px"  >';		
		temp += '<div id="maisBotoes2" style="left:'+recuo+';top:-6px;"  ></div></div>';
		novoel.innerHTML = temp;
		document.body.appendChild(novoel);
		//copia os botoes do HTML para a janela
		if ($i("barraDeBotoes2"))
		{
			$i("maisBotoes2").innerHTML = $i("barraDeBotoes2").innerHTML;
			$i("barraDeBotoes2").innerHTML = "";
		}
		YAHOO.namespace("janelaBotoes2.xp");
		YAHOO.janelaBotoes2.xp.panel = new YAHOO.widget.Panel("janelaBotoes2", {width:wj, fixedcenter: false, constraintoviewport: false, underlay:"none", close:true, visible:true, draggable:true, modal:false } );
		YAHOO.janelaBotoes2.xp.panel.render();
		return;
	}
	if ((qual == 2) && ($i("maisBotoes2")))
	{YAHOO.janelaBotoes2.xp.panel.show();}
}
/*
Function: initJanelaRef

Abre a janela com o mapa de referencia
*/
function initJanelaRef()
{
	if (!$i("winRef"))
	{
		var novoel = document.createElement("div");
		novoel.id = "winRef";
		novoel.style.display="none";
		novoel.style.borderColor="gray";
		var ins = '<div class="hd">';
		var temp = "javascript:if(g_zoomRefDinamico == -1){g_zoomRefDinamico = 1};g_zoomRefDinamico = g_zoomRefDinamico + 1 ;$i(\"refDinamico\").checked = true;objmapa.atualizaReferencia();";
		ins += "<img class=mais onclick='"+temp+"' src="+$im("branco.gif")+" />";
		var temp = "javascript:if(g_zoomRefDinamico == 1){g_zoomRefDinamico = -1};g_zoomRefDinamico = g_zoomRefDinamico - 1 ;$i(\"refDinamico\").checked = true;objmapa.atualizaReferencia();";
		ins += "<img class=menos onclick='"+temp+"' src="+$im("branco.gif")+" />&nbsp;";
		ins += '<input style="cursor:pointer" onclick="javascript:objmapa.atualizaReferencia()" type="checkbox" id="refDinamico" />&nbsp;'+$trad("o6")+'</div>';
		ins += '<div class="bd" style="text-align:left;padding:3px;" id="mapaReferencia" onmouseover="javascript:movimentoRef(this)" onclick="javascript:clicouRef()">';
		ins += '<img style="cursor:pointer;" id=imagemReferencia src="" >';
		ins += '<div id=boxRef style="position:absolute;top:0px;left:0px;width:10px;height:10px;border:2px solid blue;display:none"></div></div>';
		ins += '<div style="text-align:left;font-size:0px" id="refmensagem" ></div></div>';
		novoel.innerHTML = ins;
		document.body.appendChild(novoel);
		$i("imagemReferencia").style.height = objmapa.refheight+"px";
	}
	if($i("winRef").style.display != "block")
	{
		$i("winRef").style.display = "block";
		YAHOO.namespace("janelaRef.xp");
		YAHOO.janelaRef.xp.panel = new YAHOO.widget.Panel("winRef", { width:"156px", fixedcenter: false, constraintoviewport: true, underlay:"shadow", close:true, visible:true, draggable:true, modal:false } );
		YAHOO.janelaRef.xp.panel.render();
		var pos = pegaPosicaoObjeto($i("img"));
		if (navm){YAHOO.janelaRef.xp.panel.moveTo((pos[0]+objmapa.w-160),pos[1]+4);}
		else
		{YAHOO.janelaRef.xp.panel.moveTo((pos[0]+objmapa.w-160),pos[1]+4);}
		var escondeRef = function()
		{
			YAHOO.util.Event.removeListener(YAHOO.janelaRef.xp.panel.close, "click");
			YAHOO.janelaRef.xp.panel.destroy();	
			iCookie("g_mapaRefDisplay","none");
		};
		YAHOO.util.Event.addListener(YAHOO.janelaRef.xp.panel.close, "click", escondeRef);	
		iCookie("g_mapaRefDisplay","block");
	}
	objmapa.atualizaReferencia();
}
/*
Function: mudaboxnf

Posiciona o botao aplicar quando o check box que liga/desliga um tema é pressionado.

Parâmetros:

tipo - de onde veio a requisicao ligadesliga|adicionatema

obj - objeto que foi clicado
*/
function mudaboxnf(tipo,obj)
{
	try
	{
		//
		//insere botao dinamico de aplicar se ainda não existir
		//
		if (!$i("aplicari"))
		{
			var novoel = document.createElement("input");
			novoel.id = 'aplicari';
			novoel.type = 'button';
			novoel.value = 'Aplicar';
			novoel.style.cursor="pointer";
			novoel.style.fontSize="10px";
			novoel.style.zIndex = 15000;
			novoel.style.position="absolute";
			novoel.style.display="none";
			novoel.onclick=function()
			{
				remapaf();
				this.style.display="none"
			};
			novoel.onmouseover = function(){this.style.display="block";};
			novoel.onmouseout = function(){this.style.display="none";};
			document.body.appendChild(novoel);
		}
		var pos = pegaPosicaoObjeto(obj);
		g_operacao = tipo;
		clearTimeout(objmapa.tempo);
		objmapa.tempo = setTimeout('remapaf()',(g_tempo_aplicar));
		autoRedesenho("reinicia");
		if ($i("aplicari"))
		{
			var i = $i("aplicari").style;
			i.display="block";
			var l = pos[0];
			var t = pos[1]-5;
			if (navn)
			{
				i.left = l;
				i.top = t;
			}			
			else
			{
				i.pixelLeft = l+document.body.scrollLeft;
				i.pixelTop = t+document.body.scrollTop;
			}
		}
	}
	catch(e){var e = "";}
}
/*
Function: movelentef

Move a imagem na lente de aumento conforme o movimento do mouse sobre o mapa.

A lente de aumento é uma ferramenta do i3geo.

Esta função é executada sempre que o mouse é movido sobre o mapa e se o elemento "lente" estiver visível.
*/
function movelentef()
{
	try
	{
		if ($i("lente"))
		{
			if ($i("lente").style.visibility=="visible")
			{
				var pos = pegaPosicaoObjeto($i("img"));
				var esq = (objposicaocursor.telax - pos[0]) * 2.25;
				var topo = (objposicaocursor.telay - pos[1]) * 2.25;
				var clipt = "rect("+ (topo - 40) + " " + (esq + 40) + " " + (topo + 40) + " " + (esq - 40) +")";
				var i = $i("lente").style;
				i.clip = clipt;
				eval("i." + g_tipotop + "= (pos[1] - (topo - 40)) + g_postpx");
				eval("i." + g_tipoleft +  "= (pos[0] - (esq - 40)) + g_postpx");
			}
		}
	}
	catch(e){var e = "";}
}
/*
Function: zoomiauto

Aproxima o mapa tendo o centro do mapa atual como referência.
*/
function zoomiauto()
{
	objaguarde.abre("ajaxredesenha",$trad("o1"));
	g_fatordezoom = 0;
	var p = g_locaplic+"/classesphp/mapa_controle.php?funcao=aproxima&nivel=2&g_sid="+g_sid;
	g_operacao = "navega";
	cpObj.call(p,"aproxima",ajaxredesenha);
}
/*
Function: zoomoauto

Afasta o mapa tendo o centro do mapa atual como referência.
*/
function zoomoauto()
{
	objaguarde.abre("ajaxredesenha",$trad("o1"));
	g_fatordezoom = 0;
	var p = g_locaplic+"/classesphp/mapa_controle.php?funcao=afasta&nivel=2&g_sid="+g_sid;
	g_operacao = "navega";
	cpObj.call(p,"afasta",ajaxredesenha);
}
/*
Function: zoomboxf

Faz o zoom no mapa utilizando a opção de desenhar um retângulo.

As coordenadas de tela devem estar no objeto "objposicaocursor".
A opção "desloca" altera a posição do box (box1) na tela. A opção "termina", pega as coordenadas
de tela do box1 e chama a função ajax que redesenha o mapa.

Parameters:

tipo - desloca|termina
*/
function zoomboxf(tipo)
{
	var pos = pegaPosicaoObjeto($i("img"));
	if($i("box1"))
	{
		var bx = $i("box1");
		var bxs = bx.style;
	}
	else
	{alert("Box nao encontrado");return;}
	switch(tipo)
	{
		case "desloca":
		// muda o ret�gulo de zoom conforme deslocamento do mouse
		bxs.display="block";
		ppx = objposicaocursor.telax;
		py = objposicaocursor.telay;
		if (navm)
		{
			if ((ppx > boxxini) && ((ppx - boxxini - 2) > 0))
			{bxs.width = ppx - boxxini - 2;}
			if ((py > boxyini) && ((py - boxyini - 2) > 0))
			{
				bxs.height = py - boxyini - 2;
			}
			if (ppx < boxxini)
			{bxs.left = ppx;bxs.width = boxxini - ppx + 2;}
			if (py < boxyini)
			{bxs.top = py;bxs.height = boxyini - py + 2;}
		}
		else
		{
			if (ppx > boxxini)
			{bxs.width = ppx - boxxini - 15 + "px";}
			if (py > boxyini)
			{bxs.height = py - boxyini - 15 + "px";}
			if (ppx < boxxini)
			{bxs.left = ppx + "px";bxs.width = boxxini - ppx + 15 + "px";}
			if (py < boxyini)
			{bxs.top = py + "px";bxs.height = boxyini - py + 15 + "px";}
		}
		break;
		case "termina":
		// finaliza o ret�gulo de zoom
		md = 1;
		eval ('pix = parseInt(document.getElementById("box1").style.' + g_tipoleft + ")");
		eval ('piy = parseInt(document.getElementById("box1").style.' + g_tipotop + ")");
		xfig0 = parseInt(bxs.width) - pos[0];
		yfig0 = parseInt(bxs.height) - pos[1];
		xfig = pix + (parseInt(bxs.width)) - pos[0];
		yfig = piy + (parseInt(bxs.height)) - pos[1];
		amext = objmapa.extent.split(" ");
		dx = ((amext[0] * -1) - (amext[2] * -1)) / (tamanhox - 1);
		dy = ((amext[1] * 1) - (amext[3] * 1)) / (tamanhoy - 1);
		if (dy < 0) dy=dy * -1;
		nx = g_celula * xfig;
		ny = g_celula * yfig;
		x1 = (amext[0] * 1) + nx;
		y1 = (amext[3] * 1) - ny;
		xfig = pix - pos[0];
		yfig = piy - pos[1];
		if (dy < 0) dy=dy * -1;
		nx = g_celula * xfig;
		ny = g_celula * yfig;
		x2 = (amext[0] * 1) + nx;
		y2 = (amext[3] * 1) - ny;
		v = x2+" "+y2+" "+x1+" "+y1;
		// se o retangulo for negativo pula essa parte para n� gerar erro
		if (g_tipoacao != "selecaobox")
		{
			if (x1 != x2)
			{
				objmapa.extent=v;
				objaguarde.abre("ajaxredesenha",$trad("o1"));
				var p = g_locaplic+"/classesphp/mapa_controle.php?funcao=mudaext&tipoimagem="+g_tipoimagem+"&ext="+v+"&g_sid="+g_sid;
				cpObj.call(p,"mudaExtensao",ajaxredesenha);
			}
		}
		else
		{
			if (x1 != x2)
			{
				try
				{
					var doc = (navm) ? document.frames("wdocai").document : $i("wdocai").contentDocument;
					var tipo = "adiciona";
					//pega o tipo de operacao da janela de selecao
					if (doc.getElementById("tipoOperacao")){tipo = doc.getElementById("tipoOperacao").value;}
					if (objmapa.temaAtivo == ""){alert("Nenhum tema ativo");return;}
					//se tipo for limpa ou inverte, a operacao nao e executada no clique no mapa
					if ((tipo != "limpa") && (tipo != "inverte"))
					{
						objaguarde.abre("ajaxredesenha",$trad("o1"));
						var p = g_locaplic+"/classesphp/mapa_controle.php?funcao=selecaobox&ext="+v+"&g_sid="+g_sid+"&tipo="+tipo+"&tema="+objmapa.temaAtivo;
						cpObj.call(p,"selecaobox",ajaxredesenha);
					}
				}
				catch(e){var e = "";}
			}
		}		
		bxs.visibility="hidden";
		bxs.width = 0;
		bxs.height = 0;
		document.getElementById("imgh").style.display="block";
		break;
	}
}
/*
Function: zoomIP

Localiza no mapa o usuário baseado em seu número IP.

O ponto de localização é adicionado ao mapa como um novo tema.
*/
function zoomIP()
{
	try
	{
		var xxx = convdmsddf($i("xg").value,$i("xm").value,$i("xs").value);
		var yyy = convdmsddf($i("yg").value,$i("ym").value,$i("ys").value);
		var mostraIP = function(retorno)
		{
			if (retorno.data.latitude != null)
			{
				objaguarde.abre("ajaxredesenha",$trad("o1"));
				var p = g_locaplic+"/classesphp/mapa_controle.php?funcao=zoomponto&pin=pin&tamanho=14&xy="+retorno.data.longitude+" "+retorno.data.latitude+"&g_sid="+g_sid;
				cpObj.call(p,"zoomPonto",ajaxredesenha);
			}
			else
			{alert("Nao foi possivel identificar a localizacao.");}
		};
		var p = g_locaplic+"/classesphp/mapa_controle.php?funcao=localizaIP&g_sid="+g_sid;
		cpObj.call(p,"localizaIP",mostraIP);	
	}
	catch(e){var e = "";}
}
/*
Function: zoomPonto

Localiza uma coordenada no mapa e desloca o mapa centralizando no ponto.

O ponto de localização é adicionado ao mapa como um novo tema.
*/
function zoomPonto()
{
	try
	{
		if ($i("xg"))
		{
			var xxx = convdmsddf($i("xg").value,$i("xm").value,$i("xs").value);
			var yyy = convdmsddf($i("yg").value,$i("ym").value,$i("ys").value);
			objaguarde.abre("ajaxredesenha",$trad("o1"));
			var p = g_locaplic+"/classesphp/mapa_controle.php?funcao=zoomponto&pin=pin&xy="+xxx+" "+yyy+"&g_sid="+g_sid;
			cpObj.call(p,"zoomPonto",ajaxredesenha);
		}
	}
	catch(e){var e = "";}
}
/*
Function: clicouRef

Altera a abrangência do mapa quando o mapa de referência é clicado
*/
function clicouRef()
{
	try
	{
		objaguarde.abre("ajaxredesenha",$trad("o1"));
		var p = g_locaplic+"/classesphp/mapa_controle.php?funcao=pan&escala="+objmapa.scale+"&tipo=ref&x="+objposicaocursor.refx+"&y="+objposicaocursor.refy+"&g_sid="+g_sid;
		cpObj.call(p,"pan",ajaxredesenha);
	}
	catch(e){var e = "";objaguarde.fecha("ajaxredesenha");}
}
/*
Function: movimentoRef

Pega a coordenada do cursor sobre o mapa de referência
*/
function movimentoRef(obj)
{
	obj.onmousemove =function(exy)
	{
		capturaposicao(exy);
	};
}
/*
Function: aplicaescala

Aplica a escala numerica definida no formulário existente no mapa.

O valor da escala a ser aplicada é obtido do elemento com id="escalanum"
*/
function aplicaescala()
{
	if ($i("escalanum"))
	{var nova = $i("escalanum").value;}
	else
	{var nova = objmapa.scale;}
	objaguarde.abre("ajaxredesenha",$trad("o1"));
	var p = g_locaplic+"/classesphp/mapa_controle.php?funcao=mudaescala&escala="+nova+"&g_sid="+g_sid;
	g_operacao = "outras";
	cpObj.call(p,"mudaEscala",ajaxredesenha);
}
/*
Function: zoomtot

Zoom para a extensão default.

O valor da extensão default é obtido de objmapa.extentTotal, cujo valor é definido na inicialização do mapa.
*/
function zoomtot()
{
	objaguarde.abre("ajaxredesenha",$trad("o1"));
	var p = g_locaplic+"/classesphp/mapa_controle.php?funcao=mudaext&tipoimagem="+g_tipoimagem+"&ext="+objmapa.extentTotal+"&g_sid="+g_sid;
	g_operacao = "navega";
	cpObj.call(p,"mudaExtensao",ajaxredesenha);
}
/*
Function: panFixo

Desloca o mapa em uma direção determinada.

Parameters:

direcao - norte|sul|leste|oeste
*/
function panFixo(direcao)
{
	if (direcao == "norte")
	{
		var y = objmapa.h / 6;
		var x = objmapa.w / 2;
	}
	if (direcao == "sul")
	{
		var y = objmapa.h - (objmapa.h / 6);
		var x = objmapa.w / 2;
	}
	if (direcao == "leste")
	{
		var x = objmapa.w - (objmapa.w / 6);
		var y = objmapa.h / 2;
	}
	if (direcao == "oeste")
	{
		var x = objmapa.w / 6;
		var y = objmapa.h / 2;
	}
	if (direcao == "nordeste")
	{
		var y = objmapa.h / 6;
		var x = objmapa.w - (objmapa.w / 6);
	}
	if (direcao == "sudeste")
	{
		var y = objmapa.h - (objmapa.h / 6);
		var x = objmapa.w - (objmapa.w / 6);
	}
	if (direcao == "noroeste")
	{
		var y = objmapa.h / 6;
		var x = objmapa.w / 6;
	}
	if (direcao == "sudoeste")
	{
		var y = objmapa.h - (objmapa.h / 6);
		var x = objmapa.w / 6;
	}
	objaguarde.abre("ajaxredesenha",$trad("o1"));
	var p = g_locaplic+"/classesphp/mapa_controle.php?funcao=pan&escala="+objmapa.scale+"&x="+x+"&y="+y+"&g_sid="+g_sid;
	g_operacao = "navega";
	cpObj.call(p,"pan",ajaxredesenha);
}
/*
Function: ativaEntorno

Ativa ou desativa a carga do entorno.

Com o entorno ativo, são produzidas imagens no entorno do mapa, no estilo Google.
*/
function ativaEntorno()
{
	if(objmapa.mapfile == "")
	{alert("Essa opcao nao pode ser ativada. Consulte o administrador do sistema. Mapfile nao esta exposto.");return;}
	if (g_entorno == "sim")
	{
		var letras=["L","O","N","S"];
		for (var l=0;l<4; l++)
		{
			if ($i("img"+letras[l]))
			{
				$i("img"+letras[l]).style.display = "none";
				$i("img"+letras[l]).src = "";
			}
		}
		$left("img",0);
		$top("img",0);
		g_entorno = "nao";
		alert("Entorno desativado");
		$i("img").style.visibility = "visible";
		$i("img").style.display = "block";
	}
	else
	{
		geraURLentorno();
		var letras=["L","O","N","S"];
		for (var l=0;l<4; l++)
		{
			if ($i("img"+letras[l]))
			{
				$i("img"+letras[l]).style.width = objmapa.w;
				$i("img"+letras[l]).style.height = objmapa.h;
				$i("img"+letras[l]).style.display = "block";
			}
		}
		g_entorno = "sim";
		ajustaEntorno();
		alert("Entorno ativado. o desenho do mapa pode demorar mais.");
	}
}
/*
Function: geraURLentorno

Gera as urls que farão parte dos divs de desenho do entorno do mapa.
Essas URLs utilizam o mapserver no modo CGI
*/
function geraURLentorno()
{
	var nny = (objmapa.h / 2) * -1;
	var nnx = objmapa.w / 2;
	var sy = objmapa.h + (objmapa.h / 2);
	var sx = objmapa.w / 2;
	var lx = objmapa.w + (objmapa.w / 2);
	var ly = objmapa.h / 2;
	var ox = (parseInt(objmapa.w/2)) * -1;
	var oy = objmapa.h / 2;
	var u = window.location.protocol+"\/\/"+window.location.host+objmapa.cgi+"?map="+objmapa.mapfile;
	u += "&mode=map&imgext="+objmapa.extent+"&mapsize="+nnx+" "+oy;
	var sul = u+"&imgxy="+sx/2+" "+sy/2;
	var norte = u+"&imgxy="+nnx/2+" "+nny/2;
	var leste = u+"&imgxy="+lx/2+" "+ly/2;
	var oeste = u+"&imgxy="+ox/2+" "+oy/2;
	$i("imgS").src=sul;
	$i("imgN").src=norte;
	$i("imgL").src=leste;
	$i("imgO").src=oeste;
}
/*
Function: ajustaEntorno

Ajusta o tamanho do mapa e das imagens do entorno, quando a opção de desenho do entorno estiver ativa.

Os valores que definem o tamanho do mapa são obtidos do objeto objmapa (métodos w e h)
*/
function ajustaEntorno()
{
	$left("img",objmapa.w*-1);
	$left("imgS",objmapa.w*-1);
	$left("imgL",objmapa.w);
	$left("imgO",objmapa.w*-3);
	$left("imgN",objmapa.w*-1);
	$top("img",objmapa.h*-1);
	$top("imgS",objmapa.h*-1);
	$top("imgL",objmapa.h*-1);
	$top("imgN",objmapa.h*-1);
	$top("imgO",objmapa.h*-1);
}
/*
Section: atributos
*/
/*
Function: verificaTip

Verifica se a opção de identificação está ativa e se o mouse está parado.
Se o mouse estiver parado, chama a função de mostrar tip.

A função de busca dos dados para a etiqueta é definida na variável de configuração g_funcaoTip

Pode-se definir uma outra função qualquer, sem a necessidade de alteração do código original do i3geo, definindo-se
no HTML da interface a variável, por exemplo, gfuncaoTip = "minhasEtiquetas()"

Por default, utiliza-se a função verificaTipDefault()
*/
function verificaTip()
{
	if ((objmapa.parado == "parar") || (objmapa.parado=="cancela") || (g_operacao != "identifica")){return;}
	//insere div para tips
	if (!$i("tip"))
	{
		var novoel = document.createElement("div");
		novoel.id = "tip";
		novoel.style.position="absolute";
		novoel.style.zIndex=5000;
		if (navm)
		{novoel.style.filter = "alpha(opacity=90)";}
		document.body.appendChild(novoel);
	}
	if ((objmapa.parado == "sim") && (g_operacao == "identifica") && ($i("tip").style.display!="block"))
	{
		var i = $i("tip");
		var ist = i.style;
		ist.top = objposicaocursor.telay +20;
		ist.left = objposicaocursor.telax;
		i.innerHTML = "<table style='text-align:left'><tr><td style='text-align:left'>Pesquisando...</td></tr></table>";
		ist.display="block";
		eval(g_funcaoTip);
	}
	if ((objmapa.parado!="cancela") && ($i("tip").style.display!="block"))
	{objmapa.parado = "sim";}
}
/*
Function: verificaTipDefault

Executa a operação de identificação para mostrar uma etiqueta no mapa.

Esta é a função default, definida na variável g_funcaoTip
*/
function verificaTipDefault()
{
	var p = g_locaplic+"/classesphp/mapa_controle.php?funcao=identifica&opcao=tip&xy="+objposicaocursor.ddx+","+objposicaocursor.ddy+"&resolucao=5&g_sid="+g_sid;
	var cp = new cpaint();
	//cp.set_debug(2)
	cp.set_persistent_connection(true);
	cp.set_response_type("JSON");
	cp.call(p,"identifica",mostraTip);
}
/*
Function: mostraTip

Mostra a descrição de um elemento do mapa como uma etiqueta na posição do mouse.

Para que um tema tenha uma etiqueta, é necessário configurar o metadata TIP no map file.

Parameters:

retorno - retorno da função ajax com os dados para montar a etiqueta.
*/
function mostraTip(retorno)
{
	var retorno = retorno.data;
	if ((retorno != "erro") && (retorno != undefined))
	{
		if ($i("img"))
		{$i("img").title = "";}
		if (retorno != "")
		{
			var res = "<div id='cabecatip' style='text-align:left;background-color:rgb(240,240,240)'><span style='color:navy;cursor:pointer;text-align:left' onclick='javascript:objmapa.parado=\"cancela\"'>parar&nbsp;&nbsp;</span>";
			res += "<span style='color:navy;cursor:pointer;text-align:left' onclick='javascript:objmapa.objtips.push($i(\"tip\"));$i(\"tip\").id=\"\";$i(\"cabecatip\").innerHTML =\"\";$i(\"cabecatip\").id =\"\"' >fixar</span></div>";
			var temas = retorno.split("!");
			var tema = temas.length-1;
			if(tema >= 0)
			{
				do
				{
					var titulo = temas[tema].split("@");
					if (g_tipotip == "completo")
					{
						res += "<span style='text-align:left;font-size:9pt'><b>"+titulo[0]+"</b></span><br>";
					}
					var ocorrencias = titulo[1].split("*");
					var ocorrencia = ocorrencias.length-1;
					if(ocorrencia >= 0)
					{
						do
						{
							if (ocorrencias[ocorrencia] != "")
							{
								var pares = ocorrencias[ocorrencia].split("##");
								var paresi = pares.length;
								for (var par=0;par<paresi; par++)
								{
									var valores = pares[par].split("#");
									if (g_tipotip == "completo")
									{
										res = res + "<span class='tiptexto' style='text-align:left;font-size:9pt'>" + valores[0] + " <i>" + valores[1] + "</i></span><br>";
									}
									else
									{
										res = res + "<span class='tiptexto' style='text-align:left;font-size:9pt'><i>" + valores[1] + "</i></span><br>";
									}
								}
							}
						}
						while(ocorrencia--)
					}
				}
				while(tema--)
			}
			if ($i("janelaMen"))
			{
				$i("janelaMenTexto").innerHTML = res;
			}
			else
			{
				var i = $i("tip");
				i.innerHTML = "<table style='text-align:left'><tr><td style='text-align:left'>"+res+"</td></tr></table>";
				ist = i.style;
				ist.top = objposicaocursor.telay - 10;
				ist.left = objposicaocursor.telax - 20;
				ist.display="block";
			}
		}
	}
}
/*
Section: legenda
*/
/*
Function: legendaGrafico

Mostra a legenda dos gráficos adicionados no mapa.

Chamado pela ferramenta de inclusão de gráficos

Parâmetros:

par - string com os parâmetros item*r,g,b*item....
*/
function legendaGrafico(par)
{
	try
	{
		var temp = par.split("*");
		var par = "<table>";
		var i = temp.length-1;
		if(i >= 0)
		{
			do
			{
				var t = temp[i];
				var t = t.split(",");
				par += "<tr style='text-align:left'><td style='background-color:rgb("+t[1]+","+t[2]+","+t[3]+")'>&nbsp;&nbsp;</td><td style='text-align:left'>"+t[0]+"</td></tr>";
			}
			while(i--)
		}
		par += "</table>";
		if (!$i("legendagr"))
		{
			var novoel = document.createElement("div");
			var temp = '<div class="hd">Legenda</div>';
			temp += '<div class="bd">';
			temp += '<div id="contemleggr" ></div></div>';
			novoel.id = "legendagr";
			novoel.style.display="block";
			novoel.style.textAlign="left";
			novoel.innerHTML = temp;
			document.body.appendChild(novoel);
			YAHOO.namespace("legendagr.xp");
			YAHOO.legendagr.xp.panel = new YAHOO.widget.Panel("legendagr", {width:"250px", fixedcenter: true, constraintoviewport: false, underlay:"none", close:true, visible:true, draggable:true, modal:false } );
		}
		$i("contemleggr").innerHTML = par;
		YAHOO.legendagr.xp.panel.render();
		YAHOO.legendagr.xp.panel.show();
	}
	catch(e){alert("Ocorreu um erro. legendaGrafico"+e);}
}
/*
Function: inverteStatusClasse

Ativa ou desativa a visualização de uma classe de um tema.

Parameters:

leg - objeto input clicado no mapa
*/
function inverteStatusClasse(leg)
{
	var p = g_locaplic+"/classesphp/mapa_controle.php?funcao=inverteStatusClasse&g_sid="+g_sid+"&tema="+leg.name+"&classe="+leg.value;
	cpObj.call(p,"inverteStatusClasse",ajaxredesenha);
}
/*
Section: sistemas de busca e navegação
*/
/*
Function: atualizagoogle

Atualiza o box do google se a função google estiver ativa
*/
function atualizagoogle()
{
	if (frames["wdocai"])
	{
		if (navn)
		{
			if ($i("wdocai"))
			{var doc = $i("wdocai").contentDocument;}
		}
		else
		{
			if(document.frames("wdocai"))
			{var doc = document.frames("wdocai").document;}
		}
		if(doc)
		{
			if (doc.getElementById("map"))
			{
				if(window.parent.frames["wdocai"].panTogoogle)
				{window.parent.frames["wdocai"].panTogoogle();}
			}
		}
	}
}
/*
Function: atualizascielo

Atualiza a lista de dados na opção de busca Scielo
*/
function atualizascielo()
{
	if ($i("wdocai"))
	{
		if (window.parent.frames["wdocai"])
		{
			var docel = (navm) ? document.frames("wdocai").document : $i("wdocai").contentDocument;
			if (docel.getElementById("resultadoscielo"))
			{
				$i("wdocai").src = g_locaplic+"/ferramentas/scielo/index.htm";
			}
		}
	}
}	
/*
Function: atualizaconfluence

Atualiza a lista de dados na opção de busca confluence
*/
function atualizaconfluence()
{
	if($i("wdocai"))
	{
		if (window.parent.frames["wdocai"])
		{
			var docel = (navm) ? document.frames("wdocai").document : $i("wdocai").contentDocument;
			if (docel.getElementById("resultadoconfluence"))
			{
				$i("wdocai").src = g_locaplic+"/ferramentas/confluence/index.htm";
			}
		}
	}
}
/*
Function: atualizawiki

Atualiza a lista de dados na opção de busca wiki
*/
function atualizawiki()
{
	if ($i("wdocai"))
	{
		if (window.parent.frames["wdocai"])
		{
			var docel = (navm) ? document.frames("wdocai").document : $i("wdocai").contentDocument;
			if (docel.getElementById("resultadowiki"))
			{
				$i("wdocai").src = g_locaplic+"/ferramentas/wiki/index.htm";
			}
		}
	}
}
/*
Section: menu de temas e outras listagens
*/
/*
Function: procurartemas

Localiza um tema no menu de temas.

O texto para busca é obtido do elemento INPUT com id="buscatema", ou no parâmetro "texto"

Parameters:

texto - (opcional)
*/
function procurartemas(texto)
{
	if (document.getElementById("buscatema"))
	var procurar = removeAcentos(document.getElementById("buscatema").value);
	else
	var procurar = removeAcentos(texto);
	var resultadoProcurar = function(retorno)
	{
		if(!retorno.data)
		{$i("achados").innerHTML = "<span style='color:red'>Nada encontrado<br><br></span>";return;}
		var retorno = retorno.data;
		var conta = 0;
		if ((retorno != "erro") && (retorno != undefined))
		{
			var ins = "";
			var ig = retorno.length-1;
			if(ig >= 0)
			{
				do
				{
					var ngSgrupo = retorno[ig].subgrupos;
					var tempn = ngSgrupo.length;
					for (var sg=0;sg<tempn;sg++)
					{
						var nomeSgrupo = ngSgrupo[sg].subgrupo;
						var ngTema = ngSgrupo[sg].temas;
						var tempng = ngTema.length;
						for (var st=0;st<tempng;st++)
						{
								if ( ngTema[st].link != " ")
								{var lk = "<a href='"+ngTema[st].link+"' target='blank'>&nbsp;fonte</a>";}
								var tid = ngTema[st].tid;
								var inp = "<input style='text-align:left;cursor:pointer;' onclick='mudaboxnf(\"adiciona\",this)' class='inputsb' style='cursor:pointer' type='checkbox' value='"+tid+"'  /> ("+nomeSgrupo+")";
								var nomeTema = inp+(ngTema[st].nome)+lk+"<br>";
								ins += nomeTema;
								conta++;
						}
					}
				}
				while(ig--)
			}
			if (ins != "")
			{
				$i("achados").innerHTML = "Total: "+conta+"<br>"+ins+"<br>";
			}
			else
			{$i("achados").innerHTML = "<span style='color:red'>Nada encontrado<br><br></span>";}
		}
	};
	$i("achados").innerHTML = "<span style='color:green'>Procurando...<br><br></span>";
	var p = g_locaplic+"/classesphp/mapa_controle.php?funcao=procurartemas&procurar="+procurar+"&g_sid="+g_sid;
	cpObj.call(p,"procurartemas",resultadoProcurar);
}
/*
Function: expandeTema

Busca dados sobre um tema quando o botão de expandir tema é clicado.

Os dados obtidos sobre o tema são utilizados para montagem do nó "opções" que é mostrado abaixo do nome do tema.

Algumas das opções apenas serão mostradas se a variável de configuração g_opcoesTemas = "sim"

Parameters:

itemID - Id do nó que foi expandido
*/
function expandeTema(itemID)
{
	var lista = (objmapa.temas).split(";");
	if (!document.getElementById("idx"+itemID))
	{
		var l = lista.length-1;
		if(l >= 0)
		{
			do
			{
				var ltema = lista[l].split("*");
				//codigo,status,nome,transparencia,tipo,selecao,escala,download,tem features,conexao,tem wfs
				if (ltema[0] == itemID)
				{
					var farol = "maisamarelo.png";
					if (ltema[8] == undefined){ltema[8] = "nao";}
					if (ltema[6]*1 < objmapa.scale*1)
					{
				 		var farol = "maisverde.png";
				 		var mfarol = $trad("t9");
					}
					if (ltema[6]*1 > objmapa.scale*1)
					{
				 		var farol = "maisvermelho.png";
						var mfarol = $trad("t10");
					}
					if (ltema[6] == 0)
					{
				 		var farol = "maisamarelo.png";
						var mfarol = $trad("t11");
					}
					tnome = "&nbsp;<img id='farol"+ltema[0]+"' src='"+$im(farol)+"' title='"+mfarol+"' \>";
					tnome += "&nbsp;<img  id='idx"+ltema[0]+"' class='x' src='"+$im("branco.gif")+"' title='"+$trad("t12")+"' onclick='excluitemaf(\""+ltema[0]+"\")' onmouseover=\"javascript:mostradicasf(this,'"+$trad("t12a")+"','exclui')\" onmouseout=\"javascript:mostradicasf(this,'')\" \>";
					tnome += "&nbsp;<img class='sobe' src='"+$im("branco.gif") +"' title='"+$trad("t13")+"' onclick='sobetemaf(\""+ltema[0]+"\")' onmouseover=\"javascript:mostradicasf(this,'"+$trad("t14")+"','sobe')\" onmouseout=\"javascript:mostradicasf(this,'')\" \>";
					tnome += "&nbsp;<img class='desce' src='"+$im("branco.gif") +"' title='"+$trad("t15")+"' onclick='descetemaf(\""+ltema[0]+"\")' onmouseover=\"javascript:mostradicasf(this,'"+$trad("t16")+"','desce')\" onmouseout=\"javascript:mostradicasf(this,'')\" \>";
					//a operação de zoom para o tema não funciona na interface flamingo
					if( (ltema[11] == "sim") && (!$i("flamingo")))
					{tnome += "&nbsp;<img class='extent' src='"+$im("branco.gif") +"' title='"+$trad("t17")+"' onclick='zoomtemaf(\""+ltema[0]+"\")' onmouseover=\"javascript:mostradicasf(this,'"+$trad("t18")+"','')\" onmouseout=\"javascript:mostradicasf(this,'')\" \>";}
					mytreeview1.createItem("temap0"+ltema[0], tnome, imgBranco, false, true, true, ltema[0]);
					if (g_opcoesTemas == "sim")
					{mytreeview1.createItem("opc"+ltema[0], $trad("t18a"), imgBranco, true, true, true, ltema[0]);}
					mytreeview1.createItem("legenda"+ltema[0], $trad("t18b"), imgBranco, true, true, true, ltema[0]);
					if (g_opcoesTemas == "sim")
					{
						var im = "";
						if (navn)
						{var im = "<img src='"+g_locaplic+"/imagens/branco.gif' width='0' height='13' />";}
						//transparencia
						if ((ltema[4] != 0) || (ltema[8] == "sim"))
						{
							tnome = "<span onclick='mudatranspf(\""+ltema[0]+"\")'>"+im+"<img class='ticOpcoesTemas' src='"+$im("branco.gif")+"' onmouseover=\"javascript:mostradicasf(this,'"+$trad("t19")+"','')\" onmouseout=\"javascript:mostradicasf(this,'')\" />"+$trad("t20")+" </span>"+$inputText("","","tr"+ltema[0],"","3",ltema[3])+"<img  class='tic' style='position:relative;top:3px;' onclick='mudatranspf(\""+ltema[0]+"\")' src='"+$im("branco.gif")+"' />";
							mytreeview1.createItem("temap1"+ltema[0], tnome, imgBranco, false, true, false, "opc"+ltema[0]);
						}
						//muda nome
						tnome = "<span onclick='mudanomef(\""+ltema[0]+"\")'>"+im+"<img class='ticOpcoesTemas' src='"+$im("branco.gif")+"' onmouseover=\"javascript:mostradicasf(this,'"+$trad("t21a")+"','')\" onmouseout=\"javascript:mostradicasf(this,'')\" />"+$trad("t21")+" </span>"+$inputText("","","nn"+ltema[0],"","10","")+"<img  class='tic' style='position:relative;top:3px;' onclick='mudanomef(\""+ltema[0]+"\")' src='"+$im("branco.gif")+"' />";
						mytreeview1.createItem("temap2"+ltema[0], tnome, imgBranco, false, true, false, "opc"+ltema[0]);
						if ((ltema[4] < 3) && (ltema[9] != 7))
						{
							tnome = "<span onmouseover=\"javascript:mostradicasf(this,'"+$trad("t22")+"','');this.style.textDecoration='underline';\" onmouseout=\"javascript:mostradicasf(this,'');this.style.textDecoration='none';\" onclick='procuraratribf(\""+ltema[0]+"\")'>"+im+"<img class='ticOpcoesTemas' src="+$im("branco.gif")+" />"+$trad("t23")+" </span>";
							mytreeview1.createItem("temap3"+ltema[0], tnome, imgBranco, false, true, false, "opc"+ltema[0]);
							tnome = "<span onmouseover=\"javascript:mostradicasf(this,'"+$trad("t24")+"','');this.style.textDecoration='underline';\" onmouseout=\"javascript:mostradicasf(this,'');this.style.textDecoration='none';\" onclick='toponimiaf(\""+ltema[0]+"\")'>"+im+"<img class='ticOpcoesTemas' src="+$im("branco.gif") + " />"+$trad("t25")+" </span>";
							mytreeview1.createItem("temap4"+ltema[0], tnome, imgBranco, false, true, false, "opc"+ltema[0]);
							tnome = "<span onmouseover=\"javascript:mostradicasf(this,'"+$trad("t26")+"','');this.style.textDecoration='underline';\" onmouseout=\"javascript:mostradicasf(this,'');this.style.textDecoration='none';\" onclick='etiquetas(\""+ltema[0]+"\")'>"+im+"<img class='ticOpcoesTemas' src="+$im("branco.gif") + " />"+$trad("t27")+" </span>";
							mytreeview1.createItem("temap7"+ltema[0], tnome, imgBranco, false, true, false, "opc"+ltema[0]);
							tnome = "<span onmouseover=\"javascript:mostradicasf(this,'"+$trad("t28")+"','');this.style.textDecoration='underline';\" onmouseout=\"javascript:mostradicasf(this,'');this.style.textDecoration='none';\" onclick='filtrof(\""+ltema[0]+"\")'>"+im+"<img class='ticOpcoesTemas' src="+$im("branco.gif") + " />"+$trad("t29")+" </span>";
							mytreeview1.createItem("temap5"+ltema[0], tnome, imgBranco, false, true, false, "opc"+ltema[0]);
							tnome = "<span onmouseover=\"javascript:mostradicasf(this,'"+$trad("t30")+"','');this.style.textDecoration='underline';\" onmouseout=\"javascript:mostradicasf(this,'');this.style.textDecoration='none';\" onclick='tabelaf(\""+ltema[0]+"\")'>"+im+"<img class='ticOpcoesTemas' src="+$im("branco.gif") + " />"+$trad("t31")+" </span>";
							mytreeview1.createItem("temap6"+ltema[0], tnome, imgBranco, false, true, false, "opc"+ltema[0]);
							if(objmapa.versaoms > 4)
							{
								tnome = "<span onmouseover=\"javascript:mostradicasf(this,'"+$trad("t37")+"','');this.style.textDecoration='underline';\" onmouseout=\"javascript:mostradicasf(this,'');this.style.textDecoration='none';\" onclick='graficotema(\""+ltema[0]+"\")'>"+im+"<img class='ticOpcoesTemas' src="+$im("branco.gif") + " />"+$trad("t37")+" </span>";
								mytreeview1.createItem("temap7"+ltema[0], tnome, imgBranco, false, true, false, "opc"+ltema[0]);
							}
						}
						if (ltema[4] < 4)
						{
							tnome = "<span onmouseover=\"javascript:mostradicasf(this,'"+$trad("t32")+"','');this.style.textDecoration='underline';\" onmouseout=\"javascript:mostradicasf(this,'');this.style.textDecoration='none';\" onclick='editaLegenda(\""+ltema[0]+"\")'>"+im+"<img class='ticOpcoesTemas' src='"+$im("branco.gif") + "' />"+$trad("t33")+" </span>";
							mytreeview1.createItem("temap7"+ltema[0], tnome, imgBranco, false, true, false, "opc"+ltema[0]);
						}
						tnome = "<span onmouseover=\"javascript:mostradicasf(this,'"+$trad("t34")+"','');this.style.textDecoration='underline';\" onmouseout=\"javascript:mostradicasf(this,'');this.style.textDecoration='none';\" onclick='destacaTema(\""+ltema[0]+"\")'>"+im+"<img class='ticOpcoesTemas' src='"+$im("branco.gif") + "' />"+$trad("t35")+" </span>";
						mytreeview1.createItem("temap8"+ltema[0], tnome, imgBranco, false, true, false, "opc"+ltema[0]);
					}
					mytreeview1.createItem("","", imgBranco, false, true, true, ltema[0]);
					break;
				}
			}
			while(l--)
		}
	}
	//verifica se clicou para expandir a legenda
	var tema = itemID.split("legenda");
	if (tema.length == 2)
	{
		var expandeLegendaVer = function (retorno)
		{
			if (retorno.data != undefined)
			{
				var original = retorno;
				//é um tema normal
				if (retorno.data.legenda)
				{
					var retorno = retorno.data.legenda;
					if (retorno[0])
					{
						if ((navn) && (!retorno[0].imagem))
						{tabela = retorno;}
						else
						{
							var i = retorno[0].imagem;
							var re = new RegExp("tiff", "g");
							var i = i.replace(re,'png');
							var tabela = "<img src='"+i+"' />";
						}					
						retorno = "";
					}
					else
					{
						var linhas = retorno.split("#");
						if (linhas.length > 1)
						{
							var linhas = retorno.split("|");
							var tabela = "<table >";
							var linha = linhas.length-1;
							if(linha >= 0)
							{
								do
								{
									var colunas = linhas[linha].split("#");
									var id = colunas[0]+"-"+colunas[1];
									var re = new RegExp("'", "g");
									var exp = colunas[3].replace(re,'"');
									tabela += "<tr style='border-top:1px solid rgb(240,240,240);'><td><img src='"+colunas[4]+"' </td><td style='text-align:left'>"+colunas[2]+"</td></tr>";
								}
								while(linha--)
							}
							tabela += "</table><br>";
						}
						else
						{tabela = retorno;}
					}
				}
				else //o tema é um wms
				{
					var tabela = "<img src='"+retorno.data[0].imagem+"' />";
				}
				if (!$i(g_arvoreClick+"verdiv"))
				{
					incluir = "<div style='text-align:left' id='"+g_arvoreClick+"verdiv"+"'>"+tabela+"</div>";
					mytreeview1.createItem(g_arvoreClick+"ver", incluir, imgBranco, false, true, true, g_arvoreClick);
				}
				else
				{
					$i(g_arvoreClick+"verdiv").innerHTML = tabela;
				}
				//desliga os checkbox que foram desativados
				//pega os objetos input
				var elementos = $i(g_arvoreClick+"verdiv").getElementsByTagName("input");
				var nelementos = elementos.length;
				var inputs = new Array();
				var i = 0;
				if (nelementos > 0)
				{
					do
					{
						if (elementos[i].type == "checkbox")
						{inputs.push(elementos[i]);}
						i++;
					}
					while(i < nelementos)
				}
				if(original.data.desativar)
				{
					var desativar = original.data.desativar;
					var nindices = desativar.length;
					var i = 0;
					if (nindices > 0)
					{
						do
						{
							inputs[desativar[i]].checked = false;
							i++;
						}
						while(i < nindices)
					}
				}	
			}
		};
		g_arvoreClick = itemID;
		tema = tema[1];
		var p = g_locaplic+"/classesphp/mapa_controle.php?funcao=criaLegendaHTML&template=legenda2.htm&tema="+tema+"&g_sid="+g_sid;
		cpObj.call(p,"criaLegenda",expandeLegendaVer);
	}
}
/*
Function: expandeGrupo

Chama a função ajax que pega a lista de temas de um subgrupo no menu de temas.

Parameters:

itemID - string Id do nó que foi expandido na árvore de grupos e subgrupos.
*/
function expandeGrupo(itemID)
{
	var idmenu = (TreeviewPvtFindRootObject($i(itemID)).idmenu);
	//
	//o codigo do grupo é sempre somado +1, para pegar o correto é necessário subtrair 1
	//
	var item = $i(itemID);
	if (item.grupo)
	{
		if(item.grupo == "0a"){var grupo = "0";}
		else
		{var grupo = parseInt(item.grupo);}
	}
	else
	{var grupo = "";}
	if (item.subgrupo)
	{
		if(item.subgrupo == "0a"){var subgrupo = "0";}
		else
		{var subgrupo = parseInt(item.subgrupo);}
	}
	else
	{var subgrupo = "";}
	if (item.getElementsByTagName("ul").length == 0)
	{
		if (subgrupo != "")
		{
			var processaTemas = function(retorno)
			{
				if ((retorno.data != "erro") && (retorno.data != undefined))
				{
					var cor = "rgb(251,246,184)";
					var stlt = retorno.data.temas.length;
					if(stlt > 0)
					{
						var st = 0;
						do
						{
							var nome = retorno.data.temas[st].nome;
							var lk = retorno.data.temas[st].link;
							if ( lk != " ")
							{var lk = "<a href="+lk+" target='blank'>&nbsp;"+$trad("a9")+"</a>";}
							var tid = retorno.data.temas[st].tid;
							//
							//inclui o link para abrir o qrcode e kml
							//
							var inp = "<input style='text-align:left;cursor:pointer;' onclick='mudaboxnf(\"adiciona\",this)' class='inputsb' style='cursor:pointer' type=\"checkbox\" value="+tid+"  />";
							var lkgrcode = g_locaplic+"/pacotes/qrcode/php/qr_html.php?d="+g_locaplic+"/mobile/index.php?temasa="+tid;
							var lkgrcode1 = g_locaplic+"/pacotes/qrcode/php/qr_img.php?d="+g_locaplic+"/mobile/index.php?temasa="+tid;
							var qrcode = "&nbsp;<a onmouseover='mostradicasf(this,\"<img src="+lkgrcode1+" />\")' href='"+lkgrcode+"' target='blank' >qrcode</a>";	
							var kml = "&nbsp;<span style='cursor:pointer;text-decoration:underline;' onclick='abreKml(\""+tid+"\")' target='blank' >kml</span>";	
							if ((g_kml != "sim") && (retorno.data.temas[st].ogc != "nao"))
							{var kml = "";}
							var mini = "";
							var lkmini = g_locaplic+"/testamapfile.php?map="+tid+".map&tipo=mini";
							var lkmini1 = g_locaplic+"/testamapfile.php?map="+tid+".map&tipo=grande";
							var mini = "&nbsp;<a onmouseover='mostradicasf(this,\"<img src="+lkmini+" />\")' href='"+lkmini1+"' target='blank' >mini</a>";	
							if (g_qrcode == "nao"){qrcode = "";}
							if(navm)
							nomeTema = "<span style='background-color:"+cor+"' title='"+$trad("a10")+" "+tid+"'>"+inp+nome+"<br>"+lk+qrcode+kml+mini+"</span>";
							else
							nomeTema = "<span style='background-color:"+cor+"' title='"+$trad("a10")+" "+tid+"'><img src='"+g_locaplic+"/imagens/branco.gif' width='0' height='15' />"+inp+nome+"<br>"+lk+qrcode+kml+mini+"</span>";
							mytreeview2.createItem("t_"+itemID+"_"+st, nomeTema, imgBranco, false, true, true, itemID);
							if (cor == "rgb(251,246,184)"){var cor = "rgb(255,255,255)";}
							else
							{var cor = "rgb(251,246,184)";}
							st++;
						}
						while(st<stlt)
					}
					//inclui um item em branco
					mytreeview2.createItem("vazio", "", imgBranco, false, true, true, g_arvoreClick);
				}
			};
			var p = g_locaplic+"/classesphp/mapa_controle.php?funcao=pegalistadetemas&grupo="+grupo+"&subgrupo="+subgrupo+"&g_sid="+g_sid+"&idmenu="+idmenu;
			cpObj.call(p,"pegaListaDeTemas",processaTemas);
		}
		else if (grupo != "")
		{
			//
			//processa o resultado da chamada ajax para montar a árvore de sub-grupos
			//
			var processaSubgrupos = function (retorno)
			{	
				var ngSgrupo = retorno.data.subgrupo;
				var cor = "rgb(230,230,230)";
				var sglt = ngSgrupo.length;
				if (sglt>0)
				{
					var sg = 0;
					do
					{
						if (navm)
						var nomeSgrupo = "<span style='text-align:left;background-color:"+cor+"' onmouseover=\"javascript:mostradicasf(this,'"+$trad("a8")+"','ligadesliga')\" onmouseout=\"javascript:mostradicasf(this,'')\" >"+ngSgrupo[sg].nome+"</span>";
						else
						var nomeSgrupo = "<span style='text-align:left;background-color:"+cor+"' onmouseover=\"javascript:mostradicasf(this,'"+$trad("a8")+"','ligadesliga')\" onmouseout=\"javascript:mostradicasf(this,'')\" ><img src='"+g_locaplic+"/imagens/branco.gif' width='0' height='15' />"+ngSgrupo[sg].nome+"</span>";
						mytreeview2.createItem(itemID+"_"+sg, nomeSgrupo, imgBranco, true, true, true, itemID);
						$i(itemID+"_"+sg).subgrupo = sg+"a";
						$i(itemID+"_"+sg).grupo = grupo+"a";
						if (cor == "rgb(230,230,230)"){var cor = "rgb(255,255,255)";}
						else
						{var cor = "rgb(230,230,230)";}
						sg++;
					}
					while(sg<sglt)
					mytreeview2.createItem("","", imgBranco, false, true, true, itemID);
				}
				var ngtSgrupo = retorno.data.temasgrupo;
				var sgtlt = ngtSgrupo.length;
				if(sgtlt > 0)
				{
					var sgt=0;
					do
					{
						var no = ngtSgrupo[sgt];
						var nome = no.nome;
						var lk = no.link;
						if ( lk != " ")
						{var lk = "<a href="+lk+" target='blank'>&nbsp;fonte</a>";}
						var tid = no.tid;
						var inp = "<input style='text-align:left;cursor:pointer;' onclick='mudaboxnf(\"adiciona\",this)' class='inputsb' style='cursor:pointer' type=\"checkbox\" value="+tid+" onmouseover=\"javascript:mostradicasf(this,'"+$trad("a8")+"','ligadesliga')\" onmouseout=\"javascript:mostradicasf(this,'')\" />";
						if(navm)
						nomeTema = "&nbsp;"+inp+nome+lk;
						else
						nomeTema = "<span><img src='"+g_locaplic+"/imagens/branco.gif' width='0' height='15' />"+inp+nome+lk+"</span>";
						mytreeview2.createItem(itemID+"tema_"+sgt, nomeTema, imgBranco, false, true, true, itemID);
						sgt++;
					}
					while(sgt<sgtlt)
					mytreeview2.createItem("","", imgBranco, false, true, true, itemID);
				}		
			};		
			//
			//faz a cahamada ajax para pegar a lista de sub-grupos de um grupo
			//
			var p = g_locaplic+"/classesphp/mapa_controle.php?funcao=pegalistadeSubgrupos&grupo="+grupo+"&g_sid="+g_sid+"&idmenu="+idmenu;
			cpObj.call(p,"pegaListaDeSubgrupos",processaSubgrupos);
		}
	}
}
/*
Function: processaGrupos

Recebe os dados da função Ajax com a lista de grupos e subgrupos.

Monta a árvore para adição de um novo tema no mapa.

Se existir o id="arvoreAdicionaTema", a árvore será incluída nele, se não, será incluída na guia definida em objmapa.guiaMenu

Parameters:

idmenu - identificador do menu que será aberto. É definido em ms_configura.php

listasistemas - sim|nao indica se a lista de sistemas será mostrada ou não

status - aberto|fechado indica se a árvore será mostrada aberta ou fechada no menu.

nomemenu - nome do menu que será incluído na raiz da árvore
*/
function pegaListaDeGrupos(idmenu,listasistemas,status,nomemenu)
{			
	if(status == "aberto"){status = true;}
	else
	{status = false;}
	if(status == undefined){status = true;}
	//
	//pega o retorno da chamada ajax com a lista de grupos de um determinado menu de temas
	//
	var processaGrupos = function(retorno)
	{
		if ((retorno.data != "erro") && (retorno.data != undefined))
		{
			if($i(objmapa.guiaMenu+"obj") && !$i("buscatema"))
			{$i(objmapa.guiaMenu+"obj").innerHTML = "";}
			if(!$i("arvoreAdicionaTema"))
			{var ondeArvore = objmapa.guiaMenu+"obj";}
			else
			{var ondeArvore = "arvoreAdicionaTema";}
			var idarvore = retorno.data.grupos[retorno.data.grupos.length - 2].idmenu;
			//
			//monta o campo para busca de temas por palavra chave.
			//
			if ($i("buscatema"))
			{var busca = $i("buscatema").value;}
			if (!document.getElementById("buscatema"))
			{
				if(!$i("arvoreAdicionaTema"))
				{
					var insp = "<table  cellspacing='0' cellpadding='0' ><tr><td style='text-align:left;font-size:10px;'>";
					insp += "<img src='"+g_locaplic+"/imagens/branco.gif'  height=0 />";
					insp += "<br><p>&nbsp;"+$trad("a1")+"<input class='digitar' type='text' id='buscatema' size='15' value=''  /><img  class='tic' title='"+$trad("a1")+"' src='"+$im("branco.gif")+"' onclick='procurartemas()' style='cursor:pointer;top:2px;position:relative;' /></p></td></tr></table><br>";
					$i(ondeArvore).innerHTML = insp+"<div onmouseover=\"javascript:mostradicasf(this,'Clique no box ao lado de cada tema para ligar ou desligar esse tema, mostrando-o ou não no mapa. Após alterar o estado do tema, aguarde alguns instantes para o mapa ser redesenhado, ou clique no botão aplicar que será mostrado.','ligadesliga')\" onmouseout=\"javascript:mostradicasf(this,'')\" style='text-align:left;font-size:10px;' id='achados' ></div></div>";
				}
				else
				{$i(ondeArvore).innerHTML = "<div id=buscatema ></div>"}
				var outrasOpcoes = "<table width='120px' ><tr>";
				if (g_uploaddbf == "sim")
				{outrasOpcoes += "<td><div id='updbf' style='width:98%;left:5px;cursor:pointer;text-align:left;font-size:11px;' onclick='uploaddbf()'><img class='uploaddbf' src='"+$im("branco.gif")+"' style='cursor:pointer;text-align:left' title='"+$trad("a2b")+"'/></div><td>";}
				if (g_uploadlocal == "sim")
				{outrasOpcoes += "<td><div id='uplocal' style='width:98%;left:5px;cursor:pointer;text-align:left;font-size:11px;' onclick='upload()'><img class='upload' src='"+$im("branco.gif")+"' style='cursor:pointer;text-align:left' title='"+$trad("a2")+"'/></div><td>";}
				if (g_downloadbase == "sim")
				{outrasOpcoes += "<td><div style='width:98%;left:5px;cursor:pointer;text-align:left;font-size:11px;' onclick='downloadbase()'><img class='download' src='"+$im("branco.gif")+"' style='cursor:pointer;text-align:left'  title='"+$trad("a3")+"'/></div><td>";}
				if (g_conectarwms == "sim")
				{outrasOpcoes += "<td><div style='width:98%;left:5px;cursor:pointer;text-align:left;font-size:11px;' onclick='conectarwms()'><img class='conectarwms' src='"+$im("branco.gif")+"' style='cursor:pointer;text-align:left'  title='"+$trad("a4")+"'/></div><td>";}
				if (g_conectargeorss == "sim")
				{outrasOpcoes += "<td><div style='width:98%;left:5px;cursor:pointer;text-align:left;font-size:11px;' onclick='conectargeorss()'><img class='conectargeorss' src='"+$im("branco.gif")+"' style='cursor:pointer;text-align:left'  title='"+$trad("a5")+"'/></div><td>";}
				if (g_nuvemTags == "sim")	
				{outrasOpcoes += "<td><div style='width:98%;left:5px;cursor:pointer;text-align:left;font-size:11px;' onclick='nuvemTags()'><img class='nuvemtags' src='"+$im("branco.gif")+"' style='cursor:pointer;text-align:left'  title='"+$trad("a5a")+"'/></div><td>";}

				if (objmapa.navegacaoDir == "sim")
				{
					outrasOpcoes += "<td><div style='width:98%;left:5px;cursor:pointer;text-align:left;font-size:11px;' onclick='navegacaoDir()'><img class='conectarservidor' src='"+$im("branco.gif")+"' style='cursor:pointer;text-align:left'  title='"+$trad("a6")+"'/></div><td>";
				}

				if($i("outrasOpcoesAdiciona"))
				{$i("outrasOpcoesAdiciona").innerHTML = outrasOpcoes+"</tr></table>";}
				else
				$i(ondeArvore).innerHTML += outrasOpcoes;
			}
			//
			//monta a árvore de menus com os grupos e temas no nível raiz
			//cria o objeto mytreeview2
			//
			mytreeview2 = treeviewNew("mytreeview2"+idmenu, "default", ondeArvore, null);
			$i("mytreeview2"+idmenu).innerHTML += "<br>";
			//
			//aqui é incluido um atributo na árvore correspondente ao seu codigo
			//isso é necessário para identificar qual árvore foi clicada e assim, descobrir o código do menu
			//isso é necessário pq podem existir mais de uma árvore de menus
			//
			$i("mytreeview2"+idmenu).idmenu = idmenu;
			//
			//cria a raiz da árvore
			//
			var nometemas = $trad("a7");
			if (idmenu != ""){nometemas += " - "+nomemenu;}
			mytreeview2.createItem("i"+idmenu, "<b>"+nometemas+"</b>", "foldermapa", true, true, true, null);
			mytreeview2.itemExpand = expandeGrupo;
			//
			//monta a árvore de grupos
			//
			var ilt = retorno.data.grupos.length;
			var i = 0;
			do
			{
				if (retorno.data.grupos[i].nome)
				{
					mytreeview2.createItem("g"+i+"_"+idmenu, retorno.data.grupos[i].nome, "folder", true, true, status, "i"+idmenu);
					$i("g"+i+"_"+idmenu).grupo = i+"a";
				}
				//
				//acrescenta os temas que ficam no nível da raiz da árvore
				//
				if (retorno.data.grupos[i].temasraiz)
				{
					var stlt = retorno.data.grupos[i].temasraiz.length;
					var st = 0;
					if(stlt > 0)
					{
						do
						{
							var no = retorno.data.grupos[i].temasraiz[st];
							var nome = no.nome;
							var lk = no.link;
							if ( lk != " ")
							{var lk = "<a href="+lk+" target='blank'>&nbsp;fonte</a>";}
							var tid = no.tid;
							var inp = "<input style='text-align:left;cursor:pointer;' onclick='mudaboxnf(\"adiciona\",this)' class='inputsb' style='cursor:pointer' type='checkbox' value="+tid+" onmouseover=\"javascript:mostradicasf(this,'"+$trad("a8")+"','ligadesliga')\" onmouseout=\"javascript:mostradicasf(this,'')\" />";
							if(navm)
							nomeTema = "&nbsp;"+inp+nome+lk;
							else
							nomeTema = "<span><img src='"+g_locaplic+"/imagens/branco.gif' width='0' height='15' />"+inp+nome+lk+"</span>";
							mytreeview2.createItem("tema"+i+""+st+"a"+idmenu, nomeTema, imgBranco, false, true, status, "i"+idmenu);
							st++;
						}
						while(st<stlt)
					}
					mytreeview2.createItem("", "", imgBranco, false, true, status, "i"+idmenu);
				}
				i++;
			}
			while(retorno.data.grupos[i])
			pegavalSistemas(retorno.data.grupos[retorno.data.grupos.length - 1].sistemas);
		}	
	};
	//
	//faz a chamada em ajax para pegar a lista de grupos de um menu
	//
	var p = g_locaplic+"/classesphp/mapa_controle.php?funcao=pegalistadegrupos&g_sid="+g_sid+"&idmenu="+idmenu+"&listasistemas="+listasistemas+"&listasgrupos=nao";
	cpObj.call(p,"pegaListaDeGrupos",processaGrupos);
}
/*
Function: i3geo_comboGruposMenu

Busca a lista de grupos existentes no menu de temas do i3geo e monta um combo com o resultado.

Ao escolher uma opção do combo, a função de retorno receberá como parâmetro o id do grupo.

Parameters:

funcaoOnchange - nome da funcao que será executada quando o usuário escolhe um grupo

idDestino - id do elemento HTML que receberá o combo

idCombo - id do combo que será criado

largura - largura em pixels do combo

altura - altura do combo em linhas
*/
function i3geo_comboGruposMenu(funcaoOnchange,idDestino,idCombo,largura,altura)
{
	var combo = function (retorno)
	{
		obGrupos = retorno.data;
		var ins = "<select id='"+idCombo+"' SIZE="+altura+" style=width:"+largura+"px onchange='"+funcaoOnchange+"(this.value)' ><option value='' >Escolha um grupo:</option>";
		for (ig=0;ig<obGrupos.grupos.length; ig++)
		{
			if(obGrupos.grupos[ig].nome)
			ins += "<option value="+ig+" >"+obGrupos.grupos[ig].nome+"</option>";
		}
		$i(idDestino).innerHTML = ins+"</select>";
	};
	var p = "classesphp/mapa_controle.php?funcao=pegalistadegrupos&map_file=''&listasgrupos=nao";
	var cp = new cpaint();
	//cp.set_debug(2)
	cp.set_response_type("JSON");
	cp.call(p,"pegalistadegrupos",combo);
}
/*
Function: i3geo_comboSubGruposMenu

Monta um combo com a lista de subgrupos de um grupo do menu de temas do i3geo.

Ao escolher um subgrupo, a função de retorno receberá o id do grupo e o id do subgrupo.

Parameters:

funcaoOnchange - nome da funcao que será executada quando o usuário escolhe um grupo

idDestino - id do elemento HTML que receberá o combo

idCombo - id do combo que será criado

idGrupo - identificador do grupo que será pesquisado

largura - largura em pixels do combo

altura - altura do combo em linhas
*/
function i3geo_comboSubGruposMenu(funcaoOnchange,idDestino,idCombo,idGrupo,largura,altura)
{
	if(idGrupo != "")
	{
		var combo = function(retorno)
		{
			var ins = "<select id='"+idCombo+"' size="+altura+" style=width:"+largura+"px onchange='"+funcaoOnchange+"("+idGrupo+",this.value)' ><option value='' >Escolha um sub-grupo:</option>";
			if (retorno.data.subgrupo)
			{
				var sg = retorno.data.subgrupo;
				for (ig=0;ig<sg.length; ig++)
				{	
					ins += "<option value="+ig+" >"+sg[ig].nome+"</option>";
				}
			}
			$i(idDestino).innerHTML = ins+"</select>";
		};
		var p = "classesphp/mapa_controle.php?funcao=pegalistadeSubgrupos&map_file=''&grupo="+idGrupo;
		var cp = new cpaint();
		//cp.set_debug(2)
		cp.set_response_type("JSON");
		cp.call(p,"pegalistadeSubgrupos",combo);
	}
}
/*
Function: i3geo_comboTemasMenu

Monta um combo com a lista de subgrupos de um grupo do menu de temas do i3geo.

Ao escolher um subgrupo, a função de retorno receberá o id do grupo e o id do subgrupo.

Parameters:

funcaoOnchange - nome da funcao que será executada quando o usuário escolhe um grupo

idDestino - id do elemento HTML que receberá o combo

idCombo - id do combo que será criado

idGrupo - identificador do grupo que será pesquisado

idSubGrupo - id do subgrupo

largura - largura em pixels do combo

altura - altura do combo em linhas
*/
function i3geo_comboTemasMenu(funcaoOnchange,idDestino,idCombo,idGrupo,idSubGrupo,largura,altura)
{
	var combo = function(retorno)
	{
		var ins = "<select id='"+idCombo+"' size="+altura+" style=width:"+largura+"px onchange='"+funcaoOnchange+"("+idGrupo+","+idSubGrupo+",this.value)' ><option value='' >Escolha um tema:</option>";
		if (retorno.data.temas[i])
		{
			var sg = retorno.data.temas;
			for (ig=0;ig<sg.length; ig++)
			{	
				ins += "<option value="+sg[ig].tid+" >"+sg[ig].nome+"</option>";
			}
		}
		$i(idDestino).innerHTML = ins+"</select>";
	};
	var p = "classesphp/mapa_controle.php?funcao=pegalistadetemas&map_file=''&grupo="+idGrupo+"&subgrupo="+idSubGrupo;
	var cp = new cpaint();
	//cp.set_debug(2)
	cp.set_response_type("JSON");
	cp.call(p,"pegalistadetemas",combo);

}
/*
Function: pegavalSistemas

Adiciona uma árvore no menu de adição de temas, contendo os sistemas que podem ser executados.

Parameters:

sis - objeto com a lista de sistemas.
*/
function pegavalSistemas(sis)
{
	if(sis.length > 0)
	{
		mytreeviewS = new Object();
		mytreeviewS = treeviewNew("mytreeviewS", "default", objmapa.guiaMenu+"obj", null);
		$i("mytreeviewS").innerHTML += "<br>";
		mytreeviewS.createItem("Sitem1", "<b>"+$trad("a11")+"</b>", "foldermapa", true, true, true, null);
		var iglt = sis.length;
		var ig=0;
		do
		{
			var nomeSis = sis[ig].NOME;
			if(sis[ig].PUBLICADO)
			{
				if(sis[ig].PUBLICADO == "NAO" || sis[ig].PUBLICADO == "nao")
				{var nomeSis = "<s>"+sis[ig].NOME+"</s>";}
			}
			mytreeviewS.createItem("sis"+ig, nomeSis, "folder", true, true, true, "Sitem1");
			var funcoes = sis[ig].FUNCOES;
			var tempf = funcoes.length;
			for (var ig2=0;ig2<tempf;ig2++)
			{
				var executar = funcoes[ig2].ABRIR;
				var w = funcoes[ig2].W;
				var h = funcoes[ig2].H;
				var nomeFunc = "<span onclick='abreSistema(\""+executar+"\",\""+w+"\",\""+h+"\")'>"+funcoes[ig2].NOME+"</span>";
				var inp = "<img class='folder' title='"+$trad("a12")+"' src='"+$im("branco.gif")+"' style='cursor:pointer;text-align:left' onclick='abreSistema(\""+executar+"\",\""+w+"\",\""+h+"\")' />&nbsp;";
				mytreeviewS.createItem("sis"+ig+"func"+ig2, inp+nomeFunc, imgBranco, false, true, false, "sis"+ig);
			}
			ig++;
		}
		while(ig<iglt)
	}
}
/*
Function: pegaMapas

Recebe a lista de mapas (banners) e monta a apresentação na guia "mapas".

Adiciona na guia mapas os banners que dão acesso direto a mapas especiais.

A indicação do arquivo xml é feita em ms_configura.php ou no sistema de administração

Parameters:

retorno - objeto JSON com a lista de mapas
*/
function pegaMapas(retorno)
{
	var ins = "<br>";
	var mapa = retorno.data.mapas;
	var ig1lt = mapa.length;
	var ig1=0;
	if(ig1lt > 0)
	{
		do
		{
			var nome = mapa[ig1].NOME;
			if(mapa[ig1].PUBLICADO)
			{
				if(mapa[ig1].PUBLICADO == "NAO" || mapa[ig1].PUBLICADO == "nao")
				{var nome = "<s>"+nome+"</s>";}
			}
			var descricao = mapa[ig1].DESCRICAO;
			var imagem = mapa[ig1].IMAGEM;
			var temas = mapa[ig1].TEMAS;
			var ligados = mapa[ig1].LIGADOS;
			var extensao = mapa[ig1].EXTENSAO;
			var outros = mapa[ig1].OUTROS;
			var lkd = mapa[ig1].LINK;
			var link = g_locaplic+"/ms_criamapa.php?temasa="+temas+"&layers="+ligados;
			if (extensao != "")
			{link += "&mapext="+extensao;}
			if (outros != "")
			{link += "&"+outros;}
			if (lkd != "")
			{var link = lkd;}
			ins += "<div><a href='"+link+"'><img src='"+imagem+"'></a></div><br>";
			ins += "<div><p>"+nome+"</p></div><br>";
			ig1++;
		}
		while(ig1<ig1lt)
	}
	$i("banners").innerHTML = ins;
}
/*
Function: arvoreclick

Marca o checkbox de adição de temas

Parameters:

itemID - ID que identifica qual tema foi clicado. O ID é definido no arquivo .map e no arquivo menutemas/menutemas.xml
*/
function arvoreclick(itemID)
{
	if (itemID.search("tema") == 0)
	{
		if ($i(itemID).checked == true)
		{$i(itemID).checked = false;}
		else
		{$i(itemID).checked = true;}
	}
}
/*
Function: pegaTema

Pega o tema de um no na guia de temas.

Utilizado nas opções que operam sobre um tema específico.

Parameters:

celula - objeto que foi clicado

Returns:

Id do tema.
*/
function pegaTema(celula)
{
	var nos = celula.parentNode.childNodes;
	var tempi = nos.length;
	for (var no=0;no<tempi; no++){if (nos[no].type == "checkbox"){return nos[no].value;}}
}
/*
Section: redesenho do mapa
*/
/*
Function: autoRedesenho

Controla a opção de redesenho automático temporizado

Para funcionar, a variável de inicialização g_autoRedesenho deve ser > 0

Parameters:

opcao: ativa|desativa|redesenha
*/
function autoRedesenho(opcao)
{
	if (opcao == "desativa")
	{
		g_autoRedesenho = 0;
		clearTimeout(objmapa.tempoRedesenho);
		clearTimeout(objmapa.contaTempoRedesenho);
		objmapa.tempoRedesenho = "";
		objmapa.contaTempoRedesenho = "";
		objmapa.tempoRedesenho = "";
		if ($i("tempoRedesenho"))
		{$i("tempoRedesenho").style.display = "none";}
	}
	if (opcao == "ativa")
	{
		if (($i("tempoRedesenho")) && (g_autoRedesenho > 0))
		{$i("tempoRedesenho").style.display = "block";}
		if (g_autoRedesenho > 0)
		{objmapa.tempoRedesenho = setTimeout('autoRedesenho("redesenha")',g_autoRedesenho);}
		if (($i("tempoRedesenho")) && (g_autoRedesenho > 0))
		{
			$i("tempoRedesenho").innerHTML = g_autoRedesenho/1000;
			objmapa.contaTempoRedesenho = setTimeout('autoRedesenho("contagem")',1000);
		}
	}
	if (opcao == "redesenha")
	{
		clearTimeout(objmapa.tempoRedesenho);
		clearTimeout(objmapa.contaTempoRedesenho);
		remapaf();
		autoRedesenho("ativa");
	}
	if (opcao == "contagem")
	{
		if ($i("tempoRedesenho"))
		{
			$i("tempoRedesenho").innerHTML = parseInt($i("tempoRedesenho").innerHTML) - 1;
			objmapa.contaTempoRedesenho = setTimeout('autoRedesenho("contagem")',1000);
		}
	}
}
/*
Function: remapaf

Prepara o redesenho do mapa de acordo com o que esta visivel ou nao.

Chamado por algumas funções que necessitam refazer o desenho do mapa.

Verifica na lista de temas já adicionados, os temas que estão ligados e desligados,
Chama a função que verifica na lista de temas adicionais.
*/
function remapaf()
{
	//
	//zera o contador de tempo
	//
	clearTimeout(objmapa.tempo);
	objmapa.tempo = "";
	objmapa.temaAtivo = "";
	if ($i(objmapa.guiaTemas+"obj"))
	{
		//
		//se g_operacao = 'legenda' significa que o usuário clicou em um tema na guia legenda
		//nesse caso, a busca dos temas que devem ser ligados e desligados deve ser feita no id='legenda'
		//
		if(g_operacao == "legenda")
		{var iguias = $i("legenda").getElementsByTagName("input");}
		else
		{var iguias = $i(objmapa.guiaTemas+"obj").getElementsByTagName("input");}
		var tsl = new Array();
		var tsd = new Array();
		var i = iguias.length-1;
		if (i >= 0)
		{
			do
			{
				if (iguias[i].type == "checkbox")
				{
					if(iguias[i].name == "layer")
					{
						if (iguias[i].checked == false)
						{tsd.push(iguias[i].value);}
						if (iguias[i].checked == true)
						{tsl.push(iguias[i].value);}
					}
				}
			}
			while(i--)
		}
		var remapaAdicNovos = function remapaAdicNovos(retorno)
		{
			if ($i("buscatema"))
			{
				var g = $i(objmapa.guiaMenu+"obj");
				if($i("arvoreAdicionaTema"))
				{var g = $i("arvoreAdicionaTema");}
				var iguias = g.getElementsByTagName("input");
				var ta = new Array();
				var i = iguias.length-1;
				if (i >= 0)
				{
					do
					{
						if (iguias[i].type == "checkbox")
						{
							if (iguias[i].checked == true)
							{
								ta.push(iguias[i].value);
								iguias[i].checked = false;
							}
						}
					}
					while(i--)
				}
				if (ta.length > 0)
				{
					objaguarde.fecha("remapa");
					objaguarde.abre("ajaxredesenha",$trad("o1"));
					var temp = function(retorno)
					{
						objaguarde.fecha("ajaxredesenha");
						if(retorno.data.erro)
						{
							alert(retorno.data.erro);
							return;
						}
						ajaxredesenha("");					
					};
					var p = g_locaplic+"/classesphp/mapa_controle.php?funcao=adtema&temas="+(ta.toString())+"&g_sid="+g_sid;
					cpObj.call(p,"adicionaTema",temp);
				}
				else
				{
					objaguarde.fecha("remapa");
					objaguarde.abre("ajaxredesenha",$trad("o1"));
					ajaxredesenha("");
				}
			}
			else
			{
				objaguarde.fecha("remapa");
				objaguarde.abre("ajaxredesenha",$trad("o1"));
				ajaxredesenha("");
			}
		};
		if ((tsd.length > 0) || (tsl.length > 0))
		{
			objaguarde.abre("remapa",$trad("o1"));
			var p = g_locaplic+"/classesphp/mapa_controle.php?funcao=ligatemas&desligar="+(tsd.toString())+"&ligar="+(tsl.toString())+"&g_sid="+g_sid;
			cpObj.call(p,"ligaDesligaTemas",remapaAdicNovos);
		}
		else{remapaAdicNovos();}
		objaguarde.fecha("remapa");
	}
	else
	{remapaAdicNovos();}
	//
	//utilizado na interface flamingo para redesenhar o mapa
	//
	if($i("flamingo"))
	{
		//atualizaFL();
	}
}
/*
Section: eventos
*/
/*
Function: processevent1 (depreciado)

Captura a posição do mouse tendo como referência o navegador.

Atualiza o objeto objposicaomouse e movimenta as janelas docáveis.

Recalcula a posição correta da imagem do mapa.

Parameters:

exy1 - objeto evento.
*/
function processevent1(exy1)
{}
/*
Function: calcposf

Calcula a posição do corpo do mapa e posiciona-o corretamente na tela.
*/
function calcposf()
{
	try
	{
		imagemxi = 0;
		imagemyi = 0;
		imagemxref = 0;
		imagemyref = 0;
		if(!$i("i3geo")){return;}
		if ($i("i3geo").style.left){imagemxi += parseInt($i("i3geo").style.left);}
		if ($i("i3geo").style.top){imagemyi += parseInt($i("i3geo").style.top);}	
		var dc = $i("i3geo");
		if ($i("contemImg"))
		{var dc = $i("contemImg");}
		else
		{var dc = $i("img");}
		if ($i("openlayers"))
		{var dc = $i("openlayers");}
		if ($i("flamingo"))
		{var dc = $i("flamingo");}
		while ((dc.offsetParent) && (dc.offsetParent.id != "i3geo"))
		{
			dc = dc.offsetParent;
			imagemxi = imagemxi + dc.offsetLeft;
			imagemyi = imagemyi + dc.offsetTop;
		}
		if ($i("corpoMapa"))
		{
			$i("corpoMapa").style.position="absolute";
			$left("corpoMapa",imagemxi);
			$top("corpoMapa",imagemyi);
			if ($i("i3geo").style.left){$left("corpoMapa",imagemxi - parseInt($i("i3geo").style.left));}
			if ($i("i3geo").style.top){$top("corpoMapa",imagemyi - parseInt($i("i3geo").style.top));}
		}
		if ($i("ref"))
		{
			var dc = $i("ref");
			while (dc.offsetParent.id != "i3geo")
			{
				dc = dc.offsetParent;
				imagemxref = imagemxref + dc.offsetLeft;
				imagemyref = imagemyref + dc.offsetTop;
			}
		}
		if ($i("aguarde"))
		{
			$top("aguarde",imagemyi);
			$left("aguarde",imagemxi);
		}
	}
	catch(e){alert("Ocorreu um erro. calcposf"+e);}
}
/*
Function: movecursor

Move o ícone que segue o mouse quando da movimentação sobre o mapa
*/
function movecursor()
{
	//
	//se a interface openlayers ou flamingo estiver sendo usada, o ícone não é mostrado
	//'obj' é o elemento que guarda o ícone
	//
	if ($i("obj"))
	{
		if ($i("openlayers") || $i("flamingo"))
		{$i("obj").style.display = "none";}
		else
		{
			var obje = $i("obj").style;
			if ($i("img"))
			{
				eval ("obje." + g_tipotop + "= objposicaocursor.telay + 5 + g_postpx");
				eval ("obje." + g_tipoleft + "= objposicaocursor.telax + 5 + g_postpx");
			}
			else
			{
				eval ("obje." + g_tipotop + "= objposicaocursor.telay - 15 + g_postpx");
				eval ("obje." + g_tipoleft + "= objposicaocursor.telax + 15 + g_postpx");
			}
		}
	}
	if($i("box1"))
	{
		var bx = $i("box1");
		if (bx.style.visibility != "visible")
		{
			//move o box para a posição correta
			bx.style.left = objposicaocursor.telax + g_postpx;
			bx.style.top = objposicaocursor.telay + g_postpx;
		}
	}
}
/*
Function: capturaposicao

Captura a posição do mouse em função do evento onmousemove sobre o corpo do mapa ou sobre o mapa de referência.

Atualiza o objeto objposicaocursor.
A função de mostrar etiquetas é definida como "" quando o mouse é movimentado.

Parameters:

exy - objeto evento.
*/
function capturaposicao(e)
{
	if (!e) var e = window.event;
	//
	//verifica sob qual objeto o mouse está se movendo
	//
	if (e.target)
	{var targ = e.target;}
	else if (e.srcElement) var targ = e.srcElement;
	if(targ.id == "" && $i("img"))
	{targ = $i("img");}
	//
	//se estiver no modo pan, o movimento deve ser obtido do elemento
	//onde está a imagem do mapa e não diretamente sobre o elemento 'img'
	//se não for feito assim, o deslocamento do mapa não é capturado
	//
	if (g_panM == "sim")
	{var pos = pegaPosicaoObjeto(targ.parentNode);}
	else
	{var pos = pegaPosicaoObjeto(targ);}
	if((g_entorno == "sim") && (g_panM == "sim"))
	{
		pos[0] = pos[0] - objmapa.w;
		pos[1] = pos[1] - objmapa.h;
	}
	//
	//pega a posicao correta do mouse
	//
	var mousex = 0;
	var mousey = 0;
	if (e.pageX || e.pageY) 	{
		mousex = e.pageX;
		mousey = e.pageY;
	}
	else if (e.clientX || e.clientY) 	{
		mousex = e.clientX + document.body.scrollLeft
			+ document.documentElement.scrollLeft;
		mousey = e.clientY + document.body.scrollTop
			+ document.documentElement.scrollTop;
	}

	//
	//faz os cálculos de posicionamento
	//fig e reffig são a mesma coisa por enquanto
	//
	var xfig = mousex - pos[0];
	var yfig = mousey - pos[1];
	var xreffig = xfig;
	var yreffig = yfig;
	var xtela = mousex;
	var ytela = mousey;
	//
	//celula e extent são necessários para se fazer a
	//conversão de coordenadas de tela para coordenadas geográficas
	//esses valores são obtidos das funções ajax que redesenham ou inicializam o mapa
	// 
	var c = g_celula;
	var ex = objmapa.extent;
	if(targ.id == "imagemReferencia")
	{
		var c = g_celularef;
		var ex = objmapa.extentref;
	}
	var teladd = calcddf(xfig,yfig,c,ex);
	var teladms = convdmsf(teladd[0],teladd[1]);
	objposicaocursor.ddx = teladd[0];
	objposicaocursor.ddy = teladd[1];
	objposicaocursor.dmsx = teladms[0];
	objposicaocursor.dmsy = teladms[1];
	objposicaocursor.telax = xtela;
	objposicaocursor.telay = ytela;
	objposicaocursor.imgx = xfig;
	objposicaocursor.imgy = yfig;
	objposicaocursor.refx = xreffig;
	objposicaocursor.refy = yreffig;
	//
	//aqui é feita a verificação da função de etiquetas
	//toda vez que o mouse é movimentado o tip é zerado
	//e é identificado que o mouse não está parado, obviamente
	//
	if (objmapa.parado!="cancela")
	{objmapa.parado = "nao";}
	ajaxTip = "";
}
/*
Section: quadro de animação
*/
/*
Function: gerafilmef

Cria os quadros que serão utilizados na função de animação e mostrados no mapa.

Cada novo quadro é criado como um objeto quadrofilme. Os quadros criados são armazenados no
array global quadrosfilme.

Parameters:

qs - número de quadros
*/
function gerafilmef(qs)
{
	try
	{
		if ($i("lugarquadros"))
		{
			var q = "<table class=tablefilme ><tr><td><div class='menuarrow'  title='op&ccedil;&otilde;es' onclick='opcoesQuadros()' style='cursor:pointer'></div></td>";
			for (var i = 0; i < qs; i++)
			{
				q = q + "<td><img class='quadro' src=\""+g_localimg+"/branco.gif\" id=f"+i+"  onmouseover='filmef(this);mostradicasf(this,\"Quadro - clique para restaurar\",\"quadro\")' onmouseout=\"javascript:mostradicasf(this,'')\" onclick='filmezf(this)' /></td>";
				var qu = new quadrofilme();
				quadrosfilme[i] = qu;
			}
			var finalq = "</tr></table>";
			document.getElementById("lugarquadros").innerHTML = q+finalq;
		}
	}
	catch(e){var e = "";}
}
/*
Function: gravaQuadro

Armazena um determinado valor em uma determinada característica de um objeto quadro.

Parameters:

variavel - parâmetro do objeto quadro.

valor - valor que será aplicado.
*/
function gravaQuadro(variavel,valor)
{
	try
	{
		var muda = -1;
		if ($i("lugarquadros"))
		{
			var nquadros = quadrosfilme.length;
			//
			//verifica se todos os quadros estão cheios
			//
			if (quadrosfilme[nquadros - 1].imagem != " ")
			{
				//
				//se estiverem cheios, esvazia o primeiro e acrescenta o novo
				//
				//rebobinaf();
				quadrosfilme.shift();
				var qu = new quadrofilme();
				quadrosfilme.push(qu);
			}
			for (var i = 0; i < nquadros; i++)
			{
				if ((eval("quadrosfilme["+i+"]."+variavel+" == ' '")) && (muda < 0))
				{var muda = i;}
			}
			if (eval("quadrosfilme["+(muda)+"]"))
			{eval("quadrosfilme["+(muda)+"]."+variavel+"='"+ valor+"'");}
		}
	}
	catch(e){var e = "";}
}
/*
Function: avancaQuadro

Avança um quadro na lista de quadros, mudando a imagem utilizada na sua representação.
*/
function avancaQuadro()
{
	try
	{
		var muda = -1;
		if ($i("lugarquadros"))
		{
			var nquadros = quadrosfilme.length;
			for (var i = 0; i < nquadros; i++)
			{
				if ((quadrosfilme[i].imagem == " ") && (muda < 0))
				{var muda = i;}
			}
			$i("f"+muda).className = "quadro1";
		}
	}
	catch(e){var e = "";}
}
/*
Function: filmef

Mostra a imagem armazenada em um quadro no lugar do corpo do mapa.

Parameters:

o - quadro
*/
function filmef(o)
{
	try
	{
		if ($i("lugarquadros"))
		{
			var v = (o.id).replace("f","");
			if (quadrosfilme[v].imagem != " ")
			{$i("img").src = quadrosfilme[v].imagem;}
		}
	}
	catch(e){var e = "";}
}
/*
Function: rebobinaf

Rebobina as imagens dos quadros, limpando os parâmetros armazenados.
*/
function rebobinaf()
{
	try
	{
		janima = 0;
		var nquadros = quadrosfilme.length;
		for (var i = 0; i < nquadros; i++)
		{
			$i("f"+i).className = "quadro";
			with (quadrosfilme[i]){imagem = " ";escala = " ";legenda = " ";extensao = " ";referencia = " ";}
		}
	}
	catch(e){var e = "";}
}
/*
Function: filmezf

Muda a extensão geográfica do mapa conforme o valor armazenado em um quado de animação.

Parameters:

o - objeto quadro ou número do quadro
*/
function filmezf(o)
{
	if(o.id)
	{var quadro = (o.id).replace("f","");}
	else
	{var quadro = o;}
	if (quadrosfilme[quadro].extensao != " ")
	{
		var p = g_locaplic+"/classesphp/mapa_controle.php?funcao=mudaext&tipoimagem="+g_tipoimagem+"&ext="+quadrosfilme[quadro].extensao+"&g_sid="+g_sid;
		objaguarde.abre("ajaxredesenha",$trad("o1"));
		cpObj.call(p,"mudaExtensao",ajaxredesenha);
	}
	else{alert("Extensao nao definida");}
}
/*
Function: filmeanimaf

Carrega as imagens armazenadas nos quadros de animação.
*/
function filmeanimaf()
{
	preLoad = new Array();
	var tempi = quadrosfilme.length;
	for (var i = 0; i < tempi; i++)
	{
		$i("f"+i).className = "quadro";
		if (quadrosfilme[i].imagem != " ")
		{
			preLoad[i] = new Image();
			preLoad[i].src = quadrosfilme[i].imagem;
		}
	}
	filmeanimarodaf(0);
}
/*
Function: filmeanimarodaf

Roda a animacao usando as imagens armazenadas nos quadros de animação quadros.
*/
function filmeanimarodaf(janima)
{
	if (janima < quadrosfilme.length)
	{
		$i("img").src = preLoad[janima].src;
		$i("f"+janima).className = "quadro1";
		janima = janima + 1;
		var doc = (navm) ? document.frames("wdocai").document : $i("wdocai").contentDocument;
		var ti = doc.getElementById("tempoanima").value;
		t = setTimeout('filmeanimarodaf('+janima+')',ti);
	}
}
/*
Function: quadrofilme

Cria um objeto quadro de animação. Cada quadro é utilizado para armazenar parâmetros de um mapa que foi visto na tela.
É utilizado pela função que lista as imagens já vistas no mapa e pela função que retorna a um determinado zoom do mapa.

Methods:

imagem - URL da imagem

escala - escala do mapa

legenda - URL da legenda do mapa

extensao - extensão geográfica do mapa com valores separados por espaço

referencia - URL do mapa de referência
*/
function quadrofilme()
{
	this.imagem = " ";
	this.escala = " ";
	this.legenda = " ";
	this.extensao = " ";
	this.referencia = " ";
}
/*
Section: calculos
*/
/*
Function calculaArea

Calcula a área de um polígono.

Os pontos são obtidos do objeto pontosdistobj

Para o cálculo da área, é feito o cálculo do número de pixel abrangido pelo polígono e multiplicado pela resolução de cada pixel.

O cálculo da resolução é feito quando a ferramenta de cálculo é ativada e armazenado na variável g_areapixel

Referência - http://www.mail-archive.com/mapserver-users@lists.umn.edu/msg07052.html
*/
function calculaArea()
{
	try
	{
		if(pontosdistobj.xpt.length > 2)
		{
			var $array_length = pontosdistobj.xpt.length;
			pontosdistobj.xtela.push(pontosdistobj.xtela[0]);
			pontosdistobj.ytela.push(pontosdistobj.ytela[0]);
			pontosdistobj.xtela.push(pontosdistobj.xtela[0]);
			pontosdistobj.ytela.push(pontosdistobj.ytela[1]);
			var $polygon_area = 0;
			for (var $i=0;$i <= $array_length;$i++)
			{
				$polygon_area += ((pontosdistobj.xtela[$i] * pontosdistobj.ytela[$i+1])-(pontosdistobj.ytela[$i] * pontosdistobj.xtela[$i+1]));
			}
			$polygon_area = Math.abs($polygon_area) / 2;
		}
		else
		{$polygon_area = "Sao necessarios pelo menos tres pontos para o calculo";}
		//g_areapixel precisa estar definida
		return $polygon_area*g_areapixel;
	}
	catch(e){return (0);}
}
/*
Function: calculadistancia

Calcula a distância entre dois pontos.

Parameters:

lga - x inicial.

lta - y inicial

lgb - x final

ltb - y final
*/
function calculadistancia(lga,lta,lgb,ltb) //0ms
{
	//calculo baseado no site http://www.wcrl.ars.usda.gov/cec/java/lat-long.htm
	try
	{
		var er = 6366.707;
		var radlat1 = Math.PI * lta/180;
		var radlat2 = Math.PI * ltb/180;
		var radlong1 = Math.PI * lga/180;
		var radlong2 = Math.PI * lgb/180;
		if (lta > 0) {radlat1=Math.PI/2-radlat1;}
		if (lta < 0) {radlat1=Math.PI/2+radlat1;}
		if (lga < 0) {radlong1=Math.PI*2-radlong1;}
		if (ltb > 0) {radlat2=Math.PI/2-radlat2;}
		if (ltb < 0) {radlat2=Math.PI/2+radlat2;}
		if (lgb < 0) {radlong2=Math.PI*2-radlong2;}
		var x1 = er * Math.cos(radlong1)*Math.sin(radlat1);
		var y1 = er * Math.sin(radlong1)*Math.sin(radlat1);
		var z1 = er * Math.cos(radlat1);
		var x2 = er * Math.cos(radlong2)*Math.sin(radlat2);
		var y2 = er * Math.sin(radlong2)*Math.sin(radlat2);
		var z2 = er * Math.cos(radlat2);
		var d = Math.sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)+(z1-z2)*(z1-z2));
		//side, side, side, law of cosines and arccos
		var theta = Math.acos((er*er+er*er-d*d)/(2*er*er));
		return theta*er;
	}
	catch(e){return (0);}
}
/*
Function: convdmsddf

Converte dms em dd.

Parameters:

cd - grau.

cm - minuto.

cs - segundo

Returns:

Coordenada em dd.
*/
function convdmsddf(cd,cm,cs)
{
	try
	{
		//converte dms em dd
		var sinal = 'positivo';
		if (cd < 0)
		{
			cd = cd * -1;
			sinal = 'negativo';
		}
		spm = cs / 3600;
		mpg = cm / 60;
		var dd = (cd * 1) + (mpg * 1) + (spm * 1);
		if (sinal == 'negativo')
		{dd = dd * -1;}
		return (dd);
	}
	catch(e){return (0);}
}
/*
Function: calcddf

Converte o x,y de unidades de tela para décimo de grau.

Parameters:

xfign - x em valores de imagem.

yfign - y em coordenadas de imagem.

g_celula - tamanho no terreno do pixel da imagem.

imgext - extensão geográfica do mapa.

Returns:

Coordena em dd.
*/
function calcddf(xfign,yfign,g_celula,imgext)
{
	try
	{
		if (navm)
		{
		 xfign = xfign - 2.2;
		 yfign = yfign - 2.7;
		}
		if (navn)
		{
		 xfign = xfign - 0.12;
		 yfign = yfign - 1.05;
		}
		var nx = g_celula * xfign;
		var ny = g_celula * yfign;
		var amext = imgext.split(" ");
		var longdd = (amext[0] * 1) + nx;
		var latdd = (amext[3] * 1) - ny;
		var res = new Array();
		res[0] = longdd;
		res[1] = latdd;
		return (res);
	}
	catch(e){return(0);}
}
/*
Function: convdmsf

Converte dd em dms.

Parameters:

x - coordenada x.

y - coordenada y.

Returns:

Array com o valor de x [0] e y [1] no formato dd mm ss
*/
function convdmsf(x,y)
{
	var m = 0;
	var s = 0;
	var dx = parseInt(x);
	if (dx > 0)
	{var restod = x - dx;}
	if (dx < 0)
	{restod = (x * -1) - (dx * -1);}
	dx = dx;
	if (restod != 0)
	{
		var mm = restod * 60;
		var m = parseInt(restod * 60);
		var restos = mm - m;
		var mx = m;
		if (restos != 0)
		{
			var s = restos * 60;
			var s = (s+"_").substring(0,5);
			var sx = s;
		}
		else  { s = "00.00" }
	}
	else
	{
		var mx = "00";
		var sx = "00.00";
	}
	if (m.length == 2){m = "0"+m+"";}
	if (s*1 < 10){s = "0"+s;}
	var xv = dx+" "+mx+" "+sx;
	var m = 0;
	var s = 0;
	var dy = parseInt(y);
	if (dy > 0)
	{var restod = y - dy;}
	if (dy < 0)
	{var restod = (y * -1) - (dy * -1);}
	dy = dy;
	if (restod != 0)
	{
		var mm = restod * 60;
		var m = parseInt(restod * 60);
		var restos = mm - m;
		var my = m;
		if (restos != 0)
		{
			var s = restos * 60;
			s = (s+"_").substring(0,5);
			var sy = s;
		}
		else  { var s = "00.00";}
	}
	else
	{
		var my = "00";
		var sy = "00.00";
	}
	if (m.length == 2){m = "0"+m;}
	if (s*1 < 10){s = "0"+s;}
	var yv = dy+" "+my+" "+sy;
	var res = new Array();
	res[0] = xv;
	res[1] = yv;
	if ($i("localizarxy"))
	{
		if($i("xg"))
		{
			$i("xg").value = dx;
			$i("xm").value = mx;
			$i("xs").value = sx;
			$i("yg").value = dy;
			$i("ym").value = my;
			$i("ys").value = sy;
		}
	}
	return res;
}
/*
Function: convddtela

Converte coordenadas dd em coordenadas de tela.

Parameters:

vx - coordenada x.

vy - coordenada y.

docmapa - objeto que contém o objeto imagem.

Returns:

Array com o valor de x [0] e y [1]
*/
function convddtela(vx,vy,docmapa)
{
	try
	{
		if(!docmapa)
		{var docmapa = window.document;}
		if(docmapa.getElementById("contemImg"))
		var dc = docmapa.getElementById("contemImg");
		else
		var dc = docmapa.getElementById("img");
		
		var pos = pegaPosicaoObjeto(dc);
		var imgext = objmapa.extent;
		var imgext = imgext.split(" ");
		vx = (vx * 1) - (imgext[0] * 1);
		vy = (vy * -1) + (imgext[3] * 1);
		c = objmapa.cellsize * 1;
		xy = new Array();
		return [(vx  / c) + pos[0],(vy / c) + pos[1]];
	}
	catch(e){return(new Array());}
}
/*
Function: posicaomouse

Cria um objeto que guarda a posição do mouse na tela. A posição é medida em relação a janela do navegador.

Methods:

x - coordenada x em valores de tela

y - coordenada y em valores de tela
*/
function posicaomouse()
{
	this.x = 0;
	this.y = 0;
}
/*
Function: posicaocursor

Cria um objeto que guarda a posição do mouse no corpo do mapa. A posição é medida em relação à posição do mapa no navegador.

Methods:

ddx - coordenada x em décimo de grau

ddy - coordenada y em décimo de grau

dmsx - coordenada x em grau, minuto e segundo

dmsy - coordenada y em grau, minuto e segundo

telax - coordenada x em valores de tela

telay - coordenada y em valores de tela

imgx - coordenada x em relação ao mapa

imgy - coordenada y em relação ao mapa

refx - coordenada x em relação ao mapa de referência

refy - coordenada y em relação ao mapa de referência
*/
function posicaocursor()
{
	this.ddx = 0;
	this.ddy = 0;
	this.dmsx = '';
	this.dmsy = '';
	this.telax = 0;
	this.telay = 0;
	this.imgx = 0;
	this.imgy = 0;
	this.refx = 0;
	this.refy = 0;
}
/*
Function: pontosdist

Cria o objeto que irá armazenaa as coordenadas para calculo de distancia

Parameters:

xpt - coordenadas x em dd

ypt - coordenadas y em dd

dist - distância entre os dois últimos pontos

xtela - coordenada x na tela

ytela - coordenada y na tela

ximg - coordenada x na imagem do mapa

yimg - coordenada y na imagem do mapa

linhas - lista de objetos criados pela biblioteca richdraw utilizados no desenho da linha de medição
*/
function pontosdist()
{
	this.xpt = new Array();
	this.ypt = new Array();
	this.dist = new Array();
	this.xtela = new Array();
	this.ytela = new Array();
	this.ximg = new Array();
	this.yimg = new Array();
	this.linhas = new Array();
}
/*
Section: desenho sobre o mapa
*/
/*
Function: desenhoRichdraw

Desenha elementos na tela usando a biblioteca richdraw

Parameters:

tipo - tipo de operação

objeto - objeto gráfico do container richdraw

n - índice do elemento no array pontosdistobj
*/
function desenhoRichdraw(tipo,objeto,n)
{
	if (richdraw && $i("img"))
	{
		var pos = pegaPosicaoObjeto($i("img"));
		//
		//faz o reposicionamento de linhas quando o mouse é movido e a linha está ativa
		//
		if((tipo=="resizeLinha") || (tipo=="resizePoligono") && navn)
		{
			try
			{richdraw.renderer.resize(objeto,0,0,objposicaocursor.imgx,objposicaocursor.imgy);}
			catch(e){window.status=n+" erro ao movimentar a linha ";}
		}
		if((tipo=="resizeLinha") && navm)
		{
			try
			{
				//
				//no caso do ie, a linha tem de ser removida e desenhada novamente
				//
				var r = $i(richdraw.container.id);
				r.removeChild(r.lastChild);
				var dy = objposicaocursor.imgy;
				var dx = objposicaocursor.imgx - (objmapa.w/2);
				richdraw.renderer.create(richdraw.mode, richdraw.fillColor, richdraw.lineColor, richdraw.lineWidth, (pontosdistobj.ximg[n-1])-(objmapa.w/2)-1,pontosdistobj.yimg[n-1]-3,dx,dy-3);
			}
			catch(e){window.status=n+" erro ao movimentar a linha ";}			
		}
		if((tipo=="resizePoligono") && navm)
		{
			try
			{
				var r = $i(richdraw.container.id);
				r.removeChild(r.lastChild);
				r.removeChild(r.lastChild);
				var dy = objposicaocursor.imgy;
				var dx = objposicaocursor.imgx - (objmapa.w/2);
				richdraw.renderer.create(richdraw.mode, richdraw.fillColor, richdraw.lineColor, richdraw.lineWidth, (pontosdistobj.ximg[n-1])-(objmapa.w/2)-1,pontosdistobj.yimg[n-1]-3,dx,dy-3);
				richdraw.renderer.create(richdraw.mode, richdraw.fillColor, richdraw.lineColor, richdraw.lineWidth, (pontosdistobj.ximg[0])-(objmapa.w/2)-1,pontosdistobj.yimg[0]-3,dx,dy-3);
			}
			catch(e){window.status=n+" erro ao movimentar a linha ";}			
		}
		if(tipo=="insereCirculo")
		{
			if (navn)
			{
				var dx = Math.pow(((pontosdistobj.xtela[n])*1) - ((pontosdistobj.xtela[n-1])*1),2);
				var dy = Math.pow(((pontosdistobj.ytela[n])*1) - ((pontosdistobj.ytela[n-1])*1),2);
				var w = Math.sqrt(dx + dy);
				try
				{
					richdraw.renderer.create('circ', '', 'rgb(250,250,250)', richdraw.lineWidth, pontosdistobj.ximg[n-1],pontosdistobj.yimg[n-1],w,w);
				}
				catch(e){window.status=n+" erro ao desenhar o raio";}
			}
			else
			{
				var dx = Math.pow(((pontosdistobj.xtela[n])*1) - ((pontosdistobj.xtela[n-1])*1),2);
				var dy = Math.pow(((pontosdistobj.ytela[n])*1) - ((pontosdistobj.ytela[n-1])*1),2);
				var w = Math.sqrt(dx + dy);
				try
				{
					richdraw.renderer.create('circ', '', 'rgb(250,250,250)', richdraw.lineWidth, pontosdistobj.ximg[n-1]-w,pontosdistobj.yimg[n-1]-w,w*2,w*2);
				}
				catch(e){window.status=n+" erro ao desenhar o raio";}
			}
		}
	}
}
/*
Section: outros
*/
/*
Function: i3geo_pegaElementoPai

Pega o elemento pai de um elemento clicado para identificar o código do tema.

Parameters:

e - elemento do DOM.
*/
function i3geo_pegaElementoPai(e)
{
	var targ;
	if (!e)
	{var e = window.event;}
	if (e.target)
	{targ = e.target;}
	else
	if (e.srcElement)
	{targ = e.srcElement;}
	if (targ.nodeType == 3)
   	{targ = targ.parentNode;}
	var tname;
	tparent=targ.parentNode;
	return(tparent);
}
/*
Function: inseremarcaf

Insere um ponto no mapa.

Os pontos são inseridos em um contaier de pontos e mostrados temporáriamente como uma imagem.
Utilizado pela função de medição de distâncias.

Parameters:

xi - coordenada x.

yi - coordenada y.

funcaoonclick - funcao que sera executada quando a marca for clicada
*/
function inseremarcaf(xi,yi,funcaoOnclick)
{
	try
	{
		//verifica se existe o container para os pontos
		if (!$i("pontosins") )
		{
			var novoel = document.createElement("div");
			novoel.id = "pontosins";
			var i = novoel.style;
			i.position = "absolute";
			i.top = parseInt($i("img").style.top);
			i.left = parseInt($i("img").style.left);
			document.body.appendChild(novoel);
		}
		var container = $i("pontosins");
		var novoel = document.createElement("div");
		var i = novoel.style;
		i.position = "absolute";
		i.zIndex=2000;
		i.top=(yi - 4)+"px";
		i.left=(xi - 4)+"px";
		i.width="4px";
		i.height="4px";
		var novoimg = document.createElement("img");
		if (arguments.length == 2)
		{funcaoOnclick = "";}
		if (funcaoOnclick != "")
		{novoimg.onclick = funcaoOnclick;}
		novoimg.src=g_locaplic+"/imagens/dot1.gif";
		with (novoimg.style){width="6px";height="6px";zIndex=2000;}
		novoel.appendChild(novoimg);
		container.appendChild(novoel);
	}
	catch(e){alert("Ocorreu um erro. inseremarcaf"+e);}
}
/*
Function: limpacontainerf

Limpa o container de pontos.
*/
function limpacontainerf()
{
	if ($i("pontosins"))
	{$i("pontosins").innerHTML = "";}
	if ($i("mostradistancia"))
	{$i("mostradistancia").style.display="none";}
}
/*
Function: criaboxg

Cria o div boxg utilizado nas operações de navegação, google, etc.

O boxg é utilizado para o desenho de retângulos na tela.
*/
function criaboxg()
{
	if (!$i("boxg"))
	{
		var novoel = document.createElement("div");
		novoel.id = "boxg";
		novoel.style.zIndex=1;
		novoel.innerHTML = '<font face="Arial" size=0></font>';
		novoel.onmouseover = function(){$i("boxg").style.display="none";};
		document.body.appendChild(novoel);
	}
	if (!$i("boxpin"))
	{
		var novoel = document.createElement("img");
		novoel.id = "boxpin";
		novoel.style.zIndex=10000;
		novoel.style.position="absolute";
		novoel.style.width="21px";
		novoel.style.height="25px";
		novoel.src = g_locaplic+'/imagens/marker.png';
		//novoel.innerHTML = '<img src="'+g_locaplic+'/imagens/marker.png" />';
		novoel.onmouseover = function(){$i("boxpin").style.display="none";};
		document.body.appendChild(novoel);
	}
}
try
{
//controle dos painéis que podem ser redimensionados
YAHOO.widget.ResizePanel = function(el, userConfig)
{
    if (arguments.length > 0) 
    {YAHOO.widget.ResizePanel.superclass.constructor.call(this, el, userConfig);}
};
YAHOO.widget.ResizePanel.CSS_PANEL_RESIZE = "yui-resizepanel";
YAHOO.widget.ResizePanel.CSS_RESIZE_HANDLE = "resizehandle";
YAHOO.extend
(
	YAHOO.widget.ResizePanel, YAHOO.widget.Panel,
	{
   		init: function(el, userConfig) 
   		{
    		YAHOO.widget.ResizePanel.superclass.init.call(this, el);
       		this.beforeInitEvent.fire(YAHOO.widget.ResizePanel);
       		var Dom = YAHOO.util.Dom,
           		Event = YAHOO.util.Event,
           		oInnerElement = this.innerElement,
           		oResizeHandle = document.createElement("DIV"),
           		sResizeHandleId = this.id + "_resizehandle";
       		oResizeHandle.id = sResizeHandleId;
       		oResizeHandle.className = YAHOO.widget.ResizePanel.CSS_RESIZE_HANDLE;
       		Dom.addClass(oInnerElement, YAHOO.widget.ResizePanel.CSS_PANEL_RESIZE);
       		this.resizeHandle = oResizeHandle;
       		function initResizeFunctionality()
       		{
           		var me = this,
               		oHeader = this.header,
               		oBody = this.body,
               		oFooter = this.footer,
               		nStartWidth,
               		nStartHeight,
               		aStartPos,
               		nBodyBorderTopWidth,
               		nBodyBorderBottomWidth,
               		nBodyTopPadding,
               		nBodyBottomPadding,
               		nBodyOffset;
           		oInnerElement.appendChild(oResizeHandle);
           		this.ddResize = new YAHOO.util.DragDrop(sResizeHandleId, this.id);
           		this.ddResize.setHandleElId(sResizeHandleId);
           		this.ddResize.onMouseDown = function(e)
           		{
               		nStartWidth = oInnerElement.offsetWidth;
               		nStartHeight = oInnerElement.offsetHeight;
               		if (YAHOO.env.ua.ie && document.compatMode == "BackCompat")
               		{nBodyOffset = 0;}
               		else
               		{
                   		nBodyBorderTopWidth = parseInt(Dom.getStyle(oBody, "borderTopWidth"), 10),
                   		nBodyBorderBottomWidth = parseInt(Dom.getStyle(oBody, "borderBottomWidth"), 10),
                   		nBodyTopPadding = parseInt(Dom.getStyle(oBody, "paddingTop"), 10),
                   		nBodyBottomPadding = parseInt(Dom.getStyle(oBody, "paddingBottom"), 10),
                   		nBodyOffset = nBodyBorderTopWidth + nBodyBorderBottomWidth + nBodyTopPadding + nBodyBottomPadding;
               		}
               		me.cfg.setProperty("width", nStartWidth + "px");
               		aStartPos = [Event.getPageX(e), Event.getPageY(e)];
           		};
           		this.ddResize.onDrag = function(e)
           		{
               		var aNewPos = [Event.getPageX(e), Event.getPageY(e)],
                   		nOffsetX = aNewPos[0] - aStartPos[0],
                   		nOffsetY = aNewPos[1] - aStartPos[1],
                   		nNewWidth = Math.max(nStartWidth + nOffsetX, 10),
                   		nNewHeight = Math.max(nStartHeight + nOffsetY, 10),
                   		nBodyHeight = (nNewHeight - (oFooter.offsetHeight + oHeader.offsetHeight + nBodyOffset));
               		me.cfg.setProperty("width", nNewWidth + "px");
               		if (nBodyHeight < 0)
               		{nBodyHeight = 0;}
               		oBody.style.height =  nBodyHeight + "px";
               		if ($i("wdocai"))
               		{$i("wdocai").style.height = nBodyHeight;}
           		};
       		};
       		function onBeforeShow()
       		{
       			initResizeFunctionality.call(this);
       			this.unsubscribe("beforeShow", onBeforeShow);
       		};
       		function onBeforeRender()
       		{
           		if (!this.footer)
           		{this.setFooter("");}
           		if (this.cfg.getProperty("visible"))
           		{initResizeFunctionality.call(this);}
           		else
           		{this.subscribe("beforeShow", onBeforeShow);}
       			this.unsubscribe("beforeRender", onBeforeRender);
       		};
       		this.subscribe("beforeRender", onBeforeRender);
       		if (userConfig)
       		{this.cfg.applyConfig(userConfig, true);}
       		this.initEvent.fire(YAHOO.widget.ResizePanel);
   		},
   		toString: function()
   		{return "ResizePanel " + this.id;}
	}
);
}
catch(e){};
/*
Function: ativaDragDrop

Ativa a funcionalidade de arrastar e soltar para alteração da ordem de desenho dos temas e para excluir um tema do mapa.
*/
function ativaDragDrop()
{
	var Dom = YAHOO.util.Dom;
	var Event = YAHOO.util.Event;
	var DDM = YAHOO.util.DragDropMgr;
	YAHOO.example.DDList = "";
	YAHOO.example.DDApp = 
	{
    	init: function() 
    	{
        	if($i("lixeira"))
        	{new YAHOO.util.DDTarget("lixeira");}
        	var lista = objmapa.temas.split(";");
        	var i = lista.length-1;
        	if (i >= 0)
        	{
	        	do
	        	{
               		var ltema = lista[i].split("*");
               		if($i("arrastar_"+ltema[0]))
               		{new YAHOO.example.DDList("arrastar_"+ltema[0]);}
        		}
        		while(i--)
        	}
    	}
	};
	YAHOO.example.DDList = function(id, sGroup, config) 
	{
	    YAHOO.example.DDList.superclass.constructor.call(this, id, sGroup, config);
	    this.logger = this.logger || YAHOO;
    	var el = this.getDragEl();
    	Dom.setStyle(el, "opacity", 0.67); // The proxy is slightly transparent
	    this.goingUp = false;
   		this.lastY = 0;
	};
	YAHOO.extend
	(
		YAHOO.example.DDList, YAHOO.util.DDProxy, 
		{
	    	startDrag: function(x, y) 
	    	{
        		this.logger.log(this.id + " startDrag");
	        	// make the proxy look like the source element
    	    	var dragEl = this.getDragEl();
        		var clickEl = this.getEl();
        		Dom.setStyle(clickEl, "visibility", "hidden");
	        	dragEl.innerHTML = clickEl.innerHTML;
	        	Dom.setStyle(dragEl, "color", Dom.getStyle(clickEl, "color"));
   		    	Dom.setStyle(dragEl, "backgroundColor", Dom.getStyle(clickEl, "backgroundColor"));
    	    	Dom.setStyle(dragEl, "border", "4px solid gray");
    	    	Dom.setStyle(dragEl, "z-index", "5000");
    		},
	    	endDrag: function(e) 
	    	{
	        	var srcEl = this.getEl();
    	    	var proxy = this.getDragEl();
	        	// Show the proxy element and animate it to the src element's location
    	    	Dom.setStyle(proxy, "visibility", "");
        		var a = new YAHOO.util.Motion
        		( 
           			proxy,
            		{ 
                		points:
                		{to: Dom.getXY(srcEl)}
    	        	}, 
        	   	 	0.2, 
            		YAHOO.util.Easing.easeOut
        		);
        		var proxyid = proxy.id;
        		var thisid = this.id;
	        	// Hide the proxy and show the source element when finished with the animation
	        	a.onComplete.subscribe
	        	(
	        		function() 
	        		{
                		Dom.setStyle(proxyid, "visibility", "hidden");
                		Dom.setStyle(thisid, "visibility", "");
            		}
            	);
	        	a.animate();
	        	if ($i("lixeira"))
	        	{$i("lixeira").style.border = "0px solid blue";} 	
    		},
	    	onDragDrop: function(e, id)
	    	{
	        	// If there is one drop interaction, the li was dropped either on the list,
	        	// or it was dropped on the current location of the source element.
	        	if (DDM.interactionInfo.drop.length === 1)
	        	{
	            	// The position of the cursor at the time of the drop (YAHOO.util.Point)
	            	var pt = DDM.interactionInfo.point; 
	            	// The region occupied by the source element at the time of the drop
	            	var region = DDM.interactionInfo.sourceRegion; 
	            	// Check to see if we are over the source element's location.  We will
	            	// append to the bottom of the list once we are sure it was a drop in
	            	// the negative space (the area of the list without any list items)
	            	if (!region.intersect(pt))
	            	{
                		var destEl = Dom.get(id);
                		//var destDD = DDM.getDDById(id);
                		if(DDM.getDDById(id).id != "lixeira")
                		{
                 			if(navn)
							{
								 var brd = document.createElement("br");
	                			 brd.appendChild(this.getEl());
    	            			 destEl.appendChild(brd);
							}
							else
							{destEl.appendChild(this.getEl());}		
                		}
                		//destDD.isEmpty = false;
                		DDM.refreshCache();
                		//exclui tema
                		if(DDM.getDDById(id).id == "lixeira")
                		{
                			var tema = (this.getEl()).id.split("arrastar_")[1];
                			objaguarde.abre("ajaxredesenha",$trad("o1"));
							var p = g_locaplic+"/classesphp/mapa_controle.php?funcao=excluitema&temas="+tema+"&g_sid="+g_sid;
							cpObj.call(p,"excluiTemas",ajaxredesenha);
							objmapa.temaAtivo = "";
						}
						//muda ordem de desenho do tema
						else
						{
 							var els = $i("mytreeview1").getElementsByTagName("input");
 							var lista = new Array();
 							var tempie = els.length;
 							for (var i=0;i<tempie;i=i+1)
 							{
 								if(els[i].type == "checkbox")
 								{
 									var itema = els[i].value;
 									lista.push(itema);
 								}								
 							}
 							var lista = lista.join(',');
 							if($i("listaTemas")){$i("listaTemas").innerHTML = "";}
							var p = g_locaplic+"/classesphp/mapa_controle.php?funcao=reordenatemas&lista="+lista+"&g_sid="+g_sid;
							var cp = new cpaint();
							//cp.set_debug(2)
							cp.set_response_type("JSON");
							cp.call(p,"reordenatemas",ajaxredesenha);
						}
            		}
	        	}
	    	},
	    	onDrag: function(e) 
	    	{
	        	// Keep track of the direction of the drag for use during onDragOver
	        	var y = Event.getPageY(e);
	        	if (y < this.lastY) 
	        	{this.goingUp = true;}
        		else
        		if (y > this.lastY)
        		{this.goingUp = false;}
	        	this.lastY = y;
	    	},
	    	onDragOver: function(e, id) 
	    	{
	        	var srcEl = this.getEl();
	        	var destEl = Dom.get(id);
	        	// We are only concerned with list items, we ignore the dragover
	        	// notifications for the list.
	        	if ($i("lixeira") && id == "lixeira")
	        	{$i("lixeira").style.border = "1px solid red";}
	        	else
	        	{
	        		destEl.style.textDecoration="underline";
	        	}
	    	},
	    	onDragOut: function(e, id)
	    	{
	    		$i(id).style.textDecoration="none";
	    	}
		}
	);
	Event.onDOMReady(YAHOO.example.DDApp.init, YAHOO.example.DDApp, true);
}
/*
Function: removeAcentos

Remove acentos de uma palavra ou frase

Parameters:

palavra -
*/
function removeAcentos(palavra)
{
	var re = /ã|á|à|â/gi;
	palavra = palavra.replace(re,"a");
	var re = /é/gi;
	palavra = palavra.replace(re,"e");
	var re = /í/gi;
	palavra = palavra.replace(re,"i");
	var re = /ó|õ/gi;
	palavra = palavra.replace(re,"o");
	var re = /ç/gi;
	palavra = palavra.replace(re,"c");
	var re = /ú/gi;
	palavra = palavra.replace(re,"u");
	return(palavra);
}
/*
Function: pegaPosicaoObjeto

Retorna a posição x,y de um objeto em relação a tela do navegador
*/
function pegaPosicaoObjeto(obj)
{
	if(obj)
	{
		if(obj.style.position == "absolute")
		{
			return [(parseInt(obj.style.left)),(parseInt(obj.style.top))];
		}
		else
		{
			var curleft = curtop = 0;
			if(obj)
			{
				if (obj.offsetParent) {
					do {
						curleft += obj.offsetLeft-obj.scrollLeft;
						curtop += obj.offsetTop-obj.scrollTop;
					} while (obj = obj.offsetParent);
				}
			}
			return [curleft,curtop];
		}
	}
	else
	{return [0,0];}
}
/*
Function: recuperamapa

Tenta recuperar o último mapa, caso tenha ocorrido algum erro.
*/
function recuperamapa()
{
	g_recupera = 1;
	var p = g_locaplic+"/classesphp/mapa_controle.php?funcao=recuperamapa&g_sid="+g_sid;
	var cp = new cpaint();
	//cp.set_debug(2)
	cp.set_response_type("JSON");
	cp.call(p,"recuperamapa",remapaf);
}
/*
Function: protocolo

Retorna o protocolo utilizado na url.
*/
function protocolo()
{
	var u = window.location.href;
	var u = u.split(":");
	return (u[0]);
}
//Mantido aqui apenas para fins de compatibilidade
function borra()
{}
//testa se esse script foi carregado
function testafuncoes()
{}