function publier_ev(id, ok)
	{
		$.ajax({
			   type: "POST",
			   url: "dist/mes_scripts/sortirennievre/etc/ajax_publication.php",
			   data: "id=" + id + "&publication=" + ok,
			   success: function(data){
			   		if(ok==0)
			   		{
			   			alert('La fiche n\'est plus publiee.');
			   		}
			   		else
			   		{
			   			alert('La fiche est publiee.');
			   		}
			   		$('#backoffice').hide();			   			
			   }
			 })  
	}
	
	function lance_video(){
	/*
debugging = true;

		$.fn.ceebox.videos.base.param.allowScriptAccess = "sameDomain" //added to kill the permissions problem
		$.extend($.fn.ceebox.videos,{
			uctv:{
				siteRgx: /uctv\.tv\/search\-details/i, 
				idRgx: /(?:showID=)([0-9]+)/i, 
				src: "http://www.uctv.tv/player/player_uctv_bug.swf",
				flashvars: {previewImage : "http://www.uctv.tv/images/programs/[id].jpg", movie : "rtmp://webcast.ucsd.edu/vod/mp4:[id]",videosize:0,buffer:1,volume:50,repeat:false,smoothing:true}
			}
		});*/
		//$().ceebox(); //used to test to make sure the init call works.
		//$(".ceebox").ceebox({boxColor:'#fff',borderColor:'#525252',textColor:'#333',videoJSON:"js/humor.json"});
		//$(".ceebox").ceebox({borderColor:'#dcdcdc',boxColor:"#fff"});
		
		$(document).ready(function(){ $(".ceebox").ceebox();});
}


function choix_carte(id)
{	
	// communes
	if(id==1)
	{	
		$.ajax({
			   type: "POST",
			   url: "dist/mes_scripts/sortirennievre/ajax/ajax_liste_communes.php",
			   success: function(data){		
			   	  $('#liste_communes').html(data);			   	  
			   	  $('#liste_communes').show();
			   }
			 }) 
		$('#recherche_geographique').show();		 
		$('#carte_cantons').hide();		 
		$('#carte_pays').hide();		 	
		
	}	
	// cantons
	if(id==2)
	{			
		$('#recherche_geographique').show();		 
		$('#carte_cantons').show();		 
		$('#carte_pays').hide();
		$('#liste_communes').hide();		
	}

	//pays
	if(id==4)
	{		
		$('#recherche_geographique').show();		 
		$('#carte_cantons').hide();		 
		$('#carte_pays').show();
		$('#liste_communes').hide();				
	}	
}


function choix_zone(type,id)
{	
	$('#fond_gris').hide();
	$('#zone').val(id);
	$('#typezone').val(type);
	$('#recherche_geographique').hide();
	liste_evenement(0);
}


function fiche_evenement(id,repositionner)
{
	 var aryPosition = ObjectPosition(document.getElementById(id));	 
	 
	
	$.ajax({
			   type: "POST",
			   url: "dist/mes_scripts/sortirennievre/ajax/agenda_fiche_evenement.php",
			   data: "id=" + id + "&liste=" +  $('#liste_id_fiche').val(),
			   success: function(data){				   		  	 
			   	  $('#fiche_evenement').html(data);			   	  
			   	  $('#fiche_evenement').show();
				  $(".tooltip").tooltip({ 
 
					// place tooltip on the right edge 
					position: "left right",  
					// a little tweaking of the position 
					//offset: [-2, 10],  
					// use the built-in fadeIn/fadeOut effect 
					effect: "fade",  
					// custom opacity setting 
					opacity: 0,  
					// use this single tooltip element 
					tip: '#infobulle2'  
				});

			   }
			 }) 
			
	if(repositionner==1)
	{	
		$('#close_btn').hide();	 
		// animation pour positionner la fiche à la bonne hauteur dans la page
		// pour ie 
		if(Navigateur()=='Explorer')
		{
			$('#fiche_evenement').css({ top: aryPosition[1]-50 + "px" }); 
				$('#close_btn').css({ top: aryPosition[1]-65 + "px" });    
	     	$('#close_btn').show(); 
			
		}
		else // pour mozilla
		{		
		    $("#fiche_evenement").animate({
	    	opacity: 0.5,
	        top: aryPosition[1]-60 + "px"
	         }, 500, function() {
	     	$('#fiche_evenement').css({ opacity: "1" });   
	     	$('#close_btn').css({ top: aryPosition[1]-75 + "px" });    
	     	$('#close_btn').show();
	  		});
		}		
	}

	
}



function lookup(inputString,id,lib,champ,table,database) {
    if(inputString.length == 0) {
        // Hide the suggestion box.
        $('#suggestions').hide();
    } else {
    	
    	$.ajax({
			   type: "POST",
			   url: "dist/mes_scripts/sortirennievre/etc/ajax_autocompletion.php",
			   data: "queryString=" + inputString + "&id=" + id + "&lib=" + lib + "&table=" + table + "&champ=" + champ + "&db=" + database,
			   success: function(data){
			   	  $('#suggestions'+champ).show();
			   	  $('#autoSuggestionsList'+champ).html(data);
			   }
			 })  
    }
} // lookup

function fill(id,lib,champ) {
	
    $('#lib'+champ).val(lib);
     $('#'+champ).val(id);

   $('#suggestions'+champ).hide();
}

	
	
	
$(function() {
    $("#menu_categorie").lavaLamp({
        fx: "backout", 
        speed: 700,
        click: function(event, menuItem) {
            return false;
        }
    });
});

function choix_categorie(id){
	$("#categorie").val(id);
	$("#sscategorie").val('');
	$('#fiche_evenement').hide('slow');
	$('#close_btn').hide();
	//$("#gratuit").val('');			
	liste_evenement(1); 
	
}
		
/*function choix_ss_categorie(id){
	$("#categorie").val(id);			
	liste_evenement(); 			
}*/

function filtre(idcat,disabled)
{
//$("#categorie").val(idcat);
var date=$("#date").val();
if(date!='')
{
	date=1;
}
else
{
	date=0;
}

var gratuit=$("#gratuit").val();
if(gratuit!='')
{
	gratuit=1;
}
else
{
	gratuit=0;
}

var lieu=$("#zone").val();
if(lieu!='')
{
	lieu=1;
}
else
{
	lieu=0;
}


$.ajax({
   type: "POST",
   url: "dist/mes_scripts/sortirennievre/ajax/agenda_filtre.php",
   data: "idcat=" + idcat + "&disabled=" + disabled+ "&date=" + date + "&lieu=" + lieu + "&gratuit=" + gratuit,
   success: function(msg){
		$("#filtre").html(msg);
		$("#filtre").show('slide', {direction: 'right'}, 1000);
		DD_roundies.addRule('.filtre', '30px');		

		/*$("#sous_menu_categorie").slideDown("slow");*/
   }
 })
	
}
		
function liste_evenement(reload){		

$.ajax({
	   type: "POST",
	   url: "dist/mes_scripts/sortirennievre/ajax/agenda_liste_evenement.php",
	   data: "cat=" + $("#categorie").val() +"&sscat=" + $("#sscategorie").val() + "&gratuit=" + $("#gratuit").val() + "&reload=" + reload + "&date=" + $("#date").val() + "&zone=" + $('#zone').val() + "&typezone=" + $('#typezone').val(),
	   success: function(msg){
			$("#agenda").html(msg);
			$("#agenda").show();
			/*$("#filtre").show(\'slide\', {direction: \'right\'}, 1000);*/
		
	   }
	 })



}	

/*   var name = "#filtre";  
var menuYloc = null;  

$(document).ready(function(){  
menuYloc = parseInt($(name).css("top").substring(0,$(name).css("top").indexOf("px")))  
$(window).scroll(function () {   
   var offset = menuYloc+$(document).scrollTop()+"px";  
    $(name).animate({top:offset},{duration:500,queue:false});  
});  
});   */


function ObjectPosition(obj) {
var curleft = 0;
var curtop = 0;
if (obj.offsetParent) {
do {
  curleft += obj.offsetLeft;
  curtop += obj.offsetTop;
} while (obj = obj.offsetParent);
}
return [curleft,curtop];
}

function Navigateur(){
if (navigator.appName.indexOf("Netscape") > -1) {return "Netscape";}
if (navigator.appName.indexOf("Explorer") > -1) {return "Explorer";}
return "Unknown";}
