﻿document.write('<script type="text/javascript" src="http://fai.informazione.it/js/jquery.js"></script>');
document.write('<script type="text/javascript" src="http://fai.informazione.it/js/jquery-dom.js"></script>');
document.write('<script type="text/javascript" src="http://fai.informazione.it/js/jquery.dateFormat.js"></script>');
document.write('<link rel="stylesheet" type="text/css" media="all" href="http://fai.informazione.it/css/widget.css" />');

if (typeof infoit_theme == 'string' && infoit_theme.charAt(0) != 'f')
    infoit_theme = "fa" + infoit_theme;

infoit_width = typeof infoit_width == 'string' ? infoit_width : '300px';
infoit_height = typeof infoit_height == 'string' ? infoit_height : '350px';
infoit_border = typeof infoit_border == 'number' ? infoit_border : 1;
infoit_target = typeof infoit_target == 'number' ? infoit_target == 1 ? '_blank' : '' : ''; infoit_count = typeof infoit_count == 'number' ? infoit_count == 0 ? 'no-fainfoit-count' : '' : '';
infoit_summary = typeof infoit_summary == 'number' ? infoit_summary == 0 ? 'no-fainfoitSummary' : '' : '';
infoit_theme = typeof infoit_theme == 'string' ? infoit_theme != 'fainfoit-widget-unstyled' ? 'fainfoit-widget ' + infoit_theme : infoit_theme : 'fainfoit-widget fainfoit-widget-theme1';
infoit_title = typeof infoit_title == 'string' ? infoit_title : 'SOCIAL NEWS';

if (infoit_theme.search(/fainfoit-widget-theme5/i) > -1) {
    infoit_customHeader = typeof infoit_customHeader == 'string' ? ' style="background: ' + infoit_customHeader + '"' : '';
    infoit_customTopic = typeof infoit_customTopic == 'string' ? ' style="background: ' + infoit_customTopic + '"' : '';
    infoit_customBody = typeof infoit_customBody == 'string' ? 'background: ' + infoit_customBody + ';' : '';
    infoit_customBorder = typeof infoit_customBorder == 'string' ? 'border-color: ' + infoit_customBorder + ';' : '';
    infoit_customLink = typeof infoit_customLink == 'string' ? infoit_customLink : '';
    infoit_customHoverLink = typeof infoit_customHoverLink == 'string' ? infoit_customHoverLink : '';
    infoit_customFooter = typeof infoit_customFooter == 'string' ? ' style="background: ' + infoit_customFooter + '"' : '';
}
else {
    infoit_customHeader = ''; infoit_customTopic = ''; infoit_customBody = ''; infoit_customBorder = ''; infoit_customLink = '';
    infoit_customHoverLink = '';infoit_customFooter = '';
}
infoit_id = typeof infoit_id == 'string' ? '' + infoit_id + '' : 'fiwidgetContainer';

document.write('<div id="' + infoit_id + '" class="' + infoit_theme + '" style="width: ' + infoit_width + '; border-width: ' + infoit_border * 7 + 'px; ' + infoit_customBorder + '" align="left">');
document.write('<div class="fainfoit-widget-header" ' + infoit_customHeader + '><h1 ' + infoit_customHeader + '><a href="http://fai.informazione.it" title="fai.informazione.it - Social News"></a></h1></div>');
document.write('<div class="fainfoit-widget-topic" ' + infoit_customTopic + '>' + infoit_title + '</div>');
document.write('<ul style="height: ' + infoit_height + ';' + infoit_customBody + '" class="' + infoit_count + ' ' + infoit_summary + '"></ul>');
document.write('<div class="fainfoit-widget-footer"' + infoit_customFooter + '></div></div>');

function __fainfowidhelper() {
    var a = new Array();
    a.push(infoit_id);
    a.push(infoit_target);
    a.push(infoit_customLink);
    a.push(infoit_summary);
    a.push(infoit_customHoverLink);
    a.push(infoit_customBody);
    return a;
}

function __fainfowid(obj,a) {
    if (!$j) setTimeout(function() { __infowid(obj); }, 200);
    var loc_id = a[0];
    var loc_target = a[1];
    var loc_customLink = a[2];
    var loc_summary = a[3];
    var loc_customHoverLink = a[4];
    var loc_customBody = a[5];
    
    $j('#' + loc_id + ' ul').html('');
    var s = '';
    var d = 'display:none;';
    var wvote = '';
    var tpl = function() {
        return [
            'li', {}, [
                'a', { 'href': this.Url, 'class': 'fainfoit-count' }, this.VoteCount + ' <span>'+wvote+'</span>',
                 'h3', { 'style': loc_customBody }, [
                    'a', { 'href': this.Url, 'target': loc_target, 'style': 'color: ' + loc_customLink + ' ' }, this.Title,
                    'span', { 'style': d }, s
                ],
                'p', {}, this.Description,

            ]
        ];
    };
    if (!obj) {
        $j('#' + loc_id + ' ul').html('Non è stato possibile acquisire le notizie da fai.informazione.it. Suggeriamo di riprovare, riaggiornando la pagina.');
    }
    if (!obj || obj.length == 0) {
        $j('#' + loc_id + ' ul').html('Al momento, su fai.informazione.it non sono disponibili notizie del tipo richiesto.');
    }
    if (obj) {
        if (loc_summary != '')
            d = '';
        for (var i = 0; i < obj.length; i++) {
            s = '';
            if (d == '')
                s = ' - ' + obj[i].WhenPosted;
            else
                obj[i].Description += ' - ' + obj[i].WhenPosted;
            wvote = obj[i].VoteCount == 1 ? 'voto' : 'voti';
            $j('#' + loc_id + ' ul').tplAppend(obj[i], tpl);
        }
    }
    if (loc_customHoverLink != '') {
        var z = "$j('#" + loc_id + " ul h3 a').hover(function() { $j(this).css('color', '"+loc_customHoverLink+"'); }, function() { $j(this).css('color', '"+loc_customLink+"'); })";
        eval('(' + z + ')');
    }
}