/*
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 page_width(){return(ns)? innerWidth : document.body.clientWidth;}
function page_height(){return(ns)? innerHeight : document.body.clientHeight;}
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 document.body && document.body.clientWidth ? document.body.clientWidth/2:window.innerWidth ? innerWidth/2 : null;}
function center_page_y(){
return document.body && document.body.clientHeight ? document.body.clientHeight/2 :
window.innerHeight? innerHeight/2 : null;
}
function page_eventX(e){alert(e.pageX);return(ie)? event.clientX + document.body.scrollLeft : e.pageX + window.pageXOffset;}
function page_eventY(e){return(ie)? event.clientY + document.body.scrollTop : e.pageY + window.pageYOffset;}
function scrollTop(){return(ie)? document.body.scrollTop : window.pageYOffset;}
function scrollLeft(){return(ie)? document.body.scrollLeft : window.pageXOffset;}
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++){
			if(openPop[i].closed == false){
				openPop[i].focus();
			}else {
				openPop[i] = '';
			}
		}
   }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){

		for(i = 0; i < openPop.length; i++){
			if(openPop[i].closed == false){
				openPop[i].self.close();
			}else{
				openPop[i] = '';
			}
		}
		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)
{
	if (! window.focus)return true;
	var x =(!x) ?(screen.width - w)/2 : x;
	var y =(!y) ?(screen.height - h)/2 : y;
	wp = 'height=' + h + ',width=' + w + ',left=' + x + ',top=' + y + ',scrollbars=' + scroll + ',resizable=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);
		}
	}
}

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("message",msg);
			window.document.message_box.TPlay("loadBarMov");
		}
	}
	document.getElementById("divBg").focus();
}

//·¹ÀÌ¾î ÇÏÀÌµå
function layerHide(lay){document.getElementById(lay).style.display = "none";}
function layerShow(lay){document.getElementById(lay).style.display = "inline";}

//Å° ÀÌº¥Æ® Ä¸Ãç
var KeyPress;
function capturekey()
{
   if(ns)
   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 ieznSwf(){

	document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="1" height="1" id="ieznSwf" align="middle">');
	document.write('<param name="allowScriptAccess" value="sameDomain" />');
	document.write('<param name="Copyright" value="iezn.com">');
	document.write('<param name="wmode" value="transparent">'); 
	document.write('<param name="movie" value="'+http_app_path+'/flash/ieznSwf.swf" />');
	document.write('<param name="quality" value="high" />');
	document.write('<param name="play" value="false" />');
	document.write('<param name="debug" value="1" />');
	document.write('<param name="FlashVars" value="IEZN_SESS='+IEZN_SESS+'&rpc_file='+rpc_file+'">');
	document.write('<param name="loop" value="false" />');
	document.write('<param name="bgcolor" value="#ffffff" />');
	document.write('<embed src="'+http_app_path+'/flash/ieznSwf.swf" FlashVars="IEZN_SESS='+getCookie("IEZN_SESS")+'&rpc_file='+rpc_file+'" quality="high" bgcolor="#ffffff" width="1" height="1" name="ieznSwf" align="middle" allowScriptAccess="sameDomain" wmode="transparent" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />');
	document.write('</object>');
}
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';
		}
		if(document.all){
			obj["onclick"] = new Function("popup_window(this.src);");
		}else{
			obj.setAttribute("onclick","popup_window(this.src)");
		}
		obj.style.cursor='pointer';
	}
}

//ÀÌ¹ÌÁö ÆË¾÷
function popup_window(src){
	img = new Image();
	img.src = src;
	if(!img.width){
		alert('ÀÌ¹ÌÁö ÆÄÀÏÀÌ ¾Æ´Õ´Ï´Ù');
		return false;
	}
	if(ns) {
		//img.width+=18;
		//img.height+=3;
	}
	open_window("about:blank","_blank",img.width,img.height,'no',0,0);
	n = openPop.length-1;
	openPop[n].document.write("<title>ieznbuilder image viewer</title><body topmargin=0 leftmargin=0><img alt='Ã¢À» ´Ý½À´Ï´Ù' src="+src+" style=cursor:pointer onclick=window.close()>");
	openPop[n]["onclick"] = new Function("self.window.close();");
}


function center(id) {
	obj = getElement(id);
	if (obj && obj.style) {
		x = center_page_x();
		y = center_page_y();
		if (x && y) {
			obj.style.left = x - obj.offsetWidth/2 + 'px';
			obj.style.top = y - obj.offsetHeight/2 + 'px';
		}
	}
}