function date()
{       
	var now = new Date();

	var day = now.getDay();
	var date = now.getDate();
	var month = now.getMonth() +1;
	var year = now.getYear();
	var jour = "";
	var mois = "";

	if (year < 1900)
		year = year + 1900;

	if (day == 0)
		jour = "Dimanche";
	if (day == 1)
		jour = "Lundi";
	if (day == 2)
		jour = "Mardi";
	if (day == 3)
		jour = "Mercredi";
	if (day == 4)
		jour = "Jeudi";
	if (day == 5)
		jour = "Vendredi";
	if (day == 6)
		jour = "Samedi";

	if (month == 1)
		mois = "janvier";
	if (month == 2)
		mois = "f&eacute;vrier";
	if (month == 3)
		mois = "mars";
	if (month == 4)
		mois = "avril";
	if (month == 5)
		mois = "mai";
	if (month == 6)
		mois = "juin";
	if (month == 7)
		mois = "juillet";
	if (month == 8)
		mois = "ao&ucirc;t";
	if (month == 9)
		mois = "septembre";
	if (month == 10)
		mois = "octobre";
	if (month == 11)
		mois = "novembre";
	if (month == 12)
		mois = "d&eacute;cembre";



	return( jour + "  " + date + " " + mois   + " " + year );
}










function openwin(ow) {
url = '/maquette/pop.htm?' + ow;
fen = window.open(url,"fenetre","width=350,height=350,scrollbars=0,toolbar=0,menubar=0,location=0,resizable=yes,status=0");
}









function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}










function getByID(id)
{
	if (document.all)
	{
		return document.all(id) ;
	}
	if(document.getElementById)
	{
		return document.getElementById(id) ;
	}
	alert(id+' not found') ;
}

function hide(id)
{
	var o = getByID(id) ;
	if (o)
	{
		if (document.all)
		{
			o.display = "none" ;
		}
		if(document.getElementById)
		{
			o.style.display = "none" ;
		}
	}
}

function show(id)
{
	var o = getByID(id) ;
	if (o)
	{
		if (document.all)
		{
			o.display = "visible" ;
		}
		if(document.getElementById)
		{
			o.style.display = "block" ;
		}
	}
}




function afftest()
{
document.write('');
}









function popname(url,nom,toolb,loca,dir,sta,munub,scroll,resize,width,height,x,y)
{
open(url,nom,'toolbar='+toolb+',location='+loca+',directories='+dir+',status='+sta+',menubar='+munub+',scrollbars='+scroll+',resizable='+resize+',width='+width+',height='+height+',left=x,top=y').focus();
}





function pagedem()
{
var name = navigator.appName;
var useragent = navigator.userAgent;
//alert(useragent);

if ( useragent.indexOf("MSIE") != -1) {
        var evenemento = "this.style.behavior='url(#default#homepage)';this.setHomePage('http://www.letelegramme.com');return false;";
        document.write('<div class="MENU-TOP"><span class="MENU-TXT">&nbsp;</span></div>');
        document.write('<div class="MENUP-TOP"><a class="MENU-TXT" href="#" onClick='+evenemento+'>Démarrer avec LeTélégramme.com</a></div>');
        }
}


//Fonction de Maxime
function select_val(id,val)
{
	sel = document.getElementById(id);
	for (i=0;i<sel.options.length;i++)
	{
		if (sel.options[i].value == val)
			sel.options[i].selected = true;
	}
}

function frm_contact(id_select)
{
	select_val('objet',id_select);
	document.getElementById("td_titre_contact").innerHTML = "Nous Contacter";
	document.getElementById("select_objet").style.visibility = "visible";
	if(id_select==3) 
	{
		document.getElementById("td_titre_contact").innerHTML = "Signalez un contenu illicite";
		document.getElementById("select_objet").style.visibility = "hidden";
		document.getElementById("objet").style.visibility = "hidden";
	}
	
	
	ShowForm('CONTACT');
}

function frm_ami(art,url,titre,date)
{
	frm = document.forms['env_mail'];
	frm.elements['art'].value	= art;
	frm.elements['url'].value	= url;
	frm.elements['titre'].value	= titre;
	frm.elements['date'].value	= date;
	document.getElementById('td_titre').innerHTML = titre;
	ShowForm('AMI');

}

function mess_contact(type)
{
	if (type != "")
	{
		var div = 'MESSAGE';
		var td = 'td_message';
		switch(type)
		{
			case 'ok':
				mess = "Votre message a été envoyé.";
				break;
			case 'no':
				mess = "Pour des raisons techniques ind&eacute;pendant de notre volont&eacute;, le mail n'a pu être envoy&eacute;e.<br>Veuillez nous en excuser et r&eacute;-essayer ult&eacute;rieurement.";
				break;
			case 'forum_connect':
				mess = "Vous êtes connecté au forum des éléctions municipales 2008 du Télégramme";
				break;
			case 'forum_oubli_mdp':
				mess = "Votre mot de passe vous a été transmis par mail";
				break;
			case 'forum_register':
				mess = "Votre compte est créé. Vous allez recevoir un mail de confirmation.";
				break;				
		}
		if (mess != '')
		{
			document.getElementById(td).innerHTML = mess;
			ShowForm(div);
		}
	}
}

function verif_img(elem)
{
	elem.src = "/static/images/municipales/candidats/noimage.gif";
}
function verif_img_res(elem)
{
	elem.src = "/static/images/municipales/candidats/candidat0.jpg";
}


// <!-- Pagination javascript par Maxime
function pagination(nb_liste_lien, nb_page, nb_par_page, nb_elem)
{
	this.nll	= parseInt(nb_liste_lien);
	this.np		= parseInt(nb_page);
	this.npp	= parseInt(nb_par_page);
	this.ne		= parseInt(nb_elem);
	this.p		= 1;

	function start()
	{
		this.liens();
		this.afficher_page();
	}
	this.start = start;

	function page_suivante()
	{
		if (this.p < this.np)
			this.p++;
		this.start();
	}
	this.page_suivante = page_suivante;

	function page_precedente()
	{
		if (this.p > 1)
			this.p--;
		this.start();
	}
	this.page_precedente = page_precedente;

	function page_num(num)
	{
		num = parseInt(num);
		if ((num >= 1) && (num <= this.np))
			this.p = num;
		this.start();
	}
	this.page_num = page_num;

	function liens()
	{
		for(i=0;i<this.nll;i++)
		{
			if (this.p == 1)
				this.cacher('page_prec_'+i);
			else
				this.afficher('page_prec_'+i);
			if (this.p == nb_page)
				this.cacher('page_suiv_'+i);
			else
				this.afficher('page_suiv_'+i);
			for(i2=1;i2<=this.np;i2++)
			{
				if (i2 == this.p)
				{
					this.afficher('page_span_'+i+'_'+i2);
					this.cacher('page_a_'+i+'_'+i2);
				}
				else
				{
					this.afficher('page_a_'+i+'_'+i2);
					this.cacher('page_span_'+i+'_'+i2);
				}
			}
				
		}
	}
	this.liens = liens;

	function afficher_page()
	{
		var p_start	= (this.p*this.npp)-this.npp;
		var p_end	= (this.p*this.npp)-1;
		if (p_end > this.ne)
			p_end = this.ne;
		for(i=0;i<this.ne;i++)
		{
			if ((i >= p_start) && (i <= p_end))
				this.afficher('page_elem_'+i);
			else
				this.cacher('page_elem_'+i);
		}
	}
	this.afficher_page = afficher_page;

	function afficher(id)
	{
		if (document.getElementById(id).tagName == "TR")
			document.getElementById(id).style.display = "";
		else
			document.getElementById(id).style.display = "inline";
	}
	this.afficher = afficher;

	function cacher(id)
	{
		document.getElementById(id).style.display = "none";
	}
	this.cacher = cacher;
}
// Pagination javascript -->

// Autres reprises

function Valid(frm)
{
	var nom =  frm.nom.value;
	var mail =  frm.email.value;
	var mask = /^[a-zA-Z0-9_-][a-zA-Z0-9._-]+@[a-zA-Z0-9._-]+\.([a-zA-Z]{2,3})$/;
	var error='';
	if (nom == '') error += "- veuillez saisir votre nom\n";
	if (mail == '') error += "- veuillez saisir votre email\n";
	if(!mail.match(mask)) error += "- votre adresse mail est non valide\n";
	if(error.length > 0) alert(error);
	else frm.submit();
}

function ctrl_champ()
{
        f       = document.env_mail;
        to	= f.to.value;
        from    = f.from.value;
        code    = f.code_chk.value;
	err	= '';

        if( from=="" || to == "")
                err += "Veuillez saisir les champs obligatoires !\n";
        if(!verif_email(from) )
                err += "Vérifier votre adresse email !\n";
        if(!verif_email(to) )
                err += "Vérifier l'adresse email de votre destinataire !\n";
        if(code=='')
                err += "Vérifier saisir le code de sécurité !\n";
	if (err != '')
		alert(err);
	else
	        f.submit();
}

function verif_email(mail)
{
	var mask = /^[a-zA-Z0-9_-][a-zA-Z0-9._-]+@[a-zA-Z0-9._-]+\.([a-zA-Z]{2,3})$/;
	if(!mail.match(mask))
		return false;
	else
		return true;
}

function check_cookie_forum()
	{
	if(cookie_forum !='')
		{
		var reg=new RegExp("[=&]+", "g");
		t_forum_cookie=cookie_forum.split(reg);
		//for (var i=0; i<t_forum_cookie; i++) {
		//	document.write("t_forum_cookie[" + i + "] = " + t_forum_cookie[i] + "<BR>");
		//	}
		return true;
		}
	else return false;
	}
	
function show_sond(id_titre,id_sond,id_res,url_res)
	{
	document.getElementById(id_titre).style.display="none";
	document.getElementById(id_sond).style.display="block";
	document.getElementById(id_res).innerHTML="<a href=# onclick=\"javascript:hide_sond('"+id_titre+"','"+id_sond+"','"+id_res+"','"+url_res+"');\" class=bleu10 >Masquer les résultats</a>&nbsp;|&nbsp;";
	document.getElementById(id_sond).innerHTML="<iframe name=\"sondage_comm_detail\" marginwidth=0 hspace=0 width=340 frameborder=no border=0 scrolling=yes style=\"height:110px\" src="+url_res+"></iframe>";						  	
	}
function hide_sond(id_titre,id_sond,id_res,url_res)
	{
	document.getElementById(id_titre).style.display="block";
	document.getElementById(id_sond).style.display="none";
	document.getElementById(id_res).innerHTML="<a href=# onclick=\"javascript:show_sond('"+id_titre+"','"+id_sond+"','"+id_res+"','"+url_res+"');\" class=bleu10 >Voir les résultats</a>&nbsp;|&nbsp;";
	document.getElementById(id_sond).innerHTML="";
	}

function verif_sond(insee,type,frm)
	{
	if(vcook_sond.length==0) return null; 
	id_sond=frm.snd_id.value;
		
	if(id_sond=='') return null;
	
	for(i=0;i<vcook_sond.length;i++)
		{
		if(vcook_sond[i]==id_sond)
			{
			switch(type)
				{
				case 'comm': document.location.href="/sondage/resultats_commune.php?id="+id_sond+"&insee="+insee;
					break;
				case 'gr': document.location.href="/sondage/resultats.php?id="+id_sond+"&w=300";
					break;
				default : return null;break;
				}
			}
		}
	return null;
	}
	
//Fonction de Maxime
function tailleImage(elem,h,w)
{
	var img = new Image();
	img.src = elem.src;
	if (img.height > h || img.width > w)
	{
		var nh;
		var nw;
		if (img.height > img.width)
		{
			nw = img.width / img.height * h;
			nh = h;
		}
		else
		{
			nh = img.height / img.width * w;
			nw = w;
		}
		elem.height = nh;
		elem.width = nw;
	}
}
	

/*
function LireCookie(nom)
{
var arg=nom+"=";
var alen=arg.length;
var clen=document.cookie.length;
var i=0;
while (i<clen)
{
var j=i+alen;
if (document.cookie.substring(i, j)==arg) return getCookieVal(j);
i=document.cookie.indexOf(" ",i)+1;
if (i==0) break;

}
return null;
}
*/
	
