﻿function append_social_post(platform, title, link, picture, linkTitle, description) {
    var posts = $('#posts');
    var postItem = $('<div class="post-item"></div>');
    postItem.addClass(platform);
    var postTitle = $('<div class="post-title"></div>');
    postTitle.html(title);
    postItem.append(postTitle);
    if (picture != '') {
        var postPicture = $('<div class="post-picture"></div>');
        postPicture.html('<a href="' + link + '" title="' + title + '" target="_blank"><img alt="' + title + '" title="' + title + '" src="' + picture + '" /></a>');
        postItem.append(postPicture);
    }
    var postLink = $('<div class="post-link"></div>');
    postLink.html('<a href="' + link + '" target="_blank">' + linkTitle + '</a>');
    postItem.append(postLink);
    var postDescription = $('<div class="post-description"></div>');
    postDescription.html(description);
    postItem.append(postDescription);
    posts.append(postItem);
}

function append_portfolio_post(platform, title, link, thumbnail, picture) {
    var posts = $('#posts');
    var postItem = $('<div class="post-item" style="width: 220px; height: 200px; float: left; margin: 5px 15px 5px 0;"></div>');
    postItem.addClass(platform);
    var postTitle = $('<div class="post-title"><a href="' + link + '" target="_blank">' + title + '<a></div>');
    postItem.append(postTitle);
    var postPicture = $('<div class="post-picture" style="margin-left: -5px;"></div>');
    postPicture.html('<a href="' + picture + '" class="fancy" title="' + title + '" rel="portfolio"><img alt="' + title + '" title="' + title + '" style="max-width: 190px; max-height: 150px;" src="' + thumbnail + '" /></a>');
    postItem.append(postPicture);
    posts.append(postItem);
}

function GetURLFullSize(entry) {

    var content = entry.content;
    var start = content.indexOf("<img src=") + 10;
    var stop = content.indexOf(".jpg", start) + 4;
    var thumburl = content.substring(start, stop);


    return (thumburl);
}

function linkify_plain(text) {
    if (!text) return text;

    text = text.replace(/((https?\:\/\/|ftp\:\/\/)|(www\.))(\S+)(\w{2,4})(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/gi, function (url) {
        return '<a target="_blank" rel="nofollow" href="' + url + '">' + url + '</a>';
    });

    return text;
}
