function init_events(){
	embed_live = document.getElementsByName("addliveembed");
	stream_live = document.getElementsByName("addlivestreamer");
	var number_form = parseInt($j('#id_' + init_prefix + '-TOTAL_FORMS').val());
	for (nb_form=0; nb_form<number_form;nb_form++){
		// for each form we want the list of the radio button of the type (embed or stream)
		var live_embed=document.getElementsByName(""+init_prefix+"-"+nb_form+"-type");
		// we look for the one that is checked
		for(var k=0;k<live_embed.length;k++){
	         if(live_embed[k].checked){
	        	 // we display the right block
	        	 if(live_embed[k].value == "1"){
		        	embed_live[nb_form].style.display = 'block';
		        	stream_live[nb_form].style.display = 'none';
	     		}
	     		else {
		        	embed_live[nb_form].style.display = 'none';
		        	stream_live[nb_form].style.display = 'block';
	     		}
	         }
		 }		
	}		
	if(number_form<2){
		$j(".delete-row").hide();
	}
	$j(".add-row").click(function() {
		var number_form = parseInt($j('#id_' + init_prefix + '-TOTAL_FORMS').val())-1;
		var live_embed=document.getElementsByName(""+init_prefix+"-"+number_form+"-type");
		live_embed[0].checked = false
		live_embed[1].checked = true
		$j(".delete-row").show()
		toggle_type()	
	});

}



function toggle_type() {
	// we check the number of forms in the formset (number of lives that the user wants to add)
	var formCount = parseInt($j('#id_' + init_prefix + '-TOTAL_FORMS').val());
	
	// this is the lists of the different blocks of the forms
	var stream_live = document.getElementsByName("addlivestreamer");
	var embed_live = document.getElementsByName("addliveembed");
	
	// loop in this forms
	for (nb_form=0; nb_form<formCount;nb_form++){
		// for each form we want the list of the radio button of the type (embed or stream)
		var live_embed=document.getElementsByName(""+init_prefix+"-"+nb_form+"-type");
		// we look for the one that is checked
		for(var k=0;k<live_embed.length;k++){
	         if(live_embed[k].checked){
	        	 // we display the right block
	        	 if(live_embed[k].value == "1"){
		        	embed_live[nb_form].style.display = 'block';
		        	stream_live[nb_form].style.display = 'none';
	     		}
	     		else {
		        	embed_live[nb_form].style.display = 'none';
		        	stream_live[nb_form].style.display = 'block';
	     		}
	         }
		 }		
	}		
}