﻿
var xsl_transformer = new XSLTransformer();

var sermon_file = null;

$(document).ready(function()
{
    set_nav_images(2);

    find_gospel();

    play("강론 - " + sermon_file, "http://www.stakim.org/resources/sermons/" + sermon_file + "-sermon.wma");
});

function view_today_mass()
{
    var today = new Date();
    var url = "http://www.cbck.or.kr/page/misa.asp?CurDay=" + today.getFullYear() + "-" + (today.getMonth() + 1) + "-" + today.getDate() + "&p_code=K6300";
    window.open(url, "blank");
}

function find_gospel()
{
    $.ajax({ type: "POST",
        url: "BibleService.asmx/FindGospel",
        dataType: "xml",
        //data: "weekDate=" + week_date,
        async: false,
        processData: false,
        beforeSend: function() { ajax_before_send_find_gospel(); },
        complete: function(XMLHttpRequest) { ajax_complete_find_gospel(XMLHttpRequest); },
        error: function(XMLHttpRequest, textStatus, errorThrown) { ajax_error_find_gospel(XMLHttpRequest, textStatus, errorThrown); },
        success: function(xml, textStatus) { ajax_success_find_gospel(xml, textStatus); }
    });
}

function ajax_before_send_find_gospel()
{
    //$("#gospel_div").html('<img src="./res/app/image/loading_small.gif"></img>');
}

function ajax_complete_find_gospel(XMLHttpRequest)
{
}

function ajax_error_find_gospel(XMLHttpRequest, textStatus, errorThrown)
{
    $("#gospel_div").html('');
}

function ajax_success_find_gospel(xml, textStatus)
{
    // display the returned records
    var content_str = xsl_transformer.transform_doc(xml, "resources/xsl/mass.xslt");
    $("#gospel_div").html(content_str);

    /*var splitted = xml.documetElement.getAttribute("week_date").split("-");
    week_date = new Date();
    week_date.setFullYear(splitted[0], (splitted[1] * 1) - 1, splitted[2]);*/
    sermon_file = xml.documentElement.getAttribute("sermon_file");
}