
function Start(x) {
	a=x;
	image_on(a);
	Timer(a);		
		return x;
		}
		
function Timer(x) {	
		a=x;
		interval= setInterval('opacity("content", 0, 100, 500),augmenter(a), menuRequest(a), image_on(a)', 8000);
		 return x;
   }
   
  function stop_Int(x){
			  a=x;
			  clearInterval(interval);			
			Start(a);
        }
		
  function stop_Int2(){
			   clearInterval(interval);	
        }
		
 function restart(){			
 				 clearInterval(interval);	
			  Start(a);
        }
		
		function suivant(){
			a = a +1;
			if(a > 5) {
				a=1;
				}
				clearInterval(interval);
				opacity("content", 0, 100, 500);
			menuRequest(a);
			Start(a);
			return a; 
       }		
	   
	 	function precedent(){
			a = a -1;
			if(a < 1) {
				a=5;
				}
				clearInterval(interval);
				opacity("content", 0, 100, 500);
			menuRequest(a);
			Start(a);
			return a;
       }		
		
function augmenter(x){
			a = x +1;
			if(a > 5) {
				a=1;
				}
			return a;
       }
	   
	   function roll(img_name, img_src)
   {
   document[img_name].src = img_src;
   }
	      
  function image_on(x){	 
  a=x;
 if (a == 1)       {	a = 2 ;
						roll('btn_onglet_cul','image/zone_onglet/btn/onglet_cul.gif');
						a = 3 ;
						roll('btn_onglet_spo','image/zone_onglet/btn/onglet_spo.gif');
						a = 4 ;
						roll('btn_onglet_heb','image/zone_onglet/btn/onglet_heb.gif');
						a = 5 ;
						roll('btn_onglet_loi','image/zone_onglet/btn/onglet_loi.gif');
						a = 1;
			roll('btn_onglet_fil','image/zone_onglet/btn/onglet_fil_r.gif'); 	 }
if (a == 2) 	  {		a = 1 ;
						roll('btn_onglet_fil','image/zone_onglet/btn/onglet_fil.gif');
						a = 3 ;
						roll('btn_onglet_spo','image/zone_onglet/btn/onglet_spo.gif');
						a = 4 ;
						roll('btn_onglet_heb','image/zone_onglet/btn/onglet_heb.gif');
						a = 5 ;
						roll('btn_onglet_loi','image/zone_onglet/btn/onglet_loi.gif');
						a = 2;
		  				 roll('btn_onglet_cul','image/zone_onglet/btn/onglet_cul_r.gif'); 	 }
if (a == 3) 	  { 	a = 1 ;
						roll('btn_onglet_fil','image/zone_onglet/btn/onglet_fil.gif');
						a = 2 ;
						roll('btn_onglet_cul','image/zone_onglet/btn/onglet_cul.gif');
						a = 4 ;
						roll('btn_onglet_heb','image/zone_onglet/btn/onglet_heb.gif');
						a = 5 ;
						roll('btn_onglet_loi','image/zone_onglet/btn/onglet_loi.gif');
						a = 3;
						roll('btn_onglet_spo','image/zone_onglet/btn/onglet_spo_r.gif'); 	 }
if (a == 4) 	  {  	a = 1 ;
						roll('btn_onglet_fil','image/zone_onglet/btn/onglet_fil.gif');
						a = 2 ;
						roll('btn_onglet_cul','image/zone_onglet/btn/onglet_cul.gif');
						a = 3 ;
						roll('btn_onglet_spo','image/zone_onglet/btn/onglet_spo.gif');
						a = 5 ;
						roll('btn_onglet_loi','image/zone_onglet/btn/onglet_loi.gif');
						a = 4;
		  				roll('btn_onglet_heb','image/zone_onglet/btn/onglet_heb_r.gif');	 }
if (a == 5) 	  {		 a = 1 ;
						roll('btn_onglet_fil','image/zone_onglet/btn/onglet_fil.gif');
						a = 2 ;
						roll('btn_onglet_cul','image/zone_onglet/btn/onglet_cul.gif');
						a = 3 ;
						roll('btn_onglet_spo','image/zone_onglet/btn/onglet_spo.gif');
						a = 4 ;
						roll('btn_onglet_heb','image/zone_onglet/btn/onglet_heb.gif');
						a = 5;
						roll('btn_onglet_loi','image/zone_onglet/btn/onglet_loi_r.gif'); 	 }       
}


function opacity(id, opacStart, opacEnd, millisec) {
    //speed for each frame
    var speed = Math.round(millisec / 100);
    var timer = 0;
	//determine the direction for the blending, if start and end are the same nothing happens
    if(opacStart > opacEnd) {
        for(i = opacStart; i >= opacEnd; i--) {
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
            timer++;
        }
    } else if(opacStart < opacEnd) {
        for(i = opacStart; i <= opacEnd; i++)
            {
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
            timer++;
       }
    }
}

//change the opacity for different browsers
function changeOpac(opacity, id) {
    var object = document.getElementById(id).style;
    object.opacity = (opacity / 100);
    object.MozOpacity = (opacity / 100);
    object.KhtmlOpacity = (opacity / 100);
    object.filter = "alpha(opacity=" + opacity + ")";
} 

function menuRequest(url)
{
var arg = url;
url = "reponse.php?q=" + url;
var http_request = false;

if (window.XMLHttpRequest)
{ // Mozilla, Safari,...
http_request = new XMLHttpRequest();

if (http_request.overrideMimeType)
{
http_request.overrideMimeType('text/xml');
// See note below about this line
}
} else if (window.ActiveXObject)
{ // IE
try
{
http_request = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e)
{
try
{
http_request = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e) {}
}
}

if (!http_request)
{
alert('Giving up :( Cannot create an XMLHTTP instance');
return false;
}

http_request.onreadystatechange = function() { alertContents(http_request); };
http_request.open('GET', url, true);
http_request.send(null);

}


function alertContents(http_request, id, opacStart, opacEnd, millisec, onglet)
{
if (http_request.readyState == 4)
{
if (http_request.status == 200)
{
	
document.getElementById("content").innerHTML=http_request.responseText;
//alert(http_request.responseText);
}
else
{
alert('There was a problem with the request.');
}
}
}