//Child
//alert('aaa');
function setCookie( name, value, expiredays )
{
	var todayDate = new Date();
	todayDate.setDate( todayDate.getDate() + expiredays );
	document.cookie = name + "=" + escape( value ) + "; path=/; expires=" + todayDate.toGMTString()  + ";"
}

function closeWin() 
{ 
	if (document.DontShowNext.PopupCloseCheckbox.checked ) 
 		setCookie( self.name, "DontOpenPopupWindowCookie" , parseInt(DontShowNext.expires.value)); 

	self.close(); 
}


// Parent

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 NoticePopupWindowOpen(NoticeFileURL, PopupWindowName, WindowOption ) {
 
	if ( getCookie( PopupWindowName ) != "DontOpenPopupWindowCookie" )
        window.open(NoticeFileURL,PopupWindowName,WindowOption);
}


// Popup Centered Window

function popUpCenteredWindow(PopupWindowName, URL, x_size, y_size) {

	if ( getCookie( PopupWindowName ) != "DontOpenPopupWindowCookie" ) {

  	var iMyWidth;
  	var iMyHeight;

  	//gets top and left positions based on user's resolution so hint window is centered.
  	iMyWidth = (window.screen.width/2) - (x_size/2 + 10); //half the screen width minus half the new window width (plus 5 pixel borders).
  	iMyHeight = (window.screen.height/2) - (y_size/2 + 50); //half the screen height minus half the new window height (plus title and status bars).
  	var win2 = window.open(URL, PopupWindowName,"status=no ,height=" + y_size + ",width=" + x_size + ",resizable=no,left=" + iMyWidth + ",top=" + iMyHeight + ",screenX=" + iMyWidth + ",screenY=" + iMyHeight + ",scrollbars=no");
  	win2.focus();
  	
	}

}


// Layer Noitce Window

  function findObj(n, d) {
    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=findObj(n,d.layers[i].document); return x;
  }

  function showHideLayers() {
    var i,p,v,obj,args=showHideLayers.arguments;
    for (i=0; i<(args.length-2); i+=3) if ((obj=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 LayerNotice(PopupWindowName, NoticeURL, top, left, width, height, expiredays) {

    if ( getCookie( PopupWindowName ) != "DontOpenPopupWindowCookie" ) {
      document.write("<div id='oDiv' style='cursor:move; position:absolute; top:" + top +"px; left:" + left + "px; width:" + width + "px; height:" + height +"px; z-index:2;visibility: visible;'  onmouseout='fnStopMove()' onmouseup='fnStopMove()' onmousemove='fnMove()' onmousedown='fnStartMove()'>");
      document.write("<div align=right><img src=\"http://www.ndsl.or.kr/eng/notice/image/close(layer).gif\" style='CURSOR:hand' onClick=showHideLayers('oDiv','','hide') align=right><br><br></div>");
      document.write("<IFRAME WIDTH="+ width +" HEIGHT="+ height +" NORESIZE SCROLLING=No FRAMEBORDER=0 MARGINHEIGHT=0 MARGINWIDTH=0 SRC='"+ NoticeURL +"'></iframe>");
      document.write("<img src=\"http://www.ndsl.or.kr/eng/notice/image/dontshownext(layer).gif\" border=0 style=cursor:hand\
        onClick=\"setCookie('" + PopupWindowName +" ','DontOpenPopupWindowCookie'," + expiredays + "); showHideLayers('oDiv','','hide'); \
        \" align=right >");
      document.write("</div>");
    }

  }
  
  
// Movable layer

  function fnStartMove() 
  { 
    oDiv.adjustX=event.clientX - oDiv.offsetLeft;
    oDiv.adjustY=event.clientY - oDiv.offsetTop;
    oDiv.moving=true;
  } 

  function fnStopMove() 
  {
  	oDiv.moving=false; 
  } 

  function fnMove() 
  {
  	if(oDiv.moving==true)
  	{
  		if(event.clientX - oDiv.adjustX>0)
  		{ 
  			oDiv.style.left=event.clientX - oDiv.adjustX;
  		}
  		if(event.clientY - oDiv.adjustY>0)
  		{
  			oDiv.style.top=event.clientY - oDiv.adjustY;
  		}
  	}
  } 

  function fnUpdate() 
  {
  	iOffset=parseInt(oOffset.value);
  }
  
  // example
  // <body><DIV ID="oDiv" STYLE="cursor: move;" onmouseout="fnStopMove()" onmouseup="fnStopMove()" onmousemove="fnMove()" onmousedown="fnStartMove()">ÀÌµ¿ÇØº¸¼¼¿ä</DIV>
