// JavaScript Document


$(function () {
    $('.index-banner').bannerSlider();

    //屏蔽鼠标右键
    $(document).bind("contextmenu", function (e) {
        return false;
    }); 
})
//banner 的js
; (function ($) {
    $.fn.bannerSlider = function (options) {

        var $this = $(this);
        var defaults = {
            auto: true,
            time: 6000
        }
        var opts = $.extend(defaults, options),
			$item = $this.find('div.banner-item'),
			$select,
			prevIndex = currIndex = 0,
			sliderTimer = null,
			$top = $('.index-top'),
			scrollDir = false,
			_init = function () {
			    if ($item.length == 0) {
			        return false;
			    } else if ($item.length > 1) {
			        selectHtml()
			        if (opts.auto) {
			            sliderTimer = setInterval(sliderIndex, opts.time);
			        }
			    }
			    bannerHeight();
			    $top.css({
			        position: 'fixed',
			        width: '100%',
			        background: '#fff',
			        top: 0,
			        left: 0
			    });
			}
        function selectHtml() {
            $select = $('<div class="banner-select" />').appendTo($this);
            var html = '<ul class="clearfix">';
            for (var i = 0; i < $item.length; i++) {
                if ($item.eq(i).is('.curr')) {
                    html += '<li class="curr"></li>';
                } else {
                    html += '<li></li>';
                }
            }
            html += '</ul>';
            $select.html(html);
            $select.find('li').bind('click', function () {
                clearTimer();
                currIndex = $(this).index();
                swicthTo();
            })
        }
        function bannerHeight() {
            var h = $(window).height();
            if (h - 120 <= 550) {
                $item.height(550);
                position(50);
                sliderScroll(false);
            } else {
                $item.height(h - 120);
                position((h - 120 - 450) / 2);
                sliderScroll(true);
            }
        }
        function sliderScroll(b) {
            if (b) {
                var h = $(window).height();
                $(window).bind('mousewheel', function (event) {
                    if (scrollDir) {
                        return false;
                    }
                    var s = document.documentElement.scrollTop || document.body.scrollTop;
                    if (event.deltaY > 0 && h > 620) {
                        if (s <= h - 80 && s > 0) {
                            scrollDir = true;
                            $("body,html").animate({
                                scrollTop: 0
                            },
							1000,
							function () {
							    scrollDir = false
							})
                        }
                    } else {
                        console.info(document.documentElement.scrollTop)
                        if (event.deltaY < 0 && h > 620) {
                            if (s < h - 80 && s >= 0) {
                                scrollDir = true;
                                $("body,html").animate({
                                    scrollTop: h - 80
                                },
								1000,
								function () {
								    scrollDir = false
								})
                            }
                        }
                    }

                });
            } else {
                $(window).unbind('mousewheel');
            }
        }
        function position(t) {
            $item.each(function (index) {
                $(this).find('div.banner-position').css('top', t);
            })
        }
        function Throttle(fn, delay, mustRunDelay) {
            var timer = null;
            var t_start;
            return function () {
                var context = this, args = arguments, t_curr = +new Date();
                clearTimeout(timer);
                if (!t_start) {
                    t_start = t_curr;
                }
                if (t_curr - t_start >= mustRunDelay) {
                    fn.apply(context, args);
                    t_start = t_curr;
                }
                else {
                    timer = setTimeout(function () {
                        fn.apply(context, args);
                    }, delay);
                }
            };
        }
        function clearTimer() {
            clearInterval(sliderTimer);
            sliderTimer = null;
        }
        function sliderIndex() {
            if (currIndex >= $item.length - 1) {
                currIndex = 0;
            } else {
                currIndex++;
            }
            swicthTo();
        }

        function swicthTo() {
            $select.find('li').eq(currIndex).addClass('curr').siblings().removeClass('curr');
            $item.eq(currIndex).addClass('curr').siblings().removeClass('curr');
            prevIndex = currIndex;
        }
        _init();
        $(window).resize(function () { Throttle(bannerHeight(), 10, 5) });
    }
})(jQuery)

$(function () {
    $('#J-kf').kf();
});
//tab 选项卡
(function ($) {

    $.fn.kf = function () {
        var $this = $(this),
			$button = $this.find('.kf-button>a'),
			$wrap = $this.find('.kf-wrap'),
			$colse = $this.find('.kf-colse>a'),
			steep = 300;
        $button.bind('click', function() {
            $button.parent().animate({
                opacity: 0
            }, steep, function() {
                $wrap.show().animate({ opacity: 1 }, steep);
            });
        });
        $colse.bind('click', function () {
            $wrap.animate({
                opacity: 0
            }, steep, function() {
                $button.parent().animate({ opacity: 1 }, steep).show();
            }).hide();
        })
    
        var Location = function () {
            if ($(window).width() < 1400) {
                $this.addClass('kf-online-right');
            } else {
                $this.removeClass('kf-online-right');
            }
        }
        Location();
        $(window).resize(function (e) {
            Location();
        });
    };

    $.fn.cityStarTab = function (option) {
        var defaults = {
            hdClass: "cityStarTab-hd",
            bdClass: "cityStarTab-bd",
            hoverClass: "oncurr",
            bindEvent: "click",
            Index: 0
        }
        var handle = function (objElem, currIndex, className) {
            $.each(objElem, function (index, elem) {
                if (index == currIndex) {
                    if (className) {
                        $(elem).addClass(className);
                    } else {
                        $(elem).css("display", "block");
                    }
                } else {
                    if (className) {
                        $(elem).removeClass(className);
                    } else {
                        $(elem).css("display", "none");
                    }
                }
            });
        }
        var opts = $.extend(defaults, option);
        var $hdItems = $(this).find("." + opts.hdClass);
        var $bdItems = this.find("." + opts.bdClass);
        $hdItems.eq(0).addClass(opts.hoverClass);
        $bdItems.eq(0).css("display", "block");
        if ($hdItems.length != $bdItems.length) return false;
        $hdItems.each(function () {
            $(this).bind(opts.bindEvent, function () {

                opts.Index = $hdItems.index(this);
                handle($hdItems, opts.Index, opts.hoverClass);
                handle($bdItems, opts.Index);
            });
        });

    };
})(jQuery)

//头部导航
; (function ($) {
    $.fn.CSMenu = function (options) {
        var defaults = {
            maxWidth: 980,
            align: "left",
            isFloat: false,
            subNavClass: "nav-sub",
            hoverClass: "onHover",
            navWrapId: "J_navWrap",
            arrowW: 38,
            zIndex: 30,
            pushMenuDownBy: 36
        }
        var opts = $.extend(defaults, options);
        var $navWrap = $("#" + opts.navWrapId), $this = this, $child_lis, $subNav, Index, isFirst = true;
        function bindData(navSubW, elem, elemW, posTop, posLeft, $navSub) {
            var arrowLeft = null;
            if (elemW > navSubW) { navSubW = elemW };
            if (navSubW > opts.maxWidth) { navSubW = opts.maxWidth; }
            var floatNavLeft = null;
            var pos_C_L = posLeft + elemW / 2;
            var pos_C_R = opts.maxWidth - (posLeft + elemW / 2);
            var pos_L_R = opts.maxWidth - posLeft;
            if (opts.isFloat) {
                if ($navSub.find("li").length == 1) {
                    $navSub.addClass("nav-subSingle");
                }
            }
            if (navSubW > opts.maxWidth) {
                arrowLeft = posLeft + (elemW - opts.arrowW) / 2;
                floatNavLeft = 0;
                $navSub.addClass("center");
            } else {
                if (opts.align == "center") {
                    if (pos_C_L < navSubW / 2) {
                        //如果li的中心到达左岸的距离小于"子导航"的一半
                        if (pos_L_R >= navSubW) {//如果li的左边到右岸的距离 大于navSubW的时候，左对齐
                            arrowLeft = (elemW - opts.arrowW) / 2;
                            floatNavLeft = posLeft;
                            $navSub.addClass("left");
                        } else if (pos_L_R < navSubW) {//如果li的左边到右岸的距离 大于navSubW的时候，左岸对其
                            arrowLeft = posLeft + (elemW - opts.arrowW) / 2;
                            floatNavLeft = 0;
                            $navSub.addClass("center");
                        }
                    } else if (pos_C_L >= navSubW / 2) {
                        //如果li的中心到达左岸的距离大于等于"子导航"的一半
                        if (pos_C_R >= navSubW / 2) {
                            //如果li的中心到右岸的距离 大于navSubW一半的时候，剧中
                            arrowLeft = (navSubW - opts.arrowW) / 2;
                            floatNavLeft = posLeft - (navSubW - elemW) / 2;
                            $navSub.addClass("center");
                        } else if (pos_C_R < navSubW / 2) {
                            //如果li的中心到右岸的距离 小于navSubW一半的时候，直接右对齐
                            if (pos_C_L < navSubW) {
                                arrowLeft = pos_C_L;
                                floatNavLeft = 0;
                                $navSub.addClass("center");

                            } else {
                                arrowLeft = navSubW - (elemW + opts.arrowW) / 2;
                                floatNavLeft = posLeft + elemW - navSubW;
                                $navSub.addClass("right");
                            }
                        }
                    }
                } else if (opts.align == "left") {
                    if (navSubW <= elemW) {
                        arrowLeft = navSubW - (elemW + opts.arrowW) / 2;
                        floatNavLeft = posLeft;
                        $navSub.addClass("center");
                    } else {
                        if (pos_L_R < navSubW) {//右对齐
                            arrowLeft = navSubW - (elemW + opts.arrowW) / 2;
                            floatNavLeft = posLeft + elemW - navSubW;
                            $navSub.addClass("right");
                        } else if (pos_L_R >= navSubW) {//左对齐
                            arrowLeft = (elemW - opts.arrowW) / 2;
                            floatNavLeft = posLeft;
                            $navSub.addClass("left");
                        }
                    }
                }
            }
            elem.data({ "posLeft": floatNavLeft, "arrowLeft": arrowLeft, "floatNavW": navSubW });


        }

        var floatMenuObj = (function () {
            var $floatMenuBox = $("<div class='floatMenuWrap' id='J_floatMenu' style='display:none;position:absolute;'></div>");
            $floatMenuBox.css({ zIndex: opts.zIndex + 1, top: opts.pushMenuDownBy })
            var $floatArrow = $("<div class='floatArrow' style='position:absoulte'></div>");
            var $floaContextBox = $("<div class='floatContentBox'></div>");
            $floatMenuBox.css("top", opts.pushMenuDownBy);
            $floatMenuBox.append($floatArrow).append($floaContextBox);
            $navWrap.append($floatMenuBox);
            return { "self": $floatMenuBox, "Arrow": $floatArrow, "contentBox": $floaContextBox };
        })();



        var init = function () {
            $navWrap.css("zIndex", opts.zIndex);
            $child_lis = $this.children("li");
            $child_lis.last().addClass("last")
            $.each($child_lis, function (index, elem) {
                var $elem = $(elem);
                var $navSub = $elem.find("." + opts.subNavClass).eq(0);
                var navSubW = $navSub.width();
                var posTop = $elem.position().top;
                var posLeft = $elem.position().left;
                var elemW = $elem.outerWidth();
                bindData(navSubW, $elem, elemW, posTop, posLeft, $navSub);
                if ($elem.find("li").length > 0) {
                    $elem.find("li").last().addClass("last");
                    $elem.bind("mouseenter", function (event) {
                        Index = $child_lis.index(this);
                        var relateTarget = event.relatedTarget;

                        //if($(relateTarget).closest(floatMenuObj.self).length > 0){return false}	

                        floatMenuObj.self.width($(this).data("floatNavW"));
                        $(this).addClass(opts.hoverClass);
                        floatMenuObj.contentBox.empty().append($navSub.clone());
                        floatMenuObj.Arrow.css({ left: $(this).data("arrowLeft") });
                        floatMenuObj.self.stop(true, true).css("left", $(this).data("posLeft")).fadeIn();
                    }).bind("mouseleave", function (event) {
                        var relateTarget = event.relatedTarget;
                        if ($(relateTarget).closest(floatMenuObj.self).length > 0) {
                            return;
                        } else {

                            $(this).removeClass(opts.hoverClass);
                            floatMenuObj.self.fadeOut();

                        }
                    });

                } else {
                    $elem.bind("mouseover", function (event) {
                        floatMenuObj.self.stop(true, true).fadeOut();

                    });
                }

            });
        };
        init();

        floatMenuObj.self.bind("mouseleave", function (event) {
            var relateTarget = event.relatedTarget;
            if ($(relateTarget).closest($child_lis.eq(Index)).length > 0) {
                return;
            } else {
                $child_lis.eq(Index).removeClass(opts.hoverClass)
                floatMenuObj.self.stop(true, true).fadeOut()

                /*  var relateTarget=relateTarget.tagName=="LI" ? relateTarget : relateTarget.parentNode;
                        $child_lis.eq(Index).removeClass(opts.hoverClass);
                        Index=$child_lis.index(relateTarget);
                        $navSub=$child_lis.eq(Index).find("."+opts.subNavClass).eq(0);
                        floatMenuObj.contentBox.empty().append($navSub.clone());										    								                       floatMenuObj.Arrow.css({left:$child_lis.eq(Index).data("arrowLeft")});
                        floatMenuObj.self.stop(true,true).css({left:$child_lis.eq(Index).data("posLeft")}).fadeIn();	*/
            }
        });

    }
})(jQuery)

//侧栏导航
; (function ($) {
    $.fn.sideBarNav = function (options) {
        var defaults = {
            subHoverClass: "onHover",
            subNavClass: "sidebar-subnav"
        }
        var opts = $.extend(defaults, options);
        var mouseover_timerArr = [], mouseout_timerArr = [];
        var $children_lis = this.children("li");
        $children_lis.last().addClass("last");
        $.each($children_lis, function (index, elem) {
            $(elem).find("." + opts.subNavClass).children("li").last().addClass("last");
            if ($(elem).find(".subOncurr").length > 0) {
                $(elem).addClass("oncurr");
            }
            if ($(elem).find("li").length <= 0) {
                $(elem).addClass("sidebar-notSub");
            }
            if ($(elem).find("li").length > 0 && !$(elem).hasClass("oncurr")) {
                $(elem).hover(function () {
                    var $this = $(this);
                    $this.addClass(opts.subHoverClass);
                    clearTimeout(mouseout_timerArr[index]);
                    mouseover_timerArr[index] = setTimeout(function () { $this.find('.' + opts.subNavClass).eq(0).slideDown(150); }, 155);
                }, function () {
                    var $this = $(this);
                    $this.removeClass(opts.subHoverClass);
                    clearTimeout(mouseover_timerArr[index]);
                    mouseout_timerArr[index] = setTimeout(function () { $this.find('.' + opts.subNavClass).eq(0).slideUp(150); }, 155)
                });
            }
        });
    }
})(jQuery)

//没有伸缩在线客服
; (function ($) {
    $.fn.kfonline1 = function (options) {
        var $this = this;
        var defaults = {
            siteWidth: 980,
            distance: 20,
            selfWidth: 126
        }
        var opts = $.extend(defaults, options);
        var windowResize = {
            Timer: null,
            processing: function (screenWidth) {
                $this.css({ left: screenWidth - opts.selfWidth, "margin-left": 0 })
            },
            start: function (screenWidth) {
                clearTimeout(this.Timer);
                if (screenWidth <= opts.siteWidth + (opts.distance + opts.selfWidth) * 2) {

                    this.Timer = setTimeout(function () { windowResize.processing(screenWidth) }, 200)
                } else {
                    $this.css({ left: "50%", "margin-left": opts.siteWidth / 2 + opts.distance })
                }
            }
        }
        $(window).bind("resize", function () {
            var screenWidth = $(window).width();
            windowResize.start(screenWidth);
        }).trigger("resize");

    }
})(jQuery)


//有伸缩在线客服
; (function ($) {
    $.fn.kfonline2 = function (options) {
        var $this = this;
        var defaults = {
            bdClass: "kf-online2-bd",
            closeBtnId: "J_online2-closeBtn"
        }
        var opts = $.extend(defaults, options);
        var optbtnFunc = function () {
            if ($("." + opts.bdClass).is(":visible")) {
                $("." + opts.bdClass).hide();
                $this.css("cursor", "pointer");
            } else {
                $("." + opts.bdClass).show();
                $this.unbind("click").css("cursor", "default");
            }
        }
        this.bind("click", optbtnFunc);
        $("#" + opts.closeBtnId).bind("click", function () {
            $("." + opts.bdClass).hide();
            $this.bind("click", optbtnFunc);
            $this.css("cursor", "pointer");
            return false;
        });
    }
})(jQuery)



//相册的js
; (function ($) {
    $.fn.staffGallery = function (option) {

        var defaultsId = {
            bigPrevId: "J_staff-bigPrev",
            bigNextId: "J_staff-bigNext",
            bigPicTitId: "J_staff-bigPicTit",
            bigPicTxtId: "J_staff-bigPicTxt",
            smallListWrapId: "J_staff-smallListWrap",
            containerId: "J_staff-conBox"


        }
        $.fn.staffGallery.defaults = {
            smallPrevId: "J_staff-smallPrev",
            smallNextId: "J_staff-smallNext",
            smallListInnerId: "J_staff-smallListInner",
            smallDisPrevClass: "staff-dis-smallPrev",
            smallDisNextClass: "staff-dis-smallNext",
            smallDataClass: "staff-smallItem",
            smallWrapId: "J_staff-smallWrap",
            bigPicTitClass: "staff-bigPicTit",
            arrowId: "J_staff-arrow",
            bigPicWrapId: "J_staff-bigWrap",
            bigPrevClass: "staff-bigPrev",
            bigNextClass: "staff-bigNext",
            bigPicWrapW: 666,
            bigPicWrapH: 483,
            fixLen: 4,//第几张固定
            viewLen: 6,//滚动可见的长度
            arrowH: 35,
            scroW: 103,
            dir: "left",
            isTitShow: true,
            isBigBtnShow: true //是否显示标题													
        }
        var opts = $.extend(defaultsId, $.fn.staffGallery.defaults, option);
        var Index = 0,
               $smallPrev = $("#" + opts.smallPrevId),
               $smallNext = $("#" + opts.smallNextId),
               $container = $("#" + opts.containerId),
               $smallListInner = $("#" + opts.smallListInnerId),
               $arrow = $("#" + opts.arrowId),
               $bigPicWrap = $("#" + opts.bigPicWrapId);
        $smallListWrap = $("#" + opts.smallListWrapId);
        $smallWrap = $("#" + opts.smallWrapId)

        var nextDistance = opts.viewLen - opts.fixLen,
$smallDataItems = $smallListInner.find("." + opts.smallDataClass);
        totalLen = $smallDataItems.length;
        var bigSrc,
            bigTit,
                $bigPicTit,
                $bigNext,
                $bigPrev,
                $bigPicTit,
                $bigPicTxt,
  $this = this;



        //获取图片信息和操作图片函数
        var changeBigImg = function (currIndex) {
            bigSrc = $smallDataItems.eq(currIndex).attr("href");
            bigTit = $smallDataItems.eq(currIndex).attr("data-title");
            $this.stop(false, true).fadeOut(200, function () {
                $this.attr("src", bigSrc).fadeIn()
            });
            if (opts.isTitShow) {
                $bigPicTit.animate({ top: opts.bigPicWrapH }, 200, function () {
                    if ($.trim(bigTit) != "") {
                        $bigPicTxt.text(bigTit);
                        $bigPicTit.show();
                    } else {
                        $bigPicTit.hide();
                    }
                    $bigPicTit.stop(false, true).animate({ top: opts.bigPicWrapH - opts.arrowH })
                });


            }
        };


        //初始化
        var Init = function () {
            if (opts.dir == "left") {
                $smallWrap.css({ width: opts.bigPicWrapW, overflow: "hidden" });
            }
            $this.parent().css({ width: opts.bigPicWrapW - 2, height: opts.bigPicWrapH - 2, overflow: "hidden" })
            if (totalLen == 1) {
                $smallWrap.hide();

            }
            $bigPicWrap.css({ width: opts.bigPicWrapW, height: opts.bigPicWrapH, overflow: "hidden", position: "relative" })
            bigSrc = $smallDataItems.eq(Index).attr("href");
            bigTit = $smallDataItems.eq(Index).attr("data-title");
            $this.attr("src", bigSrc);
            if (opts.isTitShow) {//如果显示标题的话
                var $bigPicTxtDom = $('<div class="' + opts.bigPicTitClass + '" id="' + opts.bigPicTitId + '"><span></span><b id="' + opts.bigPicTxtId + '"></b></div>')
                $bigPicTxtDom.appendTo($bigPicWrap);
                $bigPicTit = $("#" + opts.bigPicTitId);
                $bigPicTxt = $("#" + opts.bigPicTxtId);
                $bigPicTit.css({ top: opts.bigPicWrapH - opts.arrowH }).hide();
                changeBigImg(Index)
            }
            if (opts.isBigBtnShow) {//如果显示大图按钮的话
                var $bigPrevBtn = $("<a href='#' class='" + opts.bigPrevClass + "' id='" + opts.bigPrevId + "'></a>");
                var $bigNextBtn = $("<a href='#' class='" + opts.bigNextClass + "' id='" + opts.bigNextId + "'></a>");
                $bigPrevBtn.appendTo($bigPicWrap);
                $bigNextBtn.appendTo($bigPicWrap);
            }
            $smallPrev.eq(Index).addClass(opts.smallDisPrevClass);
            if (totalLen <= opts.viewLen) {

            } else {
                if (opts.dir == "left") {
                    $smallListInner.width(totalLen * opts.scroW);
                } else {
                    $smallListInner.height(totalLen * opts.scroW)
                }
            }
            $smallListInner.css({ "position": "absolute", "overflow": "hidden" });
            if (opts.dir == "left") {
                $smallListWrap.css({ "width": opts.viewLen * opts.scroW, "position": "relative", "overflow": "hidden" });
            } else {
                $smallListWrap.css({ "height": opts.viewLen * opts.scroW, "position": "relative", "overflow": "hidden" });
            }



        };
        Init();

        //处理index 范围的函数
        var slideIndexChange = function (currIndex, Dir) {
            if (Dir == "left") {
                if (totalLen < opts.viewLen) {
                    $arrow.stop(false, true).animate({ left: currIndex * opts.scroW }, 200);
                    $smallListInner.animate({ left: 0 * opts.scroW })
                } else {
                    if (currIndex >= 0 && currIndex <= opts.fixLen - 1) {//0-3
                        $arrow.stop(false, true).animate({ left: currIndex * opts.scroW }, 200);
                        $smallListInner.animate({ left: 0 * opts.scroW })
                    } else if (currIndex > (opts.fixLen - 1) && currIndex < (totalLen - nextDistance)) {//4

                        $arrow.stop(false, true).animate({ left: (opts.fixLen - 1) * opts.scroW }, 200);
                        $smallListInner.animate({ left: -(currIndex - opts.fixLen + 1) * opts.scroW })
                    } else if (currIndex >= (totalLen - nextDistance)) {//5-7  

                        $arrow.stop(false, true).animate({ left: (opts.viewLen - (totalLen - currIndex)) * opts.scroW }, 200);
                        $smallListInner.animate({ left: -(totalLen - opts.viewLen) * opts.scroW })
                    }
                }
            } else if (Dir == "top") {
                if (totalLen < opts.viewLen) {
                    $arrow.stop(false, true).animate({ top: currIndex * opts.scroW }, 200);
                    $smallListInner.animate({ left: 0 * opts.scroW })
                } else {
                    if (currIndex >= 0 && currIndex <= opts.fixLen - 1) {//0-3
                        $arrow.stop(false, true).animate({ top: currIndex * opts.scroW }, 200);
                        $smallListInner.animate({ top: 0 * opts.scroW })
                    } else if (currIndex > (opts.fixLen - 1) && currIndex < (totalLen - nextDistance)) {//4
                        $arrow.stop(false, true).animate({ top: (opts.fixLen - 1) * opts.scroW }, 200);
                        $smallListInner.animate({ top: -(currIndex - opts.fixLen + 1) * opts.scroW })
                    } else if (currIndex >= (totalLen - nextDistance)) {//5-7   
                        $arrow.stop(false, true).animate({ top: (opts.viewLen - (totalLen - currIndex)) * opts.scroW }, 200);
                        $smallListInner.animate({ top: -(totalLen - opts.viewLen) * opts.scroW })
                    }
                }
            }
        }

        //单击prev按钮的事件函数
        var prevBtnHander = function (currIndex) {
            if (currIndex != totalLen - 1) {
                $smallNext.removeClass(opts.smallDisNextClass);
            }
            if (currIndex == 0) {
                $smallPrev.addClass(opts.smallDisPrevClass);
            }
            slideIndexChange(Index, opts.dir);

            changeBigImg(Index)
        };
        //单击next按钮的事件函数
        var NextBtnHander = function (currIndex) {
            if (Index != 0) {
                $smallPrev.removeClass(opts.smallDisPrevClass);
            }
            if (Index == (totalLen - 1)) {
                $smallNext.addClass(opts.smallDisNextClass)
            }

            if (Index <= opts.fixLen - 1) {
                if (opts.dir == "left") {
                    $arrow.stop(false, true).animate({ left: "+=" + opts.scroW }, 200)
                } else {
                    $arrow.stop(false, true).animate({ top: "+=" + opts.scroW }, 200)
                }
            } else {
                if ((totalLen - Index - nextDistance) <= 0) {
                    if (opts.dir == "left") {
                        $arrow.stop(false, true).animate({ left: "+=" + opts.scroW }, 200);
                    } else {
                        $arrow.stop(false, true).animate({ top: "+=" + opts.scroW }, 200);
                    }
                } else {
                    if (opts.dir == "left") {
                        $smallListInner.animate({ left: -(Index - opts.fixLen + 1) * opts.scroW })
                    } else {
                        $smallListInner.animate({ top: -(Index - opts.fixLen + 1) * opts.scroW })
                    }

                }
            }
            changeBigImg(Index)

        };


        //单击小图的左按钮	
        $smallPrev.bind("click", function () {
            if (Index == 0) { return false }
            Index--;
            prevBtnHander(Index)
            return false
        });


        //单击小图的右按钮	
        $smallNext.bind("click", function () {
            if (Index == (totalLen - 1)) { return false }
            Index++;
            NextBtnHander(Index);
            return false;
        });
        $smallDataItems.each(function () {
            $(this).bind("click", function () {
                var lastIndex = Index
                Index = $smallDataItems.index(this);
                if (Index == 0) { $smallPrev.addClass(opts.smallDisPrevClass); }
                if (Index == totalLen - 1) { $smallNext.addClass(opts.smallDisNextClass) }
                if (Index != 0) { $smallPrev.removeClass(opts.smallDisPrevClass); }
                if (Index != totalLen - 1) { $smallNext.removeClass(opts.smallDisNextClass) }
                var distanceIndex = Math.abs(lastIndex - Index);
                changeBigImg(Index);
                slideIndexChange(Index, opts.dir);
                return false;
            })
        })

        if (opts.isBigBtnShow && totalLen != 1) {
            $bigNext = $("#" + opts.bigNextId);
            var bigNextH = $bigNext.height();
            $bigPrev = $("#" + opts.bigPrevId);
            var bigPrevH = $bigPrev.height();
            $bigNext.css("top", (opts.bigPicWrapH - bigNextH) / 2);
            $bigPrev.css("top", (opts.bigPicWrapH - bigPrevH) / 2)
            //单击大图的右按钮
            $bigNext.bind("click", function () {
                Index++;
                if (Index != 0) { $bigPrev.show(); }
                if (Index == totalLen - 1) { $(this).hide() }
                NextBtnHander(Index)
                return false;
            })
            //单击大图的左按钮
            $bigPrev.bind("click", function () {

                Index--;
                if (Index != totalLen - 1) { $bigNext.show(); }
                if (Index == 0) { $(this).hide() }
                prevBtnHander(Index);
                return false
            });
            //大图 $bigWrap hover的时候的效果
            $bigPicWrap.bind("mouseover", function (event) {
                var relateElem = event.relatedTarget;
                if ($(relateElem).closest($bigPicWrap).length > 0) {
                    return;
                } else {
                    if (Index == totalLen - 1) {
                        $bigPrev.stop(false, true).fadeIn();
                    } else if (Index == 0) {
                        $bigNext.stop(false, true).fadeIn()
                    } else {
                        $bigPrev.stop(false, true).fadeIn();
                        $bigNext.stop(false, true).fadeIn()
                    }
                }
            }).bind("mouseout", function (event) {
                var relateElem = event.relatedTarget;
                if ($(relateElem).closest($bigPicWrap).length > 0) {
                    return;
                } else {
                    $bigPrev.stop(false, true).fadeOut();

                    $bigNext.stop(false, true).fadeOut()
                }

            });
        }

    }
})(jQuery)
//广告
; (function ($) {
    $.fn.CSadvert = function (options) {
        var opts = $.extend({}, $.fn.CSadvert.defaults, options);
        return this.each(function () {
            var $this = $(this),
                isStop = false,
                Index = 0,
                $parent2 = $this.parent().parent().eq(0),
                $parent1 = $this.parent(),
                adWidth,
                adHeight,
                Timer = null,
                $pagination,
                $pagination_lis,
                isIE6 = !-[1, ] && !window.XMLHttpRequest,
                $slider_lis = $this.children("li"),
                len = $slider_lis.length,
                $pagination;


            adWidth = $parent2.width()
            adHeight = $parent2.height()
            var paginationInit = function () {
                var strLis = "";
                $pagination = $('<ul></ul>');
                $pagination.addClass("advert-numlist").css({ "zIndex": opts.zIndex + 1, "position": "absolute" })
                for (var i = 0; i < len; i++) {
                    strLis += "<li><span>" + (i + 1) + "</span></li>";
                }
                $pagination.append(strLis);
                $pagination.appendTo($parent1)
                $pagination_lis = $pagination.find("li");
                $pagination_lis.eq(Index).addClass("oncurr");
                $pagination_lis.each(function () {
                    $(this).bind("mouseover", paginationEvt);
                    $(this).bind("mouseover", thisMouseover).bind("mouseout", thisMouseout);
                })
            };
            function paginationEvt() {
                var prevIndex = Index;
                isStop = true;
                clearTimeout(Timer);
                Index = $pagination_lis.index(this);
                beginStart()
            }
            function thisMouseover(event) {
                clearTimeout(Timer);
                var relateElem = event.relatedTarget;
                if ($(relateElem).closest($parent1).length > 0) {
                    return;
                } else {
                    isStop = true;
                }
            };

            function thisMouseout(event) {
                var relateElem = event.relatedTarget;
                if ($(relateElem).closest($parent1).length > 0) {
                    return;
                } else {
                    isStop = false;
                    beginStart()
                }
            };
            function beginStart() {
                if (Index < 0) {
                    Index = len - 1;
                } else if (Index == len) {
                    Index = 0
                }
                scrolling();
            };
            function scrolling() {

                $slider_lis.css("zIndex", opts.zIndex - 1).stop(true).animate({ opacity: 0 }).eq(Index).css("zIndex", opts.zIndex).stop(true).animate({ opacity: 1 });
                if (opts.pagination) {
                    $pagination_lis.eq(Index).addClass("oncurr").siblings().removeClass("oncurr")
                }
                if (isIE6) {
                    $slider_lis.css("display", "none").eq(Index).css("display", "block")
                }
                if (!isStop) {
                    Timer = setTimeout(function () { Index++; beginStart(); }, 3000)
                }
            };
            var Init = function () {
                $parent1.css({ position: "relative", width: adWidth, height: adHeight, "overflow": "hidden" });
                $slider_lis.css({ position: "absolute", opacity: 0, zIndex: opts.zIndex - 1, left: "0", top: "0" }).eq(Index).css("zIndex", opts.zIndex).animate({ "opacity": 1 });
                if (isIE6) {
                    $slider_lis.css("display", "none").eq(Index).css("display", "block")
                }

                $this.bind("mouseover", thisMouseover);
                $this.bind("mouseout", thisMouseout);
                if (opts.pagination) {
                    paginationInit();
                    $pagination.bind("mouseover", thisMouseover);
                    $pagination.bind("mouseout", thisMouseout);
                }


                beginStart()
            }
            Init();

        })
    }
    $.fn.CSadvert.defaults = {
        Index: 10,
        pagination: true
    }
})(jQuery)
//无缝滚动js
; (function ($) {
    $.fn.CSContinueScroll = function (options) {
        var opts = $.extend({}, $.fn.CSContinueScroll.defaults, options);
        return this.each(function () {
            var Timer = null, $listElem, $this = $(this), listElemW;
            $listElem = $this.find("." + opts.listClass).eq(0);
            listElemW = $listElem.width();
            $listElem_clone = $listElem.html();
            $listElem.append($listElem_clone);
            function Marquee() {
                if ($this.scrollLeft() >= listElemW) {
                    $this.scrollLeft(0);

                } else {
                    $this.scrollLeft($this.scrollLeft() + opts.step);
                }
            }
            Timer = setInterval(function () { Marquee() }, 15);
            $listElem.hover(function () {
                clearInterval(Timer)
            }, function () {
                Timer = setInterval(function () { Marquee() }, 15);
            })
        })

    }
    $.fn.CSContinueScroll.defaults = {
        listClass: "hsite-listType1",
        step: 1
    }
})(jQuery);

function searchFunc(inputId, labelTipId) {

    var $searchLabel = $("#" + labelTipId);
    var $searchInput = $("#" + inputId);

    if ($.trim(($searchInput).val()) == "") {
        $searchLabel.show();

    } else {
        $searchLabel.hide();
    }


    $searchLabel.bind("click", function () {
        if ($.trim($searchLabel.text()) == "" || $.trim($searchLabel.text()) == "请输入APP名称") {
            $(this).hide();
            $searchInput.focus();
        } else {
            $searchInput.val($.trim($searchLabel.text()));
            $(this).hide();
            //$searchInput.get(0).focus();
            var tObj = $searchInput.get(0);
            var sPos = tObj.value.length;
            setCaretPosition(tObj, sPos);
        }
        

    });/*点击时把txt转换成focus状态*/
    function setCaretPosition(tObj, sPos){
        	    if(tObj.setSelectionRange){
                    setTimeout(function(){
                            tObj.setSelectionRange(sPos, sPos);
                            tObj.focus();
                        }, 0);
                }else if(tObj.createTextRange){
                        var rng = tObj.createTextRange();
                	        rng.move('character', sPos);
                        rng.select();
                  }
      	}
}
$(function () {

    $('.proshow-list li').bind('mouseenter', function () {
        $(this).siblings().removeClass('Hover')
        $(this).addClass('Hover')

    }).bind('mouseleave', function () {
        $(this).removeClass('Hover')
    })


})
$(function () {

    $('.go-top').bind('click', function () {

        $('html,body').animate({ scrollTop: 0 });

    })



})
; (function ($) {
    $.fn.proScroll = function (options) {

        var opts = $.extend({}, $.fn.proScroll.defaults, options);
        return this.each(function () {
            var $this = $(this), len, $children_lis, li_w, isFull = true, $prev, $next, $thisParent, thisW, Timer;
            var each_opts = $.meta ? $.extend({}, opts, $this.data()) : opts;
            var init = function () {
                $thisParent = $this.parent();
                $children_lis = $this.children("li");
                li_w = $children_lis.eq(0).outerWidth(true);
                len = $children_lis.length;
                if (len <= each_opts.len) {
                    isFull = false
                    len = each_opts.len;
                    return;
                }
                thisW = len * li_w;
                $this.css("width", thisW)
                $thisParent.css({ width: thisW * 2, left: -thisW });

                var thisClone = $this.clone(true);
                thisClone.appendTo($thisParent);
                $prev = $('<a href="#" class="ui-scro-prev1" style="display:block"></a>');
                $next = $('<a href="#" class="ui-scro-next1" style="display:block"></a>');
                $prev.appendTo($thisParent.parent());
                $next.appendTo($thisParent.parent());
                $prev.bind("click", function () {
                    if ($this.is(":animated")) { return }
                    $thisParent.stop(false, true).animate({ left: "+=" + li_w }, each_opts.animTime, function () {
                        if (Math.abs(parseInt($thisParent.css("left"))) == 0) {
                            $thisParent.css("left", -thisW)
                        }
                    })
                    return false
                });
                $next.bind("click", function () {
                    if ($this.is(":animated")) { return }
                    $thisParent.stop(false, true).animate({ left: "-=" + li_w }, each_opts.animTime, function () {
                        if (Math.abs(parseInt($thisParent.css("left"))) == 2 * thisW - (each_opts.len * li_w)) {
                            $thisParent.css("left", -(len - each_opts.len) * li_w)
                        }
                    })
                    return false
                });

            }


            init();
        });
        $.fn.proScroll.defaults = {
            len: 3,
            animTime: 300
        };

    }


})(jQuery);
$(function () { $(".h-scroll-list").proScroll({ len: 2, animTime: 300 }); })
; (function ($) {
    $.fn.jMarquee = function (o) {
        if (this.length == 0) return this;

        if (this.length > 1) {
            this.each(function () { $(this).jMarquee(o) });
            return this;
        }
        o = $.extend({
        }, o || {});
        var $this = $(this), $ul = $this.find('ul'), li_height = 24;
        function nextbt() {
            $ul.stop(true).animate({ marginTop: -li_height }, 800, function () {
                $ul.css('marginTop', 0).find('li:first').insertAfter($ul.find('li:last'));
            })
        }

        $this.hover(function() {
            clearInterval(banner_T);
        }, function() {
            banner_T = setInterval(nextbt, 3000);
        }).triggerHandler('mouseleave');
    };

})(jQuery);