﻿/**   
 *    
 * @param {} sURL 收藏链接地址   
 * @param {} sTitle 收藏标题   
 */   
function AddFavorite(sURL, sTitle) {   
    try {   
        window.external.addFavorite(sURL, sTitle);   
    } catch (e) {   
        try {   
            window.sidebar.addPanel(sTitle, sURL, "");   
        } catch (e) {   
            alert("加入收藏失败，请使用Ctrl+D进行添加");   
        }   
    }   
}   
/**   
 *    
 * @param {} obj 当前对象，一般是使用this引用。   
 * @param {} vrl 主页URL   
 */   
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);   
        }   
    }   
} 


/*下拉菜单代码开始*/
var p_count = 0;  //全局变量，保存DisplaySubMenu函数上一次执行接收到的参数
function DisplaySubMenu(count) { 
	if(document.getElementById("SubMenu"+count).style.display != "inline"){
		document.getElementById("SubMenu"+count).style.display = "inline";
	}else{
		document.getElementById("SubMenu"+count).style.display = "none";
	}
	if(p_count!=0&&p_count!=count)
	{
		document.getElementById("SubMenu"+p_count).style.display = "none";
	}
	p_count = count;
}
function HiddenSubMenu(count) { 
	document.getElementById("SubMenu"+count).style.display = "none";
}
/*下拉菜单代码结束*/


/*定义ajax对象*/
function myObjRequest(){
	var myhttp=null;
	try{
		myhttp = new ActiveXObject("Msxml2.XMLHTTP");
	}
	catch(ie){
				try{
					myhttp = new ActiveXObject("Microsoft.XMLHTTP");
				}
				catch(huohu){
					myhttp = new XMLHttpRequest();
				}
	}
	return myhttp;
}


//信息切换
function TabsSwitcher( tabButtons,tabs,toggleCSS )
{
	for( var j = 0; j < tabButtons.length; j++ )
	{
		if( document.getElementById( tabButtons[j] ) )
		{
			document.getElementById( tabButtons[j] ).onclick = function()
			{
				for( var i = 0; i < tabButtons.length; i++ )
					if( tabButtons[i] == this.id )
					{
						document.getElementById( tabs[i] ).style.display = 'block';
						if( toggleCSS && this.className.indexOf( toggleCSS ) == -1 )
							AddClass( this.id, toggleCSS );
					}else{
						document.getElementById( tabs[i] ).style.display = 'none';
						if( toggleCSS && document.getElementById( tabButtons[i] ).className.indexOf( toggleCSS ) != -1 )
							RemoveClass( tabButtons[i], toggleCSS );
					}
				this.blur();
				return false;
			}
			if( j > 0 )
				document.getElementById( tabs[j] ).style.display = 'none';
		}
	}
}
AddClass = function( id, className )
{
	var this_ = document.getElementById( id );
	if( this_.className.indexOf( className ) == -1 )
		this_.className = ( this_.className ? this_.className + ' ' : '' ) + className;
	return this_;
}
RemoveClass = function( id, className )
{
	var this_ = document.getElementById( id );
	if( this_.className.indexOf( className ) != -1 )
		if( this_.className.indexOf( ' ' ) == -1 )
		
			this_.className = '';
			
		else{
			
			var arr = this_.className.split( ' ' );
			
			for( var k = 0; k < arr.length; k++ )
				if( arr[k] == className )
					break;
			arr.splice( k, 1 );		
			this_.className = arr.join( ' ' );
		}
	return this_;
}
