﻿if (typeof $ != 'function') { window.$ = function(id) { return 'string' == typeof id ? document.getElementById(id) : id; }; }
eval(function(p, a, c, k, e, d) { e = function(c) { return (c < a ? '' : e(parseInt(c / a))) + ((c = c % a) > 35 ? String.fromCharCode(c + 29) : c.toString(36)) }; if (!''.replace(/^/, String)) { while (c--) d[e(c)] = k[c] || e(c); k = [function(e) { return d[e] } ]; e = function() { return '\\w+' }; c = 1 }; while (c--) if (k[c]) p = p.replace(new RegExp('\\b' + e(c) + '\\b', 'g'), k[c]); return p } ('8 Z={k:c(7,a,6){8 g="Y";2(6==h||6==""||6=="X"){g="W";6=a;a=h}8 1;2(V.s){1=r s()}p{8 i=["d.9.5.0","d.9.4.0","d.9.3.0","d.9","U.9"];T(8 n=0;n<i.S;n++){q{1=r R(i[n]);Q}j(e){}}}2(1.b==h){1.b=0;1.P("O",c(){1.b=4;2(N 1.f=="c"){1.f()}},M)}L(1){q{2(7.K("?")>0){7+="&o="+m.l()}p{7+="?o="+m.l()}1.J(g,7,I);1.H("G-F","E/x-D-C-B");1.f=c(){2(1.b==4){2(1.A==z){6(1.y)}}};1.k(a)}j(e){w("1 v u t!")}}}};', 62, 62, '|xmlhttp|if||||func|url|var|XMLHTTP|param|readyState|function|MSXML2||onreadystatechange|method|null|MSXML|catch|send|random|Math||ajaxrandnum|else|try|new|XMLHttpRequest|failed|creation|object|alert||responseText|200|status|urlencoded|form|www|application|Type|Content|setRequestHeader|true|open|indexOf|with|false|typeof|load|addEventListener|break|ActiveXObject|length|for|Microsoft|window|GET|undefined|POST|ajax'.split('|'), 0, {}));
var loadfile = function(filesrc, filetype, callback, encoding) { var fileref = null; function load(bool, res) { encoding = encoding || 'utf-8'; if (filetype == 'js') { fileref = document.createElement('script'); fileref.setAttribute('type', 'text/javascript'); fileref.setAttribute('charset', encoding); fileref.setAttribute('src', filesrc); } if (filetype == 'css') { fileref = document.createElement('link'); fileref.setAttribute('rel', 'stylesheet'); fileref.setAttribute('type', 'text/css'); fileref.setAttribute('href', filesrc); } if (fileref == null) { if (bool) { callback(false); } } else { document.getElementsByTagName('head')[0].appendChild(fileref); if (bool) { callback(true); } } } if (typeof (callback) == 'function') { ajax.send(filesrc, function(res) { load(true, res); }); } else { load(false, ''); } };


/*===========================登录/状态 事件============================*/
function login() {
    if ($("txtUID").value == "" || $("txtPWD").value == "") alert("请将帐号密码填写完整");
     if ($("txtCode").value == "" ) alert("请填写验证码");
   
    else ajax.send("ashx/login.ashx", "action=index&u=" + encodeURIComponent($("txtUID").value) +"&code="+encodeURIComponent($("txtCode").value) +"&p=" + encodeURIComponent($("txtPWD").value)+"&type="+$("seltype").value, function(res) { eval(res) });
}
function loginout() { ajax.send("ashx/login.ashx", "action=logout", function(res) { eval(res); }); }



function unlogin() {   
    var str = '';
    str += '<p style="margin-bottom:3px;"><label>帐 &nbsp;&nbsp;号：</label><input type="text" class="text" name="txtUID" id="txtUID" value="" /></p>';
    str += '<p><label>密 &nbsp;&nbsp;码：</label><input type="password" class="text" name="txtPWD" id="txtPWD" value="" /></p>';
    str += '<p><label>验证码：</label><input type="text" class="text" name="txtCode" id="txtCode" value="" /><span style="margin-top:5px;"><img style="height:21px;" title="看不清，换一张" src="ashx/getcode.ashx"  alt="获取验证码错误" onclick="this.src+=\'?\'" /></span></p>';
    str+='<p><label>类 &nbsp;&nbsp;型：</label><select id="seltype"><option value="0">教师</option><option value="1">访客</option></select></p>';
    str += '<p><input type="image" class="btn" src="images/dl.gif" onclick="login();" /><input type="image" class="btnzc" src="images/zc.gif" onclick="register();" /></p>';
    $("formlogin").innerHTML = str;
}
function state() {ajax.send("ashx/login.ashx", "action=state", function(res) { eval(res); }); }
function onstate(str) { $("formlogin").innerHTML = str; }
/*===========================家长注册/状态 事件============================*/
function register(){
        var callback=false;
    _url="Register.aspx";
    art.dialog.open(_url, {              id: "box_head",        title: '用户注册',        initFn: function(iframeWin, topWin) {            if(callback) //loadcontent([document.getElementById("show")]);            callback=true;        },        closeFn: function() {                   //location.reload();          //parent.art.dialog.get('box_head').close();                 }    });
  
}

/*===========================页面加载完毕后执行============================*/
function loadcomplete() {
    /*===========================即时时间显示============================*/
    if ($("showtime")) {
        var weekarr = new Array("日", "一", "二", "三", "四", "五", "六");
        function nowtime() {
            var now = new Date();
            var thn = "";
            if (now.getHours() >= 0 && now.getHours() < 6)
                thn = "凌晨";
            else if (now.getHours() >= 6 && now.getHours() < 12)
                thn = "上午";
            else if (now.getHours() >= 12 && now.getHours() < 18)
                thn = "下午";
            else
                thn = "晚上";
            $("showtime").innerHTML = "杭州第九中学欢迎您！ " + now.toLocaleDateString() + " 星期" + weekarr[now.getDay()] + " " + now.toLocaleTimeString() + " " + thn;
            setTimeout(nowtime, 1000);
        }
        nowtime();
    }

    /*===========================左侧导航事件============================*/
   if ($("leftlist")) {
        var clink = 0;
        var listlink = $("leftlist").getElementsByTagName("a");//所有链接集合
        var allchild = $("leftlist").getElementsByTagName("div");//所有子集集合
        for (var i = 0; i < allchild.length; i++) allchild[i].style.display = "none";//让所有子集先隐藏
        for (var i = 0; i < allchild.length; i++) allchild[i].style.display = "";
        for (var i = 0; i < listlink.length; i++) {
            listlink[i].value = i;
            listlink[i].onmouseover = function() { this.className = "hover"; };
            listlink[i].onmouseout = function() { if (listlink.length > 1) this.className = ""; };
            listlink[i].onclick = function() {
                if (this.parentNode.tagName == "LI") {
                    for (var c = 0; c < listlink.length; c++) { if (listlink[c].parentNode.tagName == "LI") { listlink[c].className = ""; listlink[c].onmouseout = function() { this.className = ""; }; } }
                    if (this.parentNode.getElementsByTagName("div").length > 0) {
                        var child = this.parentNode.getElementsByTagName("div")[0];
                        for (var c = 0; c < allchild.length; c++) { if (allchild[c] != child) allchild[c].style.display = "none"; }
                        child.style.display = child.style.display == "none" ? "block" : "none";

                        listlink[this.value].className = "hover";
                        listlink[this.value].onmouseout = function() { return false; };
                        //return false;
                    }
                    for (var c = 0; c < allchild.length; c++) { allchild[c].style.display = "none"; }
                } else if (this.parentNode.tagName == "DIV")
                    for (var c = 0; c < listlink.length; c++) { if (listlink[c].parentNode.tagName == "DIV") { listlink[c].className = ""; listlink[c].onmouseout = function() { this.className = ""; }; } }
                clink = this.value;
                listlink[clink].className = "hover";
                listlink[clink].onmouseout = function() { return false; };
                resizeheight();
            };
            if (cval == listlink[i].id.replace("childlink_", "")) {
                clink = i;
                listlink[clink].className = "hover";
                listlink[clink].onmouseout = function() { return false; };
                if (listlink[clink].parentNode.tagName == "DIV") {
                    listlink[clink].parentNode.style.display = "block";
                    listlink[clink].parentNode.parentNode.childNodes[0].className = "hover";
                    listlink[clink].parentNode.parentNode.childNodes[0].onmouseout = function() { return false; };
                }
                if (listlink[clink].parentNode.getElementsByTagName("div").length > 0) {
                    var child = listlink[clink].parentNode.getElementsByTagName("div")[0];
                    child.style.display = "block";
                    listlink[clink].className = "hover";
                    listlink[clink].onmouseout = function() { return false; };
                }
            }
        }
    }


    /*===========================横向导航事件============================*/
    function funcnavigate() {
        if ($("navigate")) {
            var nlink = 0;
            var links = $("navigate").getElementsByTagName("a");
            if (links.length > 0) {
                for (var i = 1; i < links.length; i++) {
                    if (fval == links[i].id.replace("navlink_", "")) nlink = i;
                    links[i].value = i;
                    links[i].onmouseover = function() { this.className = "hover"; };
                    links[i].onmouseout = function() { if (this.id.replace("navlink_", "") != fval) this.className = ""; };
                    links[i].onclick = function() { nlink = this.value; };
                }
                links[nlink].className = "hover";
            }
        }
    } funcnavigate();

    /*===========================信息内容修正============================*/
    if ($("ctl00_MainContent_divContent")) {
        var divDetail = $("ctl00_MainContent_divContent");
        var maxwidth = 915;
        var tables = divDetail.getElementsByTagName("table");
        var images = divDetail.getElementsByTagName("img");
        for (var i = 0; i < tables.length; i++) {
            tables[i].style.marginLeft = "auto";
            tables[i].style.marginRight = "auto";
        }
        for (var i = 0; i < images.length; i++) {
            if (images[i].width > maxwidth) {
                images[i].setAttribute("style", "width:" + maxwidth + "px;");
                images[i].width = maxwidth;
            }
            images[i].style.zoom = "100%";
            images[i].style.marginLeft = "auto";
            images[i].style.marginRight = "auto";
        }
    }
    
    /*===========================栏目切换============================*/
    if ($("showtablink") && $("showtabcont") && $("showtabmore")) {
        var n = 0;
        var t = null;
        var links = $("showtablink").getElementsByTagName("A");
        var conts = $("showtabcont").getElementsByTagName("UL");
        var smore = $("showtabmore");
        if (links.length > 0 && links.length == conts.length) {
            function autoshowtab() {
                if (t != null)
                    clearTimeout(t);
                for (var c = 0; c < links.length; c++)
                    links[c].className = "";
                for (var c = 0; c < conts.length; c++)
                    conts[c].style.display = "none";
                links[n].className = "hover";
                conts[n].style.display = "block";
                smore.href = links[n].href;
                t = setTimeout(function() { n++; if (n == links.length) n = 0; autoshowtab(); }, 5000);
            }
            for (var i = 0; i < links.length; i++) {
                links[i].value = i;
                links[i].onmouseover = function() { n = this.value; autoshowtab(); clearTimeout(t); };
                links[i].onmouseout = function() { t = setTimeout(function() { n++; if (n == links.length) n = 0; autoshowtab(); }, 5000); };
            }
            autoshowtab();
        }
    }
    
    /*if($("colee_left")&&$("colee_left1")&&$("colee_left2")){
        var speed = 30//速度数值越大速度越慢
        var colee_left2 = $("colee_left2");
        var colee_left1 = $("colee_left1");
        var colee_left = $("colee_left");
        var colee_hover = false;
        colee_left2.innerHTML = colee_left1.innerHTML
        function Marquee3() {
            if(colee_hover) return;
            if (colee_left2.offsetWidth - colee_left.scrollLeft <= 0)
                colee_left.scrollLeft -= colee_left1.offsetWidth;
            else {
                colee_left.scrollLeft++
            }
        }
        var MyMar3 = setInterval(Marquee3, speed);
        colee_left.onmouseover = function () { clearInterval(MyMar3); colee_hover = true; };
        colee_left.onmouseout = function () { MyMar3 = setInterval(Marquee3, speed); colee_hover = false; };
    }*/
    /*===========================自动高度 -- 最后调用============================*/
    function resizeheight() {
        if ($("leftcont") && $("maincontent")) {
            if ($("leftcont").clientHeight > $("maincontent").clientHeight) $("maincontent").style.height = $("leftcont").clientHeight + "px";
            else $("leftcont").style.height = $("maincontent").clientHeight + "px";
        }
    } resizeheight();


}

function lanScroll(){
    setTimeout(function(){
        if($("MyMarqueeX")){
            new Marquee({ obj: 'MyMarqueeX', mode: 'x', movePause: true });
        }
    },1000);
}

if (document.attachEvent) document.onreadystatechange = function() { if (document.readyState == "complete") { loadcomplete(); lanScroll(); } };
else document.addEventListener("DOMContentLoaded", function() { loadcomplete(); lanScroll(); }, false);
