//參數說明
//可依需要修改的參數如下
OB_Top=5;				//選單離頂端的距離
OB_Left=0;				//選單離左端的距離
DB_ShowImage=0;				//是否顯示選單KenralT..系統設定請勿更動
OB_Margin=10;				//選單項目離bottom的間距
OB_ItemsLeft=5;	  			//選單項目離左端的距離
OB_ItemsRight=5;
OB_Width=125;				//選單的寬度
OB_Height=220;				//選單的高度
OB_SlideSpeed=1.6;			//選單移動的速度
OB_BackgroundColor="";			//選單的背景顏色，""表示透明
OB_ItemsSpacing=0;			//文字選單時物件間的空隙
OB_ImageItemsSpacing=32;		//選單物件空間
OB_BorderWidth=0;			//選單框的厚度
OB_BorderStyle="ridge";			//選單框的樣式
OB_BorderColor="";		//選單框的顏色
OB_IconsWidth=20;			//選單項目的寬度
OB_IconsHeight=10;			//選單項目的高度
OB_ButtonFontFamily="Arial";		//選單項目上的字體
OB_ButtonFontSize=9;			//選單項目上字體的大小
OB_ButtonFontColor="#004080";		//選單項目上字體的顏色
OB_ButtonHeight=20;			//選單的高度
OB_LabelFontFamily="Arial";		//選單上的字體
OB_LabelFontSize=8;			//選單上字體的大小
OB_LabelFontColor="#ffff00";		//選單上字體的顏色
OB_LabelMargin=0;			//選單離邊緣的距離，值愈大，就必需出現向下的按鈕來捲動看不到的部分
OB_UpArrow="./down.gif";		//向下按鈕的圖檔
OB_DownArrow="./up.gif";		//向上按鈕的圖檔
OB_ArrowWidth=10;			//設定按鈕的寬度
OB_ArrowHeight=12;			//設定按鈕的高度
OB_ArrowSlideSpeed=10;			//設定移動一項的速度



function ItemClicked(item)
{
	if(this.sliding)
		return;		
	item.style.border="1 inset #ffffff";
}

//選擇項目時的動作
function ItemSelected(item)
{
	if(this.sliding)
		return;		
	item.style.border="1 outset #ffffcc";
	if(item.link.indexOf("javascript")!=-1) 
		eval(item.link)
	else 
		eval(item.targetFrame+".location='"+item.link+"'");
}

//當Over項目時的動作
function OverItems(item)
{
	if(this.sliding)
		return;		
	item.style.border="1 outset #ffffcc";
}

//當Out項目時的動作
function OutItems(item)
{
	if(this.sliding)
		return;		
	item.style.border=" 1 ridge #ffffff";
	
}

//點選箭號圖示時的動作
function ArrowClicked(arrow)
{
	if(this.sliding)
		return;		
	arrow.style.border="1 inset #ffffff";
}
//當Over箭號圖示時的動作
function OverArrow(arrow)
{
	if(this.sliding)
		return;		
	arrow.style.border="1 outset #ffffff";
}

//當Over箭號圖示時的動作
function OutArrow(arrow)
{
	if(this.sliding)
		return;		
	arrow.style.border="0 none black";
}
//選單基本設定如高度、寬度及點選選單時選單的移動
function OutBar(width,height,items,buttonHeight,borderWidth,slideSpeed,slideArrowValue,ArrowSlideSpeed,id)
{
	this.currentFolder=1;
	this.currentItem=null;
	this.slideCount=0;
	this.slideStep=1;
	this.slideArrowValue=slideArrowValue;
	this.slideSpeed=slideSpeed;
	this.borderWidth=borderWidth;
	this.width=width;
	this.visibleAreaHeight=height-2*borderWidth-items*buttonHeight;
	this.visibleAreaWidth=width;
	this.FolderClicked=FolderClicked;
	this.slidefolders=slidefolders;
	this.ItemClicked=ItemClicked;
	this.ItemSelected=ItemSelected;
	this.OverItems=OverItems;
	this.OutItems=OutItems;
	this.OverArrow=OverArrow;
	this.OutArrow=OutArrow;
	this.ArrowClicked=ArrowClicked;
	this.ArrowSelected=ArrowSelected;
	this.ArrowSlideSpeed=ArrowSlideSpeed;
	this.slideitems=slideitems;
	this.slideitemsAction=slideitemsAction;
	this.Start=Start;
	this.clipfolder=clipfolder;
	this.SetArrows=SetArrows;
	this.Hidearrows=Hidearrows;
	this.sliding=false;
	this.items=items;
	this.started=false;
	this.Start(id);
}
function Start(id)
{
	if(!this.started)
	{
		this.clipfolder(1,0,this.visibleAreaWidth,this.visibleAreaHeight,0,id);
		this.SetArrows(id);
	}		
}
//設定邊緣物件在按下後的動作
function slideitems(up,id)
{
	this.sliding=true;
	this.slideCount=Math.floor(this.slideArrowValue/this.ArrowSlideSpeed);
	up ? this.slideitemsAction(-this.ArrowSlideSpeed,id) : this.slideitemsAction(this.ArrowSlideSpeed,id);
}


///////////////////////////////////id////////////////////////////////////////////
///////////////////////////////////id////////////////////////////////////////////
///////////////////////////////////id////////////////////////////////////////////
//選擇箭號圖示時的動作
function ArrowSelected(arrow,id)
{
	if(this.sliding)
		return;		
	arrow.style.border="0 none black";
	this.slideitems(arrow.id=="OB_SlideUp"+id,id);
}



//----------Setup End----------
//以下為核心程式執行碼，非必要請勿修改

//繪製選單:
//此function會根據111s.js檔中宣告的array數來製作選單項目：預設為一般網頁連結<a href>敘述
function MakeItems(Folder,zorder,top,id)
{
	var items=0;
	var folderWidth=(OB_Width-OB_BorderWidth*2);
	while(Folder[items+1])
		items+=4;
	items/=4;
	if(DB_ShowImage==1)
	{
	document.write("<DIV id='OB_Folder"+id+"_"+zorder+"' style='position:absolute;left:0;top:"+top+";width:"+folderWidth+";height:"+(OB_Margin*2+items*(OB_IconsHeight+OB_LabelFontSize+OB_LabelMargin)+(items-1)*OB_ImageItemsSpacing)+";z-index:"+zorder+";clip:rect(0 0 0 0);'>");
	}
	else
	{
	document.write("<DIV id='OB_Folder"+id+"_"+zorder+"' style='position:absolute;left:0;top:"+top+";width:"+folderWidth+";height:"+(OB_Margin*2+items*(OB_IconsHeight+OB_LabelFontSize+OB_LabelMargin)+(items-1)*OB_ItemsSpacing)+";z-index:"+zorder+";clip:rect(0 0 0 0);'>");
	}
	for(var i=1;i<items*4;i+=4)
	{

if(DB_ShowImage==1)
		{
		document.write("<div  style='position:absolute;left:0;top:"+(OB_Margin+Math.ceil((i-1)/4)*(OB_ImageItemsSpacing+OB_LabelFontSize+OB_IconsHeight))+";font-family:"+OB_LabelFontFamily+";font-size:"+OB_LabelFontSize+"pt;color:"+OB_LabelFontColor+"'>");
		document.write("<a href="+Folder[i+2]+" target="+Folder[i+3]+" onMouseOver='window.status=\""+Folder[i+1]+"\";return true\'>"+"<img src="+Folder[i]+" width=32 height=32 border=0><br>&nbsp;&nbsp;"+Folder[i+1]+"</a>");
		document.write("<br>");
		document.write("</div>");
		}
		
else

		{
	        document.write("<div  style='position:absolute;left:0;top:"+(OB_Margin+Math.ceil((i-1)/4)*(OB_ItemsSpacing+OB_LabelFontSize+OB_IconsHeight))+";font-family:"+OB_LabelFontFamily+";font-size:"+OB_LabelFontSize+"pt;color:"+OB_LabelFontColor+"'>");
		document.write("<a href="+Folder[i+2]+"  target="+Folder[i+3]+" onMouseOver='window.status=\""+Folder[i+1]+"\";return true\'>&nbsp;&nbsp;"+Folder[i+1]+"</a>");
		document.write("<!--"+Folder[i]+"-->");
		document.write("</div>");
		};

	}	
	document.write("</DIV>");
}



//選單下項目的動作：點選項目
function FolderClicked(folder,id)
{
	if(this.sliding)
		return;
	if(folder==this.currentFolder)
		return;
	this.sliding=true;		
	this.slideCount=this.visibleAreaHeight;
	this.slideStep=1;
	this.countStep=0;
	this.Hidearrows(id);
	this.slidefolders(folder,document.all["OB_Button"+id+"_"+folder].position=="DOWN",id);
}

//選單滑動
function slidefolders(folder,down,id)
{
	var step;	
	if(down)
	{
		this.slideCount-=Math.floor(this.slideStep);
		if(this.slideCount<0)
			this.slideStep+=this.slideCount;
		step=Math.floor(this.slideStep);
		for(var i=2;i<=folder;i++)
			if(document.all["OB_Button"+id+"_"+i].position=="DOWN")
			{
				document.all["OB_Button"+id+"_"+i].style.pixelTop-=step;
				document.all["OB_Folder"+id+"_"+i].style.pixelTop-=step;
			}				

	    filter = /rect\((\d*)px (\d*)px (\d*)px (\d*)px\)/;

		var clipString=document.all["OB_Folder"+id+"_"+folder].style.clip;
		var clip=clipString.match(filter);
		this.clipfolder(folder,parseInt(clip[1]),this.visibleAreaWidth,(parseInt(clip[3])+step),0,id);

		var clipString=document.all["OB_Folder"+id+"_"+this.currentFolder].style.clip;
		var clip=clipString.match(filter);
		this.clipfolder(this.currentFolder,parseInt(clip[1]),this.visibleAreaWidth,(parseInt(clip[3])-step),0,id);

		this.slideStep*=this.slideSpeed;
		if(this.slideCount>0)
			setTimeout("OutlookLikeBar"+id+".slidefolders("+folder+",true,"+id+")",20);
		else		
		{
			for(var k=2;k<=folder;k++)
				document.all["OB_Button"+id+"_"+k].position="UP";
			this.currentFolder=folder;		
			this.SetArrows(id);
			this.sliding=false;		
		}		
	}
	else		
	{
		this.slideCount-=Math.floor(this.slideStep);
		if(this.slideCount<0)
			this.slideStep+=this.slideCount;
		step=Math.floor(this.slideStep);
		for(var i=folder+1;i<=this.items;i++)
			if(document.all["OB_Button"+id+"_"+i].position=="UP")
			{
				document.all["OB_Button"+id+"_"+i].style.pixelTop+=step;
				document.all["OB_Folder"+id+"_"+i].style.pixelTop+=step;
			}

	    filter = /rect\((\d*)px (\d*)px (\d*)px (\d*)px\)/;

		var clipString=document.all["OB_Folder"+id+"_"+folder].style.clip;
		var clip=clipString.match(filter);
		this.clipfolder(folder,parseInt(clip[1]),this.visibleAreaWidth,(parseInt(clip[3])+step),0,id);

		var clipString=document.all["OB_Folder"+id+"_"+this.currentFolder].style.clip;
		var clip=clipString.match(filter);
		this.clipfolder(this.currentFolder,parseInt(clip[1]),this.visibleAreaWidth,(parseInt(clip[3])-step),0,id);

		this.slideStep*=this.slideSpeed;
		if(this.slideCount>0)
			setTimeout("OutlookLikeBar"+id+".slidefolders("+folder+",false,"+id+")",20);
		else		
		{
			for(var k=folder+1;k<=this.items;k++)
				document.all["OB_Button"+id+"_"+k].position="DOWN";
			this.currentFolder=folder;		
			this.SetArrows(id);
			this.sliding=false;		
		}		
	}
}

//選單設定
function clipfolder(folder,top,right,bottom,left,id)
{
	document.all["OB_Folder"+id+"_"+folder].style.clip=clip='rect('+top+' '+right+' '+bottom+' '+left+')';
}

//當一開始時，預設會展開的選項


//箭號設定，如向上、向下等
function SetArrows(id)
{
	document.all["OB_SlideUp"+id].style.pixelTop=document.all["OB_Button"+id+"_"+this.currentFolder].style.pixelTop+document.all["OB_Button"+id+"_"+this.currentFolder].style.pixelHeight+20;
	document.all["OB_SlideUp"+id].style.pixelLeft=0;
	document.all["OB_SlideDown"+id].style.pixelTop=document.all["OB_Button"+id+"_"+this.currentFolder].style.pixelTop+document.all["OB_Button"+id+"_"+this.currentFolder].style.pixelHeight+this.visibleAreaHeight-document.all["OB_SlideDown"+id].height-20;
	document.all["OB_SlideDown"+id].style.pixelLeft=0;

	var folder=document.all["OB_Folder"+id+"_"+this.currentFolder].style;
	var startTop=document.all["OB_Button"+id+"_"+this.currentFolder].style.pixelTop+document.all["OB_Button"+id+"_"+this.currentFolder].style.pixelHeight;

	if(folder.pixelTop<startTop)
		document.all["OB_SlideDown"+id].style.visibility="visible";
	else		
		document.all["OB_SlideDown"+id].style.visibility="hidden";

	if(folder.pixelHeight-(startTop-folder.pixelTop)>this.visibleAreaHeight)
		document.all["OB_SlideUp"+id].style.visibility="visible";
	else		
		document.all["OB_SlideUp"+id].style.visibility="hidden";
}

//當選單上的項目沒有那麼多時，隱藏箭號圖示，不用上、下移動
function Hidearrows(id)
{
	document.all["OB_SlideUp"+id].style.visibility="hidden";
	document.all["OB_SlideDown"+id].style.visibility="hidden";
}


//設定邊緣物件的動作
function slideitemsAction(value,id)
{
	document.all["OB_Folder"+id+"_"+this.currentFolder].style.pixelTop+=value;
    filter = /rect\((\d*)px (\d*)px (\d*)px (\d*)px\)/;
    var clipString=document.all["OB_Folder"+id+"_"+this.currentFolder].style.clip;
    var clip=clipString.match(filter);
    this.clipfolder(this.currentFolder,(parseInt(clip[1])-value),parseInt(clip[2]),(parseInt(clip[3])-value),parseInt(clip[4]),id);
	this.slideCount--;
	if(this.slideCount>0)
		setTimeout("OutlookLikeBar"+id+".slideitemsAction("+value+","+id+")",20);
	else
	{
		if(Math.abs(value)*this.ArrowSlideSpeed!=this.slideArrowValue)		
		{
			document.all["OB_Folder"+id+"_"+this.currentFolder].style.pixelTop+=(value/Math.abs(value)*(this.slideArrowValue%this.ArrowSlideSpeed));
		    filter = /rect\((\d*)px (\d*)px (\d*)px (\d*)px\)/;
			var clipString=document.all["OB_Folder"+id+"_"+this.currentFolder].style.clip;
			var clip=clipString.match(filter);
		    this.clipfolder(this.currentFolder,(parseInt(clip[1])-(value/Math.abs(value)*(this.slideArrowValue%this.ArrowSlideSpeed))),parseInt(clip[2]),(parseInt(clip[3])-(value/Math.abs(value)*(this.slideArrowValue%this.ArrowSlideSpeed))),parseInt(clip[4]),id);
		}		    
		this.SetArrows(id);
		this.sliding=false;
	}		
}
