try{ document.execCommand("BackgroundImageCache", false, true); }catch(e){}

/* ----- userAgent Check ----- */
var user = {
    IE			:!!(window.attachEvent && !window.opera),
    IE6			:((navigator.userAgent.toLowerCase().indexOf("msie 6")!=-1)&&(navigator.userAgent.toLowerCase().indexOf("msie 7")<0)),
    IE7			:(navigator.userAgent.toLowerCase().indexOf("msie 7")!=-1),
    FF			:(navigator.userAgent.toLowerCase().indexOf("firefox")!=-1),
    Opera		:!!window.opera,
    Apple		:navigator.userAgent.toLowerCase().indexOf("applewebkit")!=-1 //safari,chrome
}

/* ----- Layer Show,Hidden ----- */
var util = {
	$ : function(element) { // document.getElementById Return
		if (arguments.length > 1) {
			for (var i = 0, elements = [], length = arguments.length; i < length; i++) elements.push(util.$(arguments[i]));
			return elements;
		}
		if (typeof(element) == "string") element = document.getElementById(element);
		return element;
	},
	AddEvent : function(obj, type, fn) { //Event Register
		if(obj.addEventListener) {
			obj.addEventListener(type, fn, false);
		} else if(obj.attachEvent) {
			obj["e"+type+fn] = fn;
			obj[type+fn] = function() { obj["e"+type+fn]( window.event ); }
			obj.attachEvent("on"+type, obj[type+fn]);
			} else {
			obj["on"+type] = obj["e"+type+fn];
		}
	},
	reflash : function(containerid, swfid, src, w, h, flashvars, base, wmode,bg){ // flash reWrite.
		var wmode = wmode || "transparent";
		var bg = bg || "none";
		var base = base || "";
		var flashvars = flashvars || "";
		var html="";
		if(user.IE){
			html += "<object id=\""+swfid+"\" width=\""+w+"\" height=\""+h+"\" classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0\">"
					 + "<param name=\"base\" value=\""+base+"\" />"
					 + "<param name=\"movie\" value=\""+src+"\" />"
					 + "<param name=\"wmode\" value=\""+wmode+"\" />"
					 + "<param name=\"bgcolor\" value=\""+bg+"\" />"
					 + "<param name=\"flashvars\" value=\""+flashvars+"\"/>"
					 + "<param name=\"allowScriptAccess\" value=\"always\" />"
					 + "<param name=\"allowFullScreen\" value=\"true\" />"
					 + "<param name=\"quality\" value=\"high\" />"
					 + "</object>";
		}else{
			html += "<embed id=\""+ swfid+"\" src=\""+src+"\" flashvars=\""+flashvars+"\" width=\""+w+"\" height=\""+h+"\" quality=\"high\" base=\""+base+"\" wmode=\""+wmode+"\" bgcolor=\""+bg+"\" allowScriptAccess=\"always\" allowFullScreen=\"true\" type=\"application/x-shockwave-flash\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\"></embed>";
		}
		util.$(containerid).innerHTML = html;
	},
	show : function(obj){ util.$(obj).style.display = "block"; },
	hidden : function(obj){ util.$(obj).style.display = "none"; },
	toggle : function(obj){ util.$(obj).style.display = (util.$(obj).style.display=="block") ? "none" : "block" ; },
	popOpen : function(url,name,w,h,scroll){
		w = (scroll) ? w+17 : w ;
		scroll = (scroll) ? "yes" : "no" ;
		window.open(url,name,"width="+w+",height="+h+",scrollbars="+scroll+",toolbar=no,location=no,status=no,menubar=no");
	},
	popFull : function(url,name){
		window.open(url,name,"channelmode,scrollbars,scrollbars=no");
	},
	getDoffset : function(obj){ //Offset Position
		var pos=[0,0];
		if(obj.offsetParent){
			do{
				pos[0] += obj.offsetLeft;
				pos[1] += obj.offsetTop;
			}while(obj = obj.offsetParent);
		}
		return pos;
	},
	move : function(obj,dir,ms,me,pORm,percent,time,fun){ //( ¿ÀºêÁ§Æ® , ÀÌµ¿property:style.left_or_scrollLeftµî , ½ÃÀÛÀ§Ä¡ , ÀÌµ¿ÇÒÀ§Ä¡ , +(1)ÀÎÁö-(0)ÀÎÁö±¸º° )
		clearTimeout(obj.moveact);
		ms = parseInt(ms);
		me = parseInt(me);

//trace(ms+" | "+me+" | ")
		var pos = Math.ceil((me-ms)*percent);
		if(pos==0) pos = (pORm) ? 1 : -1 ;
		var _me = eval("parseInt(obj."+dir+")");
		var unit = (dir.indexOf("style.")>-1) ? "px" : "";
		if((pORm==1&&_me>=me)||(pORm==0&&_me<=me)){
			eval("obj."+dir+" = me+unit");
			if(fun) eval(fun);
		}else{
			eval("obj."+dir+" = (parseInt(obj."+dir+")+pos)+unit");
			if((pORm==1&&_me<me)||(pORm==0&&_me>me)) obj.moveact=setTimeout(function(){util.move(obj,dir,eval("obj."+dir),me,pORm,percent,time,fun)},time);
		}
//trace(_me+"<br />")
	},
	listChange : function(name){ //ÁúÀÇ ÀÀ´äÇü ¸®½ºÆ®
		if(!((typeof(name)=="string")? util.$(name) : name)) return;
		var obj = (util.$(name).nodeName!="DL") ? util.$(name).getElementsByTagName("dl")[0] : util.$(name) ;
		var objTitle = obj.getElementsByTagName("dt");
		var objCont = obj.getElementsByTagName("dd");
		for( i=0; i < objTitle.length; i++ ){
			objCont[i].style.overflow = "hidden";
			objCont[i].style.height = "0";
			if(i == objTitle.length-1) objCont[i].className += " last";
			objTitle[i].onclick = function(){ listView(name,this); }
			if(objTitle[i].getElementsByTagName("a").length>0) objTitle[i].getElementsByTagName("a")[0].onclick = function(){ this.blur(); return false; }
		}
		function listView(name,item){
			for( i=0; i < objTitle.length; i++ ){
				objTitle[i].className = (objTitle[i]==item&&objTitle[i].className!="this") ? "this" : "" ;
				objCont[i].className = (objTitle[i].className=="this") ? objCont[i].className+" this" : objCont[i].className.replace("this","");
				if(objTitle[i]==item&&objTitle[i].className=="this"){
					util.move(objCont[i],"style.height",parseInt(objCont[i].style.height),objCont[i].scrollHeight,1,0.2,20)
				}else{
					util.move(objCont[i],"style.height",parseInt(objCont[i].style.height),0,0,0.2,20)
				}
			}
		}
	},
	tabChange : function(obj){
		var objBox = obj.parentNode.parentNode;
		for(i=0;i<objBox.childNodes.length;i++){
			if(objBox.childNodes[i].nodeType==1){
				if(objBox.childNodes[i].getElementsByTagName("a")[0]==obj){
					objBox.childNodes[i].getElementsByTagName("a")[0].className = "this";
					util.$(objBox.childNodes[i].getElementsByTagName("a")[0].href.split("#")[1]).style.display = "block";
				}else{
					objBox.childNodes[i].getElementsByTagName("a")[0].className = "";
					util.$(objBox.childNodes[i].getElementsByTagName("a")[0].href.split("#")[1]).style.display = "none";
				}
			}
		}
	}
}

function isAllMenu(bool){
	if(!util.$("mainNavi")) return;
	util.$("mainNavi").style.height = (bool) ? "auto" : "194px";
}

function topGo(){
	if(!util.$("wrap")||!util.$("topGo")) return;
	var doc = util.$("wrap");
	var obj = util.$("topGo");
	obj.moveact = null;
	obj.bMar = 126;
	obj.tMar = 228;
	obj.maxH = doc.offsetHeight-obj.bMar;
	function objTop(){
		var topPos = ( document.documentElement.clientHeight > obj.maxH ) ? obj.maxH : document.documentElement.clientHeight+document.documentElement.scrollTop-obj.bMar;
		topPos = (topPos < obj.tMar) ? obj.tMar : topPos;
		return topPos;
	}
	obj.style.top = objTop()+"px";
	util.move(obj,"style.top",parseInt(obj.style.top),objTop(),((parseInt(obj.style.top)>objTop())?0:1),0.35,30)
	obj.style.visibility = "visible";
	util.AddEvent(window, "resize", function(){util.move(obj,"style.top",parseInt(obj.style.top),objTop(),((parseInt(obj.style.top)>objTop())?0:1),0.075,1)});
	util.AddEvent(window, "scroll", function(){util.move(obj,"style.top",parseInt(obj.style.top),objTop(),((parseInt(obj.style.top)>objTop())?0:1),0.075,1)});
}
var family = {
	objBox : null, obj : null, btn : null, familyAct : null, familySetAct : null, objW : 0, repeat : false,
	set : function(){
		if(!util.$("familySite")) return;
		family.objBox = util.$("familySite");
		family.obj = util.$("familySite").getElementsByTagName("div")[0];
		family.btn = util.$("familySite").getElementsByTagName("p")[0];
		if(!family.obj.style.width) family.obj.style.width=family.objW+"px";
		if(!family.objBox.style.width) family.objBox.style.width=family.btn.offsetWidth+"px";

		family.objBox.onmouseover = function(){family.repeat=true; over(); };
		family.objBox.onmouseout = function(){family.repeat=false; family.familyAct = setTimeout(out,300); };
		function over(){
			clearTimeout(family.familyAct);
			clearTimeout(family.familySetAct);
			family.objBox.style.width=(family.btn.offsetWidth+family.obj.scrollWidth)+"px";
			if(family.repeat) util.move(family.obj,"style.width",parseInt(family.obj.style.width),family.obj.scrollWidth,1,0.2,20);
			family.familySetAct = setTimeout(out,2000);
		}
		function out(){
			clearTimeout(family.familyAct);
			if(!family.repeat){
				util.move(family.obj,"style.width",parseInt(family.obj.style.width),family.objW,0,0.2,20,"family.objBox.style.width=family.btn.offsetWidth+'px'");
			}
		}
	}
}

function tableStyle(){
try{
	if(document.getElementsByTagName("table").length<1) return;
	var styleName = ["dType1"];
	var styleName2 = "none";
	var obj = document.getElementsByTagName("div");
	for(i=0;i<obj.length;i++){
		if((obj[i].className.indexOf(styleName[0])>-1 || obj[i].className.indexOf(styleName[1])>-1) && !(obj[i].className.indexOf(styleName2)>-1)){
			var objTr = obj[i].getElementsByTagName("table")[0].getElementsByTagName("tbody")[0].rows;
			for(j=0;j<objTr.length;j++){
				objTr[j].onmouseover = function(){ this.className += " tOver";  }
				objTr[j].onmouseout = function(){ this.className = this.className.replace("tOver",""); }
			}
		}
	}
}catch(e) {  }
}

util.AddEvent(window, "load", topGo); //Top¹öÆ° Ãß°¡
util.AddEvent(window, "load", function(){ family.set() }); //family Site
util.AddEvent(window, "load", tableStyle);

function subMenu(){
	var obj = util.$("menuCrop");
	var objBox = util.$("smList");
	var objW = [obj.scrollWidth,24];
	var objH = [obj.scrollHeight,0];
	obj.style.height=obj.offsetHeight+"px";
	objBox.style.width=objBox.offsetWidth+"px";
	if(objBox.className=="close"){
		objBox.className = "open";
		util.move(obj,"style.height",objH[1],objH[0],1,0.2,20);
		util.move(objBox,"style.width",objW[1],objW[0],1,0.2,20);
	}else{
		objBox.className = "close";
		util.move(obj,"style.height",objH[0],objH[1],0,0.2,20);
		util.move(objBox,"style.width",objW[0],objW[1],0,0.2,20);
	}
}

function indexCont(obj){
	if(!obj || !util.$("subPoint")) return;
	var objW = 0;
	if(!obj.style.width){
		obj.style.width=obj.scrollWidth+"px";
		util.$("subPoint").style.width="auto";
	}
	util.$("doorBtn").className=(util.$("doorBtn").className=="close") ? "open" : "close";
	var objW = (util.$("doorBtn").className=="close") ? 0 : obj.scrollWidth ;
	var pORm = (util.$("doorBtn").className=="close") ? 0 : 1 ;
	var fun = (util.$("doorBtn").className=="close") ? "util.$('subPoint').style.width=(util.$('doorBtn').offsetWidth+7)+'px'" : "" ;
	if(fun=="") util.$("subPoint").style.width="auto";

	util.move(obj,"style.width",parseInt(obj.style.width),objW,pORm,0.3,70,fun);
}

//calendar
var cal={

	obj : null,
	classname : "minCal",
	settarget : null,
	today : null,
	date : [0,0],
	days : [31,0,31,30,31,30,31,31,30,31,30,31],

	show : function(target,settarget,positionx,positiony){
		if(!cal.obj){

			var style="position:absolute;display:none;";
			if(user.IE) cal.obj=document.createElement("<div class=\""+cal.classname+"\" style=\""+style+"\">");
			else{
				cal.obj=document.createElement("div");
				cal.obj.setAttribute("class",cal.classname);
				cal.obj.setAttribute("style",style);
			}

			var html="";
			html+="<div class=\"ynm\">";
			html+="	<a href=\"#\"><img src=\"../images/common/btn_mincalprevm.gif\" alt=\"ÀÌÀü´Þ\" /></a>";
			html+="	<strong>2008.11</strong>";
			html+="	<a href=\"#\"><img src=\"../images/common/btn_mincalnextm.gif\" alt=\"´ÙÀ½´Þ\" /></a>";
			html+="</div>";
			html+="<div class=\"table\">";
			html+="</div>";
			cal.obj.innerHTML=html;
			cal.obj.tbarea=cal.obj.childNodes[1];
			cal.obj.tarea=cal.obj.childNodes[0].getElementsByTagName("strong")[0];

			var btn=cal.obj.childNodes[0].getElementsByTagName("a");
			btn[0].onclick=function(){
				cal.set("prevmonth");
				return false;
			}
			btn[1].onclick=function(){
				cal.set("nextmonth");
				return false;
			}

			document.body.appendChild(cal.obj);
			
			var today=new Date();
			cal.today=[today.getFullYear(),today.getMonth(),today.getDate()];

		}
		cal.set();

		cal.settarget=(typeof(settarget)=="string")? util.$(settarget) : settarget;

		var pos=getoffsetpos(target);
		cal.obj.style.left="-10000px";
		cal.obj.style.display="block";

		if(!positionx) positionx="justify-left";
		if(!positiony) positiony="bottom";

		if(positionx=="left") cal.obj.style.left=(pos[0]-cal.obj.offsetWidth)+"px";
		else if(positionx=="justify-left") cal.obj.style.left=pos[0]+"px";
		else if(positionx=="right") cal.obj.style.left=(pos[0]+target.offsetWidth)+"px";
		else if(positionx=="justify-right") cal.obj.style.left=(pos[0]+target.offsetWidth-cal.obj.offsetWidth)+"px";

		if(positiony=="top") cal.obj.style.top=(pos[1]-cal.obj.offsetHeight)+"px";
		else if(positiony=="justify-top") cal.obj.style.top=pos[1]+"px";
		else if(positiony=="bottom") cal.obj.style.top=(pos[1]+target.offsetHeight)+"px";

		target.onmouseout=sethidetimer;
		if(user.IE) target.attachEvent("onmouseover",clearhidetimer);
		else target.addEventListener("mouseover",clearhidetimer,false);
		cal.obj.onmouseover=clearhidetimer;
		cal.obj.onmouseout=sethidetimer;

		var hidetimer=null;
		function sethidetimer(){
			hidetimer=setTimeout(cal.hide,300);
		}
		function clearhidetimer(){
			clearTimeout(hidetimer);
		}
	},

	hide : function(){
		cal.obj.style.display="none";
	},

	set : function(f){

		if(!f){
			cal.date[0]=new Date().getFullYear();
			cal.date[1]=new Date().getMonth();
		}else{
			if(f=="prevyear") cal.date[0]--;
			else if(f=="nextyear") cal.date[0]++;
			else if(f=="prevmonth"){
				if(cal.date[1]==0){
					cal.date[0]--;
					cal.date[1]=11;
				}else cal.date[1]--;
			}else if(f=="nextmonth"){
				if(cal.date[1]==11){
					cal.date[0]++;
					cal.date[1]=0;
				}else cal.date[1]++;
			}
		}

		cal.obj.tarea.innerHTML=cal.date[0]+". "+(cal.date[1]+1);

		var week=new Date(cal.date[0],cal.date[1],1).getDay();
		var days=(cal.date[1]==1)? new Date(new Date(cal.date[0],2,1)-(24*60*60*1000)).getDate() : cal.days[cal.date[1]];

		var start=false;
		var day=1;
		var html="<table summary=\"´Þ·Â\">";
		for(var i=0,max=Math.ceil((days+week)/7); i<max; i++){
			html+="<tr>";
			for(var j=0; j<7; j++){
				if((cal.date[0]==cal.today[0]) && (cal.date[1]==cal.today[1]) && (day==cal.today[2])) html+="<td class=\"today\">";
				else html+=(j==0)? "<td class=\"sun\">" : (j==6)? "<td class=\"sat\">" : "<td>";
				if(!start && j==week) start=true;
				if(start && day<=days) html+="<a href=\"#\" onclick=\"cal.select("+day+");return false;\">"+(day++)+"</a>";
				html+="</td>";
			}
			html+="</tr>";
		}
		html+="</table>";

		cal.obj.tbarea.innerHTML=html;

	},

	select : function(day){
		cal.settarget.value=cal.date[0]+"-"+((cal.date[1]<9)?"0":"")+""+(cal.date[1]+1)+"-"+((day<10)?"0":"")+""+day;
		cal.hide();
	}

}

// get offset position
function getoffsetpos(tg){
	var pos=[0,0];
	function addpos(left,top){
		pos[0]+=left;
		pos[1]+=top;
	}
	for(var i=0,cobj=tg; !cobj.tagName.toLowerCase().match(/body|html/); cobj=cobj.offsetParent,i++){
		addpos(cobj.offsetLeft,cobj.offsetTop);
		if(!user.Opera && i>0){
			if(user.IE) addpos(cobj.clientLeft,cobj.clientTop);
			else if(cobj.tagName.toLowerCase().match(/table|thead|tbody|tfoot|th|td/)){
				if(user.Apple) addpos(cobj.clientLeft,cobj.clientTop);
				else addpos(cobj.offsetWidth-cobj.clientWidth,cobj.offsetHeight-cobj.clientHeight);
			}
		}
	}
	return pos;
}