if(document.all)var selection="document.all";
if(document.getElementById)var selection="document.getElementById";

timer = null;
vitesse = 1;

function MM_swapImgRestore() { //v3.0
	  var i,x,a=document.MM_sr; 
	  for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){
	   document.MM_sr[j++]=x; 
	   if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];
	   }
}

function saisir(nomChamp,nomFormulaire){
with( eval("document.forms."+nomFormulaire+"") ){
var valeur=eval(nomChamp+".value");
var defaut=eval(nomChamp+".defaultValue");

	if( valeur==defaut)  {
		eval(nomChamp+".value=''");
		}
	if (valeur==''){
		eval(nomChamp+".value='"+defaut+"'");
		}
	}
}

var envoi=false;
function valider(){
	with(arguments[0]){
	 for (var i = 1; i < arguments.length; i++) {
		arguments[i].value=arguments[i].value.replace(/(^\s*)|(\s*$)/g,'');
		if( arguments[i].value ==''){
			document.all.message_erreur.innerHTML = "Merci de bien vouloir indiquer "+arguments[i].label;
			envoi=false;
			break;
			}	
		else {envoi=true;}
		 }
	}
}


var masquerFlash;
var masquerSelect;

function menu(menu){
with(selection){
	
/*if(masquerFlash==true){
	if(gifAmasquer.style.display == 'none'){
	flashAmasquer.style.display='none';
	gifAmasquer.style.display='block';
	} else {
	flashAmasquer.style.display='block';
	gifAmasquer.style.display='none';
	}
}*/

// Masquer le select
if(masquerSelect==true && (menu.name=="marques" || menu.name=="poles")){
	if(document.forms.rayon.selectRayon.style.visibility == 'visible'){
	document.forms.rayon.selectRayon.style.visibility='hidden';
	} else {
	document.forms.rayon.selectRayon.style.visibility='visible';
	}
}
//

element=menu.style;
	if(element.visibility=='visible'){
		element.visibility='hidden';
		MM_swapImgRestore();
	} else {
		element.visibility='visible';
		}
	}
}


function colorer(cellule){
	if(cellule.bgColor=='#dadcef') cellule.bgColor='#024298';
	else if (cellule.bgColor=='#024298') cellule.bgColor='#dadcef';
}

function haut(){
with(selection){
	if(parseInt(idees.style.top)<0) {
		idees.style.top = parseInt(idees.style.top) + vitesse + "px";
		timer = setTimeout("haut()",0);
		imgBas.style.display='block';
	} else {
		imgHaut.style.display='none';
		}
	}
}

function bas(){
if(container.offsetHeight) var limite=container.offsetHeight-idees.offsetHeight;	
if(container.innerHeight) var limite=container.innerHeight-idees.innerHeight;	

with(selection){
	if(parseInt(idees.style.top)>limite) {
		idees.style.top = parseInt(idees.style.top) - vitesse +"px";
		timer = setTimeout("bas()",0);
		imgHaut.style.display='block';
		} else {
		imgBas.style.display='none';
		}
	}
}

function arret(){
    clearTimeout(timer);
}


tempo=1;
speed=40;
maximum=320;
var chrono = null;
var jeuAGratter;

function publicite() {

if (jeuAGratter){delai=600000;}
else{delai=20000;}
	
	with (selection) {
	if(parseInt(encartPub.style.left)<maximum) {
		
		encartPub.style.left = parseInt(encartPub.style.left) +speed+"px";
		if(parseInt(encartPub.style.left)==maximum) {tempo=delai;maximum=-800}
		}
		
	else {encartPub.style.left = parseInt(encartPub.style.left) -speed+"px";}
	
		chrono=setTimeout("publicite()",tempo);
		tempo=1;
		
	if(parseInt(encartPub.style.left)==maximum) {clearTimeout(chrono);}
	}
}


function init(){
	if(container.offsetHeight) var limite=container.offsetHeight-idees.offsetHeight;	
	if(container.innerHeight) var limite=container.innerHeight-idees.innerHeight;	
with(selection){
	if(limite>0) navigation.style.display='none';
	imgHaut.style.display='none';
	}
	if(document.getElementById('encartPub')){
		maximum=320
		document.getElementById('encartPub').style.pixelLeft = -800;
		publicite();
	}
}

function solution(url,largeur,hauteur){
	var popupSolution=window.open(url,"solution","toolbar=1, location=no, directories=0, status=no, scrollbars=yes, resizable=no, copyhistory=no,width="+largeur+", height="+hauteur+"");
	var gauche = (screen.width - largeur)/2;
	var droite = (screen.height - hauteur)/2;
	popupSolution.moveTo (gauche,droite);
	if (popupSolution.blur)popupSolution.focus();
}

function plan(url){
	var popupImage=window.open(url,"plan","toolbar=no, location=0, directories=no, status=no, scrollbars=no, resizable=0, copyhistory=no, menubar=no, width=800, height=720");
	if (popupImage.blur)popupImage.focus();
	}
	
function popup(url,largeur,hauteur){
	var fen=window.open(url,"fen","toolbar=no, location=no, directories=0, status=no, scrollbars=no, resizable=no, copyhistory=no,width="+largeur+", height="+hauteur+"");
	var gauche = (screen.width - largeur)/2;
	var droite = (screen.height - hauteur)/2;
	fen.moveTo (gauche,droite);
	if (fen.blur)fen.focus();
}	
