
var transitionVar = 0;
var max=-4;
var t=0;
var tempo=25000;
var nb=1;
var version=0;
var widthFe=window.innerWidth;
var heightFe=window.innerHeight;
var maxW=(window.innerWidth)-305;
var minW=(window.innerWidth)-55;
var PopUpTimer=0;

if(navigator.appName=="Microsoft Internet Explorer"){
	if (navigator.appVersion.indexOf("MSIE")!=-1){
		temp=navigator.appVersion.split("MSIE")
		version=parseFloat(temp[1])
	}
}else{
	version=10;
}
function stop(margin){
	clearTimeout(t);
	document.getElementById('popupGaucheConnexion').style.marginLeft = margin+'px';
	t=setTimeout(transition,10000);
}
function wait(){
	clearTimeout(t);
	if(version==7){
		widthFe=-602;
	}else{
		widthFe=-291;
	}
	
	// document.getElementById('LoginYou').innerHTML="<b>Vous n'êtes pas connecté</b><br />Les prix indiqués sont les prix publics";
	document.getElementById('popupGaucheConnexion').style.marginLeft = widthFe+'px';
	t=setTimeout(play,54000);//2 min
}

function Attente(margin){
	clearTimeout(t);
	PopUpTimer=1;
	identifieur=setTimeout("stop3("+margin+")",500);	
}

function stop3(margin){
	clearTimeout(t);
	// document.getElementById('LoginYou').innerHTML="<b>Vous n'êtes pas connecté</b><br />Les prix indiqués sont les prix publics";
	if(version==7){
		margin=-338;
	}else{
		margin=-4;
	}
	if(PopUpTimer==1){
		PopUpTimer=0;
		transitionVar=2;
		document.getElementById('popupGaucheConnexion').style.marginLeft = margin+'px';
		if(version==7){
			t=setTimeout(transitionIE2,10000);//rembobine
		}else{
			t=setTimeout(transition2,10000);//rembobine
		}
	}else{
		Attente(margin);
	}
}
function play(){
	transitionVar=0;
	// document.getElementById('LoginYou').innerHTML="<b>Vous n'êtes pas connecté</b><br />Les prix indiqués sont les prix publics";
	if(version==7){
		transitionIE();	
	}else{
		transition();	
	}
}
function stop2(margin){
	clearTimeout(t);
	document.getElementById('popupGaucheConnexion').style.marginLeft = margin+'px';
	if(transitionVar){
		transitionVar=1;
		t=setTimeout(transition,10000);
	}else{
		t=setTimeout(wait,10000);
	}
}

function stopIE(margin){
	clearTimeout(t);
	document.getElementById('popupGaucheConnexion').style.marginLeft = margin+'px';
	t=setTimeout(transitionIE,10000);
}
function stopIE2(margin){
	clearTimeout(t);
	document.getElementById('popupGaucheConnexion').style.marginLeft = margin+'px';
	
	if(transitionVar){
		t=setTimeout(transitionIE,10000);
	}else{
		t=setTimeout(wait,10000);
	}
}

function clipPub() {
	if(version>7){//Si navigateur pas IE7
		if(transitionVar==4){
			transitionVar=0;
			stop2(parseInt(document.getElementById('popupGaucheConnexion').style.marginLeft));
		}else{
			if(transitionVar==3){
				transitionVar=1;
				t=setTimeout(transition,35000);
			}else{
				if(transitionVar==0){
					transitionVar=1;
					transition();
				}else{
					if(transitionVar==1){
						if(parseInt(document.getElementById('popupGaucheConnexion').style.marginLeft)==-4){//stop le défilement
							stop(parseInt(document.getElementById('popupGaucheConnexion').style.marginLeft));
						}else{
							if(parseInt(document.getElementById('popupGaucheConnexion').style.marginLeft)==-250){
								stop2(parseInt(document.getElementById('popupGaucheConnexion').style.marginLeft));
							}else{ 
								transition();
							}
						}
					}else{
						transition2();
					}
				}
			}
		}
	}else{	
		if(transitionVar==4){
			transitionVar=0;
			stopIE2(parseInt(document.getElementById('popupGaucheConnexion').style.marginLeft));
		}else{
			if(transitionVar==3){
				transitionVar=1;
				t=setTimeout(transitionIE,35000);
			}else{
				if(transitionVar==0){
					transitionVar=1;
					transitionIE();
				}else{
					if(transitionVar==1){
						if(parseInt(document.getElementById('popupGaucheConnexion').style.marginLeft)==-580){//stop le défilement
							stopIE(parseInt(document.getElementById('popupGaucheConnexion').style.marginLeft));
						}else{
							if(parseInt(document.getElementById('popupGaucheConnexion').style.marginLeft)==-338){
								stopIE2(parseInt(document.getElementById('popupGaucheConnexion').style.marginLeft));
							}else{
								transitionIE();
							}
						}
					}else{
						transitionIE2();
					}
				}
			}
		}
	}
}

function compteur (nbClic){
	if(nbClic==5){
		nbClic=0;	
		clipPub();	
	}
}

function transition(){
 	var id1 = document.getElementById('popupGaucheConnexion');	
 	id1.style.marginLeft = parseInt(id1.style.marginLeft)+41 + 'px';
	// alert(parseInt(id1.style.marginLeft));
 	if(parseInt(id1.style.marginLeft) > -4) {
		transitionVar=2;
 	}
	t=setTimeout(clipPub,40);	
}

function transition2(){
 	var id1 = document.getElementById('popupGaucheConnexion');	
 	id1.style.marginLeft = parseInt(id1.style.marginLeft)-41 + 'px';
	// alert(parseInt(id1.style.marginLeft));
 	if(parseInt(id1.style.marginLeft)<=-250){
		transitionVar=4;	
	}
	t=setTimeout(clipPub,40);	
}	

function transitionIE(){
 	var id1 = document.getElementById('popupGaucheConnexion');	
 	id1.style.marginLeft = parseInt(id1.style.marginLeft)+22 + 'px';
 	if(parseInt(id1.style.marginLeft) > -338) {
		transitionVar=2;
 	}
	t=setTimeout(clipPub,40);	
}

function transitionIE2(){
 	var id1 = document.getElementById('popupGaucheConnexion');	
 	id1.style.marginLeft = parseInt(id1.style.marginLeft)-22 + 'px';
 	if(parseInt(id1.style.marginLeft)<=-580){
		transitionVar=4;	
		// transitionVar=1;
	}
	t=setTimeout(clipPub,40);	
}

// function addLoadEvent(func) {
  // var oldonload = window.onload;
  // if (typeof window.onload != 'function') {
    // window.onload = func;
  // } else {
    // window.onload = function() {
      // if (oldonload) {
        // oldonload();
      // }
      // func();
    // }
  // }
// }

function init_popup(){
	// document.getElementById('LoginYou').innerHTML="<b>Vous n'êtes pas connecté</b><br />Les prix indiqués sont les prix publics";
	wait();
	// if(nb==-1){
		// if(version==7){
			// widthFe=-602;
		// }else{
			// widthFe=-291;
		// }
		// document.getElementById('LoginYou').innerHTML="";
		// document.getElementById('popupGaucheConnexion').style.marginLeft = widthFe+'px';
	// }else{
		// if(version==7){
			// minW=-580;
		// }else{
			// minW=-250;
		// }
		// document.getElementById('LoginYou').innerHTML="<b>Vous n'êtes pas connecté</b><br />Les prix indiqués sont les prix publics";
		// document.getElementById('popupGaucheConnexion').style.marginLeft=minW+'px';
		// if(nb==1){
			// clipPub();
		// }else{
			// transitionVar=0;
			// wait();
		// }
	// }
}
// addLoadEvent(function() {
	// init_popup();
// });
