// common.js ------------------------------------------------------------------
(function(){
    /*Use Object Detection to detect IE6*/
    var  m = document.uniqueID /*IE*/
    && document.compatMode  /*>=IE6*/
    && !window.XMLHttpRequest /*<=IE6*/
    && document.execCommand ;

    try{
        if(!!m){
            m("BackgroundImageCache", false, true) /* = IE6 only */
        }
    }catch(oh){};
})();
window.name = 'NKsearch';


/*Åä±Û*/
function toggleLay(hiddenLay,showLay){
    if (hiddenLay == showLay){
        if (document.getElementById(hiddenLay).style.display == 'none')
        {
            document.getElementById(hiddenLay).style.display = 'block';
        }else if (document.getElementById(hiddenLay).style.display == 'block')
        {
            document.getElementById(hiddenLay).style.display = 'none';
        }
    }else{
        if (hiddenLay != '')
        {
            document.getElementById(hiddenLay).style.display = 'none';
        }
        if (showLay != '')
        {
            document.getElementById(showLay).style.display = 'block';
        }
    }
}

function hLay(name){
 document.getElementById(name).style.display='none';
}
function sLay(name){
 document.getElementById(name).style.display='block';
}

/*¿ÞÂÊ¸Þ´ºÀÌ¹ÌÁö on || off */
function lmChg(obj,idx,val,tIdx){
    if (tIdx != 3){
        if (val ==1){
         obj.src = 'http://imgsrc.search.daum-img.net/knowledge4/ca'+tIdx+'_'+idx+'_on.gif';
        }else{
         obj.src = 'http://imgsrc.search.daum-img.net/knowledge4/ca'+tIdx+'_'+idx+'.gif';
        }
    }else if(tIdx == 3){
        if (val ==1){
            obj.src = 'http://imgsrc.search.daum-img.net/knowledge4/ca1_all_on.gif';
        }else{
            obj.src = 'http://imgsrc.search.daum-img.net/knowledge4/ca1_all.gif';
        }
    }
}

/********* paging ********/
function daum_paging_rollover(obj, img, type) {
    var imgurl = "http://image.daum-img.net/hanmail/2006_ui/";
    var tmp
    if (type == "on") {
        obj.src = imgurl + img + "_over.gif";
    } else {
        obj.src = imgurl + img + ".gif";
    }
}

/** µ¿Àû Flash »ðÀÔ tag »ý¼º script */
function DaumFlash(src,fv,width,height,div) {
    var obj = new Object();
    obj.type = 'application/x-shockwave-flash';
    obj.classid = 'clsid:d27cdb6e-ae6d-11cf-96b8-444553540000';
    obj.codebase = 'http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0';
    obj.width = width;
    obj.height = height;

    var param = [
        ['movie',src],
        ['src',src],
        ['quality','high'],
        ['wmode','transparent'],
        ['allowScriptAccess','always'],
        ['bgcolor','#FFFFFF'],
        ['FlashVars',fv]
    ];
    obj.param = param;
    daumActiveX(obj,div);
}

function getNavi(){
    if(navigator.appName == "Microsoft Internet Explorer")
        return 1;
    else if(navigator.appName == "Netscape")
        return 2;
    else
        return 0;
}


/** »ó¼¼º¸±â +/- ¹öÆ° toggle Ã³¸® */
function togNK(obj,name){
    if (document.getElementById(name).style.display == 'none'){
        obj.src='http://imgsrc.search.daum-img.net/knowledge4/btn_qna_close.gif';
        document.getElementById(name).style.display = 'block';
    }else{
        obj.src='http://imgsrc.search.daum-img.net/knowledge4/btn_qna_open.gif';
        document.getElementById(name).style.display = 'none';
    }
}

function layCatelOver(obj,val){
    if (val==0){
        obj.style.background = '#ffffff';
    }else if (val==1){
        obj.style.background = '#f2f2f2';
    }
}

function showCateLay(objName){
    var disp = document.getElementById(objName).style.display;
    if (disp == 'none'){
        document.getElementById(objName).style.display = 'block';
    }else if (disp == 'block'){
        document.getElementById(objName).style.display = 'none';
    }
}

function cChg(obj,cName){
    obj.className = cName;
}

function rtChg(idx){
    if (idx ==1){
     document.getElementById('rRankTab1').src = 'http://imgsrc.search.daum-img.net/knowledge4/r_rank1_tap3_on.gif';
     document.getElementById('rRankTab2').src = 'http://imgsrc.search.daum-img.net/knowledge4/r_rank1_tap5.gif';
     toggleLay('rRankList2','rRankList1');
    }else if(idx == 2){
     document.getElementById('rRankTab2').src = 'http://imgsrc.search.daum-img.net/knowledge4/r_rank1_tap5_on.gif';
     document.getElementById('rRankTab1').src = 'http://imgsrc.search.daum-img.net/knowledge4/r_rank1_tap3.gif';
     toggleLay('rRankList1','rRankList2');
    }else if (idx ==3){
     document.getElementById('rRankTab1').src = 'http://imgsrc.search.daum-img.net/knowledge4/r_rank1_tap3_on.gif';
     document.getElementById('rRankTab2').src = 'http://imgsrc.search.daum-img.net/knowledge4/r_rank1_tap4.gif';
     toggleLay('rRankList2','rRankList1');
    }else if(idx == 4){
     document.getElementById('rRankTab2').src = 'http://imgsrc.search.daum-img.net/knowledge4/r_rank1_tap4_on.gif';
     document.getElementById('rRankTab1').src = 'http://imgsrc.search.daum-img.net/knowledge4/r_rank1_tap3.gif';
     toggleLay('rRankList1','rRankList2');
    }
}

// ±ÛÀÚ¼ö Á¦ÇÑ
String.prototype.byteLength = function() {
    var byteSize = 0;
    for (var i = 0; i < this.length; i++) {
        val = escape(this.charAt(i)).length;
        if (val == 6) byteSize++;
        byteSize++;
    }
    return byteSize;
}

// ÀüÈÄ °ø¹é Á¦°Å
String.prototype.trim = function() {
    return this.replace(/(^\s*)|(\s*$)/g, '');
}

String.prototype.isEmpty = function() {
    return (this.trim() == '');
}

var EmailAddress = Class.create();
EmailAddress.prototype = {
    value: "",
    initialize: function(sAddr, sHost) {
        if (arguments.length == 2) {
            this.setUserAndHost(sAddr, sHost)
        }
        else {
            this.setValue(sAddr);
        }
    },
    validate: function() {
        var emailRegExp  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
        if (emailRegExp.test(this.value) == false) {
            throw "Invalid Email Format";
        }
    },
    isValid: function() {
        try {
            this.validate();
            return true;
        } catch (e) {
            return false;
        }
    },
    setUserAndHost: function(user, host) {
        if (!user.isEmpty() && !host.isEmpty()) {
            this.setValue(user + "@" + host);
        } else {
            this.setValue('');
        }
    },
    setValue: function(value) {
        this.value = value;
    },
    toString: function() {
        return this.value;
    }
}

// ¼¼ÀÚ¸®¸¶´Ù ',' ±âÈ£¸¦ ³Ö´Â´Ù.
function toMoneyExp(digit) {
    var digitstr = digit + "";
    var retstr = "";
    for (var i = digitstr.length - 1, j = 0; i >= 0; i--, j++) {
        if (j != 0 && j %3 == 0) retstr = "," + retstr;
        retstr = digitstr.charAt(i) + retstr;
    }
    return retstr;
}

function updateChar(textobject, spanname, length_limit)
{
    var msg = textobject.value;
    var length = msg.byteLength();

    if (spanname != '') {

        document.getElementById(spanname).innerHTML = toMoneyExp(length);
    }
    if (length > length_limit) {
        alert("ÃÖ´ë " + length_limit + "byteÀÌ¹Ç·Î ÃÊ°úµÈ ±ÛÀÚ¼ö´Â ÀÚµ¿À¸·Î »èÁ¦µË´Ï´Ù.");
        textobject.value = textobject.value.replace(/\r\n$/, "");
        textobject.value = assert_msglen(textobject.value, length_limit, spanname);
    }
}

function assert_msglen(message, maximum, spanname)
{
    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;
    }
    if (spanname != '') {
        document.getElementById(spanname).innerHTML = toMoneyExp(nbytes);
    }
    return msg;
}


/** °ü·ÃÅ°¿öµå ½ºÅ©·Ñ Ã³¸®¸¦ À§ÇÑ function */
var checkMCpos = function(alter){
    this.obj = document.getElementById('MrecomCate');//¹Ú½º
    this.rightH = document.getElementById('right' + ((alter != undefined) ? alter : '')).scrollHeight;//right³ôÀÌ
    this.Tspc = 0;	//½ºÆäÀÌ½º
    this.time= 10;//setTimeout½Ã°£
    this.maxHeight = document.getElementById('body_middle' + ((alter != undefined) ? alter : '')).scrollHeight;//ÃÖ´ë³ôÀÌ

    //this.clientH = document.body.clientHeight;
    this.boxH = this.obj.scrollHeight;//¹Ú½ºÀÇ ³ôÀÌ°ª

    this.vav = function(){
        this.sclT = document.body.scrollTop;//È­¸é½ºÅ©·ÑµÈ °ª
        this.totTopV = this.sclT+ (this.boxH-this.Tspc) ;//¹Ú½º ³ôÀÌ Æ÷Áö¼Ç°ª
        this.objFrom = parseInt(this.obj.style.top, 10);

        if (this.rightH+this.Tspc >= this.totTopV){
            this.totTopV = this.rightH+this.Tspc-20;//¸ÇÀ§
        }else if (this.maxHeight < this.totTopV){
            this.totTopV = this.maxHeight-this.Tspc;//¸Ç¾Æ·¡
        }


        if ((this.rightH+this.Tspc >= this.objFrom) && (this.rightH+this.Tspc == this.totTopV)){
            this.obj.style.top = this.rightH+this.Tspc;//¸ÇÀ§
        }else if (this.maxHeight < this.objFrom){
            this.obj.style.top = this.maxHeight-(this.Tspc*2);//¸Ç¾Æ·¡
        }else{
            if (this.objFrom != this.totTopV){
                this.yOffset = Math.ceil(Math.abs( this.totTopV - this.objFrom ) / 20);
                if (this.totTopV < this.objFrom)
                    this.yOffset = -(this.yOffset-1);
                this.obj.style.top = parseInt(this.obj.style.top, 10) + this.yOffset;
            }else{
                this.obj.style.top = this.totTopV;
            }
        }
        if (getNavi() == 2){
            this.time = 1;
        }
//		document.getElementById('jtmjtm').innerHTML = this.obj.style.top;
        setTimeout("aada.vav()", this.time);
    }

    this.obj.style.top = this.rightH;//¸ÇÀ§
}
// End common.js --------------------------------------------------------------


/** templating ½Ã string concatÀÇ ¼º´É ÀúÇÏ¸¦ ÇÇÇÏ±â À§ÇÑ ¹æ¾ÈÀ¸·Î »ç¿ëµÇ´Â function */
var totalHtml = function(){
    this.html = new Array();

    this.inHtml = function(ihtml){
        this.html[this.html.length] = ihtml;
    }

    this.outHtml = function(objId,clr){
        if (!(!(clr)))	{
            this.html[this.html.length] = '<br class="clr" />';
        }
        document.getElementById(objId).innerHTML = this.html.join('');
    }
}

// sindong.js -----------------------------------------------------------------
/* Å¾½ºÅ©·Ñ*/
var oList = new Array();

var tProVar = function(){
    this.text = new Array();
    this.img = new Array();
    this.link = new Array();
    this.recom = new Array();
    this.date = new Array();
    this.nickname = new Array();
    this.ihtml = new Array();

    this.insVal = function(textV,imgV,linkV,recomV,dateV, nickV){
        this.text[this.text.length] = textV;
        this.img[this.img.length] = imgV;
        this.link[this.link.length] = linkV;
        this.recom[this.recom.length] = recomV;
        this.date[this.date.length] = dateV;
        this.nickname[this.nickname.length] = nickV;
    }

    this.sHtml = function() {
        this.ihtml[this.ihtml.length] = '<ul>';
        for (i =0 ;i<this.text.length ;i++ ) {
            this.ihtml[this.ihtml.length] = '<li><dl>';
            this.ihtml[this.ihtml.length] = '<dd class="img">';
            this.ihtml[this.ihtml.length] = '<a href="'+this.link[i]+'" onFocus="this.blur();" onclick="javascript:gLink(null, \'W2KS\', \'1\', \'1\');"><img src="'+this.img[i]+'" width="116" height="91" alt="" /></a>';
            this.ihtml[this.ihtml.length] = '<div class="playBtn"><a href="'+this.link[i]+'" onFocus="this.blur();" onclick="javascript:gLink(null, \'W2KS\', \'1\', \'1\');" class="iconPlay">play</a></div>';
            this.ihtml[this.ihtml.length] = '</dd>';
            this.ihtml[this.ihtml.length] = '<dd class="tit"><a href="'+this.link[i]+'" onclick="javascript:gLink(null, \'W2KS\', \'1\', \'2\');">'+this.text[i]+'</a></dd>';
            this.ihtml[this.ihtml.length] = '<dd class="text">'+this.date[i]+' <span class="bar">|</span>'+this.nickname[i]+'</dd>';
    //        this.ihtml[this.ihtml.length] = '<dd class="text"><img src="http://imgsrc.search.daum-img.net/knowledge4/icon_up.gif" width="11" height="13" alt=""  class="valign1"/> <b class="bR11_4">'+this.recom[i]+'</b> <span class="bar">|</span> '+this.date[i]+'</dd>';
            this.ihtml[this.ihtml.length] = '</dl>';
            this.ihtml[this.ihtml.length] = '<div class="wImg"><a href="'+this.link[i]+'" onFocus="this.blur();" onclick="javascript:gLink(null, \'W2KS\', \'1\', \'1\');"><img src="http://imgsrc.search.daum-img.net/knowledge4/sin_top_icon_wow.gif" width="42" height="42" alt=""/></div></li>';
        }
        this.ihtml[this.ihtml.length] = '</ul>';
        oList[oList.length] = this.ihtml.join('');
        return this.ihtml.join('');
    }
}
// End sindong.js -------------------------------------------------------------

// top.js ---------------------------------------------------------------------
/* Å¾½ºÅ©·Ñ*/
var oList = new Array();

var tpScr = function(obj){
    this.idx = 0;
    this.scrollsize = 609;
    this.scrObj = $(obj);
    if (!(!(this.scrObj))){
        this.scrObj.style.left = -this.scrollsize +'px';
    }

}
    tpScr.prototype.scrollL = function(){

        for (i =0 ; i <= this.scrollsize ; i++){
             setTimeout("ttp.scroll(-1);",i/1.5 );
            }
        this.scrObj.style.left = -this.scrollsize +'px';

        if (this.idx == 2){
            this.idx =0;
        }else{
            this.idx++;
        }

        if(this.idx ==0){
            this.scrObj.innerHTML = oList[1]+oList[2]+oList[0];
        }
        else if(this.idx == 1){
            this.scrObj.innerHTML = oList[2]+oList[0]+oList[1];
        }
        else if(this.idx ==2){
            this.scrObj.innerHTML = oList[0]+oList[1]+oList[2];
        }
    }

    tpScr.prototype.scrollR = function(){
        for (i =0 ; i <= this.scrollsize ; i++){
         setTimeout("ttp.scroll(1);",i/1.5 );
        }
        this.scrObj.style.left = -this.scrollsize +'px';

        if(this.idx == 0){
            this.idx = 2;
        }else{
            this.idx--;
        }

        if(this.idx ==0){
            this.scrObj.innerHTML = oList[0]+oList[1]+oList[2];
        }
        else if(this.idx == 1){
            this.scrObj.innerHTML = oList[1]+oList[2]+oList[0];
        }
        else if(this.idx ==2){
            this.scrObj.innerHTML = oList[2]+oList[0]+oList[1];
        }

    }
    tpScr.prototype.scroll = function(val){
        this.scrObj.style.left = (parseInt(this.scrObj.style.left)+val) + 'px';
    }


/*¿ÞÂÊÅÇ */
function lmtChg(idx){
    if (idx ==1){
     document.getElementById('lmTab1').src = 'http://imgsrc.search.daum-img.net/knowledge4/ca1_tap1_on.gif';
     document.getElementById('lmTab2').src = 'http://imgsrc.search.daum-img.net/knowledge4/ca1_tap2.gif';
     toggleLay('lCate_dl2','lCate_dl1');
    }else if(idx == 2){
     document.getElementById('lmTab2').src = 'http://imgsrc.search.daum-img.net/knowledge4/ca1_tap2_on.gif';
     document.getElementById('lmTab1').src = 'http://imgsrc.search.daum-img.net/knowledge4/ca1_tap1.gif';
     toggleLay('lCate_dl1','lCate_dl2');
    }
}

function rmtChg(idx){
    if (idx ==1){
     document.getElementById('rRankTab1').src = 'http://imgsrc.search.daum-img.net/knowledge4/r_rank1_tap1_on.gif';
     document.getElementById('rRankTab2').src = 'http://imgsrc.search.daum-img.net/knowledge4/r_rank1_tap6.gif';
     toggleLay('rRankList2','rRankList1');
    }else if(idx == 2){
     document.getElementById('rRankTab2').src = 'http://imgsrc.search.daum-img.net/knowledge4/r_rank1_tap6_on.gif';
     document.getElementById('rRankTab1').src = 'http://imgsrc.search.daum-img.net/knowledge4/r_rank1_tap1.gif';
     toggleLay('rRankList1','rRankList2');
    }
}

function chgTpro(val){
document.getElementById('topProR').style.backgroundImage= 'url(http://imgsrc.search.daum-img.net/knowledge4/top_q_ovbg'+val+'.gif)';
    for (i =1;i<=4 ;i++ ){
        if (val==i){
            document.getElementById('topProL'+i).style.display = 'block';
            $('topProR00'+i).style.fontWeight = 'bold';
            $('topProR00'+i).style.letterSpacing = '-1px';
        }else{
            document.getElementById('topProL'+i).style.display = 'none';
            $('topProR00'+i).style.fontWeight = 'normal';
            $('topProR00'+i).style.letterSpacing = '0';
        }
    }
}
// End top.js -----------------------------------------------------------------

//°øÅëÆË¾÷ (qna3.js depends)
function openPopWindow(szURL, szTarget, iWidth, iHeight, scrollable, resizable, returnwin) {
    var argv = openPopWindow.arguments;
    if (scrollable == undefined) scrollable = "no";
    if (resizable == undefined) resizable = "no";

    openWindow = window.open(szURL, szTarget, 'width=' + iWidth + ',height=' + iHeight + ',resizable=' + resizable + ',scrollbars=' + scrollable + ' ');
    //openWindow.focus();

    if (returnwin != undefined && returnwin == true) {
        return openWindow;
    }
}
//ºê¶ó¿ìÁ® Á¾·ù¿¡ µû¸¥ popup ³ôÀÌ Á¶Á¤
function popup(url, wndName, width, height, scrollable, resizable) {
    if (scrollable == undefined) scrollable = "no";
    if (resizable == undefined) resizable = "no";

    return openPopWindow(url, wndName, parseInt(width), parseInt(height) + getAdditionalWindowBorderHeight(), scrollable, resizable);
}

function getAdditionalWindowBorderHeight() {
    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;
    }
    return h;
}

function levelHelpPopup(url) {
    popup(url, 'qna_level_info', 710, 740, 'yes', 'yes');
}
function printPopup(url) {
    popup(url, 'qna_member_info', 781, 800, 'yes', 'yes');
}

function goMustLogin(message) {
    if (message == undefined || message.trim() == "") {
        message = "·Î±×ÀÎ ÈÄ »ç¿ëÇÏ½Ç ¼ö ÀÖ½À´Ï´Ù. ·Î±×ÀÎ ÇÏ½Ã°Ú½À´Ï±î?";
    }
    if (confirm(message)) {
        var prevUrl = encodeURIComponent(document.location.href);
        document.location.href = "http://www.daum.net/Mail-bin/login.html?category=qna&url=" + prevUrl;
    }
}
function goMustJoin(message) {
    if (message == undefined || message.trim() == "") {
        message = "½ÅÁö½Ä È¸¿ø °¡ÀÔ ÈÄ »ç¿ëÇÏ½Ç ¼ö ÀÖ½À´Ï´Ù. °¡ÀÔ ÇÏ½Ã°Ú½À´Ï±î?";
    }
    if (confirm(message)) {
        var prevUrl = encodeURIComponent(document.location.href);
        document.location.href = "/qna/sign_up.html?returnUrl=" + prevUrl;
    }
}
function goCafeLogin(message) {
    if (message == undefined || message.trim() == "") {
        message = "·Î±×ÀÎ ÈÄ »ç¿ëÇÏ½Ç ¼ö ÀÖ½À´Ï´Ù. ·Î±×ÀÎ ÇÏ½Ã°Ú½À´Ï±î?";
    }
    if (confirm(message)) {
        prevUrl = top.down.location.href;
        top.down.location.href = "http://www.daum.net/Mail-bin/login.html?category=qna&url=" + URLencode(prevUrl);
    }
}
function openLoginAndJoinPopup(objId) {
    openLoginAndMoveTarget(document.location.href + ((objId != undefined) ? '&focus_on=' + objId : ''));
}
function openLoginAndComplainPopup(type, objId) {
    openLoginAndMoveTarget("javascript:complain(" + type + ", \"" + objId + "\")");
}
function openLoginAndMoveTarget(target) {
    popup('/qna/sign_up.html?theme=popup&pass_through=true&returnUrl=' + encodeURIComponent(target), 'hwdSignUp', '400', '245', 'no', 'yes');
}
function openTexticonHelpWindow() {
    popup('/qna/texticon_help.html', 'hwdTexticonHelp', '630', '490', 'no', 'yes');
}
function goIdentifyService(urlEscapedCurrentUrl) {
    var url = "https://user.daum.net/checkidentity/check.daum?svcCode=SpVlCMkyBiw0&rtnURL=" + urlEscapedCurrentUrl;
    document.location.href = url;
}


function URLencode(sStr) {
    return escape(sStr).replace(/\+/g, '%2C').replace(/\"/g,'%22').replace(/\'/g, '%27');
}

function daumActiveX(obj,div){
    // generate html code
    // for ie obejct
    var html = '<object ';
    if (!obj.id && !obj.name){
        var r = Math.round(Math.random()*100);
        html += 'id="daumActiveXObject'+r+'" name="daumActiveXObject'+r+'" ';
    } else {
        if (obj.id) html += 'id="'+obj.id+'" ';
        else html += 'id="'+obj.name+'" ';
        if (obj.name) html += 'name="'+obj.name+'" ';
        else html += 'name="'+obj.id+'" ';
    }
    if (obj.type) html += 'type="'+obj.type+'" ';
    if (obj.classid) html += 'classid="'+obj.classid+'" ';
    if (obj.width) html += 'width="'+obj.width+'" ';
    if (obj.height) html += 'height="'+obj.height+'" ';
    if (obj.codebase) html += 'codebase="'+obj.codebase+'" ';
    // append events
    for (var i in obj.events){
        if (obj.events[i]){
            html += obj.events[i][0]+'="'+obj.events[i][1]+'" ';
        }
    }
    // end of object tag
    html += '>\n';
    // append params
    for (var i in obj.param){
        if (typeof(obj.param[i][0]) != 'undefined') {
            html += '<param name="'+obj.param[i][0]+'" value="'+obj.param[i][1]+'"/>\n';
        }
    }

    // for ns embed
    html += '<embed ';
    if (!obj.id && !obj.name){
        var r = Math.round(Math.random()*100);
        html += 'id="daumActiveXObject'+r+'" name="daumActiveXObject'+r+'" ';
    } else {
        if (obj.id) html += 'id="'+obj.id+'" ';
        if (obj.name) html += 'name="'+obj.name+'" ';
        else html += 'name="'+obj.id+'" ';
    }
    if (obj.type) html += 'type="'+obj.type+'" ';
    if (obj.width) html += 'width="'+obj.width+'" ';
    if (obj.height) html += 'height="'+obj.height+'" ';
    // append params
    for (var i in obj.param){
        if (obj.param[i]){
            if (obj.param[i][0]=='movie' || obj.param[i][0]=='src'){
                var _src = obj.param[i][1];
            }
            html += obj.param[i][0]+'="'+obj.param[i][1]+'" ';
        }
    }
    html += '/>\n';

    html += '</object>';

    var isIE = (document.all)?true:false;
    if (isIE){
        document.getElementById(div).innerHTML = html;
    } else if (obj.type=='application/x-shockwave-flash' || obj.classid=='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000'){
        // ie¿ÜÀÇ ºê¶ó¿ìÀú¿¡¼­ activex°¡ flashÀÎ °æ¿ì¸¸ ³ëÃâ
        document.getElementById(div).innerHTML = html;
    }
}

function resizePopup(iWidth, iHeight) {
    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(iWidth, iHeight + h);
}


function onErrorLoadingImage(imageObject) {
    imageObject.alt = 'º» ÀÌ¹ÌÁö´Â ¸µÅ© URLÀÌ Àß¸ø ÁöÁ¤µÇ¾î Ç¥½ÃµÇÁö ¾Ê½À´Ï´Ù.'
    imageObject.title = imageObject.alt
    imageObject.style.width = '58px';
    imageObject.style.height = '51px';
    imageObject.src = 'http://imgsrc.search.daum-img.net/knowledge4/no_img.gif'
}

// -------------------------------------------------------------------------
// prototype
// -------------------------------------------------------------------------
String.prototype.hasText = function() {
    return (this.trim() != '');
}


// -------------------------------------------------------------------------
// utility
// -------------------------------------------------------------------------
// ÆÄÀÏ¸í¿¡¼­ È®ÀåÀÚ¸¦ ±¸ÇÑ´Ù.
function getFileExt(filename) {
    var cuttingPosition = filename.lastIndexOf('.');
    if (cuttingPosition > 0) {
        return filename.substr(cuttingPosition + 1).toLowerCase();
    } else {
        return '';
    }
}

function resetTextFormObject(obj, defaultValue) {
    if (obj.value == defaultValue) {
        obj.value = '';
    }
}

/**
 * »ó¼¼º¸±â > ºÎ°¡Á¤º¸ Ç¥½Ã °ü·Ã library
 * prototype 1.40 required
 */
AddInfo = {};
AddInfo.Base = Class.create();
AddInfo.Base.prototype = {
    initialize: function(url, handler, targetLayerId) {
        this.url = url;
        this.handler = handler;
        this.targetLayerId = targetLayerId;
        //this.run();
    },
    run: function() {
        // Ajax.Request¿¡¼­ È£ÃâµÇ´Â handleRequest°¡
        // AddInfo.*¿¡ bind µÇÁö ¾ÊÀ¸¹Ç·Î ÀÌ¸¦ °­Á¦ bindÇÑ´Ù.
        if (typeof this.handleRequest != 'undefined') {
            this.handleRequest = this.handleRequest.bind(this);
        }
        var ajax = new Ajax.Request(
            this.url, { method: 'get', onSuccess: this.handleRequest, handler: this.handler }
        );
    }
}
AddInfo.Json = Class.create();
AddInfo.Json.prototype = Object.extend(new AddInfo.Base(), {
    handleRequest: function(orgReq) {
        var obj = eval('(' + orgReq.responseText + ')');
        str = this.handler(obj);
        try { new Insertion.Bottom(this.targetLayerId, str); } catch (e) { }
    }
});
AddInfo.Html = Class.create();
AddInfo.Html.prototype = Object.extend(new AddInfo.Base(), {
    handleRequest: function(orgReq) {
        var str =  orgReq.responseText;
        if (typeof(this.handler) != 'undefined' && this.handler != null) { this.handler(str); }
        new Insertion.Bottom(this.targetLayerId, str);
        try { onCafeLoadReSize(); } catch (e) { } // cafe iframe resize
    }
});

// ±îÆä°Ô½ÃÆÇ ¾Ë¸®¹Ì Á¤º¸Ç¥½Ã (Ajax ¹æ½Ä)
// TODO

// Àý´ë ³ôÀÌ °è»ê
function getAbsoluteTop(oNode){
    var oCurrentNode=oNode;
    var iTop=0;
    while(oCurrentNode.tagName!="BODY"){
        iTop+=oCurrentNode.offsetTop;
        oCurrentNode=oCurrentNode.offsetParent;
    }
    return iTop;
}
// Àý´ë ÁÂÃø °è»ê
function getAbsoluteLeft(oNode){
    var oCurrentNode=oNode;
    var iLeft=0;
    while(oCurrentNode.tagName!="BODY"){
        iLeft+=oCurrentNode.offsetLeft;
        oCurrentNode=oCurrentNode.offsetParent;
    }
    return iLeft;
}

/* ÁÙ¹Ù²Þ ¹®ÀÚ¸¦ <br /> ÅÂ±×·Î º¯È¯ÇÑ´Ù. */
function lineFeedToBreak(str){
    var replaceWith = '<br/>';
    str = escape(str);
    for (var i = 0; i< str.length; i++) {
        if (str.indexOf("%0D%0A") > -1){
            str = str.replace("%0D%0A", replaceWith)
        } else if (str.indexOf("%0A") > -1){
            str = str.replace("%0A", replaceWith)
        } else if (str.indexOf("%0D") > -1){
            str = str.replace("%0D", replaceWith)
        }
    }
    str = unescape(str)
    return str;
}
/*
 * enter key ÀÔ·ÂÀÌ ¹ß»ý½Ã false ¸¦ ¸®ÅÏÇÑ´Ù.
 * onkeypress event¿¡ binding½Ã¿¡ enter ÀÔ·ÂÀ» Á¦ÇÑÇÏ´Â È¿°ú¸¦
 * º¼ ¼ö ÀÖ´Ù.
 */
function blockEnter(e) {
    if (!e) e = window.event;
      return !(e.keyCode == Event.KEY_RETURN);
}

/*
 * blockEnter¸¦ ÀÌ¿ëÇØ¼­ Enter ÀÔ·Â ¶§, ´Ù¸¥ µ¿ÀÛÀ¸·Î º¯°æÇÑ´Ù
 */
function interceptEnter(e, callee) {
    var result = blockEnter(e);
    if (result == false) {
        callee();
    }
    return result;
}

/*
 * IE ¿¡¼­ document.getElementById°¡ ´ë¼Ò¹®ÀÚ ±¸ºÐÇÏ±â ¸øÇÏ´Â ¹ö±× hack
 */
document._getElementById = document.getElementById;
document.getElementById = function(id) {
    var a = [];
    var o = document._getElementById(id);
    if (!o) return o;
    while (o && o.id != id) {
        a.push({i:o.id,e:o});
        o.id='';
        o = document._getElementById(id);
    }
    for (j=0,jj=a.length; j<jj; j++) a[j].e.id = a[j].i;
    a = null;
    return o;
}



var TITLE_MIN_LENGTH = 2;
var TITLE_MAX_LENGTH = 100;
var CONTENT_MIN_LENGTH = 17;
var CONTENT_MAX_LENGTH = 70 * 1000;
/** °Ô½Ã±Û Á¦¸ñ validation */
function validateTitle(titleObject) {
    titleObject.value = titleObject.value.trim();
    var titleLength = titleObject.value.byteLength();
    if (titleLength < TITLE_MIN_LENGTH || titleLength > TITLE_MAX_LENGTH ) {
        alert('±Û Á¦¸ñÀº ÇÑ±Û ' + toMoneyExp(TITLE_MIN_LENGTH / 2) + 'ÀÚ ~ ' + toMoneyExp(TITLE_MAX_LENGTH / 2) +
              'ÀÚ(¿µ¾î ' + toMoneyExp(TITLE_MIN_LENGTH) + 'ÀÚ ~ ' + toMoneyExp(TITLE_MAX_LENGTH) + 'ÀÚ) ÀÌ³»·Î ÀÔ·ÂÇÏ¿© ÁÖ¼¼¿ä.'
        );
        titleObject.focus();
        return false;
    }
    return true;
}
/** °Ô½Ã±Û ³»¿ë validation */
function validateContent(contentObject) {
    contentObject.value = contentObject.value.trim();
    var contentLength = contentObject.value.byteLength();
    if (contentLength < CONTENT_MIN_LENGTH || contentLength > CONTENT_MAX_LENGTH) {
        alert('±Û ³»¿ëÀº ÇÑ±Û 5ÀÚ ~ ' + toMoneyExp(CONTENT_MAX_LENGTH / 2) +
              'ÀÚ(¿µ¾î 10ÀÚ ~ ' + toMoneyExp(CONTENT_MAX_LENGTH) + 'ÀÚ) ÀÌ³»·Î ÀÔ·ÂÇÏ¿© ÁÖ¼¼¿ä.'
        );
        if (Editor) {
            Editor.focus();
        }
        return false;
    }
    return true;
}
/** Ã¤ÅÃÇÏ±â ¿Ï·á ÈÄ Ã³¸® */
function handleRecommendFeedback() {
    var choosedTextPosition = document.location.href.indexOf('&choosed=true');
    if (choosedTextPosition > 0) {
        growl('´äº¯À» Ã¤ÅÃÇÏ¼Ì½À´Ï´Ù.');
        return ;
    }
}

/** ½ÅÁö½Ä ³»¿¡¼­ °Ë»öÀ» ÇÏ´Â °æ¿ì */
function kinSearch(frmObj) {
    with (frmObj) {
        if (w.value == "daum_search") {
            action = "http://search.daum.net/search";
            target = "_blank";
            return false;
        } else if (w.value == "kin_file") {
            action = "/qna/file/search.html";
            target = "_self";
        } else if (w.value == "kin_video") {
            action = "/qna/sindongk/search.html";
            target = "_self";
        } else if (w.value == "kin_qna") {
            action = "/qna/qna_search.html";
            target = "_self";
        } else if (w.value == "my_answer") {
            action = "/qna/my/my_search/myAnswer.html";
            target = "_self";
        } else if (w.value == "open_knowledge") {
            action = "/qna/my/my_search/openKnowledge.html";
            target = "_self";
        } else if (w.value == "member_answer") {
            w.value = "my_answer";
            action = "/qna/member/member_search/memberAnswer.html";
            target = "_self";
        } else if (w.value == "member_open_knowledge") {
            w.value = "open_knowledge";
            action = "/qna/member/member_search/openKnowledge.html";
            target = "_self";
        } else {
            action = "/qna/search.html";
            target = "_self";
        }
    }
    return true;
}

/** ÁöÁ¤ÇÑ element ÀÌÇÏ ¸µÅ©´Â ÇöÀçÃ¢À¸·Î ¶ç¿ï ¼ö ÀÖµµ·Ï classNameÀ» º¯°æÇÑ´Ù. */
function exceptModifyLinkTarget(excepts) {
    $A(excepts).each(function (item) {
        var deleteElement = $(item);
        if (deleteElement != undefined) {
            $A(deleteElement.getElementsByTagName("a")).each(function (oLink) {
                oLink.target = "_self";
            });
        }
    });
}

var VIEW_WIDTH_MAX = 670;
/* ±Û ³»¿ë filter set */
var contentFilterRegistry = [
    /* ±Û ³»¿ëÀÇ link targetÀ» º¯°æÇÏ´Â handler */
    function (oContent) {
        exceptModifyLinkTarget(['mRankListS_ul']); // ¾ÏÁß¸ð»ö °Ô½Ã±Û : mRankListS_ul

        $A(oContent.getElementsByTagName("a")).each(function (oLink) {
            if (oLink.target != undefined && oLink.target == "_self") {
                oLink.target = "_self";
            } else {
                oLink.target = "_blank";
            }
        });
    },
    /* image resize */
    function (oContent) {
        $A(oContent.getElementsByTagName("img")).each(function (oImage) {
            if (oImage.width > VIEW_WIDTH_MAX) {
                oImage.style.height = oImage.height * (VIEW_WIDTH_MAX / oImage.width);
                oImage.style.width = VIEW_WIDTH_MAX;
                if (oImage.id == "qnaimg" || oImage.className == "tx-daum-image") {
                    // if you want using lightbox, disable below block
                    oImage.onclick = openImageViewer;
                    oImage.style.cursor = 'pointer';
                }
            }
        });
    },
    function (oContent) {
    	$A(oContent.getElementsByTagName("table")).each(function (obj) {
     		if (obj.getWidth() > VIEW_WIDTH_MAX) {
    			obj.style.width = VIEW_WIDTH_MAX;
    		}
    	});
    }
    /*, function(oContent) { implement here } */
];
function filterContents() {
    if (contentIds == undefined) return ;
    contentIds.each(function (contentId) {
        if (contentId == undefined) return ;
        contentFilterRegistry.each(function (fpFilter) {
            fpFilter($(contentId));
        });
    });
}

/* ¸ñ·Ï¿¡ µ¿¿µ»ó Æ÷ÇÔ ¿©ºÎ¸¦ Ç¥½ÃÇÑ´Ù. */
function showVideoClipIcon(qids, type, callback, host) {
    if (callback == null) {
        callback = 'hasVideoClip';
    }
    if (host == null) {
        host = "http://k.daum-img.net/qna";
    }
    var aObj = new JSONscriptRequest(
            host + '/sindongk/has_video_clip.ajax?qid=' + qids +
            '&type=' + type + '&callback=' + callback);
    aObj.buildScriptTag();
    aObj.addScriptTag();
}
/* worker */
function hasVideoClip(obj) {
    var targetIds = $H(obj).keys();
    for (var i = 0; i < targetIds.length; i++) {
        $('has_video_' + targetIds[i]).innerHTML = '' +
                '<img src="http://imgsrc.search.daum-img.net/knowledge4/btn_play.gif" ' +
                ' width="12" height="13" class="icoMV" alt="µ¿¿µ»óÀ» Æ÷ÇÔÇÑ °Ô½Ã±ÛÀÔ´Ï´Ù." /> ';
    }
}
function hasVideoClipInCafe(obj) {
    var targetIds = $H(obj).keys();
    for (var i = 0; i < targetIds.length; i++) {
        $('has_video_' + targetIds[i]).innerHTML = '' +
                '<img src="http://cafeimg.daum-img.net/cf_img2/bbs2/icon_file_movie.gif" ' +
                ' width="11" height="12" class="vam" alt="µ¿¿µ»óÀ» Æ÷ÇÔÇÑ °Ô½Ã±ÛÀÔ´Ï´Ù." /> ';
    }
}
/*¿¢½ºÆÛÆ® ¸Å´ÏÀú¿¡°Ô ¸ÞÀÏ º¸³»±â*/
function mailToExpertManager() {
    popup('/qna/rank/mail_to_expert_manager.html', 'maiL_to_expert_manager', 650, 450, 'no', 'yes');
}

/**
 * ÄÁÅÙÃ÷(HTML)¸¦ ÀÐ¾î overlay - ¹è°æÀº gray Ã³¸®, È­¸é Áß¾Ó¿¡ ·¹ÀÌ¾î¸¦
 * ¶ç¿ì´Â - ¹æ½ÄÀ» ÀÌ¿ëÇÏ¿© ³ëÃâÇÑ´Ù.
 */
var OverlayMessagePanel = {
    show: function(rawHTML, cssClassName) {
        this.showOverlayBackground();
        this.showOverlayMessage(rawHTML, cssClassName);
    },
    hide: function() {
        $('overlay').remove();
        $("overlayMessagePanel").hide();
        $("overlayMessagePanel").update("");
    },
    showOverlayBackground: function() {
        var objBody = document.getElementsByTagName("body").item(0);
        var objOverlay = document.createElement("div");
        objOverlay.setAttribute('id', 'overlay');
        objOverlay.style.display = 'none';
        objOverlay.onclick = function () { OverlayMessagePanel.hide() };
        objBody.appendChild(objOverlay);

        var pageHeight = 0;
        if (window.innerHeight && window.scrollMaxY) {
            pageHeight = window.innerHeight + window.scrollMaxY;
        }
        else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
            pageHeight = document.body.scrollHeight;
        }
        else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
            pageHeight = document.body.offsetHeight;
        }

        $('overlay').setStyle({
            position: 'absolute', top: 0, left: 0, zIndex: 90, backgroundColor: '#000',
            width: '100%',
            height: pageHeight
        });
        new Effect.Appear('overlay', { duration: 0.2, from: 0.0, to: 0.75 });
    },
    showOverlayMessage: function(rawHTML, cssClassName) {
        var panel = $("overlayMessagePanel");
        if (self.pageYOffset) {
            panel.style.left = ((self.innerWidth / 2) - 230);
            panel.style.top = self.pageYOffset + 250;
        }
        else if (document.documentElement && document.documentElement.scrollTop) {    // Explorer 6 Strict
            panel.style.left = ((document.documentElement.clientWidth / 2) - 230);
            panel.style.top = document.documentElement.scrollTop + 250;
        }
        else if (document.body) {// all other Explorers
            panel.style.left = ((document.body.clientWidth / 2) - 230);
            panel.style.top = document.body.scrollTop + 250;
        }

        panel.update(rawHTML);

        if (cssClassName != undefined) {
            panel.className = cssClassName;
        }
        new Effect.Appear(panel, { duration: 0.2 });
    }
};

function getRandomInteger(limit) {
    var ran_unrounded = Math.random() * limit;
    return Math.floor(ran_unrounded);
}

Array.prototype.random = function(n) {
    var arr = this.clone();
    if (n > this.length) return arr;
    var result = [];
    (n).times(function (i) {
        var item = arr[getRandomInteger(arr.length)];
        result.push(item);
        arr = arr.without(item);
    });
    return result;
}

function growl(message) {
    if (document.location.href.indexOf("/cafe/") > 0 || typeof(Effect) == 'undefined') {
        alert(message);
        return ;
    }
    var scrollBarWidth = 20;
    var layerWidth = 262;
    var layerHeight = 10 + 100 + 15;
    // prototype-viewport doesn't contain scrollbar width on IE
    var viewPortWidth = document.viewport.getWidth() + (Prototype.Browser.IE ? 0 : scrollBarWidth);
    var viewPortHeight = document.viewport.getHeight();
    var left = (viewPortWidth - layerWidth) / 2;
    var top = ((viewPortHeight - layerHeight) / 2) + document.viewport.getScrollOffsets().top;

    // create layer objects
    var objBody = document.getElementsByTagName("body").item(0);
    var objOverlay = document.createElement("ul");
    objOverlay.setAttribute('id', 'nSellayer');
    var objOverlayTop = document.createElement("li");
    objOverlayTop.setAttribute("id", "nATop");
    var objOverlayText = document.createElement("li");
    objOverlayText.setAttribute("id", "nAText");
    var objOverlayBottom = document.createElement("li");
    objOverlayBottom.setAttribute("id", "nABot");
    objOverlay.appendChild(objOverlayTop);
    objOverlay.appendChild(objOverlayText);
    objOverlay.appendChild(objOverlayBottom);

    // set style and assign class name for alpha effect
    $(objOverlayTop).className = ((Prototype.Browser.IE) ? 'e_' : '') + $(objOverlayTop).id;
    $(objOverlayText).className = ((Prototype.Browser.IE) ? 'e_' : '') + $(objOverlayText).id;
    $(objOverlayBottom).className = ((Prototype.Browser.IE) ? 'e_' : '') + $(objOverlayBottom).id;
    $(objOverlay).setStyle({
        'position': 'absolute', 'display': 'none', 'zIndex': 100
    });

    objBody.appendChild(objOverlay);
    objOverlayText.update(message);
    new Effect.Appear(objOverlay, { duration: 0.3, from: 0.0, to: 1.0 });
    $(objOverlay).setStyle({ 'top': top, 'left': left });

    // auto hide
    new PeriodicalExecuter(function (pe) {
        new Effect.Fade(objOverlay, { duration: 0.8 });
        pe.stop();
    }, 2);
}

/* extends dom elements methods (using prototype.js) */
var QnaDomUtils = {
    resetable: function(element, flag) {
        var obj = $(element);
        if (flag) {
            obj.DEFAULT_MESSAGE = obj.value;
            obj.onfocus = function() {
                if (this.value == this.DEFAULT_MESSAGE) {
                    this.value = '';
                }
            }.bind(obj);
            obj.onblur = function() {
                if (this.value == '') {
                    this.value = this.DEFAULT_MESSAGE;
                }
            }.bind(obj);
        }
        else {
            obj.onfocus = null;
            obj.onblur = null;
        }
    }
};
Element.addMethods(QnaDomUtils);

// jsr_class.js ---------------------------------------------------------------
// Author: Jason Levitt
// Date: December 7th, 2005
// Constructor -- pass a REST request URL to the constructor
//
function JSONscriptRequest(fullUrl) {
    this.fullUrl = fullUrl;
    this.noCacheIE = '&noCacheIE=' + (new Date()).getTime();
    this.headLoc = document.getElementsByTagName("head").item(0);
    this.scriptId = 'JscriptId' + JSONscriptRequest.scriptCounter++;
}
JSONscriptRequest.scriptCounter = 1;
JSONscriptRequest.prototype.buildScriptTag = function () {
    this.scriptObj = document.createElement("script");
    this.scriptObj.setAttribute("type", "text/javascript");
    //this.scriptObj.setAttribute("charset", "euc-kr");
    this.scriptObj.setAttribute("src", this.fullUrl + this.noCacheIE);
    this.scriptObj.setAttribute("id", this.scriptId);
}
JSONscriptRequest.prototype.removeScriptTag = function () {
    this.headLoc.removeChild(this.scriptObj);
}
JSONscriptRequest.prototype.addScriptTag = function () {
    this.headLoc.appendChild(this.scriptObj);
}
// End jsr_class.js -----------------------------------------------------------

// LogApps.js -----------------------------------------------------------------
var sec; var kw; var ks; var sss; var uco=0; var uda2;
var URL="http://log.search.daum.net/cgi-bin/";
var etlImg=new Image();

function openWin(u1,u2)
{
 var url=u1+"&uco="+(++uco)+u2;
 etlImg.src=url;
 uda2=null;
 return true;
}
function init(s,keyw,keys,ss)
{
 sec=s;
 var index=keyw.indexOf("%2F");
 if(index>0){kw=unescape(keyw);
 }else{kw=keyw;}
 ks=keys;
 sss=ss;
}
function cU1(a,scope,r,p,ext)
{
 return URL+"s="+sec+"&a="+a+scope+"&q="+kw+"&k="+ks+"&r="+r+"&p="+p+"&ext="+ext;
}
function cU2(o,u1,u2,u3)
{
 var u="NONE";
 if(o!=null) u=o.href;
 if(uda2!=null) u2 = uda2;
 return "&usr1="+u1+"&usr2="+u2+"&usr3="+u3+"&t=D&u="+u;
}
function cU3(u,u1,u2,u3)
{
 return "&usr1="+u1+"&usr2="+u2+"&usr3="+u3+"&t=D&u="+u;
}
function gLink(o,a,r,p)
{
 var scope="&ss="+sss+"&as=@@";
 var u1=cU1(a,scope,r,p,""); var u2=cU2(o,"","","");
 return openWin(u1,u2);
}
function gExtraLink(o,a,ext)
{
 var scope="&ss="+sss+"&as=@@";
 if(o != null) u = o.href;
 var u1=cU1(a,scope,"","",ext); var u2=cU2(o,"","","");
 return openWin(u1,u2);
}

function gCRLink(u,a,r,p)
{
 var scope="&ss="+sss+"&as=@@";
 var u1=cU1(a,scope,r,p,""); var u2=cU3(u,"","","");
 return openWin(u1,u2);
}
function gCRExtraLink(u,a,ext)
{
 var scope="&ss="+sss+"&as=@@";
 var u1=cU1(a,scope,"","",ext); var u2=cU3(u,"","","");
 return openWin(u1,u2);
}
function gUSR1Link(o,a,r,p,usr1)
{
 var scope="&ss="+sss+"&as=@@";
 var u1=cU1(a,scope,r,p,""); var u2=cU2(o,usr1,"","");
 return openWin(u1,u2);
}
function gUSR2Link(o,a,r,p,usr2)
{
 var scope="&ss="+sss+"&as=@@";
 var u1=cU1(a,scope,r,p,""); var u2=cU2(o,"",usr2,"");
 return openWin(u1,u2);
}
function gUSR12Link(o,a,r,p,usr1,usr2)
{
 var scope="&ss="+sss+"&as=@@";
 var u1=cU1(a,scope,r,p,""); var u2=cU2(o,usr1,usr2,"");
 return openWin(u1,u2);
}
function gUSR123Link(o,a,r,p,usr1,usr2,usr3)
{
 var scope="&ss="+sss+"&as=@@";
 var u1=cU1(a,scope,r,p,""); var u2=cU2(o,usr1,usr2,usr3);
 return openWin(u1,u2);
}
function gAsLink(o,a,r,p,as)
{
 var scope="&ss="+sss+"&as="+as;
 var u1=cU1(a,scope,r,p,""); var u2=cU2(o,"","","");
 return openWin(u1,u2);
}
function gAsUSR1Link(o,a,r,p,as,usr1)
{
 var scope="&ss="+sss+"&as="+as;
 var u1=cU1(a,scope,r,p,""); var u2=cU2(o,usr1,"","");
 return openWin(u1,u2);
}
function gAsUSR12Link(o,a,r,p,as,usr1,usr2)
{
 var scope="&ss="+sss+"&as="+as;
 var u1=cU1(a,scope,r,p,""); var u2=cU2(o,usr1,usr2,"");
 return openWin(u1,u2);
}
function gAsUSR123Link(o,a,r,p,as,usr1,usr2,usr3)
{
 var scope="&ss="+sss+"&as="+as;
 var u1=cU1(a,scope,r,p,""); var u2=cU2(o,usr1,usr2,usr3);
 return openWin(u1,u2);
}
function gReplaceAll(str,o,n) {var pstr=""; for(var i=0;i<str.length;i++){ pstr+=str.charAt(i).replace(o,n); }return pstr;}
function gSetUSR2(v) {v=gReplaceAll(v, "%", "%25");v=gReplaceAll(v, "#", "%23");v=gReplaceAll(v, "&", "%26");v=gReplaceAll(v, "?", "%3F");uda2=v;}
function gSetKW(v) {kw=v;}
// End LogApps.js -------------------------------------------------------------

/*-------------------------------------------------------------------------*/
/* Ä«Æä Áö½Ä°Ô½ÃÆÇ iframe Á¶Á¤ */
var DEFAULT_QNA_FRAME_HEIGHT = 1310;
var DEFAULT_QNA_FRAME_MINIMUM_HEIGHT = 330;

/* cafe ³» ½ÅÁö½Ä iframeÀÇ ³ôÀÌ¸¦ resizeÇÑ´Ù. */
function resizeQnaFrame(height) {
    try {
        var frameInParent = parent.document.getElementById('qna_bbs');
        if (frameInParent == null) { frameInParent = parent.document.getElementById('qna_read'); }
        frameInParent.height = height;
    } catch (e) { }
}
function onCafeLoad() {
    if (document.domain != 'daum.net') { document.domain = 'daum.net'; }
    parent.scrollTo(0, 0);

    var height = document.body.scrollHeight == 0 ?
            DEFAULT_QNA_FRAME_MINIMUM_HEIGHT : document.body.scrollHeight;
    resizeQnaFrame(height);
}
function onCafeLoadReSize() {
    var height = document.body.scrollHeight == 0 ?
            DEFAULT_QNA_FRAME_MINIMUM_HEIGHT : document.body.scrollHeight;
    resizeQnaFrame(height);
}
function onCafeUnLoad() {
    //resizeQnaFrame(DEFAULT_QNA_FRAME_HEIGHT);
}
/* cafe FAQ µî·Ï,»èÁ¦ */
function deleteCafeFAQ(qid, param) {
    if (confirm('FAQ¿¡¼­ ÇØÁ¦ÇÏ½Ã°Ú½À´Ï±î?')) {
        processCafeFAQ('delete', qid, param);
    }
}
function addCafeFAQ(qid, param) {
    if (confirm('FAQ·Î µî·ÏÇÏ½Ã°Ú½À´Ï±î?')) {
        processCafeFAQ('add', qid, param);
    }
}
function processCafeFAQ(type, qid, param) {
    new Ajax.Request("/qna/cafe/faq.ajax", {
        method: 'post',
        parameters: $H({ "type":type, "qid":qid, "param":param }).toQueryString(),
        onSuccess: function(transport) {
            var resp = eval("(" + transport.responseText + ")");
            alert(resp.message);
            if (type == 'delete') {
                location.reload();
            }
        }
    });
}
/* ÃßÃµÇÏ±â */
function openLoginAndRecommendPopup(type, qid, aid, count_objid, point) {
    openLoginAndMoveTarget("javascript:recommend(\"" + type + "\", \"" + qid + "\", \"" + aid + "\", \"" + count_objid + "\", true, " + point + ")");
}

function recommend(type, qid, aid, count_objid, reloadable, point) {
    new Ajax.Request(
        "/qna/recommend.json",
        {
            parameters: { "type":type, "qid":qid, "aid":aid, "point": point },
            onSuccess: function(transport) {
                var resp = eval("(" + transport.responseText + ")");
                if (count_objid != '') {
                    var cnt = parseInt($(count_objid).innerHTML);
                    $(count_objid).innerHTML = cnt + 1;
                }
                growl(resp.message);
                if (reloadable == true || resp.netizen_selected == true) {
                    document.location.reload();
                }
            },
            onFailure: function(transport) {
                var resp = eval("(" + transport.responseText + ")");
                if (resp.exception.indexOf('RestrictedIpException') > 0) {
                    growl('±ÍÇÏÀÇ ÄÄÇ»ÅÍ¿¡¼­ Áö¼ÓÀûÀÎ ½ºÆÔ, µµ¹è, ±¤°í±ÛÀÌ µî·ÏµÊ¿¡ µû¶ó ¼­ºñ½º Á¢±ÙÀÌ Â÷´ÜµÇ¾ú½À´Ï´Ù.');
                }
                else {
                    if (resp.message) growl(resp.message);
                }
            }
        }
    );
}
/*
 * Ä«Å×°í¸® ¼±ÅÃ Ã¢À» ¶ç¿î´Ù.
 */
var CategoryType = {
    Question: 'Q', Encyclopedia: 'D', Hanguel: 'H', Knowhow: 'K', File: 'F'
};
function openCategorySelect(type, fpCallback, isChooseOnlyLastItem, xss) {
    var url = '/qna/category_select.html?category_id=' + type +
            '&callback_function=' + fpCallback +
            '&choose_only_last_item=' + isChooseOnlyLastItem +
            '&xss=' + xss;
    popup(url, 'category_select', 700, 420, 'yes');
}
function openCategorySearch(type, fpCallback, isChooseOnlyLastItem, xss, query) {
    var url = '/qna/category_search.html?category_id=' + type +
            '&callback_function=' + fpCallback +
            '&choose_only_last_item=' + isChooseOnlyLastItem +
            '&xss=' + xss + '&q=' + query;
    popup(url, 'category_select', 700, 420, 'yes');
}
var COMPLAINT_TYPE = { Question: "QQ", Answer: "AA", OpenKnowledge: "OO", FileArticle: "FF", TrackbackAnswer: "TA" };
function complain(type, id) {
    var url = '/qna/complain.html?targetType=' + type + '&objectId=' + id;
    popup(url, 'complain', 600, 426, 'no');
}
function openUploadImageWindow(callbackFunctionName, xss, use) {
    var url = '/qna/file/upload_image/form.html?callback_function=' + callbackFunctionName + '&xss=' + xss;
    if (use != null) { url = url + '&use=' + use; }
    popup(url, 'upload_image', 600, 554, 'no');
}
function openUploadMovieWindow(callbackFunctionName, xss) {
    var url = '/qna/movie_uploader.html?callback_function=' + callbackFunctionName + '&xss=' + xss;
    popup(url, 'upload_movie', 480, 335, 'no');
}
function openImageViewer() {
    var filename = this.src;
    popup('/qna/file/view_image.html?' + filename, 'kinImageViewer',
        100, 100, 'no');
}
/* °ü½É Ä«Å×°í¸® ºÒ·¯¿À±â */
var favorCategoryLoaded = false;
function loadMyFavorCategory() {
    if (favorCategoryLoaded == false) {
        new Ajax.Request('/qna/my/favorite_category_manager.json', {
            method: 'GET',
            evalJSON: 'force',
            onSuccess: function (transport) {
                var favorites = transport.responseJSON.favorites;
                var template = "";
                if (favorites.length > 0) {
                    $A(favorites).each(function (item) {
                        template += '<dd onclick="location.href=\'/qna/list.html?category_id=' + item.id + '\'">' + item.name + '</dd>';
                    });
                } else {
                    template += '<dd>¼³Á¤µÈ °ü½ÉÄ«Å×°í¸®°¡ ¾ø½À´Ï´Ù.</dd>';
                }
                $('cateList').innerHTML = template;
                favorCategoryLoaded = true;
            }
        })
    }
}

/* ¾Ë¸®¹Ì È®ÀÎ */
function confirm_notification(seq) {
    new Ajax.Request("/qna/notification/confirm.ajax", {
        method: 'post',
        parameters: $H({ "seq":seq }).toQueryString(),
        onSuccess: function(transport) {return;}
    });
}

/* ¾Ë¸®¹Ì »èÁ¦ */
function delete_notification(seq) {
    new Ajax.Request("/qna/notification/delete.ajax", {
        method: 'post',
        parameters: $H({ "seq":seq }).toQueryString(),
        onSuccess: function(transport) {
            location.reload();
        }
    });
}

/* Trackback URL Clipboard·Î º¹»çÇÏ±â */
function copyToClipboard(string, Element, urlBox1) {
    if(window.clipboardData) {
        // IE
        window.clipboardData.setData('Text',string);
        window.alert('º¹»çµÇ¾ú½À´Ï´Ù');
    }else {
        // others (ex. FF)
        Element.toggle(urlBox1);
    }
}

/* paramÀÌ null ¶Ç´Â empty stringÀÌ¸é default ¸®ÅÏ */
function nvl(param, defaultValue) {
    if (typeof(param) == 'undefined' || (typeof(param) == 'string' && param.trim() == '')) {
        return defaultValue;
    }
    return param;
}

function check_restricted_word(content, proceed) {
    new Ajax.Request("/qna/.ajax", {
        parameters: $H({"content": content}).toQueryString(),
        onSuccess: function(transport) {
        }
    });
}

function typeChange(lay) {
    $(lay).className = $(lay).hasClassName('comment_open') ? 'comment_close' : 'comment_open';
}

/* ÀÇ°ß ´õº¸±â ¹öÆ° toggle Ã³¸®¸¦ À§ÇÑ ·ÎÁ÷ */
var COMMENT_FRAGMENT_BUFFER = { };
function toggleMoreComment(anchor, target_layer_id) {
    var handler = $(anchor).hasClassName('downarrow') ? showMoreComment : hideMoreComment;
    handler(anchor, target_layer_id);
}
function showMoreComment(anchor, target_layer_id) {
    COMMENT_FRAGMENT_BUFFER[target_layer_id] = $(target_layer_id).innerHTML;
    new AddInfo.Html(anchor.href, function () { $(target_layer_id).innerHTML = ''; }, target_layer_id ).run();
    anchor.innerHTML = 'ÀÇ°ß ¼û±â±â';
    $(anchor).removeClassName('downarrow').addClassName('uparrow');
}
function hideMoreComment(anchor, target_layer_id) {
    $(target_layer_id).innerHTML = COMMENT_FRAGMENT_BUFFER[target_layer_id];
    anchor.innerHTML = '´õ ¸¹Àº ÀÇ°ßº¸±â';
    $(anchor).removeClassName('uparrow').addClassName('downarrow');
}

var Cookies={set:function(n,v,d){var g="";if(d!=undefined){var f=new Date();f.setTime(f.getTime()+(d*24*60*60*1000));g="; expires="+f.toGMTString();};document.cookie=escape(n)+"="+escape(v||'')+g;},get:function(n){var a=n+"=";var r=null;document.cookie.split(';').each(function(s){while(s.charAt(0)==' ')s=s.substring(1,s.length);if(s.indexOf(a)==0)r=s.substring(a.length,s.length);});return r;},remove:function(n){this.set(n,'',-1);return this.get(n)||true;}};