﻿(function() {
    /*
		homiKnowledge 오브젝트를 생성합니다.
		아이디속성을 리턴하는 함수 $을 생성합니다.
		2009-09-01 이영무
    */
    window.homiKnowledge = {
        $: function(element) {
            return document.getElementById(element);
        }
    };

    /*
		사용자 브라우져 속성을 가져옵니다.
		2009-09-03 황진우
    */
    homiKnowledge.browser = new function() 
    {
        this.userBrowser = navigator.userAgent.toLowerCase();
        this.__user = function(f) {
            return (this.userBrowser.indexOf(f) != -1);
        }
        this.fox = this.__user('firefox');
        this.ie = this.__user('ie');
        this.ns = this.__user('netscape');
        this.mozilla = (!this.fox && !this.ie);
        this.op = this.__user('opera');
        this.ie = (this.__user('msi') && !this.op);
        this.mac = this.__user('mac');
        this.user = this.ie ? 'ie' : this.fox ? 'firefox' : this.ns ? 'netscape' : this.mozilla ? 'mozilla' : this.op ? 'opera' : 'ie';
    };

    /*
		2009-09-10 황진우
		플레시플레이어,미디어플레이어 스크립트를 생성합니다.
    */
    homiKnowledge.flashPlayer = {
        dataSource: function(src, width, height, vars) {
            return (document.write('<object type="application/x-shockwave-flash" data="', src, '" width="', width, '" height="', height, '"><param name="movie" value="', src, '" /></object>'));
        },
        flashSource: function(src, width, height, vars) {
            return ('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="' + width + '" height="' + height + '" id="main_top_flash" name="main_top_flash" />' +
            '<param name="FlashVars" value="' + vars + '" />' +
            '<param name="movie" value="' + src + '" />' +
            '<param name="allowScriptAccess" value="always" />' +
            '<param name="quality" value="high" />' +
            '<param name="wmode" value="transparent" />' +
            '<embed src="' + src + '" wmode="transparent" FlashVars="' + vars + '" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="' + width + '" height="' + height + '" allowScriptAccess="always" swLiveConnect="true" id="main_top_flash" name="main_top_flash"></embed></object>'
            );
        },

        mediaSource: function(objId, src, width, height, barMenu, DisableVoice) {
            currentSource = '';
        
            if (width && height)
                currentSource = "width='" + width + "' height='" + height + "'";
                
            return ('<object id="' + objId + '" classid="clsid:6bf52a52-394a-11d3-b153-00c04f79faa6" codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701" ' + currentSource + '>' +
            '<param name="mute" value="' + (DisableVoice ? 'true' : 'false') + '" />'+
            '<param name="url" value="' + src + '" /><param name="autostart" value="true" /><PARAM NAME="enableContextMenu" VALUE="0"><PARAM NAME="uiMode" VALUE="' + (barMenu ? 'full' : 'none') + '">' +
            '<embed type="application/x-mplayer2" src="' + src + '" url="' + src + '" style="filter:xray" autostart="true" ></embed></object>');
        },
        flashPlay : function(src, width, height, vars) { document.write(this.flashSource(src, width, height, vars)); },
        mediaPlay : function(objId, src, width, height, barMenu, DisableVoice) {document.write(this.mediaSource(objId, src, width, height, barMenu, DisableVoice)); }
    };
	
	/*
		2009-09-10 황진우
		팝업창 스크립트를 생성합니다.
    */
    homiKnowledge.popup = {
        view: function(url, name, width, height) {
            this.popup = open(url, 'PopupWindow_' + name, 'width=' + width + ', height=' + height + ',menubar=0,scrollbars=no,status=0,toolbar=0,location=0,directories=0,resizable=yes');
            this.popup.focus();
        },
        optionView: function(url, name, width, height, scroll) {
            this.popup = open(url, 'PopupWindow_' + name, 'width=' + width + ', height=' + height + ',menubar=0,scrollbars=' + scroll + ',status=0,toolbar=0,location=0,directories=0,resizable=yes');
            this.popup.focus();
        }
    };
	
	/*
		2009-09-12 황진우
		ajax사용을 위해 객체를 생성합니다.
    */
    homiKnowledge.loadHttp = function() 
    {
        try 
        {
            $aj = new ActiveXObject("Microsoft.XMLHTTP");
        }
        catch (e) 
        {
            try { $aj = new ActiveXObject("MSXML2.XMLHTTP"); } catch (Es) { $aj = false; }
        }

        if (!$aj && typeof XMLHttpRequest != 'underfined') 
        {
            $aj = new XMLHttpRequest();
        }

        return ($aj);
    };
	
	/*
		2009-09-12 황진우
		ajax request
    */
    homiKnowledge.ajProc;
    homiKnowledge.ajProcCall = function(method, action, param, callFunction, call) 
    {
        if (!homiKnowledge.ajProc) homiKnowledge.ajProc = this.loadHttp();
        homiKnowledge.ajProc.open(method, action, call);
        homiKnowledge.ajProc.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
        homiKnowledge.ajProc.onreadystatechange = callFunction;
        homiKnowledge.ajProc.send((method == 'POST') ? param : null);
    }
    
    /*
		2009-11-25 황진우
		지정한 영역에 노드를 추가합니다.
    */
    homiKnowledge.createNode=function(f,sId)
    {
	    var $node=document.createElement('div');
	    //처음
	    //(sId?docs.$(sId).insertBefore(this.node):document.body.insertBefore(this.node));
	    //끝
	    (sId?homiKnowledge.$(sId).appendChild($node):document.body.appendChild($node));
	    
	    $node.innerHTML = f;
    }
    
    /***********************************************************************
		2009-10-24 황진우
		검색 셀렉트박스 이벤트 제어
    ***********************************************************************/
    //searchForm object생성
    homiKnowledge.searchForm = {};
    //토글 버튼 이벤트
    homiKnowledge.searchForm.toggleSearch = function()
    {
        if (homiKnowledge.$('searchType').style.display == 'block') 
        {
            document['onmousedown'] = homiKnowledge.searchForm.clearEvent;
            document['onkeydown'] = homiKnowledge.searchForm.clearEvent;
            homiKnowledge.$('searchType').style.display = 'none';
        }
        else 
        {
            homiKnowledge.$('hotSearchType').style.display = 'none';
            document['onmousedown'] = homiKnowledge.searchForm.clearSearch;
            document['onkeydown'] = homiKnowledge.searchForm.clearDownSearch;
            
            homiKnowledge.searchForm.currentSelect('searchType');
            homiKnowledge.$('searchType').style.display = 'block';
        }
    }
    
    //인기검색 이벤트
    homiKnowledge.searchForm.toggleHotSearch = function() 
    {
        if (homiKnowledge.$('hotSearchType').style.display == 'block') 
        {
            document['onmousedown'] = homiKnowledge.searchForm.clearEvent;
            document['onkeydown'] = homiKnowledge.searchForm.clearEvent;
            homiKnowledge.$('hotSearchType').style.display = 'none';
        }
        else 
        {
            homiKnowledge.$('searchType').style.display = 'none';
            document['onmousedown'] = homiKnowledge.searchForm.clearSearch;
            document['onkeydown'] = homiKnowledge.searchForm.clearHotDownSearch;
            homiKnowledge.$('hotSearchType').style.display = 'block';
        }
    }
    
    //토글 버튼 이벤트
    homiKnowledge.searchForm.toggleDownSearch = function(e)
    {
        if (e)
	    {
		    if (e.which==13)
		    {
			    homiKnowledge.searchForm.toggleSearch();
			    homiKnowledge.$('searchType').getElementsByTagName('li')[homiKnowledge.searchForm.currentDownCheck].focus();
			    return false;	
		    }
	    }
	    else if (window.event.keyCode == 13) 
        {
            homiKnowledge.searchForm.toggleSearch();
            homiKnowledge.$('searchType').getElementsByTagName('li')[homiKnowledge.searchForm.currentDownCheck].focus();
            return false;
        }
    }
    
    //인기검색 이벤트
    homiKnowledge.searchForm.toggleHotDownSearch = function(e) 
    {
        if (e)
	    {
		    if (e.which==13)
		    {
			    homiKnowledge.searchForm.toggleHotSearch();
			    return false;
		    }
	    }
	    else if (window.event.keyCode == 13) 
        {
            homiKnowledge.searchForm.toggleHotSearch();
            return false;
        }
    }
    
    //활성화된 검색 이벤트 제어
    homiKnowledge.searchForm.clearSearch = function(e) 
    {
        $node = e ? e.target : window.event.srcElement;

        if ($node.className && $node.className === 'selectBoxList') 
        {
            return;
        }
        else 
        {
            if (homiKnowledge.$('searchType').style.display == 'block')
                homiKnowledge.searchForm.toggleSearch();
            else if (homiKnowledge.$('hotSearchType').style.display == 'block')
                homiKnowledge.searchForm.toggleHotSearch();
        }
    }
    
    //활성화된 검색 다운 이벤트 제어
    homiKnowledge.searchForm.currentDownCheck = 0;
    homiKnowledge.searchForm.currentMoveCheck = '';
    homiKnowledge.searchForm.clearDownSearch = function(e) 
    {
        if (e)
	    {
		    if (e.which == 38)
		    {
				homiKnowledge.searchForm.currentMoveHandle('up');
				
				homiKnowledge.searchForm.currentDownCheck--;
				homiKnowledge.searchForm.currentMoveCheck = 'up';
				return false;
		    }
		    else if (e.which == 40)
		    {
				homiKnowledge.searchForm.currentMoveHandle('down');
				
				homiKnowledge.searchForm.currentDownCheck++;
				homiKnowledge.searchForm.currentMoveCheck = 'down';
				return false;
		    }
	    }
	    else
        {
			if (window.event.keyCode == 38) 
			{
				homiKnowledge.searchForm.currentMoveHandle('up');
				
				homiKnowledge.searchForm.currentDownCheck--;
				homiKnowledge.searchForm.currentMoveCheck = 'up';
				return false;
			}
			else if (window.event.keyCode == 40)
			{
				homiKnowledge.searchForm.currentMoveHandle('down');
				
				homiKnowledge.searchForm.currentDownCheck++;
				homiKnowledge.searchForm.currentMoveCheck = 'down';
				return false;	
			}
        }
    }
    
    homiKnowledge.searchForm.currentMoveHandle = function(f)
    {
		if ((f=='up' && this.currentMoveCheck=='down') || (f=='down' && this.currentMoveCheck=='up'))
		{
			switch(f)
			{
				case 'up' : 
						this.currentDownCheck = (Number(this.currentDownCheck)-2);
					break;
				case 'down' :
						this.currentDownCheck = (Number(this.currentDownCheck)+2);
					break;
			}
		}
		
		if (this.currentDownCheck < 0)
			this.currentDownCheck = (homiKnowledge.$('searchType').getElementsByTagName('li').length-1);
		
		if (this.currentDownCheck >= homiKnowledge.$('searchType').getElementsByTagName('li').length)
			this.currentDownCheck = 0;
			
		homiKnowledge.$('searchType').getElementsByTagName('li')[homiKnowledge.searchForm.currentDownCheck].focus();
    }
    
    //활성화된 인기검색어 다운 이벤트 제어
    homiKnowledge.searchForm.currentHotDownCheck = 0;
    homiKnowledge.searchForm.currentHotMoveCheck = '';
    homiKnowledge.searchForm.clearHotDownSearch = function(e) 
    {
        if (e)
	    {
		    if (e.which==38)
		    {
				homiKnowledge.searchForm.currentHotMoveHandle('up');
				
				homiKnowledge.searchForm.currentHotDownCheck--;
				homiKnowledge.searchForm.currentHotMoveCheck = 'up';
				return false;
		    }
		    else if (e.which == 40)
		    {
				homiKnowledge.searchForm.currentHotMoveHandle('down');
				
				homiKnowledge.searchForm.currentHotDownCheck++;
				homiKnowledge.searchForm.currentHotMoveCheck = 'down';
				return false;
		    }
	    }
	    else
        {
			if (window.event.keyCode == 38) 
			{
				homiKnowledge.searchForm.currentHotMoveHandle('up');
				
				homiKnowledge.searchForm.currentHotDownCheck--;
				homiKnowledge.searchForm.currentHotMoveCheck = 'up';
				return false;
			}
			else if (window.event.keyCode == 40)
			{
				homiKnowledge.searchForm.currentHotMoveHandle('down');
				
				homiKnowledge.searchForm.currentHotDownCheck++;
				homiKnowledge.searchForm.currentHotMoveCheck = 'down';
				return false;	
			}
        }
    }
    
    homiKnowledge.searchForm.currentHotMoveHandle = function(f)
    {
		if ((f=='up' && this.currentHotMoveCheck=='down') || (f=='down' && this.currentHotMoveCheck=='up'))
		{
			switch(f)
			{
				case 'up' : 
						this.currentHotDownCheck = (Number(this.currentHotDownCheck)-2);
					break;
				case 'down' :
						this.currentHotDownCheck = (Number(this.currentHotDownCheck)+2);
					break;
			}
		}
		
		if (this.currentHotDownCheck < 0)
			this.currentHotDownCheck = (homiKnowledge.$('hotSearchType').getElementsByTagName('li').length-1);
		
		if (this.currentHotDownCheck >= homiKnowledge.$('hotSearchType').getElementsByTagName('li').length)
			this.currentHotDownCheck = 0;
			
		homiKnowledge.$('hotSearchType').getElementsByTagName('li')[homiKnowledge.searchForm.currentHotDownCheck].focus();
    }
    
	//이벤트 제거
    homiKnowledge.searchForm.clearEvent = function(e) 
    {
        if (e) 
        {
            e.target.stopPropagation();
        }
        else 
        {
            window.event.cancelBubble = true;
        }
    }
	
	//검색 타입 
    homiKnowledge.searchForm.searchSelectType = 'Search_All';
    homiKnowledge.searchForm.selectOver = function() 
    {
		for(var i=0; i < homiKnowledge.$('searchType').getElementsByTagName('li').length;i++)
		{
			 homiKnowledge.$('searchType').getElementsByTagName('li')[i].style.backgroundColor = '';
		}
		
        return this.style.backgroundColor = '#e0e0e0';
    }
    
    homiKnowledge.searchForm.hotSelectOver = function() 
    {
		for(var i=0; i < homiKnowledge.$('hotSearchType').getElementsByTagName('li').length;i++)
		{
			 homiKnowledge.$('hotSearchType').getElementsByTagName('li')[i].style.backgroundColor = '';
		}
		
        return this.style.backgroundColor = '#e0e0e0';
    }
    
    homiKnowledge.searchForm.selectOut = function() 
    {
        return this.style.backgroundColor = '#e0e0e0';
    }
    
	//메뉴 선택시
    homiKnowledge.searchForm.selectClick = function(str,id) 
    {
        homiKnowledge.$('search_select').innerHTML = this.innerHTML;
        homiKnowledge.searchForm.searchSelectType = this.id;
        homiKnowledge.$('searchKeyWord').focus();
        homiKnowledge.searchForm.toggleSearch();
    }
    homiKnowledge.searchForm.selectKeyDown = function(str,id) 
    {
        homiKnowledge.$('search_select').innerHTML = str;
        homiKnowledge.searchForm.searchSelectType = id;
        homiKnowledge.$('searchKeyWord').focus();
        homiKnowledge.searchForm.toggleSearch();
    }
    //메뉴 선택시
    homiKnowledge.searchForm.selectDown = function(e) 
    {
		if (e)
	    {
		    if (e.which==13)
		    {
			    homiKnowledge.searchForm.selectKeyDown(this.innerHTML, this.id);
			    return false;
		    }
		    else if (e.which == 9)
			{
				homiKnowledge.$('searchKeyWord').focus();
				homiKnowledge.searchForm.toggleSearch();
			}
		    
	    }
	    else if (window.event.keyCode == 13) 
        {
            homiKnowledge.searchForm.selectKeyDown(this.innerHTML, this.id);
            return false;
        }
        else if (window.event.keyCode == 9)
        {
			homiKnowledge.$('searchKeyWord').focus();
			homiKnowledge.searchForm.toggleSearch();
        }
    }
    //인기검색 선택시
    homiKnowledge.searchForm.hotSelectDown = function(e) 
    {
		if (e)
	    {
		    if (e.which==13)
		    {
			    homiKnowledge.searchForm.hotClick(this.innerHTML);
			    return false;
		    }
		    else if (e.which == 9)
			{
				homiKnowledge.searchForm.toggleHotSearch();
			}
		    
	    }
	    else if (window.event.keyCode == 13) 
        {
            homiKnowledge.searchForm.hotClick(this.innerHTML);
            return false;
        }
        else if (window.event.keyCode == 9)
        {
			homiKnowledge.searchForm.toggleHotSearch();
        }
    }
	//인기검색 선택시
    homiKnowledge.searchForm.hotClick = function(f) 
    {
        location.replace('/Search/Search.aspx?SearchType=All&SearchKeyword=' + encodeURI(f.trim()));
    }
    homiKnowledge.searchForm.hotSelectClick = function() 
    {
        location.replace('/Search/Search.aspx?SearchType=All&SearchKeyword=' + encodeURI(this.innerHTML.trim()));
    }
    homiKnowledge.searchForm.currentSelect = function(selectId) 
    {
        $selectList = homiKnowledge.$(selectId).getElementsByTagName('li');
        for (this.i = 0; this.i < $selectList.length; this.i++) 
        {
            $selectList[this.i].style.backgroundColor = '';
        }
        $selectList[homiKnowledge.searchForm.searchSelectType].style.backgroundColor = '#e0e0e0';
    }
	
	//검색 유효성 검사
    homiKnowledge.searchForm.go = function(f) 
    {
        this.searchKeyWord = homiKnowledge.$('searchKeyWord');

        if (!this.searchKeyWord.value) {
			//이벤트 우선순위 때문에 ie에서만 작동하게설정
            if (homiKnowledge.browser.user == 'ie' || f)
				alert('검색어를 입력해주세요!');
				
            this.searchKeyWord.focus();
            return;
        }

        location.replace('/Search/Search.aspx?SearchType=' + homiKnowledge.searchForm.searchSelectType.replace('Search_','') + 
			'&SearchKeyword=' + encodeURI(homiKnowledge.$('searchKeyWord').value.trim()));
    }
	
	//인기 검색어 이벤트 생성
    homiKnowledge.searchForm.hotSelectList = function() 
    {
        $selectList = homiKnowledge.$('hotSearchType').getElementsByTagName('li');
        for (this.i = 0; this.i < $selectList.length; this.i++) 
        {
            $selectList[this.i]['onmouseover'] = homiKnowledge.searchForm.hotSelectOver;
            $selectList[this.i]['onfocus'] = homiKnowledge.searchForm.hotSelectOver;
            $selectList[this.i]['onmouseout'] = homiKnowledge.searchForm.selectOut;
            $selectList[this.i]['onblur'] = homiKnowledge.searchForm.selectOut;
            $selectList[this.i]['onkeydown'] = homiKnowledge.searchForm.hotSelectDown;
            $selectList[this.i]['onclick'] = homiKnowledge.searchForm.hotSelectClick;
        }
    }
	
	//검색타입목록 이벤트 생성
    homiKnowledge.searchForm.selectList = function() 
    {
        $selectList = homiKnowledge.$('searchType').getElementsByTagName('li');

        for (this.i = 0; this.i < $selectList.length; this.i++) 
        {
            $selectList[this.i]['onmouseover'] = homiKnowledge.searchForm.selectOver;
            $selectList[this.i]['onfocus'] = homiKnowledge.searchForm.selectOver;
            $selectList[this.i]['onmouseout'] = homiKnowledge.searchForm.selectOut;
            $selectList[this.i]['onblur'] = homiKnowledge.searchForm.selectOut;
            $selectList[this.i]['onclick'] = homiKnowledge.searchForm.selectClick;
            $selectList[this.i]['onkeydown'] = homiKnowledge.searchForm.selectDown;
        }
    }
	
	//검색중이라면 검색메뉴 기본 설정
    homiKnowledge.searchForm.setSearch = function() 
    {
        this._SearchType = 'SearchType'.paramValue();
        //this._SearchKeyword = 'SearchKeyword'.paramValue();

        if (this._SearchType) 
        {
            if (!homiKnowledge.$('Search_' + this._SearchType)) return;
            homiKnowledge.searchForm.searchSelectType = 'Search_' + this._SearchType;
            homiKnowledge.$('search_select').innerHTML = homiKnowledge.$('Search_' + this._SearchType).innerHTML;
        }

        if (this._SearchKeyword) 
        {
            homiKnowledge.$('searchKeyWord').value = this._SearchKeyword;
        }
    }
    
    //텍스트박스 엔터 입력시
    homiKnowledge.searchForm.searchTextClick = function(e) 
    {
	    if (e)
	    {
		    if (e.which==13)
		    {
			    homiKnowledge.searchForm.go();	
			    return false;
		    }
	    }
	    else if (window.event.keyCode == 13) 
        {
            homiKnowledge.searchForm.go();
            return false;
        }
    }
    
	//검색 도입시 첨부시킬 스크립트
    homiKnowledge.searchForm.init = function() 
    {
        homiKnowledge.$('searchKeyWord')['onkeydown'] = homiKnowledge.searchForm.searchTextClick;
        this.selectList();
        this.hotSelectList();
    }
    
    
    /*
		2009-09-10 황진우
		함수 호출시 이용합니다.
    */
    Function.prototype.addFunction = function() {
        var $method = this;
        for (var $args = [], $i = 0; arguments[$i]; ++$i) $args.push(arguments[$i]);
        $obj = $args.shift();
        return function() { return $method.apply($obj, $args); };
    }

    /*
		숫자인지 검사합니다 문자일경우 0을 리턴합니다.
		2009-09-15 황진우
    */
    String.prototype.numberCheck = function() {
        regexp = /^\d+$/
        return regexp.test(this) ? this : 0;
    }
    /*
		문자열의 양쪽 공백을 제거합니다.
		2009-10-05 이영무
    */
    String.prototype.trim = function() {
        return this.replace(/(^\s*)|(\s*$)/g, "");
    }
    
    /*
		HTML을 제거합니다.
		2009-10-05 이영무
    */
    String.prototype.htmlTrim = function() {
        return this.replace(/<[^>]*?>|<\/[^>]*?>/g, "");
    }
    
    /*
		파라미터 값 리턴
		2009-11-10 황진우
    */
    String.prototype.paramValue = function() 
    {
        var $path = decodeURI(location.search).substring(1).split(/\&/g);
        for (this.i in $path) 
        {
            this.param = $path[this.i].split(/\=/g);
            if (this == this.param[0])
		    {
                return this.param[1];
		    }
        }
    }

})();

/*
	좌측메뉴 롤오버 처리
	2009-10-05 이영무
*/
function leftMenuActive(object, image)
{
    object.src = image;
}

/************************************************************************
	관심 지식을 스크랩합니다. 출력을 관리합니다.
	2009-11-20 임준기
*************************************************************************/
// FavoriteKnowledge 오브젝트 생성
var FavoriteKnowledge = {
    init : function (type, userId, titleId, imgUrl, printElementId, cssUrl, title)
    {
        this.htmlObj = '';
        this.type = type;                       //출력타입
        this.userId = userId;                   //아이디
        this.elementId = titleId;               //제목아이디
        //버튼경로
        this.imgUrl = imgUrl ? imgUrl : '/Images/Button/btn_favoriteknowledge.gif';
        this.printElementId = printElementId;   //프린트대상아이디
        this.cssUrl = cssUrl;                   //스타일시트 경로
    
        //프린트창제목
        this.title = this.titleConfirm(title);
        
        switch(type)
        {
            case 1 :
                    this.htmlObj += this.nowledge(); //스크랩
                break;
            
            case 2 :
                    this.htmlObj += this.print(); //프린터
                break;
                
            default :
                    this.htmlObj += this.print(); //프린터
                    if (this.userId)
                        this.htmlObj += this.nowledge(); //스크랩
                break;
        }
        
        document.write(this.htmlObj);
    },
    nowledge : function()
    {
        return '<a href="javascript:Scrap();" title="관심지식 등록"><img src="' + this.imgUrl + '" alt="스크랩" style="padding-left:3px;"/></a>';
    },
    print : function ()
    {
        return '<a href="javascript:PagePrint();"><img src="/Images/Button/btn_Print.gif" alt="인쇄"/></a>'
    },
    titleConfirm : function (title)
    {
        if (homiKnowledge.$(title))
        {
            return homiKnowledge.$(title).innerHTML.htmlTrim(); //html제거
        }
        else 
        {
            return title;
        }
    }
    
};
//스크랩 유효성 검사후 처리
function Scrap()
{
    if ( !(homiKnowledge.$(FavoriteKnowledge.elementId).innerHTML) || !(location.pathname) )
    {
        alert("스크랩 할 컨텐츠가 없습니다 ");
    }
    else
    {
        homiKnowledge.ajProcCall('POST', '/MyPage/FavoriteKnowledgeRegist.aspx', 'title=' + encodeURI(homiKnowledge.$(FavoriteKnowledge.elementId).innerHTML) + '&url=' + escape(location.pathname + location.search), ScrapResult, true);
    }
}
//스크랩 처리결과
function ScrapResult()
{
    //alert(homiKnowledge.ajProc.responseText); //오류확인창2. 실행되면 자바스크립트 오류남. 에러메시지 확인할때만 사용할것
    if (homiKnowledge.ajProc.readyState == 4)
    {
        send = homiKnowledge.ajProc.responseText;

        switch(send)
        {
            case "0":
                alert("관심지식으로 스크랩하였습니다 ");
                return;
            case "1":
                alert("스크랩 실패 ");
                return;
            case "2":
                alert("이미 스크랩하였습니다 ");
                return;    
            case "3":
                alert("로그인후 이용해 주세요 ");
                return;
            case "4":
                alert("잘못된 접근입니다 ");
                return;
            default :
                alert("스크랩 오류 ");
                return;
        }
        
    }
}

/*************************************************************************
	현재 페이지의 컨텐츠를 프린트 합니다.
	2009-11-25 임준기
**************************************************************************/
homiKnowledge.$newWin; //창 객체

function PagePrint()
{
    str ='<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">';
    str+='<html xmlns="http://www.w3.org/1999/xhtml">';
    str+='<head>';
    str+='<title>' + FavoriteKnowledge.title + '</title>';
    str+='<link href="/Css/Print.css" rel="stylesheet" type="text/css" />';
    str+='<script type="text/javascript" src="/Js/common.js"/></script>';
    str+='<link href="' + FavoriteKnowledge.cssUrl + '" rel="stylesheet" type="text/css" />';
    str+='</head><body onload="PagePrintInit();">';
    str+="<div id='printArea'><div id='"+ FavoriteKnowledge.printElementId +"'>" + eval("homiKnowledge.$('" + FavoriteKnowledge.printElementId + "').innerHTML").replace(/<A[^>]*?>/g, "<a href=\"#\">") + "</div></div>";
    str+='<div id="nodeArea"></div>';
    str+='<!--<div id="getPopPrint"><a href="javascript:window.print();"><img src="/Images/Button/btn_Print.gif"></a></div>-->'
    str+='</body></html>';
    
	this.$popup = false;

	try
	{
		homiKnowledge.$newWin.close();
		this.$popup = true;
	}
	catch (e)
	{
		this.$popup = true;
	}
	
	if (this.$popup == true)
	{
		homiKnowledge.$newWin = open('', FavoriteKnowledge.printElementId, 'width=660,height=400,menubar=0,scrollbars=1,status=0,toolbar=0,location=0,directories=0,resizable=0');
		homiKnowledge.$newWin.document.open();
		homiKnowledge.$newWin.document.write(str);
		homiKnowledge.$newWin.document.close();
		homiKnowledge.$newWin.focus();
	}
}

function ClearEvent(e)
{
	if (e)
		return false;
	else 
		window.event.keyCode = 1;
	
	return false;
}

function PagePrintInit()
{
	document['onkeydown'] = ClearEvent;
	$node= homiKnowledge.$('printArea');
	//homiKnowledge.$('nodeArea').style.width = document.documentElement.scrollWidth + 'px';
	//homiKnowledge.$('nodeArea').style.height = document.documentElement.scrollHeight + 'px';
	//homiKnowledge.$('nodeArea').style.backgroundColor = '#fff';
	
	/*
	if (homiKnowledge.browser.user == 'ie')
		homiKnowledge.$('nodeArea').style.filter = 'alpha(opacity=100)';
	else
		homiKnowledge.$('nodeArea').style.opacity = '0.1';	
	*/
	$width = document.documentElement.offsetWidth > 660 ? document.documentElement.offsetWidth : 660;
	
	if(confirm('인쇄하시겠습니까?'))
	{
		window.print();
	}
	
}

/*************************************************************************
	화면 글씨 크기 이벤트
	2009-11-25 황진우
**************************************************************************/
var defaultSize = 12;
var defaultIconPos = 833;
function addFontSize(pos,elementId,f)
{
    if (pos == '+')
    {
        if(defaultSize >= 30) return;
        
        defaultIconPos = defaultIconPos + 2;
        
        if (defaultIconPos <= 862)
        {
			homiKnowledge.$('staticIcon').style.left =  defaultIconPos + 'px'
		}
        else
        {
			defaultIconPos=862;
			return;
		}
		
        defaultSize++;
    }
    else if (pos == '-')
    {
        if(defaultSize <= 2) return;
        defaultIconPos = defaultIconPos - 2;
        homiKnowledge.$('staticIcon').style.left =  defaultIconPos + 'px'
        defaultSize--;
    }
    else
    {
		//defaultSize = f ? 11:12;
		defaultSize = 12;
		defaultIconPos = 833;
		homiKnowledge.$('staticIcon').style.left =  '833px';
    }
    //homiKnowledge.$('contentBottom').style.lineHeihgt = currentLineheight + "px";
    homiKnowledge.$(elementId).style.fontSize=defaultSize + "px";
}
