﻿document.writeln("<script language=javascript>");
document.writeln("");
document.writeln("");
document.writeln("  \/\/\/ 设置每行显示多少个图片");
document.writeln("  var LineNum = 3;");
document.writeln("");
document.writeln("  \/\/\/ 设置每页显示多少行图片");
document.writeln("  var PageNum = 2;");
document.writeln("");
document.writeln("  \/\/\/ 设置图片的总数");
document.writeln("  var ImgTotal = 7;");
document.writeln("");
document.writeln("  \/\/\/ 设置图片的基本网址");
document.writeln("  var ImgBaseHref = \"upload\/KC00228\/\";");
document.writeln("");
document.writeln("  \/\/\/ 设置图片的缩略图后缀");
document.writeln("  var imgThumb = \".gif\";");
document.writeln("");
document.writeln("  \/\/\/ 设置图片的大图后缀");
document.writeln("  var imgPicture = \".jpg\";");
document.writeln("");
document.writeln("  document.onLoad=autoCreatePictureList();");
document.writeln("");
document.writeln("  function autoCreatePictureList()");
document.writeln("  {");
document.writeln("");
document.writeln("                var objpTable;");
document.writeln("                var objpTr;");
document.writeln("");
document.writeln("        var strTableOut;");
document.writeln("        var strTableIn;");
document.writeln("        var strTrOut;");
document.writeln("        var strTrIn;");
document.writeln("        var ColNum;");
document.writeln("");
document.writeln("        var strTrOutModify;");
document.writeln("        var strTrInModify;");
document.writeln("        var strTableOutModify;");
document.writeln("        var strTableInModify;");
document.writeln("");
document.writeln("        var strPrev = \"\";");
document.writeln("        var strNext = \"\";");
document.writeln("        var strPage = \"\";");
document.writeln("");
document.writeln("        var strBaseHref = \"\";");
document.writeln("");
document.writeln("     if (navigator.userAgent.indexOf(\"MSIE\") != -1)");
document.writeln("     {");
document.writeln("                objpTable = document.getElementById(\'pTable\');");
document.writeln("                objpTr = document.getElementById(\'pTr\');");
document.writeln("        strTableOut= objpTable.outerHTML;");
document.writeln("        strTableIn = objpTable.innerHTML;");
document.writeln("        strTrOut   = objpTr.outerHTML;");
document.writeln("        strTrIn    = objpTr.innerHTML;");
document.writeln("");
document.writeln("        strTrOutModify = \"\";");
document.writeln("        strTrInModify = \"\";");
document.writeln("        strTableOutModify = \"\";");
document.writeln("        strTableInModify = \"\";");
document.writeln("     }");
document.writeln("     else");
document.writeln("     {");
document.writeln("            objpTable = document.getElementById(\'pTable\');");
document.writeln("                objpTr = document.getElementById(\'pTr\');");
document.writeln("");
document.writeln("        strTableIn = objpTable.innerHTML;");
document.writeln("        strTrIn    = objpTr.innerHTML;");
document.writeln("");
document.writeln("        strTrInModify = \"\";");
document.writeln("        strTableInModify = \"\";");
document.writeln("     }");
document.writeln("");
document.writeln("     strBaseHref = window.location.pathname;");
document.writeln("     strHash = window.location.hash;");
document.writeln("     if (strHash==\"\")");
document.writeln("     {");
document.writeln("        strHash = window.location.search;");
document.writeln("     }");
document.writeln("     ");
document.writeln("     if (strHash==\"\")");
document.writeln("     {");
document.writeln("        strHash = \"page1\";");
document.writeln("     }");
document.writeln("");
document.writeln("     var strPage;");
document.writeln("     var myregexp = \/page(\\d+)\/;");
document.writeln("     var match = myregexp.exec(strHash);");
document.writeln("     if (match != null && match.length > 1) {");
document.writeln("        strPage = match[1];");
document.writeln("     } else {");
document.writeln("        strPage = \"\";");
document.writeln("     }");
document.writeln("");
document.writeln("     var strPicNum;");
document.writeln("     var myregexp = \/pic(\\d+)\/;");
document.writeln("     var match = myregexp.exec(strHash);");
document.writeln("     if (match != null && match.length > 1) {");
document.writeln("        strPicNum = match[1];");
document.writeln("     } else {");
document.writeln("        strPicNum = \"\";");
document.writeln("     }");
document.writeln("");
document.writeln("     if (strPage==\"\")");
document.writeln("     {");
document.writeln("        if (strPicNum>1 && strPicNum<ImgTotal)");
document.writeln("        {");
document.writeln("           strPrev = \"<a href=\'\"+strBaseHref+\"?pic\"+(strPicNum*1-1)+\"\' target=\'_self\'><img src=\'images/prev.gif\' border=\'0\' \/><\/a>\";");
document.writeln("           strNext = \"<a href=\'\"+strBaseHref+\"?pic\"+(strPicNum*1+1)+\"\' target=\'_self\'><img src=\'images/next.gif\' border=\'0\' \/><\/a>\";");
document.writeln("        }");
document.writeln("        else if (strPicNum==1)");
document.writeln("        {");
document.writeln("           strPrev = \"\";");
document.writeln("           strNext = \"<a href=\'\"+strBaseHref+\"?pic\"+(strPicNum*1+1)+\"\' target=\'_self\'><img src=\'images/next.gif\' border=\'0\' \/><\/a>\";");
document.writeln("        }");
document.writeln("        else if (strPicNum==ImgTotal)");
document.writeln("        {");
document.writeln("           strPrev = \"<a href=\'\"+strBaseHref+\"?pic\"+(strPicNum*1-1)+\"\' target=\'_self\'><img src=\'images/prev.gif\' border=\'0\' \/><\/a>\";");
document.writeln("           strNext = \"\";");
document.writeln("        }");
document.writeln("        else");
document.writeln("        {");
document.writeln("           strPicNum = Math.round(Math.random() * ImgTotal);");
document.writeln("           if (strPicNum<=2)");
document.writeln("           {");
document.writeln("              strPicNum = 2;");
document.writeln("           }");
document.writeln("           else if(strPicNum>=ImgTotal-1)");
document.writeln("           {");
document.writeln("              strPicNum = ImgTotal-1;");
document.writeln("           }");
document.writeln("           strPrev = \"<a href=\'\"+strBaseHref+\"?pic\"+(strPicNum*1-1)+\"\' target=\'_self\'><img src=\'images/prev.gif\' border=\'0\' \/><\/a>\";");
document.writeln("           strNext = \"<a href=\'\"+strBaseHref+\"?pic\"+(strPicNum*1+1)+\"\' target=\'_self\'><img src=\'images/next.gif\' border=\'0\' \/><\/a>\";");
document.writeln("        }");
document.writeln("");
document.writeln("        strTrInModify = strTrIn.replace(\/\\{IMAGE\\}\/g, \"<img border=\'0\' src=\'\"+ImgBaseHref+strPicNum+imgPicture+\"\'>\");");
document.writeln("        strTrInModify = strTrInModify.replace(\/width=[\"\']?150[\"\']?\/ig, \"width=10%\");");
document.writeln("");
document.writeln("        strPage = \'<tr><td colspan=\"\'+LineNum+\'\" rowspan=\"1\" width=100% align=center>\'+strPrev+\' \'+strNext+\'<\/tr>\';");
document.writeln("");
document.writeln("        if (navigator.userAgent.indexOf(\"MSIE\") != -1)");
document.writeln("        {");
document.writeln("           strTableInModify = strTableIn.replace(strTrIn,strTrInModify);");
document.writeln("");
document.writeln("           strTableInModify = strPage + strTableInModify + strPage;");
document.writeln("");
document.writeln("           strTableOutModify = strTableOut.replace(strTableIn , strTableInModify);");
document.writeln("        }");
document.writeln("        else");
document.writeln("        {");
document.writeln("           strTableInModify = strTableIn.replace(strTrIn,strTrInModify);");
document.writeln("           strTableInModify = strPage + strTableInModify + strPage;");
document.writeln("        }");
document.writeln("     }");
document.writeln("     else");
document.writeln("     {");
document.writeln("");
document.writeln("        var intStart;");
document.writeln("        var intEnd;");
document.writeln("        var intPageTotal;");
document.writeln("");
document.writeln("        intPageTotal = Math.round(ImgTotal \/ (PageNum * LineNum)+0.4);");
document.writeln("        if (strPage>intPageTotal)");
document.writeln("        {");
document.writeln("           strPage = intPageTotal;");
document.writeln("        }");
document.writeln("        if (strPage<1)");
document.writeln("        {");
document.writeln("           strPage = 1;");
document.writeln("        }");
document.writeln("        intStart = (strPage-1) * PageNum * LineNum;");
document.writeln("        intEnd = (strPage-0) * PageNum * LineNum;");
document.writeln("        if (intEnd > ImgTotal)");
document.writeln("        {");
document.writeln("           intEnd = ImgTotal;");
document.writeln("        }");
document.writeln("        var pageImgTotal = intEnd - intStart;");
document.writeln("");
document.writeln("        ColNum = Math.round(pageImgTotal\/LineNum+0.4) ;");
document.writeln("");
document.writeln("        for(j=0;j<ColNum;j++)");
document.writeln("        {");
document.writeln("           strTrInModify = \"\";");
document.writeln("");
document.writeln("           for (i=0;i<LineNum ;i++ )");
document.writeln("           {");
document.writeln("              if (j*LineNum+i+1+intStart>ImgTotal)");
document.writeln("              {");
document.writeln("                 strTrInModify = strTrInModify + strTrIn.replace(\/\\{IMAGE\\}\/g, \" \");");
document.writeln("              }");
document.writeln("              else");
document.writeln("              {");
document.writeln("                 strTrInModify = strTrInModify + strTrIn.replace(\/\\{IMAGE\\}\/g, \"<a href=\'\"+strBaseHref+\"#pic\"+(j*LineNum+i+1+intStart)+\"\' target=\'_blank\'><img border=\'0\' src=\'\"+ImgBaseHref+(j*LineNum+i+1+intStart)+imgThumb+\"\'><\/a>\");");
document.writeln("              }");
document.writeln("           }");
document.writeln("           if (navigator.userAgent.indexOf(\"MSIE\") != -1)");
document.writeln("           {");
document.writeln("              strTrOutModify = strTrOutModify + strTrOut.replace(strTrIn,strTrInModify);");
document.writeln("           }");
document.writeln("           else");
document.writeln("           {");
document.writeln("              strTableInModify = strTableInModify + strTableIn.replace(strTrIn,strTrInModify);");
document.writeln("           }");
document.writeln("        }");
document.writeln("");
document.writeln("        if (strPage>1 && strPage<intPageTotal)");
document.writeln("        {");
document.writeln("           strPrev = \"<a href=\'\"+strBaseHref+\"?page\"+(strPage*1-1)+\"\' target=\'_self\'>上一页<\/a>\";");
document.writeln("           strNext = \"<a href=\'\"+strBaseHref+\"?page\"+(strPage*1+1)+\"\' target=\'_self\'>下一页<\/a> \";");
document.writeln("        }");
document.writeln("        else if (strPage==1)");
document.writeln("        {");
document.writeln("           strPrev = \"上一页\";");
document.writeln("           strNext = \"<a href=\'\"+strBaseHref+\"?page\"+(strPage*1+1)+\"\' target=\'_self\'>下一页<\/a>\";");
document.writeln("        }");
document.writeln("        else if (strPage==intPageTotal)");
document.writeln("        {");
document.writeln("           strPrev = \"<a href=\'\"+strBaseHref+\"?page\"+(strPage*1-1)+\"\' target=\'_self\'>上一页<\/a>\";");
document.writeln("           strNext = \"下一页\";");
document.writeln("        }");
document.writeln("      ");
document.writeln("        strPageStart = \"<a href=\'\"+strBaseHref+\"?page1\' target=\'_self\'>首页<\/a>\";");
document.writeln("        strPageEnd = \"<a href=\'\"+strBaseHref+\"?page\"+intPageTotal+\"\' target=\'_self\'>尾页<\/a>\";");
document.writeln("        strPageIndex =\"\";");
document.writeln("        for (i=1;i<=intPageTotal;i++)");
document.writeln("        {");
document.writeln("           if (strPage == i)");
document.writeln("           {");
document.writeln("              strPageIndex = strPageIndex + \"[<a href=\'\"+strBaseHref+\"?page\"+i+\"\' target=\'_self\'><b style=\'color:red\'>\"+i+\"<\/b><\/a>]\";");
document.writeln("           }");
document.writeln("           else");
document.writeln("           {");
document.writeln("              strPageIndex = strPageIndex + \"[<a href=\'\"+strBaseHref+\"?page\"+i+\"\' target=\'_self\'>\"+i+\"<\/a>]\";");
document.writeln("           }");
document.writeln("           ");
document.writeln("        }");
document.writeln("        strPage = \'<tr><td colspan=\"\'+LineNum+\'\" rowspan=\"1\" width=100% align=center>\'+strPageStart+\' \'+strPrev+\' \'+\' \'+strPageIndex + \' \' + strNext+\' \'+strPageEnd+\'<\/tr>\';");
document.writeln("");
document.writeln("        if (navigator.userAgent.indexOf(\"MSIE\") != -1)");
document.writeln("        {");
document.writeln("           strTrOutModify = strPage + strTrOutModify + strPage;");
document.writeln("           strTableOutModify = strTableOut.replace(strTableIn , strTrOutModify);");
document.writeln("        }");
document.writeln("        else");
document.writeln("        {");
document.writeln("           strTableInModify = strPage + strTableInModify + strPage;");
document.writeln("           strTableInModify = strTableInModify;");
document.writeln("        }");
document.writeln("     }");
document.writeln("     if (navigator.userAgent.indexOf(\"MSIE\") != -1)");
document.writeln("     {");
document.writeln("        strTableOutModify = strTableOutModify.replace(\/vAlign=center\/ig, \"align=center\");");
document.writeln("        strTableOutModify = strTableOutModify.replace(\/align=middle\/ig, \"valign=middle\");");
document.writeln("        objpTable.outerHTML = strTableOutModify;");
document.writeln("     }");
document.writeln("     else");
document.writeln("     {");
document.writeln("        strTableInModify = strTableInModify.replace(\/vAlign=center\/ig, \"align=center\");");
document.writeln("        strTableInModify = strTableInModify.replace(\/align=middle\/ig, \"valign=middle\");");
document.writeln("        objpTable.innerHTML = strTableInModify;");
document.writeln("     }");
document.writeln("");
document.writeln("  }");
document.writeln("");
document.writeln("<\/script>");
