﻿/*----------- common ----------------
	write by 不要相信我
	last modify 2007/12/16
*/
var isIE = (window.navigator.appName.indexOf('Microsoft') == 0 ) ? true : false;
var isFF = (window.navigator.appName.indexOf('Netscape') == 0 ) ? true : false;

function SetHome(obj,url){
	try{
		obj.style.behavior='url(#default#homepage)';obj.setHomePage(url);
	}
	catch(e){
		if(window.netscape) {
			try {
				netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); 
			} 
			catch (e) { 
				alert("此操作被浏览器拒绝！\n请在浏览器地址栏输入“about:config”并回车\n然后将[signed.applets.codebase_principal_support]设置为'true'"); 
			}
		var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces.nsIPrefBranch);
		prefs.setCharPref('browser.startup.homepage',url);
		}
	}
}

function setFont(targetObj,size)
{
	var obj = document.getElementById(targetObj);
	obj.style.fontSize = size + 'pt';
}


function AddFavorite(sURL, sTitle)
{
   try
   {
       window.external.addFavorite(sURL, sTitle);
   }
   catch (e)
   {
       try
       {
           window.sidebar.addPanel(sTitle, sURL, "");
       }
       catch (e)
       {
           alert("加入收藏失败，请使用Ctrl+D进行添加");
       }
   }
}

function ArticleAddFavorite(){
	var sTitle = document.title;
	bookmark(sTitle,location.href,"");
}

function bookmark(title,url,desc){
	if ((typeof window.sidebar == "object") && (typeof window.sidebar.addPanel == "function"))
		{
				window.sidebar.addPanel(title,url,desc);
		}
		else
		{
				window.external.AddFavorite(url,title);
		} 
}

function HTMLcutPage(obj)
{
	if (document.getElementById(obj) ){
		var Source = document.getElementById(obj)
		var html = Source.innerHTML;
	}
	if (document.getElementById('Content'))
	{
		var Content = document.getElementById('Content');
	}
													
}

function SubmitOnce(form){
	if (document.all||document.getElementById)
		{
			for (i=0;i<form.length;i++)
			{
				var tempobj=form.elements[i];
				if(tempobj.type.toLowerCase()=="submit"||tempobj.type.toLowerCase()=="reset")
				tempobj.disabled=true;
			}
		}
}

function setTarget(){
	if ( document.all || document.getElementsByTagName )
	{
		var tagList = document.getElementsByTagName("A");
		for( var i = 0 ; i < tagList.length; i ++)
		{
			tagList[i].target = "_blank";
		}
	}
}

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)}
	}
  }
  }
}

function click(e) {
 if (document.all) { //ie
  if (event.button==1||event.button==2||event.button==3) {
   oncontextmenu='return false';
  }
 }
 if (document.layers) { //ff
  if (e.which == 3) {
   oncontextmenu='return false';
  }
 }
}
if (document.layers) {//other
 document.captureEvents(Event.MOUSEDOWN);
}
document.onmousedown=click;
document.oncontextmenu = new Function("return false;")
document.onselectstart = new Function("return false");
document.onselect="document.selection.empty()";
document.oncopy="document.selection.empty()";
document.onbeforecopy="return false";
