function AddFavorite(sURL, sTitle)
{
    try
    {
        window.external.addFavorite(sURL, sTitle);
    }
    catch (e)
    {
        try
        {
            window.sidebar.addPanel(sTitle, sURL, "");
        }
        catch (e)
        {
            alert("加入收藏失败，请使用Ctrl+D进行添加");
        }
    }
}
// 使用方法：<a onclick="AddFavorite(window.location,document.title)">加入收藏</a>
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("该浏览器不支持，请手动设置");  
                        }
                        var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces.nsIPrefBranch);
                        prefs.setCharPref('browser.startup.homepage',vrl);
                 }
        }
}
//使用方法：<a onclick="SetHome(this,window.location)">设为首页</a>
//注意上面一行那个this.
//调用：<img src="图片" onload="javascript:drawImage(this,100,100)" width=100 height=100>
function DrawImage(ImgD,iwidth,iheight){    
    //参数(图片,允许的宽度,允许的高度)    
    var image=new Image();    
    image.src=ImgD.src;    
    if(image.width>0 && image.height>0){    
      if(image.width/image.height>= iwidth/iheight){    
          if(image.width>iwidth){      
              ImgD.width=iwidth;    
              ImgD.height=(image.height*iwidth)/image.width;    
          }else{    
              ImgD.width=image.width;      
              ImgD.height=image.height;    
          }    
      }else{    
          if(image.height>iheight){      
              ImgD.height=iheight;    
              ImgD.width=(image.width*iheight)/image.height;            
          }else{    
              ImgD.width=image.width;      
              ImgD.height=image.height;    
          }    
      }    
    }    
}  
//o_tab 用法
function o_tab(){
	var tab_menu,tab_main;
	var on,off;
	var type;
	
	function $( id ){ return document.getElementById( id );}
	
	function setListener(){
		for( var i = 0; i < tab_menu.length; i++ ){
			tab_menu[i].cur_no = i;
			if( type == "" ){
				tab_menu[i].onmouseover = setOnAndOff;
			} else {
				tab_menu[i].onmouseover = setOnAndOff;
			}
		}
	}
	
	function setOnAndOff(){
		for( var i=0; i<tab_menu.length; i++ ){
		   	$(tab_main+(i+1)).style.display = ( i==this.cur_no )?"block":"none";
			tab_menu[i].className = ( i==this.cur_no )?on:off;
		}
		return false;
	}
	
	this.init = function( tab_menu1,tagName,tab_main1,on1,off1,no1,type1 ){
		tab_menu = $(tab_menu1).getElementsByTagName( tagName );
		tab_main = tab_main1;
		on = on1;
		off = off1;
		type = type1;
		tab_menu[no1-1].className = on;
		$(tab_main+no1).style.display = "block";
		setListener();
	}

}

