/********************************************************************************************************
	[개발 추가영역 - 균]
		- /common/js/richScript.js, /common/js/richScript.XmlData.js 임포트
		- [선언] loadSiteMenuDataXml - 메뉴 XML을 로딩하여 자바스크립트 객체로 변환하여 SITE_MENU에 셋팅함.
		- [선언] getMenu - DIR Array로 해당메뉴 데이터를 가져옴
		- [선언] setCurrentDir - 현재 URL 정보를 Array로 변환하여 CURRENT_DIR에 셋팅함.
	
	함수 순서
	[선언] addEvent - 이벤트 추가 함수
	[실행] addEvent - 추가되는 이벤트 목록
	[선언] findRollOvers - 페이지내 롤오버 이미지 찾기
	[선언] viewPopup - 레이어 팝업 오픈(단순한 display:block)
	[선언] resizeIframe - 같은 도메인의 iframe 리사이즈
	[선언] txtFocus, bgFocus - input, textarea 포커스시 텍스트 삭제.
	[선언] initConditionToggle - 브랜드 색인 - 조건별 검색 - Toggle
	[선언] initFAQToggle - 고객센터 FAQ, 상품평 DL - Toggle
	[선언] initBrandToggle - 브랜드 검색결과 - Toggle
	[선언] setRoundBox - 가변 박스 설정
	[선언] setPositionBtns - 이전 페이지, 맨위로 버튼 설정
	[선언] setSectionArea - 섹션별 타이틀 설정
	[선언] setSiteLocation - 사이트 현재위치(히스토리) 설정
	[선언] getSiteInfo - 롯데면세점 사이트 정보영역 내용 설정
	[선언] setPositionSiteInfo - 롯데면세점 사이트 정보영역 위치 설정
	
	[플래시 링크함수 영역]

	[개발 추가영역 -욱]
		- string
		- validate


********************************************************************************************************/

// XML 로딩 라이브러리
document.writeln('<script type="text/javascript" src="/common/js/richScript.XmlData.js"></script>');

var SITE_MENU = null;	// 메뉴 XML을 자바스크립트 OBJECT로 변환한 객체
var CURRENT_DIR = null;	// 현재 URL의 디렉토리 정보 Array
document.title = "여행의 시작! 롯데면세점";

/***********************************************
 * 메뉴 XML을 로딩하여 자바스크립트 객체로
 * 변환하여 SITE_MENU에 셋팅함.
 @ return : void
***********************************************/
function loadSiteMenuDataXml() {
	var xData = new XmlData();
	xData.load("/common/xml/ldfmenu.xml");
	SITE_MENU = xData.toObject();
	xData = null;
}

/***********************************************
 * DIR Array로 해당메뉴 데이터를 가져옴
 @ param : _dirArray (Array)
 @ return : Object
***********************************************/
function getMenu(_dirArray) {
	var menu = {id : "", title : "", url : ""};
	var _tempMenu = SITE_MENU;
	for (var i=0; i<_dirArray.length; i++) {
		for (var j=0; j<_tempMenu.MENU.length; j++) {
			if (_tempMenu.MENU[j].ID.value==_dirArray[i]) {
				_tempMenu = _tempMenu.MENU[j];
				break;
			}
		}
	}
	if (_tempMenu!=undefined) {
		try { menu.id = _tempMenu.ID.value; } catch(e) { }
		try { menu.title = _tempMenu.TITLE.value; } catch(e) { }
		try { menu.url = _tempMenu.URL.value; } catch(e) { }
	}
	_tempMenu = null;
	return menu;
}

/***********************************************
 * 현재 URL 정보를 Array로 변환하여 CURRENT_DIR에 셋팅함.
 @ return : void
***********************************************/
function setCurrentDir() {
	var path = location.pathname;
	while(path.indexOf("//")>-1) {
		path = path.replace("//","/");
	}
	if (path.indexOf("/")==0) {
		path = path.substring(1,path.lastIndexOf("/"));
	}
	CURRENT_DIR = path.split("/", 3);
}

// Set Current Dir Info
setCurrentDir();



/***********************************************
 * _url만 받으면 현재 지점 코드를 유지하고 이동함.
 * _bCode를 받으면 입력한 지점코드를 달로 이동함.
 @ param : _url (String)
 @ param : _bCode (String:지점코드)
 @ return : void
***********************************************/
function openB(_url, _bCode) {
	var url = (_url!=undefined) ? _url : "";
	var bCode = (_bCode!=undefined) ? _bCode : "";
	if (bCode!="") {
		location.href = "#bCode="+BRANCH_CODE;
		url = _url.appendParameter("bCode="+bCode);
	}
	location.href = url;
}

// 새로운 지점코드를 쿠키에 저장
if (request.get("bCode")!="") {
	Cookie.set("bCode", request.get("bCode"));
}

// history.go(-1) 했을 경우 이전 지점코드를 쿠키에 저장
var prevBranchCodeParam = location.href.split("#")[1];
var prevBranchCode = "";
if (prevBranchCodeParam!=undefined) {
	prevBranchCode = prevBranchCodeParam.split("=")[1];
}
if (prevBranchCode!=undefined&&prevBranchCode!="") {
	Cookie.set("bCode", prevBranchCode);
}

// 쿠키의 지점코드를 가져온다.
var BRANCH_CODE = Cookie.get("bCode");




/***********************************************
 * 정해진 사이즈보다 크면 이미지 사이즈를 줄여준다.
 @ param : _obj (이미지객체)
 @ return : void
***********************************************/
function resizeContentsToMaxWidth(_obj) {
	var maxWidth = 632;
	if (_obj!=undefined) {
		if (_obj.offsetWidth>maxWidth) {
			_obj.style.width = maxWidth + "px";
		}
	}
}


/***********************************************
 * 레이어 팝업 open.
 @ param : _seviceId (login:로그인, zipcode:우편번호팝업, buyTime:구매가능시간안내)
 @ return : void
***********************************************/
var LAYERPOPUP_ROOT_ELEMENT_ID = "layerPopupRootArea";
function openLayerPopup(_seviceId, _param) {
	var bgTitleImagePath = "/img/common/popup/bgTitle/"+_seviceId+".gif";
	var titleImagePath = "/img/common/popup/title/"+_seviceId+".gif";
	var contentsPath = "/layerPopup/"+_seviceId+"/index.jsp";
	if (_param!=undefined) {
		contentsPath = contentsPath.appendParameter(_param);
	}
	if (_seviceId=="login") {
		open(contentsPath, "DFSPUB_LoginPopupWindow", "width=444,height=404,toolbar=no,scrollbars=no,resizable=no,status=yes");
	} else {
		var s = '';
		s += '<div class="popupLayout" style="top: 251px; left: 419px;">\n';
		s += '	<div class="pTitleArea">\n';
		s += '		<div class="btnClose"><img src="/img/common/popup/btnClose01.gif" alt="닫기" onClick="closeLayerPopup();" /></div>\n';
		s += '		<div class="mainTitle"><img src="'+bgTitleImagePath.escapeXml()+'" /></div>\n';
		s += '		<p class="pageTitle"><img src="'+titleImagePath.escapeXml()+'" /></p>\n';
		s += '	</div>\n';
		s += '	<div class="containerPContents">\n';
		s += '		<iframe id="layerPopupContentsFrame" name="layerPopupContentsFrame" src="'+contentsPath.escapeXml()+'" width="424" height="260" frameborder="0" scrolling="no"></iframe>\n';
		s += '		<p class="copyright"><img src="/img/common/popup/copyright.gif" alt="" /></p>\n';
		s += '	</div>\n';
		s += '</div>\n';
		if ($(LAYERPOPUP_ROOT_ELEMENT_ID).isNull) {
			var span = document.createElement("SPAN");
			span.setAttribute("id", LAYERPOPUP_ROOT_ELEMENT_ID);
			document.body.insertBefore(span, document.body.firstChild);
			span = null;
		}
		$(LAYERPOPUP_ROOT_ELEMENT_ID).innerHTML = s;
	}
	
	if (_seviceId=="buyTime") {
		scrollTo(0, 0);
	}
}

function closeLayerPopup() {
	try {
		document.body.removeChild($(LAYERPOPUP_ROOT_ELEMENT_ID));
	} catch(e) { }
}

function openLayerPopup_buyTime() {
	openLayerPopup("buyTime");
}

/***********************************************
 * 레이어 팝업 Contents Resize.
 @ return : void
***********************************************/
function resizeLayerPopupContents() {
	var windowName = window.name;
	var contentsHeight = document.documentElement.scrollHeight;
	if (contentsHeight<100) contentsHeight = 100;
	try {
		parent.$(windowName).setStyle("height", contentsHeight);
	} catch(e) { }
}





try {
	document.execCommand('BackgroundImageCache', false, true);
} catch(e) {}


/********************************************************************************************************
	이벤트 추가 함수
********************************************************************************************************/
function addEvent(elm, evType, fn, useCapture) {   
    if( elm.addEventListener ) {
        elm.addEventListener(evType, fn, useCapture);   
        return true;   
    } else if ( elm.attachEvent ) {   
        var r = elm.attachEvent('on' + evType, fn);   
        return r;
    } else {
        elm['on' + evType] = fn;
    }
}


/********************************************************************************************************
	추가되는 이벤트 목록
********************************************************************************************************/
addEvent(window, "load", function() {


	// 페이지 공통 영역 설정
	loadSiteMenuDataXml();		// Load Menu Data XML
	setSectionArea();			// 섹션별 타이틀 설정
	setSiteLocation();			// 사이트 현재위치(히스토리) 설정
	setPositionSiteInfo();		// 사이트 정보영역 위치 설정
	setPositionBtns();			// 이전 페이지, 맨위로 버튼 설정	
});




/********************************************************************************************************
	페이지내 롤오버 이미지 찾기
********************************************************************************************************/
function findRollOvers() {
	var imgs = document.getElementsByTagName("img");

	for( var i=0; i<imgs.length; i++ ) {
		if( imgs[i].getAttribute("rel") == null ) continue;
		
		if( imgs[i].getAttribute("rel").indexOf("rollover") != -1 ) {
			imgs[i].onmouseover = function() {
				this.src = this.src.replace(".gif", "On.gif");
			}
			imgs[i].onmouseout = function() {
				this.src = this.src.replace("On.gif", ".gif");
			}
		}
	}
}



/********************************************************************************************************
	레이어 팝업 오픈(단순한 display:block)
********************************************************************************************************/
function viewPopup(_id) {
	if( !document.getElementById(_id) ) return false;
	var popupNote = document.getElementById(_id);
	popupNote.style.display = "block";
	popupNote.focus();
}



/********************************************************************************************************
	같은 도메인의 iframe 리사이즈
********************************************************************************************************/
function resizeIframe(targetId, _height) {
	if( !parent.document.getElementById(targetId) ) return false;
	
	var targetIframe = parent.document.getElementById(targetId);
	targetIframe.style.height = _height + "px";
}



/********************************************************************************************************
	이미지 탭 - TAB
********************************************************************************************************/
function initTabMenu(tabContainerID) {
	var tabContainer = document.getElementById(tabContainerID);
	var tabAnchor = tabContainer.getElementsByTagName("a");
	var i = 0;

	for(i=0; i<tabAnchor.length; i++) {
		if (tabAnchor.item(i).className == "tab")
			thismenu = tabAnchor.item(i);
		else
			continue;

		thismenu.container = tabContainer;
		thismenu.targetEl = document.getElementById(tabAnchor.item(i).href.split("#")[1]);
		thismenu.targetEl.style.display = "none";
		thismenu.imgEl = thismenu.getElementsByTagName("img").item(0);
		thismenu.onclick = function tabMenuClick() {
			currentmenu = this.container.current;
			if (currentmenu == this)
				return false;

			if (currentmenu) {
				currentmenu.targetEl.style.display = "none";
				if (currentmenu.imgEl) {
					currentmenu.imgEl.src = currentmenu.imgEl.src.replace("On.gif", ".gif");
					currentmenu.className = currentmenu.className.replace(" here", "");
				} else { }
			}
			
			this.targetEl.style.display = "";
			if (this.imgEl) {
				this.imgEl.src = this.imgEl.src.replace(".gif", "On.gif");
				this.className += " here";
			} else { }
			this.container.current = this;

			return false;
		};

		if (!thismenu.container.first)
			thismenu.container.first = thismenu;
	}
	if (tabContainer.first)
		tabContainer.first.onclick();
}




/********************************************************************************************************
	input, textarea 포커스시 텍스트 삭제.
********************************************************************************************************/
function txtFocus(_txtArea) {
	if( _txtArea.value == "로그인 후 작성해 주세요." ) _txtArea.value = "";
	
	_txtArea.onblur = function() {
		if( this.value == "" ) this.value = "로그인 후 작성해 주세요.";
	}
}

function bgFocus(_txtArea) {
	if( _txtArea.value == "" ) {
		_txtArea.className = "focus";
	}
	
	_txtArea.onblur = function() {
		if( this.value == "" ) this.className = "";
	}
}





/********************************************************************************************************
	고객센터 FAQ, 상품평 DL - Toggle
********************************************************************************************************/
function initFAQToggle(tabContainer, _initialTarget) {
	
	triggers = tabContainer.getElementsByTagName("a");

	for(i = 0; i < triggers.length; i++) {
		if (triggers.item(i).href.split("#")[1])
			triggers.item(i).targetEl = document.getElementById(triggers.item(i).href.split("#")[1]);

		if (!triggers.item(i).targetEl)
			continue;
		
		triggers.item(i).targetEl.style.display = "none";
		triggers.item(i).onclick = function () {
			if (tabContainer.current == this) {
				this.targetEl.style.display = "none";
				tabContainer.current.parentNode.className = "";
				tabContainer.current = null;
			} else {
				if (tabContainer.current) {
					tabContainer.current.targetEl.style.display = "none";
					tabContainer.current.parentNode.className = "";
				}
				this.targetEl.style.display = "block";
				tabContainer.current = this;
				tabContainer.current.parentNode.className = "active";
			}
			
			return false;
		}

		if( !document.getElementById(_initialTarget) ) { continue; }
		var initialTarget = document.getElementById(_initialTarget);
		if( triggers.item(i).targetEl == initialTarget ) {
			triggers.item(i).onclick();
		}
	}
}





/********************************************************************************************************
	브랜드 색인 - 조건별 검색 - Toggle
********************************************************************************************************/
function initConditionToggle(defaultSelected) {
	if( !document.getElementById("category") || !document.getElementById("alphabet") || !document.getElementById("kalphabet") ) return false;
	
	var category = document.getElementById("category");
	category.desc = document.getElementById("categoryDesc");

	var alphabet = document.getElementById("alphabet");
	alphabet.desc = document.getElementById("alphabetDesc");

	var kalphabet = document.getElementById("kalphabet");
	kalphabet.desc = document.getElementById("kalphabetDesc");
	
	var container = Object();

	if( !defaultSelected ) {
		category.className = category.id + "On";
		category.desc.className = category.id + "On";
		container.current = category;
	} else {
		defaultSelected.desc = document.getElementById(defaultSelected.id+"Desc");
		defaultSelected.className = defaultSelected.id + "On";
		defaultSelected.desc.className = defaultSelected.id + "On";
		container.current = defaultSelected;
	}

	category.parent = alphabet.parent = kalphabet.parent = container;
	
	alphabet.onclick = category.onclick = kalphabet.onclick = function() {
		if( this.parent.current == this ) { return false; }
		
		if( this.parent.current ) {
			this.parent.current.className = this.parent.current.className.replace("On", "");
			this.parent.current.desc.className = this.parent.current.desc.className.replace("On", "");
		}
		
		this.className = this.className.replace(this.id, this.id + "On");
		this.desc.className = this.desc.className.replace(this.id, this.id + "On");
		this.parent.current = this;
	}

}


/********************************************************************************************************
	브랜드 검색결과 - Toggle
********************************************************************************************************/
function initBrandToggle(tabContainer) {
	triggers = tabContainer.getElementsByTagName("a");

	for(i = 0; i < triggers.length; i++) {
		if (triggers.item(i).href.split("#")[1])
			triggers.item(i).targetEl = document.getElementById(triggers.item(i).href.split("#")[1]);

		if (!triggers.item(i).targetEl)
			continue;

		triggers.item(i).targetEl.style.display = "none";
		triggers.item(i).onclick = function () {
			if (tabContainer.current == this) {
				this.targetEl.style.display = "none";
				tabContainer.current.innerHTML = '<img src="/img/common/btn/tbView01.gif" alt="자세히보기" />';
//				tabContainer.current.className = "";
				tabContainer.current = null;
			} else {
				if (tabContainer.current) {
					tabContainer.current.targetEl.style.display = "none";
					tabContainer.current.innerHTML = '<img src="/img/common/btn/tbView01.gif" alt="자세히보기" />';
//					tabContainer.current.className = "";
				}
				this.targetEl.style.display = "block";
				tabContainer.current = this;
				tabContainer.current.innerHTML = '<img src="/img/common/btn/tbClose01.gif" alt="닫기" />';
//				tabContainer.current.className = "active";
			}
			
			return false;
		}
	}
}


/********************************************************************************************************
	가변 박스 설정
********************************************************************************************************/
function setRoundBox(_roundContents, _roundStyle, _classParam) {
	var roundContents = _roundContents;
	var roundStyle = _roundStyle;
	var classParam = _classParam;

	var tbRoundBox = document.createElement("table");
		if( !classParam ) {
			tbRoundBox.className = roundStyle;
		} else {
			tbRoundBox.className = roundStyle + " " + classParam;
		}
		
		var trTop = tbRoundBox.insertRow(0);
			var tdTopLeft = trTop.insertCell(0);
				tdTopLeft.className = "rtTL";
			var tdTop = trTop.insertCell(1);
				tdTop.className = "rtT";
			var tdTopRight = trTop.insertCell(2);
				tdTopRight.className = "rtTR";
		
		var trMiddle = tbRoundBox.insertRow(1);
			var tdLeft = trMiddle.insertCell(0);
				tdLeft.className = "rtL";
			var tdCenter = trMiddle.insertCell(1);
				tdCenter.className = "rtC";
			var tdRight = trMiddle.insertCell(2);
				tdRight.className = "rtR";
		
		var trBottom = tbRoundBox.insertRow(2);
			var tdBottomLeft = trBottom.insertCell(0);
				tdBottomLeft.className = "rtBL";
			var tdBottom = trBottom.insertCell(1);
				tdBottom.className = "rtB";
			var tdBottomRight = trBottom.insertCell(2);
				tdBottomRight.className = "rtBR";
	
	var parentRoundContents = roundContents.parentNode;
	parentRoundContents.insertBefore(tbRoundBox, roundContents);
	tdCenter.appendChild(roundContents);
	
}

/********************************************************************************************************
	이전 페이지, 맨위로 버튼 설정
********************************************************************************************************/
function setPositionBtns() {
	if( !document.getElementById("btnPrev") || !document.getElementById("scTop") ) return false;

	var btnPrev = document.getElementById("btnPrev");
	var scTop = document.getElementById("scTop");
	btnPrev.innerHTML = '<a href="#" onclick="history.back(-1); return false;">이전 페이지로</a>';
	scTop.innerHTML = '<a href="#menuLottedfs">맨위로</a>';
}



/********************************************************************************************************
	섹션별 타이틀 설정
********************************************************************************************************/
function getDepth01() {
	var crntURI = location.href;
	var domain = "http://" + document.domain + "/";
	crntURI = crntURI.replace(domain, '');
	var directories = crntURI.split("/");

	for( var i=0; i<directories.length; i++ ) {
		if( directories[i].indexOf(".") != -1 ) directories[i]=null;
	}
	return directories[0];
}

function setSectionArea() {
	if( !document.getElementById("titleSection") || !document.getElementById("imgSection") ) return false;
	
	var titleSection = document.getElementById("titleSection");
	var imgSection = document.getElementById("imgSection");
	var directories;
	var h2Tag = document.createElement("h2");
	var pExp = document.createElement("p");
	var divTitleKor = document.createElement("div");
	
	directories = CURRENT_DIR[0];
	
	switch(directories) {
		case 'event' : 
			var txt = document.createTextNode("이벤트 - Event");
			h2Tag.appendChild(txt);
			txt = document.createTextNode("롯데면세점에서 마련한 다양한 이벤트로 더욱 알찬 쇼핑을 즐겨보세요. ");
			pExp.appendChild(txt);
			break;

		case 'brand' : 
			var txt = document.createTextNode("브랜드 - Brand");
			h2Tag.appendChild(txt);
			txt = document.createTextNode("롯데면세점에 입점한 400여 개의 고품격 브랜드를 확인해 보세요.");
			pExp.appendChild(txt);
			break;

		case 'guide' : 
			var txt = document.createTextNode("가이드 - Guide");
			h2Tag.appendChild(txt);
			txt = document.createTextNode("고객님의 편안한 쇼핑을 위해 면세점 이용에 필요한 모든 정보를 알려드립니다.");
			pExp.appendChild(txt);
			break;

		case 'magazine' : 
			var txt = document.createTextNode("매거진 - Magazine");
			h2Tag.appendChild(txt);
			txt = document.createTextNode("고품격 쇼핑전문지 롯데 매거진과 스타들의 트렌디한 화보를 감상하세요.");
			pExp.appendChild(txt);
			break;

		case 'support' : 
			var txt = document.createTextNode("고객센터 - Support");
			h2Tag.appendChild(txt);
			txt = document.createTextNode("면세점 이용 시 궁금한 점과 불편하신 점을 신속하게 해결하여 드립니다.");
			pExp.appendChild(txt);
			break;

		case 'company' : 
			var txt = document.createTextNode("회사소개 - Company");
			h2Tag.appendChild(txt);
			txt = document.createTextNode("대한민국 대표 면세점, 롯데면세점 홈페이지에 오신 것을 환영합니다.");
			pExp.appendChild(txt);
			break;

		case 'mypage' : 
			var txt = document.createTextNode("마이페이지 - Mypage");
			h2Tag.appendChild(txt);
			txt = document.createTextNode("회원님의 정보와 상담내역을 확인하실 수 있는 마이페이지입니다.");
			pExp.appendChild(txt);
			break;

		case 'recruit' : 
			var txt = document.createTextNode("채용정보 - Recruit");
			h2Tag.appendChild(txt);
			txt = document.createTextNode("롯데면세점에서 꿈을 펼칠 인재를 위한 정보들을 담았습니다.");
			pExp.appendChild(txt);
			break;

		case 'information' : 
			var txt = document.createTextNode("안내 - Information");
			h2Tag.appendChild(txt);
			txt = document.createTextNode("");
			pExp.appendChild(txt);
			break;
	}
	
	titleSection.appendChild(h2Tag);
	titleSection.appendChild(pExp);
	titleSection.appendChild(divTitleKor);
	pExp.className = "exp";
	divTitleKor.className = "titleKor";
	titleSection.className = "h2" + directories;
	
	imgSection.className = directories + "Exp";
}



/********************************************************************************************************
	사이트 현재위치(히스토리) 설정
********************************************************************************************************/
function setSiteLocation() {
	if( !document.getElementById("siteLocation") ) return false;
	var siteLocation = document.getElementById("siteLocation");
	var _tempDir = [];
	var s = "";
	s += '<h3>사이트 현재 위치</h3>\n';
	s += '<ul>\n';
	s += '<li class="home"><a href="javascript:openB(\'/index.jsp\', 1);">HOME</a></li>\n';
	if (CURRENT_DIR!=null&&SITE_MENU!=null) {
		for (var i=0; i<CURRENT_DIR.length; i++) {
			_tempDir.push(CURRENT_DIR[i]);
			var menu = getMenu(_tempDir);
			if (i<CURRENT_DIR.length-1) {
				if( CURRENT_DIR[i] == "information" ) continue;
				s += '<li><a href="'+menu.url+'">'+menu.title+'</a></li>\n';
			} else {
				s += '<li class="here">'+menu.title+'</li>\n';
			}
		}
	}
	s += '</ul>\n';
	siteLocation.innerHTML = s;
	_tempDir = null;
}


/********************************************************************************************************
	롯데면세점 사이트 정보영역 내용 설정
********************************************************************************************************/
function getSiteInfo() {
	var sInfo = "";
	sInfo += '		<!-- '+BRANCH_CODE+' -->\n';
	sInfo += '		<h3>롯데면세점 사이트 정보</h3>\n';
	sInfo += '		<ul>\n';
	sInfo += '			<li class="info01"><a href="/company/submain.jsp">회사소개</a></li>\n';
	sInfo += '			<li class="info02"><a href="/recruit/hr/hr.jsp">채용정보</a></li>\n';
	sInfo += '			<li class="info03"><a href="/information/private/private.jsp">개인정보보호방침</a></li>\n';
	sInfo += '			<li class="info04"><a href="http://www.lottetown.com/cust/cust_agreement.jsp" target="_blank">이용약관</a></li>\n';
	sInfo += '			<li class="info05"><a href="/information/vip/vip_agreement.jsp">VIP 회원약관</a></li>\n';
	sInfo += '			<li class="info06"><a href="/guide/membership/members/members.jsp">롯데 멤버스</a></li>\n';
	sInfo += '			<li class="info07"><a href="/guide/membership/partner/list.jsp">제휴서비스</a></li>\n';
	sInfo += '			<li class="info08">고객센터 1688-3000</li>\n';
	sInfo += '		</ul>\n';
	sInfo += '		<p class="copyright">copyright(C)2010 lotte hotel all rights reserved</p>\n';
	/* 지점별 주소 */
	if (BRANCH_CODE == "6") { // 김해공항점
		sInfo += '		<p class="address_6">(주)부산롯데호텔 롯데김해공항면세점 부산광역시 강서구 대저2동 2350 사업자등록번호 : 606-85-24281 대표이사 : 심우진  개인정보관리책임자 : 김재영</p>\n';
	} else if (BRANCH_CODE == "7") { // 부산점
		sInfo += '		<p class="address_7">(주)부산롯데호텔 롯데부산면세점 부산광역시 부산광역시 진구 부전동 503-15 사업자등록번호 : 605-85-33088 대표이사 : 심우진  개인정보관리책임자 : 김재영</p>\n';
	} else if (BRANCH_CODE == "12") { // 김포공항점
		sInfo += '		<p class="address_12">롯데디에프글로벌(주) 롯데김포공항면세점 서울특별시 강서구 방화동 712-1 국제선청사 3층 격리대합실 사업자등록번호 : 109-85-21667 대표이사 : 최병록  개인정보관리책임자 : 김주남팀장</p>\n';
	} else if (BRANCH_CODE == "13") { // 코엑스점
		sInfo += '		<p class="address_13">롯데디에프리테일(주) 롯데코엑스면세점 서울특별시 강남구 삼성동 159 코엑스인터컨티넨탈호텔 지하2층 사업자등록번호 : 120-85-15745 대표이사 : 최병록  개인정보관리책임자 : 윤현철</p>\n';
	} else {
		sInfo += '		<p class="address">(주)호텔롯데 롯데면세점 서울시 중구 소공동 1번지 사업자등록번호 : 104-85-18866 대표이사 : 최영수 개인정보관리책임자 : 김주남 팀장 TEL : 1688-3000</p>\n';
	}

	sInfo += '		<div class="familySite" onmouseout="closeFamilySite();">\n';
	sInfo += '			<a class="button" href="#" onclick="openFamilySite();return false;">Family Site</a>\n';
	sInfo += '			<div id="familySite" style="display:none;" onmouseout="closeFamilySite();" onmouseover="openFamilySite();">\n';
	sInfo += '				<a href="http://www.lotte.co.kr" target="_blank">롯데그룹</a>\n';
	sInfo += '				<a href="http://www.lottetown.com" target="_blank">롯데타운</a>\n';
	sInfo += '				<a href="http://www.lottemembers.com" target="_blank">롯데멤버스</a>\n';
	sInfo += '				<a href="http://green.lotte.co.kr" target="_blank">롯데환경경영</a>\n';
	sInfo += '				<a href="http://www.daehong.com" target="_blank">대홍기획</a>\n';
	sInfo += '				<a href="http://www.lottecon.co.kr" target="_blank">롯데건설</a>\n';
	sInfo += '				<a href="http://www.lotteapt.net" target="_blank"> - 롯데캐슬</a>\n';
	sInfo += '				<a href="http://www.lottelem.co.kr" target="_blank">롯데기공</a>\n';
	sInfo += '				<a href="http://www.lotte.com" target="_blank">롯데닷컴</a>\n';
	sInfo += '				<a href="http://www.llc.co.kr" target="_blank">롯데로지스틱스</a>\n';
	sInfo += '				<a href="http://www.lotteria.co.kr" target="_blank">롯데리아 </a>\n';
	sInfo += '				<a href="http://www.lotteriamall.com" target="_blank"> - 롯데리아몰</a>\n';
	sInfo += '				<a href="http://www.angelinus.co.kr" target="_blank">엔제리너스</a>\n';
	sInfo += '				<a href="http://shop.angelinus.co.kr" target="_blank"> - 엔제리너스몰</a>\n';
	sInfo += '				<a href="http://www.lottemart.com" target="_blank">롯데마트</a>\n';
	sInfo += '				<a href="http://www.lottedfs.com" target="_blank">롯데인터넷면세점</a>\n';
	sInfo += '				<a href="http://www.busanlottedfs.com" target="_blank">부산롯데인터넷면세점</a>\n';
	sInfo += '				<a href="http://www.lottecorp.com" target="_blank">롯데물산</a>\n';
	sInfo += '				<a href="http://www.lotteshopping.com" target="_blank">롯데백화점</a>\n';
	sInfo += '				<a href="http://www.lotteoutlets.com" target="_blank"> - 롯데아울렛</a>\n';
	sInfo += '				<a href="http://www.lotteshopping.com/green/index.jsp" target="_blank"> - 롯데그린파트너십</a>\n';
	sInfo += '				<a href="http://buying.lotteshopping.com" target="_blank"> - 상품본부</a>\n';
	sInfo += '				<a href="http://lotteedi.dpt.co.kr" target="_blank"> - EDI시스템</a>\n';
	sInfo += '				<a href="http://www.eshoppingb2b.com" target="_blank"> -B2B구매시스템</a>\n';
	sInfo += '				<a href="http://www.lotteb.co.kr" target="_blank">롯데브랑제리</a>\n';
	sInfo += '				<a href="http://www.skyhill.co.kr" target="_blank">롯데스카이힐C.C</a>\n';
	sInfo += '				<a href="http://www.lottesamkang.com" target="_blank">롯데삼강</a>\n';
	sInfo += '				<a href="http://www.lotteins.co.kr" target="_blank">롯데손해보험</a>\n';
	sInfo += '				<a href="http://www.lotteintl.co.kr" target="_blank">롯데상사</a>\n';
	sInfo += '				<a href="http://www.lottesuper.co.kr" target="_blank">롯데슈퍼</a>\n';
	sInfo += '				<a href="http://www.lottestyle.co.jp" target="_blank">롯데스타일</a>\n';
	sInfo += '				<a href="http://www.lottecinema.co.kr" target="_blank">롯데시네마</a>\n';
	sInfo += '				<a href="http://www.lottefood.co.kr" target="_blank">롯데식품</a>\n';
	sInfo += '				<a href="http://www.lotteasahi.co.kr" target="_blank">롯데아사히주류</a>\n';
	sInfo += '				<a href="http://www.lotteal.co.kr" target="_blank">롯데알미늄</a>\n';
	sInfo += '				<a href="http://www.lotteal.co.kr/2_product/s0240.asp" target="_blank"> - 포장사업본부</a>\n';
	sInfo += '				<a href="http://www.lotteacademy.co.kr" target="_blank">롯데인재개발원</a>\n';
	sInfo += '				<a href="http://edu.lotteacademy.co.kr" target="_blank"> - 사이버인재개발원</a>\n';
	sInfo += '				<a href="http://www.lotteworld.com" target="_blank">롯데월드</a>\n';
	sInfo += '				<a href="http://www.lottelhp.com" target="_blank">롯데유통사업본부</a>\n';
	sInfo += '				<a href="http://www.giantsclub.com" target="_blank">롯데자이언츠</a>\n';
	sInfo += '				<a href="http://www.lottefoundation.or.kr" target="_blank">롯데재단</a>\n';
	sInfo += '				<a href="http://www.ldcc.co.kr" target="_blank">롯데정보통신</a>\n';
	sInfo += '				<a href="http://www.lotteconf.co.kr" target="_blank">롯데제과</a>\n';
	sInfo += '				<a href="http://www.lottehealth1.com" target="_blank"> - 헬스원</a>\n';
	sInfo += '				<a href="http://www.natuur.co.kr" target="_blank"> - 나뚜루 </a>\n';
	sInfo += '				<a href="http://www.pepero.co.kr" target="_blank"> - 빼빼로</a>\n';
	sInfo += '				<a href="http://www.cheetos.co.kr" target="_blank"> - 치토스</a>\n';
	sInfo += '				<a href="http://www.lottepharm.co.kr" target="_blank">롯데제약</a>\n';
	sInfo += '				<a href="http://www.lottejtb.com" target="_blank">롯데제이티비</a>\n';
	sInfo += '				<a href="http://www.lotteliquor.com" target="_blank">롯데주류BG</a>\n';
	sInfo += '				<a href="http://www.lotternd.com" target="_blank">롯데중앙연구소</a>\n';
	sInfo += '				<a href="http://job.lotte.co.kr" target="_blank">롯데채용센터</a>\n';
	sInfo += '				<a href="http://www.lottechilsung.co.kr" target="_blank">롯데칠성음료</a>\n';
	sInfo += '				<a href="http://www.coffeecantata.co.kr" target="_blank"> - 칸타타</a>\n';
	sInfo += '				<a href="http://www.lottecard.co.kr" target="_blank">롯데카드</a>\n';
	sInfo += '				<a href="http://www.lottecap.com" target="_blank">롯데캐피탈</a>\n';
	sInfo += '				<a href="http://www.lotteham.co.kr" target="_blank">롯데햄</a>\n';
	sInfo += '				<a href="http://www.lottehotelbusan.com" target="_blank">부산롯데호텔</a>\n';
	sInfo += '				<a href="http://www.lotteimall.com/main/Index.jsp" target="_blank">롯데홈쇼핑</a>\n';
	sInfo += '				<a href="http://www.freshdelica.co.kr" target="_blank">롯데후레쉬델리카</a>\n';
	sInfo += '				<a href="http://www.charlottetheater.co.kr" target="_blank">샤롯데씨어터</a>\n';
	sInfo += '				<a href="http://www.avenuel.co.kr" target="_blank">에비뉴엘</a>\n';
	sInfo += '				<a href="http://www.wellga.com" target="_blank">웰가</a>\n';
	sInfo += '				<a href="http://www.uniqlo.kr" target="_blank">유니클로</a>\n';
	sInfo += '				<a href="http://www.canon-bs.co.kr" target="_blank">캐논코리아비즈니스솔루션</a>\n';
	sInfo += '				<a href="http://www.kpchem.co.kr" target="_blank">케이피케미칼</a>\n';
	sInfo += '				<a href="http://www.7-eleven.co.kr" target="_blank">코리아세븐</a>\n';
	sInfo += '				<a href="http://www.krispykreme.co.kr" target="_blank">크리스피크림도넛</a>\n';
	sInfo += '				<a href="http://www.toysrus.co.kr" target="_blank">토이저러스</a>\n';
	sInfo += '				<a href="http://www.fujifilm.co.kr" target="_blank">한국후지필름</a>\n';
	sInfo += '				<a href="http://shop.fujifilm.co.kr" target="_blank"> - 후지필름쇼핑몰</a>\n';
	sInfo += '				<a href="http://www.hpc.co.kr" target="_blank">호남석유화학</a>\n';
	sInfo += '				<a href="http://www.tgif.co.kr" target="_blank">T.G.I.Friday`s</a>\n';
	sInfo += '				<a href="http://www.kirin.co.kr" target="_blank">기린식품</a>\n';
	sInfo += '				<a href="http://www.mybi.co.kr" target="_blank">마이비</a>\n';
	sInfo += '				<a href="http://www.hanpay.net" target="_blank">한페이시스</a>\n';
	sInfo += '			</div>\n';
	sInfo += '		</div>\n';

	sInfo += '		<div class="cBoth"></div>\n';
	return sInfo;
}



/********************************************************************************************************
	롯데면세점 사이트 정보영역 위치 설정
********************************************************************************************************/
function setPositionSiteInfo() {
	if( !document.getElementById("lottedfsInfo") || !document.getElementById("frameContents") ) return false;
	
	var lottedfsInfo = document.getElementById("lottedfsInfo");
	var frameContents = document.getElementById("frameContents");
	
	if( frameContents.className.indexOf("frameBrancMainContents") == 0 ) {
		var headerHight = 15;
	} else if( frameContents.className == "frameMainContents" ) {
		var headerHight = 175;
	} else {
		var headerHight = 105;
	}

	var infoMargin = 20;
	var frameContentsHeightHeight = frameContents.offsetHeight;
	var currentHeight = 0;
	
	currentHeight = frameContentsHeightHeight + headerHight + infoMargin;
	
	lottedfsInfo.style.top = currentHeight + "px";
//	lottedfsInfo.style.left = 41 + "px";

	lottedfsInfo.innerHTML = getSiteInfo();
	
	frameContents.onresize = function() {
		setPositionSiteInfo();
	}
}



/********************************************************************************************************
	플래시 링크함수 영역
********************************************************************************************************/
function scEng() { open("http://en.lottedfs.com/", "_self", ""); }
function scJp() { open("http://jp.lottedfs.com/", "_self", ""); }
function scCn() { open("http://cn.lottedfs.com/", "_self", ""); }
function scHome() { openB("http://kr.lottedfs.com/index.jsp", 1); }
function scLogin() { openLayerPopup("login"); }
function scLogout() { location.href="http://member.lottetown.com/door/sso/logout.jsp?sid=DFSPUB"; }
function scJoin() { location.href="http://kr.lottedfs.com/information/join/join.jsp"; }
function scMypage() { location.href="http://kr.lottedfs.com/mypage/userinfo/userinfo.jsp"; }
function scSupport() { location.href="http://kr.lottedfs.com/support/submain.jsp"; }
function scVip() { location.href="http://kr.lottedfs.com/vip/member/member.jsp"; }
function scSitemap() { location.href="http://kr.lottedfs.com/information/sitemap/sitemap.jsp"; }
//인터넷 면세점 본점 부산점 주소 scLotteDFS():본점 scLotteDFS2(): 부산점
function scLotteDFS() { open("http://www.lottedfs.com/handler/Index?CHANNEL_CD=9000000200040001", "_blank", ""); }
function scLotteDFS2() { open("http://www.busanlottedfs.com/handler/Index", "_blank", ""); }
function scLotteDFS3() { open("http://www.lottecoexdfs.com", "_blank", ""); }
function scCallCenter() { location.href="/support/counsel/phone.jsp"; }

/* 지점바로가기 */
function scBranch(_bCode) {
//	alert("지점바로가기 - 지점코드 : " + _bCode);
	switch(parseInt(_bCode)) {
		case 2 :
		case 3 :
		case 4 :
		case 5 :
		case 6 :
		case 7 :
		case 8 :
		case 9 :
		case 12 :
		case 13 :
			openB("/branchMain.jsp", _bCode);
			break;
//본점 Ec 바로가기 버튼
		case 10 :
			scLotteDFS();
			break;
//부산점 Ec 바로가기 버튼
		case 11 :
			scLotteDFS2();
			break;
//코엑스면세점 바로가기 버튼		
		case 14 :
			scLotteDFS3();
			break;

		default :
			openB("/index.jsp", _bCode);
			break;
	}
}

function scTheLotte() { location.href="/magazine/lotte/magazine.jsp"; }
function scTheLotteHomme() { location.href="/magazine/homme/homme.jsp" }
function scTheMagazine() { location.href="/magazine/lotte/lotteMagazine.jsp" }

/***** 인덱스 *****/
function scStoreInfoAll() {
	location.href = "/guide/branch/storeinfo.jsp";
}

/***** 지점메인 *****/
	/* 쇼핑안내 */
	function scShoppingInfo(_bCode) { 
		switch(parseInt(_bCode)) {
			case 2 :
				location.href = "/guide/shopping/guide01.jsp";
				break;
	
			case 3 :
				location.href = "/guide/shopping/guide02.jsp";
				break;
	
			case 4 :
				location.href = "/guide/shopping/guide03.jsp";
				break;
	
			case 5 :
				location.href = "/guide/shopping/guide04.jsp";
				break;
	
			case 6 :
				location.href = "/guide/shopping/guide06.jsp";
				break;
	
			case 7 :
				location.href = "/guide/shopping/guide05.jsp";
				break;
	
			case 8 :
				location.href = "/guide/shopping/guide07.jsp";
				break;
	
			case 9 :
				location.href = "/guide/shopping/guide08.jsp";
				break;

			case 12 :
				location.href = "/guide/shopping/guide09.jsp";
				break;

			case 13 :
				location.href = "/guide/shopping/guide10.jsp";
				break;
		}
	}
	
	/* 입점브랜드 */
	function scStoreInfoView(_bCode) {
		switch(parseInt(_bCode)) {
			case 2 :
				location.href = "/guide/branch/maindetail/detail.jsp";
				break;
	
			case 3 :
				location.href = "/guide/branch/lobbydetail/detail.jsp";
				break;
	
			case 4 :
				location.href = "/guide/branch/worlddetail/detail.jsp";
				break;
	
			case 5 :
				location.href = "/guide/branch/incheonadetail/detail.jsp";
				break;
	
			case 6 :
				location.href = "/guide/branch/gimhaeadetail/detail.jsp";
				break;
	
			case 7 :
				location.href = "/guide/branch/busandetail/detail.jsp";
				break;
	
			case 8 :
				location.href = "/guide/branch/jejudetail/detail.jsp";
				break;
	
			case 9 :
				location.href = "/guide/branch/jejuadetail/detail.jsp";
				break;

			case 12 :
				location.href = "/guide/branch/gimpoadetail/detail.jsp";
				break;

			case 13 :
				location.href = "/guide/branch/coexdetail/detail.jsp";
				break;
		}
	}
	
	/* 지점메인 바로가기 링크 */
	function scBranchMain(_seq) {
		switch(parseInt(_seq)) {
			case 0 :
				location.href = "/vip/member/member.jsp";
				break;

			case 1 :
				location.href = "/support/faq/faq.jsp";
				break;

			case 2 :
				location.href = "/magazine/lotte/lotteMagazine.jsp";
				break;

			case 3 :
				location.href = "/event/catalog/catalog.jsp";
				break;
		}
	}
	
	/* 카테고리 클릭 */
	function searchBrandByCategory(_bCode, _categoryValue) {
		// alert("지점코드 : " + _bCode + ", 카테고리 VALUE값 : " + _categoryValue);
		location.href='/brand/info/searchBrand.jsp?searchStoreCode=' + _bCode + "&searchCategory=" + _categoryValue;
	}


/***** 가이드 지점안내 - 매장정보 지도 확대보기 *****/
function magnificationMap(_nFloor) {
	if( !document.getElementById("popupMap") ) return false;
	
	var popupMap = document.getElementById("popupMap");
	popupMap.style.display = "block";

	if( document.getElementById("floor0"+parseInt(_nFloor)) ) {
		var pFloor = document.getElementById("floor0"+parseInt(_nFloor));
		pFloor.style.display = "block";

		scrollbarWidth = (pFloor.clientWidth/(pFloor.scrollWidth/pFloor.clientWidth));
		scrollbarHeight = (pFloor.clientHeight/(pFloor.scrollHeight/pFloor.clientHeight));

		pFloor.scrollLeft = pFloor.clientWidth - scrollbarWidth;
		pFloor.scrollTop = pFloor.clientHeight - scrollbarHeight;
//		alert("pFloor.scrollLeft : " + pFloor.scrollLeft + ", pFloor.scrollTop : " + pFloor.scrollTop);
	}

}

function closeStoreMap() {
	if( !document.getElementById("popupMap") ) return false;

	if( document.getElementById("floor01") ) {
		document.getElementById("floor01").style.display = "none";
	}
	if( document.getElementById("floor02") ) {
		document.getElementById("floor02").style.display = "none";
	}
	
	document.getElementById("popupMap").style.display = "none";
}

/***** 가이드 - 지점안내 *****/
function scStoreInfo(_bCode) {
//	alert("가이드 - 지점안내 : " + _bCode);
	switch(parseInt(_bCode)) {
		case 2 :	// 본점
			location.href = "/guide/branch/mainintro/intro.jsp";
			break;

		case 3 :	// 로비점
			location.href = "/guide/branch/lobbyintro/intro.jsp";
			break;

		case 4 :	// 월드점
			location.href = "/guide/branch/worldintro/intro.jsp";
			break;

		case 5 :	// 인천공항점
			location.href = "/guide/branch/incheonaintro/intro.jsp";
			break;

		case 6 :	// 김해공항점
			location.href = "/guide/branch/gimhaeaintro/intro.jsp";
			break;

		case 7 :	// 부산점
			location.href = "/guide/branch/busanintro/intro.jsp";
			break;

		case 8 :	// 제주점
			location.href = "/guide/branch/jejuintro/intro.jsp";
			break;

		case 9 :	// 제주공항점
			location.href = "/guide/branch/jejuaintro/intro.jsp";
			break;

		case 10 :
			scLotteDFS();			
			break;

		case 11 :
			scLotteDFS2();			
			break;

		case 12 :	// 김포공항점
			location.href = "/guide/branch/gimpoaintro/intro.jsp";
			break;

		case 13 :	// 코엑스점
			location.href = "/guide/branch/coexintro/intro.jsp";
			break;

	}
}

/***** 브랜드 검색 *****/
/* 첫번째 탭 - 브랜드 검색 */
	function searchBrandByStore(_storeElement, _searchWord) {
		//alert("store element의 value attribute값 : " + _storeElement + ", 검색어값 : " + _searchWord);
		document.write("<form name='searchBrandByStoreByCommon' method='post'>");
		document.write("<input type='hidden' name='searchStoreCode' >");
		document.write("<input type='hidden' name='searchValue' >");
		document.write("</form>");
		var f = document.searchBrandByStoreByCommon;
		f.searchStoreCode.value = _storeElement;
		f.searchValue.value = _searchWord;
		f.action = "/brand/info/searchBrand.jsp"
		f.submit();
		//location.href='/brand/info/searchBrand.jsp?searchStoreCode=' + _storeElement + "&searchValue=" + encodeURIComponent(_searchWord);
	}
	
	/* 두번째 탭 - 가, 나, 다 */
	function searchBrandByKorean(_seq) {
		//alert("순서값 : " + _seq);
		location.href='/brand/info/searchBrand.jsp?searchKorean1_index=' + _seq;
	}
	
	/* 세번째 탭 - A, B, C */
	function searchBrandByAZ(_seq) {
		//alert("선택한 영어의 소문자값 : " + _seq);
		location.href='/brand/info/searchBrand.jsp?searchAlphabet=' + _seq;
	}


/********************************************************************************************************
	개발쪽 추가 javascript 영역
********************************************************************************************************/
/***** String *****/
String.prototype.trim = function () {
	var s = (this!=null) ? this : "";
	s = s.replace(/^\s+/g,"");
	s = s.replace(/\s+$/g,"");
	return s;
};

String.prototype.getBytes = function() {
	var s = (this!=null) ? this : "";
	var bytes = 0;
	var c = "";
	var u = "";
	for (var i=0; i<s.length; i++) {
		c = s.charAt(i);
		u = escape(c);
		if (u.length < 4) { // 반각문자 : 기본적인 영문, 숫자, 특수기호
			bytes++; // + 1byte
		} else {
			var b = parseInt(c.charCodeAt(0));
			if (((b >= 65377)&&(b <= 65500))||((b >= 65512)&&(b <= 65518))) // 반각문자 유니코드 10진수 범위 : 한국어, 일본어, 특수문자
				bytes++; // + 1byte
			else // 전각문자 : 위 조건을 제외한 모든 문자
				bytes += 2; // + 2byte
		}
	}
	return bytes;
};


/***** validate *****/
var funcs = {};
funcs['nospace'] = isNoSpace;				// 공백없이
funcs['email'] = isValidEmail;				// 이메일검사
funcs['emailfirst'] = isValidEmailFirst;	// 이메일 앞자리
funcs['phone'] = isValidPhone;				// 전화번호
funcs['userid'] = isValidUserid;			// 아이디
funcs['hangul'] = hasHangul;				// 한글
funcs['number'] = isNumeric;				// 숫자
funcs['number2'] = isNumeric2;				// 숫자2
funcs['engonly'] = alphaOnly;				// 영문
funcs['engonly2'] = alphaOnly2;				// 영문+숫자
funcs['hangulonly'] = hangulOnly;			// 한글
funcs['jumin'] = isValidJumin;				// 주민번호
funcs['bizno'] = isValidBizNo;				// 사업자번호
funcs['pw'] = isValidPassword;				// 비밀번호


var NO_BLANK = "{name+을를} 입력하여 주십시오";
var NO_SELECT = "{name+을를} 선택하여주십시오";
var NOT_VALID = "{name+이가} 올바르지 않습니다";
var TOO_LONG = "{name}의 길이가 초과되었습니다 (최대 {maxbyte}바이트)";
var TOO_SHORT = "{name}의 길이가 부족합니다 (최소 {minbyte}바이트)";

String.prototype.hasFinalConsonant = function(str) {
	str = this != window ? this : str; 
	var strTemp = str.substr(str.length-1);
	return ((strTemp.charCodeAt(0)-16)%28!=0);
}

function josa(str,tail) {
	return (str.hasFinalConsonant()) ? tail.substring(0,1) : tail.substring(1,2);
}

function validate(form) {
	var i=0;

	for (i = 0; i < form.elements.length; i++ ) {
		var el = form.elements[i];
		if(el.tagName.toUpperCase() != "OBJECT") {
			try
			{
			el.value = el.value.trim();
			}
			catch (e)
			{
			}
	
			if (el.getAttribute("REQUIRED") != null) {
				//select 구문 처리
				if(el.type.indexOf("select")>-1){
					//|| el.option[el.selectedIndex].value == ""
					if (el.selectedIndex==0 ) {
						return doError(el,NO_SELECT);
					}
				}else{
					if (el.value == null || el.value == "") {
						return doError(el,NO_BLANK);
					}
				}
			}
	
			if (el.getAttribute("MAXBYTE") != null && el.value != "") {
				var len = el.value.getBytes();
				if (len > parseInt(el.getAttribute("MAXBYTE"))) {
					maxbyte = el.getAttribute("MAXBYTE");
					return doError(el,TOO_LONG,"",maxbyte);
				}
			}
			if (el.getAttribute("MINBYTE") != null && el.value != "") {
				var len = el.value.getBytes();
				if (len < parseInt(el.getAttribute("MINBYTE"))) {
					minbyte = el.getAttribute("MINBYTE");
					return doError(el,TOO_SHORT,"",minbyte);
				}
			}
	
			if (el.getAttribute("OPTION") != null && el.value != "") {
				if (!funcs[el.getAttribute("OPTION").toLowerCase()](el)) return false;
			}
	
			if (el.getAttribute("FILETYPE") != null && el.value != "") {
				var validFileType = el.getAttribute("FILETYPE").split(",");
				var nFileType = el.value.substring(el.value.lastIndexOf(".")+1,el.length);
				var isValidFileType = false;
				for (j=0; j<validFileType.length ; j++) {
					if (nFileType.toUpperCase()==validFileType[j].toUpperCase().replace(/\s/g,"")) {
						isValidFileType = true;
					}
				}
				if (!isValidFileType) {
					var nameString = "";
					if (el.getAttribute("$name") != null && el.getAttribute("$name") != "") {
						nameString = "{name+이가} ";
					}
					return doError(el,nameString+"적절한 파일 포맷이 아닙니다.");
				}
			}
		}
	}
	return true;
}

function doError(el,type,action,byte) {
	var pattern = /{([a-zA-Z0-9_]+)\+?([가-힝]{2})?}/;
	var name = ($name = el.getAttribute("$NAME")) ? $name : el.getAttribute("NAME");
	pattern.exec(type);
	var tail = (RegExp.$2) ? josa(eval(RegExp.$1),RegExp.$2) : "";
	alert(type.replace(pattern,eval(RegExp.$1) + tail).replace(pattern,byte));
	if (action == "sel") {
		el.select();
	} else if (action == "del")	{
		el.value = "";
	}
	if (el.getAttribute("UNFOCUSED") == null) {
		if(el.type!="hidden"&&el.style.display.toUpperCase()!="NONE"){		
			el.focus();
		}
	}	
	return false;
}	


/// 패턴 검사 함수들 ///
function isNoSpace(el) {
	var pattern = /[\s]/;
	return (!pattern.test(el.value)) ? true : doError(el,"{name+은는} 띄어쓰기 없이 입력해주시기 바랍니다");
}

function isValidEmail(el) {
	var pattern = /^[_a-zA-Z0-9-\.]+@[\.a-zA-Z0-9-]+\.[a-zA-Z]+$/;
	return (pattern.test(el.value)) ? true : doError(el,NOT_VALID);
}

function isValidEmailFirst(el) {
	var pattern = /^[_a-zA-Z0-9-\.]+$/;
	return (pattern.test(el.value)) ? true : doError(el,NOT_VALID);
}



//수정 필요
function isValidUserid(el) {
	var pattern = /^[a-zA-Z]{1}[a-zA-Z0-9_]{3,11}$/;
	return (pattern.test(el.value)) ? true : doError(el,"{name+은는} 4자이상 12자 미만이어야 하고,\n 영문,숫자, _ 문자만 사용할 수 있습니다");
}

function hasHangul(el) {
	var pattern = /[가-힝]/;
	return (pattern.test(el.value)) ? true : doError(el,"{name+은는} 반드시 한글을 포함해야 합니다");
}
function hangulOnly(el) {
	var pattern = /^[가-힝]+$/;
	return (pattern.test(el.value)) ? true : doError(el,"{name+은는} 한글만 입력가능 합니다");
}

function alphaOnly(el) {
	var pattern = /^[a-zA-Z]+$/;
	return (pattern.test(el.value)) ? true : doError(el,NOT_VALID);
}

function alphaOnly2(el) {
	var pattern = /^[0-9a-zA-Z]+$/;
	return (pattern.test(el.value)) ? true : doError(el,NOT_VALID);
}

function isNumeric(el) {
	var pattern = /^[0-9]+$/;
	return (pattern.test(el.value)) ? true : doError(el,"{name+은는} 반드시 숫자로만 입력해야 합니다");
}

function isNumeric2(el) {
	var pattern = /^[0-9,.]+$/;
	return (pattern.test(el.value)) ? true : doError(el,"{name+은는} 반드시 숫자로만 입력해야 합니다");
}


function isValidJumin(el) {
    var pattern = /^([0-9]{6})-?([0-9]{7})$/; 
	var num = el.value;
    if (!pattern.test(num)) return doError(el,NOT_VALID); 
    num = RegExp.$1 + RegExp.$2;

	var sum = 0;
	var last = num.charCodeAt(12) - 0x30;
	var bases = "234567892345";
	for (var i=0; i<12; i++) {
		if (isNaN(num.substring(i,i+1))) return doError(el,NOT_VALID);
		sum += (num.charCodeAt(i) - 0x30) * (bases.charCodeAt(i) - 0x30);
	}
	var mod = sum % 11;
	return ((11 - mod) % 10 == last) ? true : doError(el,NOT_VALID);
}

function isValidBizNo(el) { 
	var pattern = /([0-9]{3})-?([0-9]{2})-?([0-9]{5})/; 
	var num = el.value;
    if (!pattern.test(num)) return doError(el,NOT_VALID); 
    num = RegExp.$1 + RegExp.$2 + RegExp.$3;
    var cVal = 0; 
    for (var i=0; i<8; i++) { 
        var cKeyNum = parseInt(((_tmp = i % 3) == 0) ? 1 : ( _tmp  == 1 ) ? 3 : 7); 
        cVal += (parseFloat(num.substring(i,i+1)) * cKeyNum) % 10; 
    } 
    var li_temp = parseFloat(num.substring(i,i+1)) * 5 + '0'; 
    cVal += parseFloat(li_temp.substring(0,1)) + parseFloat(li_temp.substring(1,2)); 
    return (parseInt(num.substring(9,10)) == 10-(cVal % 10)%10) ? true : doError(el,NOT_VALID); 
}

function isValidPhone(el) {
	var pattern = /^[0-9-]+$/;
	return (pattern.test(el.value)) ? true : doError(el,"{name+은는} 반드시 숫자로만 입력해야 합니다");
}

function isValidDate(el) {
	var oDateStr = el.value;

	var oDate = new Date(oDateStr.substr(0,4),oDateStr.substr(4,2)-1,oDateStr.substr(6,2));

	var oYearStr=oDate.getFullYear();

	var oMonthStr=(oDate.getMonth()+1).toString();
		
	oMonthStr = (oMonthStr.length ==1) ? "0"+ oMonthStr: oMonthStr; 
	var oDayStr=oDate.getDate().toString();
	oDayStr = (oDayStr.length ==1) ? "0"+ oDayStr: oDayStr; 

	return  (oDateStr == oYearStr+oMonthStr+oDayStr) ? true : doError(el,NOT_VALID); 
}

function isValidPassword(el) {
	var pattern = /^[A-Za-z0-9_\-\!@#]{4,12}$/;
	return (pattern.test(el.value)) ? true : doError(el,"비밀번호가 올바르지 않습니다.\n비밀번호는 4자이상 12자 이하의 영문, 숫자, 특수문자만 사용할 수 있습니다");
}

/* Family Site */
function openFamilySite() {
	document.getElementById('familySite').style.display = "block";
}

function closeFamilySite() {
	document.getElementById('familySite').style.display = "none";
}
