i_ctrl.js 56.6 KB
Newer Older
Zhou Yang's avatar
Zhou Yang committed
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
/*当前版本:1.013 2015-10-17*/
/*构造函数*/
I.ctrl.extCas({
    __fchCls: function(jo,str) {
        if(!str) { return str; }
        var rx=/\/([\w\W]+)\//,r=str.match(rx);
        if(!r) { return str; }
        r=new RegExp(r[1]);
        jo.each(function(i,o) {
            var cls=o.className,
			a=cls.match(r);
            if(a) { a.length>1?a.splice(0,1):0; a=a.join(""); } else { a=""; }
            o.__cls=a;
        });
        return str.replace(rx,"{0}");
    },
    __rpcCls: function(e,str,def) {
        return str?str.replace("{0}",e.__cls):def;
    },
    hover: function(cls,cfg) {
        var m=this,cfg=$.extend({
            required: 0/*必选*/
        },cfg),jos=$("");
        m.sel=m.sel||$(m._args[0]);
        cls=m.__fchCls(m.sel,cls);
        if(cfg.required) {
            m.sel.hover(
				function() {
					jos.removeClass(m.__rpcCls(this,cls,"h"));
					jos=$(this).addClass(m.__rpcCls(this,cls,"h"));
				}
			).first().trigger("mouseover");
        } else {
            m.sel.hover(
				function() { $(this).addClass(m.__rpcCls(this,cls,"h")); },
				function() { $(this).removeClass(m.__rpcCls(this,cls,"h")); }
			);
        } return m;
    },
    select: function(cls,num,cfg) {
        var m=this; m.sel=m.sel||$(m._args[0]);
        cls=m.__fchCls(m.sel,cls);
        var o={},jid=$.expando,n=0/*当前数量*/,
			c=num==m.__null?1:num==0?num=m.sel.length:num/*选中数量0不限制,1单选,>1多选*/,
			cfg=$.extend({
				msg: "最多只能选择{0}个!",
				required: 0,/*必选1个*/
				recursion: 0,/*递归选择器*/
				clear: 0,/*达到指定选择时清除已选*/
				effect: 0,/*scroll|fade*/
				bindEffect: 0,/*淡入淡出子第一个对象*/
				bindAll: 0/*全选触发对象*/
			},cfg),rcs=cfg.recursion,
			efs=cfg.bindEffect,
			efc=cfg.effect,ad,
			effn=efc?({
				scroll: function(jo,fn) { jo.animate({ height: 'toggle' },300,fn); },
				fade: function(jo,fn) { jo.animate({ opacity: 'toggle' },300,fn); }
			})[efc]:0,
			mvs=function(id) {
				n--; var jo=o[id],e=jo[0],fd=e._fd,
					fn=function() { jo.removeClass(m.__rpcCls(e,cls,"s")); }; o[id]=0;
				fd?effn(fd,fn):fn();/*淡出*/
			},
			clr=function() { $.each(o,function(i) { o[i]?mvs(i):0; }); o={}; n=0; },
			ad1=function(id) { if(n+1>c) { clr(); } n++; return 1; },
			ad2=function(id) { if(n+1>c) { alert(cfg.msg.replace('{0}',c)); return 0; } else { n++; return 1; } },
			ads=function(id,e) {
				if(!ad(id)) { return; }; var jo=o[id]=$(e),fd=e._fd;
				jo.addClass(m.__rpcCls(e,cls,"s"));
				if(!e._isLoad) {
				    e._isLoad=1; if(efc) { fd=efs?jo.find(efs+":first"):jo; if(fd.length>0) { e._fd=fd.hide(); } }
				}
				fd?effn(fd):0;/*淡入*/
			};
        switch(c) { case 1: ad=ad1; break; default: ad=cfg.clear?ad1:ad2; break; }
        cfg.bindAll?$(cfg.bindAll).click(function() {
            if(n<c) { m.sel.each(function(i,e) { n<c?ads(e[jid],e):0; }); } else { clr(); }
        }):0;
        m.sel.click(function() {
            var e=this,id=e[jid]; if(o[id]) { mvs(id); } else { ads(id,e); }
            if(rcs) {/*递归选择*/
                if(!e.rcs) {
                    e.rcs=1;
                    var s=$.extend({},m);
                    s.sel=$(e).find(rcs).first().siblings(rcs).andSelf();
                    s.sel.unbind("click");
                    s.select(cls,num,cfg);
                }
                return false;
            }
        }); return m;
    }
}).extCls({
    fc: function(sel,cfg) {
        var m=this; sel=sel||$(m._args[0]);
        cfg=$.extend({ isCss: 1/*使用样式实现*/ },cfg);
        if(cfg.isCss) {
            $.each($(sel),function(i,o) {
                var jo=$(o).css({ position: "relative" }),
					od=$("<div style='float:right;position:relative;left:-50%;+float:left;+left:50%;'></div>"),
					id=$("<div style='float:right;position:relative;left:50%;+float:left;+left:-50%;'></div>");
                id.html(jo.html()); jo.empty();
                jo.append(od); od.append(id);
            });
        } else {
            $.each($(sel),function(i,o) {
                var jo=$(o),id=$("<div style='float:left;display:inline;'></div>");
                id.html(jo.html()); jo.empty();
                id.appendTo(jo).css({
                    marginLeft: Math.round((jo.width()-id.outerWidth())/2),
                    marginTop: Math.round((jo.height()-id.outerHeight())/2)
                });
            });
        } return m;
    },
    /*效果集*/
    effects: {
        demo: {
            /*与控制器共享的配置信息*/
            cfg: {},
            /*与控制器共享的控制信息*/
            inf: {
                tm: 2000,/*切换间隔*/
                cur: 0,/*当前索引(切换时前一个索引值)*/
                at: 0,/*下个索引(切换时下一个索引值)*/
                tid: 0,/*定时器ID*/
                num: 999/*切换列表集中最小列表数量*/
            },
            /*初使化*/
            init: function() { },
            /*切换到下一个*/
            to: function() { }
            /*##############自定义方法属性##########*/
        },
        fade: {
            /*与控制器共享的配置信息*/
            cfg: {
                tm: 2000,
                mvtm: 200
            },
            /*与控制器共享的控制信息*/
            inf: {},
            /*初使化*/
            init: function() {
                var m=this;
                $.each(m.inf.mvs,function(i,jo) {
                    /*设置重叠样式*/
                    jo.hide();
                    /*设置编号*/
                    jo.each(function(i,o) {
                        var je=$(o); o._at=i;
                    });
                    /*当前列表*/
                    jo._prev=m.inf.next;
                    /*当前显示a*/
                    jo.ca=jo.eq(m.inf.next).show();
                    /*设置容器样式*/
                    jo.cp=jo.ca.parent();
                });
            },
            /*切换到下一个*/
            to: function() {
                var m=this;
                $.each(m.inf.mvs,function(i,jo) {
                    var cur=m.inf.next,prev=jo._prev,o;
                    if(prev==cur) { o=jo.eq(prev); }
                    else { jo.eq(prev).hide(); }
                    if(!o) { o=jo.eq(cur); jo._prev=cur; }
                    o.show().css({ opacity: 0 }).fadeTo(m.cfg.mvtm,1);
                });
            }
        },
        fixFade: {
            /*与控制器共享的配置信息*/
            cfg: {
                tm: 4000,
                mvtm: 500
            },
            /*与控制器共享的控制信息*/
            inf: {},
            /*初使化*/
            init: function() {
                var m=this;
                $.each(m.inf.mvs,function(i,jo) {
                    /*设置重叠样式*/
                    jo.fadeOut(0);
                    /*设置编号*/
                    jo.each(function(i,o) { o._at=i; jo.eq(i).css("zIndex",i); });
                    jo._step=jo.length;
                    /*当前显示a*/
                    jo.ca=jo.eq(m.inf.next).show().css("zIndex",jo._step);
                    /*设置容器样式*/
                    jo.cp=jo.ca.parent().css("zIndex",I.index());
                    jo.cp.css({ position: "relative",width: jo.cp.width(),height: jo.cp.height() });
                    /*隐藏*/
                    jo.css({ position: "absolute",left: "0" });
                });
                $.each(m.inf.ctrs,function(i,jo) { jo.parent().css("zIndex",I.index()); });
            },
            reset: function(jo) {
                var s={},at=0;
                $.each(jo,function(i,e) { s[e.style.zIndex]=e; });
                $.each(s,function(i,e) { e.style.zIndex=at; at++; });
                jo._step=at;
            },
            /*切换到下一个*/
            to: function() {
                var m=this;
                $.each(m.inf.mvs,function(i,jo) {
                    var cur=m.inf.next,o=jo.eq(cur); jo._step++;
                    o.hide().css("zIndex",jo._step).fadeIn(m.cfg.mvtm,function() { o.clearQueue(); });
                    if(jo._step>9999) { m.reset(jo); }
                });
            }
        },
        scroll: {
            /*与控制器共享的配置信息*/
            cfg: {
                /*{垂直:0,横向:1}*/
                dir: 1,
                tm: 3000,
                sameDir/*同一方向滚动效果*/: 0,
                mvtm: 200
            },
            /*与控制器共享的控制信息*/
            inf: {},
            /*初使化*/
            init: function() {
                var m=this;
                if(m.cfg.dir>1) { m.cfg.dir=1; }
                $.each(m.inf.mvs,function(i,jo) {
                    /*父容器*/
                    var jop=jo.eq(0).parent(),dir=m.cfg.dir;
                    /*横向排列*/
                    jo.css("float",dir?"left":"none");
                    /*取得容器宽高*/
                    w=jop.width(),h=jop.height();
                    /*设置容器宽高*/
                    jop.css({ width: dir?w:undefined,height: dir?undefined:h,overflow: "hidden",position: "relative" });
                    /*将滚动容器插入到指定容器内容的外部*/
                    var oDiv=$("<div style='width:99999px;height:99999px;position:relative;left:0;top:0;'>");
                    var iDiv=$("<div style='float:left;width:auto;height:auto;'>").append(jo);
                    jop.empty();
                    oDiv.append(iDiv);
                    jop.append(oDiv);
                    /*取得内容宽高*/
                    var ow=iDiv.width(),oh=iDiv.height();
                    oDiv.css({ width: ow,height: oh });
                    /*计算坐标*/
                    var x=0,y=0;
                    /*设置元素坐标*/
                    $.each(jo,function(i,e) {
                        var ja=$(e),o={ w: ja.outerWidth(),h: ja.outerHeight() };
                        o.x=x; o.y=y; x+=o.w,y+=o.h;
                        e.cfg=o;
                    });
                    /*设置变动长度*/
                    jop.css(m.fn[dir]($(jo[m.inf.at])));
                    /*赋值*/
                    jo.box=oDiv;
                    jo.jop=jop;

                    /*设置自动填充*/
                    if(m.cfg.sameDir) {
                        var jn=[];
                        ({
                            0: function() {
                                var p=iDiv[0],ah=0,at=0,n=m.inf.num;
                                while(ah<h) {
                                    var i=at%n,ip=(at+n-1)%n,
										ja=jo.eq(i).clone().appendTo(p);
                                    jn.push(ja);
                                    ah+=jo[i].cfg.h; at++;
                                } oDiv.css({ height: oh+ah });
                            },
                            1: function() {
                                var p=iDiv[0],aw=0,at=0,n=m.inf.num;
                                while(aw<w) {
                                    var i=at%n,ip=(at+n-1)%n,
										ja=jo.eq(i).clone().appendTo(p);
                                    jn.push(ja);
                                    aw+=jo[i].cfg.w; at++;
                                } oDiv.css({ width: ow+aw });
                            }
                        })[m.cfg.dir]();
                        var e=jn[0][0],c=jo[0].cfg;
                        e.cfg={ w: c.w,h: c.h,x: x,y: y };
                        jo.push(e);
                    }
                });
                if(m.cfg.sameDir&&!m.cfg.viewArea) { m.inf.num*=2; }
            },
            /*切换到下一个*/
            to: function() {
                var m=this;
                $.each(m.inf.mvs,function(i,jo) {
                    jo.box.clearQueue();
                    var it=jo[m.inf.next];
                    jo.jop.animate(m.fnPrt[m.cfg.dir]($(it)),m.cfg.mvtm);
                    jo.box.animate(m.fn[m.cfg.dir](it.cfg),m.cfg.mvtm);
                });
            },
            /*##############返回动画设置##########*/
            /*单个项滚动*/
            fn: { 0: function(c) { return { left: 0,top: -c.y }; },1: function(c) { return { left: -c.x,top: 0 }; } },
            /*父对象动画*/
            fnPrt: {
                0: function(it) { return { width: it.outerWidth(),height: it.outerHeight() }; },
                1: function(it) { return { height: it.outerHeight() }; }
            }
        },
        fixScroll: {
            /*与控制器共享的配置信息*/
            cfg: {
                /*{垂直:0,横向:1}*/
                dir: 1,
                tm: 4500,
                viewArea/*是否用可视区域大小切换,默认按单个项切换*/: 0,
                sameDir/*同一方向滚动效果*/: 0,
                mvtm: 1000
            },
            /*与控制器共享的控制信息*/
            inf: {},
            /*初使化*/
            init: function() {
                var m=this;
                if(m.cfg.dir>1) { m.cfg.dir=1; }
                $.each(m.inf.mvs,function(i,jo) {
                    /*父容器*/
                    var jop=jo.eq(0).parent(),dir=m.cfg.dir;
                    /*设置排列方式*/
                    jo.css("float",dir?"left":"none");
                    /*取得容器宽高*/
                    w=jop.width(),h=jop.height();
                    /*设置容器宽高*/
                    jop.css({ width: dir?w:undefined,height: dir?undefined:h,overflow: "hidden",position: "relative" });
                    /*将滚动容器插入到指定容器内容的外部*/
                    var oDiv=$("<div style='width:99999px;height:99999px;position:relative;left:0;top:0;'>");
                    var iDiv=$("<div style='float:left;width:auto;height:auto;'>").append(jo);
                    jop.empty();
                    oDiv.append(iDiv);
                    jop.append(oDiv);
                    /*取得内容宽高*/
                    var ow=iDiv.width(),oh=iDiv.height();
                    oDiv.css({ width: ow,height: oh });
                    /*计算坐标*/
                    var x=0,y=0;
                    /*设置元素坐标*/
                    $.each(jo,function(i,e) {
                        var ja=$(e),o={ w: ja.outerWidth(),h: ja.outerHeight() };
                        o.x=x; o.y=y; x+=o.w,y+=o.h;
                        e.cfg=o;
                    });
                    /*赋值*/
                    jo.box=oDiv;
                    jo.jop=jop;
                    /*可视范围滚动*/
                    if(m.cfg.viewArea) {
                        m._ow=ow; m._oh=oh; m._w=w; m._h=h;
                        ({
                            0: function() { m.inf.num=Math.ceil(oh/h); },
                            1: function() { m.inf.num=Math.ceil(ow/w); }
                        })[m.cfg.dir]();
                        m.to=m.toViewArea;
                        return;
                    }
                    /*设置自动填充*/
                    if(m.cfg.sameDir) {
                        var jn=[];
                        ({
                            0: function() {
                                var p=iDiv[0],ah=0,at=0,n=m.inf.num;
                                while(ah<h) {
                                    var i=at%n,ip=(at+n-1)%n,
										ja=jo.eq(i).clone().appendTo(p);
                                    jn.push(ja);
                                    ah+=jo[i].cfg.h; at++;
                                } oDiv.css({ height: oh+ah });
                            },
                            1: function() {
                                var p=iDiv[0],aw=0,at=0,n=m.inf.num;
                                while(aw<w) {
                                    var i=at%n,ip=(at+n-1)%n,
										ja=jo.eq(i).clone().appendTo(p);
                                    jn.push(ja);
                                    aw+=jo[i].cfg.w; at++;
                                } oDiv.css({ width: ow+aw });
                            }
                        })[m.cfg.dir]();
                        var e=jn[0][0],c=jo[0].cfg;
                        e.cfg={ w: c.w,h: c.h,x: x,y: y };
                        jo.push(e);
                        m.to=m.toAutoPadding;
                    } else {
                        ({/*显示不足一页时禁止切换*/
                            0: function() {
                                var at=m.inf.num,ah=0;
                                while(ah<h&&at>0) {
                                    at--;
                                    ah+=jo[at].cfg.h;
                                } m.inf.num=at>0?at+1:1;
                            },
                            1: function() {
                                var at=m.inf.num,aw=0;
                                while(aw<w&&at>0) {
                                    at--;
                                    aw+=jo[at].cfg.w;
                                } m.inf.num=at+1;
                            }
                        })[m.cfg.dir]();
                    }
                });
                if(m.cfg.sameDir&&!m.cfg.viewArea) { m.inf.num*=2; }
            },
            /*切换到下一个*/
            to: function() {
                var m=this;
                $.each(m.inf.mvs,function(i,jo) {
                    jo.box.clearQueue();
                    var it=jo[m.inf.next];
                    jo.box.animate(m.fn[m.cfg.dir](it.cfg),m.cfg.mvtm);
                });
            },
            toViewArea: function() {
                var m=this;
                $.each(m.inf.mvs,function(i,jo) {
                    jo.box.clearQueue();
                    jo.box.animate(m.fnViewArea[m.cfg.dir](m,m.inf.next),m.cfg.mvtm);
                });
            },
            toAutoPadding: function() {
                var m=this,ok=m.inf.next+1==m.inf.num;
                $.each(m.inf.mvs,function(i,jo) {
                    jo.box.clearQueue();
                    var it=jo[m.inf.next];
                    jo.box.animate(m.fn[m.cfg.dir](it.cfg),m.cfg.mvtm,ok&&function() {
                        jo.box.css(m.fn[m.cfg.dir](jo[0].cfg));
                    });
                });
                ok?(m.inf.next=0):0;
            },
            /*##############返回动画设置##########*/
            /*单个项滚动*/
            fn: { 0: function(c) { return { left: 0,top: -c.y }; },1: function(c) { return { left: -c.x,top: 0 }; } },
            /*可视范围滚动*/
            fnViewArea: {
                0: function(jo,at) { var l=jo._h*at; l+jo._h>jo._oh?(l=jo._oh-jo._h):0; return { left: 0,top: -l }; },
                1: function(jo,at) { var l=jo._w*at; l+jo._w>jo._ow?(l=jo._ow-jo._w):0; return { left: -l,top: 0 }; }
            }
        },
        /*窗帘拉开滚动效果*/
        scroll2: {
            /*与控制器共享的配置信息*/
            cfg: {
                /*{垂直:0,横向:1}*/
                dir: 1,
                tm: 5000,
                min/*最小宽或高*/: 30,
                fixLong/*是否固定长度*/: 0,
                moveTL/*是否向上或左移动min距离*/: 0,
                mvtm: 500
            },
            /*与控制器共享的控制信息*/
            inf: {},
            /*初使化*/
            init: function() {
                var m=this;
                if(m.cfg.dir>1) { m.cfg.dir=1; }
                $.each(m.inf.mvs,function(i,jo) {
                    /*移动方式*/
                    jo.move={
                        0: {
                            0: function(i) {
                                jo.js.css({ height: jo.js.jbh+jo.js.toh*i });
                                jo.jh.css({ height: jo.jh.jbh+jo.jh.toh*(1-i) });
                            },
                            1: function(i) {
                                jo.js.css({ width: jo.js.jbw+jo.js.tow*i });
                                jo.jh.css({ width: jo.jh.jbw+jo.jh.tow*(1-i) });
                            }
                        },
                        1: {
                            0: function(i) {
                                var min=jo.js.jbh,ml=jo.jh.toh,tol=Math.ceil(ml*i);
                                jo.js.css({ height: min+tol });
                                jo.js.jd.css({ marginTop: -i*min });
                                jo.jh.css({ height: min+ml-tol });
                                jo.jh.jd.css({ marginTop: min*i-min });
                            },
                            1: function(i) {
                                var min=jo.js.jbw,ml=jo.jh.tow,tol=ml*i;
                                jo.js.css({ width: min+tol });
                                jo.js.jd.css({ marginLeft: -i*min });
                                jo.jh.css({ width: min+ml-tol });
                                jo.jh.jd.css({ marginLeft: min*i-min });
                            }
                        }
                    }[m.cfg.moveTL][m.cfg.dir];
                    /*创建定时器*/
                    jo.st=I.timeout(function(i) { jo.move(i) });
                    /*初使化*/
                    var c,mtl=m.cfg.moveTL?2:1;
                    jo.each(function(i,e) {
                        var jb=e.jb=$(e),jd=jb.jd=$("<div>").html(jb.html());
                        jb.jbh=jb.jbw=m.cfg.min;
                        if(m.cfg.fixLong) {
                            c=jo.length;
                            var jop=jo.eq(0).parent(),w=jop.width(),h=jop.height();
                            jb.empty().append(jd);
                            if(m.cfg.dir) {
                                jb.tow=w-jb.jbw*c;
                                jd.css({ width: jb.tow+jb.jbw*mtl,height: h });
                                jb.css({ height: h });
                            } else {
                                jb.toh=h-jb.jbh*c;
                                jd.css({ width: w,height: jb.toh+jb.jbh*mtl });
                                jb.css({ height: w });
                            }
                        } else {
                            c=1;
                            var jop=jo.eq(0).parent(),w=jop.width();
                            if(m.cfg.dir) {
                                jb.tow=w-jb.jbw*c;
                                jd.css({ width: jb.tow+jb.jbw*mtl });
                            } else {
                                jd.css({ width: w });
                            }
                            jb.empty().append(jd);
                            var h=jd.height();
                            if(m.cfg.dir) {
                                jd.css({ height: h });
                            } else {
                                jb.toh=h-jb.jbh*c;
                                jd.css({ height: jb.toh+jb.jbh*mtl });
                            }
                        }
                    });
                    jo.js=jo[0].jb; jo.jh=jo[1].jb;
                    jo.js.addClass("s").css(m.cfg.dir?{ width: jo.js.tow+jo.js.jbw }:{ height: jo.js.toh+jo.js.jbh });
                    if(m.cfg.moveTL) { jo.js.jd.css({ marginLeft: -jo.js.jbw }); }
                });
            },
            to: function() {
                var m=this;
                $.each(m.inf.mvs,function(i,jo) {
                    var it=jo[m.inf.next];
                    if(jo.js==it.jb) { return; }
                    jo.st.start(m.cfg.mvtm,
						function() { jo.jh.removeClass("s"); jo.js.addClass("s"); },
						function() { jo.jh=jo.js; jo.js=it.jb; }
					);
                });
            }
        }
    },
    /*控制器*/
    tab: function(
        /*切换列表集强烈建意使用块对象(display:block)*/views,
        /*对应列表集*/ctrls,
        /*前后列表集*/ctrlpns,
        /*配置*/config
        ) {
        /*参数不正确则退出*/
        var ok=function() { return 1; },ts={ str: ok,arr: ok };
        if(!views) { return; }
        /*延迟运行*/
        var ctrl=this,
            cfg={/*实例化配置*/
                effect: "scroll"/*效果*/,
                autoPlay: true/*自动播放*/,
                defAt: 0/*默认索引位置*/,
                pnloop: false/*前后切换时,到达第一张或最后一张时循环*/,
                clsPrevEnd: "prevend"/*显示第一个时向前按钮的样式*/,
                clsNextEnd: "nextend"/*显示第一个时向后按钮的样式*/,
                showEvt: "click"/*显示使用的事件类型*/,
                hideEvt: 0/*隐藏使用的事件类型*/,
                onshow: function(at) { }/*切换触发函数*/,
                onhide: function(at) { },
                on: {}/*向前兼容*/
            },
			inf={/*上下文信息*/
				mvs: [],/*显示对象列表*/
				at: 0,/*当前索引(切换时前一个索引值)*/
				next: 0,/*将要显示的索引*/
				tid: 0,/*定时器ID*/
				num: 999/*切换列表集中最小列表数量*/
			},
            efc/*效果器*/,
			htid/*隐藏定时器*/,
			id/*定时器ID*/;
        /*转换成jQuery*/
        function toJq(obj) { var a=[]; for(var b in obj) { a.push($(obj[b])); } return a; }
        /*操作列表*/
        var rtn={
            /*初使化*/
            init: function() {
                /*取得效果器*/
                efc=I.extend({},ctrl.effects[config.effect||cfg.effect]);
                efc.cfg=I.extend(cfg,efc.cfg,config);
                cfg.showEvt=cfg.on.show||cfg.showEvt;/*向前兼容*/
                cfg.hideEvt=cfg.on.hide||cfg.hideEvt;/*向前兼容*/
                efc.inf=I.extend(inf,efc.inf);
                /*显示对象集*/
                inf.mvs=toJq(I.toArr(views));
                /*取最小列表数量*/
                I.each(inf.mvs,function(i,o) {
                    var c=o.length;
                    if(c<inf.num) { inf.num=c; }
                });
                /*选项控制器*/
                inf.ctrs=toJq(I.toArr(ctrls));
                /*上下控制器*/
                inf.cpns=toJq(I.toArr(ctrlpns));
                /*设置默认项*/
                if(cfg.hideEvt) { inf.next=-1; }
                else { inf.next=cfg.defAt>0?cfg.defAt:0; }
                /*初使化效果器*/
                efc.init&&efc.init();
            },
            bind: function() {
                /*鼠标悬停*/
                if(cfg.autoPlay) {
                    I.each(inf.mvs,function(i,jo) {
                        jo.hover(function() { rtn.stop().show(); },function() { rtn.run().hide(); });
                    });
                }
                /*邦定选项控制器*/
                if(ctrls) {
                    var sh=function() { var i=this._at; rtn.stop(i).show(i).run(); }/*控制显示*/,
                        hd=function() { rtn.hide(); }/*控制隐藏*/;
                    I.each(inf.ctrs,function(i,jo) {
                        var c=inf.num,cj=jo.length,jop=jo.parent(),
                            jo1=jo.eq(0),temp=jo1.html().replace(/\s*\d+\s*/g,"{0}"),
                        htm=/^\s*\d+\s*$/.test(jo1.text())?function(jo,at) { jo.html(temp.replace(/\{0\}/g,at)); }:function() { };
                        for(var i=0;i<c;i++) {
                            var e=jo[i],t;
                            if(e) { t=$(e); } else { t=jo1.clone(); jop.append(t); e=t[0]; jo.push(e); }
                            htm(t,i+1);
                            e._at=i;
                        }
                        jo.bind(cfg.showEvt,sh);
                        if(cfg.hideEvt) { jo.bind(cfg.hideEvt,hd); }
                        else { if(jo[inf.next]) { jo.ca=jo.eq(inf.next).addClass("s"); } }
                    });
                }
                /*邦定上下控制器*/
                rtn.setPnCtrs=I.empty;
                if(ctrlpns) {
                    var endAt=inf.num-1,jp=$(),jn=$(),pdel=0,ndel=0,
                        go=function(x) { rtn.stop().show(inf.next+x).run(); };
                    I.each(inf.cpns,function(i,jo) {
                        if(jo.length<2) { return; }
                        jp=jp.add(jo[0]).css({ zIndex: I.index() }); jn=jn.add(jo[1]).css({ zIndex: I.index() });
                    });
                    if(!cfg.pnloop) {
                        rtn.setPnCtrs=function() {
                            switch(inf.next) {
                                case 0:
                                    if(pdel) { pdel=0; jp.addClass(cfg.clsPrevEnd); }
                                    if(!ndel) { ndel=1; jn.removeClass(cfg.clsNextEnd); }
                                    break;
                                case endAt:
                                    if(!pdel) { pdel=1; jp.removeClass(cfg.clsPrevEnd); }
                                    if(ndel) { ndel=0; jn.addClass(cfg.clsNextEnd); }
                                    break;
                                default:
                                    if(!pdel) { pdel=1; jp.removeClass(cfg.clsPrevEnd); }
                                    if(!ndel) { ndel=1; jn.removeClass(cfg.clsNextEnd); }
                                    break;
                            }
                        };
                    }
                    if(inf.next<1) { jp.addClass(cfg.clsPrevEnd); ndel=1; }
                    if(inf.next>=endAt) { jn.addClass(cfg.clsNextEnd); pdel=1; }
                    jp.click(cfg.pnloop?function() { go(-1); }:function() { pdel>0&&go(-1); });
                    jn.click(cfg.pnloop?function() { go(1); }:function() { ndel>0&&go(1); });
                }
            },
            /*显示指定*/
            show: function(i) {
                /*停止隐藏操作*/
                clearTimeout(htid);
                if(i==undefined) { return this; }
                /*n下个索引*/
                var n=(i+inf.num)%inf.num;
                /*下个索引=当前索引则退出*/
                if(inf.next==n) { return this; }
                /*设置当前索引*/
                inf.at=inf.next;
                inf.next=n;
                /*停止播放列表*/
                I.each(inf.mvs,function(i,jo) { jo.stop(1,1); });
                /*切换当前对象*/
                efc.to();
                this.setCtrs();
                cfg.onshow(inf.next,ctrls?inf.ctrs[0][inf.next]:undefined);
                return this;
            },
            setCtrs/*设置控制器效果*/: function() {
                /*设置选择控制位置*/
                I.each(inf.ctrs,function(i,jo) {
                    jo.ca&&jo.ca.removeClass("s");
                    jo.ca=jo.eq(inf.next).addClass("s");
                });
                /*设置上下控制器*/
                this.setPnCtrs();
            },
            /*隐藏*/
            hide: function() {
                /*自动播放类型或未定义隐藏事件类型时不运行*/
                if(!cfg.on.hide) { return this; }
                /*隐藏显示对象*/
                htid=setTimeout(function() {
                    /*设置控制位置*/
                    $.each(inf.ctrs,function(i,jo) { jo.ca.removeClass("s"); cfg.onhide(inf.next,jo.ca); });
                    $.each(inf.mvs,function(i,jo) { jo.stop(true,true); });
                    inf.next=-1;
                    efc.hide&&efc.hide();
                },50);
                return this;
            },
            /*定时自动切换显示*/
            run: function() {
                /*展示数量过少或非自动播放类型时不运行*/
                if(cfg.on.hide||!cfg.autoPlay||inf.num<1) { return this; }
                var m=this; clearInterval(inf.tid);
                /*启动定时器自动播放*/
                inf.tid=setInterval(function() { m.show(inf.next+1); },cfg.tm);
                return this;
            },
            /*停止定时切换*/
            stop: function(i) { clearInterval(inf.tid); return this; }
        }; rtn.auto=rtn.run;/*向前兼容*/
        rtn.init();
        rtn.bind();
        rtn.run();
        return rtn;
    },
    /*
	无缝滚动
	$(function(){
	//创建滚动
	sc=I.ctrl(function(){this.scroll(".cs",{dir:"right"});});
	mc=I.ctrl(function(){this.scroll("#dm",{dir:2,on:"mouseover",bind:"#sleft,#sright"});//左右加速事件});
	//结束滚动
	sc.end();
	//运行滚动
	sc.run();
	//反向控制
	sc.reverse();
	});
	*/
    scroll: function(sel,cfg) {
        var jo=$(sel);
        /*配置*/
        var cfg=$.extend({
            /*方向*/dir: 3,
            /*间隔毫秒(越小越快)*/time: 50,
            /*滚动距离*/step: 1,
            /*悬停控制1-鼠标移入停止2-鼠标移入启动*/hover: 1,
            /*内容不够长时自动填充*/autoFill: 1,
            /*邦定事件类型*/on: "mousedown",
            /*邦定对象*/bind: ""
        },cfg||{});
        var btnpn=cfg.bind.split(","),speedOn=cfg.on,resetOn=({ mousedown: "mouseup",mouseover: "mouseout" })[cfg.on],
		/*后退按钮,前进按钮*/
		jop=$(btnpn[1]),jon=$(btnpn[0]);
        /*设置加速事件*/
        if(!resetOn) { speedOn="mousedown",resetOn="mouseup"; }
        /*方向,当前的方向*/
        var dir={ top: 1,right: 2,bottom: 3,left: 4,1: 1,2: 2,3: 3,4: 4 },cdir=cfg.dir=dir[cfg.dir];
        /*外部容器的宽高,滚动容器的宽高,内容容器的宽高,内容填充次数,是否往下执行*/
        var w,h,ow,oh,iw,ih,n,ok=1;
        /*取得容器宽高*/
        w=jo.width(),h=jo.height();
        /*设置容器宽高*/
        jo.css({ width: w,height: h,overflow: "hidden" });
        /*将滚动容器插入到指定容器内容的外部*/
        var oDiv=$("<div style='float:none;'>");
        var iDiv=$("<div style='width:auto;float:left'>").html(jo.html());
        jo.empty();
        oDiv.append(iDiv);
        jo.append(oDiv);
        /*定时器id,起始值,结束值,定时(毫秒),距离,进度函数*/
        var tid,start=0,end,tm=cfg.time,step=cfg.step,fn;
        /*填充内容*/
        var sets={
            1: function() {
                oDiv.css({ width: w,height: 99999 });
                /*取得内容宽高*/
                iw=iDiv.width(),ih=iDiv.height(); iDiv.css({ width: iw,height: ih });
                /*内容不能为空*/
                if(!(iw&&ih)) { return; }
                /*高度不够时退出*/
                if(!cfg.autoFill&&h>ih) { ok=0; return; }
                iDiv.css({ 'float': "none" });
                n=ih>h?1:Math.ceil(h/ih);
                for(var i=0;i<n;i++) { oDiv.append(iDiv.clone()); }
                oDiv.height((n+2)*ih);
                end=ih;
            },
            2: function() {
                oDiv.css({ width: 99999,height: h });
                /*取得内容宽高*/
                iw=iDiv.width(),ih=iDiv.height();
                /*内容不能为空*/
                if(!(iw&&ih)) { return; }
                /*宽度不够时退出*/
                if(!cfg.autoFill&&w>iw) { ok=0; return; }
                n=iw>w?1:Math.ceil(w/iw);
                for(var i=0;i<n;i++) { oDiv.append(iDiv.clone()); }
                oDiv.width((n+2)*iw);
                end=iw;
            }
        };
        sets[3]=sets[1]; sets[4]=sets[2];
        sets[dir[cdir]]();
        /*不往下执行则退出*/
        var np=function() { return this; };
        if(!ok) { return { run: np,end: np,speed: np,reverse: np }; }
        /*各方向的配置参数*/
        var fns={
            1: function() { start=(start+step)%end; var t=-start; oDiv.css({ marginTop: t }); },
            2: function() { start=(start+step)%end; var t=start-end; oDiv.css({ marginLeft: t }); },
            3: function() { start=(start+step)%end; var t=start-end; oDiv.css({ marginTop: t }); },
            4: function() { start=(start+step)%end; var t=-start; oDiv.css({ marginLeft: t }); }
        };
        fn=fns[dir[cdir]];
        /*返回实例*/
        var rtn={
            /*加速滚动long-滚动距离*/
            speed: function(long) {
                tm=long?long:50; return this;
            },
            /*反向滚动num:1-配置的方向,2-反方向,不定义-自动切换*/
            reverse: function(num) {
                var m=this,d=dir[cdir];
                if(num) {
                    if(num>2||(num==1&&cdir==cfg.dir)||(num==2&&cdir!=cfg.dir)) {
                        m.end(); m.run(); return this;
                    }
                }
                if(d%2==0) { cdir=6-d; } else { cdir=4-d; }
                start=end-start;
                fn=fns[cdir];
                m.end(); m.run(); return this;
            },
            /*执行*/
            run: function() { tid=setInterval(fn,tm); return this; },
            /*结束*/
            end: function() { clearInterval(tid); return this; }
        };
        /*悬停*/
        var minfn=function() { rtn.end(); },moutfn=function() { rtn.run(); };

        if(cfg.hover) {
            if(cfg.hover==2) { var t=minfn; minfn=moutfn; moutfn=t; }
            /*悬停控制*/
            jo.hover(minfn,moutfn);
        }
        /*邦定*/
        jop.bind(speedOn,function() { rtn.speed(5).reverse(2); }).bind(resetOn,function() { rtn.speed().end().run(); });
        jon.bind(speedOn,function() { rtn.speed(5).reverse(1); }).bind(resetOn,function() { rtn.speed().end().run(); });
        /*执行滚动*/
        moutfn();
        return rtn;
    },
    video: function(urls,selBox,config) {
        var u,iso=typeof (urls)=="object",c=urls.length,
			jb=selBox?$(selBox):0,
			n="vod"+Math.random(),
			defBg="css/com/c_vod_bg.png",
			cfg=$.extend({
				btnSrc: "css/com/c_vod_play.png"/*播放按钮*/,
				bgSrc: defBg/*背景图片地址*/,
				showControls: 0,/*显示控制条*/
				title: "",trs: 0
			},config),
			tmp="<embed id='"+n+"' name='"+n+"' src='{url}' type='video/mpeg' uiMode='mini' autostart='true' loop='true' showstatusbar='false' showcontrols='"+(cfg.showContrls?true:false)+"' showtracker='false' showpositioncontrols='false' balance='false' style='width:100%;height:100%;'></embed>",
			trs=cfg.trs?"images":0,btn=I.toResUrl(cfg.btnSrc,trs),bg=I.toResUrl(cfg.bgSrc,trs);
        defBg=I.toResUrl(defBg,trs);
        iso?0:(urls=[urls]);
        for(var i=0;i<c;i++) {
            u=urls[i].replace(/\\/g,"/").replace(/^\s+|\s+$/g,"");
            if(u) { break; }
        }
        var rtn={
            play: function() {
                var html=tmp.replace(/\{url\}/g,u);
                if(jb) { jb.html(html); } else { document.write(html); }
            }
        };
        if(jb) {
            var jbg=$("<img class='bg' style='width:100%;height:100%;' title='"+cfg.title+"' />"),
				jpl=$("<img class='play' style='position:absolute;cursor:pointer;_filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\""+btn+"\",enabled=true)' title='点击播放' />"),
				jbp=jb.css("position").replace("static","relative");
            jb.addClass('vod').css({ position: jbp }).append(jbg).append(jpl);
            jbg.error(function() { jbg.unbind('error'); this.src=defBg; });
            jpl.click(function() { rtn.play(); });
            jpl.load(function() {
                jpl.unbind('load');
                var jplw=this.width,jplh=this.height;
                jpl.css({ width: jplw,height: jplh,left: (jb.width()-jplw)/2,top: (jb.height()-jplh)/2 });
                if($.browser.msie&&$.browser.version.indexOf(6)==0) { jpl.attr("src",I.toUrl("css/com/c_alpha0.png",trs)); }
            });
            jbg.attr("src",bg); jpl.attr("src",btn);
            return rtn;
        }
        else { rtn.play(); }
    },
    /*宽高自由延伸
	例如:var autoW=$("#header,#main,#main .right,#footer"),
			autoH=$("#main,#msgtxt,#main .lists"),
			sz=autoSize(autoW,autoH,{width:1002}).bind().resize();*/
    autoSize: function(autoW,autoH,cfg) {
        cfg=$.extend({
            min: 1,
            width: 0,
            height: 0
        },cfg)
        var de=document.documentElement,bd=$("body"),
			size={ w: cfg.width||de.offsetWidth,h: cfg.height||de.offsetHeight },
			jow=[],joh=[],
			rtn={
				bind: function() {
				    $.each(autoW,function(i,o) { jow.push($(o)); });
				    $.each(autoH,function(i,o) { joh.push($(o)); });
				    $.each(jow,function(i,jo) { jo.minwidth=jo.width(); jo.rewidth=size.w-jo.minwidth; });
				    $.each(joh,function(i,jo) { jo.minheight=jo.height(); jo.reheight=size.h-jo.minheight; });
				    return this;
				},
				resize: function() {
				    var w=de.clientWidth,h=de.clientHeight;
				    if(cfg.min) {
				        $.each(jow,function(i,jo) { var sw=w-jo.rewidth; jo.width(sw<jo.minwidth?jo.minwidth:sw); });
				        $.each(joh,function(i,jo) { var sh=h-jo.reheight; jo.height(sh<jo.minheight?jo.minheight:sh); });
				    } else {
				        $.each(jow,function(i,jo) { jo.width(w-jo.rewidth); });
				        $.each(joh,function(i,jo) { jo.height(h-jo.reheight); });
				    }
				    return this;
				}
			};
        return rtn;
    },
    /*进度条/滚动条
	结构1:<div id="sc"><div class="b"></div></div>//内部可用任务标签
	结构2:<div id="sc"><div class="p"></div><div class="b"></div><div class="n"></div></div>
	I.ctrl(function(){this.silderBar("#sc");});
	*/
    silderBar: function(sctr,cfg) {
        cfg=$.extend({
            dir: 0/*0上下滚1左右滚*/,
            time: 20/*滚动触发间隔*/,
            onscroll: function(i) { }/*滚动触发,i-进度百分比*/,
            box: ""/*容器选择器*/,
            isMouseScroll: 1/*启用鼠标滚轮(box非空时有效)*/,
            step: 12/*鼠标滚轮每次触发滚动距离(box非空时有效)*/,
            autoShow: 1/*自动显示滚动条(box非空时有效)*/
        },cfg);
        var jbox=$(cfg.box),/*容器*/
			jdoc=$(document),
			jctr=$(sctr),
			jbtns=jctr.children(),
			jbtnp/*往前移*/,jbtnn/*往后移*/,jbtn/*滑块*/;
        if(jbtns.length<3) { jbtn=$(jctr.children()[0]); }
        else {
            jbtn=$(jctr.children()[1]);
            jbtnp=$(jctr.children()[0]);
            jbtnn=$(jctr.children()[2]);
        }
        var cmax=0/*控制条滚动距离*/,pos=0/*当前位置*/,mspos=0/*鼠标起始位置*/,
			ctrw,ctrh,btnw,btnh,setjbtn,
			bmax=0/*盒子滚动距离*/,setjbox,bstep/*盒子滚动距离*/,
			getPos,mousewhl,mousedow,mousemov,mouseup,
			stopevent=function(e) { e.stopPropagation&&(e.preventDefault(),e.stopPropagation())||(e.cancelBubble=true,e.returnValue=false); }/*取消事件冒泡*/,
			tmot=I.timeout(),tmout=1,tid;
        var rtn={
            init: function() {
                /*设置样式*/
                jctr.css({ position: "relative" });
                var bset={ position: "absolute" };
                jbtn.css(bset);
                if(jbtnp) { jbtnp.css(bset); jbtnn.css(bset); }
                /*计算长宽*/
                ctrw=jctr.outerWidth(); ctrh=jctr.outerHeight();
                btnw=jbtn.outerWidth(); btnh=jbtn.outerHeight();
                /*计算滚动范围*/
                var cw=ctrw-btnw,ch=ctrh-btnh;
                if(cfg.dir) {/*1左右滚*/
                    var bpw=0,bnw=0;
                    if(jbtnp) {
                        bpw=jbtnp.css({ left: 0,top: ch/2 }).outerWidth();
                        bnw=jbtnn.css({ right: 0,top: ch/2 }).outerWidth();
                    }
                    cmax=cw-bpw-bnw;
                    jbtn.css({ left: bpw,top: ch/2 });
                    getPos=function(e) { return (e.clientX-mspos); };
                    setjbtn=function(p) { jbtn.css({ left: bpw+p }); };
                    if(jbox.length>0) {
                        bmax=jbox[0].scrollWidth-jbox.width();
                        setjbox=function(p) { jbox.scrollLeft(bmax*p/cmax); };
                    } else { setjbox=function() { }; }
                } else {/*0上下滚*/
                    var bph=0,bnh=0;
                    if(jbtnp) {
                        bph=jbtnp.css({ left: cw/2,top: 0 }).outerWidth();
                        bnh=jbtnn.css({ left: cw/2,bottom: 0 }).outerWidth();
                    }
                    cmax=ch-bph-bnh;
                    jbtn.css({ left: cw/2,top: bph });
                    getPos=function(e) { return (e.clientY-mspos); };
                    setjbtn=function(p) { jbtn.css({ top: bph+p }); };
                    if(jbox.length>0) {
                        bmax=jbox[0].scrollHeight-jbox.height();
                        setjbox=function(p) { jbox.scrollTop(bmax*p/cmax); };
                    } else { setjbox=function() { }; }
                }
                /*计算盒子滚动距离*/
                if(jbox.length>0) {
                    bstep=bmax>cfg.step?cfg.step/bmax*cmax:cmax;
                    if(cfg.autoShow&&bmax==0) { jctr.fadeTo(0,0); }
                }
            },
            /*开始拖动*/
            start: function(e) {
                var m=this,n;
                if(cfg.dir) {
                    mspos=e.clientX-pos;
                } else {
                    mspos=e.clientY-pos;
                }
                /*启用捕获范围*/
                if(window.captureEvents) {
                    window.captureEvents(Event.MOUSEMOVE|Event.MOUSEUP);
                } else {
                    jbtn[0].setCapture(false);
                }
                jbtn.addClass("s");
                jdoc.bind("mousemove",mousemov).bind("mouseup",mouseup);
                stopevent(e);
            },
            /*自动移动*/
            auto: function(n) {
                var m=this;
                var set=function(jo) { jo.addClass("s"); };
                if(n>0) { set(jbtnp); } else { set(jbtnn); }
                tid=setInterval(function() { m.pos(pos+n*bstep); },cfg.time);
            },
            /*直接定位*/
            pos: function(p) {
                pos=p<0?0:(p>cmax?cmax:p);
                setjbtn(pos); setjbox(pos);
                tmout=1; cfg.onscroll(pos/cmax);
            },
            /*缓冲移动*/
            move: function(p) {
                p=p<0?0:(p>cmax?cmax:p);
                tmot.start(500,function() { pos=p; },function() {
                    var l=p-pos;
                    tmot.set(function(i) { var a=pos+l*i; setjbtn(a); setjbox(a); })
                });
            },
            /*结束拖动*/
            end: function(e) {
                /*禁用捕获范围*/
                if(window.releaseEvents) {
                    window.releaseEvents(Event.MOUSEMOVE|Event.MOUSEUP);
                } else {
                    jbtn[0].releaseCapture(false);
                }
                jbtn.removeClass("s h");
                jdoc.unbind("mousemove").unbind("mouseup");
            }
        };
        mousedow=function(e) { rtn.start(e); };
        mousemov=function(e) {
            if(tmout) {
                tmout=0;
                setTimeout(function() { rtn.pos(getPos(e)); },cfg.time);
            }
        };
        mouseup=function(e) { rtn.end(e); };
        mousewhl=function(e) {
            e=window.event||e;
            var n=(-e.wheelDelta||e.detail)>0?1:-1;
            if(tmout) {
                tmout=0;
                setTimeout(function() { rtn.pos(pos+n*bstep); },cfg.time);
            }
            stopevent(e);
        };
        I(function() {
            /*滚动事件*/
            if((jbox.length>0)&&cfg.isMouseScroll) {
                var emt=jbox[0];
                if(emt.addEventListener) {
                    /*IE9, Chrome, Safari, Opera*/
                    emt.addEventListener("mousewheel",mousewhl,false);
                    /*Firefox*/
                    emt.addEventListener("DOMMouseScroll",mousewhl,false);
                }
                    /*IE 6/7/8*/
                else { emt.attachEvent("onmousewheel",mousewhl); }
            }
            if($.browser.safari) { window.addEventListener("load",function() { rtn.init(); }); } else { rtn.init(); }
            /*附加样式*/
            var hover=function(jo) { jo.hover(function() { jo.addClass("h"); },function() { jo.removeClass("h"); }); };
            hover(jbtn);
            jbtn.bind("mousedown",function(e) { rtn.start(e); }).click(function(e) { stopevent(e);/*不向上传递*/ });
            if(jbtnp) {
                var bind=function(jo,n) {
                    var end=function(e) { clearInterval(tid); stopevent(e); };
                    jo.mousedown(function(e) { rtn.auto(n); }).mouseout(end).mouseup(end).click(end);
                }
                hover(jbtnp); bind(jbtnp,-1);
                hover(jbtnn); bind(jbtnn,1);
            }
            jctr.bind("click",function(e) {/*定向移动*/
                var emt=e.srcElement;
                if(emt) {
                    if(emt==this) {
                        rtn.move(cfg.dir?e.offsetX-btnw/2:e.offsetY-btnh/2);
                    }
                } else {
                    emt=e.currentTarget;
                    rtn.move(cfg.dir?e.layerX-btnw/2:e.layerY-btnh/2);
                }
            });
        });
        return rtn;
    }
});

I.ctrl.extCls({
    /*树形下拉菜单
    sels:树的层级选择数组
    cfgs -配置集
        btn - 触发弹出列表的按钮选择器
        box - 列表容器的选择器
        dir - 方向列表,1上,2右,3下,4左(默认为3)
        pos - 列表显示位置的偏移量,例:{l:10,t:.5},表示左侧加10像素,与按钮上下则居中
        fix - 列表是否固定宽或高:0不固定,1固定宽或高,例:{w:1,h:0},表示宽度固定,高度自由延伸
        effect - 列表出现与消失的效果,例:fade,表示淡入淡出(暂时只实现这种)
    例如:
    I.ctrl(function(){this.treeMenu("#main .menu",[
        {dir:3,btn:"a",box:".links1",dir:3,pos:{},fix:1,effect:"fade"},
        {dir:2}]);
    });
    */
    treeMenu: function(selBox,cfgs) {
        I("I.dom",I.Mode.同步);
        var jtree={
            box/*根盒子*/: 0,
            lst/*列表*/: [
                { a/*链接*/: 0,box/*弹出盒子*/: 0,p/*父级*/: 0,lst: 0 }
            ]
        },
		de=document.documentElement,
		bd=$("body"),
		dir={
			w: function(node,isLeft) {
			    var a=node.a,
					p=a.jo.offset(),
                    pos=node.pos||{ l: 0,t: 0 },
					iw=a.jo.outerWidth(),
					bw=node.box.outerWidth(),
                    bt=a.jo.outerHeight()-node.box.outerHeight();
			    p.left+=(pos.l||0); p.top+=pos.t?(pos.t<0||pos.t>1?pos.t:bt*pos.t):0;
			    var r=de.clientWidth-p.left-iw,ok;
			    if(isLeft) {
			        ok=p.left>bw||p.left>r;
			    } else {
			        ok=!(r>bw||r>p.left);
			    }
			    p.left=ok?p.left-bw+(a.cssInt("borderLeftWidth")||0):p.left+iw-(a.cssInt("borderRightWidth")||0);
			    return p;
			},
			h: function(node,isTop) {
			    var a=node.a,
					p=a.jo.offset(),
                    pos=node.pos,
					ih=a.jo.outerHeight(),
					bh=node.box.outerHeight(),
				    bl=a.jo.outerWidth()-node.box.outerWidth();
			    p.left+=pos.l?(pos.l<0||pos.l>1?pos.l:bl*pos.l):0; p.top+=(pos.t||0);
			    var r=de.clientHeight-p.top-ih,ok;
			    if(isTop) {
			        ok=p.top>bh||p.top>r;
			    } else {
			        ok=!(r>bh||r>p.top);
			    }
			    p.top=ok?p.top-bh+(a.cssInt("borderTopWidth")||0):p.top+ih-(a.cssInt("borderBottomWidth")||0);
			    return p;
			},
			0/*不定位*/: function(node) {
			    return {};
			},
			1/*上*/: function(node) {
			    return this.h(node,1);
			},
			2/*右*/: function(node) {
			    return this.w(node);
			},
			3/*下*/: function(node) {
			    return this.h(node);
			},
			4/*左*/: function(node) {
			    return this.w(node,1);
			}
		};
        /*实例*/
        var rtn={
            init: function() {
                cfgs.push({},{},{});
                I.each(cfgs,function(i,cfg) {
                    I.extendJumpExist(cfg,{
                        btn/*选择器列表*/: "a",
                        box/*子列表容器*/: "div",
                        dir/*方向列表0不定位(poss,fixs将不生效),1上,2右,3下,4左*/: 3,
                        pos/*偏移列表l左侧t上侧*/: { l: 0,t: 0 },
                        fix/*固定宽高:0不固定,1固定宽或高*/: { w: 1,h: 0 },
                        effect/*效果*/: "fade"
                    });
                });
            },
            bind: function(lst) {
                var m=this;
                I.each(lst,function(i,o) {
                    var show=function() {
                        clearTimeout(o.tid); if(!o.show) { o.show=1; m.show(o); }
                    },hide=function() {
                        o.tid=setTimeout(function() { o.show=0; m.hide(o); },50);
                    };
                    o.a.jo.hover(show,hide);
                    o.box&&o.box.hover(show,hide);
                }); return m;
            },
            show: function(node) {
                /*邦定子节点*/
                if(!node.bind) { node.bind=1; this.bind(node.lst); }
                if(!node.box) { return; }
                /*设置子节点为显示状态*/
                node.p.cshow=1;
                node.box.show();
                /*固定宽度*/
                if(node.fix.w) { node.box.width(node.a.jo.outerWidth()); }
                /*固定高度*/
                if(node.fix.h) { node.box.height(node.a.jo.outerHeight()); }
                /*显示盒子*/
                node.box.css(dir[node.dir](node)).fadeTo(300,1,function() {
                    node.box.clearQueue();
                });
                node.a.jo.addClass("h");
                return this;
            },
            hide: function(node) {
                var m=this;
                /*子节点显示时退出*/
                if(node.cshow||node.show||!node.a) { return; }
                node.a.jo.removeClass("h");
                if(!node.box) { return; }
                node.box.fadeTo(5,0,function() {
                    node.box.clearQueue().hide().css({ opacity: 0 });
                    /*隐藏父节点*/
                    if(node.p) {
                        node.p.cshow=0;
                        m.hide(node.p);
                    }
                });
            }
        };
        rtn.init();
        /*加载子节点*/
        var loadChildren=function(jpbox,cfgs,n) {
            var cfg=cfgs[n]/*未配置*/;
            if(!cfg) { return; }
            /*获取下级列表的按钮集*/
            var jcbtn=jpbox[/[^\w]/.test(cfg.btn)?"find":"children"](cfg.btn);
            /*当按钮集为空时直接返回*/
            if(jcbtn.length==0) { jpbox.remove(); return; }
            var node/*建节点*/={ box/*列表容器*/: jpbox,lst/*节点列表*/: [] };
            /*加入子节点*/
            I.each(jcbtn,function(i,o) {
                var a=I.dom(o),jcbox=a.jo.next(cfg.box||"div");
                var nodec=loadChildren(jcbox,cfgs,n+1)||{};
                if(nodec.lst) {
                    jcbox.appendTo(bd).css({ display: "block",position: "absolute",zIndex: I.index()+80000 });/*初使化盒子*/
                    /*兼容ie6:取得弹出列表的宽度*/
                    if(I.msie&&nodec.lst.length&&!cfg.fix.w) {
                        var box=nodec.lst[0].a.jo.parent().css({ width: 99999 });
                        var u=document.createElement("u"),db=I.dom(box[0]);
                        I.extend(u.style,{ width: "0",position: "absolute",height: "1px",overflow: "hidden" })
                        box[0].appendChild(u);
                        var num=$(u).offset().left;
                        num&&box.width(Math.ceil(num));/*原因不明,要多加一倍的paddingLeft*/
                        nodec.box.width(num+db.cssInt("paddingRight")+db.cssInt("borderRight"));
                    }
                    jcbox.css({ opcity: 0 }).hide();
                }
                nodec.a=a;
                nodec.p=node;
                nodec.dir=cfg.dir;
                nodec.pos=cfg.pos;
                nodec.fix=cfg.fix;
                node.lst.push(nodec);
            });
            return node;
        };
        I(function() {
            /*加载树*/
            var jtree=loadChildren($(selBox),cfgs,0);
            /*邦定列表*/
            rtn.bind(jtree.lst);
        }); return rtn;
    }
});