//
//    define as global and initialize rss_index and rss_sub
//

var rss_index	= 0;
var rss_sub		= 0;


function rss_timer_start()
	{
		get_rss();		//  start immediately
		
		timer_id	= setInterval( "get_rss()", 5000 );
		
	}    //    end of function


function rss_timer_stop( timer_id )
	{
		clearInterval( timer_id );
		
	}    //    end of function


function get_rss()
	{
		//alert( rss_index );
		
		var http_rq = new XMLHttpRequest();
		
		var prefix 	= parent.location.protocol;
		
		var url		= prefix + "//www.sunrise-blog.com/rss/rss.php?rss_index=" + rss_index + "&rss_sub=" + rss_sub ;
		
		http_rq.open( "GET", url, true );    //    'true' is for asynchronous
		
		//    Send the proper header information along with the request
		
		http_rq.setRequestHeader( "Connection", "close" );
		
		http_rq.send( "" );
		
		
		//    wait for readyState == 4
		
		http_rq.onreadystatechange	= function() { if( http_rq.readyState == 4 )
			{
				var r		= http_rq.responseText;
				
				//alert( "r = " + r );
				//alert( "colon index = " + r.indexOf( ":" ) );
				
				rss_index		= r.substring( 0, r.indexOf( ":" ) );
				
				rss_sub			= r.substring( r.indexOf( ":" ) + 1, r.indexOf( "_" ) );
				
				//alert( "rss_index = " + rss_index );
				
				//alert( "rss_sub = " + rss_sub );
				
				document.getElementById( "rss_display" ).innerHTML = r.substring( r.indexOf( "_" ) + 1 );
				
				//alert( rss_index );
				
				rss_index++;
				
				//rss_sub++;
				
				//alert( rss_index );

			}	};    //    end of http_rq.onreadystatechange
			
	}    //    end of function


function rss_banner()
	{
		var prefix 	= parent.location.protocol;
		
		var url	= prefix + "//www.sunrise-blog.com/rss/rss.html";
		
		//var url	= "https://www.sunrise-blog.com/rss/rss.html";
		
		rsswindow	= window.open ( url, "rss", "width=800, height=30" );
		
		rsswindow.moveTo( 0, 0 );
		
	}    //    end of function

