var nMyTongId = 0;
var nMyBoxId = 0;
var nMyPostId = 0;
var nMyGuestbookId = 0;
var strViewMode = 'mytong';
var strSearchKeyword = '';
var strOwnerNickName = '';
var strVisitorNateId = '';
var nBoxCount = 0;
var nMyClippingBoxId = 0;
var nMyFirstBoxId = 0;
var nTickerBoxId = 0;
var bOwner = false;

function PageInit()
{	
	if(strViewMode == 'nobox')
	{
		GoToNoBox(false, nMyTongId)
		return ;
	}
//	frameLeftBoxList.location.href = '/mytong/box.do?action=menu&myTongID=' + nMyTongId;

	if (strViewMode == 'box')
		GoToBox(false, nMyTongId, nMyBoxId);
	else if (strViewMode == 'post')
		GoToPost(false, nMyTongId, nMyBoxId, nMyPostId);
	else if (strViewMode == 'puzzle')
		GoToAdmin(3);
	else if (strViewMode == 'recommand')
		GoToRecommand(nMyTongId, nMyBoxId);
	else if (strViewMode == 'linkmap')
		GoToLinkmap(nMyTongId, nMyBoxId);
	else if (strViewMode == 'comment')
		GoToComment(nMyTongId, nMyBoxId, nMyPostId);
	else if (strViewMode == 'weave')
		GoToWeave(nMyTongId, nMyBoxId, nMyPostId);
	else if (strViewMode == 'sympathy')
		GoToSympathy(nMyTongId, nMyBoxId, nMyPostId);
	else if (strViewMode == 'rss')
		GoToRss(nMyTongId, nMyBoxId);
	else if (strViewMode == 'today')
		GoToToday();
	else if (strViewMode == 'search')
		GoToSearch();
	else if (strViewMode == 'guest')
		GoToGuestbookNew(nMyGuestbookId);
	else if (strViewMode == 'together')
		GoToTogether(nMyTongId, nMyBoxId);
	else if (strViewMode == 'list' || strViewMode == 'clist' || strViewMode == 'plist')
		GoToBox(false, nMyTongId, nMyBoxId, strViewMode);
	else if (strViewMode == 'admin_invite')
		GoToAdmin(4);
	else if(strViewMode =='admin_favorite')
		GoToAdmin(5);
	else if (strViewMode == 'admin_default')
		GoToAdmin(0);
	else if (strViewMode == 'guestbook')
		GoToGuestbookView();
	else if(strSubViewMode == 'tag')
		GoTagView(strTongMode,strTag);
	else if (strViewMode == 'tagView')
		GoToTagAll(nMyTongId);
	else if (strTongMode == 'mymaintong')
		GoToMyMainTong(false, nMyTongId);

	else if(strTongMode == 'photo')
	{
		if(strLibID)
			GoToPhotoDetail(nMyTongId,strLibID);
		else if(strSubViewMode == 'happened')
			GoToPhotoHappened(nMyTongId);
		else if(strSubUrl)
			GoToPhotoSubUrl(strSubUrl);
		else
			GoToMyPhotoTong(nMyTongId);
	}
	else if(strTongMode == 'mmedia')
	{
		if(strLibID)
			GoToMMediaDetail(nMyTongId,strLibID);
		else if(strSubViewMode == 'happened')
			GoToMMediaHappened(nMyTongId);
		else if(strSubUrl)
			GoToMMediaSubUrl(strSubUrl);
		else
			GoToMyMMediaTong(nMyTongId);
	}
	else if(strTongMode== 'review')
	{
		if(strLibID)
			GoToReviewDetail(nMyTongId,strLibID);
		else if(strSubViewMode == 'happened')
			GoToReviewHappened(nMyTongId);
		else if(strSubUrl)
			GoToReviewSubUrl(strSubUrl);
		else
			GoToReviewTong(nMyTongId);
	}
	else
		GoToTong(false, nMyTongId);

	RefreshVisitorList();
}

// photo
function GoToPhotoDetail(nTongId,strLibID)
{
	frameMain.location.href = '/library/photo.do?action=read&_tongID=' + nTongId + '&_photoID=' + strLibID ;
}
function GoToPhotoHappened(nMyTongId)
{
	frameMain.location.href = '/library/library.do?action=happenedList&_tongID=' + nTongId + '&source=photo';
}
function GoToPhotoSubUrl(strSubUrl)
{
	frameMain.location.href = strSubUrl;
}


// MMedia
function GoToMMediaDetail(nTongId,strLibID)
{
	frameMain.location.href = '/library/mmedia.do?action=view&_tongID=' + nTongId + '&_mmediaID=' + strLibID ;
}
function GoToMMediaHappened(nMyTongId)
{
	frameMain.location.href = '/library/library.do?action=happenedList&_tongID=' + nTongId + '&source=mmedia';
}
function GoToMMediaSubUrl(strSubUrl)
{
	frameMain.location.href = strSubUrl;
}


// Review
function GoToReviewDetail(nTongId,strLibID)
{
	frameMain.location.href = '/library/review.do?action=view&_tongID=' + nTongId + '&_reviewID=' + strLibID ;
}
function GoToReviewHappened(nMyTongId)
{
	frameMain.location.href = '/library/library.do?action=happenedList&_tongID=' + nTongId + '&source=review';
}
function GoToReviewSubUrl(strSubUrl)
{
	frameMain.location.href = strSubUrl;
}


// tag
function GoToTagAll(nTongId)
{
	frameMain.location.href = '/mytong/tagManage.do?action=tagManage&_tongID=' + nTongId ;
}

function PageInitLibrary()
{
	frameLeftVisitorList.location.href = '/user/main.do?myTongID=' + nMyTongId;
}

function GoToMyPhotoTong(nTongId)
{
	frameMain.location.href = '/library/photo.do?action=mainbody&_tongID=' + nTongId;
	nMyBoxId = 0;	
	ShowTicker(false);
	RefreshLinkBoxList();
}
		
function GoToMyMMediaTong(nTongId)
{
	frameMain.location.href ='/library/mmedia.do?action=indexContent&_tongID=' + nTongId;
	nMyBoxId = 0;
	ShowTicker(false);
	RefreshLinkBoxList();
}
function GoToReviewTong(nTongId)
{
	frameMain.location.href = '/library/review.do?action=indexContent&_tongID=' + nTongId;
	nMyBoxId = 0;
	ShowTicker(false);
	RefreshLinkBoxList();
}


function GoTagView(strMenuMode, sTag)
{
	switch(strMenuMode)
	{
		case 'mymaintong':
		
			frameMain.location.href="/boxitem/jini.do?action=myBoxListWithTag&_tongID=" + nMyTongId + "&_tag=" + TongEncodeURIComponent(sTag);
			break;
		case 'photo':
			frameMain.location.href = '/library/photo.do?action=mainbody&_tongID=' + nMyTongId + '&_sort=2&_tag=' + TongEncodeURIComponent(sTag);
			break;
		case 'mmedia':
			frameMain.location.href = '/library/mmedia.do?action=indexContent&_tongID=' + nMyTongId + '&_sort=2&tagName=' + TongEncodeURIComponent(sTag);
			break;
		case 'review':
			frameMain.location.href = '/library/review.do?action=indexContent&_tongID=' + nMyTongId + '&_sort=2&_tagName=' + TongEncodeURIComponent(sTag);
			break;
	}
	RefreshLinkBoxList();
}

function GoFieldView(strMenuMode, nFieldCode)
{
	switch(strMenuMode)
	{
		case 'photo':
			frameMain.location.href = '/library/photo.do?action=mainbody&_tongID=' + nMyTongId + '&_sort=1&_fieldCode=' +nFieldCode;
			break;
		case 'mmedia':
			frameMain.location.href = '/library/mmedia.do?action=indexContent&_tongID=' + nMyTongId + '&_sort=1&fieldCode=' + nFieldCode;
			break;
		case 'review':
			frameMain.location.href = '/library/review.do?action=indexContent&_tongID=' + nMyTongId + '&_sort=1&_fieldID=' + nFieldCode;
			break;
	}
	RefreshLinkBoxList();
}

function GoToMyMainTong(bTopNavigate, nTongId)
{
	if (bTopNavigate)
	{
		self.location.href = '/boxitem/jini.do?action=listMyTong&_tongID=' + nTongId;
		return;
	}	
	nMyTongId = nTongId;
	strViewMode = 'mymaintong';
 	ShowNickLayer(null,false);
	ShowBoxLayer(null,false);
	nMyBoxId = 0;
	ShowTicker(false);
	frameMain.location.href = '/boxitem/jini.do?action=listMyTong&_tongID=' + nTongId;
}

function RefreshBoxList()
{
	GetTongInfo('mymaintong',false);
}
function RefreshVisitorList()
{
	var objVisitor = document.getElementById("ulvisiotr");
	var visitorList = objVisitor.childNodes;
	var nRowCount = 	visitorList.length;
	
	for (var i = 0; i < nRowCount; i++)
	{
		this_node = visitorList[0];
		removed_node = objVisitor.removeChild(this_node);	
	}		
	
	document.getElementById('visitormore').style.display = "none";
	document.getElementById('visitor_nothing').style.display = "";		
		
		
/*	if (nMyBoxId)
	{
		frameLeftVisitorList.location.href = '/user/visitList.do?action=box&myTongID=' + nMyTongId + '&boxID=' + nMyBoxId;
		}
	else*/
		frameLeftVisitorList.location.href = '/user/main.do?myTongID=' + nMyTongId;		
		
}
function RefreshLinkBoxList()
{
	var objLinkBoxList = document.getElementById('divLinkBoxList');
	var linkboxList = objLinkBoxList.childNodes;
	var nRowCount =   linkboxList.length;
	
	for (var i = 0; i < nRowCount; i++)
	{
		this_node = linkboxList[0];
		removed_node = objLinkBoxList.removeChild(this_node);	
	}

	if(!bOwner)
		document.getElementById('guest').style.display = (nMyBoxId ? "" : "none");
	document.getElementById('divLinkBoxListNone').style.display = (nMyBoxId ? "" : "none");
	document.getElementById('divLinkBox').style.display = "none";
	
	if (nMyBoxId)
		frameLeftLinkBoxList.location.href = '/mytong/happened.do?action=list_linkbox&mode=simple&rowsPerPage=5&myTongID=' + nMyTongId + '&boxID=' + nMyBoxId;
}

//
function WriteNewPost()
{
	strViewMode = 'box';
	ShowNickLayer(null,false);
	ShowBoxLayer(null,false);
	ShowTicker(true);
	RefreshLinkBoxList();
	frameMain.location.href = '/boxitem/jini.do?action=boxDesc&_tongID=' + nMyTongId + '&_boxID=' + (nMyFirstBoxId ? nMyFirstBoxId : nMyClippingBoxId) + '&viewMode=write';
}

function ClippingTong(bTabChangeOnly)
{
	document.getElementById('tblClippingTong').style.display = "";
	document.getElementById('tblClassifyTong').style.display = "none";
	document.getElementById('tblClassifyNoTong').style.display = "none";
	document.getElementById('tblClippingTongTail').style.display = "";
	document.getElementById('tblClassifyTongTail').style.display = "none";
	if(!bTabChangeOnly)
		GoToBox(false, nMyTongId, nMyClippingBoxId);
}

function ClassifyTong(bTabChangeOnly)
{
	document.getElementById('tblClippingTong').style.display = "none";
	document.getElementById('tblClassifyTong').style.display = (nBoxCount ? "" : "none");
	document.getElementById('tblClassifyNoTong').style.display = (nBoxCount ? "none" : "");
	document.getElementById('tblClippingTongTail').style.display = (nBoxCount ? "none" : "");
	document.getElementById('tblClassifyTongTail').style.display = (nBoxCount ? "" : "none");
	document.getElementById('imgFFCompatible').style.display = "";
	document.getElementById('imgFFCompatible').style.display = "none";
	if (!bTabChangeOnly && nBoxCount)
		GoToBox(false, nMyTongId, nMyFirstBoxId);
}

function GoToAdmin(nType)
{
	ShowNickLayer(null,false);
	ShowBoxLayer(null,false);
	nMyBoxId = (nType == 1 ? nMyBoxId : 0);
	ShowTicker(nType == 1);
	RefreshLinkBoxList();

	switch (nType)
	{
		case 0:
    		frameMain.location.href = '/mytong/mytong.do?action=form&myTongID=' + nMyTongId;
    		break;
		case 1:
			frameMain.location.href = '/mytong/box.do?action=manageform&myTongID=' + nMyTongId + '&boxID=' + nMyBoxId;
			break;
		case 2:
			frameMain.location.href = '/mytong/box.do?action=manageform&myTongID=' + nMyTongId;
			break;
		case 3:
			frameMain.location.href = '/mytong/puzzle.do?action=form&myTongID=' + nMyTongId;
			break;
		case 4:
			frameMain.location.href = '/friend/inviteList.do?myTongID=' + nMyTongId;
			break;
		case 5:
			frameMain.location.href = '/mytong/bookmark.do?action=view&tongID=' + nMyTongId;
			break;			
		case 6:
			frameMain.location.href = '/friend/friendDenied.do?myTongID=' + nMyTongId;
			break;			
		default:
			break;
	}
}

function GoToNoBox(bTopNavigate, nTongId)
{
	nMyTongId = nTongId;
	strViewMode = 'nobox';
	ShowNickLayer(null,false);
	ShowBoxLayer(null,false);
	nMyBoxId = 0;
	ShowTicker(false);
	RefreshLinkBoxList();
	frameMain.location.href = '/html/boxwizard_nobox.html';
}
/* ??¢¯? ¨ú??? Version 1.2
function GoToWizard(bTopNavigate, nTongId)
{
	nMyTongId = nTongId;
	strViewMode = 'boxwizard';
	ShowNickLayer(null,false);
	ShowBoxLayer(null,false);
	nMyBoxId = 0;
	ShowTicker(false);
	RefreshVisitorList();
	frameMain.location.href = '/mytong/box.do?action=wizard&myTongID=' + nTongId;
}
*/

function GoToTong(bTopNavigate, nTongId)
{
	if (bTopNavigate)
	{
		self.location.href = '/mytong/mytong.do?action=main&myTongID=' + nTongId;
		return;
	}
	
	nMyTongId = nTongId;
	strViewMode = 'mytong';
	ShowNickLayer(null,false);
	ShowBoxLayer(null,false);
	nMyBoxId = 0;
	ShowTicker(false);
	RefreshLinkBoxList();
	frameMain.location.href = '/mytong/mytong.do?action=body&myTongID=' + nTongId;
}
function GoToBox(bTopNavigate, nTongId, nBoxId, strMode)
{
	if (!strMode || strMode == '')
		strMode = 'box';
	
	if (bTopNavigate)
	{
		self.location.href = '/mytong/mytong.do?action=' + (strMode == 'box' ? 'main' : 'redirect') + '&myTongID=' + nTongId + '&boxID=' + nBoxId + '&viewMode=' + strMode;
		return;
	}
	
	nMyTongId = nTongId;
	nMyBoxId = nBoxId;
	strViewMode = 'box';
	ShowNickLayer(null,false);
	ShowBoxLayer(null,false);
	nMyBoxId = nBoxId;
	ShowTicker(true);
	RefreshLinkBoxList();
	frameMain.location.href = '/boxitem/jini.do?action=boxDesc&_tongID=' + nTongId + '&_boxID=' + nBoxId + '&viewMode=' + strMode;
}
function GoToPost(bTopNavigate, nTongId, nBoxId, nPostId)
{
	if (bTopNavigate)
	{
		self.location.href = '/mytong/mytong.do?action=main&myTongID=' + nTongId + '&boxID=' + nBoxId + '&postID=' + nPostId + '&viewMode=post';
		return;
	}
	
	nMyTongId = nTongId;
	nMyBoxId = nBoxId;
	strViewMode = 'post';
	nMyBoxId = nBoxId;
	ShowTicker(true);
	RefreshLinkBoxList();
	if (nMyClippingBoxId == nBoxId)
		ClippingTong(true);
	frameMain.location.href = '/boxitem/jini.do?action=boxDesc&_tongID=' + nTongId + '&_boxID=' + nBoxId + '&_boxItemID=' + nPostId + '&viewMode=post';
}
function GoToToday()
{
	GoToLastChange();
	return;	
	strViewMode = 'box';
	nMyBoxId = 0;
	ShowTicker(false);
	RefreshLinkBoxList();
	frameMain.location.href = '/mytong/happened.do?action=listall&myTongID=' + nMyTongId;
}
function GoToSearch()
{
	strViewMode = 'mytong';
	nMyBoxId = 0;
	ShowTicker(false);
	RefreshLinkBoxList();
	frameMain.location.href = '/search/search.do?action=searchintong&myTongID=' + nMyTongId + '&keyword=' + strSearchKeyword;
}
function GoToWithMe()
{
	strViewMode = 'box';
	nMyBoxId = 0;
	ShowTicker(false);
	RefreshLinkBoxList();
	frameMain.location.href = '/mytong/connected.do?action=match&ownerID=' + nMyTongId;
}
function GoToRecommand(nTongId, nBoxId)
{
	strViewMode = 'box';
	nMyBoxId = nBoxId;
	ShowTicker(true);
	RefreshLinkBoxList();
	frameMain.location.href = '/boxitem/jini.do?action=boxDesc&_tongID=' + nTongId + '&_boxID=' + nBoxId + '&viewMode=recommand';
}
function GoToRecommandByPuzzle(nTongId, nBoxId)
{
	strViewMode = 'box';
	nMyBoxId = nBoxId;
	ShowTicker(true);
	RefreshLinkBoxList();
	frameMain.location.href = '/boxitem/jini.do?action=boxDesc&_tongID=' + nTongId + '&_boxID=' + nBoxId + '&viewMode=recommand';
}
function GoToLinkmap(nTongId, nBoxId, bPostAll)
{
	strViewMode = 'box';
	nMyBoxId = nBoxId;
	ShowTicker(true);
	RefreshLinkBoxList();
	frameMain.location.href = '/boxitem/jini.do?action=boxDesc&_tongID=' + nTongId + '&_boxID=' + nBoxId + '&viewMode=' + (bPostAll ? 'linkmap_postall' : 'linkmap');
}
function GoToComment(nTongId, nBoxId, nPostId)
{
	strViewMode = 'post';
	nMyBoxId = nBoxId;
	ShowTicker(true);
	RefreshLinkBoxList();
	frameMain.location.href = '/boxitem/jini.do?action=boxDesc&_tongID=' + nTongId + '&_boxID=' + nBoxId + '&_boxItemID=' + nPostId + '&viewMode=comment';
}
function GoToWeave(nTongId, nBoxId, nPostId)
{
	strViewMode = 'post';
	nMyBoxId = nBoxId;
	ShowTicker(true);
	RefreshLinkBoxList();
	frameMain.location.href = '/boxitem/jini.do?action=boxDesc&_tongID=' + nTongId + '&_boxID=' + nBoxId + '&_boxItemID=' + nPostId + '&viewMode=weave';
}
function GoToSympathy(nTongId, nBoxId, nPostId)
{
	strViewMode = 'post';
	nMyBoxId = nBoxId;
	ShowTicker(true);
	RefreshLinkBoxList();
	frameMain.location.href = '/boxitem/jini.do?action=boxDesc&_tongID=' + nTongId + '&_boxID=' + nBoxId + '&_boxItemID=' + nPostId + '&viewMode=sympathy';
}
function GoToRss(nTongId, nBoxId)
{
	strViewMode = 'box';
	nMyBoxId = nBoxId;
	ShowTicker(true);
	RefreshLinkBoxList();
	frameMain.location.href = '/boxitem/jini.do?action=boxDesc&_tongID=' + nTongId + '&_boxID=' + nBoxId + '&viewMode=rss';
}
function GoToTogether(nTongId, nBoxId)
{
	strViewMode = 'box';
	nMyBoxId = nBoxId;
	ShowTicker(true);
	RefreshLinkBoxList();
	frameMain.location.href = '/boxitem/jini.do?action=boxDesc&_tongID=' + nTongId + '&_boxID=' + nBoxId + '&viewMode=together';
}
function GoToGuestbook(nGuestbookId)
{
	strViewMode = 'mytong';
	nMyBoxId = 0;
	ShowTicker(false);
	RefreshLinkBoxList();
	frameMain.location.href = '/mytong/mytong.do?action=body&myTongID=' + nMyTongId + '&guestbookid=' + nGuestbookId + '&viewMode=guestbook';
}

function GoToGuestbookNew(nGuestbookId)
{
	strViewMode = 'mytong';
	nMyBoxId = 0;
	ShowTicker(false);
	RefreshLinkBoxList();
	//frameMain.location.href = '/mytong/mytong.do?action=body&myTongID=' + nMyTongId + '&guestbookid=' + nGuestbookId + '&viewMode=guestbook';
	frameMain.location.href = '/user/guestbookList.do?myTongID=' + nMyTongId + '&guestbookid=' + nGuestbookId;
}


function GoToGuestbookView()
{
	strViewMode = 'mytong';
	nMyBoxId = 0;
	ShowTicker(false);
	RefreshLinkBoxList();
	frameMain.location.href = '/user/guestbookList.do?myTongID=' + nMyTongId ;	
}

function GoToPostWriter()
{
	strViewMode = 'mytong';
	nMyBoxId = 0;
	ShowTicker(false);
	RefreshLinkBoxList();
	frameMain.location.href = '/boxitem/post.do?action=createForm&_tongID=' + nTongId;
}



function TickerLoaded()
{
	if (document.getElementById('tickerContent').style.display == "")
		ShowTicker(true);
}

function ShowTicker(bShow)
{
// 20060928 ÀÓ½ÃÃ³¸®.
//	return;
	
	// gnb ¿µ¿ª ¹æ¹®ÀÚ ¹× Åë»ý¼ºÀÏ È°¼º
	document.getElementById('visitor_count').style.display = (bShow ? "none" : "");	
	
	// gnb ¿µ¿ª Æ¼Ä¿ È°¼ºÈ­
	document.getElementById('tickerContent').style.display = (bShow ? "" : "none");
	
	if (bSafari)
		return;			

	if (nMyBoxId && nTickerBoxId != nMyBoxId)
	{
		var nOldTickerBoxId = nTickerBoxId;
		nTickerBoxId = nMyBoxId;
		
		try
		{	
			var objTicker = document.getElementById((bIE ? 'object' : 'embed') + '_ticker_interface_new');			
			objTicker.SetVariable("/:tID", nMyTongId);
			objTicker.SetVariable("/:bID", nTickerBoxId);
			objTicker.TCallFrame("/", "3");
		}
		catch (e)
		{
			bShow = false;
			nTickerBoxId = nOldTickerBoxId;
		}
	}	
}

function embed_ticker_interface_DoFSCommand(command, args)
{
	// ok we may just return safely
	return;
}
function GoToLastChange()
{
	document.getElementById('imgLastChange').style.display = "none";
//	document.getElementById('imgLastChange1').style.display = "none";
	nMyBoxId = 0;
	ShowTicker(false);
	RefreshLinkBoxList();
	if(strTongMode == 'mymaintong')
	{
		frameMain.location.href = '/mytong/happened.do?action=list_inmytong_ext&myTongID=' + nMyTongId;
	}
	else if(strTongMode == 'photo')
		GoToPhotoHappened(nMyTongId);
	else if(strTongMode == 'mmedia')
		GoToMMediaHappened(nMyTongId);
	else if(strTongMode == 'review')
		GoToReviewHappened(nMyTongId);
	else
		frameMain.location.href = '/mytong/happened.do?action=list_inmytong_ext&myTongID=' + nMyTongId;

}



function GoToCommentTrace()
{
	document.getElementById('imgCommentTrace').style.display = "none";
	nMyBoxId = 0;
	ShowTicker(false);
	RefreshLinkBoxList();
	frameMain.location.href = '/mytong/happened/body_happened.vm?happenedType=C&myTongID=' + nMyTongId;
}
function GoToLinkBoxNews(bToBox)
{
	if (bOwner)
		document.getElementById('imgLinkBoxNews').style.display = "none";
	
	if (bToBox)
		GoToLinkmap(nMyTongId, nMyBoxId, true);
	else
	{
		nMyBoxId = 0;
		ShowTicker(false);
		RefreshLinkBoxList();
		frameMain.location.href = '/mytong/happened/body_happened.vm?happenedType=U&myTongID=' + nMyTongId;
	}
}

function AddBoxToLeftBoxList(nBoxId, nLevelIndex, bNeighbor, strName, bNew, bSameCategory, bHidden, sColor, bHasPermission, bAdultOnly)
{	
	if (nBoxId == -9) // category line
	{
		AddCategoryToLeftBoxList(strName, sColor);
		return;
	}
	
	if (nMyFirstBoxId == 0)
		nMyFirstBoxId = nBoxId;
	
	// icon_new			12 ( 8px + space 4px)
	// level			19 ( 15px + space 4px)
	// hidden			14 ( 10px + space 4px)
	// adultonly		16 ( 12px + space 4px)

	var nAvailPixelWidth = 145; // 170 - level
	strName = strName.split("&quot;").join("\"").split("&lt;").join("<");

	if (bNew)
		nAvailPixelWidth = nAvailPixelWidth - 12;
	if (bHidden)
		nAvailPixelWidth = nAvailPixelWidth - 15;
	if (bAdultOnly)
		nAvailPixelWidth = nAvailPixelWidth - 16;
	
	var strDrawName = GetPixelSizedText(strName, nAvailPixelWidth, false);
	
	var strHtml = '<DIV class=\"list_sub\"><img src=/images/mytong/tonglevel' + nLevelIndex + '.gif align=absmiddle class=img_bottom03>';
	strHtml = strHtml + ' <a href=javascript:GoToBox(false,' + nMyTongId + ',' + nBoxId + ')>';
	strHtml = strHtml + '<font color=' + sColor + '>' + strDrawName + '</font></a>';
	
	if (bHidden == 1)
		strHtml = strHtml + ' <img src=/images/mytong/icon_hidden.gif align=absmiddle class=img_bottom02>';
		
	if (bHidden == 2 && bHasPermission)
		strHtml = strHtml + ' <img src=/images/mytong/icon_key.gif align=absmiddle class=img_bottom02>';
		
	if (bNew)
		strHtml = strHtml + ' <img src=/images/mytong/icon_new.gif align=absmiddle class=img_bottom02>';
		
	if (bAdultOnly)
		strHtml = strHtml + ' <img src=/images/mytong/icon_19.gif align=absmiddle class=img_bottom02>';
			
	strHtml = strHtml + "</div>";
	
	MyInsertAdjacentHTML("BeforeEnd", strHtml, document.getElementById('myInterestList'));
	
	
	nBoxCount++;
}
function AddCategoryToLeftBoxList(strName, sColor)
{
	var nAvailPixelWidth = 170;
	strName = strName.split("&quot;").join("\"").split("&lt;").join("<");
  
	var strDrawName = GetPixelSizedText(strName, nAvailPixelWidth, true);	
	var strHtml = '<div class=\"list_tit\"><span style=color:' + sColor + '>' + strDrawName + '</span></div>';
	
	MyInsertAdjacentHTML("BeforeEnd", strHtml, document.getElementById('myInterestList'));	
}

// tong 1.5
function AddTongToLeftVisitorList(bIsMytong, strVisitorId, strNateId, strTongTitle, nLevelIndex, strCategoryName, nBoxId)
{
	document.getElementById('visitor_nothing').style.display = "none";	
	document.getElementById('visitor_list').style.display = "";	

	strTongTitle = strTongTitle.split("&quot;").join("\"").split("&lt;").join("<");
	strTongTitle = GetPixelSizedText(strTongTitle, (strVisitorNateId == strNateId ? 148 : 164), false);

	var  strHtml = '<LI>';
	strHtml = strHtml + '<a href=/' + strNateId + ' class=nick>' + strTongTitle + '</a>';
	if (strVisitorNateId == strNateId  || bIsMytong == "true")
		strHtml = strHtml + ' <a href="javascript:DeleteVisitorHistory(' + strVisitorId + ')"><img src=/images/mytong/icon_delete.gif align=absmiddle style=margin-bottom:2></a>';
	strHtml = strHtml + '</LI>';
	
//	var nod=document.createElement("LI");
//	document.getElementById("ulvisiotr").insertBefore(nod);
//	nod.innerHTML = strHtml;	
	
	MyInsertAdjacentHTML("BeforeEnd", strHtml, document.getElementById('ulvisiotr'));
	
	var visitorList = document.getElementById("ulvisiotr").childNodes;
	var nRowCount = visitorList.length;
	var bMore = false;
			
	for (var i = 5; i < nRowCount; i++)
	{
		visitorList[i].style.display = "none";
		document.getElementById('imgVisitorListMore').src = '/images/library/button/btn_txt_more2.gif';
		document.getElementById('visitormore').style.display = "";
	}
}

function ToggleLeftVisitorList()
{
	var visitorList = document.getElementById("ulvisiotr").childNodes;
	var nRowCount = 	visitorList.length;
	var bMore = false;

	// È®ÀåµÈ»óÅÂÀÌ¸é...
	if(visitorList[5].style.display == "")
	{
		bMore = true;
	}
			
	for (var i = 5; i < nRowCount; i++)
	{
		if(bMore == true) visitorList[i].style.display = "none";
		else visitorList[i].style.display = "";
	}
	
	document.getElementById('imgVisitorListMore').src = '/images/library/button/btn_txt_' + (bMore == "" ? "close" : "more2") + '.gif';

}

function DeleteVisitorHistory(strVisitorId)
{
	/*var tbl = document.getElementById('tblVisitorList');
	var nRowCount = tbl.rows.length;
	
	for (var i = 0; i < nRowCount; i++)
		tbl.deleteRow(0);	
	document.getElementById('tdVisitorListMore').style.display = "none";*/
		
	var objVisitor = document.getElementById("ulvisiotr");
	var visitorList = objVisitor.childNodes;
	var nRowCount = 	visitorList.length;
	
	for (var i = 0; i < nRowCount; i++)
	{
		this_node = visitorList[0];
		removed_node = objVisitor.removeChild(this_node);	
	}		
	document.getElementById('visitormore').style.display = "none";
	frameLeftVisitorList.location.href = '/user/visitList.do?action=del&myTongID=' + nMyTongId + '&targetID=' + strVisitorId;	
}

function UpdateVisitorCount(nTodayVisitor, nTotalVisitor)
{
	document.getElementById('spnTodayVisitor').innerHTML = nTodayVisitor;
	document.getElementById('spnTotalVisitor').innerHTML = nTotalVisitor;
}
function AddBoxToLeftLinkBoxList(nTongId, nBoxId, nLevelIndex, strName)
{
	document.getElementById('divLinkBox').style.display = "";
	document.getElementById('divLinkBoxListNone').style.display = "none";

	var nAvailPixelWidth = 135; // 170 - level
	
	strName = strName.split("&quot;").join("\"").split("&lt;").join("<");

	var strDrawName = GetPixelSizedText(strName, nAvailPixelWidth, false);

	var strHtml = '<div class="list_sub"><img src=/images/mytong/tonglevel' + nLevelIndex + '.gif align=absmiddle class=img_bottom03>';
	strHtml = strHtml + ' <a href=javascript:GoToBox(true,' + nTongId + ',' + nBoxId + ') >';
	strHtml = strHtml + strDrawName + '</a></div>';

	MyInsertAdjacentHTML("beforeend", strHtml, document.getElementById('divLinkBoxList'));	
}
function AddFavorite()
{
	if (confirm('Áñ°ÜÃ£±â·Î µî·ÏÇÏ½Ã°Ú½À´Ï±î?'))
	{
		frameLeftAddFavorite.location.href = '/friend/bookmark.do?bookmarked=' + nMyTongId;
		document.getElementById('imgAddFavorite').style.display = "none";
	}
}
function ShowInfoPostList(strListName)
{
	var styleNeighborBox = document.getElementById('tblNeighborBox').style;
	var styleNeighborBlog = document.getElementById('tblNeighborBlog').style;
	var styleRecommendBox = document.getElementById('tblRecommendBox').style;
	
	if (strListName == "NeighborBox")
	{
		styleNeighborBox.display = "";
		styleNeighborBlog.display = "none";
		styleRecommendBox.display = "none";
		objDefaultImg = document.getElementById('imgNeighborBox');
	}
	else if (strListName == "NeighborBlog")
	{
		styleNeighborBox.display = "none";
		styleNeighborBlog.display = "";
		styleRecommendBox.display = "none";
		objDefaultImg = document.getElementById('imgNeighborBlog');
	}
	else if (strListName == "RecommendBox")
	{
		styleNeighborBox.display = "none";
		styleNeighborBlog.display = "none";
		styleRecommendBox.display = "";
		objDefaultImg = document.getElementById('imgRecommendBox');
	}
}
function NavigateBody(strPath)
{
	frameMainBody.location.href = strPath;
}
function PopupTongSummary(strType)
{
	if (strType == 'neighbor')
		window.open('/boxitem/jini.do?action=popupConcerned&value(sort)=0&_boxID=0&_tongID=' + nMyTongId, 'popupConcerned', 'scrollbars=yes,status=yes,width=440,height=476,left=' + (window.screen.availWidth/2 - 210) + ',top=' + (window.screen.availHeight/2 - 238));
	else if (strType == 'scrap')
		window.open('/boxitem/jini.do?action=popupScrapped&value(sort)=0&_boxID=0&_tongID=' + nMyTongId, 'popupScrapped', 'status=yes,width=500,height=454,left=' + (window.screen.availWidth/2 - 250) + ',top=' + (window.screen.availHeight/2 - 227));
}

/*

var strMapLayer = '<div id=divMapLayer style=position:absolute;top:91;left:916;>';
strMapLayer = strMapLayer + '<table border=0 cellspacing=0 cellpadding=0>';
strMapLayer = strMapLayer + '<tr id=trWaveLayer style=display:none><td>';
strMapLayer = strMapLayer + '<a href=javascript:PopupBoxLinkMap(nMyTongId,nMyBoxId,nMyTongId)><img src=/images/mytong/main/icon_wave.gif></a><br><br>';
strMapLayer = strMapLayer + '</td></tr>';
strMapLayer = strMapLayer + '<tr><td id=tdMapLayer>';
strMapLayer = strMapLayer + '</td></tr></table></div>';

var objMapLayer = null;
function UseMapLayer()
{
return;
	MyInsertAdjacentHTML("BeforeEnd", strMapLayer, document.body);
	objMapLayer = document.getElementById('divMapLayer');
}
*/
function AddEventImgToMapLayer(strImg, strLink, strTarget)
{
	var strHtml = '';
	if (strLink != '')
		strHtml = '<br><a href="' + strLink + '" target="' + strTarget + '"><img src="' + strImg + '"></a><br>';
	else
		strHtml = '<br><img src="' + strImg + '"><br>';
	MyInsertAdjacentHTML("BeforeEnd", strHtml, document.getElementById('event_navi'));
}