/* list of event and explanations */
//
function On_Load()
{
	
	for(i=1;i<4;i++)
	{
		document.getElementById('container-img-'+i).style.height=document.getElementById('container-img-'+i).offsetHeight+'px';
	}
	
	setTimeout(Fade_out_Img,timer[1]);
}

window.onload=On_Load;



function On_Scroll_Img()
{
	var scrolltop;
						
	if(truebody().scrollTop!=document.body.scrollTop && document.body.scrollTop>truebody().scrollTop)
	{
		scrolltop=document.body.scrollTop;
	}
	else
	{
		scrolltop=truebody().scrollTop;
	}
	
	document.getElementById('img-container').style.top=''+scrolltop+'px';

	
}

//
/* list of function and explanations */
//

//Fade out effect for image
function Fade_out_Img()
{
	if(flag_timer)
	{
	
		var cible_effect="img-"+counter_img;
		
		function Init_Img()
		{
				Ajax_Call_Page("script/ajax/image.php",'container-'+cible_effect,"id="+page_id+"&counter_img="+counter_img+"&img_deco1="+img_deco[1]+"&img_deco2="+img_deco[2]+"&img_deco3="+img_deco[3],Img_Deco,0);
		}
		
		//alert(cible_effect);
		
		new Effect.Appear(cible_effect,{from:1, to:0,duration:1,afterFinish:Init_Img});
	}
	else
	{
		
		setTimeout(Fade_out_Img,timer[counter_img]);
	
	}
	
}

function Img_High_Def(lien,id)
{
		lien.href="";
		
		Ajax_Call_Page("script/ajax/high-def.php","div-absolute","id="+id,Img_View,0);
}

// hide img in high def
function Img_Hide()
{
	window.onscroll=null;
	document.getElementById('div-absolute').innerHTML="";
}


//total height
function Get_Total_Height() 
{

  // firefox is ok
  var height = document.documentElement.scrollHeight;

  // now IE 7 + Opera with "min window"
  if(document.documentElement.clientHeight > height ) {
    height  = document.documentElement.clientHeight;
  }
  // last for safari
  if(document.body.scrollHeight > height) {
    height = document.body.scrollHeight;
  }
  return height;
}


function truebody()
{
	return (!window.opera && document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}


//
/* list of ajax mode and explanations */
//

// effect img of right of site
function Img_Deco()
{

	
	function Init_Timer()
	{
		counter_img++;
	
		if(counter_img==4)
		{
			counter_img=1;
		}
		
		setTimeout(Fade_out_Img,timer[counter_img]);
	}

var indice=document.getElementById('counter_img'+counter_img).value;

	new Effect.Appear('container-img-'+indice,{from:0, to:0,duration:0});


	/*var temp_img=new Image();
	temp_img.src=document.getElementById('img-'+indice).src;
	*/
	//temp_img.onload=function()
	{
	
			
		//document.getElementById('container-img-'+indice).style.height=document.getElementById('img-'+indice).offsetHeight+'px';
			
		img_deco[counter_img]=document.getElementById('ajax_deco_img'+counter_img).value;
	
		new Effect.Appear('container-img-'+indice,{from:0, to:1,duration:1,afterFinish:Init_Timer});
	}
}


// view image in high def
function Img_View()
{
	var scrolltop;
						
	if(truebody().scrollTop!=document.body.scrollTop && document.body.scrollTop>truebody().scrollTop)
	{
		scrolltop=document.body.scrollTop;
	}
	else
	{
		scrolltop=truebody().scrollTop;
	}
	
	//document.getElementById('img-fond').style.display="block";
	
	document.getElementById('img-fond').style.height=Get_Total_Height+'px';
	
	new Effect.Appear('img-fond',{from:0, to:0.8, duration:0});
	
	document.getElementById('img-container').style.top=scrolltop;
	
	new Effect.Appear('img',{from:0, to:1,duration:1});
	
	window.onscroll=On_Scroll_Img;

}
