﻿

/*
        [MHz.OpenBlog.Ver.1]
        (c) 2007 MHZ. (http://www.openblog.com)
        
        author  : Pang
        date    : 2007-07-27
        comment : PopPost.aspx JavaScript & AJAX Function
*/

//<!CDATA[[
    function AxCallDate(Date){
        MHz.OpenV1.OpenBlogWeb.PopPost.AxCallDate(Date, AxRetDateList);}
    
    function AxPageChange(PageNo, Date){
        MHz.OpenV1.OpenBlogWeb.PopPost.AxPageChange(PageNo, Date, AxRetPageChange);new Effect.ScrollTo('wrap', {duration: 1.0});}
        
    function AxRecommandPost(ContentID){MHz.OpenV1.OpenBlogWeb.PopPost.AxRecommandPost(ContentID, AxRetRecomm);}
    
    function AxRetDateList(res){
        if(res != null && res.value != null){
            var RetValue = res.value;
            var Control = RetValue.Control;
            var List    = RetValue.List;
            var Pager   = RetValue.Pager;
            
            if($("popDate").style.display == "none")
                $("popDate").style.display = "block";
                
            $("popDate").innerHTML      = Control;
            $("centerPost").innerHTML   = List;
            $("page").innerHTML         = Pager;
        }else{alert(res.error);}}
        
    function AxRetPageChange(res){
        if(res != null && res.value != null){
            var RetValue = res.value;
            var List    = RetValue.List;
            var Pager   = RetValue.Pager;
            
            $("centerPost").innerHTML   = List;
            $("page").innerHTML         = Pager;
        }else{alert(res.error);}
    }
        
    function AxRetRecomm(res){
        if(res != null && res.value != null){
            if(res.value > 0){
                var ContentID = res.value;
                $("PostRecommand" + ContentID).innerHTML = "<img src=\"images/common/btn_recom_over.gif\" alt=\"추천한 포스트\" />"}
            else{alert("다음의 이유로 추천이 실패하였습니다. : " + res.error);}}}
      
    function ViewCalendar(){
        $('calendar').style.display = "block";
	    $('calendar').style.left = (posX - 10+ window.document.body.scrollLeft) +"px";
		$('calendar').style.top = (posY - 10 + window.document.body.scrollTop) +"px";};
		
	function CloseCalendar(){$('calendar').style.display = "none";}
		
	function AxCallCalendar(Year, Month, CategoryID){
	    MHz.OpenV1.OpenBlogWeb.ucCalendar.AxCalendar(Year, Month, CategoryID, AxRetCalendar);}
    
    function AxRetCalendar(res){
        if( res!= null){$('calendar').innerHTML = res.value;}
        else{alert("다음의 이유로 실패하였습니다. : " + res.error);}}
    
    function ChoiceDate(Date, CategoryID){AxCallDate(Date);$('calendar').style.display = "none";}
    
    function AxPopSearch(PageNo)
    {
        var varKeyWord = $('txtPopKeyword').value;
        if(varKeyWord!="") { 
            $("sitenavi").innerHTML = "<a href='http://www.openblog.com'>홈</a> > <a onclick='AxInitPage();'>인기 포스트</a> > " + varKeyWord;
            MHz.OpenV1.OpenBlogWeb.PopPost.AxPopSearch(1, varKeyWord, AxRetSearchList); 
            }
        else
        {
            alert("검색어를 넣어주세요.");
            $('txtPopKeyword').focus();
            return false;
        }
    }
    
    function AxPopSearchPage(PageNo, Keyword){
        MHz.OpenV1.OpenBlogWeb.PopPost.AxPopSearch(PageNo, Keyword, AxRetSearchList);
        new Effect.ScrollTo('wrap', {duration: 1.0});}
    
    function AxRetSearchList(res){
        if(res != null && res.value != null){
            var RetValue = res.value;
            var Control = RetValue.Control;
            var List    = RetValue.List;
            var Pager   = RetValue.Pager;
            
            $("popDate").style.display      = "none";
            
            $("centerPost").innerHTML   = Control + List;
            $("page").innerHTML         = Pager;
        }else{alert(res.error);}}
    
    function AxInitPage(){
        MHz.OpenV1.OpenBlogWeb.PopPost.AxInitPage(AxRetDateList);
        $("sitenavi").innerHTML = "<a href='http://www.openblog.com'>홈</a> > 인기 포스트</p>";}
//]]>