// Website Function
/*
Write by Arlen (elct9620@rwwl.co.cc)
*/
function $(d){return document.getElementById(d);}

function menuEvent(lclass,uri){
	if(lclass == "link"){
		this.location = uri;
	}else if(lclass == "ajax"){
		ajaxSend(uri,"GET","maintext");
	}else{
		alert("編寫錯誤：未知的選單動作");
	}
}

var scrollx_temp = null;
function scrollx(n){
	scrollx_temp = n;
	var mainbody = document.getElementById ("mainbody");
	mainbody.scrollTop = mainbody.scrollTop+scrollx_temp;
	if (scrollx_temp == 0) return;
	setTimeout("scrollx(scrollx_temp)",20);
}

function topscroll(){
	var mainbody = document.getElementById ("mainbody");
	mainbody.scrollTop = 0;
}

function checkScroll(){
	var mainbody = document.getElementById ("mainbody");
	var mainscroll = document.getElementById ("mainscroll");
	var maintext = document.getElementById ("maintext");
	
	if(mainbody.clientHeight > maintext.clientHeight){
		mainscroll.style.display = "none";
		mainbody.style.width = "390px";
		maintext.style.width = "390px";
	}else{
		mainscroll.style.display = "block";
		mainbody.style.width = "368px";
		maintext.style.width = "368px";
	}
}

var fade_in_i = 0;
function fade_in(div,fadeSpeed){
	var obj = $(div);
	if(fade_in_i >= 100){
		fade_in_i = 0;
	}else{
		fade_in_i+=1;
		obj.style.filter = "Alpha(Opacity=" + fade_in_i + ")";
		obj.style.opacity = fade_in_i/100;
		setTimeout("fade_in('" + div + "')", fadeSpeed);
	}
}

var fade_out_i = 100;
function fade_out(div,fadeSpeed){
	var obj = $(div);
	if(fade_out_i <= 0){
		fade_out_i = 100;
	}else{
		fade_out_i-=1;
		obj.style.filter = "Alpha(Opacity=" + fade_out_i + ")";
		obj.style.opacity = fade_out_i/100;
		setTimeout("fade_out('" + div + "')", fadeSpeed);
	}
}