﻿/// <reference path="jsLabrary.js" />
function AddLoadEvent(fun) {                                 //添加启动事件
    if (window.addEventListener) { // Mozilla, Netscape, Firefox
        window.addEventListener('load', fun, false);
    } else { // IE
        window.attachEvent('onload', fun);
    }
}

/*Login.aspx*/
function CheckLogin() {
    if ($('txtEmail').value.Trim() == '') {
        alert('登录帐号不能为空！');
        return false;
    }
    if ($('txtPassword').value.Trim() == '') {
        alert('密码不能为空！');
        return false;
    }
    return true;
}
/*Login.aspx*/

/*Register.aspx*/
function Register_Load() {
    Utility.marginLeft = 200;
    Utility.width = '170';
    $("txtEmail").focus();
    $("dropProvince").options.add(new Option("载入中...", "载入中..."));
    $("dropCity").options.add(new Option("载入中...", "载入中..."));
    $("dropSCity").options.add(new Option("载入中...", "载入中..."));
    $("dropPro1").options.add(new Option("载入中...", "载入中..."));
    $("dropCity1").options.add(new Option("载入中...", "载入中..."));
    addEventHandler($("txtEmail"), "blur", function() {
        $('txtEmail').value.Trim().length > 0 ? (Check.CheckEMail($('txtEmail').value.Trim()) ? IsExistUser('', $('txtEmail').value.Trim()) : Utility.Show($('txtEmail'), "电子邮箱格式不正确！", false)) : Utility.Show($('txtEmail'), "请输入电子邮箱！", false);
    });
    addEventHandler($("txtPassword"), "blur", function() {
        Check.CheckNull($('txtPassword').value.Trim(), 20, 6) ? Utility.Show($('txtPassword'), '', true) : Utility.Show($('txtPassword'), "请将字数限制在 6 ~ 20 内！", false);
    });
    addEventHandler($('txtRepeatPassword'), 'blur', function() {
        ($('txtRepeatPassword').value == $('txtPassword').value) ? Utility.Show($('txtRepeatPassword'), '', true) : Utility.Show($('txtRepeatPassword'), '两次密码输入不一致！', false); ;
    });
    addEventHandler($("txtUserName"), "blur", function() {
        Check.CheckNull($('txtUserName').value.Trim(), 20, 6) ? IsExistUser($('txtUserName').value.Trim(), '') : Utility.Show($('txtUserName'), "请将字数限制在 6 ~ 20 内！", false);
    });
    Renjoin.LoadArea('dropProvince', 'dropCity', 'dropSCity');
    LoadHomePlace();
}

function LoadHomePlace() {
    if ($('dropSCity').value != '载入中...' && $('dropCity1').value == '载入中...')
        Renjoin.LoadArea('dropPro1', 'dropCity1');
    else if ($('dropCity1').value != '载入中...')
        return;
    else
        setTimeout(function() { LoadHomePlace(); }, 50);
}

function IsExistUser(val1, val2) {
    ajax.url = "./WebService/EHome.asmx/IsExistsUser?userName=" + escape(val1) + '&email=' + escape(val2);
    ajax.onSuccess = function() {
        if (ajax.response == "true") {
            val2 == '' ? Utility.Show($('txtUserName'), '昵称已经存在', false) : Utility.Show($('txtEmail'), '邮箱已经存在！', false);
            return false;
        }
        else {
            Utility.Show((val2 == '' ? $('txtUserName') : $('txtEmail')), '', true);
            return true;
        }
    }
    ajax.open();
}

function CheckAct() {
    if (!$('chkAccept').checked) {
        alert('请仔细阅读《人居e家服务使用协议》');
        return false;
    }
    var result1 = Check.CheckNull($('txtUserName').value.Trim(), 20, 6)
    if (!result1)
        Utility.Show($('txtUserName'), '', false);
    var result2 = Check.CheckNull($('txtPassword').value.Trim(), 20, 6);
    if (!result2)
        Utility.Show($('txtPassword'), '', false);
    var result3 = $('txtRepeatPassword').value == $('txtPassword').value;
    if (!result3)
        Utility.Show($('txtRepeatPassword'), '', false);
    var result4 = Check.CheckNull($('txtBirth').value.Trim());
    if (!result4)
        Utility.Show($('txtBirth'), '', false);
    var result5 = $('txtEmail').value.Trim().length > 0 && Check.CheckEMail($('txtEmail').value.Trim());
    if (!result5)
        Utility.Show($('txtEmail'), '', false);
    return result1 && result2 && result3 && result4 && result5;
}
/*Register.aspx*/



function setHomePlace() {
    var a = $(homeplace);
    var province = $('ctl00_ContentPlaceHolder1_ddlProvince');
    var city = $('ctl00_ContentPlaceHolder1_ddlCity');
    a.value = province.options[province.selectedIndex].text + city.options[city.selectedIndex].text;
}
function setArea() {
    var province = $('ctl00_ContentPlaceHolder1_ddlProvince1');
    var city = $('ctl00_ContentPlaceHolder1_ddlCity1');
    var scity = $('ctl00_ContentPlaceHolder1_ddlSCity1');
    return province.options[province.selectedIndex].text + city.options[city.selectedIndex].text + (scity.value == "0" ? '' : scity.options[scity.selectedIndex].text);
}
/*MyHome.aspx 中申请好友填写理由*/
function Message(me, uid, fname) {
    if ($("Message")) {
        $("Message").style.display = "";
        return;
    }
    var msg = document.createElement("div");
    msg.id = "Message";
    msg.className = "message";
    var title = document.createElement("div");
    title.innerHTML = "申请加" + fname + "为友好家庭<div><span onclick='MessageHide();'></span></div>";
    title.className = "msgTitle";
    title.id = 'MessageTitle';
    msg.appendChild(title);
    var content = document.createElement("div");
    content.id = "Content";
    content.innerHTML = "友好家庭申请理由（选填）：<p><input id='Reason' type='text' value='' class='mCon'/></p><p><input type='button' value='发送请求' onclick='SendMessage(" + uid + ");' class='mBtn' /><input type='button' value='取 消' onclick='MessageHide();' class='mBtn' /></p>";
    content.className = "con";
    msg.appendChild(content);
    var loc = Utility.nowLocation(me);
    msg.style.left = loc.x + 'px';
    msg.style.top = loc.y + 'px';
    msg.style.position = 'absolute';
    document.body.appendChild(msg);
    var drag = new Drag("Message", { mxContainer: "Message", Handle: "MessageTitle", limit: true });
}
function MessageHide() {
    $("Message").style.display = "none";
}
function SendMessage(uid) {
    if ($("Reason").value.Trim().length == 0)
        ajax.url = "./WebService/EHome.asmx/SendMessage?param=" + escape(uid);
    else
        ajax.url = "./WebService/EHome.asmx/SendMessage?param=" + escape(uid + "|" + $("Reason").value);
    ajax.onSuccess = onSucces;
    ajax.open();

    function onSucces() {
        if (ajax.response == "true") {
            $("Message").style.display = "none";
            alert("好友请求已经发送!");
        } else { alert("好友请求发送失败，请重试!"); }
    }
}
/*MyHome.aspx 中申请好友填写理由 --结束*/
/*MyHome.aspx 中打招呼*/
function SendWave(uid) {
    ajax.url = "./WebService/EHome.asmx/Wave?uid=" + uid;
    ajax.onSuccess = onSucces;
    ajax.open();

    function onSucces() {
        if (ajax.response == "true") {
            alert("打招呼成功!");
        }
        else
            alert("打招呼失败，请刷新后重试！")
    }
}
//DailyDetail.aspx中对留言回复
function CalLength(obj) {       //计算回复字数
    obj.parentNode.parentNode.getElementsByTagName("SPAN")[0].innerHTML = obj.value.replace(/[^\x00-\xff]/g, "aa").replace(/\r\n/ig, "<br>").replace(/\n/ig, "<br>").length;
    if (obj.value.replace(/[^\x00-\xff]/g, "aa").length > 400)
        obj.parentNode.parentNode.getElementsByTagName("SPAN")[0].style.color = "red";
    else
        obj.parentNode.parentNode.getElementsByTagName("SPAN")[0].style.color = "#333";
}
function NewReply(obj) {        //创建新的回复或者隐藏
    var divs = obj.parentNode.parentNode.parentNode.parentNode.getElementsByTagName("DIV");
    var nr;
    for (var i = 0; i < divs.length; i++) {
        if (divs[i].className == "newReply") {
            nr = divs[i];
            break;
        }
    }
    if (nr.style.display == "none")
        nr.style.display = "";
    else {
        nr.style.display = "none";
        nr.getElementsByTagName("TEXTAREA").value = "";
    }
}
function Replay(obj) {      //ajax创建回复
    if (obj.parentNode.parentNode.getElementsByTagName("TEXTAREA")[0].value.Trim().length == 0) {
        alert("请填写回复内容！");
        return;
    }
    else if (obj.parentNode.parentNode.getElementsByTagName("TEXTAREA")[0].value.Trim().replace(/\r\n/ig, "<br>").replace(/\n/ig, "<br>").length > 400) {
        alert("字数超过限制，请限制在400字符内！");
        return;
    }
    ajax.url = "./WebService/EHome.asmx/Reply?pcon=" + escape(obj.name + "|" + obj.parentNode.parentNode.getElementsByTagName("TEXTAREA")[0].value.Trim().replace(/\r\n/ig, "<br>").replace(/\n/ig, "<br>"));
    ajax.onSuccess = onSuccess;
    ajax.open();
    function onSuccess() {
        var reply = ajax.xmlResult.getElementsByTagName("reply");
        if (reply[0].attributes[0].nodeValue == "0") {
            alert("您的回复发表失败，请重试！");
        }
        else {
            var newReply = document.createElement("div");
            newReply.className = "reply";
            newReply.innerHTML = "<p class='replyT'>我的回复<span>" + reply[0].attributes[1].nodeValue + "</span></p><div class='replyContent'>" + obj.parentNode.parentNode.getElementsByTagName("TEXTAREA")[0].value.Trim().replace(/\r\n/ig, "<br>").replace(/\n/ig, "<br>") + "</div>";
            obj.parentNode.parentNode.parentNode.getElementsByTagName("SPAN")[0].appendChild(newReply);
            obj.parentNode.parentNode.getElementsByTagName("TEXTAREA")[0].value = "";
            obj.parentNode.parentNode.style.display = "none";
        }
    }
}
//在替换回车等后计算字数并显示
function CalComentLength(obj) {
    $("Len").innerHTML = obj.value.replace(/[^\x00-\xff]/g, "aa").replace(/\r\n/ig, "<br>").replace(/\n/ig, "<br>").length;
    if (obj.value.replace(/[^\x00-\xff]/g, "aa").length > 400)
        $("Len").style.color = "red";
    else
        $("Len").style.color = "#333";
}
//当前物件显示隐藏
function ShowObj(obj) {
    if (obj.style.display == "none")
        obj.style.display = "";
    else
        obj.style.display = "none";
}
//输入时计算字数并提示，超过 50 个字符变色
function InputTip(obj, num, tipId) {
    $(tipId).innerHTML = obj.value.replace(/[^\x00-\xff]/g, "aa").replace(/\r\n/ig, "<br>").replace(/\n/ig, "<br>").length;
    if (parseInt($(tipId).innerHTML) > num)
        $(tipId).style.color = "red";
    else
        $(tipId).style.color = "#333";
}
//动态添加上传的input控件，每次增加五个
function addFileUploadBox() {
    if (!document.getElementById || !document.createElement)
        return false;
    var uploadArea = document.getElementById("upload-area");
    if (!uploadArea)
        return;
    for (var i = 0; i < 5; i++) {
        var cab = document.createElement("span");
        var newUploadBox = document.createElement("input");
        if (!addFileUploadBox.lastAssignedId)
            addFileUploadBox.lastAssignedId = 1;
        newUploadBox.setAttribute("id", "File" + addFileUploadBox.lastAssignedId);
        newUploadBox.setAttribute("name", "File" + addFileUploadBox.lastAssignedId);
        newUploadBox.setAttribute("type", "file");
        var index = document.createElement("b");
        index.innerHTML = addFileUploadBox.lastAssignedId;
        cab.appendChild(index);
        cab.appendChild(newUploadBox);
        var describe = document.createElement("describe");
        describe.innerHTML = "描述：";
        var titleBox = document.createElement("input");
        titleBox.setAttribute("id", "txtTitle" + addFileUploadBox.lastAssignedId);
        titleBox.setAttribute("name", "txtTitle" + addFileUploadBox.lastAssignedId);
        titleBox.setAttribute("type", "text");
        cab.appendChild(describe).appendChild(titleBox);
        uploadArea.appendChild(cab);
        addFileUploadBox.lastAssignedId++;
    }
    $("Bg2").style.backgroundPosition = "0px " + ($("Bg2").offsetHeight - 493 + "px");
}
//管理中模板页左边节点收缩或展开
function ToggleNode(obj) {
    var div = obj.parentNode.getElementsByTagName("DIV")[0];
    if (div.style.display == "") {
        obj.title = obj.title.substring(0, 3) + " 点击展开";
        div.style.display = "none";
    }
    else {
        obj.title = obj.title.substring(0, 3) + " 点击收缩";
        div.style.display = "";
    }
}

function Show(id) {
    $(id).style.display = '';
}
function Hide(id) {
    $(id).style.display = 'none';
}

function AddType(Oid, tbType, Fid) {
    if ($(tbType).value.Trim().length < 1) {
        alert("请输入分类名称！");
        return false;
    }
    if ($(tbType).value.replace(/[^\x00-\xff]/g, "aa").length > 10) {
        alert("自定义分类名称不能超过10个字符（五个汉字）");
        return false;
    }
    var op = new Option();
    op.text = op.value = $(tbType).value;
    $(Oid).options.add(op);
    $(Oid).options[$(Oid).options.length - 1].selected = true;
    $(Fid).style.display = "none";
}
function rpt(obj) {
    var n = obj.id.substring(1, 2);
    var a = obj.parentNode.getElementsByTagName("A");
    for (var i = 0; i < a.length; i++) {
        a[i].style.background = "none";
    }
    a[n].style.background = "url('./Images/imge/Album_btnk.gif')";
    $("rpt0").style.display = "none";
    $("rpt1").style.display = "none";
    $("rpt2").style.display = "none";
    var s = "rpt" + n;
    $(s).style.display = "block";
}
function bgChange(titID, conID, onStyle, offStyle, count, index) {
    for (var i = 1; i <= count; i++) {
        $(titID + i.toString()).className = offStyle;
        $(conID + i).style.display = 'none';
    }
    $(titID + index.toString()).className = onStyle;
    $(conID + index).style.display = '';
}
function DailyCh(index) {
    if (index == 1) {
        $('daily1').style.display = '';
        $('daily2').style.display = 'none';
        $('tit').style.backgroundPosition = "13px 3px";
    }
    else {
        $('daily1').style.display = 'none';
        $('daily2').style.display = '';
        $('tit').style.backgroundPosition = "118px 3px";
    }
}
function alertMe(Mes) {
    alert(Mes);
    window.location.href = window.location.href;
}
/*UserInfo   BEGIN*/
function UserInfoLoad() {
    addEventHandler(v4, "blur", function() {
        Utility.Show(v4, ' ', Check.CheckNull(v4.value.Trim(), 10));
    });
    addEventHandler(v6, "blur", function() {
        Utility.Show(v6, ' ', Check.CheckNull(v6.value.Trim(), 20, 6));
    });
    addEventHandler(v7, "blur", function() {
        Utility.Show(v7, ' ', v7.value.Trim() == v6.value.Trim());
    });
    addEventHandler(v8, "blur", function() {
        Utility.Show(v8, ' ', Check.CheckNull(v8.value.Trim(), 20, 6));
    });
}
function ChecKUserInfo() {
    var check1 = Check.CheckNull(v1.value.Trim(), 20);
    var check2 = Check.CheckNull(v2.value.Trim(), 20);
    var check3 = Check.CheckEMail(v3.value.Trim());
    var check4 = Check.CheckNull(v4.value.Trim());
    Utility.Show(v1, ' ', check1);
    Utility.Show(v2, ' ', check2);
    Utility.Show(v3, ' ', check3);
    Utility.Show(v4, ' ', check4);
    return check1 && check2 && check3 && check4;
}
function CheckChangePW() {
    var check6 = Check.CheckNull(v6.value.Trim(), 20, 6);
    var check7 = v7.value.Trim() == v6.value.Trim();
    var check8 = Check.CheckNull(v8.value.Trim(), 20, 6);
    Utility.Show(v6, ' ', check6);
    Utility.Show(v7, ' ', check7);
    Utility.Show(v8, ' ', check8);
    return check6 && check7 && check8;
}
/*UserInfo   END*/
/*UserInfo  FamilyInfo*/
function contentCh(IDName, count, index) {
    for (var i = 1; i <= count; i++) {
        $(IDName + i.toString()).style.display = 'none';
    }
    $(IDName + index.toString()).style.display = '';
}
/*FamilyInfo*/
function FamilyInfoLoad() {
    Utility.marginLeft = 145;
    addEventHandler(f1, "blur", function() { Utility.Show(f1, ' ', Check.CheckNull(f1.value.Trim(), 50)); });
    LoadRoomInfo($('ctl00_ContentPlaceHolder1_ddlRoom').value, 'ctl00_ContentPlaceHolder1_txtRoomName', 'ctl00_ContentPlaceHolder1_txtBulletin1');
}
function CheckAddRoom() {
    var fo1 = Check.CheckNull(f1.value.Trim(), 50);
    Utility.Show(f1, ' ', fo1);
    return fo1;
}

function LoadRoomInfo(roomId, txtRoomNameId, txtBulletinId) {
    ajax.url = "./WebService/EHome.asmx/GetRoomInfo?roomId=" + roomId;
    ajax.onSuccess = function() {
        $(txtRoomNameId).value = $(txtBulletinId).value = '';
        $(txtRoomNameId).value = ajax.xmlResult.getElementsByTagName("RoomName")[0].attributes[0].nodeValue;
        $(txtBulletinId).value = ajax.xmlResult.getElementsByTagName("Bulletin")[0].attributes[0].nodeValue;
        if ($(txtRoomNameId).value.Trim() == '我的房间' || $(txtRoomNameId).value.Trim() == '爸爸房间' || $(txtRoomNameId).value.Trim() == '妈妈房间')
            $(txtRoomNameId).disabled = true;
        else
            $(txtRoomNameId).disabled = false;
    };
    ajax.open();
}

function ChangeRoom(txtRoomNameId, ddlRoomId) {
    if (!Check.CheckNull($(txtRoomNameId).value.Trim(), 20)) return true;
    if ($(txtRoomNameId).value.Trim() == $(ddlRoomId).options[$(ddlRoomId).options.selectedIndex].text.Trim())
        return true;
    ajax.url = "./WebService/EHome.asmx/GetRoomInfo?roomName=" + escape($(txtRoomNameId).value) + '$foreName=' + escape($(ddlRoomId).options[$(ddlRoomId).options.selectedIndex].text);
    ajax.onSuccess = function() {
        if (ajax.response == "true") {
            alert('您修改的房间名称已经存在！');
            return false;
        }
        else
            return true;
    };
    ajax.open();
}
/*FamilyInfo*/
function MasterPage_Load(ExtraRoom, Period, roomIndex) {
    $("Bg2").style.backgroundPosition = "0px " + ($("Bg2").offsetHeight - 493 + "px");
    if (Utility.GetQuery("pid") == null) {
        $(Period).getElementsByTagName("A")[0].style.background = "url('./Images/imge/MyHome_Period2.gif') no-repeat";
    }
    else {
        $(Period).getElementsByTagName("A")[parseInt(Utility.GetQuery("pid"))].style.background = "url('./Images/imge/MyHome_Period2.gif') no-repeat";
    }
    var links = $("ROOM").getElementsByTagName("A");
    links[roomIndex].style.color = "#f8f8f8";
    if (roomIndex == 4)
        $("ROOM").style.background = "url('./Images/imge/MyHome_Active.gif') no-repeat " + ($("ROOM").offsetWidth - links[4].offsetWidth / 2 - 6) + "px 36px";
    else if (roomIndex == 0)
        $("ROOM").style.background = "url('./Images/imge/MyHome_Active.gif') no-repeat 66px 36px";
    else if (roomIndex == 1)
        $("ROOM").style.background = "url('./Images/imge/MyHome_Active.gif') no-repeat 135px 36px";
    else if (roomIndex == 2)
        $("ROOM").style.background = "url('./Images/imge/MyHome_Active.gif') no-repeat 219px 36px";
    else if (roomIndex == 3)
        $("ROOM").style.background = "url('./Images/imge/MyHome_Active.gif') no-repeat 305px 36px";
}


//计算字符长度
function calllength(obj) {
    var len = obj.value.replace(/[^\x00-\xff]/g, "aa").length;
    if (len > 400) {
        $("length").innerHTML = len;
        $("length").style.color = "red";
    }
    else {
        $("length").innerHTML = len;
        $("length").style.color = "black";
    }
}

var DailyM_Load = function() {
    imgPosition = function(obj) {
        var height = obj.clientHeight;
        var width = obj.clientWidth;
        var pt = height / 2 - obj.getElementsByTagName("IMG")[0].clientHeight / 2;
        var pl = width / 2 - obj.getElementsByTagName("IMG")[0].clientWidth / 2;
        obj.style.cssText = "padding-top:" + pt + "px; height:" + (height - pt) + "px; padding-left:" + pl + "px; width:" + (width - pl) + "px";
    }
    imgPosition($("MoodCab"));
    imgPosition($("WeatherCab"));
    $("Bg2").style.backgroundPosition = "0px " + ($("Bg2").offsetHeight - 493) + "px";

    if (isIE) {
        $("MyType").onclick = function() {
            $("Add").style.display = "";
            $("Col").innerHTML = "‹‹";
            $("Tip").style.display = "";
        }
        $("Col").onclick = function() {
            ShowObj($("Add"));
            if (this.innerHTML == "››") {
                this.innerHTML = "‹‹";
                $("Tip").style.display = "";
            }
            else {
                this.innerHTML = "››";
                $("Tip").style.display = "none";
            }
        }
        $("ST").onclick = function() {
            $("Types").style.display = "";
            this.style.display = "none";
            $(hfType).value = "1";
        }
        $("btnCancel").onclick = function() {
            this.parentNode.style.display = "none";
            $("ST").style.display = "";
            $(hfType).value = "";
        }
        $("ReadDraft").onclick = function() {
            var loc = Utility.nowLocation(this);
            $(Drafts).style.cssText = "position: absolute; padding:3px 6px; text-align:right; border:solid 1px #366EAE; background-color:White; left:" + (loc.x - 210) + "px; top:" + (loc.y + 20) + "px;";
            for (var i = 0; i < $(Drafts).getElementsByTagName("A").length; i++) {
                $(Drafts).getElementsByTagName("A")[i].style.cssText = "display: block; padding: 4px 13px; color: #111; font-size: 11px; font-family: Verdana,Arial; ";
            }
        }
        $(Drafts).onmousemove = function() { this.style.display = ''; }
        $(Drafts).onmouseout = function() { this.style.display = 'none'; }
        $(btnSaveDraft).onclick = function() {
            KindSubmit();
        }
        $(btnOK).onclick = function() {
            KindSubmit();
            if ($(txtDiaryTitle).value.Trim().length == 0) {
                alert("请填写日记标题！");
                return false;
            }
            else if ($(content).value.Trim().length == 0) {
                alert("请填写日记内容！");
                return false;
            }
            return true;
        }
        $("Leave").onclick = function() {
            if (confirm("您确定要离开当前页面转向日记列表页？\n 您正在编辑的内容将会丢失！") == true)
                self.location = "./MyDaily.aspx";
        }
    }
    else {
        $("MyType").setAttribute("onclick", "$('Add').style.display = ''; $('Col').innerHTML = '‹‹'; $('Tip').style.display = '';");
        $("Col").setAttribute("onclick", "ShowObj($('Add')); if (this.innerHTML == '››') { this.innerHTML = '‹‹'; $('Tip').style.display = ''; } else { this.innerHTML = '››'; $('Tip').style.display = 'none'; }");
        $("ST").setAttribute("onclick", "$('Types').style.display = ''; this.style.display = 'none'; $(hfType).value = '1';");
        $("btnCancel").setAttribute("onclick", "this.parentNode.style.display = 'none'; $(ST).style.display = ''; $(hfType).value = '0';");
        $("ReadDraft").setAttribute("onclick", "var loc = Utility.nowLocation(this); $(Drafts).style.cssText = 'position: absolute; padding:3px 6px; text-align:right; border:solid 1px #366EAE; background-color:White; left:' + (loc.x - 210) + 'px; top:' + (loc.y + 20) + 'px;'; for (var i = 0; i < $(Drafts).getElementsByTagName('A').length; i++) { $(Drafts).getElementsByTagName('A')[i].style.cssText = 'display: block; padding: 4px 13px; color: #111; font-size: 11px; font-family: Verdana,Arial;'; }");
        $(Drafts).setAttribute("onmousemove", "this.style.display = '';")
        $(Drafts).setAttribute("onmouseout", "this.style.display = 'none';")
        $(btnSaveDraft).setAttribute("onclick", "KindSubmit();");
        $(btnOK).setAttribute("onclick", "KindSubmit(); if ($(txtDiaryTitle).value.Trim().length == 0) { alert('请填写日记标题！'); return false; } else if ($(content).value.Trim().length == 0) { alert('请填写日记内容！'); return false; } return true;");
        $("Leave").setAttribute("onclick", "if (confirm('您确定要离开当前页面转向日记列表页？\n 您正在编辑的内容将会丢失！') == true) self.location = './MyDaily.aspx';");
    }
}
function LoadMoods(me) {
    if ($("Moods")) {
        $("Moods").style.display = "";
        return;
    }
    var Moods = document.createElement("DIV");
    if (isIE) {
        Moods.onmousemove = function() { this.style.display = ""; }
        Moods.onmouseout = function() { this.style.display = "none"; }
    }
    else {
        Moods.setAttribute("onmousemove", "this.style.display='';");
        Moods.setAttribute("onmouseout", "this.style.display = 'none';");
    }
    Moods.id = "Moods";
    var html = "";
    XmlLoad.xmlUrl = "./Xml/etype.xml";        //载入XMl
    var doc = XmlLoad.xmlDoc(XmlLoad.xmlUrl);
    var ms = doc.getElementsByTagName("mood");
    for (var i = 0; i < ms.length; i++) {
        html += "<span><img src='./Images/face/" + ms[i].attributes[2].nodeValue + "' alt='" + ms[i].attributes[1].nodeValue + "' title='" + ms[i].attributes[0].nodeValue + "' /></span>";
    }
    Moods.innerHTML = html;
    var loc = Utility.nowLocation(me);
    Moods.style.cssText = "position: absolute; border:solid 1px #366EAE; background-color:White; left:" + (loc.x - 10) + "px; top:" + (loc.y + 25) + "px;";
    for (var i = 0; i < Moods.getElementsByTagName("SPAN").length; i++) {
        Moods.getElementsByTagName("SPAN")[i].style.cssText = "display: block; margin: 1px; padding: 4px 6px; cursor: pointer; border: solid 1px #f9f9f9; background-color: #EEF7FF;";
        if (isIE) {
            Moods.getElementsByTagName("SPAN")[i].onmouseover = function() { this.style.backgroundColor = "#84F7FF"; }
            Moods.getElementsByTagName("SPAN")[i].onmouseout = function() { this.style.backgroundColor = "#EEF7FF"; }
            Moods.getElementsByTagName("SPAN")[i].onclick = function() {
                $(ImgMood).title = this.childNodes[0].title;
                $(ImgMood).src = this.childNodes[0].src;
                $(hfMood).value = this.childNodes[0].title;
                this.parentNode.style.display = "none";
            }
        }
        else {
            Moods.getElementsByTagName("SPAN")[i].setAttribute("onmouseover", "this.style.backgroundColor = '#84F7FF';");
            Moods.getElementsByTagName("SPAN")[i].setAttribute("onmouseout", "this.style.backgroundColor = '#EEF7FF';");
            Moods.getElementsByTagName("SPAN")[i].setAttribute("onclick", " $(ImgMood).title = this.childNodes[0].title; $(ImgMood).src = this.childNodes[0].src; $(hfMood).value = this.childNodes[0].title; this.parentNode.style.display = 'none';");
        }
    }
    document.body.appendChild(Moods);
}

function LoadWeathers(me) {
    if ($("Weathers")) {
        $("Weathers").style.display = "";
        return;
    }
    var Weathers = document.createElement("DIV");
    if (isIE) {
        Weathers.onmousemove = function() { this.style.display = ''; }
        Weathers.onmouseout = function() { this.style.display = 'none'; }
    }
    else {
        Weathers.setAttribute("onmousemove", "this.style.display='';");
        Weathers.setAttribute("onmouseout", "this.style.display = 'none';");
    }
    Weathers.id = "Weathers";
    var html = "";
    XmlLoad.xmlUrl = "./Xml/EType.xml";        //载入XMl
    var doc = XmlLoad.xmlDoc(XmlLoad.xmlUrl);
    var ms = doc.getElementsByTagName("weather");
    for (var i = 0; i < ms.length; i++) {
        html += "<span><img src='./Images/face/" + ms[i].attributes[2].nodeValue + "' alt='" + ms[i].attributes[1].nodeValue + "' title='" + ms[i].attributes[0].nodeValue + "' /></span>";
    }
    Weathers.innerHTML = html;
    var loc = Utility.nowLocation(me);
    Weathers.style.cssText = "position: absolute; border:solid 1px #366EAE; background-color:White; left:" + (loc.x - 10) + "px; top:" + (loc.y + 27) + "px;";
    for (var i = 0; i < Weathers.getElementsByTagName("SPAN").length; i++) {
        Weathers.getElementsByTagName("SPAN")[i].style.cssText = "display: block; margin: 1px; padding: 4px 6px; cursor: pointer; border: solid 1px #f9f9f9; background-color: #EEF7FF;";
        if (isIE) {
            Weathers.getElementsByTagName("SPAN")[i].onmouseover = function() { this.style.backgroundColor = "#84F7FF"; }
            Weathers.getElementsByTagName("SPAN")[i].onmouseout = function() { this.style.backgroundColor = "#EEF7FF"; }
            Weathers.getElementsByTagName("SPAN")[i].onclick = function() {
                $(ImgWeather).title = this.childNodes[0].title;
                $(ImgWeather).src = this.childNodes[0].src;
                $(hfWeather).value = this.childNodes[0].title;
                this.parentNode.style.display = "none";
            }
        }
        else {
            Weathers.getElementsByTagName("SPAN")[i].setAttribute("onmouseover", "this.style.backgroundColor = '#84F7FF';");
            Weathers.getElementsByTagName("SPAN")[i].setAttribute("onmouseout", "this.style.backgroundColor = '#EEF7FF';");
            Weathers.getElementsByTagName("SPAN")[i].setAttribute("onclick", "$(ImgWeather).title = this.childNodes[0].title; $(ImgWeather).src = this.childNodes[0].src; $(hfWeather).value = this.childNodes[0].title; this.parentNode.style.display = 'none';");
        }
    }
    document.body.appendChild(Weathers);
}

//写日记中添加类别
function AddStype(obj) {
    if ($("txtSType").value.length == 0)
        alert("对不起，请您不要使用空分类名称！");
    else if ($("txtSType").value.replace(/[^\x00-\xff]/g, "aa").length > 10)
        alert("对不起，自定义分类名称不能超过10个字符/五个汉字。");
    else {
        var op = new Option();
        op.text = op.value = $("txtSType").value;
        $(ddlSType).options.add(op);
        $(ddlSType).options[$(ddlSType).options.length - 1].selected = true;
        $("Col").innerHTML = "››";
        $("Add").style.display = "none";
        $("Tip").style.display = "none";
    }
}

//载入xml
var XmlLoad = {
    xmlUrl: '',
    xmlDoc: function(xmlUrl) {
        var isIE = (document.all);
        if (isIE) {
            xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
        } else {
            xmlDoc = document.implementation.createDocument("", "", null);
        }
        try {
            xmlDoc.async = false;
            xmlDoc.load(xmlUrl);
            return (xmlDoc);
        } catch (e) { alert(e.message) }
        return (null);
    }
}

//AJAX创建相册
function CreateAlbum(me) {
    if ($("Message")) {
        $("Message").style.display = "";
        return;
    }
    var msg = document.createElement("div");
    msg.id = "Message";
    msg.className = "message";
    var title = document.createElement("div");
    title.id = "MessageTitle";
    title.innerHTML = "创建相册<div><span onclick='MessageHide();'></span></div>";
    title.className = "msgTitle";
    msg.appendChild(title);
    var content = document.createElement("div");
    content.id = "Content";
    XmlLoad.xmlUrl = "./Xml/etype.xml";        //载入XML
    var doc = XmlLoad.xmlDoc(XmlLoad.xmlUrl);
    var types = doc.getElementsByTagName("photo");
    var contentHtml = "相册名称：<input id='txtName' type='text' onkeyup='InputTip(this, 50, \"Tip\")' class='name' /><p class='tip'>您已输入<b id='Tip'>0</b>个字符（最多<b>50</b>个字符）</p><p class='limit'>系统分类：<select id='sltType'>";
    for (var i = 0; i < types.length; i++)
        contentHtml += "<option value='" + types[i].attributes[1].nodeValue + "'>" + types[i].attributes[0].nodeValue + "</option>";
    var limits = doc.getElementsByTagName("limit");
    contentHtml += "</select></p><p class='limit'>访问权限：<select id='sltLimit'>";
    for (var i = 0; i < limits.length; i++)
        contentHtml += "<option value='" + limits[i].attributes[1].nodeValue + "'>" + limits[i].attributes[0].nodeValue + "</option>";
    contentHtml += "</select></p><p class='tip'><input id='btnCreate' type='button' value='确定' onclick='CreateA();' class='mBtn' /><input id='btnDrop' type='button' value='取消' onclick='MessageHide();' class='mBtn' /></p>";
    content.innerHTML = contentHtml;
    content.className = "con";
    msg.appendChild(content);
    var loc = Utility.nowLocation(me);
    msg.style.left = loc.x + 'px';
    msg.style.top = loc.y + 20 + 'px';
    msg.style.position = 'absolute';
    document.body.appendChild(msg);
    var drag = new Drag("Message", { mxContainer: "Message", Handle: "MessageTitle", limit: true });
}

function CreateA(aid) {
    if ($("txtName").value.Trim().length == 0) {
        alert("请填写相册名称！");
        return;
    }
    else if ($("txtName").value.replace(/[^\x00-\xff]/g, "aa").length > 50) {
        alert("相册名称请不要超过50个字符！");
        return;
    }
    else if ($("txtName").value.Trim() == "默认相册") {
        alert("抱歉，默认相册为系统相册，请选择另一个名字！");
        return;
    }

    ajax.url = "./WebService/EHome.asmx/CreateAlbum?param=" + escape($("txtName").value.Trim() + "|" + $("sltType").value + "|" + $("sltLimit").value);
    ajax.onSuccess = onSuccess;
    ajax.open();

    function onSuccess() {
        if (ajax.response != "0") {
            $("Message").style.display = "none";
            var op = new Option();
            op.text = $("txtName").value;
            op.value = ajax.response;
            $(ddlAlbums).options.add(op);
            $(ddlAlbums).options[$(ddlAlbums).options.length - 1].selected = true;
        } else { alert("对不起，创建相册失败，请重试!"); }
    }
}

//检查回复字数
function CheckComent() {            //检查评论字数
    if ($(comment).value.Trim() == 0) {
        alert("请填写回复内容！");
        return false;
    }
    else if ($(comment).value.Trim().replace(/\r\n/ig, "<br>").replace(/\n/ig, "<br>").length > 400) {
        alert("字数超过限制，请限制在400字符内！");
        return false;
    }
}
//检查输入是否为空FriendM.aspx
function NameCheck() {
    if (!Check.CheckNull($("ctl00_ContentPlaceHolder1_TextBox1").value.Trim())) {
        alert("请输入名称");
        return false;
    }
    return true;
}

//确认删除,先判断有没有ckeckbox被选中  Book,Collect
function suredel() {
    var a = $("rpt").getElementsByTagName("input");
    var b = $("rpt").getElementsByTagName("input").length;
    for (var i = 0; i < b; i++) {
        if (a[i].checked == true) {
            if (confirm("确定要删除吗？"))
                return true;
            else
                return false;
        }
    }
    alert("请选择要删除的项!");
    return false;
}

//Book,Collect
function changetype() {
    var a = $("rpt").getElementsByTagName("input");
    var b = $("rpt").getElementsByTagName("input").length;
    for (var i = 0; i < b; i++) {
        if (a[i].checked == true) {
            return true;
        }
    }
    alert("请选择要转移的项!");
    return false;
}

//Book, Collect
function ckb(obj) {
    var a = $("rpt").getElementsByTagName("input");
    var b = $("rpt").getElementsByTagName("input").length;
    if (obj.title == "全选") {
        for (var i = 0; i < b; i++) {
            a[i].checked = true;
        }
        obj.title = "反选";
    }
    else {
        for (var i = 0; i < b; i++) {
            if (a[i].checked == true)
                a[i].checked = false;
            else {
                a[i].checked = true;
            }
        }
        obj.title = "全选";
    }
}

function monthChange(obj, day) {
    var d = $(day);
    var dat = new Date('2004', obj.value, 0);
    for (var i = 0; i < d.options.length; )
        d.remove(0);
    for (var i = 1; i < dat.getDate() + 1; i++) {
        var op = new Option();
        op.value = i;
        op.text = i
        d.options.add(op);
    }
}
historyLoad = function() {
    var m = $('month');
    var d = $('day');
    for (var i = 1; i <= 12; i++) {
        var op = new Option();
        op.value = i;
        op.text = i
        m.options.add(op);
    }
    for (var i = 1; i <= 31; i++) {
        var op = new Option();
        op.value = i;
        op.text = i
        d.options.add(op);
    }
    var dat = new Date();
    var dIndex = Utility.GetQuery("d");
    d.value = dIndex == null ? dat.getDate() : dIndex;
    var mIndex = Utility.GetQuery("m");
    m.value = mIndex == null ? (dat.getMonth() + 1) : mIndex;
}
historySearch = function() {
    window.location.href = 'history.aspx?m=' + $('month').value + "&d=" + $('day').value;
}


//2009-1-14   邹晓锋   添加 修改相册名称、权限     
function EditAlbum(me) {
    if ($('Message'))
        document.body.removeChild($("Message"));
    var msg = document.createElement("div");
    msg.id = "Message";
    msg.className = "message";
    var title = document.createElement("div");
    var aNameLink = me.parentNode.parentNode.getElementsByTagName("DIV")[1].childNodes[0];
    aNameLink.id = "AlbumLink";
    var aName = aNameLink.innerHTML;
    aName = aName.length > 10 ? (aName.substring(0, 10) + "...") : aName;
    title.innerHTML = "编辑相册：" + aName + " <div><span onclick='document.body.removeChild($(\"Message\"));'></span></div>";
    title.className = "msgTitle";
    title.id = 'MessageTitle';
    msg.appendChild(title);
    var content = document.createElement("div");
    content.id = "Content";

    XmlLoad.xmlUrl = "./Xml/etype.xml";        //载入XMl
    var doc = XmlLoad.xmlDoc(XmlLoad.xmlUrl);
    var types = doc.getElementsByTagName("photo");
    var contentHtml;
    if (aName == "默认相册")
        contentHtml = "相册名称：<input id='txtName' type='text' onkeydown='return false;' class='name' value='" + aNameLink.innerHTML + "' /><p class='tip'>默认相册不能修改名称</p><p class='limit'>系统分类：<select id='sltType'>";
    else
        contentHtml = "相册名称：<input id='txtName' type='text' onkeyup='InputTip(this, 50, \"Tip\")' class='name' value='" + aNameLink.innerHTML + "' /><p class='tip'>您已输入<b id='Tip'>0</b>个字符（最多<b>50</b>个字符）</p><p class='limit'>系统分类：<select id='sltType'>";
    for (var i = 0; i < types.length; i++)
        contentHtml += "<option value='" + types[i].attributes[1].nodeValue + "'>" + types[i].attributes[0].nodeValue + "</option>";
    var limits = doc.getElementsByTagName("limit");
    contentHtml += "</select></p><p class='limit'>访问权限：<select id='sltLimit'>";
    for (var i = 0; i < limits.length; i++)
        contentHtml += "<option value='" + limits[i].attributes[1].nodeValue + "'>" + limits[i].attributes[0].nodeValue + "</option>";
    contentHtml += "</select></p><p class='tip'><input id='btnCreate' type='button' value='确定' onclick='EditA(" + me.id + ", \"AlbumLink\");' class='mBtn' /><input id='btnDrop' type='button' value='取消' onclick='MessageHide();' class='mBtn' /></p>";
    content.innerHTML = contentHtml;
    content.className = "con";
    msg.appendChild(content);
    var loc = Utility.nowLocation(me);
    msg.style.left = loc.x - 150 + 'px';
    msg.style.top = loc.y + 45 + 'px';
    msg.style.position = 'absolute';
    document.body.appendChild(msg);
    var drag = new Drag("Message", { mxContainer: "Message", Handle: "MessageTitle", limit: true });
}

function EditA(aid, linkid) {
    if ($("txtName").value.Trim().length == 0) {
        alert("请填写相册名称！");
        return;
    }
    else if ($("txtName").value.replace(/[^\x00-\xff]/g, "aa").length > 50) {
        alert("相册名称请不要超过50个字符！");
        return;
    }

    ajax.url = "./WebService/EHome.asmx/EditAlbum?param=" + escape(aid + "|" + $("txtName").value.Trim() + "|" + $("sltType").value + "|" + $("sltLimit").value);
    ajax.onSuccess = onSuccess;
    ajax.open();

    function onSuccess() {
        var Root = ajax.xmlResult.documentElement;
        if (Root.attributes[0].nodeValue != "0") {
            $(linkid).innerHTML = $("txtName").value;
            $(linkid).title = $("txtName").value;
            $(linkid).parentNode.parentNode.getElementsByTagName("A")[0].title = $("txtName").value;
            $(linkid).parentNode.parentNode.getElementsByTagName("DIV")[3].innerHTML = "系统分类：" + $("sltType").options[$("sltType").selectedIndex].text;
            $(linkid).parentNode.parentNode.getElementsByTagName("DIV")[4].innerHTML = "查看权限：" + $("sltLimit").options[$("sltLimit").selectedIndex].text;
            $(linkid).id = "";
            document.body.removeChild($("Message"));
        } else { alert("对不起，编辑相册失败，请重试!"); }
    }
}
/*Account*/
function AccountSearch() {
    var t1 = $('tbTime1').value.Trim();
    var t2 = $('tbTime2').value.Trim();
    if (t1.length < 1 || t2.length < 1) {
        alert("请选择日期"); return;
    }
    window.location.href = "account.aspx?tp=" + $('ctl00_ContentPlaceHolder1_ddlSType').value + "&t1=" + t1 + "&t2=" + t2;
}

/*  显示添加分类  
20009-01-14 16:50 添加
*/
function ShowCollect(obj, id) {
    $(id).style.display = '';
    obj.style.display = "none";
}
function AddCollectType(Oid, tbType, Fid, obtn) {
    if ($(tbType).value.Trim().length < 1) {
        alert("请输入分类名称！");
        return false;
    }
    if ($(tbType).value.replace(/[^\x00-\xff]/g, "aa").length > 10) {
        alert("自定义分类名称不能超过10个字符（五个汉字）");
        return false;
    }
    var op = new Option();
    op.text = op.value = $(tbType).value;
    $(Oid).options.add(op);
    $(Oid).options[$(Oid).options.length - 1].selected = true;
    $(Fid).style.display = "none";
    $(obtn).style.display = '';
}

/*添加收藏 BEGIN*/
function Login() {
    Renjoin.Fail = function() {
        alert('用户名或密码错误');
    };
    Renjoin.Login(escape($('loginName').value.Trim()), escape($('loginPassword').value.Trim()));
}
function AddCollect() {
    Renjoin.Success = function() {
        closeDiv();
        Utility.Handle = OpenCollect;
        Utility.OpenDiv();
        InitCollect();
    };
    Renjoin.Fail = function() {
        Utility.Handle = CreateLogin;
        Utility.OpenDiv();
    };
    Renjoin.CheckLogin();
}
function OpenCollect() {
    var str = "<p style=\"padding: 0; margin: 0; height: 32px; background: url(./Images/1.gif) no-repeat;line-height: 32px;\"><a href=\"#\" onclick=\"closeDiv()\" style=\"margin-right: 10px; display: block; width: 18px; height: 28px; float:right;\"></a></p><div style=\"padding: 0; margin: 0; border: 1px solid #ffb24d; border-top: none; padding:10px 20px 10px 20px; background:#fff;\"><p style=\" padding:0; margin:10px 0;\">分类：<select id=\"opType\"><option value=\"默认分类\">默认分类</option></select><input type=\"button\" id=\"Add_AddType\" value=\"添加分类\" onclick=\"ShowCollect(this,'AddCollectType')\" style=\" margin-left:20px; width:63px; height:23px; background:url(./Images/2.gif) no-repeat;border:none;\"  /><span id=\"AddCollectType\" style=\" display:none;\"><input type=\"text\" id=\"Add_txtType\" style=\"width: 100px; border: 1px solid #ffb24d; margin:0 10px;\" /><input type=\"button\" value=\"添加\"   style=\"width:63px; height:23px; background:url(./Images/2.gif) no-repeat;border:none;\" onclick=\"AddCollectType('opType','Add_txtType','AddCollectType','Add_AddType')\" /></span></p><p style=\" padding:0; margin-top:10px;\">名称：<input type=\"text\" id='Add_txtInfo' style=\"padding: 1px; width: 250px; font-size: 12px; border: 1px solid #ffb24d;\" /></p><p style=\"margin-top:0px; padding:0px 30px; text-align: right;\">（最多<b>50</b>个字符）</p><p style=\" padding:0; margin:10px 0;\">链接：<input type=\"text\" readonly=\"readonly\" id='Add_txtLink' style=\" border: 1px solid #ffb24d;width:250px;\"/></p><p style=\" padding:0; margin:10px 0; text-align:center;\"><input type=\"button\" value=\"确认\"  onclick='SetColloct()' style=\"width:63px; height:23px; background:url(./Images/2.gif) no-repeat;border:none;\" /><input type=\"button\" value=\"取消\"  style=\"width:63px; height:23px; background:url(./Images/2.gif) no-repeat; border:none; margin-left:20px;\"  onclick=\"closeDiv()\" /></p></div>";
    loginFrame = document.createElement("div");
    loginFrame.id = "openDiv";
    loginFrame.style.width = "367px";
    loginFrame.style.height = "251px";
    loginFrame.style.position = "absolute";
    loginFrame.style.zIndex = '999';
    var arrayPageSize = getPageSize(); //调用getPageSize()函数
    var arrayPageScroll = getPageScroll(); //调用getPageScroll()函数
    loginFrame.style.top = arrayPageScroll[1] + (arrayPageSize[3] - 251) / 2 - 50 + 'px';
    loginFrame.style.left = (arrayPageSize[0] - 367) / 2 - 30 + 'px';
    loginFrame.innerHTML = str;
    document.body.appendChild(loginFrame);
    addEventHandler($('openDiv'), 'keydown', function(event) { if (event.keyCode == 13) { SetColloct() } });
}
function GetCollectType(Tid) {
    var ddlcity = document.getElementById(Tid);
    ddlcity.length = 0;
    ajax.url = "./WebService/EHome.asmx/GetCollectType";
    ajax.onSuccess = onSuccess;
    ajax.open();
    function onSuccess() {
        var citys = ajax.xmlResult.getElementsByTagName("type");
        for (var i = 0; i < citys.length; i++) {
            var op = new Option();
            op.text = citys[i].attributes[0].nodeValue;
            op.value = citys[i].attributes[0].nodeValue;
            ddlcity.options.add(op);
        }
    }
}
function InitCollect() {
    GetCollectType('opType');
    $('Add_txtLink').value = window.document.URL;
    $('Add_txtInfo').value = window.document.title.substring(0, window.document.title.indexOf("_"));
}
function SetColloct() {
    var type = $('opType').value.Trim();
    var link = $('Add_txtLink').value.Trim();
    var info = $('Add_txtInfo').value.Trim();
    ajax.url = "./WebService/EHome.asmx/SetCollect?type=" + escape(type) + "|" + escape(link) + "|" + escape(info);
    ajax.onSuccess = function() {
        if (ajax.response == "true") {
            alert('添加成功');
        }
        else {
            alert('添加失败');
        }
        closeDiv();
    }
    ajax.open();
}
function CreateLogin() {
    var str = "<p style=\"padding: 0; margin: 0; height: 32px; background: url(./Images/as.gif) no-repeat;text-align: right; line-height: 32px;\"><a href=\"#\" onclick=\"closeDiv()\" style=\"margin-right: 10px; display: block; width: 18px; height: 28px; float:right;\"></a></p><div style=\"background:#fff;padding: 0; margin: 0; border: 1px solid #ffb24d; border-top: none; height: 120px;padding: 20px 20px 10px 20px;\"><p style=\"padding: 0; margin: 10px 0;\">用户名：<input type=\"text\" id='loginName' style=\"width: 130px; border: 1px solid #ffb24d;\" /></p><p style=\"padding: 0; margin: 10px 0;\"><span style=\"margin-right: 12px;\">密</span>码：<input type=\"password\"  id='loginPassword' style=\"width: 130px;border: 1px solid #ffb24d; margin-right: 20px;\" /><a href='http://www.renjoin.com/common/Getpwd.aspx'>忘记密码?</a></p><p style=\"padding: 0; margin-top: 20px; text-align: center;\"><input type=\"button\" value=\"登录\" style=\"width: 63px; height: 23px; background: url(./Images/2.gif) no-repeat;border: none;\"  onclick='Login()' /><input type=\"button\" value=\"注册\" style=\"width: 63px; height: 23px;background: url(./Images/2.gif) no-repeat; border: none; margin-left: 35px;\"onclick=\"window.open('http://www.renjoin.com/common/RenjoinReg.aspx')\" /></p></div>";
    loginFrame = document.createElement("div");
    loginFrame.id = "openDiv";
    loginFrame.style.width = "300px";
    loginFrame.style.height = "150px";
    loginFrame.style.position = "absolute";
    loginFrame.style.zIndex = '999';
    var arrayPageSize = getPageSize(); //调用getPageSize()函数
    var arrayPageScroll = getPageScroll(); //调用getPageScroll()函数
    loginFrame.style.top = arrayPageScroll[1] + (arrayPageSize[3] - 150) / 2 - 50 + 'px';
    loginFrame.style.left = (arrayPageSize[0] - 300) / 2 - 30 + 'px';
    loginFrame.innerHTML = str;
    document.body.appendChild(loginFrame);
    addEventHandler($('openDiv'), 'keydown', function(event) { if (event.keyCode == 13) { Login(); } });
}
function closeDiv() {
    Utility.CloseDiv('layer');
    Utility.CloseDiv('openDiv');
}
function getPageSize() {
    var xScroll, yScroll;

    if (window.innerHeight && window.scrollMaxY) {
        xScroll = document.body.scrollWidth;
        yScroll = window.innerHeight + window.scrollMaxY;
    } else if (document.body.scrollHeight > document.body.offsetHeight) {
        sScroll = document.body.scrollWidth;
        yScroll = document.body.scrollHeight;
    } else {
        xScroll = document.body.offsetWidth;
        yScroll = document.body.offsetHeight;
    }

    var windowWidth, windowHeight;
    //var pageHeight,pageWidth;
    if (self.innerHeight) {
        windowWidth = self.innerWidth;
        windowHeight = self.innerHeight;
    } else if (document.documentElement && document.documentElement.clientHeight) {
        windowWidth = document.documentElement.clientWidth;
        windowHeight = document.documentElement.clientHeight;
    } else if (document.body) {
        windowWidth = document.body.clientWidth;
        windowHeight = document.body.clientHeight;
    }

    var pageWidth, pageHeight
    if (yScroll < windowHeight) {
        pageHeight = windowHeight;
    } else {
        pageHeight = yScroll;
    }
    if (xScroll < windowWidth) {
        pageWidth = windowWidth;
    } else {
        pageWidth = xScroll;
    }
    arrayPageSize = new Array(pageWidth, pageHeight, windowWidth, windowHeight)
    return arrayPageSize;
}
//获取滚动条的高度
function getPageScroll() {
    var yScroll;
    if (self.pageYOffset) {
        yScroll = self.pageYOffset;
    } else if (document.documentElement && document.documentElement.scrollTop) {
        yScroll = document.documentElement.scrollTop;
    } else if (document.body) {
        yScroll = document.body.scrollTop;
    }

    arrayPageScroll = new Array('', yScroll)
    return arrayPageScroll;
}

/*添加收藏 END*/

//Photos.aspx 在用户看自己照片时执行
function Photos_load(imgLink) {
    ps = $("Cab").getElementsByTagName("P");
    for (var i = 0; i < ps.length; i++) {
        if (ps[i].className == "manage") {
            ps[i].style.display = '';
        }
    }
    var imgs = $("Cab").getElementsByTagName("IMG");
    for (var i = 0; i < imgs.length; i++) {
        if (imgs[i].src.substring(imgs[i].src.indexOf("/s_") + 3, imgs[i].src.length - 4) == imgLink)
            imgs[i].parentNode.parentNode.parentNode.getElementsByTagName("INPUT")[0].checked = true;
    }
}
//Photos.aspx 选择封面
function ChooseCover(obj) {
    if (obj.checked == true) {
        var inputs = $("Cab").getElementsByTagName("INPUT");
        for (var i = 0; i < inputs.length; i++) {
            inputs[i].checked = false;
        }
        obj.checked = true;
        var img = obj.parentNode.parentNode.getElementsByTagName("IMG")[0];
        ajax.url = "./WebService/EHome.asmx/SetCover?param=" + ($("AlbumID").value + "|" + img.src.substring(img.src.indexOf("/s_") + 3, img.src.length));
        ajax.onSuccess = function() {
            if (ajax.response == "true")
                alert("设置成功！");
        }
        ajax.open();
    }
}

function EditPhoto(me, periodId) {
    if ($('Message'))
        document.body.removeChild($("Message"));
    var msg = document.createElement("div");
    msg.id = "Message";
    msg.className = "message";
    var title = document.createElement("div");
    var photoLink = me.parentNode.parentNode.getElementsByTagName("P")[0].getElementsByTagName("A")[0];
    photoLink.id = "PhotoLink";
    var pName = photoLink.innerHTML.Trim();
    pName = pName.length > 10 ? (pName.substring(0, 10) + "...") : pName;
    title.innerHTML = "编辑照片：" + pName + " <div><span onclick='document.body.removeChild($(\"Message\"));'></span></div>";
    title.className = "msgTitle";
    title.id = 'MessageTitle';
    msg.appendChild(title);
    var content = document.createElement("div");
    content.id = "Content";

    var contentHtml;
    contentHtml = "照片名称：<input id='txtName' type='text' onkeyup='InputTip(this, 50, \"Tip\")' class='name' value='" + pName + "' /><p class='tip'>您已输入<b id='Tip'>0</b>个字符（最多<b>50</b>个字符）</p><p class='limit'>选择相册：<select id='sltAlbum'>";
    for (var i = 0; i < $($("Albums").value).options.length; i++)
        contentHtml += "<option value='" + $($("Albums").value).options[i].value + "'>" + $($("Albums").value).options[i].text + "</option>";
    contentHtml += "</select></p><p class='limit'>选择时期：<select id='sltPeriod'>";
    XmlLoad.xmlUrl = "./Xml/etype.xml";        //载入XMl
    var doc = XmlLoad.xmlDoc(XmlLoad.xmlUrl);
    var periods = doc.getElementsByTagName("stage");
    for (var i = 0; i < periods.length; i++)
        contentHtml += "<option value='" + periods[i].attributes[1].nodeValue + "'>" + periods[i].attributes[0].nodeValue + "</option>";
    contentHtml += "</select></p><p class='tip'><input id='btnCreate' type='button' value='确定' onclick='EditP(" + me.id + ", \"PhotoLink\");' class='mBtn' /><input id='btnDrop' type='button' value='取消' onclick='MessageHide();' class='mBtn' /></p>";
    content.innerHTML = contentHtml;
    content.className = "con";
    msg.appendChild(content);
    var loc = Utility.nowLocation(me);
    msg.style.left = loc.x + 'px';
    msg.style.top = loc.y + 15 + 'px';
    msg.style.position = 'absolute';
    document.body.appendChild(msg);
    for (var i = 0; i < $("sltAlbum").options.length; i++) {
        if ($("sltAlbum").options[i].value == Utility.GetQuery("pi"))
            $("sltAlbum").options[i].selected = true;
    }
    $("sltPeriod").options[periodId - 1].selected = true;
    var drag = new Drag("Message", { mxContainer: "Message", Handle: "MessageTitle", limit: true });
}
function EditP(pid, linkid) {
    if ($("txtName").value.Trim().length == 0) {
        alert("请填写照片名称！");
        return;
    }
    else if ($("txtName").value.replace(/[^\x00-\xff]/g, "aa").length > 50) {
        alert("照片名称请不要超过50个字符！");
        return;
    }
    var IsCover = 0;
    if ($(linkid).parentNode.parentNode.getElementsByTagName("INPUT")[0].checked == true)
        IsCover = 1;
    ajax.url = "./WebService/EHome.asmx/EditPhoto?param=" + escape(pid + "|" + Utility.GetQuery("pi") + "|" + $("sltAlbum").value + "|" + $("txtName").value.Trim() + "|" + $("sltPeriod").value + "|" + IsCover);
    ajax.onSuccess = onSuccess;
    ajax.open();

    function onSuccess() {
        var Root = ajax.xmlResult.documentElement;
        if (Root.attributes[0].nodeValue != "0") {
            if (Utility.GetQuery("pi") != $("sltAlbum").value)
                self.location = "./Photos.aspx?pi=" + Utility.GetQuery("pi");
            else {
                $(linkid).innerHTML = $("txtName").value;
                $(linkid).title = $("txtName").value;
                $(linkid).parentNode.parentNode.getElementsByTagName("A")[0].title = $("txtName").value;
                $(linkid).parentNode.parentNode.getElementsByTagName("P")[1].innerHTML = "时期：" + $("sltPeriod").options[$("sltPeriod").selectedIndex].text;
            }
            $(linkid).id = "";
            document.body.removeChild($("Message"));
        } else { alert("对不起，编辑照片失败，请重试!"); }
    }
}

function ShowLogin() {
    Utility.Handle = CreateLogin;
    Utility.OpenDiv();
}