<!--
//
String.prototype.cut = function(len)
{
	var str = this;
	var l = 0;
	for (var i=0; i<str.length; i++)
	{
		l += (str.charCodeAt(i) > 128) ? 2 : 1;
		if (l > len) return str.substring(0,i) + "..";
	}
	return str;
}

String.prototype.bytes = function()
{
	var str = this;
	var l = 0;
	for (var i=0; i<str.length; i++) l += (str.charCodeAt(i) > 128) ? 2 : 1;
	return l;
}

function write_title(str, len)
{
	var cutstr = str.cut(len);
	document.write(cutstr);
}

function insertExternalFile(fname,W,H)
{
	if (navigator.appName.indexOf("Microsoft")!=-1 || navigator.appName=="Netscape" && parseInt(navigator.appVersion)>4)
	{
		document.write(''+'<IFRAME name="iframe_ad_name" src="'+fname+'" scrolling="no" frameborder=0 border=0 marginwidth=0 marginheight=0 allowTransparency="true"'+(W==null ? '' : ' width='+W)+(H==null ? '' : ' height='+H)+'></IFRAME>');
	}
	if (navigator.appName=="Netscape" && parseInt(navigator.appVersion)==4)
	{
		document.write(''+'<ILAYER>'+'<LAYER src="'+fname+'" '+(W==null ? '' : ' width='+W)+(H==null ? '' : ' height='+H)+'></LAYER></ILAYER>');
	}
}

function setPNG24(obj)
{
	obj.width=obj.height=1;
	obj.className=obj.className.replace(/\bpng24\b/i,'');
	obj.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+ obj.src +"',sizingMethod='image');";
	obj.src='';
	return '';
}

function ViewImage(img,width,height)
{
	if(img) window.open("../Libs/ViewImage.php?img="+img,"ViewImageFrm","left=0,top=0,width="+width+",height="+height);
}

function popupscrollno(sUrl,nWidth,nHeight,sPopName)
{
	var todayDate = new Date();
	var option = "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,width="+nWidth+",height="+nHeight;
	PopWin = window.open(sUrl,sPopName, option);
}

function ShowPopLayer(aEvent,LayName)
{
	var x = window.event ? window.event.clientX + document.documentElement.scrollLeft : aEvent.pageX;
	var y = window.event ? window.event.clientY + document.documentElement.scrollTop : aEvent.pageY;
	if (LayName) document.getElementById(LayName).style.top=y+"px";
	if (LayName) document.getElementById(LayName).style.left=x+"px";
	if (LayName) document.getElementById(LayName).style.display="block";
}

function WinOpen(url,id,param)
{
	window.open(url,id,param);
}

function encode_base64( what )
{
	var base64_encodetable = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
	var result = "";
	var len = what.length;
	var x, y;
	var ptr = 0;

	while( len-- > 0 )
	{
		x = what.charCodeAt( ptr++ );
		result += base64_encodetable.charAt( ( x >> 2 ) & 63 );

		if( len-- <= 0 )
		{
			result += base64_encodetable.charAt( ( x << 4 ) & 63 );
			result += "==";
			break;
		}

		y = what.charCodeAt( ptr++ );
		result += base64_encodetable.charAt( ( ( x << 4 ) | ( ( y >> 4 ) & 15 ) ) & 63 );

		if ( len-- <= 0 )
		{
			result += base64_encodetable.charAt( ( y << 2 ) & 63 );
			result += "=";
			break;
		}

		x = what.charCodeAt( ptr++ );
		result += base64_encodetable.charAt( ( ( y << 2 ) | ( ( x >> 6 ) & 3 ) ) & 63 );
		result += base64_encodetable.charAt( x & 63 );
	}
	return result;
}

function ShowUserLayer(aEvent,NickName,BbsCode,UserID)
{
	var x = window.event ? window.event.clientX + document.documentElement.scrollLeft : aEvent.pageX;
	var y = window.event ? window.event.clientY + document.documentElement.scrollTop : aEvent.pageY;
	var NoteUrl = encode_base64('../common/NoteWrite.php?ReceiveID=' + UserID);
	var UserMenuText = "<table cellpadding='0' cellspacing='0' border='0'>";
	UserMenuText += "	<tr>";
	UserMenuText += "		<td>&nbsp;<img src='../images/main/icon2.gif' /><font onclick=\"location.href='../bbs/?kids=list&BbsCode=" + BbsCode + "&s1=1&q=" + NickName + "'\" style='color:#b9b9b9;cursor:pointer;'>닉네임 검색<\/font><\/td>";
	UserMenuText += "	<\/tr>";
	UserMenuText += "	<tr>";
	UserMenuText += "		<td>&nbsp;<img src='../images/main/icon2.gif' /><font onclick=\"WinOpen('http://www.webgamech.com/common/Note.php?AutoFrm=" + NoteUrl + "','NotePopFrm','left=0,top=0,width=690,height=460');return false;\" style='color:#b9b9b9;cursor:pointer;'>쪽지쓰기<\/font><\/td>";
	UserMenuText += "	<\/tr>";
	UserMenuText += "	<tr>";
	UserMenuText += "		<td>&nbsp;<img src='../images/main/icon2.gif' /><font onclick=\"WinOpen('http://www.webgamech.com/mypage/friendcall.php?ReceiveID=" + encode_base64(UserID) + "','FriendCallFrm','left=0,top=0,width=400,height=230');return false;\" style='color:#b9b9b9;cursor:pointer;'>친구요청<\/font><\/td>";
	UserMenuText += "	<\/tr>";
	UserMenuText += "<\/table>";
	if (UserID) document.getElementById('UserMenuText').innerHTML = UserMenuText;
	if (UserID) document.getElementById('UserLayer').style.top=y+"px";
	if (UserID) document.getElementById('UserLayer').style.left=x+"px";
	if (UserID) document.getElementById('UserLayer').style.display="block";
}
//-->
