function open_popup(size1, size2) {
   if ( getCookie( "open_popup" ) != "done" ) {
      window.open('./../navigator.php?contents=popup', 'open_popup', 'scrollbars=1, width=' + size1 + ', height=' + size2);
   }
}

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.forms[0].Notice.checked ) { setCookie( "open_popup", "done" , 1); }
   self.close(); 
}

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 viewimage(image, width, height) {
   var sheight = screen.height - 100; 
   var swidth  = screen.width - 100;
   if (sheight <= height) {
      scrollbar_tag1 = "yes";
      imageheight = sheight;
   }
   else {
      scrollbar_tag1 = "no";
      imageheight = height;
   }

   if (swidth <= width) {
      scrollbar_tag2 = "yes";
      imagewidth = swidth;
   }
   else {
      scrollbar_tag2 = "no";
      imagewidth = width;
   }
   
   scrollbar_tag = "no";
   
   if (scrollbar_tag1 == "yes" || scrollbar_tag2 == "yes") {
      scrollbar_tag = "yes";
   }

   viewwin = window.open('', '' , 'height=' + imageheight + ', width=' + imagewidth + ', scrollbars=' + scrollbar_tag)
   viewwin.document.open();
   viewwin.document.write('<title>이미지를 클릭하면 창이 닫힙니다.</title><body topmargin=0 leftmargin=0 marginwidth=0 marginheight=0><center><a href="javascript:self.close()"><img src="'+image+'" border=0 alt="이미지를 클릭하면 창이 닫힙니다."></a></center></body>')
   viewwin.document.close();
   var x = screen.width / 2 - viewwin.document.body.offsetWidth / 2;
   var y = screen.height / 2 - viewwin.document.body.offsetHeight / 2;
   viewwin.moveTo(x, y);
} 

function menuvisible(submenu, tdnum) {
   var bodywidth = document.all.bodytable.offsetWidth;
   var bodyleft  = document.all.bodytable.offsetLeft;
   var submenu_message = eval("submenutext" + submenu);

   var tdleft    = document.all.tdtopmenu[tdnum].offsetLeft;
   
//   alert(tdnum + tdleft);
   
   document.all.tdsubmenu.innerHTML = submenu_message;
   var mousepos = event.clientX + document.body.scrollLeft - bodyleft;
   var submenupos = document.all.tablesubmenu.offsetWidth;
   if (mousepos - (submenupos / 2) < 0) {
      document.all.divsubmenu.style.left = document.body.scrollLeft;
   }
   else if (mousepos + (submenupos) > bodywidth) {
      document.all.divsubmenu.style.left = bodywidth - submenupos;
   }
   else {
//      document.all.divsubmenu.style.left = mousepos - (submenupos / 2);
      document.all.divsubmenu.style.left = tdleft;
   }
}
