var m_gotnews = "";			// เอาไว้เก็บค่า response ล่าสุด
var m_gotblog = "";			// เอาไว้เก็บค่า response ล่าสุด
var m_gotpodcast = "";			// เอาไว้เก็บค่า response ล่าสุด
var m_gottorrent = "";			// เอาไว้เก็บค่า response ล่าสุด
var m_gotlasttopic = "";			// เอาไว้เก็บค่า response ล่าสุด

function news_lastest_fade( icontent, itag , iurl)
{
	var contentnews = dojo.byId(itag);

	var igotlasttopic = "";		// เอาไว้เก็บค่า response ชั่วคราว เพื่อเปรียบเทียบเท่านั้น
	if ( icontent == "news" ) igotlasttopic = m_gotnews;
	else if ( icontent == "blog" ) igotlasttopic = m_gotblog;
	else if ( icontent == "podcast" ) igotlasttopic = m_gotpodcast;
	else if ( icontent == "torrent" ) igotlasttopic = m_gottorrent;

	dojo.xhrGet(
	{
		url: iurl,
		handleAs: "text",				// text (default), json, json-comment-optional, json-comment-filtered, javascript, xml
		preventCache: true,
		load: function(data,args)
		{
			if ( igotlasttopic != data )
			{
				dojo.fadeOut(				// fade out the node we're modifying
				{
					node: contentnews,
					onEnd: function()
					{
						contentnews.innerHTML = data;					  // set the data, fade it back in
						dojo.fadeIn({node: contentnews}).play();    
					}
				}).play();

				if ( icontent == "news" ) m_gotnews = data;
				else if ( icontent == "blog" ) m_gotblog = data;
				else if ( icontent == "podcast" ) m_gotpodcast = data;
				else if ( icontent == "torrent" ) m_gottorrent = data;
			}
		}
	});
};

//dojo.addOnLoad(news_alert);

function timer_news_lastest_fade( iinterval, icontent, itag, iurl)
{
	dojo.addOnLoad(function(){
//		window.setInterval(news_lastest_fade, iinterval, icontent, itag, iurl );	// Not work on IE ( but work on Firefox & Chrome )
//		window.setInterval("news_lastest_fade('news', 'news_lastest', '/javascripts/newsinspire/news_lastest.aspx?content=news&lang=th'), iinterval );	// Work on IE & Firefox & Chrome
		window.setInterval("news_lastest_fade('" + icontent + "','" + itag + "','" + iurl + "')", iinterval );	// Work on IE & Firefox & Chrome
	});
};

