function evenement_inscription(inscription, id_evenement, id_membre){
			$.ajax({
				type: "POST",
				url: CFG_HTTP_ROOT + "include/ajax.inc.php", 
				data: 'action=inscription&inscription='+inscription+'&id_evenement='+id_evenement+'&id_membre='+id_membre+'' ,
				success: function(message){
					if(message != 'ko'){
						if(inscription == true){
						$('.inscription_true').css('display','block' ); 
						$('.inscription_false').css('display','none' ); 
						}else{
						$('.inscription_true').css('display','none' ); 
						$('.inscription_false').css('display','block' ); 
						}
					}
				}
			});	
			
			
}

function affiche_intervenant(id_intervenant){
	d = $('#intervenant_'+id_intervenant+' .main').css('display'); 
	if(d == 'none'){
		$('#intervenant_'+id_intervenant+' .main').slideToggle();
		$('#intervenant_'+id_intervenant+' .header a').css('background-image','url('+CFG_HTTP_ROOT+'img/bloc_open.gif)' ); 
	}else{
		$('#intervenant_'+id_intervenant+' .main').slideUp(); 
		$('#intervenant_'+id_intervenant+' .header a').css('background-image','url('+CFG_HTTP_ROOT+'img/bloc_close.gif)' ); 

	}
}


function recherche(url,keywords ){
	
	if((keywords == undefined)|| (keywords == '') || (!keywords)){
		keywords = $('form:#form_recherche input:#keywords').val(); 
	}
	if(keywords != ''){
			$.ajax({
				type: "POST",
				url: CFG_HTTP_ROOT + "include/ajax.inc.php", 
				data: 'action=get_keywords&keywords='+keywords+'' ,
				success: function(message){
					if((message != 'ko') && (message != '')){
						document.location.replace(url+'1-'+message+'/');
					}
				}
			});	
	}
	return false;
}


function zone_login_fermer(){
	$('#zone_login_header .erreurs').html(''); 
	zone_login_update_position();
		$("#zone_login_header .formulaire").animate({top: "-55px"}, 500 );
		$("#zone_login_header .boutons").animate({top: "0px"}, 500 );
		$("#zone_login_header #fermer").css('display', 'none');
}
function log_out(){
			$.ajax({
				type: "POST",
				url: CFG_HTTP_ROOT + "include/ajax.inc.php", 
				data: 'action=logout' ,
				success: function(message){
					if(message == 'ok'){
						document.location.replace(URL_ACCUEIL_LOGOUT);
					}else{
						$('form:#'+form_id+' .erreurs').html('<p>'+message+'</p>'); 
					}
				}
			});		
}


function zone_login_update_position(){
	var top = $('#zone_login_header .formulaire').css('top');
	if(top != '-55px'){
	if($("#zone_login_header .erreurs").html() == ''){
		var h = 0;	
	}else{
		var h = $("#zone_login_header .erreurs").height();
	}
	$("#zone_login_header .boutons").css('top', (80+h)+"px");
	$("#zone_login_header .formulaire").css('padding-bottom', (35+h)+"px");
	}
}


function log_in(form_id){
	var top = $('#zone_login_header .formulaire').css('top');
	if(form_id == 'zone_login_header' && top == '-55px'){

		$("#zone_login_header .formulaire").animate({top: "25px"}, 500 );
		$("#zone_login_header .boutons").animate({top: "80px"}, 500 );
		$("#zone_login_header #fermer").css('display', 'block');
	}else{
		login = $('#'+form_id+' input:.login').val();
		password = $('#'+form_id+' input:.password').val();
		
		if(login == '' || password == ''){
			message = "Merci de compl&eacute;ter tous champs du formulaire";
			$('#'+form_id+' .erreurs').html('<p>'+message+'</p>'); 
			zone_login_update_position()
		}else{
			$.ajax({
				type: "POST",
				url: CFG_HTTP_ROOT + "include/ajax.inc.php", 
				data: 'action=login&login='+login+'&password='+password+'' ,
				success: function(message){
					if(message != 'ko'){
						document.location.replace(URL_ACCUEIL_LOGIN);
					}else{
						$('#'+form_id+' .erreurs').html('<p>'+message+'</p>');
						zone_login_update_position()
					}
				}
			});		
			
		}
	}
}







function open_popup(file, largeur, hauteur){
	largeur = (largeur == undefined) ? 650 : largeur;
	hauteur = (hauteur == undefined) ? 650 : hauteur;
	window.open(file, "_blank", "menubar=no, status=no, scrollbars=yes, menubar=no, width="+largeur+", height="+hauteur+",location=no");
}



function GetScreenSize(){
	if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)){ //test for MSIE x.x;
		var ieversion=new Number(RegExp.$1) // capture x.x portion and store as a number
	}else{
		var ieversion = 0
	}
	var myWidth = 0;
	var myHeight = 0;
	if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
		myWidth = window.innerWidth;
		myHeight = window.innerHeight;
	} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
		myWidth = document.documentElement.clientWidth;
		myHeight = document.documentElement.clientHeight;
	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
		myWidth = document.body.clientWidth;
		myHeight = document.body.clientHeight;
	}
  
  	if( (ieversion <= 6) &&  (ieversion != 0)) {
		myWidth = myWidth - 30;
	}
	if(ieversion != 0){
		myHeight = myHeight + 18;
		myWidth = myWidth - 8;
	}

	return Array(myWidth,myHeight);
}
/*** FONCTIONS DIVERS ET UTILES ***/
/**********************************/






/********************************************************/
/*** FONCTIONS RELATIVES A LA CREATION D'UN DIAPORAMA ***/
function slide_show_preload() { 
	if( diaporama_array.length > 0){
		tmp_img_loaded = new Array();
		tmp_img = new Array();
		tmp_img_loaded_count = 0
		for(a = 0; a < diaporama_array.length; a++){
			array_img =diaporama_array[a].split('|');
			tmp_img[a] = new Image(); 
			tmp_img[a].src  = array_img[0];
			tmp_img_loaded[a] = false
		}										  
		slide_show_checkload()
	}
}
function slide_show_checkload() {
	if (tmp_img_loaded_count == diaporama_array.length) { 
		slide_show(0);
		return false;
	}
	for (i = 0; i <= diaporama_array.length; i++) {
		if (tmp_img_loaded[i] == false && tmp_img[i].complete) {
			tmp_img_loaded[i] = true;
			tmp_img_loaded_count++;
		}
	}
	timerID = setTimeout("slide_show_checkload()",10) 
}
function slide_show_fade_out(id){
	$("#"+diaporama_image).fadeTo(500,0, function () {
		current_id = id;
		slide_show_timout(id)
	});
}
function slide_show_timout(id){
	slide_show(id);
}
function slide_show_next(){
	clearTimeout(MyTimout)
	id  = current_id;
	id = (id == diaporama_array.length - 1) ? 0 : id+1;
	slide_show_fade_out(id);
}
function slide_show_previous(){
	clearTimeout(MyTimout)
	id  = current_id;
	id = (id == 0) ? diaporama_array.length - 1 : id-1;
	slide_show_fade_out(id);
}

function slide_show(id){
	ScreenSize = GetScreenSize();
	myWidth = ScreenSize[0];
	myHeight = ScreenSize[1];
	array_img =diaporama_array[id].split('|');
	
	bg_source = array_img[0];
	bg_color = array_img[1];
	bg_scale = array_img[2];
	bg_top = array_img[3];
	bg_left = array_img[4];
	bg_width = array_img[5];
	bg_height = array_img[6];
	
	$("#background img").attr('src',bg_source);
	$("#background td").attr('valign',bg_top);
	$('#background').attr('scale',bg_scale);
	$("#background td").css('background-color',bg_color);
	$("#background td").css('text-align',bg_left);
	
	if(bg_scale == 1){
		ScreenRatio = myWidth / myHeight;
		ImageRatio = bg_width / bg_height;
		if(ScreenRatio > ImageRatio){
			 $('#background img').css('height', Math.round(myWidth / ImageRatio )  +'px')
			$('#background img').css('width', myWidth +'px') 
		}else{
			 $('#background img').css('height', myHeight +'px') 
			 $('#background img').css('width', Math.round(myHeight *ImageRatio )  +'px')
		}
	}else{
		$('#background img').css('height', bg_height +'px') 
		$('#background img').css('width', bg_width  +'px')
	}
    $("#background img").fadeTo(500,1, function () {
		new_id = (current_id == diaporama_array.length - 1) ? 0 : current_id+1;
		MyTimout = setTimeout("slide_show_fade_out("+new_id+")",diaporama_vitesse);
     });
}	
/*** FONCTIONS RELATIVES A LA CREATION D'UN DIAPORAMA ***/
/********************************************************/














function changeSize() {
	
	ScreenSize = GetScreenSize();
	
	
	myWidth = ScreenSize[0];
	myHeight = ScreenSize[1];

	minHeight = myHeight - 375;


	if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)){ //test for MSIE x.x;
		
	}else{
		$("#main").css('min-height',minHeight + 'px');
	}
	
	
	
	$("#overlay_bg").css('height',(parseInt($("#website").height()) + 30 )+ 'px');

	newTop = $(window).scrollTop() + (myHeight - parseInt($(".overlay").css('height')) - 30 ) / 2;
	newLeft = (myWidth - parseInt($(".overlay").css('width')) - 30) / 2;
	$(".overlay").css('top', newTop + 'px');
	$(".overlay").css('left',newLeft + 'px');

	newTop = $(window).scrollTop() + (myHeight - parseInt($("#overlay_flowplayer").css('height')) - 30 ) / 2;
	newLeft = (myWidth - parseInt($("#overlay_flowplayer").css('width')) - 30) / 2;
	$("#overlay_flowplayer").css('top', newTop + 'px');
	$("#overlay_flowplayer").css('left',newLeft + 'px');


	
	newTop = $(window).scrollTop() + (myHeight - 450 ) / 2;
	newLeft = (myWidth - parseInt($(".overlay_map").css('width')) - 30) / 2;
	$(".overlay_map").css('top', newTop + 'px');
	$(".overlay_map").css('left',newLeft + 'px');
	
	
	
	
}


$(document).ready(function() {
						   
						   
 var my_flowplayer = flowplayer("player_flowplayer", F_MASTER_COMMON_JS+"/flowplayer/flowplayer-3.2.5.swf", {
  clip: {
    autoPlay: false,
    autoBuffering: true
  }
});

						   
						   
						   
	changeSize();
	$(window).resize(function() {
		changeSize();
	});
	$('#form_login_header').submit(function() {
	  log_in('zone_login_header');
	  return false;
	});
	$('#form_login').submit(function() {
	  log_in('zone_login');
	  return false;
	});
	


function initializ_gmap(adresse) {
	var map = new GMap2(document.getElementById("map"),{ size: new GSize(920,420) } );
    var geocoder = new google.maps.ClientGeocoder();
	geocoder.getLatLng(adresse, function (coord) {
		map.setCenter(coord, 15);
		map.setUIToDefault();

		var point =  map.getCenter();
		
		var marker = new GMarker(point);
		GEvent.addListener(marker, "click", function() {
			marker.openInfoWindow('<br />' + adresse);
		});
 		map.addOverlay(marker);
		

	});
}	







$('a.close').click(function() {
  $("#overlay_bg").fadeOut();
  $("#overlay_vimeo_player").fadeOut();
  $("#overlay_map").fadeOut();
  $("#overlay_flowplayer").fadeOut();
  $("body").css('overflow', 'auto');
	$("#vimeo_player").attr('src', '');
	my_flowplayer.stop();
  	return false;
});	



	
$('a.play').click(function() {
	$("#overlay_bg").fadeIn();
	$("#overlay_vimeo_player").fadeIn();
	$("body").css('overflow', 'hidden');
  
	var Href = $(this).attr("rel");
	
	var wrap = $("#vimeo_player");
	infos = Href.split('|');
	wrap.attr('src', infos[0]);
	wrap.attr('width', infos[1]);
	wrap.attr('height', infos[2]);
		
	$("#overlay_vimeo_player").css('width', infos[1]+'px');
	$("#overlay_vimeo_player").css('height', infos[2]+'px');
	$("#overlay_vimeo_player .close").css('top', (parseInt(infos[2]) + 30 ) +'px');
	changeSize();
	return false;
});	




$('a.play_local').click(function() {
	$("#overlay_bg").fadeIn();
	$("#overlay_flowplayer").fadeIn();
	$("body").css('overflow', 'hidden');
	
	Dimensions = $(this).attr("rel");
	Dimensions = Dimensions.split('|');

	$('#overlay_flowplayer').css('width', Dimensions[0]+'px');
	$('#overlay_flowplayer').css('height', Dimensions[1]+'px');
	$("#overlay_flowplayer .close").css('top', (parseInt(Dimensions[1]) + 30 ) +'px');

	my_flowplayer.play({url: $(this).attr("href")});
	changeSize();
	return false;
});	




$('a.plan').click(function() {
  $("#overlay_bg").fadeIn();
  $("#overlay_map").fadeIn();
  $("body").css('overflow', 'hidden');
  
	var Href = $(this).attr("rel");
	initializ_gmap(Href);
	
	$("#overlay_map").css('width', '920px');
	$("#overlay_map").css('height', '420px');
	changeSize();
	return false;
});	






});	


