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 MM_findObj(n, d) { //v4.01
  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 && d.getElementById) x=d.getElementById(n); return x;
}

function MM_showHideLayers() { //v6.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 MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

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_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_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 CopyClibboard(link)
{
    window.clipboardData.setData('Text', link);
    alert('RSS 주소가 복사되었습니다');
}

//팝업창 띄우지 않게하기 시작
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 ""; 
}

/*  UTF-8 인코딩 */
function encodeURL(str){
    var s0, i, s, u;
    s0 = "";                // encoded str
    for (i = 0; i < str.length; i++){   // scan the source
        s = str.charAt(i);
        u = str.charCodeAt(i);          // get unicode of the char
        if (s == " "){s0 += "+";}       // SP should be converted to "+"
        else {
            if ( u == 0x2a || u == 0x2d || u == 0x2e || u == 0x5f || ((u >= 0x30) && (u <= 0x39)) || ((u >= 0x41) && (u <= 0x5a)) || ((u >= 0x61) && (u <= 0x7a))){       // check for escape
                s0 = s0 + s;            // don't escape
            }
            else {                  // escape
                if ((u >= 0x0) && (u <= 0x7f)){     // single byte format
                    s = "0"+u.toString(16);
                    s0 += "%"+ s.substr(s.length-2);
                }
                else if (u > 0x1fffff){     // quaternary byte format (extended)
                    s0 += "%" + (oxf0 + ((u & 0x1c0000) >> 18)).toString(16);
                    s0 += "%" + (0x80 + ((u & 0x3f000) >> 12)).toString(16);
                    s0 += "%" + (0x80 + ((u & 0xfc0) >> 6)).toString(16);
                    s0 += "%" + (0x80 + (u & 0x3f)).toString(16);
                }
                else if (u > 0x7ff){        // triple byte format
                    s0 += "%" + (0xe0 + ((u & 0xf000) >> 12)).toString(16);
                    s0 += "%" + (0x80 + ((u & 0xfc0) >> 6)).toString(16);
                    s0 += "%" + (0x80 + (u & 0x3f)).toString(16);
                }
                else {                      // double byte format
                    s0 += "%" + (0xc0 + ((u & 0x7c0) >> 6)).toString(16);
                    s0 += "%" + (0x80 + (u & 0x3f)).toString(16);
                }
            }
        }
    }
    return s0;
}

/*  UTF-8 디코딩 */
function decodeURL(str){
    var s0, i, j, s, ss, u, n, f;
    s0 = "";                // decoded str
    for (i = 0; i < str.length; i++){   // scan the source str
        s = str.charAt(i);
        if (s == "+"){s0 += " ";}       // "+" should be changed to SP
        else {
            if (s != "%"){s0 += s;}     // add an unescaped char
            else{               // escape sequence decoding
                u = 0;          // unicode of the character
                f = 1;          // escape flag, zero means end of this sequence
                while (true) {
                    ss = "";        // local str to parse as int
                        for (j = 0; j < 2; j++ ) {  // get two maximum hex characters for parse
                            sss = str.charAt(++i);
                            if (((sss >= "0") && (sss <= "9")) || ((sss >= "a") && (sss <= "f"))  || ((sss >= "A") && (sss <= "F"))) {
                                ss += sss;      // if hex, add the hex character
                            } else {--i; break;}    // not a hex char., exit the loop
                        }
                    n = parseInt(ss, 16);           // parse the hex str as byte
                    if (n <= 0x7f){u = n; f = 1;}   // single byte format
                    if ((n >= 0xc0) && (n <= 0xdf)){u = n & 0x1f; f = 2;}   // double byte format
                    if ((n >= 0xe0) && (n <= 0xef)){u = n & 0x0f; f = 3;}   // triple byte format
                    if ((n >= 0xf0) && (n <= 0xf7)){u = n & 0x07; f = 4;}   // quaternary byte format (extended)
                    if ((n >= 0x80) && (n <= 0xbf)){u = (u << 6) + (n & 0x3f); --f;}         // not a first, shift and add 6 lower bits
                    if (f <= 1){break;}         // end of the utf byte sequence
                    if (str.charAt(i + 1) == "%"){ i++ ;}                   // test for the next shift byte
                    else {break;}                   // abnormal, format error
                }
            s0 += String.fromCharCode(u);           // add the escaped character
            }
        }
    }
    return s0;
}

function popupOpen(url,vscrollbars,vtoolbar,vmenubar,vlocation,vwidth,vheight){		

	window.open(url,'_PopUp','scrollbars='+vscrollbars+',toolbar='+vtoolbar+',menubar='+vmenubar+',location='+vlocation+',width='+vwidth+',height='+vheight+',location=no')

}

//로그인div
function fn_showLoginSheet(show,mnu_siteid){
	if (show == 1) 
	{
		var pntMouseY;
		var pntMouseX;

		var obj = document.getElementById("LinkLoginWrite");
		var posX=0;               
		var posY=0; 

		if(typeof(obj.offsetParent) != "undefined")
		{                  
			  for(var x=0, y=0;obj; obj=obj.offsetParent)
			  {                       
					x += obj.offsetLeft;                       
					y += obj.offsetTop;                   
			  }                   
			  pntMouseX=x;                   
			  pntMouseY=y; 
		}               
		else{                   
			
			  pntMouseX=obj.offsetLeft;                   
			  pntMouseY=obj.offsetTop;    
		} 
		divLeft = '200px';
		divTop	=	'100px';
		if(mnu_siteid=="post"){
			divLeft = '200px';
			divTop	=	'20px';
		}else if(mnu_siteid=="tour"){
			divLeft = '200px';
			divTop	=	'50px';
		}
			

		document.getElementById('BodLoginHTML').style.position	= 'absolute';
		document.getElementById('BodLoginHTML').style.zIndex	= 1;
		document.getElementById('BodLoginHTML').style.left			= divLeft;
		document.getElementById('BodLoginHTML').style.top			= divTop;
		document.getElementById('BodLoginHTML').style.display	= 'block';		
	}else {
	    document.getElementById("BodLoginHTML").style.display = 'none';
	}	
}

/* */
//실명인증 Open 창
function fnPopup(retURL)
{
	window.open('/message/nc.php?retURL='+retURL, 'popup','width=585, height=590');
	//document.frmVar.var_path.value = path;
	//document.frmVar.target = "popup";
	//document.frmVar.action = "/message/nc.php";
	//document.frmVar.submit();
}

// G-PIN 인증창 Open
function fn_GPinAuth(retURL) {

    wWidth = 360;
    wHight = 520;
    
    wX = (window.screen.width - wWidth) / 2;
    wY = (window.screen.height - wHight) / 2;

    var w = window.open("/message/ipin_main.php?retURL="+retURL, "gPinLoginWin", "directories=no,toolbar=no,left="+wX+",top="+wY+",width="+wWidth+",height="+wHight);
}

// 프레임 제어
// iframe auto resize
function resizeIFrame(ifrName) { 
	
	var min_h = 250;
	var oIFrame = document.getElementById(ifrName);

	try {          
	  
		var oDoc = oIFrame.contentDocument || oIFrame.contentWindow.document;        

		if (/MSIE/.test(navigator.userAgent)) {
			var frmHeight = oDoc.body.scrollHeight;
		} else {
			var s = oDoc.body.appendChild(document.createElement('DIV'))
			s.style.clear = 'both';

			var frmHeight = s.offsetTop;
			s.parentNode.removeChild(s);
		}
		
		if (frmHeight < min_h) 
			frmHeight = min_h;

		oIFrame.style.height = frmHeight+"px";

	} catch (e) { }
}


function wz_checkInput(proc){
	var frm = document.getElementById('frmWebzine');
	var usr_name = frm.usr_name.value;
	var usr_email	= frm.usr_email.value;
	var usr_email_host = frm.usr_email_host.value;

	if ( usr_name.length ==0 ) {
		alert("이름을 입력해 주세요");
		frm.usr_name.focus();
		return false;
	}
	if ( usr_email.length ==0 ) {
		alert("이메일 아이디를 입력해 주세요");
		frm.usr_email.focus();
		return false;
	}
	if ( usr_email_host.length ==0 ) {
		alert("이메일 주소를 입력해 주세요");
		frm.usr_email_host.focus();
		return false;
	}
	frm.cmd.value = proc;
	frm.submit();
}


// Flow Function

var _initTop = 0;
var _layerID = "";

function FlowBanner ( id, initTop )
{
 //alert(navigator.appName);
 var ns = (navigator.appName.indexOf("Netscape") != -1);
 if (ns) initTop = initTop

 var layer = document.getElementById(id);
 layer.style.top = initTop+"px";

 _layerID = id;
 _initTop = initTop;
 _FlowBanner ();
}

function _FlowBanner ()
{
 var layer = document.getElementById(_layerID);
 var ns = (navigator.appName.indexOf("Netscape") != -1);

 if (ns){
  num = (layer.style.top.length);
  var currentTop = layer.style.top.substring(0,(num-2));
  currentTop = parseInt(currentTop);
 }else{
  var currentTop = parseInt ( layer.style.top );
 }

 if (ns){
  var baseTop = parseInt ( document.documentElement.scrollTop );
 }else{
  var baseTop = parseInt ( document.documentElement.scrollTop );
 }

 var nextTop = baseTop + _initTop;
 var distance = ( nextTop - currentTop ) / 15;

 if ( distance > 10 )
  distance = 10;
 else if ( distance < -10 )
  distance = -10;
 if (ns){
  layer.style.top = (currentTop + distance)+"px";
 }else{
  layer.style.top = (currentTop + distance)+"px";
 }
 setTimeout ( "_FlowBanner()", 3 );
}

function init ()
{
 FlowBanner ( "scrollbanner", 0 );
} 