var buildBox = document.getElementById('BuildBox'); buildBox.innerHTML = tempHTML;
var thumbs = ''; document.getElementById('thumImg')?thumbs = document.getElementById('thumImg'):thumbs ='';
var Titles = document.getElementById('textTitle');
var Dates = document.getElementById('textDate');
var Contents = document.getElementById('textContents');
var aTables = new Array(); // Build Table 용 3차 배열
if (!nRows || nRows==null || nRows ==0)
{
	var nRows = 10; //1page 화면을 구성할 Row 갯수
}
var nCols = 1; //1page 화면을 구성할 Col 갯수
var nPages = 0; //Page 갯수 - 초기값 0
var PageNav = 0;
var g = 0;


// Page number
var otURL = document.location.href;
	  tURL = otURL.split('?')[1];
	 if ( tURL != null && tURL != '' )
		PageNav =parseInt (fReplace( tURL,'pnv=',''));
	 else
		PageNav = 1;

//페이지수 계산
	nPages = parseInt(listDatas.length/nRows);
	if ( listDatas.length%nRows != 0 )
			nPages++;


//DataSorting
listDatas = DataSorting(listDatas,SOnF);


// Build Start
BuildTablesArray();


/*-------------------------------------------------------------------------------------------------------
	함수이름 : DataSorting(new or old)
	함수기능 : Data 재정렬 - 'new' 입력 여부에 따라 Sorting On/Off
	작성자 : Ockkyoung.leem
	작성일 : 2007.02.08
	수정일 : 2007.04.06
-------------------------------------------------------------------------------------------------------*/
function DataSorting(VArray,ST)
{

	if ( ST.toUpperCase() == 'ON' )
	{
		VArray = VArray.sort();
		var DataSortArray = new Array();
		for ( s=0; s<VArray.length; s++ )	 DataSortArray[s] = VArray[VArray.length-(1+s)];
		VArray = DataSortArray; 

	} else if ( ST.toUpperCase() == 'OFF' ) {
		var DataSortArray = new Array();
		for ( s=0; s<VArray.length; s++ )	 DataSortArray[s] = VArray[VArray.length-(1+s)];
		VArray = DataSortArray; 	
	}
	
	return VArray;
}


/*-------------------------------------------------------------------------------------------------------
	함수이름 : BuildTablesArray()
	함수기능 : Table Array 생성
	작성자 : Ockkyoung.leem
	작성일 : 2007.02.08
	수정일 : 2007.04.06
-------------------------------------------------------------------------------------------------------*/
// Table용 3차 Array 생성
function BuildTablesArray()
{
	for ( z=0; z<nPages; z++ )
	{
		aTables[z] = new Array();
		for ( t=0; t<nRows;t++ )
		{
			aTables[z][t] = new Array();
			for ( d=0; d<nCols; d++ )
			{
				if ( listDatas[g] != null && listDatas[g] != '' )
				{
					aTables[z][t][d] = listDatas[g];
				} else {
					aTables[z][t][d] = null;	
				}
					g++;
			}//d for문 end

		}//t for문 end

	}//z for문 end

	TableBuild(PageNav-1);
}


/*-------------------------------------------------------------------------------------------------------
	함수이름 : TableBuild(해당 view page number)
	함수기능 : 목록 Table을 Build 합니다.
	작성자 : Ockkyoung.leem
	작성일 : 2007.02.12
	수정일 : 2007.03.26
-------------------------------------------------------------------------------------------------------*/
function TableBuild(nP)
{
	
	oTableBox = document.getElementById('ResultBox');

	var NewTableHTML = '';
	var NewTableHTMLs = '';

	for ( h=0; h<nRows; h++ )
	{			
		for ( f=0; f<nCols; f++ )
		{
			if ( aTables[nP][h][f] !='' && aTables[nP][h][f]!=null )
				NewTableHTML = DataInput(aTables[nP][h][f]).innerHTML;	
			else
				NewTableHTML = '';

			NewTableHTMLs +=NewTableHTML;
			resetTemp();
		}			
	}
		
	// open Tables	
	document.all['ResultBox'].innerHTML = NewTableHTMLs;
	oTableBox.style.display = 'block';
	
	// pages navigation Build
	PagesNavBuild();

}


/*-------------------------------------------------------------------------------------------------------
	함수이름 : DataInput(listNum)
	함수기능 : Table Template을 불러와서 각 Elements들을 생성 후, 해당 Data Input
	작성자 : Ockkyoung.leem
	작성일 : 2007.03.26
	수정일 : 2007.03.26
-------------------------------------------------------------------------------------------------------*/

function DataInput(nV)
{

	// thumImg
	if ( thumbs !="" && thumbs != null )
	{
		if ( nV[4] !="" && nV[4] != null)
		{
			oImg = oImgCreator(tempImgPath + nV[4],tempPagePath+nV[1]+'.html?pnv='+PageNav,tempImgWidth,tempImgHeight);
			thumbs.appendChild(oImg);

		} else {
			oImg = oImgCreator(tempImgPath + nV[1] +'.jpg',tempPagePath+nV[1]+'.html?pnv='+PageNav,tempImgWidth,tempImgHeight);
			thumbs.appendChild(oImg);		
		}
		
	}

	// textDate
	if ( Dates !="" && Dates != null )
	{
		oDate = oTextCreator(nV[0],'','');
		Dates.appendChild(oDate);
	}
	
	// textTitle
	if ( Titles !="" && Titles != null )
	{
		oText = oTextCreator(nV[2],'','');
		Titles.appendChild(oText);		
	}

	// textContents
	if ( Contents !="" && Contents != null )
	{
		if ( tempPagePath+nV[1] !="" && tempPagePath+nV[1] != null && tempPagePath+nV[1] != "undefined" )
		{
			oText = oTextCreator(nV[3],tempPagePath+nV[1]+'.html?pnv='+PageNav,'');
			Contents.appendChild(oText);
		} else {

			oText = oTextCreator(nV[3],'','');
			Contents.appendChild(oText);
		}
		
	}

	return buildBox;	
}


/*-------------------------------------------------------------------------------------------------------
	함수이름 : resetTemp()
	함수기능 : template reset
	작성자 : Ockkyoung.leem
	작성일 : 2007.04.05
	수정일 : 2007.04.06
-------------------------------------------------------------------------------------------------------*/
function resetTemp()
{
	thumbs.innerHTML = '';
	Titles.innerHTML = '';
	Dates.innerHTML = '';
	Contents.innerHTML = '';
}


/*-------------------------------------------------------------------------------------------------------
	함수이름 : PagesNavCreator()
	함수기능 : Pages Navigator 생성
	작성자 : Ockkyoung.leem
	작성일 : 2007.02.12
	수정일 : 2007.04.06
-------------------------------------------------------------------------------------------------------*/
function PagesNavBuild()
{
	NavBox = document.getElementById('PagesNavi');
	var orgUrl = otURL.split('?')[0].split('/');
	orgUrl = orgUrl[orgUrl.length-1];
	orgUrl!='index.html'?orgUrl=otURL.split('?')[0]+'index.html':orgUrl=otURL.split('?')[0];

	for ( q=0; q<nPages; q++ )
	{
		if ( PageNav == (q+1) )
			 oText = oTextCreator((q+1),'','bold');
		
		else
			 oText = oTextCreator((q+1),orgUrl+'?pnv='+(q+1),'','');

		NavBox.appendChild(oText);
		

		if ( q != nPages-1 )
		{
			textSpace = oTextCreator('&#160;');
			NavBox.appendChild(textSpace);
		}

	}	

	document.all['PagesNavi'].innerHTML = NavBox.innerHTML;
}


/*-------------------------------------------------------------------------------------------------------
	함수이름 : fReplace(타겟 문자열,바꿀문자,바뀔문자)
	함수기능 : 문자열에서 특정 문자를 지정한 문자로 모두 바꿈
	작성자 : Ockkyoung.leem
	작성일 : 2007.02.12
	수정일 : 2007.02.12
-------------------------------------------------------------------------------------------------------*/
function fReplace(tString,vT,rT)
{
	var nR = tString.split(vT).length - 1;

	for ( j=0; j<nR; j++ )
	{
		strReplace = tString.replace(vT,rT);
		tString = strReplace;
	}	

	return tString;
}


/*-------------------------------------------------------------------------------------------------------
	함수이름 : oTextCreator(content,linkUrl,className,id)
	함수기능 : Text object를 Create함
	작성자 : Ockkyoung.leem
	작성일 : 2007.03.06
	수정일 : 2007.03.26
-------------------------------------------------------------------------------------------------------*/
function oTextCreator(content,linkUrl,className,id)
{
	oText = document.createElement('SPAN');

	if ( content !=null && content !='' )
	{
		if ( className !=null && className !='' )
			oText.setAttribute('class',className);
	
		if ( id !=null && id !='' )
			oText.setAttribute('id',id);
		
		oText.innerHTML = content;

		if ( linkUrl !=null && linkUrl !='' )
		{
			oTextA = oACreator(linkUrl,'','');
			oTextA.appendChild(oText);
			oText = oTextA;
		}
	}
	
	return oText;
}


/*-------------------------------------------------------------------------------------------------------
	함수이름 : oImgCreator(imgSrc,linkUrl,wV,hV,className)
	함수기능 : Text object를 Create함
	작성자 : Ockkyoung.leem
	작성일 : 2007.03.06
	수정일 : 2007.03.26
-------------------------------------------------------------------------------------------------------*/
function oImgCreator(imgSrc,linkUrl,wV,hV,className)
{
	if ( imgSrc !=null && imgSrc !='' )
	{
		oIMG = document.createElement('IMG');
		oIMG.src = imgSrc;
		
		if ( wV !=null && wV !='' )
			oIMG.setAttribute('width',wV);
			
		if ( hV !=null && hV !='' )
			oIMG.setAttribute('height',hV);
			
		if ( className !=null && className !='' )
			oIMG.setAttribute('class',className);
			
		if ( linkUrl !=null && linkUrl !='' )
		{
			oImgA = oACreator(linkUrl,'','');
			oImgA.appendChild(oIMG);
			oIMG = oImgA;
		}

		return oIMG;

	}
}


/*-------------------------------------------------------------------------------------------------------
	함수이름 : oTableCreator(id,className)
	함수기능 : <TABLE> object를 Create함
	작성자 : Ockkyoung.leem
	작성일 : 2007.03.06
	수정일 : 2007.03.26
-------------------------------------------------------------------------------------------------------*/
function oTableCreator(id,className)
{	
	oTable = document.createElement('TABLE');

	if ( id !=null && id !='' )
		oTable.id = id;
	
	if ( className !=null && className !='' )
		oTable.setAttribute('class',className);
		
	return oTable;
}


/*-------------------------------------------------------------------------------------------------------
	함수이름 : oTrCreator(id,className)
	함수기능 : <TR> object를 Create함
	작성자 : Ockkyoung.leem
	작성일 : 2007.03.06
	수정일 : 2007.03.26
-------------------------------------------------------------------------------------------------------*/
function oTrCreator(id,className)
{	
	oTR = document.createElement('TR');

	if ( id !=null && id !='' )
		oTR.id = id;
	
	if ( className !=null && className !='' )
		oTR.setAttribute('class',className);
	
	return oTR;
}


/*-------------------------------------------------------------------------------------------------------
	함수이름 : oTdCreator(id,className)
	함수기능 : <TD> object를 Create함
	작성자 : Ockkyoung.leem
	작성일 : 2007.03.06
	수정일 : 2007.03.26
-------------------------------------------------------------------------------------------------------*/
function oTdCreator(id,className)
{
	oTD = document.createElement('TD');

	if ( id !=null && id !='' )
		oTD.id = id;
	
	if ( className !=null && className !='' )
		oTD.setAttribute('class',className);
		
	return oTD;
}


/*-------------------------------------------------------------------------------------------------------
	함수이름 : oACreator(shref,className)
	함수기능 : <A> object를 Create함
	작성자 : Ockkyoung.leem
	작성일 : 2007.03.06
	수정일 : 2007.03.26
-------------------------------------------------------------------------------------------------------*/
function oACreator(shref,className)
{
	if ( shref !=null && shref !='' )
	{
		oA = document.createElement('A');
		oA.href = shref;
		
		if ( className !=null && className !='' )
			oA.setAttribute('class',className);
			
	}

	return oA;
}
