//-- 중복 실행 방지
if (!ZIUMSOFT_JS) {
    var ZIUMSOFT_JS = true;

	//-- browser detectvar ------------------------------------------------------------------------
	browser = (function(){
		var a = navigator.userAgent.toLowerCase();
		var b,v;

		if(a.indexOf("safari/") > -1) {
			b = "safari";
			var s = a.indexOf("version/");
			var l = a.indexOf(" ", s);
			v = a.substring(s+8, l);
		}
		if(a.indexOf("chrome/") > -1) {
			b = "chrome";
			var ver = /[ \/]([\w.]+)/.exec(a)||[];
			v = ver[1];
		}
		if(a.indexOf("firefox/") > -1) {
			b = "firefox";
			var ver = /(?:.*? rv:([\w.]+)|)/.exec(a)||[];
			v = ver[1];
		}
		if(a.indexOf("opera/") > -1) {
			b = "opera";
			var ver = /(?:.*version|)[ \/]([\w.]+)/.exec(a)||[];
			v = ver[1];
		}
		if((a.indexOf("msie") > -1) || (a.indexOf(".net") > -1)) {
			b = "msie";
			var ver = /(?:.*? rv:([\w.]+))?/.exec(a)||[];
			if(ver[1])
				v = ver[1];
			else{
				var s = a.indexOf("msie");
				var l = a.indexOf(".", s);
				v = a.substring(s+4, l);
			}
		}
		return { name: b || "", version: v || 0};
	}());

	//-- 페이지 이동 ------------------------------------------------------------------------------
	function zm_gourl(url) {
		if(url)
			document.location.href	= url;
		else
			return false;
	}

	//-- iframe 객체 생성 -------------------------------------------------------------------------
	function zm_get_iframe(id){
		if(!id) return false;

		try{
			frame = document.createElement("<IFRAME id="+id+" frameborder=0 scrolling=no>");
		}catch(e){
			frame = document.createElement("IFRAME");
			frame.setAttribute("id", id);
		}

		return frame;
	}

	//-- 쿠키 쓰기 --------------------------------------------------------------------------------
	function zm_set_cookie(c_name,value,exdays){
		var exdate = new Date();
		exdate.setDate(exdate.getDate() + exdays);
		var c_value=escape(value) + ((exdays==null) ? "" : "; expires="+exdate.toUTCString());
		document.cookie=c_name + "=" + c_value;
	}

	//-- 쿠키 읽기 --------------------------------------------------------------------------------
	function zm_get_cookie(c_name){
		var i, x, y, ARRcookies = document.cookie.split(";");

		for (i = 0; i < ARRcookies.length; i++){
			x = ARRcookies[i].substr(0,ARRcookies[i].indexOf("="));
			y = ARRcookies[i].substr(ARRcookies[i].indexOf("=")+1);
			x = x.replace(/^\s+|\s+$/g,"");
			
			if (x == c_name) {
				return unescape(y);
			}
		}
	}

	//-- dok.do 짧은 주소 창. 2014. 01 서비스 중지 됨. 자금난 ㅠㅠ ----------------------------------------
	function dokdo_url(longurl) {
		if(!longurl) return;

		var url = g4_path + "/zm.extend/dok.do.url.php?lurl=" +  longurl;

		window.open(url, "dok_do", "width=500, height=300, toolbar=0, scrollbars=0, resize=0");
	}
	//-- 주소 복사 ------------------------------------------------------------------------------------
	function uri_copy(longuri){
		if(browser.name == "msie") {
			window.clipboardData.setData('text', longuri);
			zm_alert("주소를 복사 했습니다. <br>Ctrl + V로 붙여넣기 할 수 있습니다.");
		}else{
			pmt	= prompt("짧은 주소입니다. Ctrl + C로 복사하세요.", longuri);
		}

		return;
	}


	//-- 레이어 팝업 -----------------------------------------------------------------------------------
	var s_layer_info	= "";
		s_layer_info	+= "<style>";
		s_layer_info	+= ".layer {display:none; position:fixed; _position:absolute; top:0; left:0; width:100%; height:100%; z-index:100;}";
		s_layer_info	+= ".layer .bg {position:absolute; top:0; left:0; width:100%; height:100%; background:#000; opacity:.5; filter:alpha(opacity=50);}";
		s_layer_info	+= ".layer .pop-layer {display:block;}";

		s_layer_info	+= ".pop-layer {display:none; position: absolute; top:50%; left:50%; width:410px; max-width:100%; height:auto; background-color:#fff; border:5px solid #3399FF; z-index:10;}";
		s_layer_info	+= ".pop-layer .pop-container {padding: 20px 15px; word-break:break-all; }";
		s_layer_info	+= ".pop-layer p.ctxt {color: #101010; line-height: 25px;}";
		s_layer_info	+= ".pop-layer .btn-r {width:100%; margin:10px 0 10px; padding-top:10px; border-top:1px solid #DDD; text-align:right;}";

		s_layer_info	+= "a.cbtn {display:inline-block; font-family:Dotum; height:25px; padding:0 14px 0; border:1px solid #787878; background-color:#EFEFEF; font-size:13px; line-height:25px;}";
		s_layer_info	+= "a.cbtn:hover {border: 1px solid #283810; background-color:#3399FF; color:#fff;}";
		s_layer_info	+= "</style>";

		s_layer_info	+= "<div class='layer'>";
		s_layer_info	+= "<div class='bg'></div>";
		s_layer_info	+= "<div id='layer2' class='pop-layer'>";
		s_layer_info	+= "<div class='pop-container'>";
		s_layer_info	+= "	<div class='pop-conts'>";
		s_layer_info	+= "		<p class='ctxt mb20' id='zm_layer_popup'></p>";

		s_layer_info	+= "		<div class='btn-r'>";
		s_layer_info	+= "			<a href='#' class='cbtn'>닫기</a>";
		s_layer_info	+= "		</div>";
		s_layer_info	+= "	</div>";
		s_layer_info	+= "</div>";
		s_layer_info	+= "</div>";
		s_layer_info	+= "</div>";
	document.write(s_layer_info);

	function zm_alert(txt_msg){
		$("#zm_layer_popup").html(txt_msg);	
	
		var temp = $('#layer2');
		var bg = temp.prev().hasClass('bg');	//dimmed 레이어를 감지하기 위한 boolean 변수

		if(bg){
			$('.layer').fadeIn();	//'bg' 클래스가 존재하면 레이어가 나타나고 배경은 dimmed 된다. 
		}else{
			temp.fadeIn();
		}

		// 화면의 중앙에 레이어를 띄운다.
		if (temp.outerHeight() < $(document).height() ) temp.css('margin-top', '-'+temp.outerHeight()/2+'px');
		else temp.css('top', '0px');
		if (temp.outerWidth() < $(document).width() ) temp.css('margin-left', '-'+temp.outerWidth()/2+'px');
		else temp.css('left', '0px');

		temp.find('a.cbtn').click(function(e){
			if(bg){
				$('.layer').fadeOut(); //'bg' 클래스가 존재하면 레이어를 사라지게 한다. 
			}else{
				temp.fadeOut();
			}
			e.preventDefault();
		});

		$('.layer .bg').click(function(e){	//배경을 클릭하면 레이어를 사라지게 하는 이벤트 핸들러
			//$('.layer').fadeOut();
			//e.preventDefault();
		});

	}

	
}	//-- end ZIUMSOFT_JS