var i=0;
var step=0;
var test_step = true;
//if (document.getElementById)
//	{
var fromPub = 0;
var iVolePub = new Image;
//var iVolePub.src = "img/cigognes10.gif";
//var im_src = "img/cigognes10.gif";
var offsetyPub=0;
var HauteurPub = 0;
var place = fromPub;
var xpub = 1;
var ypub = -3;
var tempo36;
var EcranlargPub;
var EcranhautPub = 200;
var onscroll;
var decal=8;
//var decal=40;
var inter = 4000;
var topdiv = 0;
//	}

function RandomDep()
{
	var numimagePub= Math.round(Math.random()*3);
	numimagePub ++;
	return numimagePub;
	
}

function VolimPub(){

	//if(i==1) return;
	i=1;

	if(document.all)
	{
		EcranlargPub = document.body.clientWidth-iVolePub.width;

	}
	else
	{
		EcranlargPub = screen.width-100;

	}

	//EcranhautPub = 200;
	if (document.getElementById)
	{

		if ((place > EcranlargPub-15 || (document.all && place > EcranlargPub-90) || place < 0 || (document.all && place < 0))){
			//place=0;
			clearTimeout(tempo36);
			//decal = -1*decal
			
			document.getElementById("pubBulle").style.display='none'
			setTimeout('document.getElementById("pubBulle").style.display=""', inter);
			setTimeout('VolimPub()', inter);
			
			place = place - decal;
			decal = -1*decal;
			step++;
			step = step%6;
			
			
			if(step==0 || step==4){
				
					ypub = (-(RandomDep()));
					document.getElementById('img_an').src= "img/cigognes10.gif"	;
				
			}
			
			
			if(step==1 || step==3){
				document.getElementById('img_an').src= "img/cigognesfixDG.GIF"	;
				ypub=0;
				
			}
			
			if(step==2){
				document.getElementById('img_an').src= "img/cigognesBB.gif"	;
				ypub=0;
				
			}
			if(step==5){
				document.getElementById('img_an').src= "img/cigogne_mob.gif"	;
				//decal=10;
				ypub=0;
				
			}
			//alert(step);
			//alert(step);
			return;
			//	document.getElementById("pubBulle").innerHTML = "totot";

		}

		if (place < fromPub)
		xpub = RandomDep();


		var top = document.getElementById('pubBulle').style.top;
		top = top.replace('px', "");
		HauteurPub = top;
		place = place + decal;
		HauteurPub = HauteurPub -1 + 1+ypub;
		//alert(HauteurPub);
		//alert(place);

		document.getElementById("pubBulle").style.left = place+"px";
		document.getElementById("pubBulle").style.top = HauteurPub+"px";
		//alert(document.getElementById("pubBulle").style.left+"   "+place);
		//alert(HauteurPub+" "+EcranhautPub);
		
		if(step==0 || step==4){
			if (HauteurPub>EcranhautPub){
				ypub = (-(RandomDep()));

				document.getElementById('img_an').src= "img/cigognes10.gif"	;
			}
			if (HauteurPub<topdiv){
				ypub = RandomDep();

				document.getElementById('img_an').src= "img/cigognesfix.gif"	;
			}
		}
		
		
		tempo36 = setTimeout('VolimPub()', 50);
	}


}



//window.onEvent = function(){alert('event');};

function OffSet()
{ 
	
	//alert('sc');
	try{
		var os = document.documentElement.scrollTop;
		//alert(window.document.scrollTop);
		EcranhautPub = 200 -1 +1+os;
		topdiv = os;

		
		
		//alert(topdiv + " "+EcranhautPub);
		//alert(document.documentElement.scrollTop)
		var top = document.getElementById('pubBulle').style.top;
		top = top.replace('px', "");
		top = top +1 - 1  + os;
		top = top+"px";
		//alert(top);
		//alert(os);
		document.getElementById('pubBulle').style.top = os+"px";
		//alert(document.getElementById('pubBulle').style.top);

	}catch(e){
		alert(e);
	}

}

window.onload =  function(){
	
	VolimPub();
	
}
window.onscroll = OffSet;
//document.onscroll = OffSet;
document.documentElement.onscroll = OffSet;



