function AddFavority(title, url){ 
	if (document.all) 
		window.external.AddFavorite(url, title); 
	else if (window.sidebar) 
		window.sidebar.addPanel(title, url, "") 
} 

function AddBrowerIndexPage(url, obj){
	if( isIE ){
		obj.style.behavior = "url(#default#homepage)";
		obj.setHomePage(url);
	}else{
		var txt = "1. 將滑鼠移至網址列後，拖曳網址列上的圖片至瀏覽器\"房屋\"圖示上.\n";
		txt += "2. 從彈跳的視窗中，選擇 \"是\"\n";
		txt += "3. 恭喜，你已完成設定！";
		alert(txt);
	}
}  

function show_banner_ad(){
	if( typeof(M_BNR) == "undefined" ){
		return false;
	}
	var n, t, obj;
	if( M_BNR.length <= 0){
		return false;
	}
	for( var i=0; i < M_BNR.length; i++){
		n = M_BNR[i][0];
		obj = document.getElementById(n);
		if( obj ){
			if( i == M_now ){
				obj.style.display = "";
				t = M_BNR[i][1];
			}else{
				obj.style.display = "none";
			}
		}
	}
	if( t > 0 && M_BNR.length > 1){
		M_now ++;
		if( M_now >= M_BNR.length )
			M_now = 0;
		
		window.setTimeout('show_banner_ad()', t);
	}
}

// * 廣告輪播 * //
$(function()
{
	actionCount = $(actionSelector).length;

	if(actionCount !=0)
	{
		cntActionIdx = 0;
		$(actionSelector + ":eq("+ cntActionIdx + ")").show();
	}

	if( typeof(M_BNR) != "undefined" )
		var time = (M_BNR[cntActionIdx])? M_BNR[cntActionIdx] : actionInterval;
	else
		var time = actionInterval;

	setTimeout("ShowAction();", time);

});

var cntActionIdx = -1;
var actionCount = 0;
var actionInterval = 6000;
var actionSelector = "#action_bnr span";

function ShowAction()
{
	if(actionCount < 2) return;

	if(cntActionIdx != -1)
	{
		$(actionSelector + ":eq("+ cntActionIdx + ")").fadeOut("slow",function()
		{
			if(cntActionIdx +1 < actionCount )
			{
				cntActionIdx++;
			}
			else
			{
				cntActionIdx = 0;
			}

			$(actionSelector + ":eq("+ cntActionIdx + ")").fadeIn("slow",function()
			{
				var time = (M_BNR[cntActionIdx])? M_BNR[cntActionIdx] : actionInterval;
				setTimeout("ShowAction();", time);
			});
			
		});
	}
}

/* 登入 */
function CheckLogin(x){
	if( x.LoginName.value == '請輸入帳號' || x.LoginName.value == '' ){
		alert('請輸入帳號！');
		x.LoginName.value = '';
		x.LoginName.focus();
		return false;
	}
	if( x.LoginPass.value == '' ){
		alert('請輸入密碼！');
		x.LoginPass.style.display = '';
		x.tmp.style.display = 'none';
		x.LoginPass.focus();
		return false;
	}
	return true;
}

$(function()
{
	if( $.browser.msie ){
		var version = parseInt($.browser.version);
		if( version < 7 ){
			$(".kborder .kd").each(
				function(){
					var iH = $(this).innerHeight();
					if( (iH % 2) != 0 ){
						var nH = (iH + 1) + "px";
						$(this).css("height", nH);
					}
				}
			);
		}
	}
});
