var banner_index = 0;
// 베너 글씨 변경 하기
function banner_start()
{
/*
	var banner_data 		= document.getElementById("banner_data");
	var banner 				= document.getElementById("banner");
	var splitData 			= "";
	var banner_size 		= 0;
	splitData = banner_data.value.split(",");
	banner_size = splitData.length;
	banner_index++;
	if(banner_size <= banner_index)
	{
		banner_index = 0;
	}
	banner.innerHTML = splitData[banner_index];
*/
	// 스크롤 맞추기
	loaded();	
}
// onload 이벤트 메소드 추가
function addLoadEvent(func)
{
	var oldonload = window.onload;
	if(typeof window.onload != 'function'){
		window.onload = func;
	}else{
		func();
	}
}

// onunload 이벤트 메소드 추가
function addUnLoadEvent(func)
{
	var oldonunload = window.onunload;
	if(typeof window.onunload != 'function'){
		window.onunload = func;
	}else{
		func();
	}
}

// 현재 페이지에 스크롤 맞추기
function loaded()
{
	document.getElementById("header").style.visibility = "visible";  
	window.scrollTo(0, 1); // pan to the bottom, hides the location bar  
}
// 현재 페이지에 스크롤 맞추기
function loaded2()
{
	document.getElementById("header").style.visibility = "visible";  
	window.scrollTo(0, 1); // pan to the bottom, hides the location bar  
}
// 기능 준비중.. 메시지
function notice()
{
	alert("기능 준비 중입니다.");	
	return;
}

String.prototype.replaceAll = replaceAll;
function replaceAll(strValue1, strvalue2)
{
    var strTemp = this;
    strTemp = strTemp.replace(new RegExp(strValue1,"g"),strvalue2);
    return strTemp;
}

String.prototype.trim = function() {
    return this.replace(/(^ *)|( *$)/g, "");
}

/*********************************************************/
function show_hide_box(an, width, height, borderStyle , zon_id , next_evnet) {
	  
	  var object_id = an.id + "_div";
	
	  var boxdiv = document.getElementById(object_id);

	  if (boxdiv != null) {
	    if (boxdiv.style.display=='none') {
	      move_box(an, boxdiv);
	      boxdiv.style.left = 5 + "px";
	      boxdiv.style.top = 240 + "px";
	      boxdiv.style.display='block';
	    } else
	      boxdiv.style.display='none';
	    return false;
	  }

	  boxdiv = document.createElement('div');
	  boxdiv.setAttribute('id', object_id);
	  boxdiv.style.display = 'block';
	  boxdiv.style.position = 'absolute';
	  
	  
	  
	  boxdiv.style.width = width + 'px';
	  boxdiv.style.height = height + 'px';
	  boxdiv.style.border = borderStyle;
	  boxdiv.style.backgroundColor = '#fff';

	  var contents = document.createElement('iframe');
	  contents.scrolling = 'no';
	  contents.frameBorder = '0';
	  contents.style.width = width + 'px';
	  contents.style.height = height + 'px';
	  
	  if(next_evnet!=null && next_evnet!=""){
		  contents.src = "/common/calendar.jsp?zon_id="+zon_id+"&object_id="+object_id+"&next_event="+next_evnet;
	  }else{
		  contents.src = "/common/calendar.jsp?zon_id="+zon_id+"&object_id="+object_id;  
	  }
	  

	  
	  
	  boxdiv.appendChild(contents);
	  document.body.appendChild(boxdiv);
	  move_box(an, boxdiv);
	  boxdiv.style.left = 5 + "px";
	  boxdiv.style.top = 240 + "px";
	  
	  return false;
	}

function move_box(an, box) 
{
	//링크된 위치에서 부터의 설정값 지정
	var cleft = -112;  //왼쪽마진  
	var ctop = -3;  //상단마진
	var obj = an;
	while (obj.offsetParent) 
	{
		cleft += obj.offsetLeft;
		ctop += obj.offsetTop;
		obj = obj.offsetParent;
	}
	box.style.left = cleft + 'px';
	ctop += an.offsetHeight + 8;
	if (document.body.currentStyle && document.body.currentStyle['marginTop']) 
	{
		ctop += parseInt(document.body.currentStyle['marginTop']);
	}
	box.style.top = ctop + 'px';
}

function start_loadding(){
	var back_div1 = document.getElementById("back_div1");
	var back_div3 = document.getElementById("back_div3");
	var back_div2 = document.getElementById("back_div2");
	
	if(window.innerWidth){
		back_div1.style.width  = document.body.offsetWidth + 'px';
		back_div1.style.height = document.body.offsetHeight + 'px';
		
		back_div2.style.width  = document.body.offsetWidth + 'px';
		back_div2.style.height = document.body.offsetHeight + 'px';
		
		
		back_div3.style.pixelLeft  = (document.body.offsetWidth/2-50);// + 'px';
		back_div3.style.pixelTop   = (document.body.offsetHeight/2-35);// + 'px';
		back_div3.style.width    = 100 + 'px';
		back_div3.style.height   = 70 + 'px';
		
		
		back_div1.style.display = "block";
		back_div2.style.display = "block";
		back_div3.style.display = "block";
	}else {
		back_div1.style.width  = document.body.offsetWidth + 'px';
		back_div1.style.height = document.body.offsetHeight + 'px';
		
		back_div2.style.width  = document.body.offsetWidth + 'px';
		back_div2.style.height = document.body.offsetHeight + 'px';
		
		
		back_div3.style.pixelLeft  = (document.body.offsetWidth/2-50);// + 'px';
		back_div3.style.pixelTop   = (document.body.offsetHeight/2-35);// + 'px';
		back_div3.style.width    = 100 + 'px';
		back_div3.style.height   = 70 + 'px';
		
		back_div1.style.display = "block";
		back_div2.style.display = "block";
		back_div3.style.display = "block";
	}

	
}
function end_loadding(){
	
	var body = document.getElementsByTagName("body");
	
	var back_div1 = document.getElementById("back_div1");
	var back_div3 = document.getElementById("back_div3");
	var back_div2 = document.getElementById("back_div2");
	
	back_div1.style.display = "none";
	back_div2.style.display = "none";
	back_div3.style.display = "none";
	
}

/////////////////////////////////////////////////////////////////////
//신규메뉴
function new_menu_images_position(){
	init();
	
	if(navigator.deviceName == "iPhoneApp" )
	{		
		var leftLibMenu =  document.getElementById("leftLibMenu");	
		if(leftLibMenu!=null ){			
			leftLibMenu.style.height = '321px';		 
		}
		document.getElementById("APP_BLANK").style.display="block";	
	}
	else if(navigator.deviceName == "androidApp"){
		document.getElementById("APP_BLANK").style.display="block";	
		document.getElementById("ANDROID_BLANK").style.display="block";
		document.getElementById("ANDROIDAPP_BLANK").style.display="block";
		var leftLibMenu =  document.getElementById("leftLibMenu");	
		if(leftLibMenu!=null ){			
			leftLibMenu.style.height = '362px';		 
		}
		
		
		
	}else if(navigator.deviceName == "androidWeb"){
		var leftLibMenu =  document.getElementById("leftLibMenu");	
		if(leftLibMenu!=null ){			
			leftLibMenu.style.height = '307px';		 
		}
		document.getElementById("ANDROID_BLANK").style.display="block";
	}
	
	  
		
	loaded();
	AppDisplay();
	//메인 페이지 공지사항 호출 
	getNotice();
	
}

/**
*
*  UTF-8 data encode / decode
*  http://www.webtoolkit.info/
*
**/
 
var Utf8 = {
	// public method for url encoding
	encode : function (string) {
		string = string.replace(/\r\n/g,"\n");
		var utftext = ""; 
		for (var n = 0; n < string.length; n++) { 
			var c = string.charCodeAt(n); 
			if (c < 128) {
				utftext += String.fromCharCode(c);
			}
			else if((c > 127) && (c < 2048)) {
				utftext += String.fromCharCode((c >> 6) | 192);
				utftext += String.fromCharCode((c & 63) | 128);
			}
			else {
				utftext += String.fromCharCode((c >> 12) | 224);
				utftext += String.fromCharCode(((c >> 6) & 63) | 128);
				utftext += String.fromCharCode((c & 63) | 128);
			} 
		} 
		return utftext;
	}, 
	// public method for url decoding
	decode : function (utftext) {
		var string = "";
		var i = 0;
		var c = c1 = c2 = 0;
 		while ( i < utftext.length ) { 
			c = utftext.charCodeAt(i); 
			if (c < 128) {
				string += String.fromCharCode(c);
				i++;
			}
			else if((c > 191) && (c < 224)) {
				c2 = utftext.charCodeAt(i+1);
				string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
				i += 2;
			}
			else {
				c2 = utftext.charCodeAt(i+1);
				c3 = utftext.charCodeAt(i+2);
				string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
				i += 3;
			} 
		} 
		return string;
	} 
}




/**
*
*  Base64 encode / decode
*  http://www.webtoolkit.info/
*
**/ 
var Base64 = { 
	// private property
	_keyStr : "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",
 
	// public method for encoding
	encode : function (input) {
		var output = "";
		var chr1, chr2, chr3, enc1, enc2, enc3, enc4;
		var i = 0;
 
		input = Base64._utf8_encode(input);
 
		while (i < input.length) {
 
			chr1 = input.charCodeAt(i++);
			chr2 = input.charCodeAt(i++);
			chr3 = input.charCodeAt(i++);
 
			enc1 = chr1 >> 2;
			enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
			enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
			enc4 = chr3 & 63;
 
			if (isNaN(chr2)) {
				enc3 = enc4 = 64;
			} else if (isNaN(chr3)) {
				enc4 = 64;
			}
 
			output = output +
			this._keyStr.charAt(enc1) + this._keyStr.charAt(enc2) +
			this._keyStr.charAt(enc3) + this._keyStr.charAt(enc4);
 
		}
 
		return output;
	},
 
	// public method for decoding
	decode : function (input) {
		var output = "";
		var chr1, chr2, chr3;
		var enc1, enc2, enc3, enc4;
		var i = 0;
 
		input = input.replace(/[^A-Za-z0-9\+\/\=]/g, "");
 
		while (i < input.length) {
 
			enc1 = this._keyStr.indexOf(input.charAt(i++));
			enc2 = this._keyStr.indexOf(input.charAt(i++));
			enc3 = this._keyStr.indexOf(input.charAt(i++));
			enc4 = this._keyStr.indexOf(input.charAt(i++));
 
			chr1 = (enc1 << 2) | (enc2 >> 4);
			chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
			chr3 = ((enc3 & 3) << 6) | enc4;
 
			output = output + String.fromCharCode(chr1);
 
			if (enc3 != 64) {
				output = output + String.fromCharCode(chr2);
			}
			if (enc4 != 64) {
				output = output + String.fromCharCode(chr3);
			}
 
		}
 
		output = Base64._utf8_decode(output);
 
		return output;
 
	},
 
	// private method for UTF-8 encoding
	_utf8_encode : function (string) {
		string = string.replace(/\r\n/g,"\n");
		var utftext = "";
 
		for (var n = 0; n < string.length; n++) {
 
			var c = string.charCodeAt(n);
 
			if (c < 128) {
				utftext += String.fromCharCode(c);
			}
			else if((c > 127) && (c < 2048)) {
				utftext += String.fromCharCode((c >> 6) | 192);
				utftext += String.fromCharCode((c & 63) | 128);
			}
			else {
				utftext += String.fromCharCode((c >> 12) | 224);
				utftext += String.fromCharCode(((c >> 6) & 63) | 128);
				utftext += String.fromCharCode((c & 63) | 128);
			}
 
		}
 
		return utftext;
	},
 
	// private method for UTF-8 decoding
	_utf8_decode : function (utftext) {
		var string = "";
		var i = 0;
		var c = c1 = c2 = 0;
 
		while ( i < utftext.length ) {
 
			c = utftext.charCodeAt(i);
 
			if (c < 128) {
				string += String.fromCharCode(c);
				i++;
			}
			else if((c > 191) && (c < 224)) {
				c2 = utftext.charCodeAt(i+1);
				string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
				i += 2;
			}
			else {
				c2 = utftext.charCodeAt(i+1);
				c3 = utftext.charCodeAt(i+2);
				string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
				i += 3;
			}
 
		}
 
		return string;
	}
 
}



/* 원문로그 남기기 시작 */
function callSaveViewerLog(system_code, control_no, client_ip, kdc_kind, copyright,title,author,publisher,pub_year){
  //document.domain = "dibrary.net";

	url= "/common/viewer_log.jsp";

	dataValue = "system_code="+system_code
		+"&control_no="+control_no+"&client_ip="+client_ip
		+"&kdc_kind="+kdc_kind+"&copyright="+copyright+"&title="+Base64.encode(title)
		+"&author="+Base64.encode(author)+"&publisher="+Base64.encode(publisher)+"&pub_year="+pub_year;
  
	sendRequest(url,dataValue,nothing,'GET', false);
 
} 

function nothing() {
}
/* 원문로그 남기기 끝 */







