//$(function() {
//    //@Mr.Think***变量
//    var $cur = 1; //初始化显示的版面
//    var $i = 5; //每版显示数
//    var $len = $('.showbox>ul>li').length; //计算列表总长度(个数)
//    var $pages = Math.ceil($len / $i); //计算展示版面数量
//    var $w = $('.ibox').width(); //取得展示区外围宽度
//    var $showbox = $('.showbox');
//    var $num = $('span.num li')
//    var $pre = $('span.pre')
//    var $next = $('span.next');
//    var $autoFun;
//    //@Mr.Think***调用自动滚动
//    autoSlide();
//    //@Mr.Think***向前滚动
//    $pre.click(function() {
//        if (!$showbox.is(':animated')) {  //判断展示区是否动画
//            if ($cur == 1) {   //在第一个版面时,再向前滚动到最后一个版面
//                $showbox.animate({
//                    left: '-=' + $w * ($pages - 1)
//                }, 500); //改变left值,切换显示版面,500(ms)为滚动时间,下同
//                $cur = $pages; //初始化版面为最后一个版面
//            }
//            else {
//                $showbox.animate({
//                    left: '+=' + $w
//                }, 500); //改变left值,切换显示版面
//                $cur--; //版面累减
//            }
//            $num.eq($cur - 1).addClass('numcur').siblings().removeClass('numcur'); //为对应的版面数字加上高亮样式,并移除同级元素的高亮样式
//        }
//    });
//    //@Mr.Think***向后滚动
//    $next.click(function() {
//        if (!$showbox.is(':animated')) { //判断展示区是否动画
//            if ($cur == $pages) {  //在最后一个版面时,再向后滚动到第一个版面
//                $showbox.animate({
//                    left: 0
//                }, 500); //改变left值,切换显示版面,500(ms)为滚动时间,下同
//                $cur = 1; //初始化版面为第一个版面
//            }
//            else {
//                $showbox.animate({
//                    left: '-=' + $w
//                }, 500); //改变left值,切换显示版面
//                $cur++; //版面数累加
//            }
//            $num.eq($cur - 1).addClass('numcur').siblings().removeClass('numcur'); //为对应的版面数字加上高亮样式,并移除同级元素的高亮样式
//        }
//    });
//    //@Mr.Think***数字点击事件
//    $num.click(function() {
//        if (!$showbox.is(':animated')) { //判断展示区是否动画
//            var $index = $num.index(this); //索引出当前点击在列表中的位置值
//            $showbox.animate({
//                left: '-' + ($w * $index)
//            }, 500); //改变left值,切换显示版面,500(ms)为滚动时间
//            $cur = $index + 1; //初始化版面值,这一句可避免当滚动到第三版时,点击向后按钮,出面空白版.index()取值是从0开始的,故加1
//            $(this).addClass('numcur').siblings().removeClass('numcur'); //为当前点击加上高亮样式,并移除同级元素的高亮样式
//        }
//    });
//    //@Mr.Think***停止滚动
//    clearFun($showbox);
//    clearFun($pre);
//    clearFun($next);
//    clearFun($num);
//    //@Mr.Think***事件划入时停止自动滚动
//    function clearFun(elem) {
//        elem.hover(function() {
//            clearAuto();
//        }, function() {
//            autoSlide();
//        });
//    }
//    //@Mr.Think***自动滚动
//    function autoSlide() {
//        $next.trigger('click');
//        $autoFun = setTimeout(autoSlide, 3000); //此处不可使用setInterval,setInterval是重复执行传入函数,这会引起第二次划入时停止失效
//    }
//    //@Mr.Think***清除自动滚动
//    function clearAuto() {
//        clearTimeout($autoFun);
//    }
//});
$(document).ready(function() {
    $(".sub_station,#head_help .close").click(function() {
        $(".station").toggleClass("show");
    });
    $("#head_search_box li").click(function() {
        $(this).addClass("search_current").siblings().removeClass("search_current");
    });

    $(".m_list_tab li").click(function() {
        $(this).parent().children(".m_tab_current").removeClass("m_tab_current");
        $(this).addClass("m_tab_current");
        var tab_num = $(this).parent(".m_list_tab").children("li").index($(this));
        $(this).parent().parent(".m_list").children(".m_list_cont").hide();
        $(this).parent().parent(".m_list").children(".m_list_cont").eq(tab_num).show();
    });
    $(".hqbj_tab li").click(function() {
        $(".hqbj_current").removeClass("hqbj_current");
        $(this).addClass("hqbj_current");
        var hq_tabnum = $(".hqbj_tab li").index($(this));
        $(".hqbj_cont").hide();
        $(".hqbj_cont").eq(hq_tabnum).show();
    });
});
$(document).ready(function() {
    //Set Default State of each portfolio piece
    $(".paging").show();
    $(".paging a:first").addClass("active");

    //Get size of images, how many there are, then determin the size of the image reel.
    var imageWidth = $(".window").width();
    var imageSum = $(".image_reel img").size();
    var imageReelWidth = imageWidth * imageSum;

    //Adjust the image reel to its new size
    $(".image_reel").css({ 'width': imageReelWidth });

    //Paging + Slider Function
    rotate = function() {
        var triggerID = $active.attr("rel") - 1; //Get number of times to slide
        var image_reelPosition = triggerID * imageWidth; //Determines the distance the image reel needs to slide

        $(".paging a").removeClass('active'); //Remove all active class
        $active.addClass('active'); //Add active class (the $active is declared in the rotateSwitch function)

        //Slider Animation
        $(".image_reel").animate({
            left: -image_reelPosition
        }, 500);

    };

    //Rotation + Timing Event
    rotateSwitch = function() {
        play = setInterval(function() { //Set timer - this will repeat itself every 3 seconds
            $active = $('.paging a.active').next();
            if ($active.length === 0) { //If paging reaches the end...
                $active = $('.paging a:first'); //go back to first
            }
            rotate(); //Trigger the paging and slider function
        }, 7000); //Timer speed in milliseconds (3 seconds)
    };

    rotateSwitch(); //Run function on launch

    //On Hover
    $(".image_reel a").hover(function() {
        clearInterval(play); //Stop the rotation
    }, function() {
        rotateSwitch(); //Resume rotation
    });

    //On Click
    $(".paging a").click(function() {
        $active = $(this); //Activate the clicked paging
        //Reset Timer
        clearInterval(play); //Stop the rotation
        rotate(); //Trigger rotation immediately
        rotateSwitch(); // Resume rotation
        return false; //Prevent browser jump to link anchor
    });

});
