//產生XMLHttpRequest物件
function getXmlHttp(){
var NewXmlHttp = null;//定義用於存儲XMLHttpRequest物件的變數
//判斷瀏覽器是否內建XMLHttpRequest
if(window.XMLHttpRequest){NewXmlHttp = new XMLHttpRequest();}//if
//判斷瀏覽器是否支援ActiveX控制項
else if(window.ActiveXObject){
	//將所有可能出現的ActiveXObject版本都放在一個陣列中
	var aryXmlHttpTypes = ['MSXML2.XMLHTTP.6.0','MSXML2.XMLHTTP.5.0','MSXML2.XMLHTTP.4.0','MSXML2.XMLHTTP.3.0','MSXML2.XMLHTTP','Microsoft.XMLHTTP'];
//通過迴圈創建XMLHttpRequest對象
for(var i = 0; i < aryXmlHttpTypes.length; i++){
	try{
		NewXmlHttp = new ActiveXObject(aryXmlHttpTypes[i]);//產生XMLHttpRequest物件
		break;//如果產生XMLHttpRequest物件成功，則跳出迴圈
	}//try
	catch(ex){}
}//for
}//else if
else {alert("您的瀏覽器不支持AJAX！");return false;}
return NewXmlHttp;
}//function

//加載事件
function set_addEvent(obj, evType, fn){  
if (obj.addEventListener){  
obj.addEventListener(evType, fn, false);  
return true; }
else if (obj.attachEvent){  
var r = obj.attachEvent("on"+evType, fn);  
return r;  
}//else if
else{return false;}
}//function

//取得瀏覽器可視範圍的寬度跟高度
function getBrowserWindowSize(strBack){
var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
  //window.alert( 'Width = ' + myWidth );
  //window.alert( 'Height = ' + myHeight );
	if (strBack == "width"){return myWidth;}
	else if (strBack == "height"){return myHeight;}
}//function

//加入我的最愛
function bookmarksite(title, url){
if (document.all)
window.external.AddFavorite(url, title);
else if (window.sidebar)
window.sidebar.addPanel(title, url, "")
}

//設為首頁
function setHomepage(){
	var HomePageDeny = "此操作被瀏覽器拒絕，無法執行 ! !\n\n";
HomePageDeny += "※如果想啟用該功能，請在\n";
HomePageDeny += "網址列輸入 about:config，然後將\n";
HomePageDeny += "signed.applets.codebase_principal_support 值改為 true\n\n";
HomePageDeny += "※或者將網頁標籤拖至瀏覽器《 房屋 》圖示上方";
if (document.all){
document.body.style.behavior='url(#default#homepage)';
document.body.setHomePage(WebPath);
}
else if (window.sidebar){
	if(window.netscape){
	try
	{netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");} 
	catch (e) 
	{ 
    alert(HomePageDeny );return false;
         }
    }//if
    var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components. interfaces.nsIPrefBranch);
    prefs.setCharPref('browser.startup.homepage',WebPath);
 }//else if
}//function

