﻿// JScript 文件


//单页图文编辑层
function sigEdit(id,cid,f_id,title)//id：单条信息编号，cid：栏目编号，title栏目名称
{ 
    //alert(f_id);
    if(f_id==1008)
    {
    ShowIframe("../../ConstructASP/CPList/PicAddLink.aspx?type=1&id="+id + "&c_id=" + cid,'650','400',title,cid);
    }
    else
    {
    if(id>0&&cid>0)
    {
        ShowIframe("../../ConstructASP/CPList/PicAdd.aspx?type=1&id="+id + "&c_id=" + cid,'650','400',title,'sig');
    }
    else if(id<=0&&cid>0)
    {
        ShowIframe("../../ConstructASP/CPList/PicAdd.aspx?type=1&c_id=" + cid,'650','400',title,'sig');
    }
    else
    {
        //ShowIframe("../../ConstructASP/CPList/PicAdd.aspx",'650','425','单页图文','');
    }
    }
}

//新闻添加层
function newsAdd(cid)//cid栏目编号
{
    if(cid >0)
    {
        ShowIframe("../../ConstructASP/News/NewsAdd.aspx?c_id="+cid,'650','415','添加新闻','newslist');
    }
    else
    {
        
    }
}
function scriptPage(fid,cm)
{
    if(fid ==1001) //新闻类
    {
        ShowIframe("../../ShowASP/script/scriptPage.aspx?fid="+fid,'275','170','修改分页显示条数','newslist');
    }
    else if(fid==1002&&cm==1) //产品列表
    {
        ShowIframe("../../ShowASP/script/scriptPage.aspx?fid="+fid+"&cm=1",'275','170','修改分页显示条数','pro');
    }
    else if(fid==1002&&cm==2) //产品图片
    {
        ShowIframe("../../ShowASP/script/scriptPage.aspx?fid="+fid+"&cm=2",'275','170','修改分页显示条数','hon');
    }
    else if(fid==1004) //留言
    {
        ShowIframe("../../ShowASP/script/scriptPage.aspx?fid="+fid,'275','170','修改分页显示条数','mess');      
    }
    else if(fid==1005) //下载
    {
       ShowIframe("../../ShowASP/script/scriptPage.aspx?fid="+fid,'275','170','修改分页显示条数','down');        
    }
    else if(fid==1006) //供求
    {
        ShowIframe("../../ShowASP/script/scriptPage.aspx?fid="+fid,'275','170','修改分页显示条数','sdlist');     
    }
    else if(fid==10006) //人才
    {
        ShowIframe("../../ShowASP/script/scriptPage.aspx?fid="+fid,'275','170','修改分页显示条数','useshow');     
    }
}
function newsEdit(id,cid)//id：单条新闻编号，cid栏目编号
{
    if(id> 0 && cid >0)
    {
        if(document.getElementById("hID") != null)
        {
            document.getElementById("hID").value=id;
        }
        if(document.getElementById("hidId") != null)
        {
            document.getElementById("hidId").value=id;
        }
        
        ShowIframe("../../ConstructASP/News/NewsAdd.aspx?id="+id+"&c_id="+cid,'650','415','编辑新闻','newsedit');
    }
}

//新闻内容页添加新闻
function newsAddT(cid,title)//cid：栏目编号
{
    ShowIframe("../../ConstructASP/News/NewsAdd.aspx?c_id="+cid,'650','415',title,'newsinfoadd');
}

//新闻详细页编辑
function newsInfoEdit(id,cid)//id：单条新闻编号，cid栏目编号
{
    if(id> 0 && cid >0)
    {
        if(document.getElementById("hID") != null)
        {
            document.getElementById("hID").value=id;
        }
        if(document.getElementById("hidId") != null)
        {
            document.getElementById("hidId").value=id;
        }
        
        ShowIframe("../../ConstructASP/News/NewsAdd.aspx?id="+id+"&c_id="+cid,'650','415','编辑新闻','newsinfo');
    }
}

//图片信息编辑层
function honEdit(id,cid)
{
    if(id>0&&cid>0)
    {
            ShowIframe("../../ConstructASP/CPList/PicAdd.aspx?type=3&id="+id + "&c_id=" + cid,'500','200','图片信息','hon');
    }
    else if(id<=0&&cid>0)
    {
            ShowIframe("../../ConstructASP/CPList/PicAdd.aspx?type=3&id="+id,'500','200','图片信息','hon');
    }
    else
    {
        //window.EditFrame.location.href="../../ConstructASP/CPList/PicAdd.aspx"
    }
}
//图片信息添加层
function honAdd(cid,title)
{
    if(cid>0)
    {
                 ShowIframe("../../ShowASP/Assistant/csUP.aspx?type=3&c_id="+cid+"&title="+title,'500','400',title,'hon');
    }
    else
    {
        //window.EditFrame.location.href="../../ConstructASP/CPList/PicAdd.aspx"
    }
}

//产品信息类页面添加层
function proAdd(cid)
{
    ShowIframe("../../ConstructASP/CPList/PicAdd.aspx?type=2&c_id="+cid,'650','440','产品信息','pro');
}

//产品列表页编辑层
function proEdit(id,cid)//id：单条信息编号，cid：栏目编号
{
    if(id<=0 || cid<=0)
    {
        //ShowIframe("../../ConstructASP/CPList/PicAdd.aspx",'650','425','产品信息','');
    }
    else
    {
        ShowIframe("../../ConstructASP/CPList/PicAdd.aspx?type=2&id="+id + "&c_id=" + cid,'650','440','产品信息','pro');
    }
}

//产品信息页编辑层
function proInfoEdit(id,cid)//id：单条信息编号，cid：栏目编号
{
    if(id<=0 || cid<=0)
    {
        //ShowIframe("../../ConstructASP/CPList/PicAdd.aspx",'650','425','产品信息','');
    }
    else
    {
        ShowIframe("../../ConstructASP/CPList/PicAdd.aspx?type=2&id="+id + "&c_id=" + cid,'650','440','产品信息','ble');
    }
}

//产品信息页添加层
function proInfoAdd(cid)//id：单条信息编号，cid：栏目编号
{
    if(cid>0)
    {
        ShowIframe("../../ConstructASP/CPList/PicAdd.aspx?type=2&c_id=" + cid,'650','440','产品信息','bleadd');
    }
}


//回复留言编辑层
function messAdd(id)//id：单条信息编号
{
    if(id>0)
    {
        ShowIframe("../../ShowASP/Message/reMessage.aspx?id="+id,'430','200','回复留言','mess');
    }
    else
    {
        //ShowIframe("../../ShowASP/Message/Message.aspx",'650','425','回复留言','mess');
    }
}

//新增文件下载
function downAdd(cid)
{
    ShowIframe("../../ConstructASP/EpicAndDown/EpicAndDownAdd.aspx?c_id="+cid,'650','425','文件下载','down');
}

//编辑文件下载
function downEdit(id)//
{
    ShowIframe("../../ShowASP/DownLoad/reDown.aspx?id=" + id,'430','200','文件下载','down');
}

//添加供求信息层
function sdAdd(cid)//cid：栏目编号
{
    if(cid<=0)
    {
        //ShowIframe("../../ConstructASP/SAndD/SAndDAdd.aspx",'650','425','供求信息','');
    }
    else
    {
        ShowIframe("../../ConstructASP/SAndD/SAndDAdd.aspx?c_id="+cid,'650','425','添加供求信息','sdlist');
    }
}
//供求列表编辑层
function sdEdit(id)//id：单条信息编号
{
    if(id<=0)
    {
        //ShowIframe("../../ConstructASP/SAndD/SAndDAdd.aspx",'650','425','供求信息','');
    }
    else
    {
        if(document.getElementById("hID") != null)
        {
            document.getElementById("hID").value=id;
        }
        if(document.getElementById("hidId") != null)
        {
            document.getElementById("hidId").value=id;
        }
    
        ShowIframe("../../ConstructASP/SAndD/SAndDAdd.aspx?id="+id,'650','425','编辑供求信息','sdlist');
    }
}

//供求信息页面添加信息层
function sdInfoAdd(cid)//cid：栏目编号
{
    if(cid<=0)
    {
        //ShowIframe("../../ConstructASP/SAndD/SAndDAdd.aspx",'650','425','供求信息','');
    }
    else
    {
        ShowIframe("../../ConstructASP/SAndD/SAndDAdd.aspx?c_id="+cid,'650','425','添加供求信息','sdinfoadd');
    }
}
//供求信息页面编辑层
function sdInfoEdit(id)//id：单条信息编号
{
    if(id<=0)
    {
        //ShowIframe("../../ConstructASP/SAndD/SAndDAdd.aspx",'650','425','供求信息','');
    }
    else
    {
        if(document.getElementById("hID") != null)
        {
            document.getElementById("hID").value=id;
        }
        if(document.getElementById("hidId") != null)
        {
            document.getElementById("hidId").value=id;
        }
    
        ShowIframe("../../ConstructASP/SAndD/SAndDAdd.aspx?id="+id,'650','425','编辑供求信息','sdinfo');
    }
}

//onclick="ShowIframe('../../ConstructASP/News/NewsAdd.aspx','650','425','添加新闻',document.getElementById('assPos').value)">
function ShowIframe(Url,kuan,gao,title,tag) //显示iframe Url 弹出的页面地址，kuan 宽度 gao 高度 title 弹出层标题 tag 用于AJAX更新的标记
{  
    var pop=new Popup({ contentType:1,isReloadOnClose:false,width:kuan,height:gao});
    pop.setContent("contentUrl",Url);
    pop.setContent("title",title);
    pop.build();
    pop.show();
    //alert(document.getElementById("dialogBoxClose").getAttribute("id"));
    //alert(ajaxName);
    
    //此次的“Show***()”在“JS\base4.js”中,要根据不同页面来分别调用相应的方法，
    if(tag == "sig")//“单页图文”类信息
    {
        document.getElementById("dialogBoxClose").onclick=function(){ShowSin();};
    }    
    if(tag == "newslist")//“新闻列表”类信息newsedit
    {
        document.getElementById("dialogBoxClose").onclick=function(){ShowNewsList();};
    }
        if(tag == "newsedit")//“新闻列表”页面编辑单条信息
    {
        document.getElementById("dialogBoxClose").onclick=function(){ShowNewsList();};
    }
    if(tag == "newsinfo")//“新闻内容”页编辑信息
    {
        document.getElementById("dialogBoxClose").onclick=function(){ShowNewsInfo();};
    }
    if(tag == "newsinfoadd")//“新闻内容”页添加信息
    {
        document.getElementById("dialogBoxClose").onclick=function(){ToNewsList();};//添加后回到列表页
    }
    if(tag == "pro")//“产品列表”类信息ToProList
    {
        document.getElementById("dialogBoxClose").onclick=function(){ShowPro();};
    }
    if(tag == "ble")//“产品内容”类信息bleadd
    {
        document.getElementById("dialogBoxClose").onclick=function(){ShowBle();};
    }
    if(tag == "bleadd")//“产品内容”类信息页添加后跳转列表页
    {
        document.getElementById("dialogBoxClose").onclick=function(){ToProList();};//添加后回到列表页
    }
    if(tag == "hon")//“图片信息”类信息
    {
        document.getElementById("dialogBoxClose").onclick=function(){ShowHon();};
    }
    if(tag == "mess")//“访客留言”类信息
    {
        document.getElementById("dialogBoxClose").onclick=function(){ShowMess();};
    }
    if(tag == "down")//“文件下载”类信息
    {
        document.getElementById("dialogBoxClose").onclick=function(){showDown();};
    }
    if(tag == "sdlist")//“供求列表”类信息
    {
        document.getElementById("dialogBoxClose").onclick=function(){ShowSDList();};
    }
    if(tag == "sdinfo")//“供求内容”类信息sdinfoadd
    {
        document.getElementById("dialogBoxClose").onclick=function(){ShowSDInfo();};
    }
    if(tag == "sdinfoadd")//“供求内容”页面添加信息后跳转到列表页
    {
        document.getElementById("dialogBoxClose").onclick=function(){ToSDList();};//添加后回到列表页
    }
    //ShowSDInfo
    if(tag == "leftcol")//定制左侧栏目
    {
        document.getElementById("dialogBoxClose").onclick=function(){LeftCol("pleftcol");};
    }
    if(tag == "pleftcol")//定制左侧栏目
    {
        document.getElementById("dialogBoxClose").onclick=function(){LeftCol(tag);};
    }
    if(tag=="leftShow")
    {
        //alert("assss");
        document.getElementById("dialogBoxClose").onclick=function(){LeftShow(tag);};
    }
    if(tag=="useshow")
    {
        //alert("assss");
        document.getElementById("dialogBoxClose").onclick=function(){parent.window.location.href='UseShowDf.aspx';};
    }
}




//删除单条记录
function deleteById(id,cid,tag)
{
    if(confirm("确认删除该记录吗？"))
    {
        //当前页面的隐藏域赋值
        if(tag == "expic")
        {
            document.getElementById("Hidden1").value="deleteinfo";
            
            if(document.getElementById("hExId") != null)
            {
                document.getElementById("hExId").value=id;
            }
            
            //页面上“信息编号隐藏域”赋值
            if(document.getElementById("hID") != null)
            {
                document.getElementById("hID").value=cid;
            }
            if(document.getElementById("hidId") != null)
            {
                document.getElementById("hidId").value=cid;
            } 
            
            document.form1.submit();
            
            ShowExPic();
           
        }
        else
        {
            document.getElementById("Hidden1").value="delete";
        
            //页面上“信息编号隐藏域”赋值
            if(document.getElementById("hID") != null)
            {
                document.getElementById("hID").value=id;
            }
            if(document.getElementById("hidId") != null)
            {
                document.getElementById("hidId").value=id;
            }
            
            document.form1.submit();
            
            //alert('删除成功！');
            //删除完成后执行Ajax方法更新页面
            //此次的“Show***()”在“JS\base4.js”中要根据不同页面来分别调用相应的方法，
            if(tag == "sig")//“单页图文”类信息
            {
                ShowSin();
            }    
            if(tag == "newslist")//“新闻列表”类信息newsedit
            {
                ShowNewsList();
            }
            if(tag == "newsedit")//“新闻列表”页面编辑单条信息
            {
                ShowNewsList();
            }
            if(tag == "newsinfo")//“新闻内容”类信息
            {
                //ShowNewsInfo();           
                
                window.location.href="News.aspx?c_id=" + cid;//删除后回到列表页
            }
            if(tag == "pro")//“产品列表”类信息
            {
                ShowPro();
            }
            if(tag == "ble")//“产品内容”类信息
            {
               //ShowBle();
               window.location.href="Product.aspx?c_id=" + cid;
            }
            
            if(tag == "hon")//“图片信息”类信息
            {
                ShowHon();
            }
            if(tag == "mess")//“访客留言”类信息
            {
                ShowMess();
            }
            if(tag == "down")//“文件下载”类信息
            {
                showDown();
            }
            if(tag == "sdlist")//“供求列表”类信息
            {
                ShowSDList();
            }
            if(tag == "sddel")//“供求内容”类信息
            {
                //ShowSDInfo();
                window.location.href="SaD.aspx?c_id=" + cid;//删除后回到列表页
            }
        }
    }
}

/////////////////////////////
//控制评论功能开启状态
function opencommentbox(col)
{
    var cid = document.getElementById("hidC_id").value;
    var id = document.getElementById("hidId").value;
    var flag=document.getElementById("opencom");
    var com=document.getElementById("comment");
    var b=document.getElementById("openb");
    var typevalue = "";
    if (flag.checked)
    {
    
        typevalue = "开启";

//		    com.style.display="none";
//		    b.innerHTML="开启评论";
    } 
    else 
    {        
        typevalue = "关闭"; 
//		    com.style.display="";
//		    b.innerHTML="关闭评论";
    }
	
    if(confirm("是否确定修改"))
    {
        //调用后台修改评论状态的方法，得到状态值
        if(col == "news")//新闻类页面
        {
            var type = ShowASP_News_NewInfo.ChangeCommType(typevalue,cid,id);
        }
        else if(col == "pro")//产品类页面
        {
        
            var type = ShowASP_Product_ProductShow.ChangeCommType(typevalue,cid,id);
            
        }
        else if(col == "sad")//供求类页面
        {
            var type = ShowASP_SAndD_SaDshow.ChangeCommType(typevalue,cid,id);
        }
        if(type.value == "开启")
        {
            b.innerHTML="关闭评论";
            flag.checked = true;
            com.style.display="block";
            //style="display:block"
        }
        else
        {
            b.innerHTML="开启评论";
            flag.checked = false;
            com.style.display="none";
        }
    }
}

//定制左侧栏目
//栏目管理内页弹出编辑窗口
function showLeftCol(type)
{
    
    if(type=='leftcol') 
    {
        //清空隐藏域的值，并根据不同的操作赋值
        if(window.document.getElementById("assPos").value != "")
        {
            window.document.getElementById("assPos").value = "";            
        }
        window.document.getElementById("assPos").value = "leftcol";  
        
        //取得当前页面的infoid或cid
        var infoid = window.document.getElementById("hidId");
        var cid = window.document.getElementById("hidC_id");
        if(cid != null && infoid != null)
        {
            //单条信息页面
            ShowIframe("../../ShowASP/indexAsp/leftcolumn.aspx?c_id="+ cid.value +"&infoid="+ infoid.value ,'360','255','定制侧边栏目','leftcol');
        }
        else if(cid != null  && infoid == null)
        {
            //信息列表页面
            ShowIframe("../../ShowASP/indexAsp/leftcolumn.aspx?c_id="+ cid.value ,'360','255','定制侧边栏目','leftcol');
        }
    }
    else if(type=='pleftcol') 
    {
        //清空隐藏域的值，并根据不同的操作赋值
        if(parent.window.document.getElementById("assPos").value != "")
        {
            parent.window.document.getElementById("assPos").value = "";            
        }
        parent.window.document.getElementById("assPos").value = "pleftcol";  
        
        //取得当前页面的infoid或cid
        var infoid = parent.window.document.getElementById("hidId");
        var cid = parent.window.document.getElementById("hidC_id");
              
        if(cid != null && infoid != null)
        {
            //单条信息页面
            ShowIframe("../../ShowASP/indexAsp/leftcolumn.aspx?c_id="+ cid.value +"&infoid="+ infoid.value ,'360','255','定制侧边栏目','pleftcol');
        }
        else if(cid != null  && infoid == null)
        {
            //信息列表页面
            ShowIframe("../../ShowASP/indexAsp/leftcolumn.aspx?c_id="+ cid.value ,'360','255','定制侧边栏目','pleftcol');
        }
    }else if(type='leftShow')
    {
        ShowIframe("../../ShowASP/indexAsp/leftCol.aspx" ,'350','220','订制侧边栏目导航','leftShow');
    }
}

//定制侧边栏目
//判断栏目选中状态
function saveColId(id)
{
    var leftID = document.getElementById("hColId");
   
    var ch = document.getElementById("rd" + id);
    
    if(ch.checked==false)//某个按钮取消选中
    {
        leftID.value=leftID.value.replace(id+",","");//从编号隐藏域中清除   
        
        if(leftID.value == "" || leftID.value == ",")
        {
            document.getElementById("btSave").disabled=true;//保存按钮不可用   
            document.getElementById("btCanel").disabled=true;//删除按钮不可用   
        } 
        else
        {
            var lID=leftID.value.substring(0,leftID.value.length-1).split(',');
            
            if(lID.length >3)//记录栏目编号,最多3个栏目
            {         
                document.getElementById("btSave").disabled=true;//保存按钮不可用   
            }
            else//
            {   
                document.getElementById("btSave").disabled=false;//保存按钮可用            
            }
        }  
    }
    else//某个按钮选中
    {    
        
        var lID=leftID.value.substring(0,leftID.value.length-1).split(',');
        if(lID.length >=3)//记录栏目编号,最多3个栏目
        {
           
            //提示
            alert("最多定制三个侧边栏目！");
            ch.checked=false;
            //document.getElementById("btSave").disabled=true;//保存按钮不可用   
        }
        else//
        {   
            leftID.value += id+",";//记录选中栏目编号
            document.getElementById("btSave").disabled=false;//保存按钮可用
           
        }        
    } 
    // alert(leftID.value);
} 

//添加侧边栏目
function addLeftCol()
{
    var leftID = document.getElementById("hColId");
            
    var lID=leftID.value.substring(0,leftID.value.length-1).split(',');
    
    if(lID.length < 4)//记录栏目编号,最多3个栏目
    {         
        if(confirm("确认操作吗？"))
        {
            var hadd = document.getElementById("hAdd");
            if(hadd != null)
            {
                hadd.value = "add";
            }
            document.form1.submit();
            hadd.value = "";

            LeftCol("pleftcol");
            alert('操作成功！'); 

            window.location.href= document.URL;//"../../ShowASP/indexAsp/leftcolumn.aspx";//完成后回原页面
        }
    }
    else
    {
        alert("最多定制三个侧边栏目！");
        document.getElementById("btSave").disabled=true;//保存按钮不可用   
    }
}

//删除侧边栏目
function delLeftCol()
{
    if(confirm("确认操作吗？"))
    {
        var hadd = document.getElementById("hAdd");
        if(hadd != null)
        {
            hadd.value = "del";
        }
        document.form1.submit();
        hadd.value = "";

        LeftCol("pleftcol");
        alert('操作成功！'); 

         window.location.href= document.URL;//"../../ShowASP/indexAsp/leftcolumn.aspx";//完成后回原页面
    }
}

function updateShowCount(id)
{

    ShowIframe("../../ShowASP/script/leftcol_showcount.aspx?id="+id,'250','180','侧边栏目信息显示数量','pleftcol');
    //alert('操作成功！'); 
    //<a href="../../ShowASP/script/leftcol_showcount.aspx">../../ShowASP/script/leftcol_showcount.aspx</a>
}

//内页侧边栏目的全站搜索
function leftSearch()
{
    var keyword;
    var col;
    
    keyword = document.getElementById("txtKey").value;
    col = document.getElementById("sCol").options[document.getElementById("sCol").selectedIndex].value;
    
    location.href="../../ShowASP/ForumASP/search.aspx?col="+col+"&keyword="+escape(keyword)+"";
}
