// ドキュメントリンク
var GET_DOCUMENT_LINK_INFO = "/DocumentSearchService/GetDocumentLinkInfo.do?";
var DOC_NO = "documentNO1";
var KISYU_NO = "kisyuNO";
var DOCUMENT_TYPE = "documentType";
var SHIRYO_ID = "shiryoID";
var SEQ_NO = "seqNo";

var PDF_ICON_IMG="/melfansweb/grparts/pdficon.gif";

var DIRECT_LINK_CATALOG  ="/melfansweb/documentsearch/catalog/cataloginfoaction.do?kisyu=";
var DIRECT_LINK_TECHNEWS ="/melfansweb/documentsearch/technews/technicalNews.do?kisyu=";
var DIRECT_LINK_SALESE   ="/melfansweb/documentsearch/sales/salesService.do?kisyu=";
var DIRECT_LINK_NPRODUCT ="/melfansweb/documentsearch/nproduct/newProductNews.do?kisyu=";
var DIRECT_LINK_MANUAL   ="/melfansweb/documentsearch/manualinfo.do?kisyu=";

// 要素番号
var xmlno = 0;
var xmldispno = 1;
var xmlurl = 2;
var xmlver = 3;
var xmltitle = 4;
var xmlimgKisyu = 5;
var xmlimgCatalog = 6;
var xmlimgOption = 7;
var xmldate = 8;
var xmlshiryoStatus= 9;
var xmlshiryoDel=10;
var xmlanchor=11;
var xmlkisyupath =12;
var xmlbunruil=13;
var xmlbunruis=14;
var xmlpdfsize=15;


function createXmlHttp(){
 if(window.XMLHttpRequest){
  // IE7以上、SAFARI、FireFox
  return new XMLHttpRequest();
 }
 else if(window.ActiveXObject){
  // IE5、IE6
  try {
   // MSXML3
   return new ActiveXObject("Msxml2.XMLHTTP");
  } catch(e) {
   // MSXML2
   return new ActiveXObject("Microsoft.XMLHTTP");
  }
 }
 else{
  // 非対応のブラウザ
  return null;
 }
}

// カタログリンク表示
function toCatalogInfo(docNo, kisyuNo, anchorType, directFlg, anchorIssueFlag, anchorNewLine, anchorTitle, imgWidth, imgHeight, imgBorder, pdfPage, pdfVol){
    if(docNo != null && docNo != "" && kisyuNo != null && kisyuNo != ""){
         var ret = makeLinkPage(docNo, kisyuNo, anchorType, directFlg, anchorIssueFlag, anchorNewLine, anchorTitle, imgWidth, imgHeight, imgBorder, pdfPage, pdfVol, 'catalog', DIRECT_LINK_CATALOG);
         if (anchorType == "10" || anchorType == "11") {
           if (ret != null && ret != "") {
              return ret;
           } else {
              return "";
           }
         }
     }
}
// カタログリンク表示
function toCatalogInfoA(kisyuNo, anchorType, titleType, directFlg, anchorIssueFlag, anchorNewLine, anchorTitle, imgWidth, imgHeight, imgBorder, pdfPage, pdfVol){
    if( kisyuNo != null && kisyuNo != "" && anchorType != null && anchorType != "" && titleType != null && titleType != ""){
         var ret = makeLinkPage2(kisyuNo, anchorType, titleType, directFlg, anchorIssueFlag, anchorNewLine, anchorTitle, imgWidth, imgHeight, imgBorder, pdfPage, pdfVol, 'cataloga', DIRECT_LINK_CATALOG);
         if (anchorType == "10" || anchorType == "11") {
           if (ret != null && ret != "") {
              return ret;
           } else {
              return "";
           }
         }
     }
}
//テクニカルニュースリンク表示
function toTechnewsInfo(docNo, kisyuNo, anchorType, directFlg, anchorIssueFlag, anchorNewLine, anchorTitle, imgWidth, imgHeight, imgBorder, pdfPage, pdfVol){
    if(docNo != null && docNo != "" && kisyuNo != null && kisyuNo != ""){
         var ret = makeLinkPage(docNo, kisyuNo, anchorType, directFlg, anchorIssueFlag, anchorNewLine, anchorTitle, imgWidth, imgHeight, imgBorder, pdfPage, pdfVol, 'technews', DIRECT_LINK_TECHNEWS);
         if (anchorType == "10" || anchorType == "11") {
           if (ret != null && ret != "") {
              return ret;
           } else {
              return "";
           }
         }
     }
}
// セールスとサービスリンク表示
function toSalesInfo(docNo, kisyuNo, anchorType, directFlg, anchorIssueFlag, anchorNewLine, anchorTitle, imgWidth, imgHeight, imgBorder, pdfPage, pdfVol){
    if(docNo != null && docNo != "" && kisyuNo != null && kisyuNo != ""){
         var ret = makeLinkPage(docNo, kisyuNo, anchorType, directFlg, anchorIssueFlag, anchorNewLine, anchorTitle, imgWidth, imgHeight, imgBorder, pdfPage, pdfVol, 'sales', DIRECT_LINK_SALESE);
         if (anchorType == "10" || anchorType == "11") {
           if (ret != null && ret != "") {
              return ret;
           } else {
              return "";
           }
         }
    }
}
// 新製品ニュースリンク表示
function toNproductInfo(docNo, kisyuNo, anchorType, directFlg, anchorIssueFlag, anchorNewLine, anchorTitle, imgWidth, imgHeight, imgBorder, pdfPage, pdfVol){
    if(docNo != null && docNo != "" && kisyuNo != null && kisyuNo != ""){
         var ret = makeLinkPage(docNo, kisyuNo, anchorType, directFlg, anchorIssueFlag, anchorNewLine, anchorTitle, imgWidth, imgHeight, imgBorder, pdfPage, pdfVol, 'nproduct', DIRECT_LINK_NPRODUCT);
         if (anchorType == "10" || anchorType == "11") {
           if (ret != null && ret != "") {
              return ret;
           } else {
              return "";
           }
         }
    }
}
// マニュアルリンク表示
function toManualInfo(docNo, kisyuNo, anchorType, directFlg, anchorIssueFlag, anchorNewLine, anchorTitle, imgWidth, imgHeight, imgBorder, pdfPage, pdfVol){
    if(docNo != null && docNo != "" && kisyuNo != null && kisyuNo != ""){
        var ret = makeLinkPage(docNo, kisyuNo, anchorType, directFlg, anchorIssueFlag, anchorNewLine, anchorTitle, imgWidth, imgHeight, imgBorder, pdfPage, pdfVol, 'manual', DIRECT_LINK_MANUAL);
         if (anchorType == "10" || anchorType == "11") {
          if (ret != null && ret != "") {
             return ret;
          } else {
              return "";
          }
        }
    } else if (docNo != null && docNo != "") {
        var ret = makeLinkPageOrgManual(docNo);
         if (anchorType == "10" || anchorType == "11") {
          if (ret != null && ret != "") {
             return ret;
          } else {
              return "";
          }
        }
    }
}
// マニュアルリンク表示 マイページ用
function toManualInfoA(docNo, kisyuNo, anchorType, directFlg, anchorIssueFlag, anchorNewLine, anchorTitle, imgWidth, imgHeight, imgBorder, pdfPage, pdfVol){
    if(docNo != null && docNo != "" && kisyuNo != null && kisyuNo != ""){
        var obj = document.getElementById(kisyuNo);
        if (obj != null) {
            makeLinkPageOrgManualA(docNo,kisyuNo);
            return;
        }
        var ret = makeLinkPage(docNo, kisyuNo, anchorType, directFlg, anchorIssueFlag, anchorNewLine, anchorTitle, imgWidth, imgHeight, imgBorder, pdfPage, pdfVol, 'manual', DIRECT_LINK_MANUAL);
         if (anchorType == "10" || anchorType == "11") {
          if (ret != null && ret != "") {
             return ret;
          } else {
             return "";
          }
        }
    }
}
// その他のPDF情報リンク表示
function toOthersInfo(docNo, kisyuNo, anchorType, directFlg, anchorIssueFlag, anchorNewLine, anchorTitle, imgWidth, imgHeight, imgBorder, pdfPage, pdfVol){
    if(docNo != null && docNo != "" && kisyuNo != null && kisyuNo != ""){
        var ret = makeLinkPage(docNo, kisyuNo, anchorType, directFlg, anchorIssueFlag, anchorNewLine, anchorTitle, imgWidth, imgHeight, imgBorder, pdfPage, pdfVol, 'other');
         if (anchorType == "10" || anchorType == "11") {
          if (ret != null && ret != "") {
             return ret;
          } else {
              return "";
          }
        }
    }
}

//******************************************************************************************************************************************************
// ドキュメントリンク HTMLイメージ作成
//******************************************************************************************************************************************************
function makeLinkPage(docNo, kisyuNo, anchorType, directFlg, anchorIssueFlag, anchorNewLine, anchorTitle, imgWidth, imgHeight, imgBorder, pdfPage, pdfVol, docType, directlink) {
    // ドキュメントリンクへの通信
    // パラメータの設定
    var parameter = DOC_NO + "=" + docNo + "&" + KISYU_NO + "=" + kisyuNo + "&" +DOCUMENT_TYPE + "=" + docType;
    if (docNo == "") {
        parameter = KISYU_NO + "=" + kisyuNo + "&" +DOCUMENT_TYPE + "=" + docType;
    }
    if (pdfVol != null && pdfVol != "") {
        parameter += "&" + SEQ_NO + "=" + pdfVol;
    }
    var httpObj = createXmlHttp();
    if(httpObj == null){
        return;
    }
    for (i=0; i< 2; i++) {
    // 通信をOPEN
    httpObj.open("POST", GET_DOCUMENT_LINK_INFO, false);
    httpObj.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
    httpObj.send(parameter);
    if(httpObj.readyState == 4){
        if(httpObj.status == 200){
             // 返り値ＸＭＬの取得
             xmlData  = httpObj.responseXML;
             var errorcode = xmlData.getElementsByTagName("ErrorCD")[0].childNodes[0].nodeValue;
             if(errorcode == 0){
               datas = ansXmlDataToArray(xmlData);
               var dispStatus = dispStatusSet(datas);
               var directurl = directlink + datas[xmlkisyupath];
               var pdfurl = pdfurlSet(datas);
               var documentNo = documentNoSet(datas);

               var chtm = new Array();
               chtm.push("<table>");
               // タイトルタイプ
               if ( (Number(anchorType) >= 0 && Number(anchorType) < 5) || anchorType == "11" ) {
                   chtm.push(titleSet(anchorType, documentNo, datas[xmlver], datas[xmltitle], anchorTitle, anchorNewLine, directFlg, pdfurl, directurl,datas[xmlanchor], datas[xmlno], pdfPage));
                   if(anchorIssueFlag == "1"){
                       chtm.push("<tr><td class='docLinkDate'>" + datas[xmldate] +"</td></tr>");
                   }
               }else if(anchorType == "5"){
                   chtm.push(imageSet(documentNo, datas[xmlimgKisyu], directFlg, pdfurl, directurl, datas[xmlanchor], imgWidth, imgHeight, datas[xmlno], imgBorder, pdfPage));
               }else if(anchorType == "6"){
                   // 画像（カタログ一覧用）
                   chtm.push(imageSet(documentNo, datas[xmlimgCatalog], directFlg, pdfurl, directurl, datas[xmlanchor], imgWidth, imgHeight, datas[xmlno], imgBorder, pdfPage));
               }else if(anchorType == "7") {
                   // 画像（任意）
                   chtm.push(imageSet(documentNo, datas[xmlimgOption], directFlg, pdfurl, directurl, datas[xmlanchor], imgWidth, imgHeight, datas[xmlno], imgBorder, pdfPage));
               }else if(anchorType == "8") {
                   // 画像（PDFアイコン）
                   chtm.push(imageSet(documentNo, PDF_ICON_IMG, directFlg, pdfurl, directurl, datas[xmlanchor], imgWidth, imgHeight, datas[xmlno], imgBorder, pdfPage));
               }else if(anchorType == "9") {
                   // ページジャンプ
                   pageLocation(directFlg, pdfurl, directurl, datas[xmlno], pdfPage);
                   return;
               }else if(anchorType == "10") {
                   // ページジャンプ
                   return getUrl(directFlg, pdfurl, directurl, pdfPage);
               }else if(anchorType == "12") {
                   uptoolTopics(anchorType, documentNo, datas[xmlver], datas[xmltitle], anchorTitle, anchorNewLine, directFlg, pdfurl, directurl,datas[xmlanchor], datas[xmlno], pdfPage);
                   return;
               }else if(anchorType == "13") {
                   // 発行年月のみ
                   if (datas[xmldate] != null && datas[xmldate] != "") {
                       document.write(datas[xmldate]);
                   } else {
                       document.write(errOut(anchorType, anchorTitle,docNo));
                   }
                   return;
               }else if(anchorType == "14") {
                   // サイズのみ
                   if (datas[xmlpdfsize] != null && datas[xmlpdfsize] != "") {
                       var orgsize = Number(datas[xmlpdfsize]);
                       orgsize = orgsize / 1024 / 1024;
                       var setsize = "" +orgsize;
                       if ( setsize.indexOf(".") != -1) {
                           var splitsize = setsize.split(".");
                           setsize = splitsize[0] + "." + splitsize[1].substring(0,1);
                       } else {
                           setsize = setsize + ".0";
                       }
                       if (setsize == "0.0") {
                           setsize = "0.1";
                       }
                       document.write(setsize + "MB");
                   } else {
                       document.write(errOut(anchorType, anchorTitle,docNo));
                   }
                   return;
               }else if(anchorType == "15") {
                   // 分類のみ
                   if (datas[xmlbunruil] != null && datas[xmlbunruil] != "") {
                       document.write(datas[xmlbunruil]);
                   } else {
                       document.write(errOut(anchorType, anchorTitle,docNo));
                   }
                   return;
               }else {
               }
               // ステータス
               chtm.push(dispStatus);
               chtm.push("</table>");
               if (anchorType == "11") {
                   return chtm.join("");
               } else {
                   document.write(chtm.join(""));
               }
               return;
             } else {
               if (anchorType == "10" || anchorType == "11") {
                 return "";
               }
               document.write(errOut(anchorType, anchorTitle,docNo));
             }
             break;
         }else{
           // 通信エラー
           if (i > 0) {
             if (anchorType == "10" || anchorType == "11") {
               return "";
             }
             document.write(errOut(anchorType, anchorTitle,docNo));
           }
         }
       }
     }
}

//******************************************************************************************************************************************************
// ドキュメントリンク おすすめカタログ
//******************************************************************************************************************************************************
function makeLinkPage2(kisyuNo, anchorType, titleType, directFlg, anchorIssueFlag, anchorNewLine, anchorTitle, imgWidth, imgHeight, imgBorder, pdfPage, pdfVol, docType, directlink) {
    // ドキュメントリンクへの通信
    // パラメータの設定
    var parameter = KISYU_NO + "=" + kisyuNo + "&" +DOCUMENT_TYPE + "=" + docType;
    var httpObj = createXmlHttp();
    if(httpObj == null){
        return;
    }
    for (i=0; i< 2; i++) {
    // 通信をOPEN
    httpObj.open("POST", GET_DOCUMENT_LINK_INFO, false);
    httpObj.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
    httpObj.send(parameter);
    if(httpObj.readyState == 4){
        if(httpObj.status == 200){
             // 返り値ＸＭＬの取得
             xmlData  = httpObj.responseXML;
             var errorcode = xmlData.getElementsByTagName("ErrorCD")[0].childNodes[0].nodeValue;
             if(errorcode == 0){
               var datas = new Array();
               datas = ansXmlDataToArray(xmlData);

               var dispStatus = dispStatusSet(datas);
               var directurl = directlink + datas[xmlkisyupath];
               var pdfurl = pdfurlSet(datas);
               var documentNo = documentNoSet(datas);

               var chtm = new Array();
               chtm.push("<table width='100%'>");
               // 画像タイプ
               if(anchorType == "5"){
                   // 画像（機種トップ用）
                   chtm.push(imageSet(documentNo, datas[xmlimgKisyu], directFlg, pdfurl, directurl, datas[xmlanchor], imgWidth, imgHeight, datas[xmlno], imgBorder, pdfPage));
               }else if(anchorType == "6"){
                   // 画像（カタログ一覧用）
                   chtm.push(imageSet(documentNo, datas[xmlimgCatalog], directFlg, pdfurl, directurl, datas[xmlanchor], imgWidth, imgHeight, datas[xmlno], imgBorder, pdfPage));
               }else if(anchorType == "7") {
                   // 画像（任意）
                   chtm.push(imageSet(documentNo, datas[xmlimgOption], directFlg, pdfurl, directurl, datas[xmlanchor], imgWidth, imgHeight, datas[xmlno], imgBorder, pdfPage));
               }else if(anchorType == "8") {
                   // 画像（PDFアイコン）
                   chtm.push(imageSet(documentNo, PDF_ICON_IMG, directFlg, pdfurl, directurl, datas[xmlanchor], imgWidth, imgHeight, datas[xmlno], imgBorder, pdfPage));
               }else if(anchorType == "9") {
                   // ページジャンプ
                   pageLocation(directFlg, pdfurl, directurl, datas[xmlno], pdfPage);
                   return;
               }

               // タイトルタイプ
               chtm.push(titleSet(titleType, documentNo, datas[xmlver], datas[xmltitle], anchorTitle, anchorNewLine,0,'','','', datas[xmlno], pdfPage));

               // 発行(改定) 日付フラグ
               if (anchorIssueFlag == "1") {
                   chtm.push("<tr><td class='docLinkDate'>");
                   chtm.push("[" +datas[xmldate]+ "]");
                   chtm.push("</td></tr>");
               }
               // ステータス
               chtm.push(dispStatus);
               chtm.push("</table>");
               // 表示処理
               document.write(chtm.join(""));
               return;
             } else {
               document.write(errOut(titleType, anchorTitle));
             }
             break;
         }else{
         // 通信エラー
           if (i > 0) {
             document.write(errOut(titleType, anchorTitle));
           }
         }
     }
     }
}

//******************************************************************************************************************************************************
// マニュアルリンク（引数１）
//******************************************************************************************************************************************************
function makeLinkPageOrgManual(docNo) {

    var NO_DATA = "マニュアル番号";

    // ドキュメントリンクへの通信
    // パラメータの設定
    var parameter = DOC_NO + "=" + docNo + "&" +DOCUMENT_TYPE + "=manual";
    var httpObj = createXmlHttp();
    if(httpObj == null){
        return;
    }
    for (i=0; i< 2; i++) {
    // 通信をOPEN
    httpObj.open("POST", GET_DOCUMENT_LINK_INFO, false);
    httpObj.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
    httpObj.send(parameter);
    if(httpObj.readyState == 4){
        if(httpObj.status == 200){
             // 返り値ＸＭＬの取得
             xmlData  = httpObj.responseXML;
             var errorcode = xmlData.getElementsByTagName("ErrorCD")[0].childNodes[0].nodeValue;
             if(errorcode == 0){
               var chtm = new Array();
               datas = ansXmlDataToArray(xmlData);
               var dispStatus = dispStatusSet(datas);
               var pdfurl = pdfurlSet(datas);
               var documentNo = documentNoSet(datas);
               if(pdfurl != null && pdfurl != "" && documentNo != null &&documentNo != "") {
                 chtm.push("<a href=\"");
                 chtm.push(pdfurl);
                 chtm.push("\">");
                 chtm.push(documentNo);
                 chtm.push("-");
                 chtm.push(datas[xmlver]);
                 chtm.push("</a>");
                 document.write(chtm.join(""));
                 return;
               }
             }
         }else{
         // 通信エラー
         }
     }
     }
     chtm.push(docNo);
     document.write(chtm.join(""));
}

//******************************************************************************************************************************************************
// マニュアルリンク（引数２）
//******************************************************************************************************************************************************
function makeLinkPageOrgManualA(docNo, id) {

    var NO_DATA = "マニュアル番号";
    var obj = document.getElementById(id);

    // ドキュメントリンクへの通信
    // パラメータの設定
    var parameter = DOC_NO + "=" + docNo + "&" +DOCUMENT_TYPE + "=manual";
    var httpObj = createXmlHttp();
    if(httpObj == null){
        return;
    }
    for (i=0; i< 2; i++) {
    // 通信をOPEN
    httpObj.open("POST", GET_DOCUMENT_LINK_INFO, false);
    httpObj.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
    httpObj.send(parameter);
    if(httpObj.readyState == 4){
        if(httpObj.status == 200){
             // 返り値ＸＭＬの取得
             xmlData  = httpObj.responseXML;
             var errorcode = xmlData.getElementsByTagName("ErrorCD")[0].childNodes[0].nodeValue;
             if(errorcode == 0){
               var chtm = new Array();
               datas = ansXmlDataToArray(xmlData);
               var dispStatus = dispStatusSet(datas);
               var pdfurl = pdfurlSet(datas);
               var documentNo = documentNoSet(datas);
               if(pdfurl != null && pdfurl != "" && documentNo != null &&documentNo != "") {
                 obj.innerHTML = "<a href=\"" + pdfurl + "\">" + documentNo + "-" + datas[xmlver] + "</a>";
                 return;
               }
             }
         }else{
         // 通信エラー
         }
     }
     }
    obj.innerHTML = NO_DATA;
}

//---------------------------------------------
// ドキュメントリンク共通ロジック
// 応答XMLデータを変数に格納します
// 引数 xmlData：応答XMLデータ
//---------------------------------------------
function ansXmlDataToArray(xmlData) {
   var ansXmlData = new Array();
   if(xmlData.getElementsByTagName("DocAnchor")[0] != null && xmlData.getElementsByTagName("DocAnchor")[0].childNodes[0] != null){
     ansXmlData[xmlanchor] = xmlData.getElementsByTagName("DocAnchor")[0].childNodes[0].nodeValue;
   }
   if(xmlData.getElementsByTagName("DocNumber")[0] != null && xmlData.getElementsByTagName("DocNumber")[0].childNodes[0] != null){
     ansXmlData[xmlno] = xmlData.getElementsByTagName("DocNumber")[0].childNodes[0].nodeValue;
   }
   if(xmlData.getElementsByTagName("DocDispNumber")[0] != null && xmlData.getElementsByTagName("DocDispNumber")[0].childNodes[0] != null){
     ansXmlData[xmldispno] = xmlData.getElementsByTagName("DocDispNumber")[0].childNodes[0].nodeValue;
   }
   if(xmlData.getElementsByTagName("DocKisyuPath")[0] != null && xmlData.getElementsByTagName("DocKisyuPath")[0].childNodes[0] != null){
     ansXmlData[xmlkisyupath] = xmlData.getElementsByTagName("DocKisyuPath")[0].childNodes[0].nodeValue;
   }
   if(xmlData.getElementsByTagName("DocPdfURL")[0] != null && xmlData.getElementsByTagName("DocPdfURL")[0].childNodes[0] != null){
       ansXmlData[xmlurl] = xmlData.getElementsByTagName("DocPdfURL")[0].childNodes[0].nodeValue;
   }
   if (xmlData.getElementsByTagName("DocPdfVer")[0] != null && xmlData.getElementsByTagName("DocPdfVer")[0].childNodes[0] != null) {
       ansXmlData[xmlver] = xmlData.getElementsByTagName("DocPdfVer")[0].childNodes[0].nodeValue;
   }
   if(xmlData.getElementsByTagName("DocTitle")[0] != null && xmlData.getElementsByTagName("DocTitle")[0].childNodes[0] != null){
     ansXmlData[xmltitle] = xmlData.getElementsByTagName("DocTitle")[0].childNodes[0].nodeValue;
   }
   if(xmlData.getElementsByTagName("DocImgKisyuURL")[0] != null && xmlData.getElementsByTagName("DocImgKisyuURL")[0].childNodes[0] != null){
       ansXmlData[xmlimgKisyu] = xmlData.getElementsByTagName("DocImgKisyuURL")[0].childNodes[0].nodeValue;
   }
   if(xmlData.getElementsByTagName("DocImgCatalogURL")[0] != null && xmlData.getElementsByTagName("DocImgCatalogURL")[0].childNodes[0] != null){
       ansXmlData[xmlimgCatalog] = xmlData.getElementsByTagName("DocImgCatalogURL")[0].childNodes[0].nodeValue;
   }
   if(xmlData.getElementsByTagName("DocImgOptionURL")[0].childNodes[0] != null && xmlData.getElementsByTagName("DocImgOptionURL")[0].childNodes[0] != null){
       ansXmlData[xmlimgOption] = xmlData.getElementsByTagName("DocImgOptionURL")[0].childNodes[0].nodeValue;
   }
   if(xmlData.getElementsByTagName("DocDate")[0] != null && xmlData.getElementsByTagName("DocDate")[0].childNodes[0] != null){
     var date = xmlData.getElementsByTagName("DocDate")[0].childNodes[0].nodeValue;
     var buff = date.split("/");
     ansXmlData[xmldate] = buff[0] + "年" + buff[1] + "月";
   }
   if(xmlData.getElementsByTagName("DocStatus")[0] != null && xmlData.getElementsByTagName("DocStatus")[0].childNodes[0] != null){
     ansXmlData[xmlshiryoStatus] = xmlData.getElementsByTagName("DocStatus")[0].childNodes[0].nodeValue;
   }
   if(xmlData.getElementsByTagName("DocRegistType")[0] != null && xmlData.getElementsByTagName("DocRegistType")[0].childNodes[0] != null){
     ansXmlData[xmlshiryoDel] = xmlData.getElementsByTagName("DocRegistType")[0].childNodes[0].nodeValue;
   }
   if(xmlData.getElementsByTagName("DocBunruiL")[0] != null && xmlData.getElementsByTagName("DocBunruiL")[0].childNodes[0] != null){
     ansXmlData[xmlbunruil] = xmlData.getElementsByTagName("DocBunruiL")[0].childNodes[0].nodeValue;
   }
   if(xmlData.getElementsByTagName("DocBunruiS")[0] != null && xmlData.getElementsByTagName("DocBunruiS")[0].childNodes[0] != null){
     ansXmlData[xmlbunruis] = xmlData.getElementsByTagName("DocBunruiS")[0].childNodes[0].nodeValue;
   }
   if(xmlData.getElementsByTagName("DocPdfSize")[0] != null && xmlData.getElementsByTagName("DocPdfSize")[0].childNodes[0] != null){
     ansXmlData[xmlpdfsize] = xmlData.getElementsByTagName("DocPdfSize")[0].childNodes[0].nodeValue;
   }
   return ansXmlData;
}

//---------------------------------------------
// ドキュメントリンク共通ロジック
// 登録状態をHTMLイメージを作成します。
// 引数 datas：応答XMLデータ配列
// 戻り値　　；登録状態HTMLイメージ
//---------------------------------------------
function dispStatusSet(datas) {
   var dispStatus = new Array();
   if (datas[xmlshiryoStatus] != null && datas[xmlshiryoStatus] != "") {
       dispStatus.push("<tr>");
       dispStatus.push("<td class='docstatus'><span class='docLinkStatus'>");
       dispStatus.push(datas[xmlshiryoStatus]);
       if (datas[xmlshiryoDel] != null && datas[xmlshiryoDel] != "") {
           dispStatus.push("&nbsp;<span class='docLinkDel'>(");
           dispStatus.push(datas[xmlshiryoDel]);
           dispStatus.push(")</span>");
       }
       dispStatus.push("</span></td></tr>");
   }
   return dispStatus.join("");
}

//---------------------------------------------
// ドキュメントリンク共通ロジック
// 資料番号の作成を行います。
//---------------------------------------------
function documentNoSet(datas) {
   var documentNo = '';
   if (datas[xmldispno] != null) {
       documentNo = datas[xmldispno];
   } else {
       documentNo = datas[xmlno];
   }
   return documentNo;
}

function pdfurlSet(datas) {
   var pdfUrl ='';
//   if (datas[xmlurl] == null || datas[xmlurl] == '') {
//       pdfUrl = datas[xmlanchor];
//   } else {
       pdfUrl = datas[xmlurl];
//   }
   return pdfUrl;
}

//---------------------------------------------
// ドキュメントリンク共通ロジック
// タイトルのHTMLイメージを作成します。
//---------------------------------------------
function titleSet(titleType, docNo, docVer, title, anchorTitle, anchorNewLine, directFlg, pdfUrl, directUrl, anchorUrl, no, pdfPage) {
   var titlehtm = new Array();
   // タイトルタイプ
   titlehtm.push("<tr><td class='docLinkSiryo'>");
   // ダイレクト表示フラグ
   if(directFlg == 0){
   }else if(directFlg == 1){
       var setPdfUrl = pdfUrl;
       if (pdfPage != null && pdfPage != "") {
           setPdfUrl = pdfUrl + "#page="+pdfPage;
       }
       titlehtm.push("<a href='" + setPdfUrl + "' title='" + docNo + "' target='_blank'>");
       titlehtm.push("<span onClick=\"javascript: pageTracker._trackPageview('" + setPdfUrl + "');\">");
   } else if(directFlg == 2) {
       titlehtm.push("<a href='" + directUrl + "#" + no + "' title='" + docNo + "' target='_top'>");
       titlehtm.push("<span onClick=\"javascript: pageTracker._trackPageview('" + directUrl + "');\">");
   } else {
   }
   if(titleType == "0" || titleType == "11"){
     //資料番号 + "-" + バージョン
       if (docVer != null && docVer != "") {
           titlehtm.push(docNo + "-" + docVer);
       } else {
           titlehtm.push(docNo);
       }
   }else if(titleType == "1"){
       //資料番号 + バージョン
       if (docVer != null && docVer != "") {
           titlehtm.push(docNo + docVer);
       } else {
           titlehtm.push(docNo);
       }
   }else if(titleType == "2"){
       //資料番号
       titlehtm.push(docNo);
   }else if(titleType == "3"){
       //資料名称
       var setTitle;
       if (anchorNewLine != null && anchorNewLine != "") {
         var buf1 = title.substring(0, anchorNewLine);
         var buf2 = title.substring(anchorNewLine);
         setTitle = buf1+"<br>"+buf2;
       } else {
         setTitle =title;
       }
       titlehtm.push(setTitle);
   }else if(titleType == "4"){
       //任意文字を設定
       titlehtm.push(anchorTitle);
   } else {
       return '';
   }
   // ダイレクト表示フラグ
   if(directFlg == 0){
   }else if(directFlg == 1){
       titlehtm.push("</span>");
       titlehtm.push("</a>");
   }else if(directFlg == 2){
       titlehtm.push("</span>");
       titlehtm.push("</a>");
   }else{
   }
   titlehtm.push("</td></tr>");
   return titlehtm.join("");
}

//---------------------------------------------
// ドキュメントリンク共通ロジック
// 画像のHTMLイメージを作成します。
//---------------------------------------------
function imageSet(docno, imageFile, directFlg, pdfUrl, directUrl, anchorUrl, imgWidth, imgHeight, no, imgBorder, pdfPage) {
   var imghtm = new Array();
   // 画像表示エリア
   imghtm.push("<tr><td class='docLinkImage'>");
   // ダイレクト表示フラグ
   if(directFlg == 0){
   }else if(directFlg == 1){
       if (no == anchorUrl ) {
           var setPdfUrl = pdfUrl;
           if (pdfPage != null && pdfPage != "") {
               setPdfUrl = pdfUrl + "#page="+pdfPage;
           }
           imghtm.push("<a href='" + setPdfUrl + "' title='" + docno + "' target='_blank'>");
           imghtm.push("<span onClick=\"javascript: pageTracker._trackPageview('" + setPdfUrl + "');\">");
       } else {
           imghtm.push("<a href='" + anchorUrl + "' title='" + docno + "' target='_top'>");
           imghtm.push("<span onClick=\"javascript: pageTracker._trackPageview('" + anchorUrl + "');\">");
       }
   } else if(directFlg == 2) {
       imghtm.push("<a href='" + directUrl + "#" + no + "' title='" + docno + "' target='_top'>");
       imghtm.push("<span onClick=\"javascript: pageTracker._trackPageview('" + directUrl + "');\">");
   } else {
   }
   // 画像
   if (imgBorder != null && imgBorder == "1") {
       imghtm.push("<img border='1' src = '" + imageFile + "'");
   } else {
       imghtm.push("<img border='0' src = '" + imageFile + "'");
   }

   // 横幅設定
   if (imgWidth != null && imgWidth != "") {
       imghtm.push(" width='"+ imgWidth  + "'");
   }
   // 縦幅設定
   if (imgHeight != null && imgHeight != "") {
       imghtm.push(" height='"+ imgHeight + "'");
   }
   imghtm.push(" >");

   // ダイレクト表示フラグ
   if(directFlg == 0){
   }else if(directFlg == 1){
       imghtm.push("</span>");
       imghtm.push("</a>");
   }else if(directFlg == 2){
       imghtm.push("</span>");
       imghtm.push("</a>");
   }else{
   }
   imghtm.push("</td></tr>");
   return imghtm.join("");
}

function pageLocation(directFlg, pdfurl, directurl, no, pdfPage) {
   if (directFlg == 1) {
       var setPdfUrl = pdfurl;
       if (pdfPage != null && pdfPage != "") {
           setPdfUrl = pdfurl + "#page="+pdfPage;
       }
       // PDFファイルのため別ウインドウで開く
       window.open(setPdfUrl);
       return true;
   } else if (directFlg == 2){
       // コンテンツのため同一ウインドウで開く
       top.location.href(directurl+ "#" + no);
       return true;
   }
   return false;
}

function getUrl(directFlg, pdfurl, directurl, pdfPage) {
   if (directFlg == 1) {
       // PDFファイルのため別ウインドウで開く
       var setPdfUrl = pdfurl;
       if (pdfPage != null && pdfPage != "") {
           setPdfUrl = pdfurl + "#page="+pdfPage;
       }
       return setPdfUrl;
   } else if (directFlg == 2){
       // コンテンツのため同一ウインドウで開く
       return directurl;
   }
   return "";
}

//---------------------------------------------
// ドキュメントリンク共通ロジック
// エラー時の出力を行います
//---------------------------------------------
function errOut(titleType, anchorTitle, docNo) {
	var outString = "";
	if (titleType != null && titleType == "4" && anchorTitle != null) {
		outString = anchorTitle;
	} else {
		if (docNo != null) {
			outString = docNo;
		}
	}
	return outString;
}

//---------------------------------------------
// ドキュメントリンク共通ロジック
// アップツールお知らせ用の出力を行います
//---------------------------------------------
function uptoolTopics(titleType, docNo, docVer, title, anchorTitle, anchorNewLine, directFlg, pdfUrl, directUrl, anchorUrl, no, pdfPage) {
   var titlehtm = new Array();
   // ダイレクト表示フラグ
   if(directFlg == 0){
   }else if(directFlg == 1){
       var setPdfUrl = pdfUrl;
       if (pdfPage != null && pdfPage != "") {
           setPdfUrl = pdfUrl + "#page="+pdfPage;
       }
       titlehtm.push("<a href='" + setPdfUrl + "' title='" + docNo + "' target='_blank'>");
       titlehtm.push("<span onClick=\"javascript: pageTracker._trackPageview('" + setPdfUrl + "');\">");
   } else if(directFlg == 2) {
       titlehtm.push("<a href='" + directUrl + "#" + no + "' title='" + docNo + "' target='_top'>");
       titlehtm.push("<span onClick=\"javascript: pageTracker._trackPageview('" + directUrl + "');\">");
   } else {
   }
   //任意文字を設定
   titlehtm.push(anchorTitle);
   // ダイレクト表示フラグ
   if(directFlg == 0){
   }else if(directFlg == 1){
       titlehtm.push("</span>");
       titlehtm.push("</a>");
   }else if(directFlg == 2){
       titlehtm.push("</span>");
       titlehtm.push("</a>");
   }else{
   }
   document.write(titlehtm.join(""));
}

