// JavaScript Document

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{ 
        for(i = opacStart; i <= opacEnd; i++) 
            { 
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed)); 
            timer++; 
        } 
    } 
}

function pausecomp(millis) 
{
	var date = new Date();
	var curDate = null;
	
	do { curDate = new Date(); } 
	while(curDate-date < millis);
} 

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 donull(){
}

function imageChange(div)
{	
	//Do not Edit below
	randMax = imagesA.length-1;
	randN ++;
	if(randN > randMax)
	{
		randN = randN - randMax;
	}
	document.getElementById(div).style.backgroundImage = "url("+imagesA[randN]+")";
	setTimeout("fadeIn('"+div+"');", 1);
}

function fadeOut(Instant, Div)
{
	/*if(Instant != true)
	{
		opacity(Div, 100, 0, 750);
	}
	else
	{
		opacity(Div, 100, 0, 1);
	}*/
	setTimeout ("imageChange('"+Div+"');", 5000);
}

function fadeIn(Div)
{
	//opacity(Div, 0, 100, 750);
	setTimeout("fadeOut(true, '"+Div+"');", 5000);
} 

function montrer(id) {
window.document.getElementById(id).style.display="block";
window.document.getElementById(elm).style.visibility ='visible';
}

function cacher(id) {
window.document.getElementById(id).style.display="none";
window.document.getElementById(elm).style.visibility ='hidden';
}


function see(id, num)
{
	for(i=1;i<=num;i++)
	{
		document.getElementById(i).style.display = 'none';
	}

	document.getElementById(id).style.display = 'block';
}

function verifFormContact(monForm)
{
	var ok = true;
	if(window.document.monForm.nom.value == ''){

         alert('Il faut obligatoirement renseigner le champs NOM');

         window.document.monForm.nom.focus();
		 ok = false;

    }

    if(window.document.monForm.pnom.value == '') {

         alert('Il faut obligatoirement renseigner le champs PRENOM');

         window.document.monForm.pnom.focus();
		 ok = false;

    }
	

	 if(window.document.monForm.mail.value == '') {

         alert('Il faut obligatoirement renseigner le champs EMAIL');

         window.document.monForm.mail.focus();
		 ok = false;

    }
	if(window.document.monForm.mail.value.indexOf('@') == -1)
	{

		alert("Votre email n'est pas valable !");

		window.document.monForm.mail.focus();
		ok = false;

	}
	
	if (ok != false)
	{
		window.document.monForm.submit();
	}

}

function see_img(div1,num)
{
	for(i=0;i<num;i++)
	{
		Pdiv = document.getElementById( 'img_' + i );
		Pdiv.className = ( Pdiv.className.match('cachediv')) ? Pdiv.className.replace("","") : Pdiv.className+' '+'cachediv';
	}
	
	var divID = div1;
	Pdiv = document.getElementById( divID );
	Pdiv.className = Pdiv.className.replace(/cachediv/,"");
}

function see_prod(div1,num)
{
	for(i=0;i<99;i++)
	{
		if(document.getElementById( 'prod_' + i ))
		{
			Pdiv = document.getElementById( 'prod_' + i );
			Pdiv.className = ( Pdiv.className.match('cachediv')) ? Pdiv.className.replace("","") : Pdiv.className+' '+'cachediv';
		}
	}
	
	if(div1 != '')
	{
		var divID = div1;
		Pdiv = document.getElementById( divID );
		Pdiv.className = Pdiv.className.replace(/cachediv/,"");
	}
}

function see_indic(id)
{
	for(i=0;i<99;i++)
	{
		if(document.getElementById( 'indic_open_' + i ))
		{
			Pdiv = document.getElementById( 'indic_open_' + i );
			Pdiv.className = ( Pdiv.className.match('cachediv')) ? Pdiv.className.replace("","") : Pdiv.className+' '+'cachediv';
		}
	}
	
	if(id != '')
	{
		var divID = 'indic_open_' + id ;
		Pdiv = document.getElementById( divID );
		Pdiv.className = Pdiv.className.replace(/cachediv/,"");
	}
	
}

function pagi_theme(div1,num)
{
	for(i=0;i<9;i++)
	{
		if(document.getElementById( i + '_pagthem' ))
		{
			Pdiv = document.getElementById( i + '_pagthem' );
			Pdiv.className = ( Pdiv.className.match('cachediv')) ? Pdiv.className.replace("","") : Pdiv.className+' '+'cachediv';
		}
	}
	
	for(i=0;i<9;i++)
	{
		if(document.getElementById( i + '_pag' ))
		{
			Pdiv = document.getElementById( i + '_pag' );
			Pdiv.className = 'pagination_sup_2';
		}
	}
	
	if(div1 != '')
	{
		var divID = div1;
		Pdiv = document.getElementById( divID );
		Pdiv.className = Pdiv.className.replace(/cachediv/,"");
	}
	
	if(num != '')
	{
		Pdiv = document.getElementById( num + '_pag' );
		Pdiv.className = 'pagination_sup';
	}
}

function pagi_prod(div1,num)
{
	for(i=0;i<9;i++)
	{
		if(document.getElementById( i + '_pagprod' ))
		{
			Pdiv = document.getElementById( i + '_pagprod' );
			Pdiv.className = ( Pdiv.className.match('cachediv')) ? Pdiv.className.replace("","") : Pdiv.className+' '+'cachediv';
		}
	}
	
	for(i=0;i<9;i++)
	{
		if(document.getElementById( i + '_pag' ))
		{
			Pdiv = document.getElementById( i + '_pag' );
			Pdiv.className = 'pagination_sup_2';
		}
	}
	
	if(div1 != '')
	{
		var divID = div1;
		Pdiv = document.getElementById( divID );
		Pdiv.className = Pdiv.className.replace(/cachediv/,"");
	}
	
	if(num != '')
	{
		Pdiv = document.getElementById( num + '_pag' );
		Pdiv.className = 'pagination_sup';
	}
}

var requete = null;
/**
 * Fonction privée qui va créer un objet XHR.
 * Cette fonction initialisera la valeur dans la variable globale définie
 * ci-dessus.
 */
function creerRequete()
{
	var requete; 
    try
    {
        /* On tente de créer un objet XmlHTTPRequest */
        requete = new XMLHttpRequest();
    }
    catch (microsoft)
    {
        /* Microsoft utilisant une autre technique, on essays de créer un objet ActiveX */
        try
        {
            requete = new ActiveXObject('Msxml2.XMLHTTP');
        }
        catch(autremicrosoft)
        {
            /* La première méthode a échoué, on en teste une seconde */
            try
            {
                requete = new ActiveXObject('Microsoft.XMLHTTP');
            }
            catch(echec)
            {
                /* À ce stade, aucune méthode ne fonctionne... mettez donc votre navigateur à jour ;) */
                requete = null;
            }
        }
    }
    if(requete == null)
    {
        alert('Impossible de créer l\'objet requête,\nVotre navigateur ne semble pas supporter les object XMLHttpRequest.');
    }
	return requete;
}


function post(who, where, div, action, id) 
{
	if(who != 'no_form')
	{
		var elements = document.forms[who].length;
	}

	var i;
	if (where.indexOf("?")>=0)
	{
		var content = '';
	}
	else
	{
		var content = '?';	
	}

    for (i = 0; i < elements; i++)
	{
		if(document.forms[who].elements[i].checked)
		{
			document.forms[who].elements[i].value ='1';
		}
    	// on regarde si l'élément est "checked".
      	if(document.forms[who].elements[i].value)
	  	{
			if(i > 0 )
			{
				content += '&';	
			}
			
			content += document.forms[who].elements[i].name;
			content += '=';
			content += escape(document.forms[who].elements[i].value);
      	}
	}
	
	
	var url = where + content + '&action=' + action +'&id=' + id;

	for (i = 0; i < elements; i++) 
	{
		if(!document.forms[who].elements[i].value)
		{
			document.forms[who].elements[i].checked = false; 
		}
	}
	checkflag = "false";
	
	var req1 = null;
	req1 = creerRequete();
	req1.open('GET', url, true);
	
	req1.onreadystatechange = function()
	{
		if(req1.readyState == 4)
		{
			if(req1.status == 200)
			{
				var result_return = req1.responseText;
				document.getElementById(div).innerHTML = result_return;
			}
		}
	}
	req1.send(null);

}


