/*
NS6.0,Mozilla 1.5,IE 5.0 이상 DOM LEVEL 1,2로 제작
Microsoft Internet Explorer 5.0 1999 DOM1 (2) JavaScript 1.3 (JScript 5.0) - ECMA
Netscape Navigator 6 2000 DOM1/DOM2 (1) (2) JavaScript 1.5(1) - ECMA
 * script by IEZN
 * 마지막 수정일 : 2003.7.17
 */
var userAgent = navigator.userAgent;
var ie =(document.all && document.getElementById) ? true : false;
var ns =(!document.all && document.getElementById) ? true : false;
if(ie == false){
   //location.href='/ieznApp/app/lib/old_browser.php';//브라우져가 버전이하면 버전 업그레이드 권고 페이지로 이동한다.
   //exit;
   // && ns==false
}
var domain= app_domain;//멀티도메인
var nowTime = new Date();
nowTime.setTime(nowTime.getTime() + 365 * 24 * 60 * 60);
function setCookie(name, value, expires, path, domain){if(!path) path="/";document.cookie = name + "=" + escape(value) +((expires == null) ? "" : "; expires=" + nowTime.toGMTString()) +((path == null) ? "" : "; path=" + path) +((domain == null) ? "" : "; domain=" + domain);}
function delCookie(name){if(getCookie(name)){document.cookie = name + "=" + "; expires=Thu, 01-Jan-70 00:00:01 GMT" + ";path=/";}}
function getCookie(name) {
   var cookies=document.cookie.split('; ')
   if (document.cookie=='') cookies.length=0
   for (var i=0;i<cookies.length;i++)
      if (cookies[i].indexOf(name+'=')==0) {
         var value=unescape(cookies[i].split('=')[1])
         return isNaN(value)?value:parseInt(value)
      }
   return null
}
function getCookieVal(offset){var endstr = document.cookie.indexOf(";", offset);if(endstr == - 1){ endstr = document.cookie.length;}return unescape(document.cookie.substring(offset, endstr));}
function getX(obj){return(obj.offsetParent == null ? obj.offsetLeft : obj.offsetLeft + getX(obj.offsetParent));}
function getY(obj){return(obj.offsetParent == null ? obj.offsetTop : obj.offsetTop + getY(obj.offsetParent));}
function center_x(){return(ie)? page_width() /2 -130 + document.body.scrollLeft:page_width()/ 2 - 170 + window.pageXOffset;}
function center_y(){return(ie)? page_height()/2 + document.documentElement.scrollTop:page_height()/ 2 - 170 + window.pageYOffset;}

function center_page_x(){return (page_width()+scrollLeft())/2;}
function center_page_y(){return (page_height()+scrollTop())/2}

function page_eventX(){return(ie)? mouseX + document.body.scrollLeft : mouseX + window.pageXOffset;}
function page_eventY(){return(ie)? mouseY + document.body.scrollTop : mouseY + window.pageYOffset;}

function scrollTop(){//이하 xhtml 에 doctype에 따른 패치
	if (window.pageYOffset){
		scroll_top = window.pageYOffset
	}else if (document.documentElement && document.documentElement.scrollTop){
		scroll_top = document.documentElement.scrollTop
	}else if (document.body){
		scroll_top = document.body.scrollTop
	}
	return scroll_top;
}
function scrollLeft(){
	if (window.pageXOffset){
		scroll_left = window.pageXOffset
	}else if (document.documentElement && document.documentElement.scrollLeft){
		scroll_left = document.documentElement.scrollLeft
	}else if (document.body){
		scroll_left = document.body.scrollLeft
	}
	return scroll_left;
}
function page_width(){
	if (window.innerWidth){
		width = window.innerWidth
	}else if (document.documentElement && document.documentElement.clientWidth){
		width = document.documentElement.clientWidth
	}else if (document.body){
		width = document.body.clientWidth
	}
	return width;
}
function page_height(){
	if (window.innerHeight){
		height = window.innerHeight
	}else if (document.documentElement && document.documentElement.clientHeight){
		height = document.documentElement.clientHeight
	}else if (document.body){
		height = document.body.clientHeight
	}
	return height;
}


IEZN_SESS = getCookie("PHPSESSID");

function getElement(id) {
	return document.getElementById ? document.getElementById(id) :
	document.all ? document.all(id) : null;
}

var openPop = new Array();
//팝업배열생성
//팝업이벤트제어
function ieznInit(e){
   if(openPop.length > 0){
		for(i = 0; i < openPop.length; i++){
			try{
				if(typeof(openPop[i])!='defined' && openPop[i].closed == false){
					openPop[i].focus();
				}else {
					openPop[i] = '';
				}
			}catch(e){}
		}
   }else {
      if(document.addEventListener){
         //ns
         document.removeEventListener("focus", ieznInit, true);
      }else if(document.detachEvent){
         //ie
         document.detachEvent("onmousedown", ieznInit);
         window.detachEvent("onfocus", ieznInit);
      }
   }
}

//언로드 이벤트
function cPop(){
	loadJs(http_app_path+'/modules/iezn_member_now_login/onunload.php');
	if(openPop.length > 0){
		try{
			for(i = 0; i < openPop.length; i++){
				if(openPop[i].closed == false){
					openPop[i].self.close();
				}else{
					openPop[i] = '';
				}
			}
		}catch(e){}
		if(document.addEventListener){
			document.removeEventListener("focus", ieznInit, true);
		}else if(document.detachEvent){
			document.detachEvent("onmousedown", ieznInit);
			window.detachEvent("onfocus", ieznInit);
		}
	}
}
//
//윈도우 오픈 함수
function open_window(href,popup_name, w, h, scroll, x, y,modal)
{
	if (! window.focus)return true;
	var x =(!x) ?(screen.width - w)/2 : x;
	var y =(!y) ?(screen.height - h)/2 : y;
	if(window.showModalDialog && modal==1){
		window.showModalDialog(href,window,"dialogWidth:"+w+"px;dialogHeight:"+h+"px;scroll:"+scroll+";center:yes;resizeable:no;status:no;help:no");
	}else{
		wp = 'height=' + h + ',width=' + w + ',left=' + x + ',top=' + y + ',scrollbars=' + scroll + ',resizable=no,status=no';
		n = openPop.length;
		if(popup_name=='article_change'){
			openPop[n] = window.open(href,popup_name, wp);
		}else{
			openPop[n] = window.open(href,'_blank', wp);
		}
		if(openPop.length == 1){
			if(document.addEventListener){
				document.addEventListener("focus", ieznInit, true);
			}else if(document.attachEvent){
				document.attachEvent("onmousedown", ieznInit);
				window.attachEvent("onfocus", ieznInit);
			}
		}
		return openPop[n];
	}
}

function loadJs(file)
{
   script = document.createElement('script');
   script.src = file;
   script.type = 'text/javascript';
   script.id = 'loadScript';
   document.body.appendChild(script);
}

function resize_textarea(obj, row, min_rows, max_rows){
   if(obj.rows + row >= min_rows && obj.rows + row <= max_rows){
      obj.rows += row;
   }
}

//메세지 체인지
function waitBoxView(msg){
	if(ns) return true;
	layerShow('waitBox');
	layerShow('divBg');
	center('waitBox');
	center('divBg');
	//로딩창 실행
	if(ie==true){
		document.all['message_box'].SetVariable("LOOP","true");
		document.all['message_box'].SetVariable("message",msg);
		document.all['message_box'].TPlay("loadBarMov");
	}else{
		if(window.document.message_box){
			window.document.message_box.SetVariable("LOOP","true");
			window.document.message_box.SetVariable("message",msg);
			window.document.message_box.TPlay("loadBarMov");
		}
	}
	document.getElementById("divBg").focus();
}

function waitBoxHide(){
	try{
		layerHide('waitBox');
		layerHide('divBg');
	}catch(e){}
}


//레이어 하이드
function layerHide(lay){try{document.getElementById(lay).style.display = "none";}catch(e){}}
function layerShow(lay){try{document.getElementById(lay).style.display = "inline";}catch(e){}}

//키 이벤트 캡춰
var KeyPress;
function capturekey()
{
   if(ns || num)
   return;
   var tag = event.srcElement.tagName;
   KeyPress = parent.PHPSESSID;
   if(tag == 'TEXTAREA' || tag == 'TEXT')
   {
      //textarea check
      if(event.keyCode == 10)
      {
         if(!blank_check_null('내용', event.srcElement, 2, 102400))
         return false;
         if(!wordFilter('내용', event.srcElement))
         return false;
         if(getCookie('ld') == 1)
         {
            event.srcElement.form.submit();
            //crtl + enter = submit 
         }
      }
   }
}

function autoPubDeny()
{
   var KeyPress = getCookie('PHPSESSID');
}
//document.onkeypress = capturekey;

//자스브라우져에러제어

function f()
{
   return true;
}
//window.onerror = f;

function hre(h){location.href=h;}
window.onunload=cPop;


//이미지 리사이즈
function image_resize(obj,w){
	img = new Image();
	img.src = obj.src;
	if(img.width>w){
		while(!obj.style.width){
			obj.style.width = w+'px';
		}
		obj.style.cursor='pointer';
		addEvent(obj,"click",function(){popup_window(obj.src)},true);
		obj.setAttribute("title","이미지를 클릭하시면 큰 이미지를 보실 수 있습니다");
	}
}


//이미지 팝업
function popup_window(src){
	img = new Image();
	img.src = src;
	if(!img.width){
		return true;
	}
	if(!document.all) {//ns
		img.width+=0;
		img.height+=9;
	}
	if(img.height>700){
		ww = 800;
		wh = 600;
	}else{
		ww = img.width;
		wh = img.height;
	}
	open_window("about:blank","_blank",ww,wh,'no',0,0);
	n = openPop.length-1;
	htm = "<html><title>ieznbuilder image viewer</title><head>"
	+"<style>a:link,a:visited,a:hover{text-decoration:none;color:#0A246A}</style>"
	+"<script>o_width="+img.width+"</script>"
	+"<script>o_height="+img.height+"</script>"
	+"<script>function winscroll(e){var posx;var posy;if(navigator.userAgent.indexOf('MSIE') == -1 ){posx = e.pageX - document.body.scrollLeft - 150;posy = e.pageY - document.body.scrollTop - 150;}else{posx=e.clientX-400;posy=e.clientY-300;}posx*=2;posy*=2;window.scroll(posx,posy);document.getElementById('menu').style.left=document.body.scrollLeft+'px';document.getElementById('menu').style.top=document.body.scrollTop+'px';}</script>"
	+"<script>function fit_img(){if(o_width>o_height){document.getElementById('main_img').style.width=document.body.clientWidth}else{document.getElementById('main_img').style.height=document.body.clientHeight}}</script>"
	+"<script>function fit_zoom(){document.getElementById('main_img').style.width=o_width+'px';document.getElementById('main_img').style.height=o_height+'px'}</script>"
	+"</head><body topmargin=0 leftmargin=0>"
	+"<div id=menu style='margin:8px;width:170px;top:4px;left:4px;text-align:center;diaplay:block;border:1px #000000 solid;float:right;padding:4px;font-size:9pt;position:absolute;background-color:#FFFFFF;margin:4px;filter:alpha(opacity=100)'><a href=javascript:window.close()>닫기</a> | <a href=javascript:fit_img()>전체보기</a> | <a href=javascript:fit_zoom()>확대보기</a></div>"
	+"<div onmousemove='winscroll(event)'><img id=main_img src="+src+"></div></body></html>";
	openPop[n].document.write(htm);
	addEvent(openPop[n],'click',function(){self.widhow.close()});
}




/** 화면 스크립의 중앙 **/
function center(id) {
	try{

		obj = getElement(id);
		if (obj && obj.style) {
			x = center_page_x() - obj.offsetWidth/2;
			y = center_page_y() + obj.offsetHeight;
			obj.style.left = x+'px';
			obj.style.top = y+'px';
		}
	}catch(e){}
}

function goHref(q){
	location.href='index.php?idx='+idx+'&g_num='+g_num+'&gs_num='+gs_num+'&now='+now+'&'+q;
}

function addEvent(obj,evType,fnc,useCapture){ 
	if (obj.addEventListener){ 
		obj.addEventListener(evType,fnc,useCapture); 
		return true; 
	}else if(obj.attachEvent){ 
		var r = obj.attachEvent("on"+evType,fnc); 
		return r; 
	} 
}

function delEvent(obj,evType,fnc,useCapture){
	if(document.addEventListener){
		document.removeEventListener(evType,fnc,useCapture);
	}else if(document.detachEvent){
		document.detachEvent("onmousedown",fnc);
		window.detachEvent("on"+evType,fnc);
	}
}

function createIframe(src,layId){
	fI = document.createElement("iframe");
	fI.setAttribute("src",src);
	fI.style.width='100%';
	addEvent(fI,'load',function(){insertIt(layId)},true);
	document.getElementById(layId).appendChild(fI);
}

function insertIt(layId) { 
	var _y = document.getElementById(layId); 
	var _x = window.frames[0].document.body.innerHTML; 
	_y.innerHTML = _x 
} 

function image_error(obj,s){
	obj.src=s;
}

function common_onclick_function(e){
	eObj = (ie)? event.srcElement:e.target;
	if(document.getElementById('cp') && document.getElementById('cp').style.display == "inline"){
		document.getElementById('cp').style.display = "none";
	}
	if(eObj.tagName!='A'){
		if(userMenuShowVar==1){
			userMenuHide();
		}
	}
}

if (document.layers)
  document.captureEvents(Event.MOUSEUP);
if (document.layers || document.all)
  document.onmouseup = common_onclick_function;
if (document.addEventListener)
  document.addEventListener('mouseup', common_onclick_function, true);

function whois(ip){
	open_window("modules/common/whois.php?ip="+ip,'whois',600,600,'yes');
}

