﻿var xmlhttp;
var secondsInterval = 30; //30 seconds
var activeMovie;

jQuery(document).ready(
        function()
        {
            //Load TwitterFeeds first time when page is done loading
            LoadTwitterFeeds();

            //Repeat Function
            setInterval(LoadTwitterFeeds, (1000 * secondsInterval));
        }
    );

//Create xmlhttp object
function InitXMLHttp()
{
    if (window.XMLHttpRequest)
    {
        // code for IE7+, Firefox, Chrome, Opera, Safari
        xmlhttp = new XMLHttpRequest();
    }
    else
    {
        // code for IE5, IE6
        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
    }
}

//Load the TwitterFeeds
function LoadTwitterFeeds()
{
    InitXMLHttp();

    xmlhttp.onreadystatechange = function()
    {
        if (xmlhttp.readyState == 4 && xmlhttp.status == 200)
        {
            //Change Twitter Text
            //document.getElementById("TwitterFeeds").innerHTML = xmlhttp.responseText;
            jQuery(".TwitterFeed").html(xmlhttp.responseText);
        }
    }

    //Load Generic Handler. Paramater = ActiveMovie
    xmlhttp.open("GET", "/layouts/remotion/TwitterLiveUpdate.ashx", true);
    xmlhttp.send();
}
