var domain = "27m.net";
var baseUrl = "http://" + domain + "/blog";

function bluring(){
	if(event.srcElement.tagName=="A"||event.srcElement.tagName=="IMG") document.body.focus();
}
document.onfocusin = bluring;

function goTop(){
	window.scrollTo(0,0);
}

function onclick_folder(hc, fd, url, check) {
	if (check == '0') {
		layer_toggle(hc);
	} else if (hc.style.display == 'none') {
		fd.src = url + 'tab_opened.gif';
		layer_toggle(hc);
	} else {
		fd.src = url + 'tab_closed.gif';
		layer_toggle(hc);
	}
}

function folder(id,option){
	var obj = document.getElementById(id);
	var img = "img" + id;
	var imgName = eval(img);
	if(obj.style.display=="none"){
		obj.style.display = "";
		imgName.src = baseUrl + "/img/tab_opened.gif";
	}
	else{
		obj.style.display = "none";
		imgName.src = baseUrl + "/img/tab_closed.gif";
	}
}

//Åä±Û
function toggle(obj){
	var r = document.getElementById(obj);
	if(r.style.display=="none") r.style.display = "";
	else r.style.display = "none";
}

//¼û±â±â º¸ÀÌ±â
function toggleMoreLess(obj,textMore,textLess){
	var r = document.getElementById(obj);
	var t = document.getElementById('txt_'+obj);
	var img = document.getElementById('img_'+obj);
	if(r.style.display=="none"){
		r.style.display = "";
		t.innerHTML = textLess;
		img.src = "/blog/img/btn_show.gif";
	}else{
		r.style.display = "none";
		t.innerHTML = textMore;
		img.src ="/blog/img/btn_hide.gif";
	}
}



function tabSwitch(tabName,tabIdx,tabCount){
	for(var i=0; i<tabCount; i++){
		tabObj = document.getElementById("tab_"+tabName+"_"+i);
		if(i==tabIdx){
			tabObj.style.display = "block";
		}else{
			tabObj.style.display = "none";
		}
	}
}

var folderAllOption = "open";
function folderAll(id){
	var obj = document.getElementById(id);
	var img = "img" + id;
	var imgName = eval(img);
	if(folderAllOption=="open"){
		obj.style.display = "";
		imgName.src = baseUrl + "/img/tab_opened.gif";
	}
	else{
		obj.style.display = "none";
		imgName.src = baseUrl + "/img/tab_closed.gif";
	}
}
function folderAllOptionChange(){
	if(folderAllOption=="open") folderAllOption = "close";
	else folderAllOption = "open";
}

//¼±ÅÃ -> Å¬¸³º¸µå º¹»ç
function selectAll(s){
	var doc = document.body.createTextRange();
	doc.moveToElementText(document.all(s));
	doc.select();
	doc.execCommand('copy');
	alert('URLÀÌ Å¬¸³º¸µå¿¡ ÀúÀåµÇ¾ú½À´Ï´Ù. ¿øÇÏ´Â °÷¿¡ ºÙ¿©³Ö±â(Ctrl+V) ÇÏ½Ã¸é µË´Ï´Ù.');
}

//Clipboard Copy Alert
function contentsCopy(name,title){
	if(window.event){
		window.event.returnValue = true;
		window.setTimeout('attachRef("' + name + '","' + title + '")',25);
	}
}
function attachRef(name,title){
	if(window.clipboardData){
		var today = new Date();
		var txt = window.clipboardData.getData('Text'); 
		txt = txt + "\r\nÃâÃ³: " + title + "\r\n¨Ï2002-" + today.getYear() + " " + name + " http://" + domain;
		var result = window.clipboardData.setData('Text', txt);
	}
}

//1ÇÈ¼¿
function fx(nNewPadding,el){
	while (el.tagName!="TD")
		el = el.parentNode;
	var nPadding = parseInt(el.getAttribute("nPadding"));
	el.style.paddingTop=nPadding+nNewPadding;
}

function defx(el){
	while (el.tagName!="TD")
		el = el.parentNode;
	var nPadding = parseInt(el.getAttribute("nPadding"));
	el.style.paddingTop = nPadding;

	ref = el.getAttribute("ref");
	if (ref)
	{
		var ref = document.getElementById(ref);

		while (ref.tagName!="TD")
			ref = ref.parentNode;

		var nPadding = parseInt(ref.getAttribute("nPadding"));
		ref.style.paddingTop = nPadding;
	}
}

function show(obj){
	var r = document.getElementById(obj);
	r.style.display = "";
}
function hide(obj){
	var r = document.getElementById(obj);
	r.style.display = "none";
}

//°¡¿îµ¥·Î »õÃ¢ ¶ç¿ì±â
function popNewwin(url,w,h,loca,resize,scroll){
	var winl = (screen.width-w)/2;
	var wint = (screen.height-h)/2;
	var settings  ='height='+h+',';
		settings +='width='+w+',';
		settings +='top='+wint+',';
		settings +='left='+winl+',';
		settings +='location='+loca+',';
		settings +='resizable='+resize+',';
		settings +='scrollbars='+scroll+',';
		if(loca==1) settings +='status=1,';
	toDay = new Date();
	var popName = "new" + toDay.getTime();
	newwins = window.open(url,popName,settings,'marginwidth=0,marginheight=0');
	newwins.focus();
}

//¼ýÀÚ¸¸
function onlyNumber(){
	if(event.keyCode!=13&&(event.keyCode<48||event.keyCode>57)){
		alert('¼ýÀÚ¸¸ ÀÔ·Â°¡´ÉÇÕ´Ï´Ù.');
		event.returnValue = false;
	}
}

//ÇÃ·¡½ÃÆÄÀÏ
function showFlashObject(id,width,height,movie,flashvars,style){
	var s = '<object id="'+id+'" classid="clsid:D27CDB6E-AE6D-11CF-96B8-444553540000" width="'+width+'" height="'+height+'" style="'+style+'"><param name="movie" value="'+movie+'"/><param name="menu" value="false"/><param name="quality" value="high"/><param name="allowScriptAccess" value="sameDomain"/><param name="play" value="true"/><param name="wmode" value="transparent"/><param name="flashvars" value="'+flashvars+'"/><embed swLiveConnect="true" flashvars="'+flashvars+'" src="'+movie+'" quality="high" bgcolor="" wmode="transparent" width="'+width+'" height="'+height+'" name="'+id+'" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"></embed></object>';
	document.write(s);
}


function checkRClickYN(isRClickNotAllowed,isAdmin){
	if(isRClickNotAllowed && !isAdmin){
		document.oncontextmenu = new Function ("return false");
		document.ondragstart = new Function ("return false");
		document.onselectstart = new Function ("return false"); 
	}
}


//miniwini ´äº¯¸ðµå
var g_bRe = false;
var g_nOrg;
var g_nDepth;
function checkComment(f){
	if (g_bRe && g_nOrg > 0 && g_nDepth > 0){
		if(g_nDepth>10){
			alert("´õÀÌ»ó ÇÏÀ§ ´ñ±ÛÀ» Ãß°¡ÇÒ ¼ö ¾ø½À´Ï´Ù.\n\n¼±ÅÃÇÑ ´äº¯ ¸ðµå¸¦ ÇØÁ¦ÇÏ¿© ÁÖ½Ê½Ã¿ä.(±ôºýÀÌ´Â Reply ¹öÆ°À» Å¬¸¯ÇÏ¿© ÁÖ¼¼¿ä.)");
			return false;
		}
		f.memo.value = "<!--"+g_nOrg+"|"+g_nDepth+"-->"+f.memo.value;
	}
	f.submit();
	return;
}


function reComment(nOrg,nDepth,f,img){
	var imgName = document.getElementById(img);
	if(g_nOrg==nOrg && g_nDepth==nDepth){
		g_nOrg = 0;
		g_nDepth = 0;
		g_bRe = false;
		alert("´äº¯ ¸ðµå¸¦ ÇØÁ¦ÇÕ´Ï´Ù.");
		imgName.src = baseUrl + "/img/btn_s_reply.gif";
	}else{
		if(g_bRe==true){
			alert("ÀÌ¹Ì ´äº¯ ¸ðµå°¡ È°¼ºÈ­µÇ¾î ÀÖ½À´Ï´Ù.\n\n¼±ÅÃÇÑ ´äº¯ ¸ðµå¸¦ ÇØÁ¦ÇÏ¿©¾ß ÇÕ´Ï´Ù.(±ôºýÀÌ´Â Reply ¹öÆ°À» Å¬¸¯ÇÏ¿© ÁÖ¼¼¿ä.)");
		}else{
			g_nOrg = nOrg;
			g_nDepth = nDepth;
			g_bRe = true;
			alert("´äº¯ ¸ðµå·Î ¼³Á¤ÇÕ´Ï´Ù.");
			imgName.src = baseUrl + "/img/btn_s_re_reply.gif";
			document.getElementById(f).memo.focus();
		}
	}
}







//¾ÆÀÌµð(·¹ÀÌ¾î), Æû name, ÀÌµ¿ url, ÀüÃ¼ ·¹ÀÌ¾î È°¼ºÈ­ true
function view_cover(id, formid, nurl, divtype, cover)
{
	if(!id) id = "loginTable";
	if(!divtype) divtype = true;
	if(!cover) cover = true;

	if(cover == true) {
		if(!top.document.getElementById('div_cover')){
			create_cover();
		}else{
			top.document.getElementById('div_cover').style.width = '100%';

			if(top.document.body.clientHeight > top.document.body.scrollHeight) top.document.getElementById('div_cover').style.height = '100%';
			else top.document.getElementById('div_cover').style.height = top.document.body.scrollHeight;
			top.document.getElementById('div_cover').style.display = 'block';
		}
	}else {
		create_cover2();
	}

	var w = parseInt(top.document.getElementById(id).style.width);
	var h = parseInt(top.document.getElementById(id).style.height);
	var window_left = (top.document.body.clientWidth-w)/2;
	var window_top = (top.document.body.clientHeight-h)/2;
	this.Lw = h/2;

	if(id) {
		this.Lid = id;
		top.document.getElementById(id).style.display = '';
		top.document.getElementById(id).style.top = window_top;
		top.document.getElementById(id).style.left = window_left;
		if(divtype == true) CheckUIElements();
	}
	
	if(formid) top.document.getElementById('formid').value = formid;
	if(nurl) top.document.getElementById('nurl').value = nurl;

	//return true;
}


function view_cover2(id, formid, nurl, divtype, cover)
{
	if(!id) id = "layer_info_box";
	if(!divtype) divtype = true;
	if(!cover) cover = true;

	if(cover == true) {
		if(!top.document.getElementById('div_cover')){
			create_cover();
		}else{
			top.document.getElementById('div_cover').style.width = '100%';

			if(top.document.body.clientHeight > top.document.body.scrollHeight) top.document.getElementById('div_cover').style.height = '100%';
			else top.document.getElementById('div_cover').style.height = top.document.body.scrollHeight;
			top.document.getElementById('div_cover').style.display = 'block';
		}
	}else {
		create_cover2();
	}

	var w = parseInt(top.document.getElementById(id).style.width);
	var h = parseInt(top.document.getElementById(id).style.height);
	var window_left = (top.document.body.clientWidth-w)/2;
	var window_top = (top.document.body.clientHeight-h)/2;
	this.Lw = h/2;

	if(id) {
		this.Lid = id;
		top.document.getElementById(id).style.display = '';
		top.document.getElementById(id).style.top = window_top;
		top.document.getElementById(id).style.left = window_left;
		if(divtype == true) CheckUIElements();
	}
	
	//if(formid) top.document.getElementById('formid').value = formid;
	if(nurl) top.document.getElementById('nurl').value = nurl;

	//return true;
}

function CheckUIElements() 
{
    var yMenuFrom, yMenuTo, yButtonFrom, yButtonTo, yOffset, timeoutNextCheck;

    yMenuFrom   = parseInt (top.document.getElementById(this.Lid).style.top, 10);
    if ( window.document.layers ) 
        yMenuTo = top.pageYOffset + 0;
    else if ( window.document.getElementById ) 
        yMenuTo = top.document.body.scrollTop + parseInt('0');

    timeoutNextCheck = 500;

    if ( Math.abs (yButtonFrom - (yMenuTo + 152)) < 6 && yButtonTo < yButtonFrom )
     {
        setTimeout ("CheckUIElements()", timeoutNextCheck);
        return;
    }

    if ( yMenuFrom != yMenuTo )
    {
        yOffset = Math.ceil( Math.abs( yMenuTo - yMenuFrom ) / 10 );
        if ( yMenuTo < yMenuFrom )
            yOffset = -yOffset;

        top.document.getElementById(this.Lid).style.top = (parseInt(top.document.getElementById(this.Lid).style.top) + yOffset) + 20;

        timeoutNextCheck = 10;
    }

    setTimeout ("CheckUIElements()", timeoutNextCheck);
}

function cover_off(id){
	if(top.document.getElementById('div_cover')) top.document.getElementById('div_cover').style.display = 'none';
	if(id) top.document.getElementById(id).style.display = 'none';
}

function create_cover(){

	var color = '#FFFFFF';
	var opacity = '70';

	var cover_div = top.document.createElement('div');
	cover_div.style.position = 'absolute';
	cover_div.style.top = '0px';
	cover_div.style.left = '0px';
	cover_div.style.width = '100%';
	cover_div.style.zIndex = 1;
	if(top.document.body.offsetHeight > top.document.body.scrollHeight) cover_div.style.height = '100%';
	else cover_div.style.height = top.document.body.scrollHeight;
	cover_div.style.backgroundColor = color;
	cover_div.style.filter = 'alpha(opacity='+opacity+')';
	cover_div.id = 'div_cover';
	top.document.body.appendChild(cover_div);
}

function create_cover2(){

	var color = '#FFFFFF';
	var opacity = '0';

	var cover_div = top.document.createElement('div');
	cover_div.style.position = 'absolute';
	cover_div.style.top = '0px';
	cover_div.style.left = '0px';
	cover_div.style.width = '100%';
	cover_div.style.zIndex = 1;
	if(top.document.body.offsetHeight > top.document.body.scrollHeight) cover_div.style.height = '100%';
	else cover_div.style.height = top.document.body.scrollHeight;
	cover_div.style.backgroundColor = color;
	cover_div.style.filter = 'alpha(opacity='+opacity+')';
	cover_div.id = 'div_cover';
	top.document.body.appendChild(cover_div);
}