﻿/*
        [MHz.OpenBlog.Ver.1]
        (c) 2007 MHZ. (http://www.openblog.com)
        
        author  : Pang
        date    : 2007-07-27
        comment : AllPost.aspx JavaScript & AJAX Function
*/

//<!CDATA[[
    var WorkingNow = false;
    
    function OffSplash() { Element.setStyle('splashDiv',{display:'none'}); }
	function OnSplash()
	{
		var objStyle = 
		{
			zindex:1000,
			position:'absolute',
			top:posY+'px',
			left:'3px',
			width:'210',
			height:'14',
			backgroundColor:'#EEEEEE',
			textAlign:'center',
			display:'block'
		};
		Element.setStyle('splashDiv',objStyle);
		$('splashDiv').update('<strong>페이지 정보를 가져오고 있습니다.</strong>');
	}   
	
    function AxCategoryChange(CategoryID){
        if(!WorkingNow){WorkingNow = true;MHz.OpenV1.OpenBlogWeb.AllPost.AxSetCategory(CategoryID, AxRetCategoryList);}
    }
    function DateChange(Date, CategoryID){
        if(!WorkingNow){WorkingNow = true;MHz.OpenV1.OpenBlogWeb.AllPost.AxSetDate(Date, CategoryID, AxRetCategoryList);}
    }
    
    function HourChange(Time, CategoryID){
        if(!WorkingNow){
            WorkingNow = true;
            var ArrHour = $("postTime").getElementsByTagName("a");
            var Hour = Time.substring(11, 13);
            for (i=0; i < ArrHour.length; i++){if(i == Hour){ArrHour[i].className = "active";}else{if(ArrHour[i].className == "active") ArrHour[i].className = null;}}
            MHz.OpenV1.OpenBlogWeb.AllPost.AxSetHour(Time, CategoryID, AxRetPostList);}}
    
    function AxPageChange(PageNo, Time, CategoryID){
	if(CategoryID == null){
		var CategoryList = $("subLeftCate").getElementsByTagName("li");
		for(i=0;i<CategoryList.length; i++){if(CategoryList[i].className == "active"){CategoryID = i;}}
		if(CategoryID == null){CategoryID = 0;}}
        if(!WorkingNow){
            WorkingNow = true;OnSplash();
            MHz.OpenV1.OpenBlogWeb.AllPost.AxPageChange(PageNo, Time, CategoryID, AxRetPageChangList);}}
    
    function AxRetCategoryList(res){
        if(res != null && res.value != null){
            var RetValue = res.value;
            var RetCategory = RetValue.CategoryList;
            var RetDateView = RetValue.DateView;
            var RetHourNavigation = RetValue.HourNavigation;
            var RetPager = RetValue.Pager;
            
            var CategoryList = $("subLeftCate").getElementsByTagName("ul");
            CategoryList[0].innerHTML   = RetCategory;
            $("centerPost").innerHTML   = RetValue.HourNavigation;
            $("postDate").innerHTML     = RetDateView;
            $("page").innerHTML         = RetPager;
        }else{alert("다음의 이유로 실패하였습니다. : " + res.error.Message);}
        WorkingNow = false;
    }
        
    function AxRetPostList(res){
        if(res != null && res.value != null){
            $("centerPost").innerHTML = res.value.HourNavigation;
            $("page").innerHTML = res.value.Pager;}
        else{alert("다음의 이유로 실패하였습니다. : " + res.error.Message);}
        WorkingNow = false;
    }
        
    function AxRetPageChangList(res){
        if(res != null && res.value != null){
            $("centerPost").innerHTML = res.value.HourNavigation;
            $("page").innerHTML = res.value.Pager;}
        else{alert("다음의 이유로 실패하였습니다. : " + res.error.Message);}
        OffSplash();
        new Effect.ScrollTo('wrap', {duration: 0.0});
        WorkingNow = false;
    }
        
    function AxRecommandPost(ContentID){
        if(!WorkingNow){
            WorkingNow = true;
            MHz.OpenV1.OpenBlogWeb.AllPost.AxRecommandPost(ContentID, AxRetRecomm);}}
    
    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.Message);}}
        WorkingNow = false;
    }
    
    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){
	    if(!WorkingNow){ 
	        WorkingNow = true;
	        MHz.OpenV1.OpenBlogWeb.ucCalendar.AxCalendar(Year, Month, CategoryID, AxRetCalendar);}
	}
    
    function AxRetCalendar(res){
        if( res!= null){$('calendar').innerHTML = res.value;}
        else{alert("다음의 이유로 실패하였습니다. : " + res.error.Message);}
        WorkingNow = false;
    }
    
    function ChoiceDate(Date, CategoryID){DateChange(Date, CategoryID);$('calendar').style.display = "none";}
    
//]]>