

//****** POPUP EWEGO GPS ******// START
function ouvrirPopup(){
	window.open( 'http://www.e-wegopro.fr/france-pare-brise/popup', "popup_ewego","width=685,height=680,menubar=yes,toolbar=no,location=yes,status=no,resizable=no,scrollbars=no,directories=no");   
}
//****** POPUP EWEGO GPS ******// END

function CalcHeight(){
	var myWidth = 0, myHeight = 0;
	var message="";
	
	if( typeof( window.innerWidth ) == 'number' ) {//Non-IE
		myWidth = window.innerWidth;
		myHeight = window.innerHeight;
	}else if(document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight)){
		//IE 6+ in 'standards compliant mode'
		myWidth = document.documentElement.clientWidth;
		myHeight = document.documentElement.clientHeight;
	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight)){
		//IE 4 compatible
		myWidth = document.body.clientWidth;
		myHeight = document.body.clientHeight;
	}
	myWidth=700;
	var newx = myWidth-100; // set to whatever you want the images max width to be.
	var newy = myHeight-200; // whatever you want the images maximum height to be.
	
	var width = document.getElementById("w"+document.slideform.slide.selectedIndex).value;
	var height = document.getElementById("h"+document.slideform.slide.selectedIndex).value;
	
	if ( newx >= width ) newx = width ;
	if ( newy >= height ) newy = height ;
	
	if ( width >= height ) {// landscape
		var tmpy = height*newx/width;
		if ( tmpy <= newy ){
			newy = tmpy;
		}else{
			newx = width*newy/height;
		}
	}else{// portrait
		tmpx = width*newy/height;
		if ( tmpx <= newx ){
			newx = tmpx;
		}else{
			newy = height*newx/width;
		}
	}
	
	if(newx>700){
		document.getElementById('backgroundFilter').style.width="99%";
		document.getElementById('backgroundFilter').style.left="2px";
	}else{
		document.getElementById('backgroundFilter').style.width="65%";
		document.getElementById('backgroundFilter').style.left="205px";
	}
	
	document.getElementById('show').height=newy;
	document.getElementById('show').width=newx;
	var wc=newx-1+20+1;
	document.getElementById('cad').style.width=wc+"px";
	
}

function MemmbreAcces(r){
	if(r=="suivi"){
		if(document.getElementById('suivi').className=='dcachediv'){
			document.getElementById('suivi').className='dmontrediv';
			//document.getElementById('alertes').className='dcachediv';
		}else{
			document.getElementById('suivi').className='dcachediv';
		}
	}else{
		if(document.getElementById('alertes').className=='dcachediv'){
			document.getElementById('alertes').className='dmontrediv';
			//document.getElementById('suivi').className='dcachediv';
		}else{
			document.getElementById('alertes').className='dcachediv';
		}
	}
}

function VerifPlugIn(ExtensionFile)
{
	var IsEnabled = true;
	if (navigator.appName == "Netscape"){
		IsEnabled = false;
		for(var x=0;(x<navigator.mimeTypes.length && !IsEnabled);x++)
		{
		if(navigator.mimeTypes[x].suffixes.indexOf(ExtensionFile)>=0)
		IsEnabled = navigator.mimeTypes[x].enabledPlugin;
		}
	}
	return IsEnabled;
}

function verif(){
	var tou = parent.document.all.tags("input");
	for (var i=0; i<tou.length; i++){
		if(tou[i].id=="depar"){
			if (tou[i].value.length<1) {
			   alert('Au moins 2 chiffres.');
			   return false;
			}else{ 
				if (tou[i].value.length<2){
					alert('Entrez au moins 2 chiffres dans la case.');
					return false;
				}else{
					if (isNaN(tou[i].value)) {
						alert('Entrez des chiffres dans la case.');
						return false;
					}else{
						if (tou[i].value.length>2){
							alert('Entrez seulement 2 chiffres dans la case.');
							return false;
						}else{
							document.getElementById('formulaire').submit();
							return true;
						}
					}
				}
			}
		}
	}
}

function run_anime(){
	AC_FL_RunContent(
		'clsid' ,'clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' ,
		'codebase' ,'http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0' ,
		'width' ,'363' ,
		'height' ,'245' ,
		'src' ,'_swf/Anim_ok' ,
		'pluginspage' ,'http://www.macromedia.com/go/getflashplayer' ,
		'movie' , '_swf/Anim_ok' ,
		'play' , 'true' ,
		'loop' , 'true' ,
		'quality' ,'high',
		'wmode' ,'transparent');
}


function run_vid(xvid){
	AC_FL_RunContent(
		'codebase', 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0',
		'width' ,'570' ,
		'height' ,'288' ,
		'src' ,'_swf/player_flv_max' ,
		'quality' ,'high',
		'pluginspage' ,'http://www.macromedia.com/go/getflashplayer' ,
		'movie' , '_swf/player_flv_max' ,
		'play' , 'true' ,
		'loop' , 'true' ,
		'Flashvars' ,'&amp;flv='+xvid+'&amp;autoplay=1&amp;autoload=1&amp;margin=11&amp;width=570&amp;height=288&amp;skin=player_flv_skin001.jpg&amp;playercolor=cccccc&amp;buttoncolor=333333&amp;buttonovercolor=999999&amp;slidercolor1=333333&amp;slidercolor2=0&amp;sliderovercolor=999999&amp;loadingcolor=0');
}


function run_film(){
	AC_FL_RunContent(
		'codebase', 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0',
		'width' ,'570' ,
		'height' ,'288' ,
		'src' ,'_swf/player_flv_max' ,
		'quality' ,'high',
		'pluginspage' ,'http://www.macromedia.com/go/getflashplayer' ,
		'movie' , '_swf/player_flv_max' ,
		'play' , 'true' ,
		'loop' , 'true' ,
		'Flashvars' ,'&amp;flv=../video/mavideo2.flv&amp;autoplay=1&amp;autoload=1&amp;margin=11&amp;width=570&amp;height=288&amp;skin=player_flv_skin001.jpg&amp;playercolor=cccccc&amp;buttoncolor=333333&amp;buttonovercolor=999999&amp;slidercolor1=333333&amp;slidercolor2=0&amp;sliderovercolor=999999&amp;loadingcolor=0');
}



function VerifMail(){
	a = document.getElementById('mail_flotte').value;
	valide1 = false;
	for(var j=1;j<(a.length);j++){
		if(a.charAt(j)=='@'){
			if(j<(a.length-4)){
				for(var k=j;k<(a.length-2);k++){
					if(a.charAt(k)=='.') valide1=true;
				}
			}
		}
	}
	if(valide1==false) alert("Veuillez saisir une adresse email valide.");
	return valide1;
	
}

function ejs_img_fx(img){
	if(img && img.filters && img.filters[0]){
		img.filters[0].apply();
		img.filters[0].play();
	}
}

function StartAnim() {
	if (document.images) {
		document.write('<A HREF="#" onClick="ImgDest();return(false)"><IMG SRC="_img/defil0.jpg" BORDER=0 ALT=Menu NAME=defil style="filter:progid:DXImageTransform.Microsoft.Pixelate(MaxSquare=100,Duration=1)"></A>');
		defilimg();
	}else{
		document.write('<A HREF="?p=offre_flotte"><IMG SRC="_img/defil0.jpg" BORDER=0></A>');
	}
}

function ImgDest(){
	document.location.href = SiClickGoTo[a-1];
}
function defilimg(){
	var tps=3000;
	if (a == 7){
		a = 0;
	}
	if (document.images){
		if(a==6) tps=10000;
		ejs_img_fx(document.defil);
		document.defil.src = imgPath[a];
		
		tempo3 = setTimeout("defilimg()",tps);
		a++;
	}
}

function DivStatus( nom ){
	var divID = nom;
	if ( document.getElementById && document.getElementById( divID ) )	{
		Pdiv = document.getElementById( divID );
		Pdiv.className = ( Pdiv.className == 'menu_cache' ) ? 'menu_montr' : 'menu_cache';
	}
}


//**********  WHO IS ONLINE  **********// START

function who_start(updateTime,ipUser){ // fucntion de départ appelle les autres fonctions
	buildZone(updateTime);
	checkTblRessource();
	updateOnlineInfo(ipUser,updateTime);
	getOnlinePeople(updateTime);
}
function who_stop(ipUser){ // vérifie si le visiteur quitte la page ... si oui execute le fichier qui supprimer son entrée IP
	var xhr_url = 'http://www.franceparebrise.org/fpb/_js/whoIsOnline.php'; // nom de la page
	var data = 'action=delete&ipUser='+ipUser; // donneé a envoyer à la page
	var getInfo = false; // donnée retourné ?
	var toMake = ''; // execution apres retour de donnée
	sendGetRequest(xhr_url,data,getInfo,toMake); // appel de la page avec les parametre ci haut
}
function buildZone(updateTime){ // créé les élément dans le div de départ
	var tx="";
	tx=tx+'<div style="font-size:11px;color:#006699;font-weight:bold;font-family:sans-serif;height:15px;">';
	tx=tx+'<span id="ivisiteur">&nbsp;</span> ';
	tx=tx+'</div>';
	document.getElementById('izone').innerHTML = tx;
	
}
function checkTblRessource(){ // execute checkTblRessource qui vérifie si la table ds la BD existe , si non la crée 
	var xhr_url = 'http://www.franceparebrise.org/fpb/_js/whoIsOnline.php'; // nom de la page
	var data = 'action=check'; // donneé a envoyer à la page
	var getInfo = false; // donnée retourné ?
	var toMake = ''; // execution apres retour de donnée
	sendGetRequest(xhr_url,data,getInfo,toMake); // appel de la page avec les parametre ci haut
}
function updateOnlineInfo(ipUser,updateTime){ // execute le fichier qui update le time de la derniere connection
	var xhr_url = 'http://www.franceparebrise.org/fpb/_js/whoIsOnline.php'; // nom de la page
	var data = 'action=update&ipUser='+ipUser; // donneé a envoyer à la page
	var getInfo = false; // donnée retourné ?
	var toMake = ''; // execution apres retour de donnée
	sendGetRequest(xhr_url,data,getInfo,toMake); // appel de la page avec les parametre ci haut
	setTimeout("updateOnlineInfo('"+ipUser+"','"+updateTime+"')",(updateTime*1000)); // decompte pour réappeler cette meme fonction pour réactualiser les donnée de dernière connection
}
function getOnlinePeople(updateTime){ // fcontion qui récupère les persones en ligne
	var xhr_url = 'http://www.franceparebrise.org/fpb/_js/whoIsOnline.php';// nom de la page
	var data = 'action=getonline&updateTime='+updateTime; // donneé a envoyer à la page
	var getInfo = true; // donnée retourné ?
	var toMake = "document.getElementById('ivisiteur').innerHTML = infos"; // execution apres retour de donnée
	sendGetRequest(xhr_url,data,getInfo,toMake); // appel de la page avec les parametre ci haut
}
function sendGetRequest(xhr_url,data,getInfo,toMake){ // function utilisant  XMLHttpRequest pour lire des page en format PHP qui g`re les requete ds la BD
	var xhr_object = null; // declarationde la variable
	if(window.XMLHttpRequest){ // Firefox 
		  xhr_object = new XMLHttpRequest(); // declaration de lobjet
	}else if(window.ActiveXObject){ // Internet Explorer 
		 xhr_object = new ActiveXObject("Microsoft.XMLHTTP"); // declaration de lobjet
	}else { // XMLHttpRequest non supporté par le navigateur 
		alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest..."); 
		return; 
	}
	if(data != false){ // si variabel à envoyer à l'autre page
		xhr_url = xhr_url+'?'+data; // ajout à la fin de l'url ... c'est sous forme GET
	}
	//alert(xhr_url);
	xhr_object.open("GET", xhr_url, true); // afectation des parametre à l'objet XMLHttpRequest
	if(getInfo != false){ // if retour d'info attendu
		xhr_object.onreadystatechange = function() { // surveille l'état XMLHttpRequest
			if(xhr_object.readyState == 4){ // Etat = 4 ... , qui est traitement effectué et terminer
				var infos = xhr_object.responseText // affectation du retour de donnée a infos
				if(toMake != ''){ // execute le javascrip contenu dans la variable toMake
					eval(toMake);
				}
			}
		}
	}
	xhr_object.send(null);
}

//**********  WHO IS ONLINE  **********// END






//**********  DEFIL PHOTOS  **********// DEB


var rotate_delay = 4000; // delais en microseconde (4000 = 4 secs)
current = 0;
function lessdelay() {
  if (rotate_delay <= 1000) {
	rotate_delay = rotate_delay-100; 
	document.slideform.delay.value = rotate_delay; 
  }else {
	rotate_delay = rotate_delay-500; 
	document.slideform.delay.value = rotate_delay; 
  }
}
function moredelay() {
  if (rotate_delay < 1000) {
	rotate_delay = rotate_delay+100; 
	document.slideform.delay.value = rotate_delay; 
  }else {
	rotate_delay = rotate_delay+500; 
	document.slideform.delay.value = rotate_delay; 
  }
}
function next() {
  if (document.slideform.slide[current+1]) {
	document.images.show.src = document.slideform.slide[current+1].value;
	document.slideform.slide.selectedIndex = ++current;
  }else first();
}
function previous() {
  if (current-1 >= 0) {
	document.images.show.src = document.slideform.slide[current-1].value;
	document.slideform.slide.selectedIndex = --current;
  }else last();
}
function first() {
  current = 0;
  document.images.show.src = document.slideform.slide[0].value;
  document.slideform.slide.selectedIndex = 0;
}
function last() {
  current = document.slideform.slide.length-1;
  document.images.show.src = document.slideform.slide[current].value;
  document.slideform.slide.selectedIndex = current;
}
function ap(text) {
document.slideform.slidebutton.value = (text == "Stop") ? " > " : "Stop";
rotate();
}
function change() {
  current = document.slideform.slide.selectedIndex;
  document.images.show.src = document.slideform.slide[current].value;
}
function rotate() {
  if (document.slideform.slidebutton.value == "Stop") {
	current = (current == document.slideform.slide.length-1) ? 0 : current+1;
	document.images.show.src = document.slideform.slide[current].value;
	document.slideform.slide.selectedIndex = current;
	window.setTimeout("rotate()", rotate_delay);
  }
}

//**********  DEFIL PHOTOS  **********// END
















