function check_alerte()
{
	$.post( 	
		'sources/acts.php' , 
		{ 
			act: 'check_alerte'
		} , 
		function( data )
		{
			if( data.success )
			{
				$('#alert-holder').html( data.alerta );
				$('#alert-holder').slideDown( 1000 );
			}
		}, 
		'json'
	);
	setTimeout( 'check_alerte()', 60000 );
}
setTimeout( 'check_alerte()', 60000 );

function update_epg()
{
	$.post( 	
		'sources/acts.php' , 
		{ 
			act: 'update_epg'
		} , 
		function( data )
		{
			if( data.success )
			{
				// change epg
				if ( data.epg_list )
				{
					$('#epg_list').html( data.epg_list );
					player_ready();
				}
				// change current ems
				$('#program_curent').html( data.program_selectat );
				if ( data.emisiune_curenta )
				{
					$('#emisiune_curenta').html( data.emisiune_curenta_trunc );
					$('#emisiune_curenta').attr( 'title', data.emisiune_curenta );
				}
				else
				{
					$('#emisiune_curenta').html( '...' );
				}
			}
		}, 
		'json'
	);
	setTimeout( 'check_alerte()', 120000 );
}
setTimeout( 'update_epg()', 5000 );


function sterge_alerte( ems_id )
{
	$.post(
		'sources/acts.php' ,
		{
			act: 'sterge_alerte',
			epg_id: ems_id
		} ,
		function( data )
		{
			$('#alert-holder').slideUp( 1000 );
		} ,
		'json'
	);
}

function check_alerta_retea()
{
	$.post(
		'sources/acts.php',
		{
			act: 'check_alerta_retea'
		} ,
		function( data )
		{
			if ( data.success )
			{
				$('#alerta-retea').html( data.alerta );
				$('#alerta-retea').slideDown( 1000 );
			}
		},
		'json'
	);
	setTimeout( 'check_alerta_retea()', 120000 );
}

function sterge_alerta_retea()
{
	$.post(
		'sources/acts.php',
		{
			act: 'sterge_alerta_retea'
		} ,
		function( data )
		{
			$('#alerta-retea').slideUp( 1000 );
		} ,
		'json'
	);
}
check_alerta_retea();