﻿// JavaScript Document

//테두리가 둥근테두리
function roundTable(objID) {
var obj = document.getElementById(objID);
var Parent, objTmp, Table, TBody, TR, TD;
var bdcolor, bgcolor, Space;
var trIDX, tdIDX, MAX;
var styleWidth, styleHeight;

// get parent node
Parent = obj.parentNode;
objTmp = document.createElement('SPAN');
Parent.insertBefore(objTmp, obj);
Parent.removeChild(obj);

// get attribute
bdcolor = obj.getAttribute('rborder');
bgcolor = obj.getAttribute('rbgcolor');
radius = parseInt(obj.getAttribute('radius'));
if (radius == null || radius < 1) radius = 1;
else if (radius > 6) radius = 6;

MAX = radius * 2 + 1;

/*
create table {{
*/
Table = document.createElement('TABLE');
TBody = document.createElement('TBODY');

Table.cellSpacing = 0;
Table.cellPadding = 0;

for (trIDX=0; trIDX < MAX; trIDX++) {
TR = document.createElement('TR');
Space = Math.abs(trIDX - parseInt(radius));
for (tdIDX=0; tdIDX < MAX; tdIDX++) {
TD = document.createElement('TD');

styleWidth = '1px'; styleHeight = '1px';
if (tdIDX == 0 || tdIDX == MAX - 1) styleHeight = null;
else if (trIDX == 0 || trIDX == MAX - 1) styleWidth = null;
else if (radius > 2) {
if (Math.abs(tdIDX - radius) == 1) styleWidth = '2px';
if (Math.abs(trIDX - radius) == 1) styleHeight = '2px';
}

if (styleWidth != null) TD.style.width = styleWidth;
if (styleHeight != null) TD.style.height = styleHeight;

if (Space == tdIDX || Space == MAX - tdIDX - 1) TD.style.backgroundColor = bdcolor;
else if (tdIDX > Space && Space < MAX - tdIDX - 1) TD.style.backgroundColor = bgcolor;

if (Space == 0 && tdIDX == radius) TD.appendChild(obj);
TR.appendChild(TD);
}
TBody.appendChild(TR);
}

/*
}}
*/

Table.appendChild(TBody);

// insert table and remove original table
Parent.insertBefore(Table, objTmp);
}

//통합검색
function sFocus(i) {
	(i).style.border='1px solid #696969';
	(i).style.background='#fff none';
	(i).style.letterSpacing='normal';
}
function sBlur(i) {
	(i).style.border='1px solid #696969';
}


//롤링되는 배너
var sRepeat=null;
 function doScrollerIE(dir, src, amount) {
  if (amount==null) amount=20; //속도
  if (dir=="left")
   document.all[src].scrollLeft-=amount;
  else
   document.all[src].scrollLeft+=amount;
  if (sRepeat==null)
   sRepeat = setInterval("doScrollerIE('" + dir + "','" + src + "'," + amount + ")",100);
  return false }
  window.document.onmouseout = new Function("clearInterval(sRepeat);sRepeat=null");
  window.document.ondragstart = new Function("return false");

  // 화면 확대 축소 시작 IE 전용 

var nowZoom = 100; // 현재비율 
var maxZoom = 500; // 최대비율(500으로하면 5배 커진다) 
var minZoom = 80; // 최소비율 

//화면 키운다. 
function zoomIn() 
{ 
    if (nowZoom < maxZoom) 
    { 
        nowZoom += 10; //25%씩 커진다. 
    } 
    else 
    { 
        return; 
    } 
    document.body.style.zoom = nowZoom + "%";
	/*document.getElementById("wrap").style.zoom = nowZoom + "%"; */

	var ue = navigator.userAgent.toLowerCase();
	 if(ue.indexOf('firefox')!=-1){ alert("익스플로러에서만 동작합니다."+"\n파이어폭스 브라우저 메뉴 [보기]-[크기조정]을 이용하세요."); }
	 else if(ue.indexOf('opera')!=-1){ alert("익스플로러에서만 동작합니다."+"\n오페라 브라우저 메뉴 [보기]-[Zoom]을 이용하세요."); }
	 else if(ue.indexOf('chrome')!=-1){ alert("익스플로러에서만 동작합니다."+"\n구글 크롬 브라우저 메뉴 [글꼴 크기]를 이용하세요."); }
	 else if(ue.indexOf('safari')!=-1){ /* alert("익스플로러에서만 동작합니다."+"\n사파리 브라우저 메뉴 [보기]-[텍스트 크게]/[텍스트 작게]를 이용하세요."); */ }
	 else if(ue.indexOf('msie')!=-1){  }
	 else { alert("익스플로러에서만 동작합니다.\n"+ue+"\n브라우저 메뉴의 확대축소 기능을 이용하세요."); }
	 if(((value=="plus")&&(curRate >= maxRate))||((value == "minus") && (curRate <= minRate))){return;} 
	  if(value=="plus"){curRate = parseInt(curRate) + parseInt(zoomRate);}
	  else if (value=="minus"){curRate = parseInt(curRate) - parseInt(zoomRate);}
	  else{curRate = 100}
	  document.body.style.zoom = curRate + '%';
} 


//화면 줄인다. 
function zoomOut() 
{ 
    if (nowZoom > minZoom) 
    { 
        nowZoom -= 10; //25%씩 작아진다. 
    } 
    else 
    { 
        return; 
    } 
    document.body.style.zoom = nowZoom + "%"; 
	/*document.getElementById("wrap").style.zoom = nowZoom + "%";*/

	 var ue = navigator.userAgent.toLowerCase();
 if(ue.indexOf('firefox')!=-1){ alert("익스플로러에서만 동작합니다."+"\n파이어폭스 브라우저 메뉴 [보기]-[크기조정]을 이용하세요."); }
 else if(ue.indexOf('opera')!=-1){ alert("익스플로러에서만 동작합니다."+"\n오페라 브라우저 메뉴 [보기]-[Zoom]을 이용하세요."); }
 else if(ue.indexOf('chrome')!=-1){ alert("익스플로러에서만 동작합니다."+"\n구글 크롬 브라우저 메뉴 [글꼴 크기]를 이용하세요."); }
 else if(ue.indexOf('safari')!=-1){ /* alert("익스플로러에서만 동작합니다."+"\n사파리 브라우저 메뉴 [보기]-[텍스트 크게]/[텍스트 작게]를 이용하세요."); */ }
 else if(ue.indexOf('msie')!=-1){  }
 else { alert("익스플로러에서만 동작합니다.\n"+ue+"\n브라우저 메뉴의 확대축소 기능을 이용하세요."); }
 if(((value=="plus")&&(curRate >= maxRate))||((value == "minus") && (curRate <= minRate))){return;} 
  if(value=="plus"){curRate = parseInt(curRate) + parseInt(zoomRate);}
  else if (value=="minus"){curRate = parseInt(curRate) - parseInt(zoomRate);}
  else{curRate = 100}
  document.body.style.zoom = curRate + '%';
} 

//화면 원래대로 
function zoomDefault() 
{ 
    nowZoom = 100; 
    document.body.style.zoom = nowZoom + "%"; 
	/*document.getElementById("wrap").style.zoom = nowZoom + "%";*/

	 var ue = navigator.userAgent.toLowerCase();
 if(ue.indexOf('firefox')!=-1){ alert("익스플로러에서만 동작합니다."+"\n파이어폭스 브라우저 메뉴 [보기]-[크기조정]을 이용하세요."); }
 else if(ue.indexOf('opera')!=-1){ alert("익스플로러에서만 동작합니다."+"\n오페라 브라우저 메뉴 [보기]-[Zoom]을 이용하세요."); }
 else if(ue.indexOf('chrome')!=-1){ alert("익스플로러에서만 동작합니다."+"\n구글 크롬 브라우저 메뉴 [글꼴 크기]를 이용하세요."); }
 else if(ue.indexOf('safari')!=-1){ /* alert("익스플로러에서만 동작합니다."+"\n사파리 브라우저 메뉴 [보기]-[텍스트 크게]/[텍스트 작게]를 이용하세요."); */ }
 else if(ue.indexOf('msie')!=-1){  }
 else { alert("익스플로러에서만 동작합니다.\n"+ue+"\n브라우저 메뉴의 확대축소 기능을 이용하세요."); }
 if(((value=="plus")&&(curRate >= maxRate))||((value == "minus") && (curRate <= minRate))){return;} 
  if(value=="plus"){curRate = parseInt(curRate) + parseInt(zoomRate);}
  else if (value=="minus"){curRate = parseInt(curRate) - parseInt(zoomRate);}
  else{curRate = 100}
  document.body.style.zoom = curRate + '%';
} 

  //pre, stop, next 버튼 관련
  function controlImg(ctlNum) {
      //alert(ctlNum);
      if (ctlNum == "pre") {
          isExecute = 1;
          changeImg(1, "I");
      } else if (ctlNum == "next") {
          isExecute = 1;
          changeImg(-1, "I");
      } else if (ctlNum == "stop") {
          //setTimeout("changeImg(0,'I')", setTimeNum);
          window.clearTimeout(idt);
      }
      isExecute = 0;
  }


  function fn_WindowOnLoad() {
      try {
          // 1. 에러 메시지가 있는 경우 팝업 출력
          if (document.all.errorMessage.value.length > 0)
              fn_OpenErrorMessage();
      }
      catch (exception) { }

      try {
          // 2. Information이 있는 경우 팝업 출력
          if (document.all.informationMessage.value.length > 0)
              fn_OpenInformation(document.all.informationMessage.value);
      }
      catch (exception) { }
  }

  function fn_GetWebRoot() {
      var strHref = document.location.href;
      var strPath;
      var arrPath;

      if (strHref.substring(0, 5).toUpperCase() == "HTTPS") {
          //strPath = strHref.substring(8, strHref.length);
          return "https://astro.kasi.re.kr/";
      }
      else if (strHref.substring(0, 4).toUpperCase() == "HTTP") {
      //strPath = strHref.substring(7, strHref.length);
        return "http://astro.kasi.re.kr/";
      }
      else {
          strPath = strHref.substring(8, strHref.length);
      }
      arrPath = strPath.split("/");
      //return "/" + arrPath[1] + "/";
      //return "HTTP://210.219.33.98/";
      //return "https://astro.kasi.re.kr/";
  }

  function fn_DocumentPath() {
      var strHref = "";
      var strLoc = "";
      var arrLoc = null;
      var strPath = "";
      var arrPath = null;
      strHref = document.location.href;
      arrLoc = strHref.split("?");
      strLoc = arrLoc[0];
      arrPath = strLoc.split("/");
      for (var i = 0; i < arrPath.length - 1; i++) {
          strPath += arrPath[i] + "/";
      }
      return strPath ;

  }
  
  function fn_OpenErrorMessage() {
      var args = new Object();
      args.win = window;
      args.errMessage = window.document.all.errorMessage.value;

      window.showModalDialog(fn_GetWebRoot() + "Common/ErrorMessageBox.html", args, "dialogWidth:430px;dialogHeight:260px;status=no;scroll=no");
  }

  function fn_OpenInformation(sInfo) {
      var args = new Object();
      args.win = window;
      args.dlgtype = "I";
      args.errMessage = sInfo;
      window.showModalDialog(fn_GetWebRoot() + "Common/ErrorMessageBox.html", args, "dialogWidth:430px;dialogHeight:260px;status=no;scroll=no");
  }

  function fn_OpenConfirm(sInfo) {
      var args = new Object();
      args.win = window;
      args.dlgtype = "Q";
      args.errMessage = sInfo
      var res = window.showModalDialog(fn_GetWebRoot() + "Common/ErrorMessageBox.html", args, "dialogWidth:430px;dialogHeight:260px;status=no;scroll=no");
      return res;
  }

