﻿//Document Done Loading
jQuery(document).ready(
        function()
        {
            //Load TwitterFeeds first time when page is done loading
            LoadTwitterFeeds();
        }
    );

//Load the TwitterFeeds
function LoadTwitterFeeds()
{
    //Set url
    var url = "/layouts/kngu/TwitterLiveUpdate.ashx";
    //Get All Twitter Feed Divs
    var twitterfeeddivs = jQuery(".TwitterFeed");

    //Loop through collection
    jQuery.each(twitterfeeddivs, function(index, value)
    {
        //Set ID and Search Attribute
        var id = jQuery(value).attr("id");
        var maxItems = jQuery(value).attr("maxItems");
        var SiteFullPath = jQuery(value).attr("siteFullPath");
        var user = jQuery(value).attr("user");
        var Color = jQuery(value).attr("color");
        var itemID = jQuery(value).attr("itemID");
        var hashTag = jQuery(value).attr("hashTag");

        //Load data in div
        jQuery("#" + id).load(url, { "user": user, "siteFullPath": SiteFullPath, "maxItems": maxItems, "color": Color, "itemID": itemID, "hashTag": hashTag }, function(response, status, xhr)
        {
            if (status == "error")
            {
                var msg = "Sorry but there was an error: ";
                $("#error").html(msg + xhr.status + " " + xhr.statusText);
            }
        });
    });
}
