/*
5digistar株式会社 [ActionBrowserサービス] 
Email： support@5digistar.co.jp 
URL： http://www.5digistar.co.jp/ 

Copyright (C) 2005 5digistar Inc. All Rights Reserved.
*/

function defineToolBar()
{
	var ToolBarBottom = new setBottomToolFrame();
	try
	{	
		getObj('lyToolBar').innerHTML = ToolBarBottom.html;
	}
	catch(err)
	{
		return;
	}
}

function defineContentList()
{
	var ContentList = new setContentListFrame();
	try
	{	
		getObj('lyContentList').innerHTML = ContentList.html;
		disableContentList();				
	}
	catch(err)
	{
		return;
	}
}

function disableContentList()
{
		if(aContentList.length < 1)
		{
			getObj('imgcontent').disabled = true;
			getObj('imgcontent').onmouseup = null;
			getObj('imgcontent').style.filter = "alpha(opacity=20)";			
		}	
}

function definePrint()
{
	var Print1 = new setPrintFrame();

	try
	{	
		getObj('lyPrint').innerHTML = Print1.html;
		if(!AB.Printing)
		{
			getObj('imgprint').disabled = true;
			getObj('imgprint').onmouseup = null;
			getObj('imgprint').style.filter = "alpha(opacity=20)";
		}	
	}
	catch(err)
	{
		return;
	}
}

function setPageNum(arg)
{
	if(!AB.ShowPageNum) return;
		
	switch(AB.FlipDirection)
	{
	case 0:
		getObj('lyLeftNum').innerHTML = AB.IndexCurrentPage-(1+AB.StartPageNum);
		getObj('lyRightNum').innerHTML = AB.IndexCurrentPage-AB.StartPageNum;
		break;
	case 1:
		getObj('lyLeftNum').innerHTML = AB.IndexCurrentPage-AB.StartPageNum;
		getObj('lyRightNum').innerHTML = AB.IndexCurrentPage-(1+AB.StartPageNum);	
		break;
	}
	
	if ( ((AB.IndexCurrentPage-AB.StartPageNum)>=(AB.PageCount-AB.StartPageNum)) || ((AB.IndexCurrentPage-AB.StartPageNum)<=0) )
		arg = false;
	
	switch(arg)
	{
	case true:
		if((AB.IndexCurrentPage-(AB.StartPageNum+1))==0)
		{
			switch(AB.FlipDirection)
			{
			case 0:
				showLayer('lyRightNum');
				break;
			case 1:
				showLayer('lyLeftNum');
				break;
			}
		}
		else
		{
			showLayer('lyLeftNum','lyRightNum');
		}
		break;
	case false:
		hideLayer('lyLeftNum','lyRightNum');		
		break;
	}
}

var ContentCurrentNum = 1;
var ContentMok;
var ContentNa;
var ContentMax;

function setContentCurrentNum(arg)
{
	switch(arg)
	{
	case 0:		
		if(aContentList.length % 10)
			ContentNa = aContentList.length % 10;
		else
			ContentNa =	 0;
		if(parseInt(aContentList.length / 10,10))
			ContentMok = parseInt(aContentList.length / 10,10);
		else
			ContentMok = 0;
			
		ContentMax = aContentList.length;
		break;
	case -1:		
	case 1:
		ContentCurrentNum = ContentCurrentNum + parseInt(arg,10);
		break;
	}	

	if(aContentList.length >0)
		setContentList();
}

function setContentList()
{
	var tmpList, tmpNum, tmpStr;
	var istr, imax;
	
	istr = ContentCurrentNum*10-10;
		
		if((ContentCurrentNum == 1) && ContentMok>0)
		{   			
			if( (ContentNa == 0) && (ContentCurrentNum==ContentMok) )
			{
				hideLayer('listprev');
				hideLayer('listnext');			
			}
			else
			{
				hideLayer('listprev');
				showLayer('listnext');
			}
			imax = ContentCurrentNum * 10
		}
		else if(ContentMok<1)
		{
			imax = ContentMax;
			hideLayer('listprev');
			hideLayer('listnext');
		}		
		else if(ContentCurrentNum == ContentMok+1)
		{
			imax = ContentMax;			
			showLayer('listprev');
			hideLayer('listnext');
		}
		else
		{
			if( (ContentNa == 0) && (ContentCurrentNum==ContentMok) )
			{
				showLayer('listprev');
				hideLayer('listnext');			
			}
			else
			{
				showLayer('listprev');
				showLayer('listnext');
			}
			imax = ContentCurrentNum * 10;
		}
		
		resetContentList();
		
		if(istr != imax)
		for(var i=istr; i < imax; i++)
		{
			tmpList = eval("document.getElementById('ct"+(i-istr)+"')");
			tmpNum = eval("document.getElementById('cn"+(i-istr)+"')");
			tmpList.href = "javascript:GoToPageNum("+(aContentList[i][0]-AB.StartPageNum)+")";
			tmpList.title = parseInt(aContentList[i][0],10)-AB.StartPageNum; 
			tmpList.innerHTML = aContentList[i][1];
			tmpStr = parseInt(aContentList[i][0],10)-AB.StartPageNum;
			tmpNum.innerHTML = tmpStr;
		}
}
function resetContentList()
{
	var tmpList, tmpNum, tmpStr;

	for(var i=0; i < 10; i++)
	{
		tmpList = eval("document.getElementById('ct"+i+"')");
		tmpNum = eval("document.getElementById('cn"+i+"')");
		tmpList.href = "#";
		tmpList.title = ""; 
		tmpList.innerHTML = "&nbsp;";
		tmpStr = "";
		tmpNum.innerHTML = tmpStr.substr(tmpStr.length-3,3);
	}
}

function beforeContent()
{
	if(aContentList.length<1) return;
	
	if (oSlideShow)	SlideShow();
	
	if(parseInt(getObj('lyContentList').style.left,10)<0)
	{
		hidePrint();	
		showContent();
	}
	else
		hideContent();
}

function beforePrint()
{
	if (oSlideShow)	SlideShow();
	
	if(!AB.Printing) 
	{
		hidePrint();
		return;
	}
	
	if(parseInt(getObj('lyPrint').style.left,10)<0)
	{
		hideContent();	
		showPrint();
	}
	else
		hidePrint();
}
