﻿// JScript 文件

function openLinkEdit(id,contentType)
{
    if(typeof(id) == "undefined" || id == null)
    {
        id = "";
    }
    window.open("IndexLink.aspx?id=" + id+"&contentType="+contentType);
}
function openNavEdit(id,typeCode)
{
    if(typeof(id) == "undefined" || id == null)
    {
        id = "";
    }
    if(typeof(typeCode) == "undefined" || typeCode == null)
    {
        typeCode = getRequestParameter("type");
    }
    window.open("NavInfo.aspx?id=" + id + "&type=" + typeCode);
}
function openMagazineEdit(id)
{
    if(typeof(id) == "undefined" || id == null)
    {
        id = "";
    }
    window.open("MagazineInfo.aspx?id=" + id);
}
function openInfoEdit(id,type)
{
    if(type != null && type != "") type = encodeURIComponent(type);
    window.open("InfoDetailView.aspx?id=" + id+"&type="+type);
}
function openInfoComments(newsId)
{
    if(typeof(newsId) == "undefined" || newsId == null)
    {
        newsId = "";
    }
    window.open("InfoComments.aspx?newsId=" + newsId);
}

function ImageSelect(currentPath,currentFile,controlId,ImageControlId)
{
    if(typeof(currentPath) == "undefined" || currentPath == null || currentPath=="") return ;
    if(typeof(currentFile) == "undefined" || currentFile == null) currentFile = "";
    if(typeof(controlId) == "undefined" || controlId == null) controlId = "";
    if(typeof(ImageControlId) == "undefined" || ImageControlId == null) ImageControlId = "";
    currentPath = encodeURIComponent(currentPath);
    currentFile = encodeURIComponent(currentFile);
    var url = "ImageManager.aspx?"+
    "currentPath="+currentPath+"&currentFile=" + currentFile+"&controlId=" + controlId + "&imageControlId=" + ImageControlId;
    window.open(url);
}
function doImageSelect(ControlId,currImagePath)
{
    if(typeof(currImagePath) == "undefined" || currImagePath == null || currImagePath == ''){
        currImagePath = "currImagePath";
    }
    var currImagePath = document.getElementById(currImagePath).value;
    var path = document.getElementById(ControlId).value;
    ImageSelect(currImagePath,path,ControlId);
}
function GetEditorHtml(hiddenControlId,innerTextControlId,eWebEditorControl)
{
    if(typeof(eWebEditorControl) == "undefined" && eWebEditorControl == null)
    {
        eWebEditorControl = eWebEditor1;
    }
    document.getElementById(hiddenControlId).value = eWebEditorControl.getHTML();
    if(typeof(innerTextControlId) != "undefined" && innerTextControlId!=null)
    {
        document.getElementById(innerTextControlId).value = eWebEditorControl.eWebEditor.document.body.innerText;
    }
}
function TranToLink(selectId)
{
    var linkSelect = document.getElementById(selectId);
    if(linkSelect.length > 0)
    {
        var linkId = linkSelect.options[linkSelect.selectedIndex].value;
        var linkUrl = doAjaxCall("GetLinkUrl",linkId);
        window.location.href = linkUrl;
    }
}
//合并表格
function MergeTable(source,dest)
{
    var row;
    var cell;
    var sourceTb = document.all(source);
    var destTb = document.all(dest);
    for (var i=0; i<sourceTb.rows.length; i++)
   {
         row = document.createElement("tr");
         for (var j=0; j<sourceTb.rows(i).cells.length; j++)
        {
             cell = document.createElement("td");
             row.appendChild(cell);
             //复制对象
             for(k=0;k<sourceTb.rows(i).cells(j).all.length;k++)
                 cell.appendChild(sourceTb.rows(i).cells(j).all.item(k));
        }
        destTb.tBodies(0).appendChild(row);
    }
    for (var i=sourceTb.rows.length-1; i>=0; i--)
    {
        sourceTb.deleteRow(i)
    }
}
function ChangeTableLayout()
{
     if(document.all('tbHeader1') == null)
        MergeTable('tbForm1','GridView1');
    else
        MergeTable('tbForm1','tbHeader1');
    if(document.all('tbHeader2') == null)
        MergeTable('tbForm2','GridView2');
    else
        MergeTable('tbForm2','tbHeader2');
}

