﻿jQuery(function () {
    jQuery("a[id^='go_']").click(function () {
        var id = parseInt(jQuery(this).attr("id").replace("go_", ""));
        var left = parseInt(jQuery("#softlist").css("left").replace("px", ""));

        if (id == 1 && left == 0) {
            return false;
        }
        if (id == 2 && left == -570) {
            return false;
        }
        if (left == 0) {
            jQuery("#softlist").animate({ left: '-570px' }, 500);
        }
        else {
            jQuery("#softlist").animate({ left: '0px' }, 500);
        }

        jQuery("a[id^='go_']").removeClass("current");
        jQuery(this).attr("class", "current");
    })

    var goflag = 0;
    function picmove() {
        var cleft = jQuery("#softlist").css("left").replace("px", "");
        cleft = parseInt(cleft);
        if (cleft % 590 != 0) {
            cleft = -590;
        }
        if (cleft > (-590 - picnum * 590)) {
            var ccleft = parseInt(cleft) - 590;
            goflag = 1;
            jQuery("#softlist").animate({ left: ccleft + 'px' }, "slow", function () { goflag = 0; });
        }
        else {
            jQuery("#softlist").hide();
            jQuery("#softlist").css("left", "-590px");
            jQuery("#softlist").show();
            jQuery("#softlist").animate({ left: '-' + 2 * 590 + 'px' }, "slow", function () { goflag = 0; });
        }
    }

    var startgo = setInterval(function () {
        picmove();
    }, 3000);


    jQuery("#softlist").hover(function () {
        window.clearInterval(startgo);
    }, function () {
        startgo = setInterval(function () {
            picmove();
        }, 3000);
    });

    jQuery("#searchalltop").click(function () {
        var keyword = jQuery("#keywordalltop").val();
        if (keyword == "") {
            return false;
        }
        location.href = "/Search/" + encodeURIComponent(keyword).replace(/%/g, "-");
    });


    jQuery("#keywordalltop").keydown(function () {
        var charCode = (navigator.appName == "Netscape") ? window.event.which : window.event.keyCode;
        if (charCode == 13) {
            jQuery("#searchalltop").click()
            return false;
        }
    })

    jQuery("#keywordalltop").focus(function () {
        if (jQuery(this).val() == "整站搜索") {
            jQuery(this).val("");
            return false;
        }
    })
});

