// TNT스쿨 기본 자바스크립트

//마우스롤오버
function over_img(pPath, pName){
document.images[pName].src = pPath;
}
function out_img(pPath, pName){
document.images[pName].src = pPath;
}

//윈도우오픈
function MM_openBrWindow(theURL,winName,features) { //v2.0
window.open(theURL,winName,features);
}

function Class_Register(obj,val){
var count=0;
var fobj = document.MemberCLass;
var obj = document.getElementsByName("chk[]");
for(i=0;i<obj.length;i++) {
if(obj[i].checked)
count++;
}
if(count != 0){
if(confirm('정말 수정하시겠습니까?')); else return false;
fobj.mode.value = val;
fobj.submit();
return true;
}else{
alert('최소 1개는\n선택해야합니다.');
return false;
}
}
function do_resize() {
resizeFrame("iframe_main2",1);
}

function resizeFrame(ifr_id,re){
//가로길이는 유동적인 경우가 드물기 때문에 주석처리!
var ifr= document.getElementById(ifr_id) ;
var innerBody = ifr.contentWindow.document.body;
var innerHeight = innerBody.scrollHeight + (innerBody.offsetHeight - innerBody.clientHeight);
//var innerWidth = document.body.scrollWidth + (document.body.offsetWidth - document.body.clientWidth);

if (ifr.style.height != innerHeight) //주석제거시 다음 구문으로 교체 -> if (ifr.style.height != innerHeight || ifr.style.width != innerWidth)
{
ifr.style.height = innerHeight;
//ifr.style.width = innerWidth;
}

if(!re) {
try{
innerBody.attachEvent('onclick',parent.do_resize);
//innerBody.attachEvent('onkeyup',parent.do_resize);
//글작성 상황에서 클릭없이 타이핑하면서 창이 늘어나는 상황이면 윗줄 주석제거
} catch(e) {
innerBody.addEventListener("click", parent.do_resize, false);
//innerBody.addEventListener("keyup", parent.do_resize, false);
//글작성 상황에서 클릭없이 타이핑하면서 창이 늘어나는 상황이면 윗줄 주석제거
}
}
}

isIE=document.all;
isNN=!document.all&&document.getElementById;
isN4=document.layers;
isHot=false;
function ddInit(e){
 topDog=isIE ? "BODY" : "HTML";
 whichDog=isIE ? document.all.popWindow : document.getElementById("popWindow");
 hotDog=isIE ? event.srcElement : e.target;
 while (hotDog.id!="popWindow"&&hotDog.tagName!=topDog){
  hotDog=isIE ? hotDog.parentElement : hotDog.parentNode;
 }
 if (hotDog.id=="popWindow"){
  offsetx=isIE ? event.clientX : e.clientX;
  offsety=isIE ? event.clientY : e.clientY;
  nowX=parseInt(whichDog.style.left);
  nowY=parseInt(whichDog.style.top);
  ddEnabled=true;
  document.onmousemove=dd;
 }
}
function dd(e){
 if (!ddEnabled) return;
 whichDog.style.left=isIE ? nowX+event.clientX-offsetx : nowX+e.clientX-offsetx;
 whichDog.style.top=isIE ? nowY+event.clientY-offsety : nowY+e.clientY-offsety;
 return false;
}
document.onmousedown=ddInit;
document.onmouseup=Function("ddEnabled=false");

function ddN4(whatDog){
  if (!isN4) return;
  N4=eval(whatDog);
  N4.captureEvents(Event.MOUSEDOWN|Event.MOUSEUP);
  N4.onmousedown=function(e){
    N4.captureEvents(Event.MOUSEMOVE);
    N4x=e.x;
    N4y=e.y;
  }
  N4.onmousemove=function(e){
    if (isHot){
      N4.moveBy(e.x-N4x,e.y-N4y);
      return false;
    }
  }
  N4.onmouseup=function(){
    N4.releaseEvents(Event.MOUSEMOVE);
  }
}

function hideMe(){
  if (isIE||isNN) whichDog.style.visibility="hidden";
  else if (isN4) document.popWindow.visibility="hide";
}

function showMe(v){
  if (isIE||isNN){
	  whichDog.style.visibility="";
	  document.pop_diary.day_date.value=v;
  }
else if (isN4){ document.popWindow.visibility="";
}
}

document.onmousedown=ddInit;
document.onmouseup=Function("ddEnabled=false");

function notice_setCookie( name, value, expiredays )
{
        var todayDate = new Date();
        todayDate.setDate( todayDate.getDate() + expiredays );
        document.cookie = name + '=' + escape( value ) + '; path=/; expires=' + todayDate.toGMTString() + ';'
 return;
}
function notice_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 "";
}