var IS_IE = (document.all) ? true : false;
var CLASS_NAME = (IS_IE) ? "className" : "class";

var regex = new RegExp("[A-Za-z0-9._-]{1,}@[A-Za-z0-9._-]{1,}[.][A-Za-z]{2,}", "gi"); 

// --------------------------------------------------------
//  Fermer un objet
// --------------------------------------------------------
function fermer(_div) {
	$("#"+_div).fadeOut('fast');	
}

// --------------------------------------------------------
//  Changer le thème de la recherche (Home)
// --------------------------------------------------------
function changeRechercheHome(_choix) {

	if (_choix == 0) {

		document.getElementById('recherche').style.background = '#D9DADB';
		document.getElementById('rech0').style.background = 'url(http://www.baby.be/fr/images/interface/onglet_site.gif)';
		document.getElementById('rech1').style.background = 'url(http://www.baby.be/fr/images/interface/onglet_forum1.gif)';
		document.getElementById('rech2').style.background = 'url(http://www.baby.be/fr/images/interface/onglet_photos1.gif)';   
		document.getElementById('rech3').style.background = 'url(http://www.baby.be/fr/images/interface/onglet_annonces1.gif)';   
		document.form_rech.action = 'http://www.baby.be/fr/divers/recherche.html';
	}
	else if (_choix == 1) {

		document.getElementById('recherche').style.background = '#D9DADB';
		document.getElementById('rech0').style.background = 'url(http://www.baby.be/fr/images/interface/onglet_site1.gif)';
		document.getElementById('rech1').style.background = 'url(http://www.baby.be/fr/images/interface/onglet_forum.gif)';
		document.getElementById('rech2').style.background = 'url(http://www.baby.be/fr/images/interface/onglet_photos1.gif)';   
		document.getElementById('rech3').style.background = 'url(http://www.baby.be/fr/images/interface/onglet_annonces1.gif)';   
		document.getElementById('mots').name = 'keywords';   
		document.form_rech.method = 'get';   
		document.form_rech.action = 'http://www.baby.be/fr/communaute/bebeforum/search.php'; 
		$("#formRech").append('<input type="hidden" name="action" value="search" id="actionForum"/>  ');  
	}
	else if (_choix == 2) {

		document.getElementById('recherche').style.background = '#D9DADB';
		document.getElementById('rech0').style.background = 'url(http://www.baby.be/fr/images/interface/onglet_site1.gif)';
		document.getElementById('rech1').style.background = 'url(http://www.baby.be/fr/images/interface/onglet_forum1.gif)';
		document.getElementById('rech2').style.background = 'url(http://www.baby.be/fr/images/interface/onglet_photos.gif)';   
		document.getElementById('rech3').style.background = 'url(http://www.baby.be/fr/images/interface/onglet_annonces1.gif)';   
		document.form_rech.action = 'http://www.baby.be/fr/galerie-photos/search.php';   
		document.getElementById('mots').name = 'mots';    
	}
	else if (_choix == 3) {

		document.getElementById('recherche').style.background = '#D9DADB';
		document.getElementById('rech0').style.background = 'url(http://www.baby.be/fr/images/interface/onglet_site1.gif)';
		document.getElementById('rech1').style.background = 'url(http://www.baby.be/fr/images/interface/onglet_forum1.gif)';
		document.getElementById('rech2').style.background = 'url(http://www.baby.be/fr/images/interface/onglet_photos1.gif)';   
		document.getElementById('rech3').style.background = 'url(http://www.baby.be/fr/images/interface/onglet_annonces.gif)';   
		document.getElementById('mots').name = 'mots';  
		document.form_rech.method = 'get';     
		document.form_rech.action = 'http://www.baby.be/fr/petites-annonces/recherche.php';   
		$("#formRech").append('<input type="hidden" name="a" value="recherche" id="actionAnnonces"/> ');
	}
}

// --------------------------------------------------------
//  Changer le thème de la recherche (Moteur de recherche)
// --------------------------------------------------------
function changeRecherche(_choix) {
	if (_choix == 0) {
		document.getElementById('recherche').style.background = '#D9DADB';
		document.getElementById('rech0').style.background = 'url(images/interface/onglet_site.gif)';
		document.getElementById('rech1').style.background = 'url(images/interface/onglet_dico1.gif)';
		document.getElementById('rech2').style.background = 'url(images/interface/onglet_questions1.gif)';
		document.form_rech.action = 'http://www.baby.be/fr/divers/recherche.html';	
	}
	
	if (_choix == 1) {
		document.getElementById('recherche').style.background = '#D9DADB';
		document.getElementById('rech0').style.background = 'url(images/interface/onglet_site1.gif)';
		document.getElementById('rech1').style.background = 'url(images/interface/onglet_dico.gif)';
		document.getElementById('rech2').style.background = 'url(images/interface/onglet_questions1.gif)';	
		document.form_rech.action = 'http://www.baby.be/fr/outils/dictionnaire/';	
	}
	else if (_choix == 2) {
		document.getElementById('recherche').style.background = '#D9DADB';
		document.getElementById('rech0').style.background = 'url(images/interface/onglet_site1.gif)';
		document.getElementById('rech1').style.background = 'url(images/interface/onglet_dico1.gif)';
		document.getElementById('rech2').style.background = 'url(images/interface/onglet_questions.gif)';		
		document.form_rech.action = 'http://www.baby.be/fr/outils/questions-reponses/';	
	}
}

// --------------------------------------------------------
//  Changer le thème de la recherche (Moteur de recherche)
// --------------------------------------------------------
function changeRechercheMaGrossesse(_choix) {
	if (_choix == 0) {
		document.getElementById('recherche').style.background = '#D9DADB';
		document.getElementById('rech0').style.background = 'url(images/interface/onglet_site.gif)';
		document.getElementById('rech1').style.background = 'url(images/interface/onglet_conseils1.gif)';
		document.form_rech.action = './divers/recherche.html';	
	}
	else if (_choix == 1) {
		document.getElementById('recherche').style.background = '#D9DADB';
		document.getElementById('rech0').style.background = 'url(images/interface/onglet_site1.gif)';
		document.getElementById('rech1').style.background = 'url(images/interface/onglet_conseils.gif)';
		document.form_rech.action = './conseils/';	
	}
}

function changeRechercheTv(_choix) {
	if (_choix == 0) {
		document.getElementById('recherche').style.background = '#D9DADB';
		document.getElementById('rech0').style.background = 'url(images/interface/onglet_site.gif)';
		document.getElementById('rech1').style.background = 'url(images/interface/onglet_tv1.gif)';
		document.form_rech.action = './divers/recherche.html';    
	}
	else if (_choix == 1) {
		document.getElementById('recherche').style.background = '#D9DADB';
		document.getElementById('rech0').style.background = 'url(images/interface/onglet_site1.gif)';
		document.getElementById('rech1').style.background = 'url(images/interface/onglet_tv.gif)';
		document.form_rech.action = './tv/';    
	}
}

function changeRechercheActus(_choix) {
	if (_choix == 0) {
		document.getElementById('recherche').style.background = '#D9DADB';
		document.getElementById('rech0').style.background = 'url(images/interface/onglet_site.gif)';
		document.getElementById('rech1').style.background = 'url(images/interface/onglet_news1.gif)';
		document.form_rech.action = './divers/recherche.html';    
	}
	else if (_choix == 1) {
		document.getElementById('recherche').style.background = '#D9DADB';
		document.getElementById('rech0').style.background = 'url(images/interface/onglet_site1.gif)';
		document.getElementById('rech1').style.background = 'url(images/interface/onglet_news.gif)';
		document.form_rech.action = './actus-bebe/';    
	}
}

function changeRechercheGuide(_choix) {
	if (_choix == 0) {
		document.getElementById('recherche').style.background = '#013E6A';
		document.getElementById('rech0').style.background = 'url(images/interface/onglet_site.gif)';
		document.getElementById('rech1').style.background = 'url(images/interface/onglet_guide1.gif)';
		document.form_rech.action = './divers/recherche.html';    
	}
	else if (_choix == 1) {
		document.getElementById('recherche').style.background = '#AAB2D7';
		document.getElementById('rech0').style.background = 'url(images/interface/onglet_site1.gif)';
		document.getElementById('rech1').style.background = 'url(images/interface/onglet_guide.gif)';
		document.form_rech.action = './guide-de-maman/';    
	}
}

function changeRechercheServices(_choix) {

	if (_choix == 0) {
		document.getElementById('recherche').style.background = '#D9DADB';
		document.getElementById('rech0').style.background = 'url(http://www.baby.be/fr/images/interface/onglet_site.gif)';
		document.getElementById('rech1').style.background = 'url(http://www.baby.be/fr/images/interface/onglet_services1.gif)';
		document.form_rech.action = 'http://www.baby.be/fr/divers/recherche.html';    
	}
	else if (_choix == 1) {

		document.getElementById('recherche').style.background = '#D9DADB';
		document.getElementById('rech0').style.background = 'url(http://www.baby.be/fr/images/interface/onglet_site1.gif)';
		document.getElementById('rech1').style.background = 'url(http://www.baby.be/fr/images/interface/onglet_services.gif)';
		document.form_rech.action = 'http://www.baby.be/fr/services-pratiques/';    
	}
}

function changeRechercheBebemoi(_choix) {

	if (_choix == 0) {
		document.getElementById('recherche').style.background = '#013E6A';
		document.getElementById('rech0').style.background = 'url(images/interface/onglet_site.gif)';
		document.getElementById('rech1').style.background = 'url(images/interface/onglet_bebemoi1.gif)';
		document.form_rech.action = './divers/recherche.html';    
	}
	else if (_choix == 1) {
		document.getElementById('recherche').style.background = '#91BCAB';
		document.getElementById('rech0').style.background = 'url(images/interface/onglet_site1.gif)';
		document.getElementById('rech1').style.background = 'url(images/interface/onglet_bebemoi.gif)';
		document.form_rech.action = './babyfra4/bebe-et-moi/';    
	}
}

function changeRechercheJeux(_choix) {

	if (_choix == 0) {

		document.getElementById('recherche').style.background = '#D9DADB';
		document.getElementById('rech0').style.background = 'url(images/interface/onglet_site.gif)';
		document.getElementById('rech1').style.background = 'url(images/interface/onglet_jeux1.gif)';
		document.form_rech.action = './divers/recherche.html';    
	}
	else if (_choix == 1) {

		document.getElementById('recherche').style.background = '#D9DADB';
		document.getElementById('rech0').style.background = 'url(images/interface/onglet_site1.gif)';
		document.getElementById('rech1').style.background = 'url(images/interface/onglet_jeux.gif)';
		document.form_rech.action = './jeux/';    
	}
}

function changeRecherchePhotos(_choix) {

	if (_choix == 0) {

		document.getElementById('recherche').style.background = '#D9DADB';
		document.getElementById('rech0').style.background = 'url(http://www.baby.be/fr/images/interface/onglet_site.gif)';
		document.getElementById('rech1').style.background = 'url(http://www.baby.be/fr/images/interface/onglet_photos1.gif)';
		document.getElementById('rech2').style.background = 'url(http://www.baby.be/fr/images/interface/onglet_videos1.gif)';   
		document.form_rech.action = 'http://www.baby.be/fr/divers/recherche.html';    
	}
	else if (_choix == 1) {

		document.getElementById('recherche').style.background = '#D9DADB';
		document.getElementById('rech0').style.background = 'url(http://www.baby.be/fr/images/interface/onglet_site1.gif)';
		document.getElementById('rech1').style.background = 'url(http://www.baby.be/fr/images/interface/onglet_photos.gif)';
		document.getElementById('rech2').style.background = 'url(http://www.baby.be/fr/images/interface/onglet_videos1.gif)';  
		document.form_rech.action = 'http://www.baby.be/fr/galerie-photos/search.php';    
	}
	else if (_choix == 2) {

		document.getElementById('recherche').style.background = '#D9DADB';
		document.getElementById('rech0').style.background = 'url(http://www.baby.be/fr/images/interface/onglet_site1.gif)';
		document.getElementById('rech1').style.background = 'url(http://www.baby.be/fr/images/interface/onglet_photos1.gif)';
		document.getElementById('rech2').style.background = 'url(http://www.baby.be/fr/images/interface/onglet_videos.gif)';  
		document.getElementById('rech2').style.background = 'url(http://www.baby.be/fr/images/interface/onglet_videos.gif)';  
		document.form_rech.action = 'http://www.baby.be/fr/galerie-videos/search.php';    
	}
}

function changeRechercheShopping(_choix) {

	if (_choix == 0) {

		document.getElementById('recherche').style.background = '#D9DADB';
		document.getElementById('rech0').style.background = 'url(images/interface/onglet_site.gif)';
		document.getElementById('rech2').style.background = 'url(images/interface/onglet_magasins1.gif)'; 
		document.form_rech.action = './divers/recherche.html';    
		}
	else if (_choix == 2) {

		document.getElementById('recherche').style.background = '#D9DADB';
		document.getElementById('rech0').style.background = 'url(images/interface/onglet_site1.gif)';
		document.getElementById('rech2').style.background = 'url(images/interface/onglet_magasins.gif)';   
		document.getElementById('mots').name = 'mots';  
		document.form_rech.method = 'get';     
		document.form_rech.action = 'http://petitesannonces.famiweb.be/recherche.php';    
	}
	

}


function changeRechercheFamiweb(_choix) {

	if (_choix == 0) {

		document.getElementById('recherche').style.background = '#013E6A';
		document.getElementById('rech0').style.background = 'url(images/interface/onglet_site.gif)';
		document.getElementById('rech1').style.background = 'url(images/interface/onglet_famiweb1.gif)';
		document.form_rech.action = './divers/recherche.html';    
	}
	else if (_choix == 1) {

		document.getElementById('recherche').style.background = '#FFAA50';
		document.getElementById('rech0').style.background = 'url(images/interface/onglet_site1.gif)';
		document.getElementById('rech1').style.background = 'url(images/interface/onglet_famiweb.gif)';
		document.form_rech.action = './2-12-ans/';    
	}
}

function changeRechercheCommunaute(_choix) {

	if (_choix == 0) {

		document.getElementById('recherche').style.background = '#D9DADB';
		document.getElementById('rech0').style.background = 'url(http://www.baby.be/fr/images/interface/onglet_site.gif)';
		document.getElementById('rech1').style.background = 'url(http://www.baby.be/fr/images/interface/onglet_forum1.gif)'; 
		document.form_rech.action = 'http://www.baby.be/fr/divers/recherche.html';    
		$("#actionSearch").remove(); 
		document.getElementById('mots').name = 'mots'; 
	}
	else if (_choix == 1) {

		document.getElementById('recherche').style.background = '#D9DADB';
		document.getElementById('rech0').style.background = 'url(http://www.baby.be/fr/images/interface/onglet_site1.gif)';
		document.getElementById('rech1').style.background = 'url(http://www.baby.be/fr/images/interface/onglet_forum.gif)';
		//document.getElementById('rech2').style.background = 'url(http://www.baby.be/fr/images/interface/onglet_blogs1.gif)'; 
		$("#formRecherche").append('<input type="hidden" name="action" value="search" id="actionSearch" />');
		document.getElementById('mots').name = 'keywords';   
		document.form_rech.method = 'post';   
		document.form_rech.action = 'http://www.baby.be/fr/communaute/bebeforum/search.php';    
	}
}


// --------------------------------------------------------
//  Changer la couleur du menu
// --------------------------------------------------------
function changeCouleurMenu(_class) {

	
	if (_class == 'menu_baby_club') {
		document.getElementById('header').style.background = '#396CBB';	
	}
	else if (_class == 'menu_actus_bebe') {
		document.getElementById('header').style.background = '#5C7B8F';
	}
	else if (_class == 'menu_ma_grossesse') {
		document.getElementById('header').style.background = '#E0CDD3';
	}
	else if (_class == 'menu_guide_maman') {
		document.getElementById('header').style.background = '#AAB2D7';
	}
	else if (_class == 'menu_babypedia') {
		document.getElementById('header').style.background = '#E0DEC9';
	}
	else if (_class == 'menu_bebe_moi') {
		document.getElementById('header').style.background = '#91BCAB';
	}
	else if (_class == 'menu_services') {
		document.getElementById('header').style.background = '#FFAA50';
	}
	else if (_class == 'menu_jeux') {
		document.getElementById('header').style.background = '#FEC85B';
	}
	else if (_class == 'menu_photos') {
		document.getElementById('header').style.background = '#B10044';
	}
	else if (_class == 'menu_communaute') {
		document.getElementById('header').style.background = '#076E8F';
	}
	else if (_class == 'menu_shopping') {
		document.getElementById('header').style.background = '#AAD1A4';
	}
	else if (_class == 'menu_shopping_sub') {
		document.getElementById('header').style.background = '#B72A79';
	}
}



// --------------------------------------------------------
//  Les widgets des articles
// --------------------------------------------------------
function article_rss(_url) {
	
	$("#articlerss").show("fast").html("Envoi en cours ...");
	
	$.get(
		"ajax.php" , 
		{ articlerss : 1, url: _url } , 
		function(data){ $("#articlerss").show('fast').html(data); }
	); 
}


// --------------------------------------------------------
// Grossir le texte de l'article
// --------------------------------------------------------
var texte, titre;			
texte = 12;
titre = 20;
function changerTaille(modif) {
	texte = texte + modif;
	titre = titre + modif;
	document.getElementById("titreContainer").style.fontSize = titre + "px";
	document.getElementById("texteContainer").style.fontSize = texte + "px";	
} 

// --------------------------------------------------------
// Envoyer article à un ami
// --------------------------------------------------------
function envoie_ami(_idArticle) {
	var t = new Date();
	
	$("#envoi_ami").show("fast").html("Envoi en cours ...");
	
	$.get(
		"./envoi_ami.php" , 
		{ idArticle: _idArticle, t: t.getTime()} , 
		function(data){ $("#envoi_ami").show("fast").html(data); }
	);	
}

// --------------------------------------------------------
// Poster article
// --------------------------------------------------------
function post_ami(_idArticle) {
	
	_nom = escape(document.inviter.nom.value);
	_email = escape(document.inviter.email.value);
	_email1 = escape(document.inviter.email1.value);
	_email2 = escape(document.inviter.email2.value);
	_email3 = escape(document.inviter.email3.value);
	
	$("#envoi_ami").show("fast").html("Envoi en cours ...");
	
	var t = new Date();
	$.post(
		"./ajax.php" , 
		{ envoiAmi: 1, idArticle: _idArticle, nom: _nom, email: _email, email1: _email1, email2: _email2, email3: _email3, t: t.getTime()} , 
		function(data){ $("#envoi_ami").show("fast").html(data); }
	);	
}


// --------------------------------------------------------
// Envoie d'un commentaire sur un article
// --------------------------------------------------------
function envoiComment() {
	
	_idArticle = document.commentaire.idArticle.value;
	_message = document.commentaire.message.value;
	
	if (_idArticle > 0 && _message != '')
		document.commentaire.submit(); 
	else
	{
		if (_message == '') document.getElementById('message').style.background = "#CCCFFF";
	}
}

// --------------------------------------------------------
// Appelle le formulaires d'inscription du babyclub
// --------------------------------------------------------
function formBabyClub(_fi) {
	var _debat = "";
	_idArticle = document.commentaire.idArticle.value;
	_message = document.commentaire.message.value;		
	_debat = $("#form_comment input:checked").val();	
	if (_debat == "undefined") _debat = "";	
	if (_idArticle > 0 && _message != '') {
		$("#babyclub").html("Envoi en cours ...");
		$.post(
		"./ajax_inscription.php" , 
		{idArticle: _idArticle, message: _message, debat: _debat, fi: _fi} , 
		function(data){ $("#babyclub").html(data); }
		);	
	}
	else
		if (_message == '') document.getElementById('message').style.background = "#CCCFFF";
}


// --------------------------------------------------------
// Sondages : Voter
// --------------------------------------------------------
function sondagesVoter(_poll_id) {
	var _option_id = '';
	_option_id = $("#sondages input:checked").val();

	$("#chargeSondage").fadeIn("fast").html('<center><img src="images/loading.gif"></center>');
	
	$.post(
	"ajax.php" , 
	{poll_ident : _poll_id, action : "vote", option_id : _option_id} , 
	function(data){ 
		$("#ajaxSondage").html(data).fadeIn("fast"); 
		$("#chargeSondage").fadeOut("fast");  
	}
	);		
}

// --------------------------------------------------------
// Sondages : Voir les resultats
// --------------------------------------------------------
function sondagesResults(_poll_id) {
	$("#chargeSondage").fadeIn("fast").html('<center><img src="images/loading.gif"></center>');
	
	$.post(
	"ajax.php" , 
	{poll_ident : _poll_id, action : "voir"} , 
	function(data){ 
		$("#ajaxSondage").html(data).fadeIn("fast"); 
		$("#chargeSondage").fadeOut("fast"); 
	}
	);		
}

// --------------------------------------------------------
// Sondages : Retour
// --------------------------------------------------------
function sondagesRetour(_poll_id) {
	$("#chargeSondage").fadeIn("fast").html('<center><img src="images/loading.gif"></center>');
					 
	$.post(
	"ajax.php" , 
	{poll_ident : _poll_id, action : "autre"} , 
	function(data){ 
		$("#ajaxSondage").html(data).fadeIn("fast"); 
		$("#chargeSondage").fadeOut("fast");
	}
	);		
}

// --------------------------------------------------------
// Form commentaire
// --------------------------------------------------------
function formComment(_action, _id, _template) {
	$("#chargeSondage").fadeIn("fast").html('<center><img src="images/loading.gif"></center>');
	
	$.post(
	"./ajax.php" , 
	{formComment: 1, id : _id, action : "send"} , 
	function(data){ 
		$("#ajaxSondage").html(data); 
		$("#chargeSondage").fadeOut("fast");  
	}
	);		
}

// --------------------------------------------------------
// LOGIN babyclub
// --------------------------------------------------------
function loginBabyclub(_fichier) {
	_login = $("#login").val();
	_pass = $("#pass").val();
	
	$.post(
	""+_fichier+"" , 
	{login_babyblub : 1, login : _login, pass : _pass} , 
	function(data){ 
		$("#login_centre").html(data); 
		location.reload(false);
	}
	);
}

// --------------------------------------------------------
// Form oublié mon mot de passe
// --------------------------------------------------------
function formOublie(_fichier, _div) {
	if (_div == null) _div = 'login_centre';
	$("#"+_div).html('<center><img src="images/loading.gif"></center>').fadeIn("fast");
	$.get(
	""+_fichier+"" , 
	{formOubie : 1, fichier : _fichier, div : _div} , 
	function(data){ 
		$("#"+_div).html(data).fadeIn("fast"); 
	}
	);
}

// --------------------------------------------------------
// Envoie Form oublié mon mot de passe
// --------------------------------------------------------
function envoiFormOublie(_fichier, _div) {
	if (_div == null) _div = 'login_centre';  
	_email = $("#email").val();
	if (_email.search(regex) != -1) {
		$("#"+_div).html('<center><img src="images/loading.gif"></center>').fadeIn("fast");  
		$.post(
		""+_fichier+"" , 
		{envoiFormOublie : 1, email:_email, div : _div} , 
		function(data){ 
			$("#"+_div).html(data).fadeIn("fast"); 
		}
		);
	}
	else
		document.getElementById('email').style.background = "#ffcccc";
}

// --------------------------------------------------------
// VISU BABYCLUB FONDS
// --------------------------------------------------------
function visuBabyclub(_idArticle, _div) {
	$("#"+_div).fadeOut("slow");
	$.post(
	"./ajax.php" , 
	{visu_babyblub_fonds : 1, idArticle : _idArticle} , 
	function(data){ $("#"+_div).fadeIn("slow").html(data); }
	);
}

// --------------------------------------------------------
// Affiche la suite de l'Horoscope
// --------------------------------------------------------
function afficheHoroscope(_idCompte, _div, _type) {
	$("#"+_div).fadeOut("fast");
	$.post(
	"./ajax.php" , 
	{afficheHoroscope : 1, idCompte : _idCompte, type: _type} , 
	function(data){ $("#"+_div).fadeIn("fast").html(data); }
	);
}

// --------------------------------------------------------
// Affiche le form de la blague
// --------------------------------------------------------
var $okBlague = 0;
function addBlague(_idCategorie) {
	if ($okBlague == 0) {
		$.post(
		"./ajax.php" , 
		{ADDBLAGUE : 1, idCategorie : _idCategorie} , 
		function(data){ $("#addBlague").html(data).slideDown("slow"); }
		);
		$okBlague = 1;  
	}
	else {
		$("#addBlague").slideUp("slow");
		$okBlague = 0;
	}
}

// --------------------------------------------------------
// Poste la blague
// --------------------------------------------------------
function postBlague(_idCategorie) {
	$("#resultPost").html("Envoi en cours ...");

	_texte = $("#texteBlague").val();  	
	_titre = $("#titreBlague").val();  
	
	if (_idCategorie == '')
		_idCategorie = $("#idCategorie").val();
	
	$.post(
	"./ajax.php" , 
	{POSTBLAGUE : 1, idCategorie : _idCategorie, texteBlague: _texte, titreBlague: _titre} , 
	function(data){ $("#resultPost").html(data); }
	);
}

// --------------------------------------------------------
// Enscription email news
// --------------------------------------------------------
function sendEmailNews() {  
	
	if (document.getElementById('emailNews').value.search(regex) == -1) {
		document.getElementById('emailNews').style.background = "#ffcccc";
	} else {
		var _email = $("#emailNews").val(); 
		var _idFiliere = $("#idFiliere").val();   
		$("#resultEmailNews").fadeIn('fast').html("<br><br>Envoi en cours ...");    

		$.post(
		"./ajax.php" , 
		{SENDEMAILNEWS : 1, email: _email, idFiliere: _idFiliere } , 
		function(data){ $("#resultEmailNews").html(data); }
		);
	}
}


function reduireSection(_div) {
	$("#reduirePlace_"+_div).html('<img src="images/agrandir.gif" onclick="agrandirSection(\''+_div+'\');">');
	$("#contenuSection_"+_div).slideUp("slow");    
}

function agrandirSection(_div) {
	$("#reduirePlace_"+_div).html('<img src="images/reduire.gif" onclick="reduireSection(\''+_div+'\');">');
	$("#contenuSection_"+_div).slideDown("slow");
}

function getMySections(_idSection, _position, _titre) {
	
	$("#contenuSection_"+_position).html('<br><br><br><center><img src="images/loading.gif"></center>');

	$.get(
		"./ajax_home.php" , 
		{MYSECTIONS: 1, idSection : _idSection, position : _position} , 
		function(data){ 
			$("#stockIdSection_"+_position).html(_idSection);  
			$("#titre_"+_position).html(_titre);
			$("#contenuSection_"+_position).html(data); 
		}
	);    
}

var sectCourant = 0;
function editerSection(_position) {
	
	$("#attenteChoix_"+_position).html('<img src="images/attente_mini.gif">').fadeIn("fast");
	
	if (sectCourant > 0) $("#choix_"+sectCourant).fadeOut("fast");
	
	agrandirSection(_position);
	$.get(
		"ajax_home.php" , 
		{CHOIXSECTIONS: 1, position:_position} , 
		function(data){ 
			$("#choix_"+_position).html(data).fadeIn("fast"); 
			$("#attenteChoix_"+_position).html('<img src="images/attente_mini.gif">').fadeOut("fast"); 
		}
	);    
	sectCourant = _position;
}

function selectChoixSection(_idSection, _position, _titre) { 
	$("#choix_"+_position).fadeOut("fast");
	$.get(
	"ajax_home.php" , 
	{SELECTCHOIXSECTION: 1, position:_position, idSection:_idSection} , 
	function(data){ 
		getMySections(_idSection, _position, _titre);
	}
	);      
}

function sectionRien(_position) { 
	$("#choix_"+_position).fadeOut("fast");
	$.get(
	"ajax_home.php" , 
	{SELECTRIEN: 1, position:_position} , 
	function(data){ 
		$("#titre_"+_position).html('');
		$("#contenuSection_"+_position).html(''); 
	}
	);      
}

function SaveSection(_idSection)
{
	var items = $(".sectionlistitem");
	var _sections = [];
	var str = "";
	for(var x=0; x<items.length; x++)
	{    
		if (str.length > 0) str += ",";    
		str += ""+items[x].id;  
	}
	
	$.get("ajax_home.php" , 
	{SAVESECTION: 1, sections: str, idSection: _idSection} , 
	function(data){ 
		$("#confirmSave").html(data);
	}
	); 
}

function refreshSection(_idSection, _position, _titre)
{
	$("#contenuSection_"+_position).html('<br><br><br><center><img src="images/loading.gif"></center>');

	$.get(
		"./ajax_home.php" , 
		{MYSECTIONS: 1, idSection : _idSection, position : _position} , 
		function(data){ 
			$("#titre_"+_position).html(_titre);
			$("#contenuSection_"+_position).html(data); 
		}
	); 
}

function changeOngletHome(_num) {
	if (_num == 1) {
		document.getElementById('OngletHome1').style.background = 'url(images/interface/onglet_news_home.gif)'; 
		document.getElementById('OngletHome2').style.background = 'url(images/interface/onglet_debats_home1.gif)'; 
		document.getElementById('OngletHome3').style.background = 'url(images/interface/onglet_sondages_home1.gif)';
		document.getElementById('OngletHome4').style.background = 'url(images/interface/onglet_annonces_home1.gif)';   
		$("#tiers1").fadeIn();
		$("#tiers2").hide(); 
		$("#tiers3").hide(); 
		$("#tiers4").hide();
	}
	else if (_num == 2) {
		document.getElementById('OngletHome1').style.background = 'url(images/interface/onglet_news_home1.gif)'; 
		document.getElementById('OngletHome2').style.background = 'url(images/interface/onglet_debats_home.gif)'; 
		document.getElementById('OngletHome3').style.background = 'url(images/interface/onglet_sondages_home1.gif)'; 
		document.getElementById('OngletHome4').style.background = 'url(images/interface/onglet_annonces_home1.gif)';  
		$("#tiers1").hide();
		$("#tiers2").fadeIn(); 
		$("#tiers3").hide(); 
		$("#tiers4").hide();    
	}
	else if (_num == 3) {
		document.getElementById('OngletHome1').style.background = 'url(images/interface/onglet_news_home1.gif)'; 
		document.getElementById('OngletHome2').style.background = 'url(images/interface/onglet_debats_home1.gif)'; 
		document.getElementById('OngletHome3').style.background = 'url(images/interface/onglet_sondages_home.gif)';
		document.getElementById('OngletHome4').style.background = 'url(images/interface/onglet_annonces_home1.gif)';  
		$("#tiers1").hide();
		$("#tiers2").hide(); 
		$("#tiers3").fadeIn();
		$("#tiers4").hide();      
	}
	else if (_num == 4) {
		document.getElementById('OngletHome1').style.background = 'url(images/interface/onglet_news_home1.gif)'; 
		document.getElementById('OngletHome2').style.background = 'url(images/interface/onglet_debats_home1.gif)'; 
		document.getElementById('OngletHome3').style.background = 'url(images/interface/onglet_sondages_home1.gif)';
		document.getElementById('OngletHome4').style.background = 'url(images/interface/onglet_annonces_home.gif)';  
		$("#tiers1").hide();
		$("#tiers2").hide(); 
		$("#tiers3").hide(); 
		$("#tiers4").fadeIn();     
	}
}

// --------------------------------------------------------
// Affiche le form On denonce
// --------------------------------------------------------
function messageEntete() {
	$.get(
	"./ajax.php" , 
	{messageEntete : 1} , 
	function(data){ $("#messageEntete").html(data).fadeIn("fast"); }
	);
}

// --------------------------------------------------------
// Envoie vers la rédaction
// --------------------------------------------------------
function postFormOnDenonce() {
	$("#resultPost").html("Envoi en cours ...");

	_texte = $("#texteBlague").val();      
	_titre = $("#titreBlague").val();  
	
	if (_idCategorie == '')
		_idCategorie = $("#idCategorie").val();
	
	$.post(
	"./ajax.php" , 
	{POSTBLAGUE : 1, idCategorie : _idCategorie, texteBlague: _texte, titreBlague: _titre} , 
	function(data){ $("#resultPost").html(data); }
	);
}


function participer(_email) {
	if (_email == '' || _email.search(regex) == -1) {
		$("#erreur").html("Erreur: Veuillez introduir votre email!");
	}
	else{
		$.get(
			"./ajax.php" , 
			{ email: _email } , 
			function(data){ $("#email").html(data); }
		);
	}

}

function envoiForm(formulaire) {
	_nom = $("#nom").val();
	_email = $("#email").val();
	_societe = $("#societe").val();
	_fonction = $("#fonction").val();
	_telephone = $("#telephone").val();
	_message = $("#message").val();
	_type = $("#type").val();
	
	$("#formulaire").html("<br><br><center><b>Envoi en cours ...</b></center>"); 
	
	$.post(
		"./ajax.php" , 
		{ nom: _nom, email: _email, societe: _societe, fonction: _fonction, telephone: _telephone, message: _message, type: _type } , 
		function(data){ $("#formulaire").html(data); }
	);    
}   

var ouvert2 = 0;
function formTemoignages() {
	if (ouvert2 == 0) {
		$.get(
			"./ajax.php" , 
			{ formTemoignages: 1} , 
			function(data){ $("#formOnDenonce").html(data).fadeIn("fast"); }
		);
		ouvert2 = 1;   	
	}
	else 
	{
		$("#formOnDenonce").fadeOut("fast");
		ouvert2 = 0; 
	}
}

function envoiFormtemoignage() {
	_nom = $("#nom").val();
	_email = $("#email").val();
	_message = $("#temoignage").val();
	$("#formOnDenonce").html('<img src="images/loading.gif"> Envoi en cours ...').fadeIn("fast"); 
	$.post(
		"./ajax.php" , 
		{envoiFormtemoignage:1, nom: _nom, email: _email, message: _message } , 
		function(data){ $("#formOnDenonce").html(data); }
	);  
}

function formCommentSondages(_id, _titre) {    
	var _t = $("#titreSondage").html();
	if (_t == null)
		_t = _titre;
	$("#tiers3").html('<br><br><br><br><center><img src="images/loading.gif"> Formulaire en chargement ...</center>').fadeIn("fast");    
	$.get(
		"./ajax.php" , 
		{ formSondages: 1, id:_id, titre:_t} , 
		function(data){ $("#tiers3").html(data).fadeIn("fast"); }
	);    
}

function envoiFormCommentSondages(_id, _titre) {
	_message = $("#messageSondage").val();
	
	var erreur = 0;
	if (_message == '') {
		document.getElementById('messageSondage').style.background = "#ffcccc";
		erreur++;
	}
	else
		document.getElementById('messageSondage').style.background = ""; 
	
	if (erreur == 0) {
		$("#formOnDenonce").html('<img src="images/loading.gif"> Envoi en cours ...').fadeIn("fast"); 
		$.post(
			"./ajax.php" , 
			{envoiFormCommentSondages:1, message: _message, id:_id, titre:_titre } , 
			function(data){ $("#tiers3").html(data); }
		);  
	}
}


function dater()
{
	aujourdhui = new Date();
	j = aujourdhui.getDate();
		if (j<10)
		{
		j = "0"+j;
		}
	d = aujourdhui.getDay();
	m = aujourdhui.getMonth();
	a = aujourdhui.getFullYear();
	jour = new Array('Dimanche','Lundi','Mardi','Mercredi','Jeudi','Vendredi','Samedi');
	mois = new Array('janvier','février','mars','avril','mai','juin','juillet','août','septembre','octobre','novembre','décembre');
	dater = ''+jour[d]+' '+j+' '+mois[m]+' '+a+'';
		if(document.getElementById)
		{
			document.getElementById("dateAuj").innerHTML = dater;
		}
		else if(document.all)
		{
			document.all["dateAuj"].innerHTML = dater;
		}
}

$accorOuvert = 0;
function mesWidgets() {  
	$("#loadWidgets").html('<img src="http://www.baby.be/fr/images/attente_mini.gif" style="position:absolute">').fadeIn("fast"); 
	if ($accorOuvert == 0) {  
		$.get(
			"http://www.baby.be/fr/ajax_widgets.php" , 
			{ AFFICHELISTE: 1} , 
			function(data){ 
				$("#my_widgets").html(data).slideDown("fast"); 
				$("#loadWidgets").hide(); 
			}
		); 
		$accorOuvert = 1;
	}
	else {
		$("#my_widgets").slideUp("fast");
		$accorOuvert = 0;
		$("#loadWidgets").hide(); 
	}   
}

function getMyWidget(_idSection, _position, _titre) {
	
	$("#loadSection_"+_position).html('<img src="http://www.baby.be/fr/images/attente_mini.gif" style="position:absolute">').fadeIn('fast');

	$.get(
		"http://www.baby.be/fr/ajax_widgets.php" , 
		{MYSECTIONS: 1, idSection : _idSection, position : _position} , 
		function(data){ 
			$("#titre_"+_position).html(_titre);
			$("#contenuSectionWidget_"+_position).html(data); 
			$("#loadSection_"+_position).hide();  
		}
	);    
}

var actualUser = 0;

function infoBullUser(_idCompte, _pseudo) {
	
	if (actualUser > 0)
		$("#userProfil_"+actualUser).fadeOut('fast');

	$("#userProfil_"+_idCompte).fadeIn("fast");
	//$("#bullPseudo_"+_idCompte).html(_pseudo);
	
	actualUser = _idCompte;  
	
	$.ajax({
	  type: "GET",
	  url: "http://www.baby.be/fr/ajax.php",
	  cache: true,
	  data: "INFOBULLUSER&idCompte="+_idCompte,
	  success: function(data){
		$("#userProfil_"+_idCompte).html(data);
	  }
	});    

}

function infoBullGroupPres(_idCompte, _pseudo, _idRelation) {
	
	if (actualUser > 0)
		$("#userProfil_"+actualUser).fadeOut('fast');

	$("#userProfil_"+_idCompte).fadeIn("fast");
	//$("#bullPseudo_"+_idCompte).html(_pseudo);
	
	actualUser = _idCompte;  
	
	$.ajax({
	  type: "GET",
	  url: "http://www.baby.be/fr/ajax.php",
	  cache: true,
	  data: "INFOBULLGROUPPRES&idCompte="+_idCompte+"&idRelation="+_idRelation,
	  success: function(data){
		$("#userProfil_"+_idCompte).html(data);
	  }
	});    

}

function masquer(_div1, _div2) {
	$("#"+_div2).html('<a href="javascript:afficher(\''+_div1+'\', \''+_div2+'\')">réafficher</a>');
	$("#"+_div1).slideUp("slow");    
}

function afficher(_div1, _div2) {
	$("#"+_div2).html('<a href="javascript:masquer(\''+_div1+'\', \''+_div2+'\')">Masquer</a>');
	$("#"+_div1).slideDown("slow");
}

function nbMsgForums(_forum, _nb) {
	$.get(
		"./ajax.php" , 
		{ nbMsgForums: 1, nb:_nb, forum:_forum} , 
		function(data){ $("#box_forum_chezmoi").html(data).fadeIn("fast"); }
	);   
}

function nbAnnChezMoi(_idRegion, _nb) {
	$.get(
		"./ajax.php" , 
		{ nbAnnChezMoi: 1, nb:_nb, idRegion:_idRegion} , 
		function(data){ $("#box_affaires_chezmoi").html(data).fadeIn("fast"); }
	);   
}

function nbNounouChezMoi(_idRegion, _nb) {
	$.get(
		"./ajax.php" , 
		{ nbNounouChezMoi: 1, nb:_nb, idRegion:_idRegion} , 
		function(data){ $("#box_nounou_chezmoi").html(data).fadeIn("fast"); }
	);   
}

//-----------------------------------------------------------------------
// Système de vote par points  (RANK)
//-----------------------------------------------------------------------

var NOMBRE_ETOILES = 5;

//------------------------------------------------------------------------
// Initialisation des points
//------------------------------------------------------------------------
function init_votes()
{
	var ratings = document.getElementsByTagName('div');
	for (var i = 0; i < ratings.length; i++)
	{
		if (ratings[i].className != 'rating')
			continue;

		var rating = ratings[i].firstChild.nodeValue;
		ratings[i].removeChild(ratings[i].firstChild);
		if (rating > NOMBRE_ETOILES || rating < 0)
			continue;

		// On cherche les étoiles :-)
		for (var j = 0; j < NOMBRE_ETOILES; j++)
		{
			var etoile = document.createElement('img');
			if (rating >= 1)
			{
				etoile.setAttribute('src', './images/stars/rating_on.png');
				etoile.className = 'on';
				rating--;
			}
			else if(rating == 0.5)
			{
				etoile.setAttribute('src', './images/stars/rating_half.png');
				etoile.className = 'half';
				rating = 0;
			}
			else
			{
				etoile.setAttribute('src', './images/stars/rating_off.png');
				etoile.className = 'off';
			}
			var widgetId = ratings[i].getAttribute('id').substr(7);
			etoile.setAttribute('id', 'star_'+widgetId+'_'+j);
			etoile.onmouseover = new Function("evt", "displayHover("+widgetId+", "+j+");");
			etoile.onmouseout = new Function("evt", "displayNormal("+widgetId+", "+j+");");
			ratings[i].appendChild(etoile);
		}
	}
}

// --------------------------------------------------------
// Mettre à jour l'affichage du vote
// --------------------------------------------------------
function resultatVote(_div) {

	var ratings = document.getElementById(_div);

		var rating = ratings.firstChild.nodeValue;
		ratings.removeChild(ratings.firstChild);

		for (var j = 0; j < NOMBRE_ETOILES; j++)
		{
			var etoile = document.createElement('img');
			if (rating >= 1)
			{
				etoile.setAttribute('src', './images/stars/rating_on.png');
				etoile.className = 'on';
				rating--;
			}
			else if(rating == 0.5)
			{
				etoile.setAttribute('src', './images/stars/rating_half.png');
				etoile.className = 'half';
				rating = 0;
			}
			else
			{
				etoile.setAttribute('src', './images/stars/rating_off.png');
				etoile.className = 'off';
			}
			var widgetId = ratings.getAttribute('id').substr(7);
			etoile.setAttribute('id', 'star_'+widgetId+'_'+j);
			etoile.onmouseover = new Function("evt", "displayHover("+widgetId+", "+j+");");
			etoile.onmouseout = new Function("evt", "displayNormal("+widgetId+", "+j+");");
			ratings.appendChild(etoile);
		}

}

// --------------------------------------------------------
// Afficher le hover des étoiles
// --------------------------------------------------------
function displayHover(ratingId, etoile)
{
	for (var i = 0; i <= etoile; i++)
	{
		document.getElementById('star_'+ratingId+'_'+i).setAttribute('src', './images/stars/rating_over.png');
	}
}

// --------------------------------------------------------
// Afficher normalement les étoiles
// --------------------------------------------------------
function displayNormal(ratingId, etoile)
{
	for (var i = 0; i <= etoile; i++)
	{
		var status = document.getElementById('star_'+ratingId+'_'+i).className;
		document.getElementById('star_'+ratingId+'_'+i).setAttribute('src', './images/stars/rating_'+status+'.png');
	}
}

// --------------------------------------------------------
// Voter
// --------------------------------------------------------
function vote(evt) {
	var tmp = evt.target.getAttribute('id').substr(5);
	var _id = tmp.substr(0, tmp.indexOf('_'));
	var etoileNbr = tmp.substr(tmp.indexOf('_')+1);

	$("#resultat_"+_id).html("Attendez SVP ...");

	// AJAX --> mise à jour des données
	$.get(
		  "./ajax.php" ,
		  { action: 'vote' , ID: _id , points: parseInt(etoileNbr)+1 } ,
		  function(data){ $("#resultat_"+_id).show("fast").html(data); }
		 );

	// Mise à jour du vote
	$("#rating_"+_id).show("fast").html(parseInt(etoileNbr)+1);
	resultatVote("rating_"+_id);
}

// --------------------------------------------------------
// Changerle rank d'une image
// --------------------------------------------------------
function changeRank(_idi,_nidi) {

	$("#reting_"+_idi).html(_nidi);

	init_votes();
}

// --------------------------------------------------------
// Initialiser l'affichage des étoiles
// --------------------------------------------------------
function init() {
	init_votes();
	$('div.rating img').click(vote);
}


