var lastGrp = '';

function AllLiveTV(){
	new Ajax.Updater( 'myprograms', 
		'mod-livetv/ajax/livetv.php', 
		{
			method:"post",
			evalScripts:true,
			parameters:'id=all' 
		} 
	);	
}

function ChangeGroupOfTV( group, to ){
	if ( lastGrp != '' )
		$(lastGrp).removeClassName('panelselected');
	lastGrp = 'grp_'+group ;	
	if( $(lastGrp) ) $(lastGrp).addClassName('panelselected');
	ShowIndicator();
	new Ajax.Updater( to,
						   'mod-livetv/ajax/livetv.php', { 
								onComplete:HideIndicator, 
								method: "post", 
								evalScripts:true,
								parameters:{id_group:group, action:'ListChannel'}
								}
						  );		
}

function ChannelInfo( id ){
	ShowIndicator();
	new Ajax.Updater( '_INFODIV',
						   'mod-livetv/ajax/livetv.php', { 
								onComplete:ShowInfo, 
								method: "post", 
								evalScripts:true,
								parameters:{id_content: id, action:'InfoChannel'}
								}
						  );		
}
function InfoGroup( id, $price ){
	if( $price == 0 ){
		ShowIndicator();
		new Ajax.Updater( '_INFODIV',
								'mod-livetv/ajax/livetv.php', { 
									onComplete:ShowInfo, 
									method: "post", 
									evalScripts:true,
									parameters:{id_content:id, action:'SubscribeChannel', typeabo:'abo', months:'0', from:'g', amount:'0'}
									}
							  );			
	}
	else
	{
		ShowIndicator();
		new Ajax.Updater( '_INFODIV',
								'mod-livetv/ajax/livetv.php', { 
									onComplete:ShowInfo, 
									method: "post", 
									evalScripts:true,
									parameters:{id_content:id, action:'InfoGroup'}
									}
							  );
	}
}
function subscribe(id_channel, atypeabo, afrom, amonths, atotal){
	document.form_subscribe.id_content.value = id_channel ;
	document.form_subscribe.typeabo.value = atypeabo ;
	document.form_subscribe.from.value = afrom ;
	document.form_subscribe.months.value = amonths ;
	document.form_subscribe.amount.value = atotal ;
	if ( atotal > 0 ){
		$('totalinvoice').update(atotal + '&nbsp;&euro;' );
		Effect.SlideUp('months',{duration:0.8}) ;
	}
	else OkSubscribe();
}

function OkSubscribe(){
	ShowIndicator();
	new Ajax.Updater( '_INFODIV',
						   'mod-livetv/ajax/livetv.php', { 
								onComplete:ShowInfo, 
								method: "post", 
								evalScripts:true,
								parameters:$('form_subscribe').serialize(true)
								}
						  );		
}
function AddChannelToSelection( id ){
	ShowIndicator();
	new Ajax.Updater( '_INFODIV',
						   'mod-livetv/ajax/livetv.php', { 
								onComplete:ShowInfo, 
								method: "post", 
								evalScripts:true,
								parameters:{id_content:id, action:'AddChannelToSelection'}
								}
						  );		
}

function CannotSubscribe(){
	ShowIndicator();
	new Ajax.Updater( '_INFODIV',
						   'mod-livetv/ajax/livetv.php', { 
								onComplete:ShowInfo, 
								method: "post", 
								evalScripts:true,
								parameters:{action:'CannotSubscribe'}
								}
						  );		
}

function DeleteLiveTV( id ){
	var vHtmlElt = 'LTV_'+id ;	
	ShowIndicator();
	$('buttonclosing').hide();
	new Ajax.Updater( '_INFODIV',
							'mod-system/ajax/deleteselection.php', { 
								onComplete:HideIndicator, 
								method: "post", 
								evalScripts:true,
								parameters:{playlist:'LIVETV', HtmlElt:vHtmlElt, todelete:id}
								}
						  );		
}

function MenuSel2( id, sh ){
	var j = 'tool'+id ;
	if ( sh ) {
	//	if ( $(j) ) $(j).show();
		$( id ).addClassName ('rolled') ;
	}
	else {
		//if ( $(j) ) $(j).hide();
		$( id ).removeClassName('rolled') ;
	}
}

