

function getQuesCount()
{
    $.getJSON("/Ajax/Question.ashx", {mode:"1",stamp:Math.round(Math.random()*100000000)},function(json){loadQuestionCountHandler(json);});
}


function loadQuestionCountHandler(json)
{
    $("#resCount").html(json.allCount);
    $("#newCount").html(json.newCount);
}

function weekPointsHandler(json)
{
    var viewStr = "<div id=\"bon2\"><div id=\"bon2_2\" class=\"font218\"><a href=\"javascript:nextSale('up');\">总积分排行</a></div></div><div id=\"bon1\" class=\"font218\">周积分排行</div><div id=\"con\">";    
    
    for(var i=0 ;i< json.length;i++)
    {
        if(i == 0)
            viewStr += "<div id=\"ul\" class=\"font565\"><div id=\"li_l\">";
        else
            viewStr += "<div id=\"ul\"><div id=\"li_l\">";
        viewStr += (i+1)+".&nbsp;&nbsp;"+ json[i].username+"</div><div id=\"li_r\">"+json[i].weekpoints+"</div></div>";
    }
    
    viewStr += "</div>";
    
    $("#saleList1").html(viewStr);
    document.getElementById("saleList0").style.display="none";
	document.getElementById("saleList1").style.display="block";
}

//登陆
function uLogin() {
    var _email = $("#txtEmail").val();
    var _pwd = $("#txtPwd").val();
    var _check = $("#cb_isAnm").val();
    if (_email == "" || _pwd == "") {
        alert('用户名密码不能为空！');
        return;
    }
    $.getJSON("http://pia.zhigou.com/user/aaa.ashx?callback=?", { mode: "3",email:_email,pwd:_pwd, stamp: Math.round(Math.random() * 100000000) }, function(json) { setLoginInfo(json); });
}
function setLoginInfo(json) {
    if (json.isloggedin == "1") {
        document.location.reload(); 
    }  
    else{
        alert('用户名或密码错误，登陆失败！');
    }    
}
//注册
function uReg(){
    var url = top.location.href;    
    top.location.href="http://my.zhigou.com/signup.html?returnurl="+url;
}
 
function GetIndexLoginInfo() {
     $.getJSON("http://pia.zhigou.com/user/aaa.ashx?callback=?", { mode: "2", stamp: Math.round(Math.random() * 100000000) }, function(json) { SetIndexLoginInfo(json); });
}
function SetIndexLoginInfo(json) {
    var html = '';
    if (json.isloggedin == "1") {
        html += '<b>欢迎' + json.username + '，[<a href="javascript:logoutUserFromTopBar();">退出</a>]</b>'
        html += '<table width="100%" border="0" cellpadding="0" cellspacing="0">'
        html += '<tr><td width="35%" rowspan="2" align="center">'
        html += '<img  height="50px" width="50px" src="' + json.userpic + '" /></td>'
        html += '<td width="65%">级别：' + json.titlename + '</td></tr>'
        html += '<tr><td>积分：' + json.historycredits + '</td></tr>'
        html += '<tr><td colspan="2" align="center"><br/><a href="http://my.zhigou.com/ask/asklist.html">我的打听</a>    '
        html += '<a href="http://my.zhigou.com/ask/answerlist.html">我的回答</a>    '
        html += '<a href="/ask/"><font color="#FF0000">我要打听</font></a> </td></tr></table>'; 
    }
    else {
        html += '<em>欢迎登录智购打听</em><table width="100%" border="0" cellpadding="0" cellspacing="0">'
        html += '<tr><td>邮箱：<input tabindex="1" id="txtEmail" name="txtEmail" type="text" Class="txtbox"/></td>'
        html += '<td rowspan="2"><input tabindex="3" name="" onclick="uLogin();" type="button" class="loginbtn" value="登录" /></td>'
        html += '</tr>'
        html += '<tr>'
        html += '<td>密码：<input tabindex="2" id="txtPwd" Class="txtbox" name="txtPwd" type="password" /></td>'
        html += '</tr>'
        html += '<tr>'
        html += '<td colspan="2">'
        html += '<input id="cb_isAnm" type="checkbox" />记住密码'
        html += '</td>'
        html += '</tr>'
        html += '<tr>'
        html += '<td colspan="2" align="center">'
        html += '<a href="http://my.zhigou.com/GetPwdBack.html">忘记密码</a></td>'
        html += '</tr>'
        html += '<tr>'
        html += '<td colspan="2"><span><a href="javascript:uReg()">免费注册</a></span></td>'
        html += '</tr>'
        html += '</table>';
    }
    $("#login_f_div").html(html);
} 

//new point rank 
function getWeekPoint() {
    $.getJSON("/Ajax/User.ashx", { mode: "5", stamp: Math.round(Math.random() * 100000000) }, function(json) { viewPointsHandler1(json); });
}

function getAllPoint() {
    $.getJSON("/Ajax/User.ashx", { mode: "6", stamp: Math.round(Math.random() * 100000000) }, function(json) { viewPointsHandler2(json); });
}
function viewPointsHandler1(json) {
    $("#pr_1").attr("class", "on");
    $("#pr_2").attr("class", "");
    fullInRank(json);
}
function viewPointsHandler2(json) {
    $("#pr_2").attr("class", "on");
    $("#pr_1").attr("class", "");
    fullInRank(json);
}
function fullInRank(json) {
    var _html = "";
    
    for (var i = 0; i < json.length; i++) {
        var point = parseInt(json[i].point);
        if(json[i].point == undefined)
        {
            point = 0;
        }
        _html += "<li><a href=\"/iask/user/" + json[i].userid + "/\">" + json[i].username + "</a><b>" + point + "</b></li>";
    }
    if (_html != "")
        $("#point_rank").html("<ul>"+_html+"</ul><div class=\"clear\"></div>");
}


function categoryCountHandler(json)
{
     for(var i=0 ;i< json.length;i++)
     {
        $("#cfont_"+json[i].cateid).html("("+json[i].catecount+")");
     }
}

//蒙板操作
function showManagerDiv(_divID)
{
      createMaskDiv();
      var msg = document.getElementById(_divID.toString());
      msg.style.position = "absolute";
      msg.style.zIndex = "9999";
      msg.style.top = "176px";
      msg.style.left = (parseInt(document.body.scrollWidth) - 184) / 2 + "px"; 
      msg.style.display = "block";
      
 }
 
function closeManagerDiv(_divID)
{      
   document.getElementById(_divID.toString()).style.display = "none";
   var _div = parent.document.getElementById("divMask");
   document.body.removeChild(_div);
}
 
