/*
    This file will automatically display the requested news feed for whichever site that calls it.
    CSS IDs: NewsFeed_Block, NewsFeed_Container, NewsFeed_Header, NewsFeed_List, NewsFeed_Date, NewsFeed_Source, NewsFeed_Text
 */

if (typeof(General) == 'undefined') { document.writeln('<script type="text/javascript" src="http://www.servingabroad.com/js/general.js"></script>'); }
if (typeof(ModalBox) == 'undefined') { document.writeln('<script type="text/javascript" src="http://www.servingabroad.com/js/modal.js"></script>'); }

var NewsFeed = new function()
{
    this.IncrementSize = 1;
    this.IncrementSpeed = 1;
    this.ItemDelay = 5000;
    this._ContainerID = 'NewsFeed_Container';
    this._DoScroll = true;
    this._ListID = 'NewsFeed_List';
    this._ScrollTimeoutID = null;

    this.ClearList = function()
    {
        var obj = document.getElementById(this._ListID);
        while(obj.firstChild) { obj.removeChild(obj.firstChild); }
    }; // ClearList()
    this.PopulateList = function()
    {
        if(document.getElementById(this._ContainerID) != null)
        {
           NewsFeed.ClearList();
           var objUl = document.getElementById(this._ListID);
           var objLi = null;
           var objDiv = null;

        objLi = document.createElement('li');
        objLi.title = 'Click To View: Group Trip Insurance Options';
        objDiv = document.createElement('a');
        objDiv.innerHTML = 'Group Trip Insurance Options';
        objDiv.href = 'http://www.tripinsuranceresource.com/group-trip-insurance.html';
        objDiv.onclick = function() { NewsFeed.Display(this); return false; }
        objLi.appendChild(objDiv);
        objDiv = document.createElement('div');
        objDiv.style.display = 'none';
        objDiv.innerHTML = '<h3>Group Trip Insurance Options</h3><p>Posted by <a href=\'http://www.tripinsuranceresource.com/group-trip-insurance.html\' onclick=\'window.open(this); ModalBox.Clear(); return false;\'>Trip Insurance</a> on September 02, 2010</p><p>When you tour, you would like to make sure that you are furnished with the right trip insurance to meet your wants and needs should an emergency appear. Even if you are touring with a group, you should make sure to have the proper trip travel insurance coverage, because you never know what may happen.</p><p><a href=\'http://www.tripinsuranceresource.com/group-trip-insurance.html\' onclick=\'window.open(this); ModalBox.Clear(); return false;\'>Read Entire Article</a></p>';
        objLi.appendChild(objDiv);
        objUl.appendChild(objLi);
        objLi = document.createElement('li');
        objLi.className = 'alt';
        objLi.title = 'Click To View: Travel Medical Insurance Guide';
        objDiv = document.createElement('a');
        objDiv.innerHTML = 'Travel Medical Insurance Guide';
        objDiv.href = 'http://www.familiadigital.com/travel-medical-insurance.html';
        objDiv.onclick = function() { NewsFeed.Display(this); return false; }
        objLi.appendChild(objDiv);
        objDiv = document.createElement('div');
        objDiv.style.display = 'none';
        objDiv.innerHTML = '<h3>Travel Medical Insurance Guide</h3><p>Posted by <a href=\'http://www.familiadigital.com/travel-medical-insurance.html\' onclick=\'window.open(this); ModalBox.Clear(); return false;\'>Family Digital</a> on September 02, 2010</p><p>Travel medical insurance is an essential thing for those who care of their health and like traveling. The most important thing about having travel medical insurance is that it covers all the medical expenses in case of some ailment or accident while staying abroad. It is reasonable to have family life insurance that provides every member of family with secure service in any case that is mentioned in policy. It is actually a very popular habit nowadays to make use of family life insurance in order to be confident in this field of life at least.</p><p><a href=\'http://www.familiadigital.com/travel-medical-insurance.html\' onclick=\'window.open(this); ModalBox.Clear(); return false;\'>Read Entire Article</a></p>';
        objLi.appendChild(objDiv);
        objUl.appendChild(objLi);
        objLi = document.createElement('li');
        objLi.title = 'Click To View: How To Obtain Medical Insurance When Traveling Overseas';
        objDiv = document.createElement('a');
        objDiv.innerHTML = 'How To Obtain Medical Insurance When Traveling Overseas';
        objDiv.href = 'http://travelcrowd.net/how-to-obtain-medical-insurance-when-traveling-overseas/';
        objDiv.onclick = function() { NewsFeed.Display(this); return false; }
        objLi.appendChild(objDiv);
        objDiv = document.createElement('div');
        objDiv.style.display = 'none';
        objDiv.innerHTML = '<h3>How To Obtain Medical Insurance When Traveling Overseas</h3><p>Posted by <a href=\'http://travelcrowd.net/how-to-obtain-medical-insurance-when-traveling-overseas/\' onclick=\'window.open(this); ModalBox.Clear(); return false;\'>Travel Crowd</a> on August 31, 2010</p><p>If you love to travel but are worried about getting sick overseas, there is now medical insurance available for traveling. Gone are the concerns that an illness away from home will incur major bills for medical treatments. Or that you may have to pay upfront for any kinds of medical bills or related expenses.</p><p><a href=\'http://travelcrowd.net/how-to-obtain-medical-insurance-when-traveling-overseas/\' onclick=\'window.open(this); ModalBox.Clear(); return false;\'>Read Entire Article</a></p>';
        objLi.appendChild(objDiv);
        objUl.appendChild(objLi);
        objLi = document.createElement('li');
        objLi.className = 'alt';
        objLi.title = 'Click To View: International Health Insurance for Travel to Paris, France';
        objDiv = document.createElement('a');
        objDiv.innerHTML = 'International Health Insurance for Travel to Paris, France';
        objDiv.href = 'http://traveltips.usatoday.com/international-health-insurance-travel-paris-france-16072.html';
        objDiv.onclick = function() { NewsFeed.Display(this); return false; }
        objLi.appendChild(objDiv);
        objDiv = document.createElement('div');
        objDiv.style.display = 'none';
        objDiv.innerHTML = '<h3>International Health Insurance for Travel to Paris, France</h3><p>Posted by <a href=\'http://traveltips.usatoday.com/international-health-insurance-travel-paris-france-16072.html\' onclick=\'window.open(this); ModalBox.Clear(); return false;\'>USA Today</a> on August 31, 2010</p><p>If you\'re traveling to Paris on business or pleasure, you want to make sure that you\'re covered for an accident or medical emergency. The health insurance policy you have at home does not necessarily cover you in an international destination, or if it does, it may not include services like emergency medical evacuation and repatriation.</p><p><a href=\'http://traveltips.usatoday.com/international-health-insurance-travel-paris-france-16072.html\' onclick=\'window.open(this); ModalBox.Clear(); return false;\'>Read Entire Article</a></p>';
        objLi.appendChild(objDiv);
        objUl.appendChild(objLi);
        objLi = document.createElement('li');
        objLi.title = 'Click To View: Why Multi-Travel Insurance Is The Best For Frequent Travelers';
        objDiv = document.createElement('a');
        objDiv.innerHTML = 'Why Multi-Travel Insurance Is The Best For Frequent Travelers';
        objDiv.href = 'http://successfulnetworkmarketingnow.com/networkmarketing/home-business/why-multi-travel-insurance-is-the-best-for-frequent-travelers/';
        objDiv.onclick = function() { NewsFeed.Display(this); return false; }
        objLi.appendChild(objDiv);
        objDiv = document.createElement('div');
        objDiv.style.display = 'none';
        objDiv.innerHTML = '<h3>Why Multi-Travel Insurance Is The Best For Frequent Travelers</h3><p>Posted by <a href=\'http://successfulnetworkmarketingnow.com/networkmarketing/home-business/why-multi-travel-insurance-is-the-best-for-frequent-travelers/\' onclick=\'window.open(this); ModalBox.Clear(); return false;\'>Successful Network</a> on August 30, 2010</p><p>For those who travel out of the country often on a regular basis, it would be wise to invest on a insurance plan that would cover, not only for one trip, but also for the series of travels – all travels rolled into one insurance policy, commonly known as the multiple trip travel insurance.</p><p><a href=\'http://successfulnetworkmarketingnow.com/networkmarketing/home-business/why-multi-travel-insurance-is-the-best-for-frequent-travelers/\' onclick=\'window.open(this); ModalBox.Clear(); return false;\'>Read Entire Article</a></p>';
        objLi.appendChild(objDiv);
        objUl.appendChild(objLi);
        objLi = document.createElement('li');
        objLi.className = 'alt';
        objLi.title = 'Click To View: Preparing For All Your Travel Needs';
        objDiv = document.createElement('a');
        objDiv.innerHTML = 'Preparing For All Your Travel Needs';
        objDiv.href = 'http://www.rentravel.info/preparing-for-all-your-travel-needs.html';
        objDiv.onclick = function() { NewsFeed.Display(this); return false; }
        objLi.appendChild(objDiv);
        objDiv = document.createElement('div');
        objDiv.style.display = 'none';
        objDiv.innerHTML = '<h3>Preparing For All Your Travel Needs</h3><p>Posted by <a href=\'http://www.rentravel.info/preparing-for-all-your-travel-needs.html\' onclick=\'window.open(this); ModalBox.Clear(); return false;\'>World Travel Information and Vacation</a> on August 27, 2010</p><p>When you’re planning your annual holiday abroad, it can be easy to forget the most important part of preparation – purchasing travel insurance. While this type of insurance can seem expensive and unnecessary to some, it is important to make sure you are covered in the event of any accidents during your holiday.</p><p><a href=\'http://www.rentravel.info/preparing-for-all-your-travel-needs.html\' onclick=\'window.open(this); ModalBox.Clear(); return false;\'>Read Entire Article</a></p>';
        objLi.appendChild(objDiv);
        objUl.appendChild(objLi);
        objLi = document.createElement('li');
        objLi.title = 'Click To View: Is it possible to lose weight on a cruise?';
        objDiv = document.createElement('a');
        objDiv.innerHTML = 'Is it possible to lose weight on a cruise?';
        objDiv.href = 'Stepping on the scale is the last thing you want to do when you get home from a cruise. It ain\'t gonna be pretty. All those late-night meals, desserts, fruity drinks -- they add up, and they add pound';
        objDiv.onclick = function() { NewsFeed.Display(this); return false; }
        objLi.appendChild(objDiv);
        objDiv = document.createElement('div');
        objDiv.style.display = 'none';
        objDiv.innerHTML = '<h3>Is it possible to lose weight on a cruise?</h3><p>Posted by <a href=\'Stepping on the scale is the last thing you want to do when you get home from a cruise. It ain\'t gonna be pretty. All those late-night meals, desserts, fruity drinks -- they add up, and they add pound\' onclick=\'window.open(this); ModalBox.Clear(); return false;\'>CNN</a> on August 27, 2010</p><p>Stepping on the scale is the last thing you want to do when you get home from a cruise. It ain\'t gonna be pretty. All those late-night meals, desserts, fruity drinks -- they add up, and they add pounds.</p><p><a href=\'Stepping on the scale is the last thing you want to do when you get home from a cruise. It ain\'t gonna be pretty. All those late-night meals, desserts, fruity drinks -- they add up, and they add pound\' onclick=\'window.open(this); ModalBox.Clear(); return false;\'>Read Entire Article</a></p>';
        objLi.appendChild(objDiv);
        objUl.appendChild(objLi);
        objLi = document.createElement('li');
        objLi.className = 'alt';
        objLi.title = 'Click To View: Top Ten International Travel Tips When Traveling';
        objDiv = document.createElement('a');
        objDiv.innerHTML = 'Top Ten International Travel Tips When Traveling';
        objDiv.href = 'http://genevahospitality.typepad.com/blog/2010/08/top-ten-international-travel-tips-when-traveling-to-murcia-spain.html';
        objDiv.onclick = function() { NewsFeed.Display(this); return false; }
        objLi.appendChild(objDiv);
        objDiv = document.createElement('div');
        objDiv.style.display = 'none';
        objDiv.innerHTML = '<h3>Top Ten International Travel Tips When Traveling</h3><p>Posted by <a href=\'http://genevahospitality.typepad.com/blog/2010/08/top-ten-international-travel-tips-when-traveling-to-murcia-spain.html\' onclick=\'window.open(this); ModalBox.Clear(); return false;\'>Geneva Hospitality</a> on August 25, 2010</p><p>1. Always Remember Safety First<br />2. Global Travel Service is Essential<br />3. Luggage and International Travel<br />4. International Travel Health Insurance<br />5. Gain Access to Airport Lounges...</p><p><a href=\'http://genevahospitality.typepad.com/blog/2010/08/top-ten-international-travel-tips-when-traveling-to-murcia-spain.html\' onclick=\'window.open(this); ModalBox.Clear(); return false;\'>Read Entire Article</a></p>';
        objLi.appendChild(objDiv);
        objUl.appendChild(objLi);
        objLi = document.createElement('li');
        objLi.title = 'Click To View: Travel Insurance Policies That Are Commonly Needed';
        objDiv = document.createElement('a');
        objDiv.innerHTML = 'Travel Insurance Policies That Are Commonly Needed';
        objDiv.href = 'http://www.laneahworld.com/2010/08/23/travel-insurance-policies-that-are-commonly-needed/';
        objDiv.onclick = function() { NewsFeed.Display(this); return false; }
        objLi.appendChild(objDiv);
        objDiv = document.createElement('div');
        objDiv.style.display = 'none';
        objDiv.innerHTML = '<h3>Travel Insurance Policies That Are Commonly Needed</h3><p>Posted by <a href=\'http://www.laneahworld.com/2010/08/23/travel-insurance-policies-that-are-commonly-needed/\' onclick=\'window.open(this); ModalBox.Clear(); return false;\'>World Travel</a> on August 23, 2010</p><p>Travel insurance and trip cancellation insurance are often used by businessmen to cover for the costs and the losses they incur if the travel could not take place as per schedule.</p><p><a href=\'http://www.laneahworld.com/2010/08/23/travel-insurance-policies-that-are-commonly-needed/\' onclick=\'window.open(this); ModalBox.Clear(); return false;\'>Read Entire Article</a></p>';
        objLi.appendChild(objDiv);
        objUl.appendChild(objLi);
        objLi = document.createElement('li');
        objLi.className = 'alt';
        objLi.title = 'Click To View: International Travel Medical Insurance Tips';
        objDiv = document.createElement('a');
        objDiv.innerHTML = 'International Travel Medical Insurance Tips';
        objDiv.href = 'http://travel.businessvn.net/2010/08/20/international-travel-medical-insurance-tips-to-help-you-find-the-cheapest-now/';
        objDiv.onclick = function() { NewsFeed.Display(this); return false; }
        objLi.appendChild(objDiv);
        objDiv = document.createElement('div');
        objDiv.style.display = 'none';
        objDiv.innerHTML = '<h3>International Travel Medical Insurance Tips</h3><p>Posted by <a href=\'http://travel.businessvn.net/2010/08/20/international-travel-medical-insurance-tips-to-help-you-find-the-cheapest-now/\' onclick=\'window.open(this); ModalBox.Clear(); return false;\'>Business Travel Tips</a> on August 23, 2010</p><p>The domestic travel insurance plans are not designed to function very well with hospitals and doctors overseas, which can add to your frustration if you have problems while you’re traveling. The most serious problem the international traveler faces when he or she is on the move is the possibility of having a serious medical problem or uncovered travel insurance medical condition in a foreign country.</p><p><a href=\'http://travel.businessvn.net/2010/08/20/international-travel-medical-insurance-tips-to-help-you-find-the-cheapest-now/\' onclick=\'window.open(this); ModalBox.Clear(); return false;\'>Read Entire Article</a></p>';
        objLi.appendChild(objDiv);
        objUl.appendChild(objLi);

           this.CheckScroll();
        }
        else { setTimeout('NewsFeed.PopulateList()',100); }
    }; // PopulateList()
    this.VerifyContainer = function()
    {
        if(document.getElementById(this._ContainerID) == null)
        {
            document.writeln('<div id="' + this._ContainerID + '">');
            document.writeln('        <ul id="' + this._ListID + '">');
            document.writeln('        </ul>');
            document.writeln('</div>');
        }
    }; // VerifyContainer()
    this.Render = function()
    {
        NewsFeed.VerifyContainer();
        setTimeout('NewsFeed.PopulateList()',100);
    }; // Render()

    this.Display = function(obj)
    {
        NewsFeed.StopScroll();

        ModalBox.ShowContent(obj.parentNode.getElementsByTagName('div')[0]);

        NewsFeed.DoRecursiveModalCheck();
    }; // Display(obj)
    this.DoRecursiveModalCheck = function()
    {
        if(ModalBox.IsVisible()) { setTimeout('NewsFeed.DoRecursiveModalCheck()', 100); }
        else { NewsFeed.StartScroll(); }
    }; // DoRecursiveModalCheck()

    this.CheckScroll = function()
    {
        var db = document.getElementById(this._ListID).parentNode;
        var ul = document.getElementById(this._ListID);

        if(ul.offsetHeight > db.offsetHeight) { NewsFeed.SetupScroll(); }
    }; // CheckScroll()
    this.SetupScroll = function()
    {
        var obj = document.getElementById(this._ContainerID);
        obj.onmouseover = function() { NewsFeed.StopScroll(); }
        obj.onmouseout = function() { if(!ModalBox.IsVisible()) { NewsFeed.StartScroll(); } }

        this._ScrollTimeoutID = setTimeout('NewsFeed.DoRecursiveScroll()', NewsFeed.ItemDelay);
    }; // SetupScroll()
    this.StartScroll = function()
    {
        NewsFeed._DoScroll = true;
    }; // StartScroll()
    this.StopScroll = function()
    {
        NewsFeed._DoScroll = false;
    }; // StopScroll()
    this.DoRecursiveScroll = function()
    {
        clearTimeout(NewsFeed._ScrollTimeoutID);

        if(NewsFeed._DoScroll)
        {
            var objUl = document.getElementById(this._ListID);
            var objLi = objUl.firstChild;
            var pt = (typeof(objUl.style.marginTop) == 'undefined') ? Number(0) : Number(objUl.style.marginTop.replace('px','').replace('-',''));
            pt += Number(NewsFeed.IncrementSize);
            if(pt == objLi.offsetHeight)
            {
                objUl.style.marginTop = '0px';
                objUl.removeChild(objUl.firstChild);
                if ((objUl.getElementsByTagName('li').length % 2) == 0) { objLi.className = (objLi.className == '') ? 'alt' : ''; }
                objUl.appendChild(objLi);
                NewsFeed._ScrollTimeoutID = setTimeout('NewsFeed.DoRecursiveScroll()', NewsFeed.ItemDelay);
                return;
            }
            else { objUl.style.marginTop = '-' + pt + 'px'; }
        }

        NewsFeed._ScrollTimeoutID = setTimeout('NewsFeed.DoRecursiveScroll()', NewsFeed.IncrementSpeed);
    }; // DoRecursiveScroll()
}; // NewsFeed

NewsFeed.Render();
