// 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()
{
  var vClip = "";
  vClip += document.all("spTitle").innerText;
  vClip += "\r\n";
  vClip += document.URL;
  window.clipboardData.setData("Text", vClip);
  alert("[C++Builder 研究] 网站友情提示：\r\n复制成功，请粘贴到你的QQ/MSN上推荐给你的好友");
}

//------------------------------------------------- 
// 高亮页面关键字
function HighLightKeyword(strKey)
{

  var vStyle, vRange, strHtml, vSuccess;
  vStyle = "background-color: Lime; font-weight: bolder;";
  vRange = document.body.createTextRange();
  vSuccess = vRange.findText(strKey, 1, 0);
  while(vSuccess && strHtml != "")
  {
    strHtml = vRange.htmlText; // 先取得包含关键字的文本
    vRange.pasteHTML("<span style=\"" + vStyle + "\">" + 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: CppBuilderStudy, 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 = "<font color=\"red\">对不起，您系统中某些设置或软件比如浏览器(如Maxthon)或防火墙(如卡巴斯基)屏蔽了本站的部分JS代码，造成下载地址或文档内容不能正常显示。<br><br>";
strErrWithJS = strErrWithJS + "解决方法：开启浏览器的JavaScript功能，暂时关掉浏览器或防火墙的广告过滤功能。<br>";
strErrWithJS = strErrWithJS + "&nbsp;1. Maxthon(傲游)的用户：<br>";
strErrWithJS = strErrWithJS + "&nbsp;&nbsp;&nbsp;请选择菜单上的选项(Options)--&gt;广告猎手(AD Hunter)--&gt;取消\"启用网页内容过滤(Enable Web Ads Blocker)\"前的对钩。<br>";
strErrWithJS = strErrWithJS + "&nbsp;2. Kaspersky(卡巴斯基)防火墙的用户：<br>";
strErrWithJS = strErrWithJS + "&nbsp;&nbsp;&nbsp;6.0的用户：请选择设置(Settings)--&gt;保护(Protection)--&gt;反间谍(Anti-Spy)--&gt;取消\"启用反广告(Enable Anti-Banner)\"前的对钩。<br>";
strErrWithJS = strErrWithJS + "&nbsp;&nbsp;&nbsp;7.0的用户：请选择设置(Settings)--&gt;防火墙(Firewall)--&gt;取消\"启用反广告(Enable Anti-Banner)\"前的对钩。<br>";
strErrWithJS = strErrWithJS + "&nbsp;3. 检查 %windir%\\system32\\drivers\\etc\\hosts文件，如果列表中有 http://pagead2.googlesyndication.com/的字样，请删除这一行保存文件并重启。<br><br>";
strErrWithJS = strErrWithJS + "如果还不能解决，请咨询站长(页面顶部有站长的Email)。<br>";
strErrWithJS = strErrWithJS + "我们强烈建议您在访问本站时暂时关掉您的浏览器或防火墙的广告过滤功能。</font><br><br>";
strErrWithJS = strErrWithJS + "<font size=4 color=Blue>请认真看完以上文字再对本站资源\"能否下载\"作评论。</font>";

