function NewWindow(url, winName, w, h, scroll) {
	var win = null;
	
	LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
	TopPosition  = (screen.height) ? (screen.height-h)/2 : 0;				
	settings='height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',resizable=no, scrollbars=' + scroll;
	win=window.open(url,winName,settings);
	return win;
}

/* 팝업창띄우기 */
function winOpen(file,wid,hei){

	if(file==""){ alert('페이지 준비중'); return false;}
	window.open(file, 'add', 'status=no, toolbar=no, location=no, menubar=no, directories=no, resizeable=no, scrollbars=yes, width='+wid+', height='+hei+',top=200,left=400');
}


//document.oncontextmenu = function (e) {
//  alert("상품이미지 무단도용방지를 위하여\n\n마우스 오른쪽 버튼을 사용하실 수 없습니다!");
//  return false;
//}
//document.onselectstart = function (e) {
//  return false;
//}


// 에디터 사용시 폼값과 에디트의 값을 초기화
function formReset(formName) {
  if(confirm('게시글을 새로 작성하시겠습니까?')) {
    eval("document."+formName).reset();
    myeditor.resetEditArea('');
  }
}

function isLogin(url,msg,param,prdIdx) {
  if (msg == "") msg = "로그인이 필요합니다.\지금 로그인하시겠습니까?"
  if(confirm(msg)) {

    if(param != '' && url.indexOf('?')==-1) url+=('?'+param);
    if(prdIdx!= '' && prdIdx != '0' && prdIdx && url.indexOf('prdIdx')==-1) url+=('&IDX='+prdIdx);

    location.href="/member/login.asp?goUrl="+escape(url);
  } else {
    return;
  }
}

function confirmLogin(url,tar,param,prdIdx) {
  if(confirm("로그인이 필요합니다.\지금 로그인하시겠습니까?")) {
    if(param != '' && url.indexOf('?')==-1) url+=('?'+param);
    if(prdIdx!= '' && prdIdx != '0' && prdIdx && url.indexOf('prdIdx')==-1) url+=('&IDX='+prdIdx);
    eval(tar+'.location').href="/member/login.asp?goUrl="+escape(url);
  } else {
    return;
  }
}

function isLoginPop(url,msg,param,prdIdx) {
  NewWindow("/popup/pop_login.asp", "shopLogin", "437", "579", "no");
}

function viewRss(opt) {
  //location.href = "/library/common/rss.php";
  window.open("/library/common/rss.php", "seoulRss");
}

// InnoAP 스크립트 파일
function numberFormat(nFileSize) {
  var nn = new String(nFileSize / 1024);
  var ns = nn.split(".");
  var n1 = new String("")
  var n2 = new String("0")

  for (var i = 0; i < ns[0].length; i++) {
    var j = ns[0].length - i;

    if (j % 3 == 0 && j != ns[0].length)
      n1 = n1 + ",";

      n1 = n1 + ns[0].slice(i, i+1);
  }
  if (ns.length > 1)
      n2 = ns[1].slice(0, 2);

  return n1 + "." + n2;
}

function InnoAPBeforeAddFile(strFileName, InnoAPObj) {
  if (InnoAP_CheckExt(strFileName) == false)
    return false;

  InnoAPObj.RemoveAllFiles();

  return true;
}

function InnoAPBeforeAddFile2(strFileName, InnoAPObj) {
  if (InnoAP_CheckExt(strFileName) == false)
    return false;

  return true;
}
// canvas document.body의 DOCTYPE 표준 모드 대응
var canvas = document[ 'CSS1Compat' == document.compatMode ? 'documentElement' : 'body'];

//마우스 X좌표 취득
function getMouseX(e) {	
  if(document.all) return canvas.scrollLeft+event.clientX;
  else if(document.getElementById) return e.pageX;
}

//마우스 Y좌표 취득
function getMouseY(e) {
  if(document.all) return canvas.scrollTop+event.clientY;
  else if(document.getElementById) return e.pageY;
}
// 스크랩
function Scrap(mode,e){
	var posy = 0;
	if(mode == 'up'){	  
	  posy = getMouseY(e) - 85;
	}else{
	  posy = getMouseY(e) - 325;
	}
	document.getElementById("scrap").style.top = posy + "px";
	document.getElementById("scrap").style.display = "block";
	document.getElementById("sendmail").style.display = "none";
//	document.scrap.sr_subject.focus();
}
function scrapClose(){
	document.getElementById("scrap").style.display = "none";
}
function scrapChk(objF){
	var form = objF;
	if(CheckInput(form.sr_subject,"スクラップ名を入力してください。")){ return false;}

	return true;
}
//이메일 보내기
function sendMail(mode,e){
	var posy = 0;
	if(mode == 'up'){	  
	  posy = getMouseY(e) - 85;
	}else{
	  posy = getMouseY(e) - 585;
	}
	document.getElementById("sendmail").style.top = posy + "px";	
	document.getElementById("sendmail").style.display = "block";
	document.getElementById("scrap").style.display = "none";
	document.send_mail.from_name.focus();
}
function mailClose(){	
	document.getElementById("sendmail").style.display = "none";	
}
function mailChk(objF){	
	var form = objF;
	if(CheckInput(form.from_name,"Enter the Name")){ return false;}
	if(CheckInput(form.from_address,"Enter the Email Address")){ return false;}
	if(CheckInput(form.to_address,"Send To Enter the Email Address")){ return false;}
	if(CheckInput(form.mail_content,"Enter the Content")){ return false;}

	return true;
}
//input 공백체크
function CheckInput(val,msg){
	if(!val.value){
		alert(msg);
		val.focus();
		return true;
	}
	return false;
}

//라디오 버튼 체크
function radio_chk(val,msg){
	for(var i=0; i<val.length; i++) {
		if(val[i].checked == true) {
			return false;
		}			
	}
	alert(msg);
	return true;
 }
/* definition list toggle */
function initToggle(tabContainer) {
  triggers = tabContainer.getElementsByTagName("a");
  var nm;

  for(i = 0; i < triggers.length; i++) {
    nm = triggers.item(i).href.split('#')[1];
    if (nm){
      triggers.item(i).targetEl = document.getElementById(nm);
      triggers.item(i).targetBtn = document.getElementById(nm + '_btn');
    }

    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";
        this.targetBtn.src = '/images/btn/faq_down.gif';
        tabContainer.current = null;
      } else {
        if (tabContainer.current) {
          tabContainer.current.targetEl.style.display = "none";
          tabContainer.current.targetBtn.src = '/images/btn/faq_down.gif';
        }
        this.targetEl.style.display = "block";
        this.targetBtn.src = '/images/btn/faq_up.gif';
        tabContainer.current = this;
      }
      return false;
    }
    triggers.item(i).onFocus = function() {
      this.blur();
    }
  }
}


//png
function setPng24(obj) {
    obj.width=obj.height=1;
    obj.className=obj.className.replace(/\bpng24\b/i,'');
    obj.style.filter =
    "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+ obj.src +"',sizingMethod='image');"
    obj.src=''; 
    return '';
} 

// 사파리용 따라다니는 객체
//new Floating(적용할개체 , X축여백 , Y축여백 , 미끄러지는속도:작을수록빠름..기본20 , 빠르기:작을수록부드러움..기본10);
function Floating(FloatingObj,MarginX,MarginY,Percentage,setTime) {
	this.FloatingObj = FloatingObj;
	this.MarginX = (MarginX) ? MarginX : 0;
	this.MarginY = (MarginY) ? MarginY : 0;
	this.Percentage = (Percentage) ? Percentage : 20;
	this.setTime = (setTime) ? setTime : 10;
	this.FloatingObj.style.position = "absolute";
	this.Body = null;
	this.setTimeOut = null;
	this.Run();
}

Floating.prototype.Run = function () {
	if ((document.documentElement.scrollLeft + document.documentElement.scrollTop) > (document.body.scrollLeft + document.body.scrollTop)) {
		this.Body = document.documentElement;
	} else {
		this.Body = document.body;
	}

	var This = this;
	var FloatingObjLeft = (this.FloatingObj.style.left) ? parseInt(this.FloatingObj.style.left,10) : this.FloatingObj.offsetLeft;
	var FloatingObjTop = (this.FloatingObj.style.top) ? parseInt(this.FloatingObj.style.top,10) : this.FloatingObj.offsetTop;
	var DocLeft = this.Body.scrollLeft + this.MarginX;
	var DocTop = this.Body.scrollTop + this.MarginY;

	var MoveX = Math.abs(FloatingObjLeft - DocLeft);
	MoveX = Math.ceil(MoveX / this.Percentage);
	var MoveY = Math.abs(FloatingObjTop - DocTop);
	MoveY = Math.ceil(MoveY / this.Percentage);

	if (FloatingObjLeft < DocLeft) {
		this.FloatingObj.style.left = FloatingObjLeft + MoveX + "px";
	} else {
		this.FloatingObj.style.left = FloatingObjLeft - MoveX + "px";
	}

	if (FloatingObjTop < DocTop) {
		this.FloatingObj.style.top = FloatingObjTop + MoveY + "px";
	} else {
		this.FloatingObj.style.top = FloatingObjTop - MoveY + "px";
	}

	window.clearTimeout(this.setTimeOut);
	this.setTimeOut = window.setTimeout(function () { This.Run(); },this.setTime);
}

// 따라다니는 레이어 
function positionMessage(){   
	//dvSidebar menu id
	var elem=document.getElementById("quick_top");   
	// 초기 top 위치 
	elem.style.top=document.documentElement.scrollTop + 540 + "px"; 				
	setTimeout("moveElement()", 10); 
} 

function moveElement(){ 
	var elem = document.getElementById("quick_top"); 
	start = parseInt (elem.style.top);  
	end = document.documentElement.scrollTop + 540; // limit 정하기
	 
	//start 와 end 같으면 멈춘다.
	if ( start != end ) {
		scale =   Math.ceil( Math.abs( end - start ) / 10 );		
		
		//스크롤이 상단으로 이동이시 마이너스값...
		if ( end < start )	{
			scale = -scale; // alert("end = "+end+" start = "+start);
		}
			elem.style.top = parseInt (elem.style.top)+ scale + "px"; 
	}	
	setTimeout("moveElement()", 10);
}

function topMove(){	 
	 document.documentElement.scrollTop = 0 +"px";
}
 
function addLoadEvent(func){	
  var oldonload = window.onload;
  if( navigator.userAgent.toLowerCase().indexOf('safari') == "-1") {
    if (typeof window.onload != 'function') {	 
      window.onload = func;
    } else {
      window.onload = function() {
        oldonload();
        func();
      }
    }
  } else {
    //new Floating(적용할개체 , X축여백 , Y축여백 , 미끄러지는속도:작을수록빠름..기본20 , 빠르기:작을수록부드러움..기본10); 
    new Floating(document.getElementById("quick_top"),925,120,20,10); 
  } 
}

//function printWindow() {
//  window.print();
//} 
//var tempBody;
//window.onbeforeprint = function() {
//  tempBody = document.body.innerHTML;
//  document.body.innerHTML = content.innerHTML;
//}
//window.onafterprint = function() {
//  document.body.innerHTML = tempBody;
//}
var tempBody; //잠시 동안 body태그 안의 내용을 담아둘 변수

function beforePrint() //인쇄 하기 전에 실행되는 내용
{
 tempBody = document.body.innerHTML; //body 안의 내용을 변수에 담는다.
 document.body.innerHTML = content.innerHTML; //body 안의 내용을 myPrint의 내용으로 바꾼다.
}
function afterPrint() //인쇄가 끝난 후 실행되는 내용
{
 document.body.innerHTML = tempBody; //body 안의 내용을 원래대로 되돌린다.
}
function printWindow(pri) //인쇄에 사용할 함수
{
	if(pri == 'Frame'){
		newsFrame.focus();
	}else{	
    window.onbeforeprint = beforePrint;
    window.onafterprint = afterPrint;
  }
 window.print();
}

// LEFT 메뉴 플레시에 따른 이동 함수
function leftBannerMove(num) {
  var posTop;
  if( num ) posTop = num + "px";
  else      posTop = "200px";

  if( $("local_banner")) {
    $("local_banner").style.top = posTop;
  }
}

// 탭메뉴 컨텐츠 보기
function contentView(url, pidx, sub) {
  var subParam;
  if ( sub ) {
    subParam = "&sub="+sub;
  } else {
    subParam = "";
  }
  location.href = url+"?pidx=" + pidx + subParam;
}

function tabRollOver(code,pidx, sub) {
  var imgCnt = $("tabDiv").getElementsByTagName("img").length;
 
  for(var i=1; i<=imgCnt; i++) {
    $("btnTab"+i).src = "/images/tab/"+code+"/tab"+i+".gif";
  }
  $("btnTab"+pidx).src = "/images/tab/"+code+"/on_tab"+pidx+".gif";

  if( sub ) {
    var simgCnt = $("stabDiv").getElementsByTagName("img").length - 1;
    for(var j=1; j<=simgCnt; j++) {
      $("sbtnTab"+j).src = "/images/tab/"+code+"/tab"+pidx+"_s"+j+".gif";
    }
    $("sbtnTab"+sub).src = "/images/tab/"+code+"/on_tab"+pidx+"_s"+sub+".gif";
  }
}

function leftFlashDiv(num) {
  //$("area_txt").innerHTML = num;
  $("area_flash").style.height = num+"px";
}

// 플래시영역변경
function pChange(mode) {
	//alert(mode);
  if(mode == "over" ) {
    document.getElementById("langSelect").className = "langSelect_over";
  } else if(mode == "out" ) {
    document.getElementById("langSelect").className = "langSelect_out";
  }
}

var prevNum = 0;
	function viewMap(eleNum){		
 
			if(prevNum != 0){
				document.getElementById("view"+prevNum).style.zIndex = "";	
				document.getElementById("view"+prevNum).style.display = "none";		
				prevNum == 0;
			}else{			
 
				document.getElementById("view"+eleNum).style.display = "block";
				document.getElementById("view"+eleNum).style.zIndex = "500"; 
				
			}
		prevNum = eleNum; 

	}
function viewOver(eleNum){

	obj=document.getElementById("view"+eleNum);
	objRect=document.getElementById("rect_"+eleNum);
	if(obj.style.display == "block") return false;
	obj.style.display ="block";
	elePos = objRect.getAttribute("coords").split(","); //coords에서 시작점 좌표 가져오기

	objLeft = (elePos[0]-obj.clientWidth/2)+10; //위치 - 레이어 넓이값 + 화살표 넓이값만큼 더하기.
	objTop = elePos[1]-obj.clientHeight; //위치 -레이어 높이값+x)

	obj.style.left=objLeft+"px";
	obj.style.top=objTop+"px";
	obj.style.zIndex = "1000";
	//alert("left :"+elePos[0]+" top :"+elePos[1]);
	return false;
}
function viewOut(eleNum){
	if(eleNum == prevNum) return false;
	obj=document.getElementById("view"+eleNum);
	obj.style.zIndex = "";
	obj.style.display ="none";
	return false;
}
function cityOver(eleNum,posMode){

	obj=document.getElementById("view"+eleNum);
	objRect=document.getElementById("rect_"+eleNum);
	if(obj.style.display == "block") return false;
	obj.style.display ="block";
	elePos = objRect.getAttribute("coords").split(","); //coords에서 시작점 좌표 가져오기
	if(posMode == "left"){
		// 레이어 왼쪽...위치..
		objLeft = (elePos[0]-obj.clientWidth)+1 ; //위치 - 레이어 넓이값
		objTop = elePos[1] - 22;// 화살표 내려온 값만큼..빼기
	}else{
		// 레이어 위쪽 위치
		//alert(elePos[2] - elePos[0]);
		objLeft = elePos[0]-20;//-(elePos[2] - elePos[0])/2; //화살표 가운데 위치하기위해 (끝지점- 시작점 )/2;
		objTop =elePos[1] -obj. clientHeight ;// 화살표 내려온 값만큼..빼기
	}

	obj.style.left=objLeft+"px";
	obj.style.top=objTop+"px";
	obj.style.zIndex = "1000";
	//alert("left :"+elePos[0]+" top :"+elePos[1]);
	return false;
}
function cityOut(eleNum){
	if(eleNum == prevNum) return false;
	obj=document.getElementById("view"+eleNum);
	obj.style.zIndex = "";
	obj.style.display ="none";
	return false;
}


// ViewLayer visible &amp; btn close
function ViewLayer() {
	var layer = document.getElementById("Pop");
	var style = layer.style.display;
	layer.style.display = (style == "none") ? "block" : "none";
}
function CloseLayer(){
	document.getElementById('Pop').style.display = "none";
}

/* 10월 행사 관련 레이어 */

function apply(e){
	var posy = 0;
	var posx = 0;
	  posy = getMouseY(e) - 475;
		posx = getMouseX(e) - 250;
		$("essay2009_application").style.top = posy + "px";
		$("essay2009_application").style.left = posx + "px";
		$("essay2009_application").style.display = "block";

}

function CheckForm(){
	var form = document.eventForm;
			
		if(CheckInput(form.oe_name,"Please enter your name.")){return false;}			
		if(CheckInput(form.oe_email,"Please enter your E-mail.")){return false;}			
		if(CheckInput(form.oe_hp,"Please enter your phone number.")){return false;}			
//		if(CheckInput(form.oe_msg,"Please enter your message.")){return false;}
		if(CheckInput(form.oe_file,"Please enter your file.")){return false;}
}

function CloseEvent(){
	$("essay2009_application").style.display = "none";
}

// 남산 레이어
var tmpLayer = 0;
function OpenLayer(val){

	$(val).style.display = "block";
	if(tmpLayer != 0 && tmpLayer != val){
		if(tmpLayer != "popMap"){
			$(tmpLayer).style.display = "none";
		}
	}
tmpLayer = val;
}
// 남산 레이어 닫기
function popCloseLayer(val){
	$(val).style.display = "none"
}
// 남산 레이어 next,prev 보기
function popChange(mode,num){

	if(mode == 'next'){		
		if(num == 12){
			alert("Last Image");
		}else{
			num = num + 1;
			$("popCon_"+num).style.display = "block";
			$(tmpLayer).style.display = "none";
		}
	}else{		
		if(num == 1){
			alert("First Image");
		}else{
			num = num - 1;
			$("popCon_"+num).style.display = "block";
			$(tmpLayer).style.display = "none";
		}
	}
	tmpLayer = "popCon_"+num;
}

// 남산 상세보기 레이어 이미지
function imgPopView(num,val){
	$("popImg_"+num).src="/images/cav/ea/large_"+val+".jpg";
}

//한강 탭 
function initTab(tabContainerID, targetName, index){
	var tabContainer = document.getElementById(tabContainerID);
	var tabAnchor = tabContainer.getElementsByTagName("a");
	var tabImages = tabContainer.getElementsByTagName("img");

	var arrEle = new Array();
	for(var i=0; i<tabAnchor.length; i++) {
		if (tabAnchor.item(i).className == "tab") arrEle.push(tabAnchor.item(i));
	}
 
	for(var i=0; i<arrEle.length; i++) {
		if(document.getElementById(targetName + i)){
			document.getElementById(targetName + i).style.display ="none";
		}
		if(tabImages[i].src.indexOf('_on.gif') != -1){
			tabImages[i].src = tabImages[i].src.replace("_on.gif", ".gif");
		}
	}
	if(tabImages[index].src.indexOf('_on.gif') == -1)
		tabImages[index].src = tabImages[index].src.replace(".gif", "_on.gif");

	if(document.getElementById(targetName + index))
		document.getElementById(targetName + index).style.display = "block";
}

//한강 탭안의 탭
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");
				} else {
					currentmenu.className = currentmenu.className.replace(" on", "");
				}
			}
			this.targetEl.style.display = "";
			if (this.imgEl) {
				this.imgEl.src = this.imgEl.src.replace(".gif", "_on.gif");
			} else {
				this.className += " on";
			}
			this.container.current = this;

			return false;
		};

		if (!thismenu.container.first)
			thismenu.container.first = thismenu;
	}
	if (tabContainer.first)
		tabContainer.first.onclick();
}

/*
셀렉트 박스
감추기/보이기 */
//function togglefaq(ele){

// alert(ele);
//	if(typeof ele == "string") ele = document.getElementById(ele);
	// css의 display 값 받아오기
//	var value = null;
//	if(ele.currentStyle) var value = ele.currentStyle['display'];
//	else if(document.defaultView.getComputedStyle) var value = document.defaultView.getComputedStyle(ele,null)['display'];
//	// none일때와 아닐때 다르게 먹이기
//	if(value != "none") (ele.style.display != 'none') ? ele.style.display = 'none' : ele.style.display = '';
//	else (ele.style.display != 'block') ? ele.style.display = 'block' : ele.style.display = ''	
//	return false;
//}



/*
셀렉트 박스
감추기/보이기 */
function togglefaq(ele){
 if(document.getElementById(ele).style.display=="none"){
  for(i=1;i<=24;i++) {
  	document.getElementById("answer"+i).style.display="none";
  	document.getElementById("answer"+i+"_btn").src="/images/btn/faq_down.gif"
  }
  document.getElementById(ele).style.display="block";
	document.getElementById(ele+"_btn").src="/images/btn/faq_up.gif"
 }
 else{
  document.getElementById(ele).style.display="none";
  document.getElementById(ele+"_btn").src="/images/btn/faq_down.gif"
 }
}



/*롤오버 이미지*/
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
