addLoadEvent(new_menu_images_position);
var notice_timer = null;
var notice_timer2 = null;
var timerFunctionFlag = false;

/* 어플 이용하였을 경우 */
function AppDisplay()
{
	var m_list_1 = document.getElementById("m_list_1");
	var m_list_2 = document.getElementById("m_list_2");
	var m_list_3 = document.getElementById("m_list_3");
	var m_list_4 = document.getElementById("m_list_4");
	var m_list_5 = document.getElementById("m_list_5");
	
	if(navigator.deviceName == "iPhoneApp" || navigator.deviceName == "androidApp" )
	{		
		/*
		m_list_1.className ="m_AP_list";
		m_list_2.className ="m_AP_list3";
		m_list_3.className ="m_AP_list4";
		m_list_4.className ="m_AP_list";
		m_list_5.className ="m_AP_list2";
		*/
		/*
		m_list_1.className ="m_AP_list4";
		m_list_2.className ="m_AP_list4";
		m_list_3.className ="m_AP_list4";
		m_list_4.className ="m_AP_list4";
		m_list_5.className ="m_AP_list4";
		*/
		m_list_1.className ="m_list4";
		m_list_2.className ="m_list4";
		m_list_3.className ="m_list4";
		m_list_4.className ="m_list4";
		m_list_5.className ="m_list4";
	}
}

function getNotice(){

	var url      = "/notice.do";
	var param    = "&method=main_page_noticeAction";
	var callback = getNoticeCallback;
	Send_ajax(url,param,callback);


}
function getNoticeCallback(){
	if (httpRequest.readyState == 4) {
		if (httpRequest.status == 200) {


			var resultText = httpRequest.responseText;
			
			$("notice_result_div").innerHTML=resultText;
			
			$("notice_result_div").style.width="320px";
			if(navigator.deviceName == "iPhoneApp" || navigator.deviceName == "androidApp" )
			{	
				$("notice_result_div").style.height="26px";	
				$("notice_result_div").scrollTop ="16";
				$("NOTICE_TABLE").width = "320px";			
				for(var i=0; i<5; i++) {
					$("notice_title_td"+i).width = "320px";
					$("notice_title_td"+i).align = "center";
				}
				notice_timer = setInterval(changeMessage,100);
				/*$("first_notice_td").height="65px";				
				$("last_notice_td").height="65px";				
				$("notice_td0").height="65px";
				$("notice_td1").height="65px";
				$("notice_td2").height="65px";
				$("notice_td3").height="65px";
				$("notice_td4").height="65px";
								
				$("notice_result_div").style.height="65px";
				$("notice_result_div").scrollTop ="40";
				
				notice_timer = setInterval(changeMessageAPP,300);*/
				
			}else{
				$("notice_result_div").style.height="26px";	
				$("notice_result_div").scrollTop ="16";
				$("NOTICE_TABLE").width = "320px";			
				for(var i=0; i<5; i++) {
					$("notice_title_td"+i).width = "320px";
					$("notice_title_td"+i).align = "center";
				}
				notice_timer = setInterval(changeMessage,100);
			}
						
		}
		else{

		}
	  }
}

var type = "1";
window.onorientationchange = function (){
	if(window.orientation == 0 || window.orientation == 180 ){
		var new_menu_div = document.getElementById("new_menu_div");
		new_menu_div.style.top  = "190px";
		new_menu_div.style.left = "230px";
		
		$("NOTICE_TABLE").width = "320px";			
		for(var i=0; i<5; i++) {
			$("notice_title_td"+i).width = "320px";
			$("notice_title_td"+i).align = "center";
		}
		
	}else if(window.orientation == 90 || window.orientation == -90 ){
		
		var new_menu_div = document.getElementById("new_menu_div");
		new_menu_div.style.top  = "190px";
		new_menu_div.style.left = "125px";
		
		
		$("NOTICE_TABLE").width = "480px";			
		for(var i=0; i<5; i++) {
			$("notice_title_td"+i).width = "480px";
			$("notice_title_td"+i).align = "center";
		}
	}
}


function changeMessage(){
	
	var tempFlag = true;
	for(var i=0; i<5; i++) {
		if($("notice_title_td"+i).offsetTop == $("notice_result_div").scrollTop+4){
			
			//$("test").value = $("test").value+"$(notice_result_div).scrollHeight="+$("notice_result_div").scrollHeight+"\t$(notice_result_div).scrollTop="+$("notice_result_div").scrollTop+"\r\n";
			
			tempFlag = false;
			clearInterval(notice_timer);
			notice_timer2 = setInterval(timerFunction,3000);
						
		}
	}
	
	if(tempFlag){		
		if($("notice_result_div").scrollHeight >26+$("notice_result_div").scrollTop+2){		
			$("notice_result_div").scrollTop = $("notice_result_div").scrollTop+2;
			//$("test").value = $("test").value+"$(notice_result_div).scrollHeight="+$("notice_result_div").scrollHeight+"\t$(notice_result_div).scrollTop="+$("notice_result_div").scrollTop+"\r\n";
		}else{		
			$("notice_result_div").scrollTop ="0";
			//$("test").value = $("test").value+"$(notice_result_div).scrollHeight="+$("notice_result_div").scrollHeight+"\t$(notice_result_div).scrollTop="+$("notice_result_div").scrollTop+"\r\n";
		}			
	}

}

function changeMessageAPP(){
	
	$("notice_result_div").scrollTop = $("notice_result_div").scrollTop+2;
	
	if($("notice_result_div").scrollHeight >65+$("notice_result_div").scrollTop+2){		
		$("notice_result_div").scrollTop = $("notice_result_div").scrollTop+2;
		//$("test").value = $("test").value+"$(notice_result_div).scrollHeight="+$("notice_result_div").scrollHeight+"\t$(notice_result_div).scrollTop="+$("notice_result_div").scrollTop+"\r\n";
	}else{		
		$("notice_result_div").scrollTop ="0";
		//$("test").value = $("test").value+"$(notice_result_div).scrollHeight="+$("notice_result_div").scrollHeight+"\t$(notice_result_div).scrollTop="+$("notice_result_div").scrollTop+"\r\n";
	}			
}

function timerFunction(){
	//alert('timerFunctionFlag = '+timerFunctionFlag);
	if(timerFunctionFlag == false){
		timerFunctionFlag = true;
	}else{
		timerFunctionFlag = false;
		$("notice_result_div").scrollTop = $("notice_result_div").scrollTop+2;
		//$("test").value = $("test").value+"$(notice_result_div).scrollHeight="+$("notice_result_div").scrollHeight+"\t$(notice_result_div).scrollTop="+$("notice_result_div").scrollTop+"\r\n";
		clearInterval(notice_timer2);
		notice_timer = setInterval(changeMessage,200);			
	}	
}

function goNotice(tableName , No){
	if(tableName == "board_notice_temp"){     //공지사항
		window.location.href = "/libnotice.do?type=1&no="+No;
		return 0;
	}else if(tableName == "board_employ"){    //인재채용
		window.location.href = "/libnotice.do?type=2&no="+No;
		return 0;
	}else if(tableName == "board_info_clob"){ //보도자료 
		window.location.href = "/libnotice.do?type=3&no="+No;
		return 0;
	}else{
		//에러 
		return 0;
	}
}
////////////////////////////////////////////////////////////////////
//바코드 검색 위치 변경
function barcode_search()
{
	var top_layer = document.getElementById("top_layer");
	var target = document.getElementById("simplesearchdata");
	var method = document.getElementById("method");
    
	// 닫기
	top_layer.style.display = "none";
	// 검색어가 입력 되지 않았을 경우 이미지 표시
	if(target.value == "")
	{
		target.className = "il_text1";	// 국립중앙도서관 소장자료 글씨 스타일 변경 하기
	}
	text_class = "il_text1";	
	method.value="barcodeSearchList";

	//테스트를 위한코드 
	//document.getElementById("simplesearchdata").value="8970134301";
	//common_search_simple();

	//검색을 외부에서 붙을수가 없다.
	checkBarcode();
}

function checkBarcode(){
	
	if(navigator.deviceName == "iPhoneApp" || navigator.deviceName == "androidApp" ){
		startBarcodeRead();	
	}else{
		alert('바코드 리더를 이용하시려면 App을 이용하셔야 합니다.');
	}
}

function startBarcodeRead(){
    //바코드 리더를 보여준다.    
	navigator.barcodeReader.show();
}
function barcodeCallBack( code ) {
	/*
	 * 바코드 인식 성공시 호출될 함수
	 * 바코드 리더의 경우 콜백함수가 정해져있다.
	 * ex)바코드 인식 성공시 barcodeCallBack( '9788970502908' )이 호출된다.
	 */
	 document.getElementById("simplesearchdata").value=code;
	 clear_text('main');
	 
	  		
	 common_search_simple();			
}

//소장원문검색
////////////////////////////////////////////////////////////////////


