/*
Author : 
Contact Us : 
Version : 
discription : 
*/
document.write('<script type=\"text/javascript\" src=\"/script/jquery.js\"></script>');
document.write('<script type=\"text/javascript\" src=\"/script/jquery.form.js\"></script>');

function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      oldonload();
      func();
    }
  }
}


//클래스 추가하기
function addClass(_element, _value){
	if(!_element.className){
		_element.className = _value;
	}else{
		newClassName = _element.className;
		newClassName += " ";
		newClassName += _value;
		_element.className = newClassName;
	}
}
//해당 클래스명 빼주기
function  pullUpClass(_element, _value){
	//_value 값 뺀 후 돌려줄 클래스텍스트값 저장
	var returnClassName;
	var className_arr = _element.className.split(" ");
	if(className_arr.length <= 1){
		_element.className ="";
	}else{
		for(var i=0; i<className_arr; i++){
			if(className_arr[i] != _value){
				returnClassName += className_arr[i] + " ";
			}
		}
		_element.className = returnClassName;
	}
}

try { 
    document.execCommand('BackgroundImageCache', false, true); 
} catch(acold) {}


function showHideElem1(_objId, _param_split){
	var showObj = document.getElementById(_objId);
	if(!showObj) return false;
	//나타낼 객체가 있고 숨길 객체가 다수인경우
	if(_param_split){
		//숨길 객체들 문자열(언더바를 구분자로 파라메터를 받는다)
		var hideObjId_arr = _param_split.split("_");
		//숨길 객체 배열
		var hideObj_arr = Array();
		for(i=0; i<hideObjId_arr.length; i++){
			hideObj_arr[i] = document.getElementById(hideObjId_arr[i]);
		}
		//숨길 객체 숨기기
		for(i=0; i<hideObj_arr.length; i++){
			if(hideObj_arr[i].style){
				hideObj_arr[i].style.display = "none";
			}else{
				return false;
			}
		}
		//나타낼 객체 나타내기
		showObj.style.display = "block";
	}
	//나타내거나 숨길 객체가 한개인 경우 
	else{
		if(showObj.style.display == "block"){
			showObj.style.display = "none";
		}else{
			showObj.style.display = "block";
		}
	}
}


/* Smooth Moving Layer */
function initMoving(target, topPosition, topLimit, btmLimit) {
	if (!target)
		return false;

	var obj = target;
	obj.initTop = topPosition;
	obj.topLimit = topLimit;
	obj.bottomLimit = document.documentElement.scrollHeight - btmLimit;

	obj.style.position = "absolute";
	obj.top = obj.initTop;
	obj.left = obj.initLeft;
	obj.style.top = obj.top + "px";

	obj.getTop = function() {
		if (document.documentElement.scrollTop) {
			return document.documentElement.scrollTop;
		} else if (window.pageYOffset) {
			return window.pageYOffset;
		} else {
			return 0;
		}
	}
	obj.getHeight = function() {
		if (self.innerHeight) {
			return self.innerHeight;
		} else if(document.documentElement.clientHeight) {
			return document.documentElement.clientHeight;
		} else {
			return 500;
		}
	}
	obj.move = setInterval(function() {
		//pos = obj.getTop() + obj.getHeight() / 2 - 15;
		pos = obj.getTop() + topPosition;

		if (pos > obj.bottomLimit)
			pos = obj.bottomLimit
		if (pos < obj.topLimit)
			pos = obj.topLimit

		interval = obj.top - pos;
		obj.top = obj.top - interval / 3;
		obj.style.top = obj.top + "px";
	}, 30)
}


//롤오버 이미지 클래스명으로 사용시
//class="imgover" 를 이미지에 삽입
function initRollovers() {
    if (!document.getElementById) return
    
    var aPreLoad = new Array();
    var sTempSrc;
    var aImages = document.getElementsByTagName('img');

    for (var i = 0; i < aImages.length; i++) {        
        if (aImages[i].className == 'imgover') {
            var src = aImages[i].getAttribute('src');
            var ftype = src.substring(src.lastIndexOf('.'), src.length);
            var hsrc = src.replace(ftype, '_on'+ftype);

            aImages[i].setAttribute('hsrc', hsrc);
            
            aPreLoad[i] = new Image();
            aPreLoad[i].src = hsrc;
            
            aImages[i].onmouseover = function() {
                sTempSrc = this.getAttribute('src');
                this.setAttribute('src', this.getAttribute('hsrc'));
            }    
            
            aImages[i].onmouseout = function() {
                if (!sTempSrc) sTempSrc = this.getAttribute('src').replace('_on'+ftype, ftype);
                this.setAttribute('src', sTempSrc);
            }
        }
    }
}



//CSS 스위치
function switchCSS(style) {
	var wrapper = document.getElementsByTagName('body');
	wrapper = wrapper[0];
	wrapper.className = style;
}


//2009-08-24 추가
try{
	document.title = "::: KB데이타시스템 :::";
}catch(E){
	// ignore
}


//GNB 네비게이션 호출
function naviOpen() {
  var para = document.getElementById("gnb");
  var para2 = document.getElementById("header");
  try
  {
   pullUpClass(para, "naviClose");
   pullUpClass(para2, "naviClose");
  }
  catch(e){}
  addClass(para,"naviOpen");    
  addClass(para2,"naviOpen");    
}

function naviClose() {
  var para = document.getElementById("gnb");
  var para2 = document.getElementById("header");
  try
  {
   pullUpClass(para, "naviOpen");
   pullUpClass(para2, "naviOpen");
  }
  catch(e){}
  addClass(para,"naviClose");
  addClass(para2,"naviClose");
}


/* select box - page 이동 */
function movePage(obj){
	obj=document.getElementById(obj);
	location.href=obj.options[obj.selectedIndex].value;
}


addLoadEvent(initRollovers);