﻿/**
* hoverIntent r5 // 2007.03.27 // jQuery 1.1.2+
* <http://cherne.net/brian/resources/jquery.hoverIntent.html>
* 
* @param  f  onMouseOver function || An object with configuration options
* @param  g  onMouseOut function  || Nothing (use configuration options object)
* @author    Brian Cherne <brian@cherne.net>
*/
(function($) { $.fn.hoverIntent = function(f, g) { var cfg = { sensitivity: 7, interval: 100, timeout: 0 }; cfg = $.extend(cfg, g ? { over: f, out: g} : f); var cX, cY, pX, pY; var track = function(ev) { cX = ev.pageX; cY = ev.pageY; }; var compare = function(ev, ob) { ob.hoverIntent_t = clearTimeout(ob.hoverIntent_t); if ((Math.abs(pX - cX) + Math.abs(pY - cY)) < cfg.sensitivity) { $(ob).unbind("mousemove", track); ob.hoverIntent_s = 1; return cfg.over.apply(ob, [ev]); } else { pX = cX; pY = cY; ob.hoverIntent_t = setTimeout(function() { compare(ev, ob); }, cfg.interval); } }; var delay = function(ev, ob) { ob.hoverIntent_t = clearTimeout(ob.hoverIntent_t); ob.hoverIntent_s = 0; return cfg.out.apply(ob, [ev]); }; var handleHover = function(e) { var p = (e.type == "mouseover" ? e.fromElement : e.toElement) || e.relatedTarget; while (p && p != this) { try { p = p.parentNode; } catch (e) { p = this; } } if (p == this) { return false; } var ev = jQuery.extend({}, e); var ob = this; if (ob.hoverIntent_t) { ob.hoverIntent_t = clearTimeout(ob.hoverIntent_t); } if (e.type == "mouseover") { pX = ev.pageX; pY = ev.pageY; $(ob).bind("mousemove", track); if (ob.hoverIntent_s != 1) { ob.hoverIntent_t = setTimeout(function() { compare(ev, ob); }, cfg.interval); } } else { $(ob).unbind("mousemove", track); if (ob.hoverIntent_s == 1) { ob.hoverIntent_t = setTimeout(function() { delay(ev, ob); }, cfg.timeout); } } }; return this.mouseover(handleHover).mouseout(handleHover); }; })(jQuery);

function CreatUserTip(id, left, top, arrow, content) {
    var format = '';
    if (typeof (id) == null) {
        format = '<div id="mlayer" class="mParent" style="position: absolute; clear: both; visibility: visible; z-index: 99999; left: {0}; display:block;top: {1};width:310px;">' +
            '<div><table class="mLayer" style="display:block;"><tbody><tr><td class="top_l"></td><td class="top_c"></td><td class="top_r"></td></tr>' +
             '<tr><td class="mid_l"></td><td class="mid_c"><div class="layerBox">' +
             '{2}' +
             '</div></td><td class="mid_r"></td></tr><tr><td class="bottom_l"></td><td class="bottom_c"></td><td class="bottom_r"></td></tr></tbody></table></div></div>';
        return String.format(format, left, top, arrow, content);
    }
    else {
        format = '<div id="mlayer_{0}" class="mParent" style="position: absolute; clear: both; visibility: visible; z-index: 99999; left: {1}; display:block;top: {2};width:310px;">' +
            '<div><table class="mLayer" style="display:block;"><tbody><tr><td class="top_l"></td><td class="top_c"></td><td class="top_r"></td></tr>' +
             '<tr><td class="mid_l"></td><td class="mid_c"><div class="layerBox">' +
             '{3}' +
             '</div></td><td class="mid_r"></td></tr><tr><td class="bottom_l"></td><td class="bottom_c"></td><td class="bottom_r"></td></tr></tbody></table></div></div>';
        return String.format(format, id, left, top, arrow, content);
    }
}

/*----------------------------atme and recommend and fans tip-------------------------------------*/
$.fn.smartFloat = function() {
    var position = function(element) {
        var top = element.position().top, pos = element.css("position");
        $(window).scroll(function() {
            var scrolls = $(this).scrollTop();
            if (scrolls > top) {
                if (window.XMLHttpRequest) {
                    element.css({
                        position: "fixed",
                        top: 0
                    });
                } else {
                    element.css({
                        top: scrolls
                    });
                }
            } else {
                element.css({
                    position: "absolute",
                    top: top
                });
            }
        });
    };
    return $(this).each(function() {
        position($(this));
    });
};

function GetAtmeTip() {

    if (typeof (document.getElementById('wbatTip')) != 'undefined') {
        $('body').append("<div id=\"wbatTip\" class=\"wbtip\" style=\"display:none\"></div>");
    }

    var rad = Math.round(Math.random() * 10000);
    var toid = $("[id$=hi_uid]").val();
    var callback_GetResult = function(response) {
        $('#wbatTip').empty();
        if (response.atmeCount > 0) {
            var html = '<div><span>' + response.atmeCount + '条微博提到我，<a class="at" href="' + appcationDomain + 'my/atme">查看@我</a></span></div>';
            $(html).appendTo($("#wbatTip"));
        }
        if (response.fansCount > 0) {

            var html = '<div><span>' + response.fansCount + '位新粉丝，<a class="at" href="' + appcationDomain + 'my/' + toid + '/fans">查看我的粉丝</a></span></div>';
            $(html).appendTo($("#wbatTip"));
        }
        if (response.CommentCount > 0) {
            //alert(response.CommentCount);
            var html = '<div><span>' + response.CommentCount + '条新评论，<a class="at" href="' + appcationDomain + 'my/comment">查看评论</a></span></div>';
            $(html).appendTo($("#wbatTip"));
        }
        //alert(response.bidbuy.length);
        for (var i = 0; i < response.bidbuy.length; i++) {
            var html = '<div><span>您的求购有人报价啦，<a class="at" href="' + appcationDomain + 'qiugou/detail_' + response.bidbuy[i].bbid + '.html">赶紧查看</a></span></div>';
            $(html).appendTo($("#wbatTip"));
        }

        if (response.BidBuyDetail.length > 0) {
            if (response.BidBuyDetail.length > 1) {
                //qiugou/index_(\d+)_(\d+).html
                var html = '<div><span>有人出价啦，<a class="at" href="' + appcationDomain + 'qiugou/index_' + response.BidBuyDetail[0].bbtype + '_0_0.html">赶紧去瞧瞧看</a></span></div>';
                $(html).appendTo($("#wbatTip"));
            }
            else {
                var html = '<div><span>有人出价啦，<a class="at" href="' + appcationDomain + 'qiugou/detail_' + response.BidBuyDetail[0].bbid + '.html">赶紧去瞧瞧看</a></span></div>';
                $(html).appendTo($("#wbatTip"));
            }
        }
        if (response.askID > 0) {
            var html = '<div><span>您的提问有人回答，<a class="at" href="' + appcationDomain + 'my/shareWD_newreply/' + $("[id$=hi_uid]").val() + '.html">点击查看</a></span></div>';
            $(html).appendTo($("#wbatTip"));
        }
        if (response.NoticeCount > 0) {
            var html = '<div><span>您有' + response.NoticeCount + '条新通知，<a class="at" href="' + appcationDomain + 'my/sysnotice.html">点击查看</a></span></div>';
            $(html).appendTo($("#wbatTip"));
        }
        if (response.atmeCount || response.fansCount || response.CommentCount || response.bidbuy.length || response.BidBuyDetail.length || response.askID || response.NoticeCount) {
            var closeHtml = '<a onclick="$(\'#wbatTip\').hide();" style="position:absolute; right:9px; top:6px;"><img src="' + appcationDomain + 'images/button/close.gif" /></a>';
            $(closeHtml).appendTo($("#wbatTip"));
            if (wbatCount == 0) {
                $('#wbatTip').show().smartFloat();
            }
            else {
                $('#wbatTip').show();
            }
            wbatCount++;
        }
    }

    $.get(appcationDomain + 'handle/Tip.ashx',
                       { Random: rad, OtType: 'atme', uid: toid }
                       , callback_GetResult, 'json');

                   }
                   var config = {
                       over: getUserDetail,
                       interval: 200,
                       out: hidUserDetail
                   };
var wbatCount = 0;
$(document).ready(function() {

   $(".userlink").hoverIntent(config);
   GetAtmeTip();
   setInterval("GetAtmeTip()", 120000); //120秒

});

function getUserDetail() {
    var uid = $(this).attr('uid');
    var uname = $(this).attr('uname');
    var dataid = '';
    if (typeof (uid) == "undefined") {
        dataid = "username_" + uname;

    }
    else {
        dataid = "userid_" + uid;
    }
    if (typeof ($("body").data(dataid)) != "undefined") {//已经存在

        var obj = $("#mlayer_tip");

        obj.find(".mParentloading").empty().html($("body").data(dataid));
        obj.find(".layerArrow").remove(); 
        var objOffSetLeft = $(this).getOffSet().left; //链接或图片相对页面的left
        var objOffSetTop = $(this).getOffSet().top; //链接或图片相对页面的top

        var objW = $(this).width(); //链接或图片的宽度
        var objH = $(this).height();

        var h = objOffSetTop - objH - $(document).scrollTop(); //用于判断是否超出屏幕
        var ew = $(document.body).width() - objOffSetLeft; //用于判断是否超出屏幕

        var offH = obj.height();
        var offW = obj.width(); //提示框的宽度

        var left = 0;
        var top = -1 - offH;

        if (h > offH && ew < offW) {
            obj.find('.layerBox').append('<div class="layerArrow layerArrow_dr"></div>');
            left = -offW + (offW - obj.find('.layerArrow_dr').position().left) + (objW / 2) - 7;
        }
        else if (h > offH && ew > offW) {
            obj.find('.layerBox').append('<div class="layerArrow layerArrow_d"></div>');

            left = -obj.find('.layerArrow_d').position().left + (objW / 2) - 7;
        }
        else if (h < offH && ew < offW) {
            obj.find('.layerBox').append('<div class="layerArrow layerArrow_tr"></div>');
            left = -offW + (offW - obj.find('.layerArrow_tr').position().left) + (objW / 2) - 7;
            top = objH;
        }
        else {
            obj.find('.layerBox').append('<div class="layerArrow layerArrow_t"></div>');
            left = -obj.find('.layerArrow_t').position().left + (objW / 2) - 7;
            top = objH + 1;
        }

        obj.css({
        "top": top + objOffSetTop - objH + 'px',
        "left": left + objOffSetLeft + "px"
        });
    }
    else {
        var isExist = $("#mlayer_loading");
        if (isExist.length == 0) {
            var tip = CreatUserTip("loading", '0px', '0px', '<div class="mParentloading" style="width:298px;height:120px;"><div style="padding:50px 0px 50px 30px;color:#727272"><img src="' + appcationDomain + 'images/my/loadingblue.gif" />加载中，请稍候。。。</div></div>');
            $(tip).appendTo($("body"));
        }

        var obj = $("#mlayer_loading");
        obj.find(".layerArrow").remove(); 
             
        var objOffSetLeft = $(this).getOffSet().left;//链接或图片相对页面的left
        var objOffSetTop = $(this).getOffSet().top; //链接或图片相对页面的top

        var objW = $(this).width(); //链接或图片的宽度
        var objH = $(this).height();

        var h = objOffSetTop - objH - $(document).scrollTop(); //用于判断是否超出屏幕
        var ew = $(document.body).width() - objOffSetLeft;//用于判断是否超出屏幕

        var offH = obj.height();
        var offW = obj.width(); //提示框的宽度
        
        var left = 0;
        var top = -1 - offH;
        
        if (h > offH && ew < offW) {
            obj.find('.layerBox').append('<div class="layerArrow layerArrow_dr"></div>');
            left = -offW + (offW - obj.find('.layerArrow_dr').position().left) + (objW / 2) - 7;
        }
        else if (h > offH && ew > offW) {
            obj.find('.layerBox').append('<div class="layerArrow layerArrow_d"></div>');
            left = -obj.find('.layerArrow_d').position().left + (objW / 2) - 7;

        }
        else if (h < offH && ew < offW) {
            obj.find('.layerBox').append('<div class="layerArrow layerArrow_tr"></div>');
            left = -offW + (offW - obj.find('.layerArrow_tr').position().left) + (objW / 2) - 7;
            top = objH;
        }
        else {
            obj.find('.layerBox').append('<div class="layerArrow layerArrow_t"></div>');
            left = -obj.find('.layerArrow_t').position().left + (objW / 2) - 7;
            top = objH + 1;
        }

        obj.css({
            "top": top + objOffSetTop - objH + 'px',
            "left": left + objOffSetLeft + "px"
        });
        //obj.show();
        if (typeof (uid) == "undefined") {
            uid = 0;
        }
        if (typeof (uname) == "undefined") {
            uname = "";
        }

        var TipisExist = $("#mlayer_tip");
        if (TipisExist.length == 0) {
            var tipParent = CreatUserTip("tip", '0px', '0px', '<div class="mParentloading" style="width:298px;"></div>');
            $(tipParent).appendTo($("body"));
        }
        var tipObj = $("#mlayer_tip");
        var loading = tipObj.find('.mParentloading');
        tipObj.find(".layerArrow").remove(); 
        
        var rad = Math.round(Math.random() * 10000);
        var callback_GetResult = function(response) {

            if (response == '') { alert('memlist is null'); return; }

            else {
                $("#mlayer_loading").css("left", "-1000px");
                loading.empty();
                loading.html(response);


                var _offH = tipObj.height();

                var _offW = tipObj.width();
                var _top = -1 - _offH;
                var _left = 0;

                var _ew = $(document.body).width() - objOffSetLeft;
                var _h = objOffSetTop - objH - $(document).scrollTop();

                if (_h > _offH && _ew < _offW) {
                    tipObj.find('.layerBox').append('<div class="layerArrow layerArrow_dr"></div>');
                    _left = -_offW + (_offW - tipObj.find('.layerArrow_dr').position().left) + (objW / 2) - 7;
                }
                else if (_h > _offH && _ew > _offW) {
                    tipObj.find('.layerBox').append('<div class="layerArrow layerArrow_d"></div>');
                    _left = -tipObj.find('.layerArrow_d').position().left + (objW / 2) - 7;
                }
                else if (_h < _offH && _ew < _offW) {
                    tipObj.find('.layerBox').append('<div class="layerArrow layerArrow_tr"></div>');
                    _left = -_offW + (_offW - tipObj.find('.layerArrow_tr').position().left) + (objW / 2) - 7;
                    _top = objH;
                }
                else {
                    tipObj.find('.layerBox').append('<div class="layerArrow layerArrow_t"></div>');
                    _left = -tipObj.find('.layerArrow_t').position().left + (objW / 2) - 7;
                    _top = objH + 1;
                }

                tipObj.css({
                    "top": _top + objOffSetTop - objH + 'px',
                    "left": _left + objOffSetLeft + "px"
                });

                $("body").data(dataid, response);

            }
        }
        $.get(appcationDomain + 'handle/User.ashx',
                       { Random: rad, OtType: 'searchUser', usid: $("[id$=hi_uid]").val(), toid: uid, toname: uname }
                           , callback_GetResult);
    }
}



var TipTimeOut = null;
var interval = null;
function hidUserDetail() {
    TipTimeOut = setTimeout("hidUserTip()", 400);

    //$(this).find('.mParent').hide();
}

function hidUserTip() {
    var tipObj = $("#mlayer_tip");
    tipObj.css("left", "-1000px");
}

$('.mParent').live('mouseenter', function() {
    interval = setInterval(function() { window.clearTimeout(TipTimeOut); }, 100);
}).live('mouseleave', function() {
    clearTimeout(TipTimeOut);
    clearInterval(interval);
    timeOut = setTimeout(function() { $("#mlayer_tip").css("left", "-1000px"); }, 100);
});

String.format = function() {
    if (arguments.length == 0) {
        return null;
    }
    var str = arguments[0];
    for (var i = 1; i < arguments.length; i++) {
        var re = new RegExp('\\{' + (i - 1) + '\\}', 'gm');
        str = str.replace(re, arguments[i]);
    }
    return str;
}
String.prototype.trim = function() {
    return this.replace('\r\n', '').replace('\n', " ");
}
String.Replace = function(str, sptr, sptr1) {
    while (str.indexOf(sptr) >= 0) {
        str = str.replace(sptr, sptr1);
    }
    return str;
}

String.prototype.endWith = function(str) {
    if (str == null || str == "" || this.length == 0 || str.length > this.length)
        return false;
    if (this.substring(this.length - str.length) == str)
        return true;
    else
        return false;
    return true;
}

String.prototype.startWith = function(str) {
    if (str == null || str == "" || this.length == 0 || str.length > this.length)
        return false;
    if (this.substr(0, str.length) == str)
        return true;
    else
        return false;
    return true;
}




function attention(obj, id) {
    var rad = Math.round(Math.random() * 10000);
    var toid = $("[id$=hi_uid]").val();
    var uname = $(obj).attr('uname');
    if (toid > 0) {
        var callback_GetResult = function(response) {

            if (response == '') { alert('memlist is null'); return; }

            else {
                $(obj).parent().removeAttr('style').html("已关注<span class='split'>|</span><a href='javascript:void(0);' uname='" + uname + "' onclick='showConfireDiv(this," + id + ")' class='color_a'>取消</a>");

                var dataid = "username_" + uname;
                if (typeof ($("body").data(dataid)) != "undefined") {
                    var da = $("body").data(dataid);
                    $("body").data(dataid, "<div class='memberMes'>" + $(da).find('.actiondiv').removeAttr('style').html("已关注<span class='split'>|</span><a href='javascript:void(0);' uname='" + uname + "' onclick='showConfireDiv(this," + id + ")' class='color_a'>取消</a>").end().html() + "</div>");
                }
                dataid = "userid_" + id;
                if (typeof ($("body").data(dataid)) != "undefined") {
                    da = $("body").data(dataid);
                    $("body").data(dataid, "<div class='memberMes'>" + $(da).find('.actiondiv').removeAttr('style').html("已关注<span class='split'>|</span><a href='javascript:void(0);' uname='" + uname + "' onclick='showConfireDiv(this," + id + ")' class='color_a'>取消</a>").end().html() + "</div>");
                }
            }
        }

        $.get(appcationDomain + 'handle/User.ashx',
                       { Random: rad, OtType: 'attention', uid: toid, touid: id }
                           , callback_GetResult);
    }
    else {
        ShowLogin(); 
    }

}
function disattention(id, uname, obj) {
    this.sss = obj.sst;
    this.id = id;
    this.name = uname;
    this.diatt = function()  //定义方法
    {
        var _name = this.name;
        var _id = this.id;
        var s = $(this.sss);
        var rad = Math.round(Math.random() * 10000);
        var toid = $("[id$=hi_uid]").val();
        if (toid > 0) {
            var callback_GetResult = function(response, name) {
                if (response == '') { return; }
                else {
                    $('#confire_' + id).remove();
                    var spar = s.parent();
                    spar.attr('style', 'padding-left:5px;border:none').html("<a href='javascript:void(0);' uname='" + _name + "' onclick='attention(this," + _id + ")' class='color_a' ><img src='" + appcationDomain + "images/my/ation.jpg' /></a>");

                    var dataid = "username_" + _name;
                    if (typeof ($("body").data(dataid)) != "undefined") {
                        var da = $("body").data(dataid);
                        $("body").data(dataid, "<div class='memberMes'>" + $(da).find('.actiondiv').attr('style', 'padding-left:5px;border:none').html("<a href='javascript:void(0);' uname='" + _name + "' onclick='attention(this," + _id + ")' class='color_a' ><img src='" + appcationDomain + "images/my/ation.jpg' /></a>").end().html() + "</div>");
                    }
                    dataid = "userid_" + _id;
                    if (typeof ($("body").data(dataid)) != "undefined") {
                        da = $("body").data(dataid);
                        $("body").data(dataid, "<div class='memberMes'>" + $(da).find('.actiondiv').attr('style', 'padding-left:5px;border:none').html("<a href='javascript:void(0);' uname='" + _name + "' onclick='attention(this," + _id + ")' class='color_a' ><img src='" + appcationDomain + "images/my/ation.jpg' /></a>").end().html() + "</div>");
                    }
                }
            }
            $.get(appcationDomain + 'handle/User.ashx',
                             { Random: rad, OtType: 'disattention', uid: toid, touid: id }
                                      , callback_GetResult);
        }
    };

}
var Person =  //定义一个对象来作为原型类
    {
    Create: function(name, age)  //这个当构造函数
    {
        this.name = name;
        this.age = age;
    },
    SayHello: function()  //定义方法
    {
        alert("Hello, I'm " + this.name);
    },
    HowOld: function()  //定义方法
    {
        $(this).remove();
    }
};
var it;
function showConfireDiv(obj, id) {
    $(".disconfireDiv").remove();
    var top = $(obj).getOffSet().top - 100;
    var left = $(obj).getOffSet().left - 40;
    var name = $(obj).attr('uname');
    this.sst = obj;
    it = new disattention(id, name, this);
    if ($('#confire_' + id).length > 0) {
        $('#confire_' + id).css({
            "top": top + 'px',
            "left": left + "px"
        });
    }
    else {
        var html = '<div id="confire_' + id + '" class="disconfireDiv" style="position: absolute;left:' + left + 'px;top:' + top + 'px; display:none; z-index:2000;"><div class="mini"><div style="padding:5px 20px 0px 20px;"><img src="' + appcationDomain + 'images/button/tip3.gif" style="margin-top:2px; margin-right:5px;" />确定不再关注' + name + '?<div><div style="padding-top:10px;"><input type="button" value="确定" onclick="it.diatt()"><input type="button" value="取消" onclick="$(\'#confire_' + id + '\').hide();"><div></div></div>';
        $(html).appendTo($("body"));
    }
    $('#confire_' + id).slideToggle("fast");

}
(function($) {
    $.fn.getOffSet = function() {
        var top = $(this).offset().top;
        var left = $(this).offset().left;
        var picHeight = $(this).height();
        var picWidth = $(this).width();
        var rttop = 0, rtleft = 0;
        var viewHeight = document.body.clientHeight; //浏览器可视高度
        var retValue = 0;
        if (top + picHeight > viewHeight)
            rttop = top - picHeight;
        else
            rttop = top + picHeight;
        var viewWidth = document.body.clientWidth;  //浏览器可视宽度 
        var retValue = 0;
        if (left > viewWidth)
            rtleft = left + picWidth;
        else
            rtleft = left;
        return results = {
            top: rttop,
            left: rtleft
        };
    }
})(jQuery);


function ShowLogin() {
    var oj = $("#mlaye_login");
    if (oj.length > 0) {
        oj.show();
    }
    else {
        var tip = format = '<div id="mlaye_login" class="mParent" style="position: absolute; clear: both; visibility: visible; z-index: 99999; display:block;">' +
            '<div><table class="mLayer" style="display:block;"><tbody><tr><td class="top_l"></td><td class="top_c"></td><td class="top_r"></td></tr>' +
             '<tr><td class="mid_l"></td><td class="mid_c"><div class="layerBox">' +
             '<div><a class="lg_close" onclick="userClose()"></a></div><div style="width:500px;padding:30px"><div style="float:left;border-right: 1px solid #CCCCCC; text-align:left"><table class="lg_table"><tr><td style="padding-top:0px">已有聚乐园账号，可直接登录</td></tr><tr><td><input type="text" id="mod_loginname" class="inp inputusername" title="邮箱/昵称" alt="邮箱/昵称" value="邮箱/昵称"></td></tr><tr><td><input type="text" id="mod_loginpwd" class="inp inputuserpwd" title="请输入密码" alt="请输入密码" value="请输入密码"><input type="password" style="display:none" id="mod_loginpassword" class="inp inputuserpassword" ></td></tr><tr><td><a id="mod_login_submit" onclick="userLogin()" class="btn_normal" href="javascript:void(0);"><em style="background-position: right -124px;height: 24px;padding-right: 20px;">登录</em></a><input type="checkbox" checked="checked" class="chkb" id="mod_isremember" style="margin-left:70px;"><label for="mod_isremember">下次自动登录</label></td></tr><tr><td><div><span id="login_error" style="color:Red"></span></div><div style="border-top: 1px dotted #CCCCCC;margin: 20px 10px 0 0;padding-top: 12px;"><strong style="color: #666666;display: block;padding-bottom: 6px; font-weight: normal;">使用其他账号登录</strong><span><i></i><a class="sharesinaBtn" onclick="userSinaLogin()" >新浪微博</a></span><b>|</b><span><i></i><a class="sharetentent" onclick="userTencentLogin()">腾讯微博</a></span></div></td></tr></table></div>' +
             '<div style="float:right;text-align:left;width:210px;">还未开通？赶紧免费注册一个吧！<p style="margin:30px 0 0 20px;"><a class="btn_greenLg"><em style="font-style:normal;font-size:16px;">注册聚乐园</em></a></p></div><div style="clear:both"></div></div>' +
             '</div></td><td class="mid_r"></td></tr><tr><td class="bottom_l"></td><td class="bottom_c"></td><td class="bottom_r"></td></tr></tbody></table></div></div>';
        $(tip).appendTo($("body"));
    }
    var bg = $("#lsxBlank");
        if (bg.length > 0) {
            bg.show();
        }
        else {
            $('<div id="lsxBlank"></div>').prependTo("body");
            $("#lsxBlank").css({
                width: $("body").width(),
                height: $("body").height(),
                "opacity": 0.15
            });
        }
        $("#mlaye_login").center({ position: 'fixed', top: '50%' });
    }
    $(document).ready(function() {
        $('.inputusername').live('focus', function() {
            if ($(this).val() == '邮箱/昵称') {
                $(this).val('');
                $('#login_error').html("");
            }
        }).live('blur', function() {
            if ($(this).val() == '') {
                $(this).val('邮箱/昵称');
            }
        });
        $('.inputuserpwd').live('focus', function() {
            if ($(this).val() == '请输入密码') {

                $("#mod_loginpassword").show();
                $("#mod_loginpassword").focus();
                $("#mod_loginpwd").hide();
                $('#login_error').html("");
            }
        }).live('blur', function() {
            if ($(this).val() == '') {
                $(this).val('请输入密码');
            }
        });
        $('.inputuserpassword').live('blur', function() {
            if ($(this).val() == '') {
                $("#mod_loginpassword").hide();
                $("#mod_loginpwd").show();
            }
        });
    });
    function userLogin() {
 
        if ($("#mod_loginname").val() == '邮箱/昵称') {
            $('#login_error').html("请输入邮箱");
            return false;
        }
        if ($("#mod_loginpassword").val() == '') {
            $('#login_error').html("请输入密码");
            return false;
        }

        
        var rad = Math.round(Math.random() * 10000);

        var callback_GetResult = function(response, name) {
            if (response.status==0) { $('#login_error').html("用户名或密码无效"); $("#mod_loginpassword").val(''); return false; }
            else { window.location.href = window.location.href; }
        }
        $.get(appcationDomain + 'handle/User.ashx',
                             { Random: rad, OtType: 'login_u', uname: $("#mod_loginname").val(), upwd: $("#mod_loginpassword").val(), uisRem: $("#mod_isremember").prop("checked") }
                                     , callback_GetResult, 'json');

    }
                         
    function userClose() {
        $('#mlaye_login').hide();
        $('#lsxBlank').hide();
        $("#mod_loginname").val('邮箱/昵称');
        $("#mod_loginpassword").val('');
        $('#login_error').html("");

    }
    function userSinaLogin() {
        window.location.href = appcationDomain + "External/tsina.aspx?returl=" + window.location.href;
    }
    function userTencentLogin() {
        window.location.href = appcationDomain + "External/tTencent.aspx?returl=" + window.location.href;
    }
(function($) {
    $.fn.center = function(settings) {
        var style = $.extend({
            position: 'absolute', //absolute or fixed
            top: '50%',            //50%即居中，将应用负边距计算，溢出不予考虑了。
            left: '50%',
            zIndex: 2009,
            relative: true        //相对于包含它的容器居中还是整个页面
        }, settings || {});

        return this.each(function() {
            var $this = $(this);

            if (style.top == '50%') style.marginTop = -$this.outerHeight() / 2;
            if (style.left == '50%') style.marginLeft = -$this.outerWidth() / 2;
            if (style.relative && !$this.parent().is('body') && $this.parent().css('position') == 'static')
                $this.parent().css('position', 'relative');
            delete style.relative;
            //ie6
            if (style.position == 'fixed' && $.browser.version == '6.0') {
                style.marginTop += $(window).scrollTop();
                style.position = 'absolute';
                $(window).scroll(function() {
                    $this.stop().animate({
                        marginTop: $(window).scrollTop() - $this.outerHeight() / 2
                    });
                });
            }

            $this.css(style);
        });
    };
})(jQuery);
