﻿// C++Builder 研究 - http://www.ccrun.com
// JavaScript 代码文件
// code by ccrun(老妖)
// 老弟,做人要厚道啊.

//-------------------------------------------------
// 在页面上显示当前时间和问候语
function initArray()
{
   this.length = initArray.arguments.length
   for(var I=0; I<this.length; I++)
   this[I+1] = initArray.arguments[I]
}
function DispTimeString()
{
  dt = new Date();
  var A_day = new initArray(
     "Sunday",
     "Monday",
     "Tuesday",
     "Wednesday",
     "Thursday",
     "Friday",
     "Saturday");
  nYear = dt.getYear();
  if(nYear < 1000)
    nYear = nYear + 1900;
  document.write(
     A_day[dt.getDay() + 1],
     " ",
     nYear, "-",
     dt.getMonth()+1, "-",
     dt.getDate()
     );
}

//-------------------------------------------------
// 图像特殊效果处理代码
function HighAlpha(obj)
{
  TheObj = obj;
  HighLighting = setInterval("HighLightIt(TheObj)", 100);
}
function LowAlpha(obj)
{
  clearInterval(HighLighting);
  obj.filters.alpha.opacity = 40;
}
function HighLightIt(obj)
{
  if(obj.filters.alpha.opacity < 100)
    obj.filters.alpha.opacity += 13;
  else if(window.HighLighting)
    clearInterval(HighLighting);
}

//-------------------------------------------------
// 将页面上指定的内容复制到剪贴板
function CopyToClipBoard(strTitle)
{
  var vClip = "";
  vClip += strTitle;
  vClip += "\r\n";
  vClip += document.URL;
  window.clipboardData.setData("Text", vClip);
  alert("[C++Builder 研究] 网站友情提示：\r\n复制成功，请粘贴到你的QQ/MSN上推荐给你的好友");
}

//-------------------------------------------------
// 高亮页面关键字
function HighLightKeyword(strKey, divArea)
{
  var strHtml, vSuccess;

  var vRange = document.body.createTextRange();
  vRange.moveToElementText(divArea);

  vSuccess = vRange.findText(strKey, 1, 0);
  while(vSuccess && strHtml != "")
  {
    strHtml = vRange.htmlText; // 先取得包含关键字的文本
    vRange.pasteHTML("<span class=\"spHighlight\">" + strHtml + "</span>");
    vRange.scrollIntoView(1);
    vSucess = vRange.findText(strKey, 1, 0);
  }
}

//-------------------------------------------------
// 显示信箱的超链接
function DispMailString(strWho, strDisplay, strDomain)
{
  var strUrl;
  strUrl = document.URL.toLowerCase();
  strUrl = strUrl.substring(strUrl.indexOf("ccrun.com") + 10, strUrl.length);

  var strSubject = "?Subject=[From: ccrun.com, Ref: " + strUrl + "]: ";
  if(strDisplay == "")
    strDisplay = strWho + String.fromCharCode(64) + strDomain;
  document.write("<a href=\"mailto:", strWho, String.fromCharCode(64), strDomain, strSubject, "\" title=\"Email\">", strDisplay, "</a>");
}

//-------------------------------------------------
// 论坛跳转
function ForumJump(URL)
{
  if(URL.options[URL.selectedIndex].value != "") self.location.href = URL.options[URL.selectedIndex].value;
  return true;
}

//-------------------------------------------------
// 弹出窗口代码
function openWin(theURL, winName, features)
{
  window.open(theURL, winName, features);
}

//-------------------------------------------------
// 预览窗口
function OpenPreviewWindow(targetPage, formName)
{
  now = new Date;
  // Open the window first
  openWin('','preview','toolbar=0,location=0,status=0,menubar=0,scrollbars=1,resizable=1,width=680,height=400');
  // Now submit form to the new window
  formName.action = targetPage + "?ID=" + now.getTime();
  formName.target = "preview";
  formName.submit();
}

//-------------------------------------------------
// 以下增加用于控制图片宽度控制
function resizeImages()
{
  if(document.images.length > 0) // Has images, validate sizes
  {
    var imgHeight;
    var imgWidth;
    for(var loop=0; loop<document.images.length; loop++)
    {
      if(document.images[loop].name.substring(0,6) == 'chkImg')
      {
        imgWidth = document.images[loop].width;
        imgHeight = document.images[loop].height;
        if(imgWidth > 500)
        {
          document.images[loop].width = 500;
          // Proportionalize Height
          imgHeight = imgHeight / (imgWidth / 500);
          document.images[loop].height = imgHeight;
        }
      }
    }
  }
}

//-------------------------------------------------
// 显示登陆界面
function ShowLoginForm(SessionID, strRedirFile)
{
  document.write("<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" height=\"91\" align=\"center\">");
  document.write("  <form method=\"post\" name=\"frmLogin\" action=\"\\forum/login_user.asp?FID=0&R=" + strRedirFile + "\">");
  document.write("  <tr><td height=\"20\">用户名：<input type=\"text\" name=\"name\" size=\"15\" maxlength=\"15\" value=\"\" /></td></tr>");
  document.write("  <tr><td height=\"20\">密　码：<input type=\"password\" name=\"password\" size=\"15\" maxlength=\"15\" /></td></tr>");
  document.write("  <tr><td height=\"20\" align=\"center\"><input type=\"checkbox\" name=\"AutoLogin\" value=\"True\" checked />自动登陆</td></tr>");
  document.write("  <tr><td align=\"center\" width=\"69%\" height=\"24\"><input type=\"hidden\" name=\"ActiveUsers\" value=\"false\"/>");
  document.write("  <input type=\"hidden\" name=\"sessionID\" value=" + SessionID + " />");
  document.write("  <input type=\"submit\" name=\"Submit\" value=\"登陆系统\" />&nbsp;");
  document.write("  <a target=\"_blank\" href=\"\\forum/registration_rules.asp?FID=0\">注册新用户</a></td>");
  document.write("  </tr>");
  document.write("  </form>");
  document.write("</table>");
}
//-------------------------------------------------
var gaf = "go" + "og" + "le_a" + "ds_fr" + "ame";
var strErrWithJS = "";
strErrWithJS = strErrWithJS + "  <div id=\"divMsgBox\" style=\"text-align:left; width:600px;\">";
strErrWithJS = strErrWithJS + "    <h3>[C++Builder研究] 网站提示 - 503(Service Unavailable)</h3>";
strErrWithJS = strErrWithJS + "    <div><img src=\"!image/logo120.gif\" title=\"C++Builder研究 - http:\/\/www.ccrun.com\" /></div>";
strErrWithJS = strErrWithJS + "    <ul style=\"text-align:left;\">";
strErrWithJS = strErrWithJS + "      <li>对不起，您系统中某些设置或软件比如浏览器(如Maxthon)或防火墙(如卡巴斯基)屏蔽了本站的部分JS代码，造成下载地址或文档内容不能正常显示。</li>";
strErrWithJS = strErrWithJS + "      <li>解决方法：开启浏览器的JavaScript功能，暂时关掉浏览器或防火墙的广告过滤功能。</li>";
strErrWithJS = strErrWithJS + "      <li>&nbsp;1. Maxthon(傲游)的用户：</li>";
strErrWithJS = strErrWithJS + "      <li>&nbsp;&nbsp;&nbsp;请选择菜单上的选项(Options)--&gt;广告猎手(AD Hunter)--&gt;取消\"启用网页内容过滤(Enable Web Ads Blocker)\"前的对钩。</li>";
strErrWithJS = strErrWithJS + "      <li>&nbsp;2. Kaspersky(卡巴斯基)防火墙的用户：</li>";
strErrWithJS = strErrWithJS + "      <li>&nbsp;&nbsp;&nbsp;6.0的用户：请选择设置(Settings)--&gt;保护(Protection)--&gt;反间谍(Anti-Spy)--&gt;取消\"启用反广告(Enable Anti-Banner)\"前的对钩。</li>";
strErrWithJS = strErrWithJS + "      <li>&nbsp;&nbsp;&nbsp;7.0的用户：请选择设置(Settings)--&gt;防火墙(Firewall)--&gt;取消\"启用反广告(Enable Anti-Banner)\"前的对钩。<br />";
strErrWithJS = strErrWithJS + "      &nbsp;&nbsp;&nbsp;或者：请选择设置(Settings)--&gt;防火墙(Firewall)--&gt;Publicity banners blocking--&gt;Settings...(设置)--&gt;General(一般)--&gt;取消 *.googlesyndication.com/*show_ads.js 前的对钩。</li>";
strErrWithJS = strErrWithJS + "      <li>如果还不能解决，请咨询站长(页面顶部有站长的Email)。</li>";
strErrWithJS = strErrWithJS + "    </ul>";
strErrWithJS = strErrWithJS + "  </div>";

//-------------------------------------------------
window.onload=function()
{
  Nifty("div#divTopContainer","normal transparent top");
  Nifty("div#divBtmContainer","normal transparent bottom");

  Nifty("div#divNavBar","normal transparent top");
  Nifty("ul#ulNavToolBar a","small transparent top");
  
  Nifty("div#divFooter", "normal");

  Nifty("div.divList h3,div.divBorderList,div.divPanel h3,div#divMsgBox h3", "top");
  Nifty("div.divList ul,div.divBorderList h3,div.divPanel div,div#divMsgBox ul", "bottom");

  if(!document.getElementsByTagName) return;
  var vAnchor, vAnchors, i;
  vAnchors = document.getElementsByTagName("a");
  for(i=0; i<vAnchors.length; i++)
  {
    vAnchor = vAnchors[i];
    if(vAnchor.getAttribute("href") && vAnchor.getAttribute("rel") == "external")
      vAnchor.target = "_blank";
  }
}

