/**
 * @file plates.js
 *
 * Routines handling reloading the plates - RSS channels.
 *
 * @author giorno
 */

/*
 * RSS channel synchronization.
 * 
 * It was switched once to synchronous Ajax mode as attempt to avoid  internal
 * server error (500) on klenot.cz hosting, but it was soon realized that
 * bottleneck cousing query timeout was MySQL connection.
 */
function platesSync ( id )
{
	new Ajax.PeriodicalUpdater( 'Id__ip__' + id, './ajaxdispatcher.php',
								{
									//asynchronous: false,
									frequency: ( refreshInterval * 60 ),
									decay: 1.1,
									method: 'post',
									parameters: 'frag=content&id=' + id,
									onLoading: function ( ) { document.getElementById( 'Id__ipl__' + id ).style.visibility = 'visible'; },
									onFailure: function ( ) { /*platesSync( id );*/ },
									onSuccess: function ( )
												{
													document.getElementById( 'Id__ipl__' + id ).style.visibility = 'hidden';
													if ( ftItems[id] ) ftUpdate( id );
												}
								}
							);
}

/*
 * Zobrazi platnu.
 */
function platesShow ( id )
{
	el = document.getElementById( 'Id__p__' + platesShown );
		el.style.visibility = 'hidden';
		el.style.display = 'none';
		
	platesShown = id;
	
	el = document.getElementById( 'Id__p__' + platesShown );
		el.style.visibility = 'visible';
		el.style.display = 'block';
}

/*
 * Frontend API pre prenutie kanalu.
 */
function platesClick( id, urlid )
{
	allowOff = true;
	tabsMark( id, urlid );
	platesShow( platesClicked );
}

/*
 * Zobrazi hit v hlavnom riadku.
 */
function platesFirstOfBlog ( )
{
	/*new Ajax.Updater('firstOfBlog', './ajaxdispatcher.php', {
						method: 'post',
						parameters: 'frag=blogLink'
					}
					);*/

	new Ajax.Request('./ajaxdispatcher.php', {
						method: 'post',
						parameters: 'frag=blogLink',
						onSuccess: function(transport) {
							if ( transport.responseText != '' )
								document.getElementById( 'firstOfBlog' ).innerHTML = transport.responseText;
						}
					});
}

/*
 * Aktualizator fastTrack.
 */
// function platesFastTrack ( id )
// {
// 	new Ajax.PeriodicalUpdater( 'fastTrack_' + id, './ajaxdispatcher.php',
// 								{
// 									frequency: ( refreshInterval * 60 ),
// 									decay: 1.1,
// 									method: 'post',
// 									parameters: 'frag=fasttrack&id=' + id//,
// // 									onLoading: function ( ) { document.getElementById( 'Id__ipl__' + id ).style.visibility = 'visible'; },
// // 									onSuccess: function ( ) { document.getElementById( 'Id__ipl__' + id ).style.visibility = 'hidden'; }
// 								}
// 							);
// }
