function bodyonload(page){
if(page=="accueil"){
makeRequest('ajax/pubmarchandG.php','','pubmarchandG');
makeRequest('ajax/pubmarchandD.php','','pubmarchandD');
makeRequest('ajax/pubmarchandcat.php','','pubmarchandcat');
}
}

function ouvrepopupprogres(page,param,tailleL,tailleH,tempo){
makeRequest(page,'page=0','popup');
var browserName=navigator.appName;
if (browserName=="Microsoft Internet Explorer"){
document.body.scrollTop=0;
noclic.style.position='absolute';
noclic.style.height=1000; noclic.style.width=1600;
popup.style.position='absolute';
document.body.style.overflow='hidden';
}
showpopup('noclic');
opacity('noclic',0, 50, 500);
showpopup('popup');
setTimeout("opacity('popup',0, 100, 500)",500);
setTimeout("changewidth('popup',0,"+tailleL+","+tempo+")",500);
setTimeout("changeheight('popup',0,"+tailleH+","+tempo+")",500);
setTimeout("makeRequest('"+page+"','"+param+"','popup')",1000);
}

function fermepopupprogres(tailleL,tailleH,tempo){
makeRequest('ajax/test.php','page=0','popup');
changewidth('popup',tailleL,0,tempo);
changeheight('popup',tailleH,0,tempo);
opacity('popup',100, 0, 500);
setTimeout("opacity('noclic',50, 0, 500)",500);
setTimeout("hidepopup('popup')",1000);
setTimeout("hidepopup('noclic')",1000);
var browserName=navigator.appName;
if (browserName=="Microsoft Internet Explorer"){
document.body.style.overflow='auto';
}
}

function ouvrepopup(page,param,tailleL,tailleH){
divwidth('popup',tailleL);
divheight('popup',tailleH);
var browserName=navigator.appName; 
if (browserName=="Microsoft Internet Explorer"){
document.body.scrollTop=0;
noclic.style.position='absolute';
noclic.style.height=1000; noclic.style.width=1600;
popup.style.position='absolute';
document.body.style.overflow='hidden';
}
showpopup('noclic');
opacity('noclic',0, 50, 500);
showpopup('popup');
setTimeout("opacity('popup',0, 100, 500)",500);
//Changecontenudiv('popup|'+contenu[page]);
makeRequest(page,param,'popup');
}

function fermepopup(){
opacity('popup',100, 0, 500);
setTimeout("opacity('noclic',50, 0, 500)",500);
setTimeout("hidepopup('popup')",1000);
setTimeout("hidepopup('noclic')",1000);
var browserName=navigator.appName;
if(browserName=="Microsoft Internet Explorer"){
document.body.style.overflow='auto';
}
}

function hidepopup(popup){
  var popup=document.getElementById(popup);
  popup.style.display='none';
  popup.style.visibility='hidden';}

function showpopup(popup){
 document.getElementById(popup).style.display='block';
 document.getElementById(popup).style.visibility='visible';}

function changewidth(id,tailledeb,taillefin,tempo){
divwidth(id,tailledeb);
    var timer = 0;
    if(tailledeb >taillefin) {
        for(i = tailledeb; i >= taillefin; i=i-10) {
            setTimeout("divwidth('"+id+"',"+i+")",(timer * tempo));
            timer++;
        }
    } else if(tailledeb < taillefin) {
        for(i = tailledeb; i <= taillefin; i=i+10)
            {
            setTimeout("divwidth('"+id+"',"+i+")",(timer * tempo));
            timer++;
        }
    }
}

function divwidth(id,taille){
 document.getElementById(id).style.width=taille;
 document.getElementById(id).style.marginLeft=-(taille/2);
}

function changeheight(id,tailledeb,taillefin,tempo){
divheight(id,tailledeb);
    var timer = 0;
    if(tailledeb >taillefin) {
        for(i = tailledeb; i >= taillefin; i=i-10) {
            setTimeout("divheight('"+id+"',"+i+")",(timer * tempo));
            timer++;
        }
    } else if(tailledeb < taillefin) {
        for(i = tailledeb; i <= taillefin; i=i+10)
            {
            setTimeout("divheight('"+id+"',"+i+")",(timer * tempo));
            timer++;
        }
    }
}

function divheight(id,taille){
 document.getElementById(id).style.height=taille;
// document.getElementById(id).style.marginTop=-(taille/2);
}

function opacity(id, opacStart, opacEnd, millisec) { 
    var speed = Math.round(millisec / 100); 
    var timer = 0; 
    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++; 
        } 
    } 
} 

function shiftOpacity(id, millisec) { 
    //if an element is invisible, make it visible, else make it ivisible 
    if(document.getElementById(id).style.opacity == 0) { 
        opacity(id, 0, 100, millisec); 
    } else { 
        opacity(id, 100, 0, millisec); 
    } 
}

function changeOpac(opacity, id) { 
//change the opacity for different browsers 
    var object = document.getElementById(id).style; 
    object.opacity = (opacity / 100); 
    object.MozOpacity = (opacity / 100); 
    object.KhtmlOpacity = (opacity / 100); 
    object.filter = "alpha(opacity=" + opacity + ")"; 
}

function Changecontenudiv(donnee) {
var updatediv = new Array();
updatediv = donnee.split('|');
if (document.getElementById)
{
document.getElementById(updatediv[0]).innerHTML = updatediv[1];
}
else if (document.all)
{
document.getElementById(updatediv[0]).innerHTML = updatediv[1];
}
}

function makeRequesttempo(url,id_niveau,id_ecrire)
{
setTimeout("makeRequest('"+url+"','"+id_niveau+"','"+id_ecrire+"')",500);
}

function makeRequest(url,id_niveau,id_ecrire) 
{ 
// CREER UNE INSTANCE (UN OBJET) DE LA CLASSE DESIREE FONCTIONNANT SUR PLUSIEURS NAVIGATEURS 
var http_request = false; 
// POUR MOZILLA ET SAFARI 
if (window.XMLHttpRequest) 
{ 
http_request = new XMLHttpRequest(); 
if (http_request.overrideMimeType) 
{ 
// UN APPEL DE FONCTION SUPPLEMENTAIRE POUR ECRASER L'EN TETE ENVOYE PAR LE SERVEUR (AU CAS OU IL NE S'AGIT PAS DE TEXT/XML, CAS DE CERTAINES VERSIONS DE FIREFOX 
http_request.overrideMimeType('text/xml'); 
} 

} 
// POUR IE 
else if (window.ActiveXObject) 
{ 
try 
{ 
http_request = new ActiveXObject("Msxml2.XMLHTTP"); 
} 
catch (e) 
{ 
try 
{ 
http_request = new ActiveXObject("Microsoft.XMLHTTP"); 
} 
catch (e) {} 
} 
} 

if (!http_request) 
{ 
alert('Abandon :( Impossible de créer une instance XMLHTTP'); 
return false; 
} 
//	FONCTION DE TRAITEMENT APPELLEE QUAND ON RECEVRA LA REPONSE 
http_request.onreadystatechange = function() { traitementReponse(http_request,id_ecrire); 
} 
// LANCEMENT DE LA REQUETE 
http_request.open('POST', url, true); 
// CHANGER LE TYPE MIME DE LA REQUETE POUR ENVOYER LES DONNEES AVEC LA METHODE POST 
http_request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); 
//http_request.setRequestHeader('Content-Type', 'Content-Type: text/html; charset=ISO-8859-1'); 
//http_request.setRequestHeader('Content-Type', 'multipart/form-data'); 
//data="page"+id_niveau; 
http_request.send(id_niveau); 
} 

// FONCTION DE TRAITEMENT 
function traitementReponse(http_request,id_ecrire) 
{ 
var affich=""; 
if (http_request.readyState == 4) 
{ 
// CAS AVEC REPONSE DE PHP EN MODE TEXTE 
if (http_request.status == 200) 
{ 
// CHARGEMENT DES ELEMENTS RECUS DANS LA LISTE 
var affich_list=http_request.responseText; 
obj = document.getElementById(id_ecrire); 
obj.innerHTML = affich_list; 
} 
else 
{ 
//alert('Un problème est survenu avec la requête.'); 
} 
} 
}

function showcodecash(cadre,msg,session)
{
setTimeout("showcodecashtempo('"+cadre+"','"+msg+"','"+session+"')",1000);
}

function showcodecashtempo(cadre,msg,session)
{
if (document.getElementById)
{
document.getElementById(cadre).innerHTML = msg;
}
else if (document.all)
{
document.getElementById(cadre).innerHTML = msg;
}
if(session==''){
if(msg.match("compapro")){
ouvrepopup('ajax/inscription.php','',500,400);
}else{
ouvrepopup('ajax/inscriptioncoupon.php','',500,400);
}
setTimeout("self.focus()",100);
}
}

function identajax() {
changeheight('popup',400,180,20);
makeRequest('/ajax/identification.php','','popup');
}

//-------------------------Selection mail parrain + categorie admin--------------------------

function checkSelect(email)
{
var emailform=document.forms['parrainage'].elements['email'].value;
if(document.forms['parrainage'].elements[email].checked==true){
document.forms['parrainage'].elements['email'].value = email+';'+emailform;
}else{
emailform=emailform.replace(email+';','');
document.forms['parrainage'].elements['email'].value = emailform;
}
}

function checkSelectCat(categorie)
{
var catform=document.forms["inscription"].elements["keywords_categorie"].value;
if(document.forms["inscription"].elements[categorie].checked==true){
document.forms["inscription"].elements["keywords_categorie"].value = categorie+"|"+catform;
}else{
catform=catform.replace(categorie+"|","");
document.forms["inscription"].elements["keywords_categorie"].value = catform;
}
}

//-----------------------------Redirection Ajax---------------------------------
function makeRedir(url,id_niveau,id_ecrire)
{
var http_request = false;
if (window.XMLHttpRequest)
{http_request = new XMLHttpRequest();
if (http_request.overrideMimeType){http_request.overrideMimeType('text/xml');}
}else if (window.ActiveXObject){try{http_request = new ActiveXObject("Msxml2.XMLHTTP");}
catch (e){try{http_request = new ActiveXObject("Microsoft.XMLHTTP");}
catch (e) {}
}}
if (!http_request)
{alert('Abandon :( Impossible de créer une instance XMLHTTP');
return false;}
http_request.onreadystatechange = function() { traitementRedir(http_request,id_ecrire);}
http_request.open('POST', url, true);
http_request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
http_request.send(id_niveau);
}
function traitementRedir(http_request,id_ecrire){
var affich="";
if (http_request.readyState == 4){
if (http_request.status == 200){
var affich_list=http_request.responseText;
window.location=affich_list;
}}}

