var attribute='base';
var color_target=0;
var links=new Array;
var current_page=-1;
var received=0;
var player_time=600;

$(function(){
	/*
	 * Init de flash
	 */
	is_flash=DetectFlashVer(8, 0, 0);
	if(is_flash) {
	swfobject.embedSWF("/swf/pastille.swf", "pastille_newsletter", "110", "110", "9.0.0", "expressInstall.swf",flashvars,params,attributes);
	swfobject.embedSWF("/swf/player.swf", "flash_player", "0", "0", "9.0.0", "expressInstall.swf");
	}
else if(first==1){
	if(confirm(flash_alert)) window.open('http://get.adobe.com/fr/flashplayer/');
};
	
	if(document.getElementById('logo'))
		Logo_init();
	
	$('#cache').css('display','none');

	
	init_select();
	init_navigator();
	init_page();
	do_refresh();
	//setTimeout('if(is_playing!=1) play_title();',3000);
	/*
	 * Initialisation des marquee
	 */
	/*
	$('a','#t_0').eq(0).attr('onmouseover',"if($('div.marquee', this).html()==null){$(this).html("+'"'+"<div class='marquee'>"+$('a','#t_0').eq(0).html()+"</div>"+'"'+");	$('div.marquee',this).marquee('marquee');}");
	alert("function(){if($('div.marquee', this).html()==null){$(this).html("+'"'+"<div class='marquee'>"+$('a','#t_0').eq(0).html()+"</div>"+'"'+");	$('div.marquee',this).marquee('marquee');}}");
	$('a','#t_0').eq(0).mouseout(function(){
			if($('div.marquee', this).html()!=null){
				$(this).html($('div.marquee',this).html());
			}
	});
	*/

});

function init_navigator() {
	if (navigator.userAgent.indexOf('Firefox/3',0)!=-1) attribute='firefox3';
	if (navigator.userAgent.indexOf('Iceweasel',0)!=-1) attribute='linux';
	if (navigator.userAgent.indexOf('Safari',0)!=-1) attribute='safari';
	if (navigator.userAgent.indexOf('MSIE 6',0)!=-1) attribute='explorer6';
	if (navigator.userAgent.indexOf('Opera',0)!=-1) attribute='opera';
	if (attribute!='explorer6'&& navigator.userAgent.indexOf('MSIE',0)!=-1) attribute='explorer';
	feuilles=document.getElementsByTagName('link');
	for (var i=0; i<feuilles.length;i++) {
	if((feuilles[i].getAttribute('rev')!=attribute)&&(feuilles[i].getAttribute('rev'))) feuilles[i].disabled='true'; 
	}
}

function go_top(){$('html,body').animate({ scrollTop: 200 }, 100);}

function init_page(){	
var pageTracker = _gat._getTracker("UA-15124063-1");
pageTracker._trackPageview();
	/*
	 * Initialisation des liens
	 */
$('input').focus(function(){
	$(this).css('background-color','#cdecff');
});
$('input').blur(function(){
	$(this).css('background-color','#FFFFFF');
});
$('textarea').focus(function(){
	$(this).css('background-color','#cdecff');
});
$('textarea').blur(function(){
	$(this).css('background-color','#FFFFFF');
});

// Barres de scroll
$('.scroll-pane').jScrollPane();

	$('html,body').animate({ scrollTop: 0 }, 100);
	$('a').each(function(){
		$(this).attr('onfocus','this.blur();');
		if(typeof($(this).attr('onclick'))=='undefined' || $(this).attr('onclick')==null){
			if(attribute!='explorer6') this.onclick=function(){return ajax(this.href);};

	//		if(attribute!='explorer6'){ $(this).click(function(){return ajax(this.href);});
	//		$(this).attr('onclick','return ajax(this.href);');}
	//else $(this).click(function(){return ajax(this.href);});
		}
	});
	$('a',$('.texte_titre','.slide')).attr('onclick', 'return false');
	$('a',$('.texte_titre','.slide')).click(function(){
		index=$('a').index(this);
		$('a',$('.texte_titre','.slide')).each(function(){
			if(index!=$('a').index(this)) {
$('p',$(this).parent().parent().parent()).slideUp(500);
$('.texte_titre',$(this).parent().parent().parent()).css('border-bottom','0px');
}
		});
		if($('p',$(this).parent().parent().parent()).css('display')=='none') {
			$('p',$(this).parent().parent().parent()).slideDown(500);
			$('.texte_titre',$(this).parent().parent().parent()).css('border-bottom','2px solid #61C4FF');
		}
		else {
			$('p',$(this).parent().parent().parent()).slideUp(500);
			$('.texte_titre',$(this).parent().parent().parent()).css('border-bottom','0px');
		}
		return false;
	});
	/*
	 * Partage réseaux sociaux
	 */
	//setTimeout('alert($(".facebook").html())',300);
	/*
	 * Transparence des png pour ie6
	 */
	if(attribute=='explorer6') fix_ie();
	return;
}
	
function flash_detection(){
	if( navigator.mimeTypes.length > 0 )
	{
		return navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin != null;
	}
	else if( window.ActiveXObject )
	{
		try
		{
			new ActiveXObject
( "ShockwaveFlash.ShockwaveFlash" );
			return true;
		}
		catch( oError )
		{
			return false;
		}
	}
	else
	{
		return false;
	}
}


function ajax(link){
	var doc_url=document.location.href;
	tmp=doc_url.split('#');
	if(doc_url.indexOf('#')==-1){tmp[1]='';tmp[0]=doc_url;}
	suffix=link.split(base);
	//alert(link);
	document.location=tmp[0]+'#'+suffix[1];
	url=link;
	current_page=link;
	tmp_url=url.split(base);
	if(url==base) $('#player').fadeOut(300);
	else if($('#player').css('display')=='none') $('#player').fadeIn(300);
	$('body').css('cursor','progress');
if(attribute=='explorer6') {document.location=link;return false;}
if(color_target!=0) manual_stop();
//alert($(link).html());
	$.ajax({
		//url:'ajax/'+url,
		url:url,
		cache:false,
		timeout:5000,
		error: function(){document.location=url;},
		success: function(html){
			$('body').css('cursor','default');
			$('.content').html($('.content',html).html());
			//alert($('.content',html).html());
			tmp=html.split('<title>');
			title=tmp[1].split('</title>');
			document.title=title[0];			
			init_page();
			$('li > a').each(function(){
				if((tmp_url[1]=='' && this.href!=base) || this.href.indexOf(tmp_url[1])==-1) $(this).removeClass('selected');
				else $(this).addClass('selected');
			});	
		}
	});
	return false;
}


function do_refresh(){
	setTimeout('do_refresh();',200);
	doc_url=document.location.href;
	if(doc_url.indexOf('#')==-1) detected='';
	else {
		tmp=doc_url.split('#');
		detected=tmp[1];
	}
	if(current_page==-1) {current_page=base;}
	suffix=current_page.split(base);
	if(suffix[1]!=detected) {ajax(base+detected);}
	return;
}


function ajax_post(form){
if(attribute=='explorer6') {form.submit();return false;}
if(color_target!=0) manual_stop();
	received=0;
	if(patienter=document.getElementById("form_patienter")){
	patienter.style.display='block';
	color_patienter(0, 1);
	}
	champs='';
	url=$(form).attr('action');
	$('textarea',form).each(function(){
		champs=champs+$(this).attr('name')+'='+$(this).val()+'&';
	});
	$('input',form).each(function(){
		champs=champs+$(this).attr('name')+'='+$(this).val()+'&';
	});
	if($('#player').css('display')=='none') $('#player').fadeIn(300);
	$('body').css('cursor','progress');
	$.ajax({
		type:'GET',
		//url:'ajax/'+url,
		url:url,
		data:champs,
		cache:false,
//		timeout:10000,
		error: function(){document.location=url;},
		success: function(html){
			received=1;
			$('.content').html($('.content',html).html());
			tmp=html.split('<title>');
			title=tmp[1].split('</title>');
			document.title=title[0];		
			init_page();
			$('body').css('cursor','default');
			//document.scrollTop=0;
		}
	});
	return false;
}

function popin_display(opacity, element){
	$('#popin_cache_cont').fadeIn(300);
	$('#'+element).fadeIn(300);
return false;
}

function popin_close(opacity, element){
	$('#popin_cache_cont').fadeOut(300);
	$('#'+element).fadeOut(300);
return false;
}

function Logo_init() {
	Logo=document.getElementById('logo').getElementsByTagName('img')[0];;
//	Logo.img=document.getElementById('logo').getElementsByTagName('img')[0];
	Logo.imageOut=new Image();
	Logo.imageOut.src=Logo.src;
	Logo.imageIn=new Image();
	Logo.imageIn.src="/design_new/logo_1.png";
	Logo.onmouseout=Logo_out;
	Logo.onmouseover=Logo_over;
}

function Logo_over() {this.src=this.imageIn.src;}
function Logo_out() {this.src=this.imageOut.src;}

var playerLoading=0;
var player_total;
var player_moving=0;
var player_moves=0;
var player_prev;
var player_next;
var is_playing=0;
var img_total;
var img_pos=0;
var video_total;
var video_pos=0;

function start_bkg(sens, pos){
	if(is_playing==0){
	$('.player_fleche').css('background-position', "0 0");
	$('.player_fleche_2').css('background-position', "0 0");
	return;
	}
	if(pos==38) sens=-1;
	if(pos==0) sens=1;
	pos=pos + sens;
	$('.player_fleche').css('background-position', "0 "+(pos*(-22)));
	$('.player_fleche_2').css('background-position', "0 "+(pos*(-29)));
	setTimeout("start_bkg("+sens+","+pos+");",30);
}

function ecouter(i, album, number) {
	if(!is_flash) {
	if(confirm(flash_alert))
		window.open('http://www.adobe.com/go/getflash');
	return false;
	}
	if(playerLoading==0) {
		$('a.pause').removeClass('pause_on');
		if(color_target!=i) {
			links[i]=document.getElementById('play_'+i);
			imgChange(i);
			color_player(100,-1,i);
			var url=document.getElementById('ecouter_'+i).href;
			url=url.replace(base,"");
			swfobject.getObjectById("flash_player").LoadMP3(base, url, album, number);
		}
		else {
			manual_stop();
		}
	}
	return false;
}

function manual_stop(){
	stopMP3();
	swfobject.getObjectById("flash_player").StopMP3();
}

function pause(i){
if($('#pause_'+i).hasClass('pause_on')){
$('a.pause').removeClass('pause_on');
return ecouter(i);
}
else {
if(i!=color_target) return false;
imgChange(0);
$('#pause_'+i).addClass('pause_on');
	swfobject.getObjectById("flash_player").PauseMP3();
}
return false;
}

function imgChange(i){
	color_target=i;
}

function loading(value){
playerLoading=value;
}

function trace(value){
alert(value);
}

function stopMP3() {
imgChange(0);
}

function color_player(offset, sens, i){
	if(received==1){
		patienter.style.display='none';
		return;
	}
	if(offset==100){
		if(i==color_target) sens=-1;
		else return;
	}
	if(offset==0||i!=color_target)sens=1;
	color=calculate_color(offset);
	try{links[i].style.backgroundColor='#'+color;}
	catch(e){}
	setTimeout("color_player("+(offset+sens)+","+sens+","+i+")",1);
}

function calculate_color(offset){
	red=Math.round(38+(0.69*offset));
	green=Math.round(67+(1.39*offset));
	blue=Math.round(80+(1.85*offset));
	color=red.toString(16)+green.toString(16)+blue.toString(16);
	return color;
}

function player_init(){
	player_total=parseInt($('#player_total').html());
	if(player_index==player_total-1)player_next=0;
	else player_next=player_index+1;
	if(player_index==0) player_prev=player_total-1;
	else player_prev=player_index-1;
	$('#p_'+player_prev).addClass('p_left left');
	$('#p_'+player_prev).removeClass('hidden');
	$('#p_'+player_index).addClass('p_center');
	$('#p_'+player_index).addClass('selected');
	$('#p_'+player_index).removeClass('hidden');
	$('#p_'+player_next).addClass('p_right');
	$('#p_'+player_next).removeClass('hidden');	
	
	//alert(player_prev+" "+player_index+" "+player_next+" "+player_total);
	$('.fond > div','#p').mouseover(function(){
		if(player_moving==0 && $(this).parent().parent().css('display')!='none' && !$(this).parent().parent().hasClass('selected'))$(this).css('opacity',1);
	});
	$('.fond > div','#p').mouseout(function(){
		if(player_moving==0 && $(this).parent().parent().css('display')!='none' && !$(this).parent().parent().hasClass('selected'))$(this).css('opacity',0.4);
	});
	$('.albums>a','#p').each(function(){
		if(!$(this).hasClass('p_center')) 
		$('.fond > div ',this).fadeTo(1000,0.4);
	});
	player_enlight();
	if(attribute!='safari') setTimeout("addReflections();",1000);
	else  setTimeout("addReflections();",3000);
}

function player_click(pos){
	if(pos==player_index) {return ajax(base+$('#p_'+player_index).attr('href'));}
	else if(pos==player_prev) player_prev_index();
	else if(pos==player_next) player_next_index();
	return false;
}

function player_left(elm_id,t){
	$(elm_id).animate({
		marginLeft:'0px'
	},t,'easeOutQuad');	
	$('img', elm_id).animate({
		width:'100px',
		height:'100px'
	},t,'easeInQuad');	
	$(elm_id+' > div').animate({
		width:'100px',
		height:'133px'
	},t,'easeInQuad');
	$('canvas',elm_id).animate({
		width:'100px',
		height:'33px'
	},t,'easeInQuad');
	$('.fond > div',elm_id).fadeTo(t,0.4,'easeInQuad');
	setTimeout("$('"+ elm_id +"').css('z-index','2')",(t*5)/12);
}

function player_center(elm,t){
	// Déplacement de la prec
	$(elm).css('z-index',1);
	$(elm).animate({
		marginLeft:'60px'
	},t, 'easeInQuad');	
	//$('.cont_cache', '#p_'+player_next).fadeTo(600, 0);
	$('.fond>div',elm).fadeTo(t, 1,'easeOutQuad');
	$('img', elm).animate({
		width:'120px',
		height:'120px'
	},t, 'easeOutQuad');
	$('.fond',elm).animate({
		width:'120px',
		height:'160px'
	},t, 'easeOutQuad');
	$('canvas', elm).animate({
		width:'120px',
		height:'40px'
	},t, 'easeOutQuad');

	setTimeout("$('"+elm+"').css('z-index','10')",(t*5)/12);
	setTimeout("$('.cache','"+elm+"').css('display','none')",(t*11)/12);
}

function player_right(elm,t){
	$(elm).animate({
		marginLeft:'150px'
	},t,'easeOutQuad');	
	$('img', elm).animate({
		width:'100px',
		height:'100px'
	},t,'easeInQuad');	
	$('canvas',elm).animate({
		width:'100px',
		height:'33px'
	},t,'easeInQuad');
	$(elm+' > div').animate({
		width:'100px',
		height:'133px'
	},t,'easeInQuad');
	$('.fond > div',elm).fadeTo(t,0.4,'easeInQuad');
	setTimeout("$('"+elm+"').css('z-index','2')",(t*5)/12);
	setTimeout("$('"+elm+"').css('z-index','2')",(t*5)/12);
}

function player_appear(elm,t, right){
	$('.fond > div',elm).fadeTo(t/6,0.4);		
	$(elm).removeClass('p_center');
	$(elm).css('z-index',0);
	$(elm).css('display','block');
	$(elm).css('position','absolute');
	if(right==1) $(elm).css('margin-left','150px');
	else $(elm).css('margin-left','0px');
	$('canvas',elm).css('width','100px');
	$('canvas',elm).css('height','33px');
	$('img',elm).css('width','100px');
	$('img',elm).css('height','33px');
	$('img', elm).animate({
		width:'100px',
		height:'100px'
	},1)
	addReflections()
	$(elm).css('width','100px');
	$(elm).css('height','100px');
	$('img',elm).css('width','100px');
	$('canvas',elm).css('width','100px');
	$('canvas',elm).css('height','33px');
}

function player_disappear(elm,t){
	$(elm).css('z-index',1);	
	$(elm).fadeOut(t);
}

function player_go(pos){
	player_next=(player_index+1==player_total ? 0 : player_index+1);
	player_prev=(player_index==0 ? player_total-1 : player_index-1);
	pos_next=(pos+1==player_total ? 0 : pos+1);
	pos_prev=(pos==0 ? player_total-1 : pos-1);
	if(pos==player_index) return ajax(base+$('a.nom','#t_'+pos).attr('href'));
	else if(pos<player_index){
		time=player_time;
		player_disappear('#p_'+(player_index+1), time);
		player_right('#p_'+player_index, time);
		player_center('#p_'+(player_prev), time);		
		
		if(pos==player_index-1){
			setTimeout("player_appear('#p_"+(pos_prev)+"','"+time+"',0);",0);
		} else {
			setTimeout("player_disappear('#p_"+player_index+"','"+time+"');",time);
			setTimeout("player_right('#p_"+(player_prev)+"','"+time+"');",time);	
			if(pos==player_index-2){
				setTimeout("player_appear('#p_"+(pos)+"','"+time+"',0);",0);
				setTimeout("player_center('#p_"+(pos)+"','"+time+"');",time);
				setTimeout("player_appear('#p_"+(pos_prev)+"','"+time+"',0);",time);
			}
			else {
				setTimeout("player_appear('#p_"+(pos_next)+"','"+time+"',0);",0);
				setTimeout("player_appear('#p_"+(pos)+"','"+time+"',0);",time);
				setTimeout("player_disappear('#p_"+(player_prev)+"','"+time+"');",time*2);	
				setTimeout("player_center('#p_"+(pos_next)+"','"+time+"');",time);
				setTimeout("player_right('#p_"+(pos_next)+"','"+time+"');",time+1);
				setTimeout("player_center('#p_"+(pos)+"','"+time+"');",time*2*0.9);
				setTimeout("player_appear('#p_"+(pos_prev)+"','"+time+"',0);",time*2);
			}
		}
		
		player_index=pos;
		player_prev=pos_prev;
		player_next=pos_next;
		player_enlight();
	}
	else if(pos>player_index){
		time=player_time;
		player_disappear('#p_'+(player_prev), time);
		player_left('#p_'+player_index, time);
		player_center('#p_'+(player_next), time);
		if(pos==player_index+1){
			setTimeout("player_appear('#p_"+(pos_next)+"','"+time+"',1);",0);
		} else {
			setTimeout("player_disappear('#p_"+player_index+"','"+time+"');",time);
			setTimeout("player_left('#p_"+(player_next)+"','"+time+"');",time);
			if(pos==player_index+2){
				setTimeout("player_appear('#p_"+(pos)+"','"+time+"',1);",0);
				setTimeout("player_center('#p_"+(pos)+"','"+time+"');",time);
				setTimeout("player_appear('#p_"+(pos_next)+"','"+time+"',1);",time);
			}
			else {
				setTimeout("player_disappear('#p_"+(player_next)+"','"+time+"');",time*2);		
				setTimeout("player_appear('#p_"+(pos_prev)+"','"+time+"',1);",0);
				setTimeout("player_center('#p_"+(pos_prev)+"','"+time+"');",time);
				setTimeout("player_left('#p_"+(pos_prev)+"','"+time+"');",time+1);
				setTimeout("player_appear('#p_"+(pos)+"','"+time+"',1);",time);
				setTimeout("player_center('#p_"+(pos)+"','"+time+"');",time*2*0.9);
				setTimeout("player_appear('#p_"+(pos_next)+"','"+time+"',1);",time*2);
			}
		}
		
		player_index=pos;
		player_prev=pos_prev;
		player_next=pos_next;
		player_enlight();
	}
	return false;
}

function player_next_index(){
	if(player_moving==0){

		if(player_next==player_total-1) player_new=0
		else player_new=player_next+1;
	
		player_disappear('#p_'+player_prev, player_time);
		player_left('#p_'+player_index,player_time);
		player_center('#p_'+player_next,player_time);
		player_appear('#p_'+player_new,player_time,1)

		// Changement des indexes
		player_prev=player_index;
		player_index=player_next;
		player_next=player_new;
player_enlight();
	}
	else player_moves++;
	return false;
}

function player_prev_index(){
	if(player_moving==0){
		if(player_prev==0) player_new=player_total-1
		else player_new=player_prev-1;

		player_disappear('#p_'+player_next, player_time);
		player_right('#p_'+player_index,player_time);
		player_center('#p_'+player_prev,player_time);
		player_appear('#p_'+player_new,player_time, 0);
		
		
		// Changement des indexes
		player_next=player_index;
		player_index=player_prev;
		player_prev=player_new;
		
player_enlight();
	}
	else player_moves++;
	return false;
	
	return false;
}



function player_enlight(){
	$('.liste > div','#p').each(function(){
		if(this.id=='t_'+player_index) {$('a.nom',this).addClass('blue');}
		else $('a.nom',this).removeClass('blue');;
	});
	$('#p_'+player_index).addClass('selected');
	$('#p_'+(player_index+1)).removeClass('selected');
	$('#p_'+(player_index-1)).removeClass('selected');
	$('#pright_title').html($('#pright_title_'+player_index).html());
	$('#pright_url').attr('href',$('#pright_url_'+player_index).html());
	elmt=$('.link','#p');
	$('a.gris',elmt).attr('href',$('#pright_url_'+player_index).html());
	setTimeout('if(is_playing==1) new_title();',200);
}

function play_title(){
if(is_playing==0) {
is_playing=1;
start_bkg(1,0);
stopMP3()
new_title();
}
else pause_title();

}

function new_title(){
	$('#player_pause').removeClass('player_pause_on');
	var url=$('#pright_titre_'+player_index).html();
	url=url.replace(base,"");
	album='';
	swfobject.getObjectById("flash_player").LoadPlayer(base, url, album);
}

function pause_title(){
	if($('#player_pause').hasClass('player_pause_on')){
		play_title();	
	}
	else {
		if(is_playing==0) return;
		is_playing=0;
		$('#player_pause').addClass('player_pause_on');
		swfobject.getObjectById("flash_player").StopPlayer();
	}
}

function player_pause(){
		is_playing=0;
		$('#player_pause').addClass('player_pause_on');
}

function change_title(){
	is_playing=1;
	setTimeout('player_next_index();',1000);
}


/*
 * Diaporama d'images
 */

	function diaporama_init(){
		/*
		 * Initialisation des diaporama
		 */
		img_pos=0;
		if(document.getElementById('img_diaporama')) {
			$('#img_0','#img_diaporama').fadeIn(500);
			img_resize();
		}
		if(document.getElementById('video_diaporama')) {
			play_video();
		}
		 $('a').focus(function(){this.blur();});
	}

	function img_inc(){
	img_total=parseInt($('#img_total').html());
		$('#img_'+img_pos).fadeOut(500);
		if(img_pos==img_total-1)img_pos=0;
		else img_pos++;
		$('#img_'+img_pos).fadeIn(500);
		img_resize();
		$('#img_number').html(img_pos+1);
	}

	function img_dec(){
	img_total=parseInt($('#img_total').html());
		$('#img_'+img_pos).fadeOut(500);
		if(img_pos==0)img_pos=img_total-1;
		else img_pos--;
		$('#img_'+img_pos).fadeIn(500);
		img_resize();
		$('#img_number').html(img_pos+1);
	}

	function img_go(index){
		document.getElementById('img_'+img_pos).style.display='none';
		img_pos=index;
		$('#img_'+img_pos).fadeIn(500);
		img_resize();
		$('#img_number').html(img_pos+1);
	}
	
	function img_resize(){
		img=$('#img_'+img_pos,'#img_diaporama');
		width=($('img',img).width()*215)/$('img',img).height()
		$(img).css('margin-left',($('.img_cont','#img_diaporama').width()-width)/2);
		$('#img_titre').html($(img).attr('rel'));
	}

	function video_inc(){
		video_total=parseInt($('#video_total').html());
			$('#video_'+video_pos).css('display','none');
			if(video_pos==video_total-1)video_pos=0;
			else video_pos++;
			play_video();
			$('#video_number').html(video_pos+1);
		}

		function video_dec(){
			video_total=parseInt($('#video_total').html());
			$('#video_'+video_pos).css('display','none');
			if(video_pos==0)video_pos=video_total-1;
			else video_pos--;
			play_video();
			$('#video_number').html(video_pos+1);
		}

		function img_go(index){
			$('#video_'+video_pos).css('display','none');
			video_pos=index;
			$('#video_'+video_pos).fadeIn(500);
			play_video();
			$('#video_number').html(video_pos+1);
		}
		
	
function play_video(){
	if(!document.getElementById('video_'+video_pos)) return;
	video=$('#video_'+video_pos);
	$('#video_titre').html($(video).attr('titre'));
	$('#video_'+video_pos).css('display','inline');
	flowplayer('video_'+video_pos, {src:"swf/flowplayer-3.1.5.swf",wmode:'opaque'}, {
		play: null,
		plugins: {
			controls: {
		      backgroundColor: '#373535',
		      backgroundGradient: 'none',
		      durationColor: '#88a423',
		      buttonOverColor: '#53Cdf3',
		      buttonColor: '#209DE8',
		      bufferGradient: 'none',
		      sliderColor: '#444444',
		      tooltipColor: '#5F747C',
		      progressColor: '#209DE8',
		      bufferColor: '#AAAAAA',
		      progressGradient: 'medium',
		      timeBgColor: '#555555',
		      volumeSliderColor: '#000000',
		      volumeSliderGradient: 'none',
		      borderRadius: '0px',
		      sliderGradient: 'none',
		      tooltipTextColor: '#ffffff',
		      timeColor: '#b8bca9',
		      height: 20,
		      opacity: 1.0,
		      volume:false,
		      time:false,
		      fullscreen:false,
		      mute:false
		   }
		},
		clip : {          
	        autoPlay: false, 
	        autoBuffering: true,
	        url: $('#video_'+video_pos).attr('rel')
		}
	});return;
}

var xhr='false';
var tempdiv=document.createElement('div');
var received;

popin_bk=new Object;
popin_achat=new Object;
popin_newsletter=new Object;
popin=document.getElementById('popin');
popin_achat=document.getElementById('popin_achat');
popin_newsletter=document.getElementById('popin_newsletter');
patienter=new Object();


function valid_newsletter(element){
	if(!valid_mail(element.email.value)){
		enlight('forms_error');
		return false;
	}
	else {
		send_mail('newsletter', element.email.value);
		received=0;
		patienter=document.getElementById("forms_patienter");
		patienter.style.display='block';
		color_patienter(0, 1);
		return false;
	}
}

/*
function valid_ami(element){
	if(!valid_mail(element.email.value)){
		enlight('forms_error');
		return false;
	}
	else {
		send_mail('ami', element.email.value);
		received=0;
		patienter=document.getElementById("forms_patienter");
		patienter.style.display='inline';
		color_patienter(0,1);
		return false;
	}
}
*/


function valid_mail(email){
		var invalid=' /:,;';
		if (email=='') {return false;}
		for (var k=0; k<invalid.length;k++){
			var badChar=invalid.charAt(k);	
			if (email.indexOf(badChar)>-1){return false;}
		}
		var atPos=email.indexOf('@',1);
		if (atPos==-1) { return false;}
		if (email.indexOf('@', atPos+1)!=-1) {return false;}
		var periodPos=email.indexOf('.',atPos);
		if (periodPos==-1) {return false;}
		if (periodPos+3>email.length) {return false;}
		return true;
}


/*
function enlight(object){
	object=document.getElementById(object)
	object.style.display='inline';
	setTimeout("delight('"+object.id+"');",1500);
}

function delight(object) {
	object=document.getElementById(object)
	object.style.display='none';

}
*/

function color_patienter(offset, sens){
	if(received==1){
		patienter.style.display='none';
		return;
	}
	if(offset==100)sens=-1;
	if(offset==0)sens=1;
	color=calculate_color(offset);
	try{patienter.style.color='#'+color;}
	catch(e){};
	setTimeout("color_patienter("+(offset+sens)+","+sens+")",10);
}

function calculate_color(offset){
	red=Math.round(38+(0.69*offset));
	green=Math.round(67+(1.39*offset));
	blue=Math.round(80+(1.85*offset));
	color=red.toString(16)+green.toString(16)+blue.toString(16);
	return color;
}

function send_mail(mode, email){
	params="mode="+mode+"&email="+email;
	if(window.XMLHttpRequest){
		xhr= new XMLHttpRequest();
	}
	else {
		if (window.ActiveXObject) {
			try {
				xhr= new ActiveXObject("Microsoft.XMLHttp");
			}
			catch(e) {}
		}
	}
	if (xhr) {
		var url=base+'send_mail.php?'+params;
		xhr.onreadystatechange=check_mail;
		xhr.open("GET",url,true);
		xhr.send(null);
	}
}


function check_mail() {
	if(xhr.readyState==4) {
		if(xhr.status==200){
			received=1;
			if (xhr.responseText.indexOf('erreur')==-1){
				tempdiv.innerHTML=xhr.responseText;

				text=xhr.responseText;
				tmp=text.split('<title>');
				tmp1=tmp[1].split('</message>');
				title=tmp1[0].split('</title>')[0];
				message=tmp1[0].split('<message>')[1];

				tempdiv.innerHTML='';

				document.getElementById('popin_title').innerHTML=title;
				document.getElementById('popin_message').innerHTML=message;
				popin_display(0, 'popin_message');
			}
		}
	}
}


function check_cgv(album, track, titre_popin){
	document.getElementById('popin_album_url').value=album;
	document.getElementById('popin_track').value=track;
	document.getElementById('titre_popin_right').innerHTML=titre_popin;
	if(track=='cd') {$('#titre_popin_left').css('display','none');$('#titre_popin_left_1').css('display','inline');}
	else {$('#titre_popin_left_1').css('display','none');$('#titre_popin_left').css('display','inline');}
	if (accept_cgv==0) {popin_display(0, 'popin_achat');}
	else document.getElementById('form_confirmation').submit();
	return false;
}

function checkbox_cgv(element){
	if (element.cgv.checked==true) {
		element.onsubmit=function(){popin_close(1, "popin_achat"); return true;};
		$('.poursuivre',element).css('color',"#1C3946");
	}
	else {
		element.onsubmit=function(){return false;};
		$('.poursuivre',element).css('color',"#8CA9B6");
	}
}

function check_ticket(form){
	if(element.cgv.checked!=true) return false;
	code=this.code.value;
	$.ajax({
		//url:'ajax/'+url,
		url:base+'cmj/check_code_.php?code='+code,
		cache:false,
		timeout:5000,
		error: function(){check_ticket(form)},
		success: function(html){
			checked=html;
			color_patienter(0, 1);
		}
	});
	if(checked=='1') {popin_close('popin_cmj'); return true;}
	else if(checked=='0') enlight('forms_error_ticket');
	else if(checked=='-1') enlight('forms_error_captcha');
	else if (checked!=form.prix.value) enlight('forms_error_prix');
	return false;
}

function check_cmj(id, prix, nom){
	document.getElementById('titre_cmj_right').innerHTML=nom;
	$('#popin_cmj_id').val(id);
	$('#popin_cmj_prix').val(prix);
	$('#cmj_lien_prix').val(prix);
	popin_display(0, 'popin_cmj');
	return false;
}


function enlight(object){
	object=document.getElementById(object)
	object.style.display='inline';
	setTimeout("delight('"+object.id+"');",1500);
}

function delight(object) {
	object=document.getElementById(object)
	object.style.display='none';

}


function fix_ie(){
var images;
images=document.getElementsByTagName('img');
   for(i=0; i<images.length; i++)
   {
      var img = images[i];
      var imgName = img.src.toUpperCase();
      if (imgName.substring(imgName.length-3, imgName.length) == "PNG")
      {
         var imgID = (img.id) ? "id='" + img.id + "' " : "";
         var imgClass = (img.className) ? "class='" + img.className + "' " : "";
         var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' ";
         var imgStyle = img.style.cssText ;
	if(parseInt($(img).css('width'))>0)width=parseInt($(img).css('width'));
else width=img.width;
	if(parseInt($(img).css('height'))>0)height=parseInt($(img).css('height'));
else height=img.height;
         if (img.align == "left") imgStyle = "float:left;" + imgStyle;
         if (img.align == "right") imgStyle = "float:right;" + imgStyle;
         if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle;
         var strNewHTML = "<span " + imgID + imgClass + imgTitle
         + " style=\"display:block; " + "width:" + width + "px; height:" + height + "px;" + imgStyle + ";\""
	+ "><span class='progid' style=\"display:inline-block; " + "width:" + width + "px; height:" + height + "px;" + imgStyle + ";"
         + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
         + "(src=\'" + img.src + "\', sizingMethod='crop');\">&nbsp;</span></span>" ; 
     
img.outerHTML = strNewHTML;
         i = i-1;
      }
   }


}

/**
 * reflection.js v2.0
 * http://cow.neondragon.net/stuff/reflection/
 * Freely distributable under MIT-style license.
 */
 
/* From prototype.js */
if (!document.myGetElementsByClassName) {
	document.myGetElementsByClassName = function(className) {
		var children = document.getElementsByTagName('*') || document.all;
		var elements = new Array();
	  
		for (var i = 0; i < children.length; i++) {
			var child = children[i];
			var classNames = child.className.split(' ');
			for (var j = 0; j < classNames.length; j++) {
				if (classNames[j] == className) {
					elements.push(child);
					break;
				}
			}
		}
		return elements;
	}
}

var Reflection = {
	defaultHeight : 0.5,
	defaultOpacity: 0.5,
	
	add: function(image, options) {
		Reflection.remove(image);
		
		doptions = { "height" : Reflection.defaultHeight, "opacity" : Reflection.defaultOpacity }
		if (options) {
			for (var i in doptions) {
				if (!options[i]) {
					options[i] = doptions[i];
				}
			}
		} else {
			options = doptions;
		}
	
		try {
			var d = document.createElement('div');
			var p = image;
			
			var classes = p.className.split(' ');
			var newClasses = '';
			for (j=0;j<classes.length;j++) {
				if (classes[j] != "reflect") {
					if (newClasses) {
						newClasses += ' '
					}
					
					newClasses += classes[j];
				}
			}

			var reflectionHeight = Math.floor(p.height*options['height']);
			var divHeight = Math.floor(p.height*(1+options['height']));
			
			var reflectionWidth = p.width;
			
			if (document.all && !window.opera) {
				/* Fix hyperlinks */
                if(p.parentElement.tagName == 'A') {
	                var d = document.createElement('a');
	                d.href = p.parentElement.href;
                }  
                    
				/* Copy original image's classes & styles to div */
				d.className = newClasses;
				p.className = 'reflected';
				
				d.style.cssText = p.style.cssText;
				p.style.cssText = 'vertical-align: bottom';
			
				var reflection = document.createElement('img');
				reflection.src = p.src;
				reflection.style.width = reflectionWidth+'px';
				reflection.style.display = 'block';
				reflection.style.height = p.height+"px";
				
				reflection.style.marginBottom = "-"+(p.height-reflectionHeight)+'px';
				reflection.style.filter = 'flipv progid:DXImageTransform.Microsoft.Alpha(opacity='+(options['opacity']*100)+', style=1, finishOpacity=0, startx=0, starty=0, finishx=0, finishy='+(options['height']*100)+')';
				
				d.style.width = reflectionWidth+'px';
				d.style.height = divHeight+'px';
				p.parentNode.replaceChild(d, p);
				
				d.appendChild(p);
				d.appendChild(reflection);
			} else {
				var canvas = document.createElement('canvas');
				if (canvas.getContext) {
					/* Copy original image's classes & styles to div */
					d.className = newClasses;
					p.className = 'reflected';
					
					d.style.cssText = p.style.cssText;
					p.style.cssText = 'vertical-align: bottom';
			
					var context = canvas.getContext("2d");
				
					canvas.style.height = reflectionHeight+'px';
					canvas.style.width = reflectionWidth+'px';
					canvas.height = reflectionHeight;
					canvas.width = reflectionWidth;
					
					d.style.width = reflectionWidth+'px';
					d.style.height = divHeight+'px';
					p.parentNode.replaceChild(d, p);
					
					d.appendChild(p);
					d.appendChild(canvas);
					
					context.save();
					
					context.translate(0,image.height-1);
					context.scale(1,-1);
					
					context.drawImage(image, 0, 0, reflectionWidth, image.height);
	
					context.restore();
					
					context.globalCompositeOperation = "destination-out";
					var gradient = context.createLinearGradient(0, 0, 0, reflectionHeight);
					
					gradient.addColorStop(1, "rgba(255, 255, 255, 1.0)");
					gradient.addColorStop(0, "rgba(255, 255, 255, "+(1-options['opacity'])+")");
		
					context.fillStyle = gradient;
					context.rect(0, 0, reflectionWidth, reflectionHeight*2);
					context.fill();
				}
			}
		} catch (e) {
	    }
	},
	
	remove : function(image) {
		if (image.className == "reflected") {
			image.className = image.parentNode.className;
			image.parentNode.parentNode.replaceChild(image, image.parentNode);
		}
	}
}

function addReflections() {
	var rimages = document.myGetElementsByClassName('reflect');
	for (i=0;i<rimages.length;i++) {
		var rheight = null;
		var ropacity = null;
		
		var classes = rimages[i].className.split(' ');
		for (j=0;j<classes.length;j++) {
			if (classes[j].indexOf("rheight") == 0) {
				var rheight = classes[j].substring(7)/100;
			} else if (classes[j].indexOf("ropacity") == 0) {
				var ropacity = classes[j].substring(8)/100;
			}
		}
		Reflection.add(rimages[i], { height: rheight, opacity : ropacity});
		$('canvas','.rheight33').fadeIn(500);
	}
}


  function init_select()
  {
    /* Find all friendly UL's */
    $('ul.SearchableSelect').each(function()
    {
      /* Hide list element */
      $(this).css("display", "none");
    
      /* Create new ID for the select, use existent Id of UL but add the _Select prefix */
      var ElementId = $(this).attr("id") + "_Select";
      
      /* Create new Select-element */
      $(this).after("<select id='" + ElementId + "' class='SearchableSelect'></select>");
      
      /* Loop-through list and add children to select */
      $(this).find("li").each(function()
      {
        /* Setup values */
        var Anchor = $(this).find("a").eq(0), Value = (Anchor.length > 0 ? $(Anchor).attr("href") : '');
        var SelectedElement = ($(this).hasClass("SelectedItem") ? ' selected' : '');
        
        /* Add child to select */
        $("#"+ElementId).append("<option value='"+Value+"'"+SelectedElement+">"+$(this).html()+"</option>");
      });
    });
    
    /* Hook selects */
    $("select.SearchableSelect").change(function()
    {
      if(this.value.length > 0) return ajax(this.value);
    });
  };




