function replaceContent(obj, html) {
    if(typeof obj.innerHTML == "undefined")  {
        obj.innerText = html;
    }
    else {
        obj.innerHTML = html;
    }
}
/*
function initRollOverPage(root_id, img_parent_class, page_class, loop) {
    loop = typeof loop != "boolean" ? true : loop;
    var imgList = $("#" + root_id + " ." + img_parent_class + " img");
    var pageList = $("#" + root_id + " ." + page_class);

    imgList.mouseover(function(event) {
        var i = imgList.index($(this));
        $.each(imgList, function(j, img) {
            this.src = i == j ? this.src.replace("_off", "_on") : this.src.replace("_on", "_off");
        });
        //pageList.fadeOut().eq(i).fadeIn();
        pageList.hide().eq(i).show();
    }).css("cursor", "pointer").eq(0).mouseover();
    /*
    setInterval(function() {
        try {
            var i = 0;
            imgList.each(function(j, img) {
                if(this.src.match(/_on/) != null) {
                    i = j;
                    return false;
                }
            });
            if(i >= imgList.length -1) {
                i = -1;
            }
            imgList.eq(i+1).mouseover();
        }
        catch(e) {
            ;
        }
    }, 2000);
    */
//}

// v2
/*
function bindRollOverPage(root_selector, button_selector, page_selector, loop) {
    loop = typeof loop != "boolean" ? true : loop;
    var imgList = $(root_selector + " " + button_selector);
    var pageList = $(root_selector + " " + page_selector);

    imgList.hover(function(event) {
        var i = imgList.index($(this));
        $.each(imgList, function(j, img) {
            this.src = i == j ? this.src.replace("_off", "_on") : this.src.replace("_on", "_off");
        });
        pageList.hide().eq(i).show();
    }, function(event) {
    }).css("cursor", "pointer").eq(0).mouseover();
    setInterval(function() {
        try {
            var i = 0;
            imgList.each(function(j, img) {
                if(this.src.match(/_on/) != null) {
                    i = j;
                    return false;
                }
            });
            if(i >= imgList.length -1) {
                i = -1;
            }
            imgList.eq(i+1).mouseover();
        }
        catch(e) {
            ;
        }
    }, 7000);
}

*/


function overCategoryMenu(idx){
    var mnImg   = "/image/2011/head/head_navi0"+idx+"_on.gif";
    var mnLayer = "Category"+idx;

    MM_showHideLayers(mnLayer,'','show');
    MM_swapImage("Menu0"+idx, '', mnImg,1);
}

function outCategoryMenu(idx){
    var mnLayer = "Category"+idx;
    MM_showHideLayers(mnLayer,'','hide');
    MM_swapImgRestore();
}


function overChgImgLayer(imgName,imgSrc, layerName,idx){
    var mnImg   = "/image/2011/"+imgSrc+idx+"_on.gif";
    var mnLayer = layerName+idx;

    MM_showHideLayers(mnLayer,'','show');
    MM_swapImage(imgName+idx, '', mnImg,1);

}

function outChgImgLayer(layerName,idx){
    var mnLayer = layerName+idx;
    MM_showHideLayers(mnLayer,'','hide');
    MM_swapImgRestore();
}

function autoChgImgLayer(idx){
    setTimeout(autoChgImgLayer(), idx*1000); 
}

function winOPEN(width, height, url){
    window.open(url,"OW",("width="+width+",height="+height));
}

function chkLogin(){
    with(document.frmLogin){
        if("" == mid.value){
            alert("¾ÆÀÌµð¸¦ ÀÔ·ÂÇØ ÁÖ¼¼¿ä.");
            mid.focus();
            return false;
        }
        if("" == pwd.value){
            alert("ºñ¹Ð¹øÈ£¸¦ ÀÔ·ÂÇØ ÁÖ¼¼¿ä.");
            pwd.focus();
            return false;
        }else submit();
    }
}
function sendLogin(){
    var ikeyCode = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode;
    if (ikeyCode == 13) {
        chkLogin();
    }
}
function loadLogin(){
    document.frmLogin.submit();
}
function goPage(idx){
    document.app.page.value = idx;
    chkForm();
}


function sendEnter(obj){
    var ikeyCode = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode;
    if (ikeyCode == 13) {
        chkForm();
    }
}
function goGroupRank(str){
	with(document.app){
		mode.value = str;
		target = "_self";
		action = "../rank/Rank_S.php";
		submit();
	}
}
function goNotice(idx){
    with(document.app){
        target = "_self";
        action = "../help/Notice_V.php";
        n_id.value = idx;
        submit();
    }
}
function goFind(idx){
    with(document.app){
        target = "_self";
        action = "../help/Find_L.php";
        n_id.value = idx;
        submit();
    }
}
function goFaq(idx){
    with(document.app){
        target = "_self";
        action = "../help/Faq_L.php";
        n_id.value = idx;
        submit();
    }
}
function goGroup(str){
    with(document.app){
        target = "_self";
        action = "../group/Group_L.php";
        p_part.value = str;
		page.value = 1;
        submit();
    }
}

function goTMoney(str){
    with(document.app){
        target = "_self";
        action = "../group/TMoney_L.php";
        p_part.value = str;
		page.value = 1;
        submit();
    }
}
function viewUpimg(str){
	window.open("/etc/imgView.php?uimg="+str,"Ppop","width=500,height=400,resizable=1")
}
function popProd(str){
    window.open("../popup/popProd_V.php?p_id="+str,"Ppop","width=750,height=450")
/*
    with(document.app){
        target = "Ppop";
        action = "";
        p_id.value = str;
        submit();
    }
*/
}

function popZzim(str){
    window.open("../popup/popZzim_I.php?p_id="+str,"Ppop","width=750,height=450");

}

function popBag(str){
    window.open("../popup/popBag_I.php?p_cnt=1&p_id="+str,"Ppop","width=750,height=450");
}

function popBisInfo(){
    window.open("../popup/FindComp_F.php","Ppop","width=750,height=450");
}


function prodView(str){
    with(document.app){
        target = "_self";
        action = "../group/Prod_V.php?p_id=" + str;
        p_id.value = str;
        submit();
    }
}
function goDiary(){
    with(document.app){
        target = "_self";
        action = "../diary/";
        submit();
    }
}
function goDiaryPart(str){
    with(document.app){
        target = "_self";
        p_part.value = str;
        action = "../diary/Diary_S.php";
        submit();
    }
}
function maniaView(idx){
    with(document.app){
        p_id.value = idx;
        target = "_self";
        action = "../play/Mania_V.php";
        submit();
    }
}

function oopsView(idx){
    with(document.app){
        p_id.value = idx;
        target = "_self";
        action = "../play/Oops_V.php";
        submit();
    }
}
function blahView(idx){
    with(document.app){
        p_id.value = idx;
        target = "_self";
        action = "../play/Blah_V.php";
        submit();
    }
}
function cartoonView(ids, idx){
    with(document.app){
        c_id.value = ids;
        p_id.value = idx;
        target = "_top";
        action = "../play/Cartoon_M.php";
        submit();
    }
}
function brandView(str){
    with(document.app){
        target = "_self";
        action = "../brand/Brand_V.php?c_id="+str;
        c_id.value = str;
        page.value=1;
        submit();
    }
}
function brandPart(idx,str){
    with(document.app){
        target = "_self";
        action = "../brand/Brand_V.php";
        c_id.value = idx;
        ppart.value = str;
        page.value=1;
        submit();
    }
}
function goTheme(idx){
    with(document.app){
        target = "_self";
        action = "../play/Theme_M.php";
        p_id.value = idx;
        submit();
    }
}

function goEvent(idx){
    with(document.app){
        p_id.value = idx;
        target = "_self";
        action = "../event/Event_V.php?p_id=" +idx;
        submit();
    }
}

function eventPart(str){
    with(document.app){
        n_id.value = str;
        target = "_self";
        action = "../event/Event_M.php";
        submit();
    }
}
function delTalk(idx){
    with(document.frmTalk){
        if("" != subchk.value){
            alert("ÇöÀç ÀÛ¼ºÇÏ½Å ±ÛÀ» »èÁ¦ÇÏ´Â ÁßÀÔ´Ï´Ù. Àá½Ã¸¸ ±â´Ù·Á ÁÖ¼¼¿ä.");
            return false;
        }
        if(confirm("Á¤¸» »èÁ¦ÇÏ½Ã°Ú½À´Ï±î?")){
            t_id.value=idx;
            subchk.value="S";
            target = "_self";
            action = "../etc/Talk_D.php";
            submit();
        }
    }
}
function chkTalk(){
    with(document.frmTalk){
        if("" != subchk.value){
            alert("ÇöÀç ÀÛ¼ºÇÏ½Å ±ÛÀ» µî·ÏÇÏ´Â ÁßÀÔ´Ï´Ù. Àá½Ã¸¸ ±â´Ù·Á ÁÖ¼¼¿ä.");
            return false;
        }
        if(w_id.value == ""){
            alert("ÀÛ¼ºÀÚÀÇ ´Ð³×ÀÓÀ» ÀÔ·ÂÇØ ÁÖ¼¼¿ä.");
            w_id.focus();
            return false;
        }else{
			if(getCookie("cGrant") != "S"){
				tmps = w_id.value;
				if(tmps.search("ÈÄÃß") != -1){
					alert("ÀÛ¼ºÀÚÀÇ ´Ð³×ÀÓ¿¡ 'ÈÄÃß'¶ó´Â ´Ü¾î´Â »ç¿ëÇÒ ¼ö ¾ø½À´Ï´Ù.");
					w_id.select();
					return false;
				}
				if(tmps.search("°ü¸®ÀÚ") != -1){
					alert("ÀÛ¼ºÀÚÀÇ ´Ð³×ÀÓ¿¡ '°ü¸®ÀÚ'¶ó´Â ´Ü¾î´Â »ç¿ëÇÒ ¼ö ¾ø½À´Ï´Ù.");
					w_id.select();
					return false;
				}
			}
        }
        var str = talk.value;
        if(str == ""){
            alert("ÇÑÁÙ ÅåÅåÀ» 100ÀÚ ÀÌ³»·Î Àû¾îÁÖ¼¼¿ä.");
            talk.focus();
            return false;
        }else{
            str = notValidStr(str);
            if(str != ""){
                alert("»ç¿ëÀÌ ±ÝÁöµÈ ´Ü¾î(" + str + ")°¡ Æ÷ÇÔÀÌ µÇ¾îÀÖ½À´Ï´Ù.");
                return false;
            }
        }
        if(confirm("ÀÛ¼ºÇÏ½Å ±ÛÀ» µî·ÏÇÏ½Ã°Ú½À´Ï±î?")){
            subchk.value="S";
            target = "_self";
            action = "../etc/Talk_I.php";
            submit();
        }
    }
}

function goMainDir(str){
	location.href= "http://www.hoochootong.com" + str;
}

function goNaver(){
	window.open("http://www.naver.com/");
}
function notValidStr(str){
    var rs = "";
    var noStr = new Array("½Ö³â","½Ö³ð","ºù½Å","Á¿±î","Á¿°°Àº°Ô","¾Ã»õ³¢","¾¾¹ß","¾¾ÆÈ","½Ã¹ú","¾¾¹ú","¾¾¹ú","¶°±×¶ö","Á¿¹ä","¾¾¹ë³Ñ");
    for (i=0; i< noStr.length; i++){
        if (str.indexOf(noStr[i]) != -1){
            rs = noStr[i];
            break;
        }
    }
    return rs;
}

function setCookieMain( name, value, expiredays ) {
        var todayDate = new Date(); 
        todayDate.setDate( todayDate.getDate() + expiredays ); 
        opener.document.cookie = name + "=" + escape( value ) + "; path=/; expires=" + todayDate.toGMTString() + ";" 
}

function setCookie( name, value, expiredays ) {
        var todayDate = new Date(); 
        todayDate.setDate( todayDate.getDate() + expiredays ); 
        document.cookie = name + "=" + escape( value ) + "; path=/; expires=" + todayDate.toGMTString() + ";" 
}
function getCookie( name ) {
        var nameOfCookie = name + "="; 
        var x = 0; 
        while ( x <= document.cookie.length ) {
                var y = (x+nameOfCookie.length);
                if ( document.cookie.substring( x, y ) == nameOfCookie ) {
                        if ( (endOfCookie=document.cookie.indexOf( ";", y )) == -1 )
                                endOfCookie = document.cookie.length;
                        return unescape( document.cookie.substring( y, endOfCookie ) );
                }
                x = document.cookie.indexOf( " ", x ) + 1;
                if ( x == 0 )
                        break;
        }
        return "";
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

function Layers_findObj(n, d) { //v4.0
	var p,i,x;  if(!d) d=document; if((p=n.indexOf('?'))>0&&parent.frames.length) {
	  d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
	if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
	for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=Layers_findObj(n,d.layers[i].document);
	if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function MM_showHideLayers() { //v3.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; }
    obj.visibility=v; }
}

    function bindSlider(button_box_id, prod_list_id, interval, width, height, vertical) {
        $(prod_list_id).hover(function(event) {
            //½½¶óÀÌ´õ¿¡ ¸¶¿ì½º°¡ ¿Ã¶ó¿ÔÀ» ¶§¿¡´Â ½½¶óÀÌ´õ¸¦ ¸ØÃá´Ù.
            var api = $(prod_list_id).data("scrollable");
            api.stop();
        }, function(event) {
            //½½¶óÀÌ´õ¿¡¼­ ¸¶¿ì½º°¡ ³ª°¡¸é ½½¶óÀÌ´õ¸¦ ´Ù½Ã ½ÃÀÛÇÑ´Ù.
            var api = $(prod_list_id).data("scrollable");
            api.play();
        });

        if(typeof vertical == "boolean" && vertical) {
        	$(prod_list_id).scrollable({
                vertical: vertical /* ½½¶óÀÌµù ¹æÇâ (true = ¼öÁ÷¹æÇâ, false=¼öÆò¹æÇâ) */,
                circular: true /* ¹Ýº¹ ¿©ºÎ (true,false) */,
                speed: 400 /* ½½¶óÀÌµù È¿°úÀÇ ¼Óµµ. 1/1000ÃÊ ´ÜÀ§ */
        	});
        }
        else {
            $(prod_list_id).scrollable({
                circular: true /* ¹Ýº¹ ¿©ºÎ (true,false) */,
                speed: 400 /* ½½¶óÀÌµù È¿°úÀÇ ¼Óµµ. 1/1000ÃÊ ´ÜÀ§ */
            });
        }

        //ÀÚµ¿½ºÅ©·Ñ. interval °ªÀÌ 0 ÀÌ»óÀ¸·Î ÁÖ¾îÁö¸é ½ÃÀÛµÈ´Ù.
        //intervalÀº millisecond °ªÀÌ´Ù (1/1000 ÃÊ ´ÜÀ§)
        if(typeof interval == "number" && interval > 0) {
            $(prod_list_id).autoscroll(interval);
        }

        //½½¶óÀÌ´õ Á¶ÀÛ¿ë ¹öÆ°(À§,¾Æ·¡,¿ÞÂÊ,¿À¸¥ÂÊ,¼ýÀÚ) ¼³Á¤
        $(button_box_id+" img.button").hover(function(event) {
            //¸¶¿ì½º ¿À¹ö ½Ã ½½¶óÀÌ´õ¸¦ ¸ØÃá´Ù
            var api = $(prod_list_id).data("scrollable");
            api.stop();
        }, function(event) {
            //¸¶¿ì½º ¾Æ¿ô ½Ã ½½¶óÀÌ´õ¸¦ ´Ù½Ã ½ÃÀÛÇÑ´Ù.
            var api = $(prod_list_id).data("scrollable");
            api.play();
        }).click(function(event) {
            //Å¬¸¯ ½Ã ´ÙÀ½ ½½¶óÀÌµå¸¦ º¸¿©ÁØ´Ù.
            var api = $(prod_list_id).data("scrollable");
            if($(this).hasClass("slide_up")) {
                api.next();
            }
            else if($(this).hasClass("slide_down")) {
                api.prev();
            }
        }).css("cursor", "pointer");

        //¼öÆò ¹× ¼öÁ÷¹æÇâÀÏ¶§ÀÇ ½ºÅ¸ÀÏ ÀÏºÎºÐÀ» Á¶ÀýÇÑ´Ù. (¿©±â¿¡ ¼³Á¤ÇÑ °ªÀÌ °¡Àå ³ôÀº ¿ì¼±±ÇÀ» °®´Â´Ù.)
        if(typeof vertical == "boolean" && vertical) {//¼öÁ÷¹æÇâ ½½¶óÀÌµå
            $(prod_list_id).css("width", width);
            $(prod_list_id).css("height", height);
            $(prod_list_id).css("overflow", "hidden");
            $(prod_list_id).css("position", "relative");
            
            $(prod_list_id+" div.items").css("cssText", "width: "+width+"; height: 2000em; position: absolute;");
            $(prod_list_id+" div.items > *").css("width", width);
        }
        else {//¼öÆò¹æÇâ ½½¶óÀÌµå
            $(prod_list_id).css("width", width);
            $(prod_list_id).css("height", height);
            $(prod_list_id).css("overflow", "hidden");
            $(prod_list_id).css("position", "relative");
            
            $(prod_list_id+" div.items").css("cssText", "width: 2000em; height: "+height+"; position: absolute;");
            $(prod_list_id+" div.items > *").css("width", $(prod_list_id).css("width"));
            if ($.browser.msie && $.browser.version.substr(0,1)<8) {
            	$(prod_list_id+" div.items > *").css("display", "inline");
            }
            else {
                $(prod_list_id+" div.items > *").css("display", "inline-block");
            }
        }
    }

/**
 * ÆäÀÌ½ººÏ ½ºÅ©·¦¿ë ½ºÅ©¸³Æ®
 *
 * @param string url
 * @param string subject
 */
function scrapFacebook(url, subject) {
    subject = typeof subject != "undefined" ? subject : "ÅåÅåÆ¢´Â »ýÈ°°¨¼º ¿£µ¹ÇÉ {ÈÄÃßÅë}ÀÔ´Ï´Ù.";
    var popup = window.open('http://www.facebook.com/sharer.php?u='+url+'&t='+encodeURIComponent(subject), '_blank', 'width=643, height=345, scrollbars=0');
    popup.focus();
}

/**
 * Æ®À§ÅÍ ¸®Æ®À­¿ë ½ºÅ©¸³Æ®
 *
 * @param string url
 * @param string subject
 */
function scrapTwitter(url, subject) {
    subject = typeof subject != "undefined" ? subject : "ÅåÅåÆ¢´Â »ýÈ°°¨¼º ¿£µ¹ÇÉ {ÈÄÃßÅë}ÀÔ´Ï´Ù.";
    subject = subject.replace(/\'/g, '&#39;');
    subject = subject.replace(/\"/g, '&quot;');
    var popup = window.open('http://twitter.com/home?status='+encodeURIComponent(subject)+' '+url, '_blank');
    popup.focus();
}

/**
 * ¹ÌÅõµ¥ÀÌ ½ºÅ©·¦¿ë ½ºÅ©¸³Æ®
 *
 * @param string url
 * @param string subject
 * @param string tags
 */
function scrapMe2day(url, subject, tags) {
    tags = typeof tags != "undefined" ? tags : 'ÅåÅåÆ¢´Â »ýÈ°°¨¼º ¿£µ¹ÇÉ {ÈÄÃßÅë}';
    subject = '"'+encodeURIComponent(subject.replace(/\"/g, '`'))+'"'+':'+url+'&new_post[tags]='+encodeURIComponent(tags);
    var popup = window.open('http://me2day.net/posts/new?new_post[body]='+subject, '_blank');
    popup.focus();
}

/**
 * ½ÎÀÌ¿ùµå ½ºÅ©·¦¿ë ½ºÅ©¸³Æ®
 * (¾ÆÁ÷ ¹Ì±¸Çö »óÅÂÀÓ)
 *
 * @param string url
 * @param string subject
 */
function scrapCyworld(url, subject) {
    return false;
}
