/* 여기부터 html.youthvoice.daum.net/js/common.js 가져온거 */

function copyToClipboard(val) { 
	window.clipboardData.setData("Text", val);
    var url = "http://youthvoice.daum.net/yv3/common/pop_copy_url_to_clipboard.do?url="+val;
    window.open(url,'winOfConfirmationURLCopy','scrollbars=no,resizable=no,width=350,height=200');
}

function addFriend(friendId) {
	var url = 'http://youthvoice.daum.net/yv3/profile/common/friend_add.do?friendId=' + friendId
	window.open(url ,'popup','scrollbars=no,resizable=no,width=350,height=230');
}

function deleteFriend(friendId) {
	var url = 'http://youthvoice.daum.net/yv3/profile/common/friend_delete.do?friendId=' + friendId
	window.open(url ,'popup','scrollbars=no,resizable=no,width=350,height=230');
}

function listFriend(userId) {
	var url = 'http://youthvoice.daum.net/yv3/profile/common/friend_list.do?userId=' + userId
	window.open(url ,'popup','scrollbars=no,resizable=no,width=360,height=230');
}

function updateChar(length_limit, obj)
{
	var comment='';
	comment = obj;
	var form = document.bbsForm;
	var length = calculate_msglen(comment.value);
	if (length > length_limit) {
		alert("최대 " + length_limit + "byte이므로 초과된 글자수는 자동으로 삭제됩니다.");
		comment.value = comment.value.replace(/\r\n$/, "");
		comment.value = assert_msglen(comment.value, length_limit, "textlimit");
	}
}

function calculate_msglen(message)
{
	var nbytes = 0;

	for (i=0; i<message.length; i++) {
		var ch = message.charAt(i);
		if(escape(ch).length > 4) {
			nbytes += 2;
		} else if (ch == '\n') {
			if (message.charAt(i-1) != '\r') {
				nbytes += 1;
			}
		} else if (ch == '<' || ch == '>') {
			nbytes += 4;
		} else {
			nbytes += 1;
		}
	}

	return nbytes;
}

function assert_msglen(message, maximum, textlimit)
{
	var inc = 0;
	var nbytes = 0;
	var msg = "";
	var msglen = message.length;

	for (i=0; i<msglen; i++) {
		var ch = message.charAt(i);
		if (escape(ch).length > 4) {
			inc = 2;
		} else if (ch == '\n') {
			if (message.charAt(i-1) != '\r') {
				inc = 1;
			}
		} else if (ch == '<' || ch == '>') {
			inc = 4;
		} else {
			inc = 1;
		}
		if ((nbytes + inc) > maximum) {
			break;
		}
		nbytes += inc;
		msg += ch;
	}
	return msg;
}
/* 여기까지 html.youthvoice.daum.net/js/common.js */

var currentMenuId = "1";
document.write("<script type='text/javascript' src='http://image.youthvoice.daum.net/yv3/js/activex.js'><"+"/script>");
function top_movie(){
document.write("<div id='topmovie'></div>");
daumFlash_general("http://image.youthvoice.daum.net/yv2/swf/top_movie.swf","","978","110","topmovie");
}

function top_nav(){
	var currentMenuId = currentMenuNo;
	if(currentMenuId <= 5){
		document.getElementById("m"+currentMenuId).childNodes.item(0).className = "on" ;
		document.getElementById("m"+currentMenuId).className = "on" ;
	}
}

/* popup */
var Browser = new Object();
Browser.isIE = (navigator.userAgent.toLowerCase().indexOf("msie")!=-1);
Browser.isIE_SV1 = (navigator.userAgent.toLowerCase().indexOf("sv1")!=-1);
Browser.isIE_SV2 = (navigator.userAgent.toLowerCase().indexOf("sv2")!=-1);
Browser.isIE_6 = (navigator.userAgent.toLowerCase().indexOf("msie 6")!=-1);
Browser.isIE_7 = (navigator.userAgent.toLowerCase().indexOf("msie 7")!=-1);
Browser.isFirefox = (navigator.userAgent.toLowerCase().indexOf("firefox")!=-1);
Browser.isSafari = (navigator.userAgent.toLowerCase().indexOf("safari")!=-1);
Browser.isOpera = (navigator.userAgent.toLowerCase().indexOf("opera")!=-1);
Browser.isNetscape = (navigator.userAgent.toLowerCase().indexOf("netscape")!=-1);
Browser.isEtc = (navigator.userAgent.toLowerCase().indexOf("gecko")!=-1 && navigator.userAgent.toLowerCase().indexOf("firefox")==-1 && navigator.userAgent.toLowerCase().indexOf("netscape")==-1 );

function resizePopup(popWidth) {
	var h=0;
	if(! popWidth){ var popWidth=0;}

	var popHeight = document.getElementById("popWrap").offsetHeight+34;
	
	if (Browser.isIE_SV1)	{ h = 14; } 
	else if(Browser.isIE_6)	{ h = 40; }
	else if(Browser.isIE_7)	{ h = 18; }
	else if(Browser.isEtc)	{ h = 22; } 
	else if(Browser.isFirefox)	{ h = 32; } 
	else if(Browser.isNetscape)	{ h = -2; }
	else if(Browser.isOpera)	{ h = 26; }
	else			{ h = 0; }
	window.resizeTo(popWidth,popHeight+h);
}

function Pop(popUrl,popId,popW,popH){
	window.open(popUrl, popId, "width="+popW+",height="+popH+",scrollbars=0");
}

function rollOver(obj, classN) { document.getElementById(obj).className = classN; }
function rollOverImg(obj, imgSrc) { document.getElementById(obj).src= "http://image.youthvoice.daum.net/yv3/img/"+imgSrc+".gif";}
function togDisplay(objId, act) {
	if (document.getElementById(objId)) {
		document.getElementById(objId).style.display = act;
	}
}

function checkApp(section){ //사전제작지원작품체크 시
	if ( (Browser.isFirefox) || (Browser.isOpera) ) {var rowBlock = "table-row"; } 
	else{ var rowBlock = "block";}
	
	if(document.getElementById('cateItemObj1').checked){
		document.getElementById('CAREER').style.display='none';
		if(document.getElementById('REPORT')) document.getElementById('REPORT').style.display=rowBlock;
		document.getElementById('TEAMMEM').style.display='inline';
		Pop("http://youthvoice.daum.net/yv3/yvvoice/pop/supportguide_pop.do?sectiona="+section,"supportGuide",475,305);
	}else{
		document.getElementById('CAREER').style.display=rowBlock;
		if(document.getElementById('REPORT')) document.getElementById('REPORT').style.display='none';
		document.getElementById('TEAMMEM').style.display='none';
	}
}
function emailsiteCheck(id){
	if(id=="직접 입력"){
		document.getElementById("custom_emailsite2").style.display="inline";
		document.getElementById("custom_emailsite2").focus();
	}else{
		document.getElementById("custom_emailsite2").style.display="none";
	}
}

/* CCL FAQ */
function showfaq(o){
	var obj =document.getElementById(o);
	if(obj.style.display =="none") obj.style.display="block";
	else obj.style.display="none";
}

/*BBS*/
function setopenOp(){document.getElementById('setopenWap').style.display="block";}
function setopenCl(){document.getElementById('setopenWap').style.display="none";}
function setopenChk(n){
	if(n=="1") document.getElementById('allow_cmt').style.display="none";
	else document.getElementById('allow_cmt').style.display="inline";
}

function editor_br(obj){obj.className="editor_br";}
function editor_br_on(obj){obj.className="editor_br_on";}

function yv20_viewact(flag) {
	closeLayers();
	/* ? */
	if(flag == "2") {
		if ( editFrm.srcedit.value == "1" ) {
			editFrm.write_edit1.src = "http://image.youthvoice.daum.net/yv2/site_img/editor/write_edit1_d.gif";
			editFrm.write_html1.src = "http://image.youthvoice.daum.net/yv2/site_img/editor/write_html1.gif";		
			document.getElementById("EditCtrl").contentWindow.document.body.innerText = document.getElementById("EditCtrl").contentWindow.document.body.innerHTML;
			editFrm.srcedit.value = "2";
		}
	/* html? */	
	} else if (flag == "1") {
		if ( editFrm.srcedit.value == "2" ) {
			editFrm.write_edit1.src = "http://image.youthvoice.daum.net/yv2/site_img/editor/write_edit1.gif";
			editFrm.write_html1.src = "http://image.youthvoice.daum.net/yv2/site_img/editor/write_html1_d.gif";
			document.getElementById("EditCtrl").contentWindow.document.body.innerHTML = document.getElementById("EditCtrl").contentWindow.document.body.innerText;
			editFrm.srcedit.value = "1";
		}		
	}
}

function resizePopup() {
	var oBody = document.body;
	var width = oBody.scrollWidth + ( oBody.offsetWidth - oBody.clientWidth );
	var height = oBody.scrollHeight + ( oBody.offsetHeight - oBody.clientHeight ) ;
        var h=0;
        if (navigator.userAgent.indexOf("SV1") > 0){  h=14; } 
        else if(navigator.userAgent.indexOf("MSIE 7")>0) { h=45; }
        else if(navigator.userAgent.indexOf("Gecko")>0 && navigator.userAgent.indexOf("Firefox") <= 0 && navigator.userAgent.indexOf("Netscape") <= 0 ){ h=22; } 
        else if(navigator.userAgent.indexOf("Firefox") >0 ){  h=18; } 
        else if(navigator.userAgent.indexOf("Netscape") >0 ){ h=-2; }
        else { h=0;} 
        window.resizeTo(width,height+h);
}

function charCounter(bytesizes, fieldname){
	var strCounter = 0;
	var tempStr, tempStr2;
	for(i = 0;i < document.getElementById(fieldname).value.length;i++)
	{
		tempStr = document.getElementById(fieldname).value.charAt(i);
		if(escape(tempStr).length > 4) strCounter += 2;
			else strCounter += 1 ;
	}
	if (strCounter > bytesizes){
		bytesz = bytesizes/2;
		alert("최대 " + bytesz + "자까지 입력할 수 있습니다.");		
		strCounter = 0;		
		tempStr2 = "";
		for(i = 0; i < document.getElementById(fieldname).value.length; i++) 
		{
			tempStr = document.getElementById(fieldname).value.charAt(i);	
			if(escape(tempStr).length > 4) strCounter += 2;
			else strCounter += 1 ;
			if (strCounter > bytesizes)
			{
				if(escape(tempStr).length > 4) strCounter -= 2;
				else strCounter -= 1 ;	
				break;	      		
			}
			else tempStr2 += tempStr;
		}	    
		document.getElementById(fieldname).value = tempStr2;
		document.getElementById(fieldname).focus();
	}
}



function goProfile(uid){
	location.href="http://youthvoice.daum.net/yv3/profile.do?userId="+uid;
}
function goGuestbook(uid){
	location.href="http://youthvoice.daum.net/yv3/profile.do?userId="+uid+"#cmtTitle";
}

function rand_number(n){
	var x;
	x=Math.round(Math.random()*100);
	x%=n;
	return x;
}
/*우측배너*/
function rBanner(){
	if(location.href.search('yvtop') < 0 && location.href.search('hyphen.daum.net/youthvoice') < 0 && location.href.search(/youthvoice\.daum\.net\/\??.*$/) < 0){
		return rBannerSub();
	}

	var img = new Array();

	img[0]="<a href='http://youthvoice.daum.net/yvevent/read?bbsId=Event&articleId=61&pageIndex=1&searchKey=&searchValue=' title='다음작가'><img src='http://image.youthvoice.daum.net/yv3/img/event090520/btop_090520.gif' width='250' height='240' alt='다음작가'></a>";
	//img[0]="<a href='http://youthvoice.daum.net/yvevent/read?bbsId=Event&articleId=55&pageIndex=1&searchKey=&searchValue=' title='10대들이 말하는 성 이야기'><img src='http://image.youthvoice.daum.net/yv3/img/event080910/btop_080910.gif' width='250' height='240' alt='10대들이 말하는 성 이야기'></a>";
	//img[0]="<a href=http://youthvoice.daum.net/yvevent/read?bbsId=Event&articleId=55&pageIndex=1&searchKey=&searchValue=' title='10대들이 말하는 성 이야기'><img src='http://image.youthvoice.daum.net/yv3/img/event080910/btop_080910.gif' width='250' height='240'></a>";
	//img[0]="<a href='http://youthvoice.daum.net/yvevent/read?bbsId=Event&articleId=47&pageIndex=1&searchKey=&searchValue=' title='유스보이스 프렌토 2기 모집'><img src='http://image.youthvoice.daum.net/yv3/img/banner/bnr080218_top.gif' width='250' height='240' alt='유스보이스 프렌토 2기 모집'></a>";
	//img[0]="<a href='http://hyphen.daum.net/hyphen/hyphenpress.do' title='하이픈 대학생 기자단 모집'><img src='http://image.youthvoice.daum.net/yv3/img/banner/bnr080225_top.jpg' width='250' height='240' alt='하이픈 대학생 기자단 모집'></a>";
	//img[1]="<a href='http://blog.daum.net/ahahblog/11765169?_top_blogtop=notice1' title='창작과나눔의파티'><img src='http://image.youthvoice.daum.net/yv3/img/banner/bnr071213_top.jpg' width='250' height='240' alt='hope day'></a>";
	var n=rand_number(img.length); 
	document.write(img[n]);
}

function rBannerSub(){
	var img = new Array();
//	img[0]="<a href='http://youthvoice.daum.net/yv3/yvsupport/top.do' title='유스보이스 사전 제작 지원'><img src='http://image.youthvoice.daum.net/yv3/img/banner/bsub_090216.gif' width='250' height='240' alt='유스보이스 사전 제작 지원'></a>";
	//img[0]="<a href='http://youthvoice.daum.net/yvevent/read?bbsId=Event&articleId=57&pageIndex=1&searchKey=&searchValue=' title='2008 유스보이스 Day'><img src='http://image.youthvoice.daum.net/yv3/img/event081210/bsub_081210.gif' width='250' height='240' alt='2008 유스보이스 Day'></a>";
	//img[0]="<a href='http://youthvoice.daum.net/yv3/yvsupport/top.do' title='UCC제작 지원 캠페인'><img src='http://image.youthvoice.daum.net/yv3/img/banner/bnr080204_sub.jpg' width='215' height='201' alt='UCC제작 지원 캠페인'></a>";
	//img[0]="<a href='http://youthvoice.daum.net/yvevent/read?bbsId=Event&articleId=55&pageIndex=1&searchKey=&searchValue=' title='10대들이 말하는 성 이야기'><img src='http://image.youthvoice.daum.net/yv3/img/event080910/bsub_080910.gif' width='215' height='201'></a>";
	//img[0]="<a href='http://youthvoice.daum.net/yvevent/read?bbsId=Event&articleId=47&pageIndex=1&searchKey=&searchValue=' title='유스보이스 프렌토 2기 모집'><img src='http://image.youthvoice.daum.net/yv3/img/banner/bnr080219_sub.gif' width='215' height='201' alt='유스보이스 프렌토 2기 모집'></a>";
	//img[0]="<a href='http://hyphen.daum.net/hyphen/hyphenpress.do' title='하이픈 대학생 기자단 모집'><img src='http://image.youthvoice.daum.net/yv3/img/banner/bnr080225_sub.jpg' width='215' height='201' alt='하이픈 대학생 기자단 모집'></a>";
	document.write(img[rand_number(img.length)]);
}
