﻿jQuery(document).ready(function() {
if (CheckRootSite()) {
        window.setTimeout(function() { GetHopeText(); }, 0);
    }
    else {
        var MyMar;
        window.setTimeout(function() { MyMar = window.setInterval(function() { if (jQuery("#myscroll ul li").length > 2) { AutoScroll("#myscroll"); } }, 2000); }, 0);

        $("#myscroll").hover(function() { window.clearInterval(MyMar); },
function() { MyMar = setInterval("AutoScroll('#myscroll')", 2000); });
    }
});

function GetHopeText() {
    jQuery.ajax({
        type: "get",
        url: "/Ajax.aspx?no-cache=" + Math.random(),
        data: "action=hopetext",
        dataType: "text",
        success: function(transport) {
            var returnvalue = transport;
            if (returnvalue.indexOf(" ?? ") > -1) { }
            else {
                jQuery("ul[id*='hopetxt']").html(returnvalue);
                if (jQuery("#myscroll>ul>li").length > 2) {
                    var MyMar;
                    window.setTimeout(function() { MyMar = window.setInterval(function() { AutoScroll("#myscroll"); }, 2000); }, 0);
                    jQuery("#myscroll").hover(function() { window.clearInterval(MyMar); },
        function() { MyMar = setInterval("AutoScroll('#myscroll')", 2000); });
                }
            }
        }
    });
}

function AutoScroll(obj) {

    jQuery(obj).find("ul:first").animate({
        marginTop: "-25px"
    }, 1000, function() {
        jQuery(this).css({ marginTop: "0px" }).find("li:first").appendTo(this);
    });
}


//匹配字符串
function CheckURL(urlname) {
    var url = window.location.toString();
    var i = url.lastIndexOf("/");
    return url.substring(i + 1, url.length).toString().toLowerCase().indexOf(urlname)
}

//判断是否为根目录
function CheckRootSite() {
    var url = window.location.toString();
    var i = url.lastIndexOf("/");
    if (url.substring(i + 1, url.length).toString().toLowerCase() == "") {
        return true;
    }
    else {
        return false;
    }
}

