﻿// JScript 文件
//分类导航初始状态
function classBanInit()
{
    var oid=$("s2s_WeeklyT_h_classBan_id").value;
    if(oid!=-1)
    {
        $("b_classBtn_"+oid).className="bgcolor_p we_ban_L2";
    }
}
addLoadEvent(classBanInit);
//分类导航栏效果
function classBanOver(oid)
{
    if(oid!=$("s2s_WeeklyT_h_classBan_id").value)
    {
        $("b_classBtn_"+oid).className="bordercolor_g we_ban_L1 bgcolor_g";
    }
}
function classBanOut(oid)
{
    if(oid!=$("s2s_WeeklyT_h_classBan_id").value)
    {
        $("b_classBtn_"+oid).className="bordercolor_g we_ban_L1";
    }
}
function classBanClick(oid)
{
    var ohref=["/channel/weekly/","/channel/weekly/weekly.aspx"];
    location.href=ohref[oid];
}
//发表观点输入框
function ttFocus(obj,cc)
{
    if(obj.value==cc)
    {
        obj.value="";
        obj.style.color="#323232";
    }
}
function ttBlur(obj,cc)
{
    if(obj.value=="")
    {
        obj.value=cc;
        obj.style.color="#BEBEBE";
    }
}

/*　说道begin　*/

function getPublicationRelInfo(ntype,maxNum,obj)
{
    var pubnum=$("pub_num").value;
    var url="/ajax/getPublocation.aspx?classId=1&pubNum=" + pubnum + "&type=" + ntype + "&maxNum=" + maxNum;

    var xmlhttp = getXMLHttp();
    xmlhttp.onreadystatechange=function(){
        if(xmlhttp.readyState == 4)
        {
            $(obj).innerHTML = xmlhttp.responseText;
        }
    }	
    xmlhttp.open("GET",url,true);
    xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");		
    xmlhttp.send(null);

}

function getPublictaionInfoList(obj,orderStr)
{
    var pubnum=$("pub_num").value;
    var url="/ajax/getPublocation.aspx?classId=2&pubNum=" + pubnum + "&orderby=" + orderStr;
    
    //alert(url);
    var xmlhttp = getXMLHttp();
    xmlhttp.onreadystatechange=function(){
        if(xmlhttp.readyState == 4)
        {
            $(obj).innerHTML = xmlhttp.responseText;
            if(location.href.indexOf("#")!=-1)
                location.href=location.href;
        }
    }	
    xmlhttp.open("GET",url,true);
    xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");		
    xmlhttp.send(null);
}

function setPubInfoUp(ntype,id)
{
    var pubnum=$("pub_num").value;
    var url="/ajax/getPublocation.aspx?classId=3&pubNum=" + pubnum + "&type=" + ntype + "&id=" + id;

    var xmlhttp = getXMLHttp();
    xmlhttp.onreadystatechange=function(){
        if(xmlhttp.readyState == 4)
        {
            if(xmlhttp.responseText=="OK")
            {
                getPuhHotInfo(5,'lblPubHotInfo');
                getPublictaionInfoList('lblPubRelInfoList','');
                alert("操作成功");
            }
            else
                alert(xmlhttp.responseText);
        }
    }	
    xmlhttp.open("GET",url,true);
    xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");		
    xmlhttp.send(null);
}

function doSavePubInfo(id,obj)
{
    var pubnum=$("pub_num").value;
    var cont =$("txt_content_" + id).value;
    if(cont=="" || cont==" " || cont=="内容" || cont=="　")
    {
        alert("请输入内容");
        $("txt_content_" + id).focus();
        return;
    }
    var url="/ajax/getPublocation.aspx";
    var content="classId=4&pubNum=" + pubnum + "&id=" + id+"&content="+formatText(cont);
    obj.disabled=true;
    var xmlhttp = getXMLHttp();
    xmlhttp.onreadystatechange=function(){
        if(xmlhttp.readyState == 4)
        {
            if(xmlhttp.responseText=="OK")
            {
                getPuhHotInfo(5,'lblPubHotInfo');
                getPublictaionInfoList('lblPubRelInfoList','');
                $("txt_content_" + id).value=""; 
                obj.disabled=false;               
                alert("内容添加成功!");
            }
            else
                alert(xmlhttp.responseText);
        }
    }	
    xmlhttp.open("POST",url,true);
    xmlhttp.setRequestHeader("Content-Length",content.length);
    xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");		
    xmlhttp.send(content);
}

function doVoteItems(id,which)
{
    var pubnum=$("pub_num").value;
    var obj=document.getElementsByName(which);
    var x = "";
    for(var i=0;i<obj.length;i++)
    {
        if(obj[i].checked==true)
        {
            x += obj[i].value + ",";
        }
    }
    if(x == "")
    {
        alert("您还未选择投票选项！");
        return;
    }
    
    window.location.href="#";
    $("div_opt_info").style.display='block';
    var url="/ajax/getPublocation.aspx";
    var content="classId=5&id=" + pubnum + "&content=" + formatText(x);

    var xmlhttp = getXMLHttp();
    xmlhttp.onreadystatechange=function(){
        if(xmlhttp.readyState == 4)
        {
            //if(xmlhttp.responseText=="OK")
            {
                $("div_opt_info").style.display='none';
                alert(xmlhttp.responseText);
            }
            //else
            //    alert(xmlhttp.responseText);
        }
    }	
    xmlhttp.open("POST",url,true);
    xmlhttp.setRequestHeader("Content-Length",content.length);
    xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");		
    xmlhttp.send(content);
}

function viewVoteResult(id)
{
    var url="/ajax/getPublocation.aspx";
    var content="classId=6&id=" + id;

    var xmlhttp = getXMLHttp();
    xmlhttp.onreadystatechange=function(){
        if(xmlhttp.readyState == 4)
        {
            //if(xmlhttp.responseText=="OK")
            {
                window.location.href="#";
                $("div_look_pool").style.display='block';
                $("lblVoteResult").innerHTML=xmlhttp.responseText;
            }
            //else
            //    alert(xmlhttp.responseText);
        }
    }	
    xmlhttp.open("POST",url,true);
    xmlhttp.setRequestHeader("Content-Length",content.length);
    xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");		
    xmlhttp.send(content);
}

function getPubHead(obj)
{
    var pubnum=$("pub_num").value;
    var url="/ajax/getPublocation.aspx?classId=7&pubNum=" + pubnum;

    var xmlhttp = getXMLHttp();
    xmlhttp.onreadystatechange=function(){
        if(xmlhttp.readyState == 4)
        {
            $(obj).innerHTML=xmlhttp.responseText;
        }
    }	
    xmlhttp.open("GET",url,true);
    xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");		
    xmlhttp.send(null);
}


function getPuhHotInfo(maxNum,obj)
{
    var pubnum=$("pub_num").value;
    var url="/ajax/getPublocation.aspx?classId=8&maxNum="+maxNum+"&pubNum=" + pubnum;

    var xmlhttp = getXMLHttp();
    xmlhttp.onreadystatechange=function(){
        if(xmlhttp.readyState == 4)
        {
            $(obj).innerHTML=xmlhttp.responseText;
        }
    }	
    xmlhttp.open("get",url,true);
    xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");		
    xmlhttp.send(null);
}
/*　说道end　*/

/*　周刊begin　*/
function getWeeklyHead(obj)
{
    var pubnum=$("weeklyId").value;
    var url="/ajax/getWeekly.aspx?classId=1&id=" + pubnum;
    
    //alert(url);
    var xmlhttp = getXMLHttp();
    xmlhttp.onreadystatechange=function(){
        if(xmlhttp.readyState == 4)
        {
            $(obj).innerHTML = xmlhttp.responseText;
        }
    }	
    xmlhttp.open("GET",url,true);
    xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");		
    xmlhttp.send(null);
}
function getWeeklyInfoList(obj,orderStr)
{
    var pubnum=$("weeklyId").value;
    var url="/ajax/getWeekly.aspx?classId=2&id=" + pubnum + "&orderby=" + orderStr;
    
    //alert(url);
    var xmlhttp = getXMLHttp();
    xmlhttp.onreadystatechange=function(){
        if(xmlhttp.readyState == 4)
        {
            $(obj).innerHTML = xmlhttp.responseText;
        }
    }	
    xmlhttp.open("GET",url,true);
    xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");		
    xmlhttp.send(null);
}

function setWeeklyInfoUp(ntype,id)
{
    //var pubnum=$("weeklyId").value;
    var url="/ajax/getWeekly.aspx?classId=3&type=" + ntype + "&id=" + id;

    var xmlhttp = getXMLHttp();
    xmlhttp.onreadystatechange=function(){
        if(xmlhttp.readyState == 4)
        {
            if(xmlhttp.responseText=="OK")
            {
                getWeeklyInfoList('lblWeeklyInfoList','')
                alert("操作成功");
            }
            else
                alert(xmlhttp.responseText);
        }
    }	
    xmlhttp.open("GET",url,true);
    xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");		
    xmlhttp.send(null);
}

function doSaveWeeklyInfo(id,obj)
{
    var pubnum=$("weeklyId").value;
    var cont =$("txt_content_" + id).value;
    if(cont=="" || cont==" " || cont=="内容" || cont=="　")
    {
        alert("请输入内容");
        $("txt_content_" + id).focus();
        return;
    }
    obj.disabled=true;
    var url="/ajax/getWeekly.aspx";
    var content="classId=4&id=" + pubnum + "&pid=" + id+"&content="+formatText(cont);

    var xmlhttp = getXMLHttp();
    xmlhttp.onreadystatechange=function(){
        if(xmlhttp.readyState == 4)
        {
            if(xmlhttp.responseText=="OK")
            {
                getWeeklyInfoList('lblWeeklyInfoList','');
                obj.disabled=false;
                $("txt_content_" + id).value='';
                if($("mms_huifu_" + id)!=null)
                    $("mms_huifu_" + id).style.display='none';
                alert("内容添加成功!");
            }
            else
                alert(xmlhttp.responseText);
        }
    }	
    xmlhttp.open("POST",url,true);
    xmlhttp.setRequestHeader("Content-Length",content.length);
    xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");		
    xmlhttp.send(content);
}

function getWeeklyRight(obj,type)
{
    var pubnum=$("weeklyId").value;
    var url="/ajax/getWeekly.aspx?classId=5&id=" + pubnum + "&type=" + type;

    var xmlhttp = getXMLHttp();
    xmlhttp.onreadystatechange=function(){
        if(xmlhttp.readyState == 4)
        {
            $(obj).innerHTML=xmlhttp.responseText;
        }
    }	
    xmlhttp.open("GET",url,true);
    xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");		
    xmlhttp.send(null);
}
/*　周刊end　*/
