
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 = "block" ;
		}
		if(document.getElementById)
		{
			o.style.display = "block" ;
		}
	}
}










function showHide(elem) {
	if (elem.style.display=='block') {
		elem.style.display='none';
	}
	else {
		elem.style.display='block';
	}
}









function hideReacPages()
{
	for (i=0; i<document.getElementsByTagName('div').length; i++)
		{
		if (document.getElementsByTagName('div')[i].className == "reac-page")
			{
			document.getElementsByTagName('div')[i].style.display = "none";
			}
		}
}









function getElementsByClassName(className, tag, elm){
	var testClass = new RegExp("(^|s)" + className + "(s|$)");
	var tag = tag || "*";
	var elm = elm || document;
	var elements = (tag == "*" && elm.all)? elm.all : elm.getElementsByTagName(tag);
	var returnElements = [];
	var current;
	var length = elements.length;
	for(var i=0; i<length; i++){
		current = elements[i ];
		if(testClass.test(current.className)){
			returnElements.push(current);
		}
	}
	return returnElements;
}

/*
function tailletexte(class,taille)
{
	var o = getElementsByClassName(class) ;
	if (o)
	{
		if (document.all)
		{
			o.fontSize = taille ;
		}
		if(document.getElementsByClassName)
		{
			o.style.fontSize = taille ;
		}
	}
}
*/

/*
function tailletexte(id,taille)
{
	var o = getByID(id) ;
	if (o)
	{
		if (document.all)
		{
			o.fontSize = taille ;
		}
		if(document.getElementById)
		{
			o.style.fontSize = taille ;
		}
	}
}
*/

function tailletexte(id,taille)
{



	var o = getByID(id) ;
	if (o)
	{
		if (document.all)
		{
			o.fontSize = taille ;
		}
		if(document.getElementById)
		{
			o.style.fontSize = taille ;
		}
	}



	var oo = getElementsByClassName(id) ;
	if (oo)
	{
		if (document.all)
		{
			oo.fontSize = taille ;
		}
		if(document.getElementsByClassName.p)
		{
			oo.style.fontSize = taille ;
		}
		if(document.getElementsByClassName.h3)
		{
			oo.style.fontSize = taille ;
		}
	}



}










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 affOutils(id_art,esc_titre,url_enc_titre,url_enc_page,rub_uri,is_archive)
{
classe=is_archive?'outils-arch':"";
document.write('	<div class="outils '+classe+'" style="height:15px;" >');
document.write('		<a class="print" href="/dyn/imprimer.php?link='+url_enc_page+'" target="_blank" title="Imprimer">Imprimer</a>');
$joliprint().set("label","PDF").set("labelposition","after").set("buttonUrl", "http://eu.joliprint.com/res/joliprint/img/buttons/default/pdf-icone.gif").set( "target", "_blank" ).write();
document.write('		<a class="ami" id="envoi_ami"  titre_article="'+esc_titre+'" id_article="'+id_art+'" href="javascript:void(0)" title="Envoyer à un ami">Envoyer à un ami</a>');
if(typeof(rub_uri)!='undefined' && rub_uri !='') {
document.write('		<a class="rss" target="_blank"  href="'+rub_uri+'rss.xml" title="RSS">Flux RSS</a>');
}
if(!is_archive){
	document.write('		<span class="partager">Partager</span>');
	document.write('		<a  target="_blank" href="http://www.wikio.fr/vote?url='+url_enc_page+'"title="wikio" target="_blank" ><img class="wikio" src="/img/trans.gif" /></a>');
	document.write('		<a  target="_blank" href="http://www.facebook.com/share.php?u='+url_enc_page+'" target="_blank" title="Facebook"><img class="facebook" src="/img/trans.gif" /></a>');
	document.write('		<a href="http://twitter.com/timeline/home?status=Lu%20sur%20%40elwatan%20'+url_enc_titre+'%20'+url_enc_page+'" target="_blank" title="Twitter"><img class="twitter" src="/img/trans.gif" /></a>');
	//document.write('		<a href="http://twitter.com/share" class="twitter-share-button" target="_blank" data-count="none" data-via="elwatancom" data-lang="fr" title="Twitter"><img class="twitter" src="/img/trans.gif" /></a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script>');
	document.write('		<a  target="_blank" href="http://www.digg.com/submit?phase=2&amp;url='+url_enc_page+'" title="Diggit" target="_blank" ><img class="diggit" src="/img/trans.gif" /></a>	</div>');
}else{
	document.write('</div><div class="clear">&nbsp;</div>');
}
}

var pdfs = 1;
/************************************/
//parametre lightbox
/***********************************/
var params_lightBox = {
	imageLoading:"/js/jquery-lightbox/images/lightbox-ico-loading.gif",
	imageBtnClose:"/img/diapo_close.gif",
	imageBtnPrev:"/img/diapo_prec.gif",
	imageBtnNext:"/img/diapo_suiv.gif",
	imageBlank:"/js/jquery-lightbox/images/lightbox-blank.gif",
	txtOf:"sur"		
};
/**********************************/
//variable pour le film foto
/**********************************/
var first_film=0;
var last_film = 4;
var last_action="";
var params_film = {width: 'toggle',border:'toggle'};
/********************************/
//fonction et variable du menu
/********************************/
var id_current,id_rub,timer_menu;

function cacheMenu(){
	$("#header_"+id_rub).addClass('off');	
	$('div[id^="'+id_rub+'"]').hide();
	if($("#header_"+id_current).size()){
		$('div[id^="'+id_current+'"]').show();
		$("#header_"+id_current).removeClass('off');
	}
}
function afficheMenu(){
if(id_rub != id_current){
$("#header_"+id_rub).removeClass('off');
        $('div[id^="'+id_rub+'"]').show();
        if($("#header_"+id_current).size()){
                $('div[id^="'+id_current+'"]').hide();
                $("#header_"+id_current).addClass('off');
        }
}

}
/***************************/
//execution dans le flux
/***************************/
$(document).ready(function(){

	/**
	 *film foto
	 */
	$('a[class^="film_"]').click(function(){
		if($(this).hasClass('film_l') && last_action =='r'){
			if(first_film){
				first_film--;
                        	last_film--;
			}
		}
		if($(this).hasClass('film_r') && last_action =='g'){
			first_film++;
                        last_film++;
		}
		$('img','.film a:eq('+first_film+')').animate(params_film, 1000);
		$('img','.film a:eq('+last_film+')').animate(params_film, 1000);
		if($(this).hasClass('film_l')){
			last_action='g';
			if(!first_film){
				$(this).hide();
				last_action="";
			}else{
				$('.film_r').show();
				first_film--;
				last_film--;
			}
		
		}else{
			last_action='r';

			if(last_film>=(($('img','.film').length)-1)){
				$(this).hide();
				last_action="";
	
			}else{
				$('.film_l').show();
				first_film++;
				last_film++;

			}
		}
		
	});
	/********************************************************/
	// lightbox
	/*******************************************************/		
	$('.zoom').lightBox(params_lightBox);
	$('a[class^="img_zoom"]').each(function(){
		$(this).lightBox(params_lightBox);
	});	
	$('a','.film').lightBox(params_lightBox);
	
	$('img[class^="f-"]').click(function(){
		$("tr",".news").toggle();							
	});

	$('td','.nav-pdf').click(function(){	
		$('th','.nav-pdf').toggle();	
	});
	/*****************************************************/
	//Menu header
	/****************************************************/
	$('div[id^="header_"]').mouseover(
		function(){
			//alert(id_current);
		
			if($('#header_'+id_rub).size()){
				$('#header_'+id_rub).addClass('off');
				$('div[id^="'+id_rub+'"]').hide();
			}
			
			id_current = $(".on",$(this).parent()).size()?$(".on",$(this).parent()).attr('id').split('_')[1]:$(this).attr('id').split('_')[1];
			if($('#header_'+id_current).size()){
				$('#header_'+id_current).addClass('off');
	        		$('div[id^="'+id_current+'"]').hide();
			}
			id_rub = $(this).attr('id').split('_')[1];
					
			$('div[id^="'+id_rub+'"]').show();
	
			$(this).removeClass('off');
				
						
		}
	);
	$('.nav-l2').hover(function(){
	afficheMenu();
	},function(){
	cacheMenu();	
	id_rub=id_current;		
	});
	$("div[id^=header_").mouseleave(function(){
		cacheMenu();
		
	});
	$('#header_'+id_current).unbind('mouseleave');
	/**********************************************/
	//imgade legende
	/*********************************************/
	var truncate_leg;
	$('#foto-leg').mouseover(
		function(){
		$(this).hide();	
		$("#foto-leg-cache").show();
		});

	$('#foto-leg-cache').mouseout(function(){

		$(this).hide();
			$("#foto-leg").show();

		});
	
/******************************************************/
// date picker pour archive
/******************************************************/
	$('#archive_date').click(function(){
		var date = new Date();
		timestamp = parseInt(date.getTime());
		//alert('timestamp : '+timestamp+' -24*60*60*1000 ='+(timestamp-(24*60*60*1000)));
		timestamp -=(24*60*60*1000);//1jour	

		date.setTime(timestamp);
		date = date.getFullYear()+'-'+(date.getMonth()+1)+'-'+date.getDate();
	
		$(this).after('<input type="hidden" id="datepicker" />');
		$('embed, object, select').css({ 'visibility' : 'hidden' });
		var nav_index =  $('#nav').css('z-index');
		$('#nav').css('z-index','0');

		$('#datepicker').datepicker({
			'changeYear' :true, 
			'minDate' : '2004-07-01',
			'dateFormat' : 'yy-mm-dd',
			'maxDate' : date,
			'onSelect' : function(dateText, inst){location.href='/archives/edition.php?ed='+dateText},
			'onClose' : function(){$('embed, object, select').css({ 'visibility' : 'visible' });$('#nav').css('z-index',nav_index);}
		});
		$('#ui-datepicker-div').css('z-index','1000');
		// le datepicker se lançant au focus.	
		$('#datepicker').focus();
	});
	//bloc sondage.. blocage du form
	$('.avis form').submit(function(){return false;});	
						
});
function showoff()
{
document.getElementById('flash_pub').style.display='none';
}

