

var extFile=$('#bc0').attr('rel');
var extTheme=$('#theme0').attr('name');

function externalize(timer){
	window.open("page/popup_flash/"+extTheme+"/"+extFile+"/"+timer,"Micro-Europa PLayer","menubar=no, status=no, scrollbars=yes, menubar=no, width=828,height=412");
	//alert("EEE");
}

	$(document).ready(function(){
		
		
		// ---------
		function loadBroadcast(num,coll){
			$('#flashPlayer').load("page/broadcast_flash/"+coll+"/"+num);
				
		}

			$('.bc').live('click',function(){
				$('a.bc').removeClass('active');
				$(this).addClass('active');
			
				extFile=$(this).attr("rel");
				extTheme=$(this).attr("name");
				externalize(0);
				
			})
		
			// JSCRIPT DU SLIDE DE LA COLONNE DES THEMATIQUES //
			var slidepos=0;
			var slidemax=$("#thglider").height()-140;
			slidemax=-slidemax;
			
			var slidemin=0;
			function slider(delta){
				slidepos+=delta;
				
			//	alert(slidepos);
			//	alert(delta);
				if(slidepos<1 && slidepos>slidemax ){
				$("#thglider").stop().animate(
		            {top: slidepos+"px"},
		            {queue: false,
		            duration: 200
		        })
				}
				if(slidepos>slidemin){
					slidepos=0;
				}
				if(slidepos<slidemax){
					slidepos=slidemax;
				}
			}
			
			$("#arrowUpList").click(function(){
				//alert("up");
				slider(70);
			})
			$("#arrowDownList").click(function(){
				//alert("down");
				slider(-70);
			})
			
			// JSCRIPT DU CLICK SUR UNE THEMATIQUE //
			function displayTheme(title,picture){
			   
				//alert(title+" "+description);
				$("#titleThematique h2").text(title);
				//$("#titleThematique p").text(description); 
				//$("#bgTheme").css('background-image','url(uploads/pics/'+picture+')');
				$("#bgTheme").html('<img src="uploads/pics/'+picture+'" />');  
				
				var picW = $("#bgTheme img").width();
				if (picW < 406) {
					$("#bgTheme img").height(230);   
				   	var picW  = $("#bgTheme img").width();
				   	if (picW >0) {
						//largeur cadre 406
						var maxW = 406;
						var margeW = (maxW - picW)/2; 
						
						$("#bgTheme img").css('position','relative');
						$("#bgTheme img").css('left',margeW);
					};
				}else{ 
					$("#bgTheme img").width(460);  
				   	var picH  = $("#bgTheme img").height();
				   	if (picH >0) {
						//hauteur cadre 230
						var maxH = 230;
						var margeH = (picH - maxH)/2; 
						
						$("#bgTheme img").css('position','relative');
						$("#bgTheme img").css('top',-margeH);
					}; 
				}
				 
			}
			function displayFiles(file){
				$("#playerList").load("page/brdcst/"+file);
			}
			
			$(".theme").click(function(){
				$('a.theme').removeClass('active');
				$(this).addClass('active');
				
				$ti=$(this).attr("title");
				$de=$(this).attr("rel");
				displayTheme($ti,$de);
				
				brd=$(this).attr("name");
				displayFiles(brd);
				
			})
			
			// SELECTION DU 1st THEME et du 1st REPORT
			$('#theme0').addClass('active');
			//$('#bc0').addClass('active');
			//loadBroadcast($('#bc0').attr("id"),$('#bc0').attr("name"));
			displayTheme($('#theme0').attr('title'),$('#theme0').attr('rel'));
			displayFiles($('#theme0').attr('name'));
			//alert($('#theme2').attr('name'));
			//
			
			//	
			//	$('#ext').html('<a href="'+uri+'" onClick="">ext</a>')
			
			var firstTheme=$('#theme0').attr('title');
			var firstFile=$('#bc0').attr('title');
			 extFile=$('#bc0').attr('rel');
			 extTheme=$('#theme0').attr('name');
			
			function openit(){
				
				
			}
			
			$('#popup').live('click',function(){
				openit();
			})
			
			//Hide (Collapse) the toggle containers on load
			$(".toggle_container").hide(); 

			//Slide up and down on click
			$("span[class*=trigger]").click(function(){
				$(this).next(".toggle_container").slideToggle();
				return false;		
			});
			
		
			
	})


