/* ------------------------------------------------------------------
  파일명 : search.js
	목  적 : 통합검색의 화면 확대 축소 및 쿠키 컨트롤 모듈
  설  명 : 통합검색의 화면 확대 및 축소 관련한 함수를 선언하는 
           JavaScript 파일
------------------------------------------------------------------
                변    경    사    항
------------------------------------------------------------------
	 날짜     작성자                      변경내역
----------  ------  ----------------------------------------------
2008.10.31  이흥열                 최초 프로그램 작성
------------------------------------------------------------------ */
var g_hostname = this.location.hostname;

function setCookie(name, value) {
	var today = new Date();
    var expire_date = new Date(today.getTime() + 365*60*60*24*1000);
    document.cookie = name + "=" + escape(value) + "; path=/; expires=" + expire_date.toGMTString() + "; domain=" + g_hostname + ";";
}
function getCookie(name) {
    var dc = document.cookie;
    var prefix = name + "=";
    var begin = dc.indexOf("; " + prefix);
    if (begin == -1) {
        begin = dc.indexOf(prefix);
        if (begin != 0) 
            return null;
    } else {
        begin += 2;
    }

    var end = document.cookie.indexOf(";", begin);
    if (end == -1)
        end = dc.length;
    return unescape(dc.substring(begin + prefix.length, end));
}
function BrowserCheck() { 
 	var appname = navigator.appName; 
 
 	if(appname == "Microsoft Internet Explorer") appname = "IE"; 
 	else if(appname == "Netscape") appname = "FF"; 
 	else appname = "ETC"; 
	 
	return appname; 
} 

/* 화면 확대 축소 시작 IE 전용 */
if(getCookie("zoom") == "" || getCookie("zoom") == null ) {
	var nowZoom = 100;
} else {
	var nowZoom = parseInt(getCookie("zoom")); //현재비율
}

 var maxZoom = 200; // 최대비율(500으로하면 5배 커진다)
 var minZoom = 80; // 최소비율

 if(nowZoom > maxZoom) nowZoom = maxZoom;
 if(nowZoom < minZoom) nowZoom = minZoom;


 //화면 키운다.
 function zoomIn() {
/*
var zoom = 1.5;
var docViewer = getBrowser().selectedBrowser.markupDocumentViewer;
docViewer.fullZoom = zoom;
*/
  if (nowZoom < maxZoom) {
   nowZoom += 10; //25%씩 커진다.
  } else {
   return;
  }
	change_position("static");
  document.body.style.zoom = nowZoom + "%";
  setCookie("zoom", nowZoom);

 }

 //화면 줄인다.
 function zoomOut() {
  if (nowZoom > minZoom) {
   nowZoom -= 10; //25%씩 작아진다.
  } else {
   return;
  }
  change_position("static");
  document.body.style.zoom = nowZoom + "%";
  setCookie("zoom", nowZoom);
 }

 //화면 초기화 (기본으로)
 function zoomInit() {
 	nowZoom = 100;
 	setCookie("zoom", nowZoom);
 	location.reload();
  //document.body.style.zoom = nowZoom + "%";
  //change_position("relative");
 }

 function zoomSet() {
  change_position("static");
  //alert(nowZoom);
  document.body.style.zoom = nowZoom + "%";
 }
 //화면 크기 유지 (이전값으로)
 function chgZoom() {
    if(nowZoom != 100) {
        setTimeout("zoomSet()", 1000);
    }
 }

 //검색 결과 DOM.style.position 값을 static <==> relative 로 변경한다.
 //이는 화면 크기 변경시에 position 이 static 인 경우만 정상 작동되기 때문이다.
function change_position(to) {
	
  if( _sites == null ) { return; }
	var num = _sites.length;
	var obj, obj2, i;

	if(_siteid == 0) {	
		for(i=0; i<num; i++) {
			obj = document.getElementById("srch"+_sites[i]);
			obj.style.position = to;
			
			try {
					obj2 = document.getElementById("UpDown"+_sites[i]);
					obj2.style.position = to;
			} catch(e) { };
		}
	} else {
			var obj = document.getElementById("srch"+_siteid);
			obj.style.position = to;
    }
	return;
}
