﻿//------------------------------------------------幻灯片开始　
var currslid = 0;
var slidint;
var picarry = {};
var introarry = {};
var titlearry = {};
var linkarry = {};
var strnav;
function FixCode(str) {
    return str.replace("'", "=");
}
function mrhdp() {
var t = $("X_xdp");
var rl = t.rows.length;
for (var i = 0; i < rl; i++) {
    try {
        titlearry[i] = FixCode(t.rows[i].cells[0].innerHTML);
        picarry[i] = t.rows[i].cells[1].childNodes[0].childNodes[0].src;
        introarry[i] = FixCode(t.rows[i].cells[2].innerHTML);
        linkarry[i] = t.rows[i].cells[1].childNodes[0].href;
        if (i == 0)
            strnav = '<span id="stab_'+i+'" onmouseover="setfoc(0)" onmouseout="playit()">1<\/span>';
        else
            strnav = strnav + ' | <span id="stab_' + i + '" onmouseover=":setfoc(' + i + ')" onmouseout="playit()">' + (i + 1) + '<\/span>';
    } catch (e) {

    }
}
$("h_hdp_num").innerHTML = strnav;
}

function setfoc(id) {
    $("h_picurl").src = picarry[id];
    $("h_hdp_title").innerHTML = titlearry[id];
    $("h_hdp_intro").innerHTML = introarry[id];
    $("h_hdp_link").href = linkarry[id];

    var borserInfo = navigator.userAgent.toLowerCase();
    if (/msie/.test(borserInfo)) {
        $("h_picurl").style.visibility = "hidden";
        if (!window.ActiveXObject) {
            $("h_picurl").filters[0].Apply();
            $("h_picurl").filters[0].transition = 23;
        }
        if ($("h_picurl").style.visibility == "visible") {
            $("h_picurl").style.visibility = "hidden";
        }
        else {
            $("h_picurl").style.visibility = "visible";
        }
        if (!window.ActiveXObject) {
            $("h_picurl").filters[0].Play();
        }
    }
    stopit();
}

function playnext() {
		var t = $("X_xdp");
		var rl = t.rows.length;
    if (currslid == rl-1) {
        currslid = 0;
    }
    else {
        currslid++;
    };
    setfoc(currslid);
    playit();
}
function playit() {
    slidint = setTimeout(playnext, 3000);
}
function stopit() {
    clearTimeout(slidint);
}

//--------------------------------------------------------首页登录加载　集成邮箱登录
//登录字串
var str_login = "<form id=\"Form_UserLogin40794\" name=\"Form_UserLogin40794\" method=\"post\" action=\"\">" +
"	        <span>帐号：<input id=\"UserName\" name=\"UserName\" type=\"text\" size=\"10\" maxlength=\"20\" \/><\/span>" +
"	        <span>密码：<input name=\"UserPwd\" type=\"password\" id=\"UserPwd\" size=\"10\" onKeyDown=\"javascript:if (event.keyCode==13) LoginSubmit();\" \/><\/span>" +
"	        <span id=\"abrand1\" class=\"ugo\" onmouseover=\"javascript:showTipsInfo(\'1\');\" onmouseout=\"hideTipsInfo(\'1\')\">请选择去向<\/span>" +
"	        <span><input type=\"button\" name=\"but_LoginSubmit\" value=\"登录\" class=\"but_LS\" onclick=\"javascript:LoginSubmit();\" \/><\/span>" +
"	        <span class=\"\"><a href=\"http:\/\/www.mr1988.net\/user\/Register.aspx\" title=\"注册新用户\">注册<\/a><\/span>" +
"	    <\/form>";
var str_way = 0;
//选择去向
function tgo(obj1, obj2, myvar) {
    $(obj1).innerHTML = obj2.innerHTML;
    str_way = myvar;
}

function EmailEncode(datastr, bassnum) {
    var tempstr;
    var tchar;
    var newdata = "";

    for (var i = 0; i < datastr.length; i++) {
        tchar = 65535 + bassnum - datastr.charCodeAt(i);
        tchar = tchar.toString();

        while (tchar.length < 5) {
            tchar = "0" + tchar;
        }

        newdata = newdata + tchar;
    }

    return newdata;
}

//function toMail() {
//    $('#header li:first-child').setAttribute("onclick","javascript:window.open('http://mail.mr1988.net/', '_blank');");
//        
// }

//登录
function LoginSubmit() {
    var uname = $F("UserName");
    var upwd = $F("UserPwd");
    if (uname == "") { alert('帐号不能为空'); return false; }
    if (upwd == "") { alert('密码不能为空'); return false; }
    if (str_way == 1) {
        window.open("http://mail.mr1988.net/newwebmail/login.php?Cmd=login&username=" + uname + "&password=" + upwd + "&domain=mr1988.net&language=1", "_blank");
        //window.open("http://mail.mr1988.net/", "_blank");
    }
    else {
        $("userlogin").innerHTML = "登录中...";
        var Action = 'UserName=' + uname + '&UserPwd=' + upwd + '&Type=Login&RandNum=40794&LoginP=true&StyleID=';
        var options = {
            method: 'get',
            parameters: Action,
            onComplete: function (transport) {
                var returnvalue = transport.responseText;
                var returnvaluearr = returnvalue.split('$$$');
                if (returnvaluearr[0] != "ERR") {
                    if (returnvaluearr[0] == "CLS") {
                        $("userlogin").innerHTML = returnvaluearr[2];
                        if (str_way == 0 || str_way == 3)
                            setTimeout(window.location.href = '/school/showclass.aspx?ClassID=' + returnvaluearr[1], 5000);
                        else
                            setTimeout(getLoginForm(), 5000);
                    }
                    else if (str_way == 2) {
                        $("userlogin").innerHTML = returnvaluearr[1];
                        setTimeout(window.location.href = '/blog', 5000);
                    }
                    else if (str_way == 4) {
                        $("userlogin").innerHTML = returnvaluearr[1];
                        setTimeout(window.location.href = 'http://forum.mr1988.net', 5000);
                    }
                    else {
                        $("userlogin").innerHTML = returnvaluearr[1];
                    }
                }
                else {
                    $("userlogin").innerHTML = returnvaluearr[1];
                }
            }
        };
        new Ajax.Request('/user/UserLoginajax.aspx?no-cache=' + Math.random(), options);
    }
}
function LoginOut() {
    var Action = 'Type=LoginOut&LoginP=true&FormCSS=&LoginCSS=&RegCSS=&PassCSS=&StyleID=';
    var options = {
        method: 'get',
        parameters: Action,
        onComplete: function(transport) {
            var returnvalue = transport.responseText;
            if (returnvalue.indexOf("??") > -1)
                alert('未知错误!请联系管理员');
            else
                $("userlogin").innerHTML = str_login;
        }
    };
    new Ajax.Request('/user/UserLoginajax.aspx?no-cache=' + Math.random(), options);
}
function getLoginForm() {
    var Action = 'Type=getLoginForm&RandNum=40794&LoginP=true&FormCSS=&LoginCSS=&RegCSS=&PassCSS=&StyleID=';
    var options = {
        method: 'get',
        parameters: Action,
        onComplete: function(transport) {
            var returnvalue = transport.responseText;
            if (returnvalue.substring(0, 5) == "<form")
                $("userlogin").innerHTML = str_login;
            else
                $("userlogin").innerHTML = returnvalue;
        }
    };
    new Ajax.Request('/user/UserLoginajax.aspx?no-cache=' + Math.random(), options);
}

//-------------------------------登录选择去向

var Position = {
    getElementLeft: function(o) {
        (typeof o == "string") ? o = $(o) : "";
        var L = 0;
        while (o) {
            L += o.offsetLeft || 0;
            o = o.offsetParent;
        }
        var W = document.body.clientWidth;
        if (W > 1002) {
            L -= (W - 1002) / 2;
        }
        return L;
    },
    getElementTop: function(o) {
        (typeof o == "string") ? o = $(o) : "";
        var T = 0;
        while (o) {
            T += o.offsetTop || 0;
            o = o.offsetParent;
        }
        return T;
    }
}

function showTipsInfo(sID) {
    $("sysmenu" + sID).style.display = "block";
    $("sysmenu" + sID).style.left = Position.getElementLeft('abrand' + sID) - 1 + "px";
    $("sysmenu" + sID).style.top = Position.getElementTop('abrand' + sID) + 22 + "px";
}

function hideTipsInfo(sID) {
    $("sysmenu" + sID).style.display = "none";
}

function Marquee() {
    this.ID = $(arguments[0]);
    this.Direction = arguments[1];
    this.Step = arguments[2];
    this.Width = arguments[3];
    this.Height = arguments[4];
    this.Timer = arguments[5];
    this.WaitTime = arguments[6];
    this.StopTime = arguments[7];
    if (arguments[8]) { this.ScrollStep = arguments[8]; } else { this.ScrollStep = this.Direction > 1 ? this.Width : this.Height; }
    this.CTL = this.StartID = this.Stop = this.MouseOver = 0;
    this.ID.style.overflowX = this.ID.style.overflowY = "hidden";
    this.ID.noWrap = true;
    this.ID.style.width = this.Width;
    this.ID.style.height = this.Height;
    this.ClientScroll = this.Direction > 1 ? this.ID.scrollWidth : this.ID.scrollHeight;
    this.ID.innerHTML += this.ID.innerHTML;
    this.Start(this, this.Timer, this.WaitTime, this.StopTime);
}
Marquee.prototype.Start = function (msobj, timer, waittime, stoptime) {
    msobj.StartID = function () { msobj.Scroll(); }
    msobj.Continue = function () {
        if (msobj.MouseOver == 1) { setTimeout(msobj.Continue, waittime); }
        else { clearInterval(msobj.TimerID); msobj.CTL = msobj.Stop = 0; msobj.TimerID = setInterval(msobj.StartID, timer); }
    }
    msobj.Pause = function () { msobj.Stop = 1; clearInterval(msobj.TimerID); setTimeout(msobj.Continue, waittime); }
    msobj.Begin = function () {
        msobj.TimerID = setInterval(msobj.StartID, timer);
        msobj.ID.onmouseover = function () { msobj.MouseOver = 1; clearInterval(msobj.TimerID); }
        msobj.ID.onmouseout = function () { msobj.MouseOver = 0; if (msobj.Stop == 0) { clearInterval(msobj.TimerID); msobj.TimerID = setInterval(msobj.StartID, timer); } }
    }
    setTimeout(msobj.Begin, stoptime);
}
Marquee.prototype.Scroll = function () {
    switch (this.Direction) {
        case 0:
            this.CTL += this.Step;
            if (this.CTL >= this.ScrollStep && this.WaitTime > 0) { this.ID.scrollTop += this.ScrollStep + this.Step - this.CTL; this.Pause(); return; }
            else { if (this.ID.scrollTop >= this.ClientScroll) this.ID.scrollTop -= this.ClientScroll; this.ID.scrollTop += this.Step; }
            break;
        case 1:
            this.CTL += this.Step;
            if (this.CTL >= this.ScrollStep && this.WaitTime > 0) { this.ID.scrollTop -= this.ScrollStep + this.Step - this.CTL; this.Pause(); return; }
            else { if (this.ID.scrollTop <= 0) this.ID.scrollTop += this.ClientScroll; this.ID.scrollTop -= this.Step; }
            break;
        case 2:
            this.CTL += this.Step;
            if (this.CTL >= this.ScrollStep && this.WaitTime > 0) { this.ID.scrollLeft += this.ScrollStep + this.Step - this.CTL; this.Pause(); return; }
            else { if (this.ID.scrollLeft >= this.ClientScroll) this.ID.scrollLeft -= this.ClientScroll; this.ID.scrollLeft += this.Step; }
            break;
        case 3:
            this.CTL += this.Step;
            if (this.CTL >= this.ScrollStep && this.WaitTime > 0) { this.ID.scrollLeft -= this.ScrollStep + this.Step - this.CTL; this.Pause(); return; }
            else { if (this.ID.scrollLeft <= 0) this.ID.scrollLeft += this.ClientScroll; this.ID.scrollLeft -= this.Step; }
            break;
    }
}

function showAds() {
          addCount();
          setTimeout("noneAds()",4000);
      }
      window.onload = function () {

          getLoginForm();
          
          mrhdp();
          playit();
          new Marquee(
    "scrollBox2",  //容器ID<br />
    0,  //滚动方向(0向上 1向下 2向左 3向右)<br />
    2,  //滚动步长<br />
    269,  //滚动区域宽度<br />
    64,  //滚动区域高度<br />
    50,  //定时器 数值越小，滚动的速度越快(1000=1秒,建议不小于20)<br />
    2000,  //停顿时间(0为不停顿,1000=1秒)<br />
    1000,  //开始等待时间(0为不等待,1000=1秒)<br />
    22  //间歇滚动间距(可选)<br />
    );
          //AD2.render('XYS_Full');
      }


