﻿//PBlog2 公用JS代码
//Author:PuterJam

//查找网页内宽度太大的图片进行缩放以及PNG纠正
 function ReImgSize(){
  for (i=0;i<document.images.length;i++)
   {
   if (document.all){
	if (document.images[i].width>500)
	 {
       document.images[i].width="500"
       document.images[i].outerHTML='<a href="'+document.images[i].src+'" target="_blank" title="在新窗口打开图片">'+document.images[i].outerHTML+'</a>'
  	 }
   }
  else{
	if (document.images[i].width>400) {
	  document.images[i].title="在新窗口打开图片"
	  document.images[i].style.cursor="pointer"
	  document.images[i].onclick=function(e){window.open(this.src)}
	}
  }
  }
 }

//AccessKey 转换For IE Design By PuterJam
  var NKey=new Array()
  var KeyCode=new Array()
  var KeyInit=false
//======== keyCode ============
  KeyCode["1"]=49
  KeyCode["2"]=50
  KeyCode["3"]=51
  KeyCode["["]=219
  KeyCode["]"]=221
  KeyCode[","]=188
  KeyCode["."]=190
  var EKey="abcdefghijklmnopqrstuwvxyz"
  for (i=0;i<26;i++){
    KeyCode[EKey.substr(i,1)]=65+i
  }
  
  function PressKey(){
	 if (document.all) {
	   for (i=0;i<NKey.length;i++){
		   if (window.event.altKey && window.event.keyCode==NKey[i].Code) {NKey[i].Object.blur();NKey[i].Object.click()}
	   }

	}
  }
  
  function AccessKey(Code,Object){
   this.Code=Code
   this.Object=Object
  }


  function initAccessKey(){
	 if (document.all && !KeyInit) {
	    for (i=0;i<document.links.length;i++){
	      if (document.links[i].accessKey) {
	        NKey[NKey.length]=new AccessKey(KeyCode[document.links[i].accessKey.toLowerCase()],document.links[i])
	      }
	    }
	 }
	 KeyInit=true
  }

//初始化JS代码
function initJS(){
	ReImgSize() //自动缩放代码 
	initAccessKey()  //转换AccessKey For IE
}

//让Mozilla支持innerText
try{
	HTMLElement.prototype.__defineGetter__
	(
	"innerText",
	function ()
	{
		var anyString = "";

		var childS = this.childNodes;
			for(var i=0; i<childS.length; i++)
			{
				if(childS[i].nodeType==1)
				anyString += childS[i].tagName=="BR" ? '\n' : childS[i].innerText;
				else if(childS[i].nodeType==3)
				anyString += childS[i].nodeValue;
			}
			return anyString;
	}
	); 
}
catch(e){}

//判断是否是IE
function isIE(){
	if (navigator.appName!="Microsoft Internet Explorer") {return false}
	return true
}
//显示隐藏主题
function TopicShow(e,TopicID){
	 e.className=(e.className=="BttnC")?"BttnE":"BttnC
