function $(id) {
return document.getElementById(id);
}

/*firefox下outerHTML的解决方法*/
if(window.HTMLElement) {
    HTMLElement.prototype.__defineSetter__("outerHTML",function(sHTML){
        var r=this.ownerDocument.createRange();
        r.setStartBefore(this);
        var df=r.createContextualFragment(sHTML);
        this.parentNode.replaceChild(df,this);
        return sHTML;
        });

    HTMLElement.prototype.__defineGetter__("outerHTML",function(){
     var attr;
        var attrs=this.attributes;
        var str="<"+this.tagName.toLowerCase();
        for(var i=0;i<attrs.length;i++){
            attr=attrs[i];
            if(attr.specified)
                str+=" "+attr.name+'="'+attr.value+'"';
            }
        if(!this.canHaveChildren)
            return str+">";
        return str+">"+this.innerHTML+"</"+this.tagName.toLowerCase()+">";
        });
        
 HTMLElement.prototype.__defineGetter__("canHaveChildren",function(){
  switch(this.tagName.toLowerCase()){
            case "area":
            case "base":
         	case "basefont":
            case "col":
            case "frame":
            case "hr":
            case "img":
            case "br":
            case "input":
            case "isindex":
            case "link":
            case "meta":
            case "param":
            return false;
        }
        return true;
     });
}

function listSwitch(obj,name)
{
	var p = obj.parentNode.getElementsByTagName("li");
	var p1 = document.getElementById(name).childNodes;
	var p2 = obj.parentNode.getElementsByTagName("span");
	for(i=0,j=0;i<p1.length;i++,j++)
	{   
		
		if(obj==p[i])
		{
			p[i].className = "index";
			p2[i].className = "colorOrange";
			//alert(p1[j].tagName);
			while(p1[j].tagName!="DIV"){	
				j++;
			}	
			p1[j].className = "list";
		}
		else
		{
			p[i].className = "";
			p2[i].className = "";
			while(p1[j].tagName!="DIV"){		
				j++;
			}
			p1[j].className = "unlist";
					
		}
	}
}

function touMingPNG(str)
{
	if($(str)==null){
		return;
	}
	imgs=$(str).getElementsByTagName("img");
	for(var i=0; i<imgs.length; i++)
	{
 	var img = imgs[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 ;
		var imgX = (img.x) ? "x='"+img.x+"' " : "";
		var imgY = (img.y) ? "y='"+img.y+"' " : "";
		var imgInfo = (img.info) ? "y='"+img.info+"' " : "";
		var imgUsemap= (img.usemap) ? "usemap='"+img.usemap+"' " : "";
		//alert(img.JSonclick);
		var imgOnclick=(img.JSonclick) ? "onclick='"+img.JSonclick+"' " : "";
  		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 + imgX + imgY + imgInfo + imgUsemap + imgOnclick + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";" + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"+ "(src=\'" + img.src + "\');\"></span>";
  		img.outerHTML = strNewHTML;
  		//alert(strNewHTML);
  		i = i-1;
	}
	}
}

function touMingObjPNG(img)
{
    if(img==null)
        return;
 	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 ;
		var imgX = (img.x) ? "x='"+img.x+"' " : "";
		var imgY = (img.y) ? "y='"+img.y+"' " : "";
		var imgInfo = (img.info) ? "y='"+img.info+"' " : "";
		var imgUsemap= (img.usemap) ? "usemap='"+img.usemap+"' " : "";
		//alert(img.JSonclick);
		var imgOnclick=(img.JSonclick) ? "onclick='"+img.JSonclick+"' " : "";
  		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 + imgX + imgY + imgInfo + imgUsemap + imgOnclick + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";" + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"+ "(src=\'" + img.src + "\');\"></span>";
  		img.outerHTML = strNewHTML;
  		//alert(strNewHTML)
	}
}

var _st = window.setTimeout; 
window.setTimeout = function(fRef, mDelay) {
if(typeof fRef == 'function'){ 
   var argu = Array.prototype.slice.call(arguments,2); 
   var f = (function(){ fRef.apply(null, argu); }); 
   return _st(f,mDelay); 
} 
return _st(fRef,mDelay); 
};

function detectBrowser()//Writed by zhong1806#gmail.com at 2007-8-9 15:14:25
{	
	var sAgent = navigator.userAgent.toLowerCase();
	this.isIE = (sAgent.indexOf("msie")!=-1); //IE6.0-7
	this.isFF = (sAgent.indexOf("firefox")!=-1);//firefox
	this.isSa = (sAgent.indexOf("safari")!=-1);//safari
	this.isOp = (sAgent.indexOf("opera")!=-1);//opera
	this.isNN = (sAgent.indexOf("netscape")!=-1);//netscape
	this.isMa = this.isIE;//marthon
	this.isOther = (!this.isIE && !this.isFF && !this.isSa && !this.isOp && !this.isNN && !this.isSa);//unknown Browser
}

String.prototype.Trim = function() { return this.replace(/(^\s*)|(\s*$)/g, "");} 
String.prototype.LTrim = function() { return this.replace(/(^\s*)/g, "");} 
String.prototype.RTrim = function() { return this.replace(/(\s*$)/g, "");} 
String.prototype.len = function() {return this.replace(/[^\x00-\xff]/g,"aa").length;}


function AddFavorite(sURL,sTitle){
    try{
        window.external.addFavorite(sURL, sTitle);
    }
    catch(e){
        try{
            window.sidebar.addPanel(sTitle,sURL,"");
        }
        catch (e){
			alert("dagadh"); 
        }
    }
}

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 setCopy(_sTxt){clipboardData.setData('Text',_sTxt);}

function tabit(btn)
{
	var idname = new String(btn.id);
	var s = idname.indexOf("_");
	var e = idname.lastIndexOf("_")+1;
	var tabName = idname.substr(0, s);
	var id = parseInt(idname.substr(e, 1));
	var tabNumber = btn.parentNode.childNodes.length;
	for(i=0;i<tabNumber;i++)
	{
		document.getElementById(tabName+"_div_"+i).style.display = "none";document.getElementById(tabName+"_btn_"+i).style.backgroundColor = "#EBF3FB";
		document.getElementById(tabName+"_btn_"+i).style.cursor = "pointer";
	}
	document.getElementById(tabName+"_div_"+id).style.display = "block";btn.style.backgroundColor = "#69BDF9";btn.style.cursor = "default";
}