/**
 *	OS와 브라우저에 상관없이 범용적인 클립보드 복사 기능을 제공한다.
 *	단 _clipboard.swf파일이 있어야 한다.
 *	참조사이트: http://webchicanery.com/2006/11/14/clipboard-copy-javascript/
 */
function __clip(text2copy)
{
	var flashcopier = $("flashcopier");

	if ( flashcopier == undefined )
	{
		var flashcopier = document.createElement('div');
		flashcopier.id = "flashcopier";
		document.body.appendChild(flashcopier);
	}
	
	flashcopier.innerHTML = '<embed src="http://flash.goorm.com/krr/_clipboard.swf" FlashVars="clipboard='
						  + text2copy.replace(/\"/, "&quot")
						  //+ escape(text2copy)
						  + '" width="0" height="0" type="application/x-shockwave-flash"></embed>';
	alert("게시판 주소가 복사되었습니다. 메신저나 게시판에 Ctrl+V로 붙여 넣으세요");				  
}

function Substr(s,strLength){	 
	  if(s.length > strLength){
	  	s = s.substr(0, strLength)+"..";
	  }	
	  return(s);
}

// 문자열의 길이를 계산.
function StrLength(str)
{
//	return (str.length + (escape(str) + "/%u").match(/%u/g).length-1);
    var l = 0;
    for (var i=0; i<str.length; i++)
    	l += 2;
    	//l += (str.charCodeAt(i) > 128) ? 2 : 2;
    return l;
}
// form 객체의 maxlength를 가져와 길이 비교를 하고 넘어갈 경우 alert 메세지를 띄움.
function titleRestrict(obj,len,hname)
{
	if(StrLength(obj.value) > len){
		alert("최대 30자까지 입력하실 수 있습니다.");
		obj.value = obj.value.substring(0,30);
		obj.select();
		return false;
	}

	return true;
}