﻿//Class constructor
function AJAXRSSControl(params)
{   
    //sets the object on the window to be accessed easily
    var id = new Date().getTime().toString();
    var windowKey = 'window.AJAXRSSControl_' + id;
    eval(windowKey + ' = this;');

    this.GeneralErrorMessage = params.GeneralErrorMessage;

    //dr.  added this to dynamically set target.
    var target = google.feeds.LINK_TARGET_BLANK;
    if (params.BrowserTarget == "_self") {
        target = google.feeds.LINK_TARGET_SELF;
    }
 
    //creaets the Google dynamic feed control
    var options =
    {
        //linkTarget: google.feeds.LINK_TARGET_SELF,
        //linkTarget : params.BrowserTarget,
        linkTarget : target,
        stacked : false,
        horizontal : false,
        numResults : params.MaximumEntries,
        customHeaderUrl : params.CustomHeaderUrl,
        title : params.CustomHeaderText,
        evenRowStyle : params.EvenRowStyle,
        alternatingRowStyle : params.AlternatingRowStyle,
        newEntryRowStyle : params.NewEntryRowStyle,
        highligthSyteDisplay : params.HighligthSyteDisplay,
        maximumDescriptionChars : params.MaximumDescriptionChars,
        generalErrorMessage : params.GeneralErrorMessage,
        errorMessagesStyle : params.ErrorMessagesStyle,
        headerStyle : params.HeaderStyle,
        feedContainerStyle : params.FeedContainerStyle,
        entryDateLabelStyle : params.EntryDateLabelStyle,
        sortByDate : true,
        readMoreLinkText : params.ReadMoreLinkText,
        readMoreLinkStyle : params.ReadMoreLinkStyle,
        baseFeedLoaderPath : params.BaseFeedLoaderPath,
        loadingMessageText : params.LoadingMessageText,
        loadingMessageStyle : params.LoadingMessageStyle,
        noDataMessage : params.NoDataMessage,
        noDataStyle : params.NoDataStyle
    };

    this.FeedControl = new GFdynamicFeedControl(params.FeedURL, params.FeedControlId, options);
    
    //timer to refresh feeds every X secods
    if(params.RefreshSpan > 0)
    {
        this.RefreshTimer = window.setInterval(windowKey + '.RefreshFeeds();', params.RefreshSpan * 1000);
    }
}

//method used to refresh automatically the feeds loaded
AJAXRSSControl.prototype.RefreshFeeds = function()
{
    this.FeedControl.loadFeeds();
}