/* ============================================================================
 * File Name	: em005.js
 * Description	: ÆË¾÷Ã¢/ºê¶ó¿ìÀú°ü·Ã ÇÔ¼ö
 * Author		: ±èÇö¼ö
 * Create Date	: 2004-03-03
 * History		:
 *	- 2004-03-03, ±èÇö¼ö	 : ÃÊ±âÀÛ¼º
 ============================================================================*/

// BrowserÀÇ Á¾·ù¸¦ ±¸ÇØ ÇØ´ç »ó¼ö·Î ¹ÝÈ¯
function typeOfNavigator(){
	var naviVer = navigator.appVersion;
	if (navigator.userAgent.indexOf("MSIE") != -1) {
		naviVer = naviVer.substring(naviVer.indexOf("MSIE") + 5, naviVer.indexOf("MSIE") + 6);
		if (naviVer == 3) return IE3;
		if (naviVer == 4) return IE4;
		if (naviVer == 5) return IE5;
		if (naviVer == 6) return IE6;
		if (naviVer == 7) return IE7;
	}else{
		naviVer = naviVer.substring(0, 1);
		if (naviVer == 3) return NS3;
		if (naviVer == 4) return NS4;
    }
}

// ÆË¾÷Ã¢ È£Ãâ
//	- url			: ÆË¾÷ÆäÀÌÁö ÁÖ¼Ò
//	- popupProperty	: ÆË¾÷ ¼Ó¼º
//	- isFull		: Full Screen À¯¹«
//	- popupName		: ÆË¾÷ÀÌ¸§
function popupWindow(url, popupProperty, isFull, popupName){
	if(!popupProperty){
		popupProperty = "width=368, height=150";
	}

	if(isFull)		popupProperty = "fullscreen=3, " + popupProperty;		// full screen
	if(!popupName)	popupName = "_blank";									// ÆË¾÷Ã¢ ÀÌ¸§

	var popup = window.open(url, popupName, popupProperty);
	popup.focus();
}

// ¸ð´ÞÃ¢ È£Ãâ
//	- url		: °æ·Î
//	- width		: ³Êºñ
//	- height	: ³ôÀÌ
//	- iargs		: Parametes
function modalWindow(url, width, height, iargs){
	if(!url){	alert("Àß¸øµÈ ÁÖ¼ÒÀÔ´Ï´Ù"); return null;}
	if(!width)	width = 455;
	if(!height)	height = 265;

	var path = getFilePath();

	var rtn_val = window.showModalDialog(PAGE_MODALWINDOW + "?page=" + path + url, iargs, "help:no;status:no;dialogWidth:" + width + "px;dialogHeight:" + height + "px");
	return rtn_val;
}

function modalWindowEx(url, width, height, iargs){
	if(!url){	alert("Àß¸øµÈ ÁÖ¼ÒÀÔ´Ï´Ù"); return null;}
	if(!width)	width = 455;
	if(!height)	height = 265;

	var path = getFilePath();

	var rtn_val = window.showModalDialog(PAGE_MODALWINDOW + "?page=" + url, iargs, "help:no;status:no;dialogWidth:" + width + "px;dialogHeight:" + height + "px");
	return rtn_val;
}

function modalReload(){
	location.href = location.href;
}

// ÀÌ¹ÌÁö¸¦ ÆË¾÷Ã¢À¸·Î º¸±â
//	- url : ÀÌ¹ÌÁö °æ·Î
function viewPicture(url){
	var url		= PAGE_VIEW_IMG + "?url=" + url;
	var pics	= window.open(url, pics, "width=350, height=350");
	pics.focus();
}

// ÆË¾÷Ã¢ ´Ý±â
//	- str			: Ã¢ÀÇ Á¾·ù
//	- opnerReload	: ºÎ¸ðÃ¢ »õ·Î°íÄ§ ¿©ºÎ
function windowClose(str, openerReload){
	if(openerReload) openerReload = true;
	if(str){
		if(confirm("\"" + str + "\"À» Ãë¼ÒÇÏ½Ã°Ú½À´Ï±î?\n\nÃë¼ÒÇÏ½Ã·Á¸é [È®ÀÎ]¹öÆ°À» ±×·¸Áö ¾Ê´Ù¸é [Ãë¼Ò]¹öÆ°À» ´­·¯ÁÖ½Ê½Ã¿À.")){
			if(openerReload) opener.location.reload();
			self.close();
		}
	} else {
		if(openerReload) opener.location.reload();
		self.close();
	}
}

//	¿ìÆí¹øÈ£ °Ë»ö
function findZipCode(){
	var url = PAGE_ZIP_CODE;
	popupWindow(url, "width=368, height=367, left=400, top=300, scrollbars=yes");
}

// ÆäÀÌÁö ÆÄÀÏ¸í °¡Á®¿À±â
function getFileName(url){
	var path = (url.indexOf("/") > 0) ? url.split("/") : url.split("\\");
	var fileName = path[path.length - 1];
	if(fileName.indexOf("?") > 0){
		fileName = fileName.split("?")[0];
	}
	return fileName;
}

function getFileExt(url){
	var filename = getFileName(url);

	if(filename.indexOf(".") == 0)	return "";

	var path = filename.split(".");
	return path[path.length-1];
}

function getFilePath(url){
	if(typeof(url) != "string")
		url = location.href;
	var path = (url.indexOf("/") > 0) ? url.split("/") : url.split("\\");
	return removeString(url, path[path.length-1]);
}

// xp sp2 ¿©ºÎ(windowÀÇ height°¡ Â÷ÀÌ°¡³²
function isXPSP2(){
	var strVerStr = window.navigator.appVersion;
	var arrVerStr = strVerStr.split('; ');
	if(arrVerStr.length >= 4){
		var arrOsVer = arrVerStr[2].split(' ');
		if(arrOsVer.length >= 3 && arrOsVer[0] == "Windows"){
			var osVerNum = new Number(arrOsVer[2]);
			if(osVerNum >= 5.1 && strVerStr.indexOf("SV1") >= 35){
				return true;
			}
		}
	}
	return false;
}

// cookie reading
//	- name			: ÀÌ¸§
function getCookie(name){ //-- 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 "";
}

// cookie writing
//	- name			: ÀÌ¸§
//	- value			: °ª
//	- expiredays	: ±â°£(day)
function setCookie(name, value, expiredays){
	var todayDate = new Date();
	todayDate.setDate(todayDate.getDate() + expiredays);
	document.cookie = name + "=" + escape( value ) + "; path=/; expires=" + todayDate.toGMTString() + ";";
}