var HOST_PATH = ""
//운영자등록 중복확인
// 지정된 ID의 IFrame을 Close함, IFrame외부의 DIV의 DISPLAY를 NONE으로 바꿈.
function CloseIframe(id) {
	parent.document.getElementById(id).style.display="none";
}

function POPUPCLOSE(){
	document.getElementById("BLOG_JOIN_POPUP_01").style.display="none";
	document.getElementById("BLOG_JOIN_POPUP_02").style.display="none";
}

function openWindow(href, WinName, w, h, scroll, resize) {

	var PosLeft;
	var PosTop;

	PosLeft = (window.screen.width / 2) - (w / 2 + 10);
	PosTop = (window.screen.height / 2) - (h / 2 + 50);

	//scroll = 0;

	if(window.screen.width < w+10){
		PosLeft = 0;
		w = window.screen.width - 10;
		scroll = 1;
	}

	if(window.screen.height < h+60){
		PosTop = 0;

		if(window.screen.width > w+10){
			w +=15;
		}

		h = window.screen.height - 60;
		scroll = 1;
	}
	var winObj = window.open(href,WinName,"status=no, height=" + h + ",width=" + w + ", scrollbars=" + scroll + ",resizable=" + resize + ",left=" + PosLeft + ",top=" + PosTop + ",screenX=" + PosLeft + ",screenY=" + PosTop );
	if(chkSP2){
		if(document.domain!="localhost"){
			h+=20;
		}
	}
	winObj.onLoad = resizeWindowObj(winObj,w,h);
	winObj.focus();
	//return winObj;
}

function chkSP2() {
	if(window.navigator.userAgent.indexOf("SV1")) return true;
	else return false;
}

function resizeWindow(w,h) {
	appname = navigator.appName
	useragent = navigator.userAgent;

	if(appname == "Microsoft Internet Explorer") appname = "IE";
	win2000 = (useragent.indexOf('NT 5.0')>0);  //윈도우 2000 버전
	winxp = (useragent.indexOf('NT 5.1')>0);     //윈도우 xp 버전

	if(appname=="IE" && win2000){
		window.resizeTo(w,h);
	}else if (appname=="IE" && winxp){
		window.resizeTo(w,h + 50);
	}else{
		window.resizeTo(w,h);
	}
}


function resizeWindowObj(Obj,w,h) {
	appname = navigator.appName
	useragent = navigator.userAgent;

	if(appname == "Microsoft Internet Explorer") appname = "IE";
	win2000 = (useragent.indexOf('NT 5.0')>0);  //윈도우 2000 버전
	winxp = (useragent.indexOf('NT 5.1')>0);     //윈도우 xp 버전

	if(appname=="IE" && win2000){
		Obj.resizeTo(w,h);
	}else if (appname=="IE" && winxp){
		Obj.resizeTo(w,h + 50);
	}else{
		Obj.resizeTo(w,h);
	}
}

//popup창 띄우기
function NewPopup(url, l, t, w, h, s, r)
{
	NewPopupWin(url, "popup", l, t, w, h, s, r);
}

function NewPopupWin(url, n, l, t, w, h, s, r)
{
 opt = "left=" + l + ", top=" + t + ", width=" + w + ", height=" + h;
 opt = opt + ", toolbar=no,location=no,directories=no,status=no,menubar=no";
 opt = opt + ",scrollbars=" + s;
 opt = opt + ",resizable=" + r;
 var a = window.open(url,n, opt);
 a.focus();
}

//popup창 닫기

function popup_close(){
	self.close();
}

/* 내부 팝업 닫기  */
function closePopup() {
   	closeDiv('POPUP_NOTICE');
}


function POPUPCLOSE(id){
	document.getElementById(id).style.display = "none";
}

function getCookie(name) {
   var Found = false;
   var start, end;
   var i = 0;

   // cookie 문자열 전체를 검색
   while(i <= document.cookie.length) {
     start = i;
     end = start + name.length;
     // name과 동일한 문자가 있다면
     if(document.cookie.substring(start, end) == name) {
       Found = true;
       break;
     }
     i++;
   }

   // name 문자열을 cookie에서 찾았다면
   if(Found == true) {
     start = end + 1;
     end = document.cookie.indexOf(";", start);
     // 마지막 부분이라는 것을 의미(마지막에는 ";"가 없다)
     if(end < start)
     end = document.cookie.length
     // name에 해당하는 value값을 추출하여 리턴한다.
     return document.cookie.substring(start, end);
   }
   // 찾지 못했다면
   return "";
}
var topleft = 1;
function openPopup(index) {
	var cookname = "grppopup"+index;
	var eventCookie=getCookie(cookname);
	if (eventCookie != "no"){
		window.open(HOST_PATH+'/main/popNotice.jsp?pIndex='+index,cookname,'width=470,height=520,top='+(50*topleft)+',left='+(100*topleft));
		topleft++;
	}	
}

function goPopupPreview(index) {
	window.open(HOST_PATH+'/main/popNotice.jsp?status=1&pIndex='+index,'_blank','width=470,height=520,top=50,left=150'); 
}
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(index) { 
	if ( document.myform.event.checked ){ 
		var cookname = "grppopup"+index;
		setCookie(cookname, "no" , 1); // 1일 간 쿠키적용
	} 
}

