
// JavaScript Document
function tabmouseover(id)
{
	var conid = 'tab';

	conid = conid.concat(id);
	var tabID = document.getElementById(conid);

	if (tabID.style.display == 'none')
	{

		new Effect.Appear(conid, {duration: 0.5});
		hideaftertime(id);
	}
}

function hideaftertime(id)
{
	var func = "hidetab(";
	func = func.concat(id);
	func = func.concat(")");
	setTimeout(func,2500);
}

function hidetab(id)
{
	var tab = 'tab';
	tab = tab.concat(id);
	if (document.getElementById(tab))
	{
		new Effect.Fade(tab, {duration: 0.5});
	}
}

function loggajax(){


  new Ajax.Request('/index.php?up=1&nom_utilisateur='+document.getElementById('nom_utilisateur').value+'&mot_passe='+document.getElementById('mot_passe').value+'&bloc=logginfo', {asynchronous:true, onComplete: succesRetourAjax, onFailure: erreurRetourAjax});

new Ajax.Updater('zone_login', '/index.php?up=1&bloc=logg', {asynchronous:true,  onFailure: erreurRetourAjax,onComplete:function(){
  load = 'zone_login';
	load = document.getElementById(load);
	new Effect.Appear(load, {duration: 0.5});
}
});		

}

function succesRetourAjax (t)
{

var aRemplacer = /\n/g; 
machaine = t.responseText.replace(aRemplacer, "") 


    if (machaine == " succes")
    {
  load = 'zone_login';

	load = document.getElementById(load);
	load.style.display = 'none';
	Effect.Fade('edwarning', {duration: 0.2});
    }
    else
    {

  Effect.Shake('zone_login');
  Effect.Appear('edwarning',{duration:2.0, transition:Effect.Transitions.wobble});
  Effect.Fade('edwarning', {duration: 3.0});       
    }
}

function erreurRetourAjax (t)
{
          Effect.Shake('zone_login');
          Effect.Appear('edwarning',
            {duration:2.0, transition:Effect.Transitions.wobble});
              Effect.Fade('edwarning', {duration: 3.0});

}

function logout(){
  new Ajax.Updater('zone_login', '/index.php?up=1&bloc=logg_out', {asynchronous:true, onSuccess: function() {
	load = 'zone_login';
	load = document.getElementById(load);
	load.style.display = 'none';
	new Effect.Appear(load, {duration: 0.5});
		}});
}

function affiche(id,bloc){
new Ajax.Updater(id, '/index.php?up=1&bloc='+bloc, {asynchronous:true,  onFailure: function(){},onComplete:function(){
	new Effect.ScrollTo(id);
	new Effect.Appear(id, {duration: 0.5});
		}});
}

function afficheporteouverte(id,bloc,id_utilisateur){
new Ajax.Updater(id, '/index.php?up=1&id_utilisateur='+id_utilisateur+'&bloc='+bloc, {asynchronous:true,  onFailure: function(){},onComplete:function(){
	new Effect.ScrollTo(id);
	new Effect.Appear(id, {duration: 0.5});
		}});
}

function affichecontactannonce(id,bloc,id_utilisateur,id_annonce){
new Ajax.Updater(id, '/index.php?up=1&id_utilisateur='+id_utilisateur+'&id_annonce='+id_annonce+'&bloc='+bloc, {asynchronous:true,  onFailure: function(){},onComplete:function(){
	new Effect.ScrollTo(id);
	new Effect.Appear(id, {duration: 0.5});
		}});
}

function inscriptionajax(type){

 var  civilite=false;
 var  type;
 if (document.getElementById('civilite1').checked==true)
 {
civilite=document.getElementById('civilite1').value;
 }
  else if (document.getElementById('civilite2').checked==true)
 {
civilite=document.getElementById('civilite2').value;
 }
 else if (document.getElementById('civilite3').checked==true)
 {
civilite=document.getElementById('civilite3').value;
 }
 
 if (document.getElementById('cguvalid').checked==true)
 {
cguvalid='1';
}else{
cguvalid='0';
}


  new Ajax.Request('/index.php?up=1&newscont=enregistrement&localite_i='+document.getElementById('localite_i').value+'&mot_passe='+document.getElementById('mot_passe_i').value+'&nom_utilisateur='+document.getElementById('nom_utilisateur_i').value+'&prenom='+document.getElementById('prenom').value+'&nom_famille='+document.getElementById('nom_famille').value+'&civilite='+civilite+'&email='+document.getElementById('email').value+'&cguvalid='+cguvalid+'&type='+type+'&bloc=inscriptioninfo', {asynchronous:true, onComplete: succesinscriptionRetourAjax, onFailure: erreurinscriptionRetourAjax});

new Ajax.Updater('forminscription', '/index.php?up=1&newscont=enregistrement&localite_i='+document.getElementById('localite_i').value+'&mot_passe='+document.getElementById('mot_passe_i').value+'&nom_utilisateur='+document.getElementById('nom_utilisateur_i').value+'&prenom='+document.getElementById('prenom').value+'&nom_famille='+document.getElementById('nom_famille').value+'&civilite='+civilite+'&email='+document.getElementById('email').value+'&cguvalid='+cguvalid+'&type='+type+'&bloc=inscription', {asynchronous:true,  onFailure: erreurinscriptionRetourAjax,onComplete:function(){
  load = 'forminscription';
	load = document.getElementById(load);
	new Effect.ScrollTo('forminscription');
	new Effect.Appear(load, {duration: 0.5});
}
});		

}

function succesinscriptionRetourAjax (t)
{
var aRemplacer = /\n/g; 
machaine = t.responseText.replace(aRemplacer, "") 
    if (machaine == "succes")
    {
  load = 'forminscription';
	load = document.getElementById(load);
	load.style.display = 'none';
	Effect.Fade('edwarninginscription', {duration: 0.2});
    }
    else
    {
  Effect.Shake('forminscription');
  Effect.Appear('edwarninginscription',{duration:2.0, transition:Effect.Transitions.wobble});
  Effect.Fade('edwarninginscription', {duration: 3.0});       
    }
}

function erreurinscriptionRetourAjax (t)
{
          Effect.Shake('forminscription');
          Effect.Appear('edwarninginscription',
            {duration:2.0, transition:Effect.Transitions.wobble});
              Effect.Fade('edwarninginscription', {duration: 3.0});

}


function contactajax(){

  new Ajax.Request('/index.php?up=1&newscont=contact&ville_contact='+document.getElementById('ville_contact').value+'&prenom_contact='+document.getElementById('prenom_contact').value+'&nom_famille_contact='+document.getElementById('nom_famille_contact').value+'&email_contact='+document.getElementById('email_contact').value+'&pays_contact='+document.getElementById('pays_contact').value+'&commentaire_contact='+document.getElementById('commentaire_contact').value+'&cp_contact='+document.getElementById('cp_contact').value+'&adresse_contact='+document.getElementById('adresse_contact').value+'&bloc=contactinfo', {asynchronous:true, onComplete: succescontactRetourAjax, onFailure: erreurcontactRetourAjax});

new Ajax.Updater('forminscription', '/index.php?up=1&newscont=contact&ville_contact='+document.getElementById('ville_contact').value+'&prenom_contact='+document.getElementById('prenom_contact').value+'&nom_famille_contact='+document.getElementById('nom_famille_contact').value+'&email_contact='+document.getElementById('email_contact').value+'&pays_contact='+document.getElementById('pays_contact').value+'&commentaire_contact='+document.getElementById('commentaire_contact').value+'&cp_contact='+document.getElementById('cp_contact').value+'&adresse_contact='+document.getElementById('adresse_contact').value+'&bloc=contact', {asynchronous:true,  onFailure: erreurcontactRetourAjax,onComplete:function(){
  load = 'forminscription';
	load = document.getElementById(load);
	new Effect.ScrollTo('forminscription');
	new Effect.Appear(load, {duration: 0.5});
}
});		

}

function contactporteouverteajax(id){
var id;
  new Ajax.Request('/index.php?up=1&id_utilisateur='+id+'&newscont=contactporteouverte&tel_contact='+document.getElementById('tel_contact').value+'&prenom_contact='+document.getElementById('prenom_contact').value+'&nom_famille_contact='+document.getElementById('nom_famille_contact').value+'&email_contact='+document.getElementById('email_contact').value+'&commentaire_contact='+document.getElementById('commentaire_contact').value+'&bloc=contactporteouverteinfo', {asynchronous:true, onComplete: succescontactRetourAjax, onFailure: erreurcontactRetourAjax});

new Ajax.Updater('forminscription', '/index.php?up=1&id_utilisateur='+id+'&newscont=contactporteouverte&tel_contact='+document.getElementById('tel_contact').value+'&prenom_contact='+document.getElementById('prenom_contact').value+'&nom_famille_contact='+document.getElementById('nom_famille_contact').value+'&email_contact='+document.getElementById('email_contact').value+'&commentaire_contact='+document.getElementById('commentaire_contact').value+'&bloc=contactporteouverte', {asynchronous:true,  onFailure: erreurcontactRetourAjax,onComplete:function(){
  load = 'forminscription';
	load = document.getElementById(load);
	new Effect.ScrollTo('forminscription');
	new Effect.Appear(load, {duration: 0.5});
}
});		

}

function contactannonceajax(id,id_annonce){
var id;
var id_annonce;
  new Ajax.Request('/index.php?up=1&id_utilisateur='+id+'&id_annonce='+id_annonce+'&newscont=contactannonce&tel_contact='+document.getElementById('tel_contact').value+'&prenom_contact='+document.getElementById('prenom_contact').value+'&nom_famille_contact='+document.getElementById('nom_famille_contact').value+'&email_contact='+document.getElementById('email_contact').value+'&commentaire_contact='+document.getElementById('commentaire_contact').value+'&bloc=contactannonceinfo', {asynchronous:true, onComplete: succescontactRetourAjax, onFailure: erreurcontactRetourAjax});

new Ajax.Updater('reponseannonce', '/index.php?up=1&id_utilisateur='+id+'&id_annonce='+id_annonce+'&newscont=contactannonce&tel_contact='+document.getElementById('tel_contact').value+'&prenom_contact='+document.getElementById('prenom_contact').value+'&nom_famille_contact='+document.getElementById('nom_famille_contact').value+'&email_contact='+document.getElementById('email_contact').value+'&commentaire_contact='+document.getElementById('commentaire_contact').value+'&bloc=contactannonce', {asynchronous:true,  onFailure: erreurcontactRetourAjax,onComplete:function(){
  load = 'reponseannonce';
	load = document.getElementById(load);
	new Effect.ScrollTo('reponseannonce');
	new Effect.Appear(load, {duration: 0.5});
}
});		

}

function pubajax(){

  new Ajax.Request('/index.php?up=1&newscont=pub&ville_contact='+document.getElementById('ville_contact').value+'&prenom_contact='+document.getElementById('prenom_contact').value+'&nom_famille_contact='+document.getElementById('nom_famille_contact').value+'&email_contact='+document.getElementById('email_contact').value+'&pays_contact='+document.getElementById('pays_contact').value+'&commentaire_contact='+document.getElementById('commentaire_contact').value+'&cp_contact='+document.getElementById('cp_contact').value+'&adresse_contact='+document.getElementById('adresse_contact').value+'&bloc=pubinfo', {asynchronous:true, onComplete: succescontactRetourAjax, onFailure: erreurcontactRetourAjax});

new Ajax.Updater('forminscription', '/index.php?up=1&newscont=pub&ville_contact='+document.getElementById('ville_contact').value+'&prenom_contact='+document.getElementById('prenom_contact').value+'&nom_famille_contact='+document.getElementById('nom_famille_contact').value+'&email_contact='+document.getElementById('email_contact').value+'&pays_contact='+document.getElementById('pays_contact').value+'&commentaire_contact='+document.getElementById('commentaire_contact').value+'&cp_contact='+document.getElementById('cp_contact').value+'&adresse_contact='+document.getElementById('adresse_contact').value+'&bloc=pub', {asynchronous:true,  onFailure: erreurcontactRetourAjax,onComplete:function(){
  load = 'forminscription';
	load = document.getElementById(load);
	new Effect.ScrollTo('forminscription');
	new Effect.Appear(load, {duration: 0.5});
}
});		

}

function succescontactRetourAjax (t)
{
var aRemplacer = /\n/g; 
machaine = t.responseText.replace(aRemplacer, "") 
    if (machaine == "succes")
    {
  load = 'forminscription';
	load = document.getElementById(load);
	load.style.display = 'none';
	Effect.Fade('edwarninginscription', {duration: 0.2});
    }
    else
    {
  Effect.Shake('forminscription');
  Effect.Appear('edwarninginscription',{duration:2.0, transition:Effect.Transitions.wobble});
  Effect.Fade('edwarninginscription', {duration: 3.0});       
    }
}

function erreurcontactRetourAjax (t)
{
          Effect.Shake('forminscription');
          Effect.Appear('edwarninginscription',
            {duration:2.0, transition:Effect.Transitions.wobble});
              Effect.Fade('edwarninginscription', {duration: 3.0});

}


function oublipassajax(mail){

new Ajax.Updater('oubli_pass', '/index.php?up=1&email='+mail+'&bloc=oubli_pass&newscont=oubli_mot_passe', {asynchronous:true,  onFailure: erreuroublipassRetourAjax,onComplete:function(){
  load = 'oubli_pass';
	load = document.getElementById(load);
	new Effect.Appear(load, {duration: 0.5});
}
});
}

function erreuroublipassRetourAjax (t)
{
          Effect.Shake('oubli_pass');


}

function chargemodule(module,id){
if(module=="inscription"){
afficheinscription();
}else if(module=="annu"){
afficheannu(id);
}else if(module=="date"){
affichecontenu(id);
}
}

function setTimeZone() {


	
timezone = "EDT";
var visitortime = new Date();

  new Ajax.Request('/timezone-controller.php?epoch='+visitortime.getTime()/1000+'&timezoneoffset='+visitortime.getTimezoneOffset()/60+'&rien=0', {asynchronous:true, onComplete:function(){}, onFailure:function(){}});
  







} 

function $RF(radioName){ 
  array=$$('input'); 
  var value=""; 
   
  array.each( 
    function (radio){ 
      if (radio.hasAttribute("name") && radio.readAttribute("name")==radioName) 
        if (radio.checked=="true" || radio.checked) value=radio.getValue();  
    } 
  );//End of each() 
  return value;  
} 

function votesondage(id){

 var  choix=false;


choix=$RF("choix");

if(choix){
new Ajax.Updater('sondage', '/index.php?up=1&sondage_en_cours='+id+'&choix='+choix+'&bloc=sondage', {asynchronous:true,  onFailure: erreuroublipassRetourAjax,onComplete:function(){


	new  Effect.Appear('merci',{duration:2.0, transition:Effect.Transitions.wobble});
  new Effect.Fade('merci', {duration: 4.0});

}
});
}else{
  load = 'erreur';
	load = document.getElementById(load);
	new Effect.Shake('sondage');
	new Effect.Appear(load, {duration: 0.5});
}
}

function ajoutnewsletter(){

email_newsletter=document.getElementById('email_newsletter').value;

if(email_newsletter){
new Ajax.Updater('newsletter', '/index.php?up=1&email_newsletter='+email_newsletter+'&bloc=newsletter', {asynchronous:true,  onFailure: erreuroublipassRetourAjax,onComplete:function(){
	new  Effect.Appear('mercinewsletter',{duration:2.0, transition:Effect.Transitions.wobble});
  new Effect.Fade('mercinewsletter', {duration: 4.0});

}
});
}else{
  load = 'erreurnewsletter';
	load = document.getElementById(load);
	new Effect.Shake('newsletter');
	new Effect.Appear(load, {duration: 0.5});
}
}

function abuscom(id){
input = confirm('Etes vous sur de vouloir signaler ce commentaire ?');
if (input==true)
{
new Ajax.Request('/index.php?up=1&id_com='+id+'&bloc=abuscom', {asynchronous:true, onComplete:function(){
alert('Ce commentaire a été signalé aux modérateurs du site, Merci.')
}, onFailure:function(){}});
}
}


function affichenote(t){
new Ajax.Updater('note', '/index.php?up=1&bloc=note&t='+t, {asynchronous:true,  onFailure: function(){},onComplete:function(){
  load = 'note';
	load = document.getElementById(load);
	new Effect.Appear(load, {duration: 0.5});
		}});
}

function affichepluslu(t){
new Ajax.Updater('pluslu', '/index.php?up=1&bloc=pluslu&t='+t, {asynchronous:true,  onFailure: function(){},onComplete:function(){
  load = 'pluslu';
	load = document.getElementById(load);
	new Effect.Appear(load, {duration: 0.5});
		}});
}

function affichereactor(t){
new Ajax.Updater('reactor', '/index.php?up=1&bloc=reactor&t='+t, {asynchronous:true,  onFailure: function(){},onComplete:function(){
  load = 'reactor';
	load = document.getElementById(load);
	new Effect.Appear(load, {duration: 0.5});
		}});
}

function Flash(swf, hauteur, largeur, couleur, nom, remp) {
document.write('<object type="application/x-shockwave-flash" data="'+swf+'" width="'+hauteur+'" height="'+largeur+'">'+"\n");
document.write('<param name="movie" value="'+swf+'" />'+"\n");
document.write('<param name="bgcolor" value="'+couleur+'" />'+"\n");
document.write('<param name="quality" value="high" />'+"\n");
document.write('<param name="movie" value="'+swf+'" />'+"\n");
document.write(remp+"\n");
document.write("</object>\n");
}

function ajoutfavoris(favoris,type)
{

alert('Vous devez être inscrit et identifié pour pouvoir utiliser les favoris');

}

function deletefavoris(favoris,id)
{
request = 'bloc=deletefavoris';
	request = request.concat('&up=1');
	request = request.concat('&favoris=');
	request = request.concat(favoris);

	input = confirm('Supprimer ce favoris ?');
				if (input==true)
				{
				new Ajax.Request('/index.php', {method:'post', postBody: request, onSuccess: function(t) {
 				comment = 'favoris';
 				comment= comment.concat(id);
				new Effect.Fade(comment, {duration: 0.5, afterFinish: function(){ }
        });
					}});
	}
}

function pourquoiimprimer(id){

	input = confirm('Est-ce bien nécessaire ? pensez à l\'environnement avant d\'imprimer');
				if (input==true)
				{
				window.location.replace("/articles/imprimer.php?aid="+id);

				}
}

function PopupImage(img) {
titre="Cause-depart";
w=open("",'image','width=800,height=600,toolbar=no,scrollbars=no,resizable=no');
w.document.write("<HTML><HEAD><TITLE>"+titre+"</TITLE></HEAD>");
w.document.write("<SCRIPT language=javascript>function checksize() { if (document.images[0].complete) { window.resizeTo(document.images[0].width+12,document.images[0].height+30); window.focus();} else { setTimeout('check()',250) } }</"+"SCRIPT>");
w.document.write("<BODY onload='checksize()' leftMargin=0 topMargin=0 marginwidth=0 marginheight=0><IMG src='"+img+"' border=0>");
w.document.write("");
w.document.write("</BODY></HTML>");
w.document.close();
} 

default_size = 12;
function plusFont(classe){
	default_size++;
	cibles = document.getElementById(classe);
	cibles.style.fontSize = default_size + "px";

	return false;
}
function moinsFont(classe){
	default_size--;
	cibles = document.getElementById(classe);
	cibles.style.fontSize = default_size + "px";

	return false;
}




