function txtReplace() { 
  FLIR.init();
  $('.home-news-container h3, .view-more-news a, #home-video-content h3').each( function() { FLIR.replace(this); } );
}

$(document).ready(function()
{
 $('.home').append('<div id="home-video-content"></div><div class="home-news-container"></div>');
	
 $.getJSON("/parse.php?u=http://www.kill9studios.com/json-video/",
   function(feed) {
	   
		var videos = feed.items,
			k = 0;
		
		for(i=0;i<videos.length;i++)
		{
			var description = videos[i].description,
					title = videos[i].title,
					player = videos[i].players[0].youtube,
					category = videos[i].category,
					hvideo = '';
	
			if(category == 'shutdown-tv' || category == 'shutdown-Extras')
			{
					
				hvideo += '<div id="home-player"><object width="390" height="238" data="http://www.youtube.com/v/' + player + '&ap=%2526fmt%3D18">';
				hvideo += '<param name="movie" value="http://www.youtube.com/v/' + player + '&ap=%2526fmt%3D18"></param>';
				hvideo += '<param name="allowFullScreen" value="true"></param>';
				hvideo += '<param name="wmode" value="transparent"></param>';
				hvideo += '<embed src="http://www.youtube.com/v/' + player + '&ap=%2526fmt%3D18" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="390" height="238"></embed>';
				hvideo += '</object></div>';
				hvideo += '<h3><a rel="bookmark" href="http://www.kill9studios.com/videos/episode-9-the-job-part-2-of-2">Episode 9: The Job (Part 2 of 2)</a></h3>';
				hvideo += '<div class="episode-description">' + description + '</div>';
				hvideo += '<div class="home-video-banner" style="margin-top:20px;">';
				hvideo += '<a href="" style="display:block;"><img src="/images/shutdown-banner.jpg" width="414" height="126" /></a>';
				hvideo += '</div>';
				
				break;
			}
		}
			$('#home-video-content').html(hvideo);
		txtReplace();
 });
 
 $.ajax({
  type: 'GET',
  url: '/parse.php?u=news',
  dataType: 'xml',
  success: function(xml)
  {
	var news = '';
	
    $(xml).find('rss').find('channel').find('item').each(function(i)
    {
	    if(i <= 0)
	    {
		  var title = $(this).find('title').text(),
			  link = $(this).find('link').text(),
			  entry = $(this).find('description').text();
	  
		  news += '  <h3 class="entry-title"><a href="' + link + '" title="' + title + '">' + title + '</a></h3>';
		  news += '  <div class="entry-content">' + entry + '</div>';
		  news += '  <p class="view-more-news"><a href="' + link + '" title="Read More">... Read More &gt;</a></p>';
	    }
	});
	$('.home-news-container').html(news);
	txtReplace();
  }
 }); 
});
