/********************************* 팝업 중앙에 띄우기 ***************************/

var win= null;
function NewWindow(mypage,myname,w,h,scroll){
  var winl = (screen.width-w)/2;
  var wint = (screen.height-h)/2;
  var settings  ='height='+h+',';
      settings +='width='+w+',';
      settings +='top='+wint+',';
      settings +='left='+winl+',';
      settings +='scrollbars='+scroll+',';
      settings +='resizable=no';
  win=window.open(mypage,myname,settings);
  if(parseInt(navigator.appVersion) >= 4){win.window.focus();}
}
/********************************* 팝업 중앙에 띄우기 ***************************/

/********************************* quick 메뉴 ***************************/
/* constructor */
/* 인수는 (엘리먼트 id, 초기 top 값, (선택사항) bottom 마진) */
function floatedLayer(eleName, initialTop, bottomLimit) {

	if (!document.getElementById(eleName)) { return; }

	this.ele = document.getElementById(eleName);
	this.initialTop = initialTop;
	this.bottomLimit = (!bottomLimit)? 0 : bottomLimit;
	this.timer = null;
	this.moveLayer();
}

/* class property */
floatedLayer.INTERVAL = 10; /* 동작 간격: (단위: 밀리초(ms)) */
floatedLayer.DEGREE = 5; /* 움직임 정도: (단위: 퍼센트, 0 < 범위 <= 100) */


/* instance method */
floatedLayer.prototype.moveLayer = function () {

	var scrollHeight = 0;

	// 스크롤된 높이 계산 (참고: http://www.howtocreate.co.uk/tutorials/javascript/browserwindow)
	if (document.body && document.body.scrollTop) {
		scrollHeight = document.body.scrollTop;
	} else if (document.documentElement && document.documentElement.scrollTop) {
		scrollHeight = document.documentElement.scrollTop;
	}

	var top = (isNaN(parseInt(this.ele.style.top)))? this.initialTop : parseInt(this.ele.style.top);
	var exactHeight = scrollHeight + this.initialTop;

	var moveHeight = Math.ceil(Math.abs(top - exactHeight) * floatedLayer.DEGREE / 100);

	top = (top > exactHeight)? top - moveHeight : top + moveHeight;

	var documentHeight = document.body.offsetHeight;
	var eleHeight = this.ele.offsetHeight;

	if ((top + eleHeight) >= documentHeight - this.bottomLimit) {
		top = documentHeight - eleHeight - this.bottomLimit;
	}

	this.ele.style.top = top + "px";

	// setTimeout에서 인스턴스 메소드 사용 (참고: http://www.faqts.com/knowledge_base/view.phtml/aid/2311)
	var self = this;
	if (this.timer) {
		window.clearTimeout(this.timer);
	}
	this.timer = window.setTimeout(function () { self.moveLayer(); }, floatedLayer.INTERVAL);
}

window.onload  = function() {
	var ele1Top = 174;
	if (document.getElementById("divStayTopLeft")) {
		new floatedLayer("divStayTopLeft", ele1Top, 150);
	}
};
/********************************* quick 메뉴 ***************************/

function selectbox_replace() {
	// 프로그램에서 변수값 변경이 적용되지 않아서 unselectbox()먼저 해줘야 함.
	$("#defaultCon .search2 select").parents('.selectbox2').unselectbox();
	$("#defaultCon .search2 select").selectbox("selectbox2");
}

(function($){
//jQuery start
$(function(){
	//family site
	$(".familySite select").selectbox("selectbox","","up");
	selectbox_replace();
});
//jQuery end
})(jQuery);
