var urlPath = location.pathname;
var languageType = urlPath.match('/en/') || "/fr/";
var dc_text = {};
if (languageType == '/en/') {
    var langType = '1';
    var more_text = "MORE"
}
else {
    langType = '2';
    more_text = "PLUS"
}

var blogFeed = "/blog/syndication.axd";
//var blogFeed = '/test.xml';

function getBlogFeed(url){
    $.ajax({
        url: url,
        type: 'GET',
        dataType: 'xml',
        cache: false,
        timeout: 100000,
        error: function(){
        
        },
        success: processFeed
    });
};

function processFeed(data){
    setTimeout(function(){
        var title = $(data).find('item[language=' + langType + ']:eq(0) title').text();
        var input = unescape($(data).find('item[language=' + langType + ']:eq(0) description').text());
        $('p.new_blog_post span').remove();
        $('p.new_blog_post').html(input).children().hide();
        input = $('p.new_blog_post p:first').text();
        $('p.new_blow_post *').remove();
        if (input.length >= 145) {
            $('p.new_blog_post').append('<strong>' + title + '</strong><br>' + input.slice(0, 145) + '...<a href="blog.html" class="more">' + more_text + '</a>');
        }
        else {
            $('p.new_blog_post').append('<strong>' + title + '</strong><br>' + input + '<a href="blog.html" class="more">' + more_text + '</a>');
        }
    }, 1500)
}


$(document).ready(function(){
    getBlogFeed(blogFeed)
})
