﻿// JavaScript Document
function killErrors() {
return true;
}
function no_oncontextmenu(){
	event.cancelBubble = true;
	window.event.returnValue=false;
}
function no_onselectstart(){
	window.event.returnValue=false;
}
function no_ondragstart(){
	window.event.returnValue=false;
}
function no_onsource(){
	window.event.returnValue=false;
}

//window.onerror = killErrors;
//document.oncontextmenu = no_oncontextmenu;
//document.onselectstart = no_onselectstart;
//document.ondragstart = no_ondragstart;
document.onsource = no_onsource;
function $(o){
	return document.getElementById(o);	
}
function lossfocus()
{
	var alist = document.getElementsByTagName('a');	
	for(i=0; i<alist.length; i++)
	{
		alist[i].onfocus = function(){
			this.blur();
		}
	}
}


function swapstyle(num){
	//alert(num);
	var swapcontain = document.getElementById('mainmenu').getElementsByTagName('a');//
	//alert(swapcontain.length);
	var j = swapcontain.length;
	for(i=0; i<j; i++){
		//alert(swapcontain[i].className);
		swapcontain[i].className = 'l1';
	}
	swapcontain[num].className = 'l2';
}

function swapdisplay(o){
	if($(o)){
		if($(o).style.display == 'none'){
			$(o).style.display = 'block';
		}else{
			$(o).style.display = 'none';
		}
		return false;	
	}
}
try {
document.execCommand('BackgroundImageCache', false, true);
}
catch(e) {}
String.prototype.trim = function() {return this.replace(/(^\s*)|(\s*$)/g, "");}

function AddFavorite(sURL, sTitle)
{
	try
	{
		window.external.addFavorite(sURL, sTitle);
	}
	catch (e)
	{
		try
		{
			window.sidebar.addPanel(sTitle, sURL, "");
		}
		catch (e)
		{
			alert("加入收藏失败，请使用Ctrl+D进行添加");
		}
	}
}

function SetHome(obj,vrl)
{
	try
	{
			obj.style.behavior='url(#default#homepage)';obj.setHomePage(vrl);
	}
	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',vrl);
			 }
	}
}


function png()
{
	var pngs = document.getElementsByTagName('img');
	
	len = pngs.length;
	for(i=0; i<len; i++){
		tempSrc = pngs[i].src;
		tempArray = tempSrc.split(".");
		ext = tempArray[tempArray.length-1];
		if(ext.toLowerCase() == "png"){
		//alert(tempSrc);
		pngs[i].style.display = 'none';
		pngs[i].style.cssText = "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'" + tempSrc + "\')";
		}
	}
	
	//alert(len);
	//filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true, sizingMethod=scale, src="3.png");
}

//function correctPNG()
//{
//   for(var i=0; i<document.images.length; i++)
//   {
//   var img = document.images[i];
//   var imgName = img.src.toUpperCase();
//   if (imgName.substring(imgName.length-3, imgName.length) == "PNG");
//   {
//   var imgID = (img.id) ? "id='" + img.id + "' " : "";
//   var imgClass = (img.className) ? "class='" + img.className + "' " : "";
//   var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' ";
//   var imgStyle = "display:inline-block;" + img.style.cssText;
//   if (img.align == "left") imgStyle = "float:left;" + imgStyle;
//   if (img.align == "right") imgStyle = "float:right;" + imgStyle;
//   if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle;
//   var strNewHTML = "<span " + imgID + imgClass + imgTitle
//   + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
//   + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
//   + "(src=\'" + img.src + "\', sizingMethod='image');\"></span>";
//   img.outerHTML = strNewHTML;
//   i = i-1;
//   };
//   };
//};
//
//if(navigator.userAgent.indexOf("MSIE")>-1)
//{
//window.attachEvent("onload", correctPNG);
//}; 
