function loadXMLDoc(url,fonction) {
	req = false;
    // branch for native XMLHttpRequest object
    if(window.XMLHttpRequest) {
    	try {
			req = new XMLHttpRequest();
        } catch(e) {
			req = false;
        }
    // branch for IE/Windows ActiveX version
    } else if(window.ActiveXObject) {
       	try {
        	req = new ActiveXObject("Msxml2.XMLHTTP");
      	} catch(e) {
        	try {
          		req = new ActiveXObject("Microsoft.XMLHTTP");
        	} catch(e) {
          		req = false;
        	}
		}
    }
	if(req) {
		var lafonction = fonction;
		var b = new Array();
		if(arguments.length > 2) {
			for(var i = 2; i < arguments.length; i++) {
				b.push(arguments[i]);
			}
		}
		req.onreadystatechange = function() { lafonction.apply(null, b); };
		req.open("GET", url, true);
		req.send(null);
	}
}
function loadXMLDocSync(url,fonction) {
	req = false;
    // branch for native XMLHttpRequest object
    if(window.XMLHttpRequest) {
    	try {
			req = new XMLHttpRequest();
        } catch(e) {
			req = false;
        }
    // branch for IE/Windows ActiveX version
    } else if(window.ActiveXObject) {
       	try {
        	req = new ActiveXObject("Msxml2.XMLHTTP");
      	} catch(e) {
        	try {
          		req = new ActiveXObject("Microsoft.XMLHTTP");
        	} catch(e) {
          		req = false;
        	}
		}
    }
	if(req) {
		req.open("GET", url, false);
		req.send(null);
		fonction();
	}
}

function sublogin() {
	var texte="dbdch=1";
	for(var i=0; i<document.loginform.elements.length; i++) {
		texte+='&'+document.loginform.elements[i].name+'='+document.loginform.elements[i].value;
	}
	req.open("POST", document.loginform.action, true);
	req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	req.send(texte);
	req.onreadystatechange = checklogin;
}

function checklogin() {
    // only if req shows "loaded"
    if (req.readyState == 4) {
        // only if "OK"
        if (req.status == 200) {
            if(req.responseText=="0") {
            	alert("ERREUR !\nEssayez encore...\n\nIMPORTANT : si vous venez de crÈer votre compte, avez-vous bien cliquÈ sur le lien de confirmation contenu dans l'email d'inscription ? VÈrifiez vos emails et aussi les courriers indÈsirables (SPAM)\n\n----------------------------\n\nERROR !\ntry again with a correct login and password\n\nIMPORTANT : if you have just created your account, did you click well on the link of confirmation contained in the email of inscription ? Check your emails and also the undesirable mails (Spam)\n\n");
            } else if(req.responseText=="ban") {
            	loadXMLDoc('ban.php', aff);
            } else if(req.responseText=="maj") {
            	loadXMLDoc('maj.php', aff);
            } else {
            	loadXMLDoc('valide_entree.php', aff);
            }
        }
    }
}

function cp_ville() {
    // only if req shows "loaded"
    if (req.readyState == 4) {
        // only if "OK"
        if (req.status == 200) {
            document.getElementById('retourcp').innerHTML=req.responseText;
        }
    }
}
function cp_ville2() {
    // only if req shows "loaded"
    if (req.readyState == 4) {
        // only if "OK"
        if (req.status == 200) {
            document.getElementById('retourcp2').innerHTML=req.responseText;
        }
    }
}

function retourmenusc() {
    // only if req shows "loaded"
    if (req.readyState == 4) {
        // only if "OK"
        if (req.status == 200) {
            document.getElementById('retourmenu').innerHTML=req.responseText;
            window.scrollTo(0,0);
        }
    }
}
function retourmenusi() {
    // only if req shows "loaded"
    if (req.readyState == 4) {
        // only if "OK"
        if (req.status == 200) {
            document.getElementById('retourmenu').innerHTML=req.responseText;
        }
    }
}

function retourpseudo() {
    // only if req shows "loaded"
    if (req.readyState == 4) {
        // only if "OK"
        if (req.status == 200) {
            document.getElementById('retourpseudo').innerHTML=req.responseText;
        }
    }
}
function aff() {
    // only if req shows "loaded"
    if (req.readyState == 4) {
        // only if "OK"
        if (req.status == 200) {
            document.getElementById('details').innerHTML=req.responseText;
            cdiv('inscription');
            odiv('details');
        }
    }
}
function affretour() {
    // only if req shows "loaded"
    if (req.readyState == 4) {
        // only if "OK"
        if (req.status == 200) {
        	if(req.responseText!="") {
            	document.getElementById('retour').innerHTML=req.responseText;
            }
        }
    }
}
function rdj(numid) {
    // only if req shows "loaded"
    if (req.readyState == 4) {
        // only if "OK"
        if (req.status == 200) {
			var nouveau=document.createElement('select');
			var opt; 
			nouveau.setAttribute("name","id_dj[]");
			opt=document.createElement('option');
			opt.setAttribute('value', '');
			opt.appendChild(document.createTextNode('Choose ...'));
			nouveau.appendChild(opt);
			for(var i=0; i<req.responseXML.getElementsByTagName('item').length; i++) {
				opt=document.createElement('option');
				opt.setAttribute('value', req.responseXML.getElementsByTagName('item')[i].getAttribute('id_dj'));
				opt.appendChild(document.createTextNode(unescape(req.responseXML.getElementsByTagName('item')[i].getAttribute('nom'))));
				nouveau.appendChild(opt);
			}
			document.getElementById('djs'+numid).appendChild(nouveau);
			document.getElementById('djs'+numid).appendChild(document.createTextNode(' '));
			var bouton=document.createElement("input");
			bouton.setAttribute("value", " + ");
			bouton.setAttribute("type", "button");
			bouton.setAttribute("onclick", "loadXMLDoc('rajouterdj.php', rdj, '"+numid+"');");
			document.getElementById('djs'+numid).appendChild(bouton);
			document.getElementById('djs'+numid).appendChild(document.createElement('br'));
        }
    }
}

function retoursimple() {
    // only if req shows "loaded"
    if (req.readyState == 4) {
        // only if "OK"
        if (req.status == 200) {
            return true;
        }
    }
}
function renvoicommun(id) {
    // only if req shows "loaded"
    if (req.readyState == 4) {
        // only if "OK"
        if (req.status == 200) {
            var retour=req.responseXML;
            if(retour.getElementsByTagName('erreur').length>0) {
            	alert(retour.getElementsByTagName('erreur')[0].firstChild.data);
            } else {
            	document.getElementById(id).innerHTML=retour.getElementsByTagName('commun')[0].firstChild.data;
            }
        }
    }
}
function checkpseudo() {
	loadXMLDocSync('check.php?p='+document.inscription.pseudo.value, retourpseudo);
}
function cv() {
	loadXMLDoc('cptoville.php?p='+document.inscription.pays.value+'&c='+document.inscription.code_postal.value, cp_ville);
}
function cv2() {
	loadXMLDoc('cptoville.php?p='+document.maj.pays.value+'&c='+document.maj.code_postal.value, cp_ville2);
}
function swdiv(div) {
	if(document.getElementById(div).style.display=='block') {
		document.getElementById(div).style.display='none';
	} else {
		document.getElementById(div).style.display='block';
	}
}
function odiv(div) {
		document.getElementById(div).style.display='block';
}
function cdiv(div) {
		document.getElementById(div).style.display='none';
}

function popupWindowLost(url) {
window.open(url,'popupWindowLost','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,copyhistory=no,width=650, height=80,screenX=30,screenY=30,top=30,left=30')
}
function popupWindowChat(url) {
window.open(url,'popupWindowChat','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no,width=620, height=430,screenX=30,screenY=30,top=30,left=30')
}
function popupWindowCGU(url) {
window.open(url,'popupWindowCGU','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width=900, height=400,screenX=0,screenY=0,top=0,left=0')
}
function popupWindowHelp(url) {
window.open(url,'popupWindowHelp','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width=300, height=500,screenX=30,screenY=30,top=30,left=30')
}
function popupWindowerreur(url) {
window.open(url,'popupWindowerreur','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width=300, height=200,screenX=30,screenY=30,top=30,left=30')
}
function popupWindow(url) {
window.open(url,'popupWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no,width=640, height=640,screenX=30,screenY=30,top=30,left=30')
}
function popupWindowtaille(url,larg,haut) {
window.open(url,'popupWindowtaille','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no,width='+larg+', height='+haut+',screenX=30,screenY=30,top=30,left=30')
}
function popupWindowvideo(url) {
window.open(url,'popupWindowvideo','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no,width=300, height=300,screenX=50,screenY=50,top=50,left=50')
}

function verifmsg() {
    // only if req shows "loaded"
    if (req.readyState == 4) {
        // only if "OK"
        if (req.status == 200) {
            if(req.responseText != 0) {
				top.frames['entete'].document.getElementById('limsg').className='petitmenublink';
				top.frames['entete'].document.getElementById('alarme').style.visibility='visible';
				try {
					if(top.document.title==titrenormal) {
						top.frames['entete'].document.getElementById('musique').Play();
					}
				} catch(e) {
					try {
						if(top.document.title==titrenormal) {
							top.frames['entete'].document.getElementById('musique').doPlay();
						}
					} catch(e2) {
						top.frames['entete'].document.getElementById('limsg').style.color='30FF00';
					}
				}
				top.document.title=titremsg;
			} else {
				top.frames['entete'].document.getElementById('limsg').className='petitmenu';
				top.frames['entete'].document.getElementById('alarme').style.visibility='hidden';
				top.document.title=titrenormal;
			}
		}
	}
}

var submitted=false;
function verifierFriends() {
var error = 0;
var error_message = "ERREUR DANS LE FORMULAIRE\nERROR IN THIS FORM :\n\n";
if(submitted){ 
alert( "... in progress"); 
return false; 
}
var friendemail = document.formfriends.friendemail.value;
if (friendemail == '' || friendemail.length < 5) {
error_message = error_message + "EMAIL INCORRECT\nINCORRECT EMAIL\n\n";
error = 1;
} 
if (error == 1) { 
alert(error_message); 
return false; 
} else { submitted = true; 
return true; 
} 
}

function prout() {
alert('salope de shrell');
return false;
}

submitted=false;
function detruirecompte() {

if(confirm('\nETES_VOUS CERTAIN DE VOULOIR DETRUIRE VOTRE COMPTE ?\nVOTRE ADRESSE EMAIL NE POURRA PLUS ETRE UTILISEE SUR CE SITE; CETTE ACTION ENTRAINE UNE DECONNECTION IMMEDIATE\n\n\nARE YOU SURE TO ERASE YOUR ACCOUNT ? \n\nYour email address will be blacklisted\n\nYOU WILL BE DISCONNECTED IMMEDIATLY\n\n')) {

var error = 0;
var error_message = "\n\nERROR :\n\n";
if(submitted){ 
alert( "... in progress"); 
return false; 
}
var cochedel = document.delcompte.cochedel.value;
if (delcompte.cochedel.checked == false) {
error_message = error_message + "\n\nSVP POUR CONFIRMER IL FAUT COCHER DETRUIRE DEFINITIVEMENT\n\n\nPLEASE CHECK : ERASE FOR EVER\n\n";
error = 1;
}
var delpass = document.delcompte.delpass.value;
if (delpass == '' || delpass.length < 6) {
error_message = error_message + "\n\nMOT DE PASSE INCORRECT\n\nINCORRECT PASSWORD\n\n";
error = 1;
} 
if (error == 1) { 
alert(error_message); 
return false; 
} else { submitted = true; 
return true; 
} 

} else {
alert("\n\nACTION ANNULEE\nTHIS ACTION IS CANCELLED\n\n");
}
}


var submitted=false;
function changeremail() {

if(confirm('\n\nVOULEZ_VOUS REELLEMENT MODIFIER VOTRE ADRESSE EMAIL ? SI VOUS CONFIRMEZ, VOTRE ADRESSE EMAIL SERA REMPLACEE ET VOUS RECEVREZ UN NOUVEAU CODE DE CONFIRMATION QUE VOUS DEVREZ VALIDER OBLIGATOIREMENT. CETTE ACTION ENTRAINE UNE DECONNECTION IMMEDIATE\n\nREALLY WANT TO MODIFY YOUR EMAIL ADDRESS ? IF YOU CONFIRM, YOUR EMAIL ADDRESS WILL BE REPLACED AND YOU WILL RECEIVE A NEW CONFIRMATION CODE TO VALIDATE; THIS ACTION WILL DISCONNECT YOU RIGHT NOW\n\n')) {

var error = 0;
var error_message = "\n\nERROR :\n\n";
if(submitted){ 
alert( "... in progress"); 
return false; 
}
var newemail = document.modifemail.newemail.value;
if (newemail == '') {
error_message = error_message + "ADRESSE EMAIL INCORRECTE\n\nINCORRECT EMAIL ADDRESS\n\n";
error = 1;
} 
if (error == 1) { 
alert(error_message); 
return false; 
} else { submitted = true; 
return true; 
} 

} else {
alert("\n\nACTION ANNULEE\nTHIS ACTION IS CANCELLED\n");
}
}

var submitted=false;
function changerpass() {

if(confirm('\n\nETES VOUS CERTAIN DE VOULOIR MODIFIER VOTRE MOT DE PASSE ? CETTE ACTION ENTRAINE UNE DECONNECTION OBLIGATOIRE\n\nARE YOU SURE TO MODIFY YOUR PASSWORD ? THIS ACTION WILL DISCONNECT YOU RIGHT NOW\n\n')) {

var error = 0;
var error_message = "\n\nERREUR - ERROR :\n\n";
if(submitted){ 
alert( "... in progress"); 
return false; 
}
var old_password = document.modifpass.old_password.value;
if (old_password == '') {
error_message = error_message + "MOT DE PASSE ACTUEL VIDE\nACTUAL PASSWORD EMPTY\n\n";
error = 1;
}
var new_password = document.modifpass.new_password.value;
if (new_password == '' || new_password.length < 6) {
error_message = error_message + "NOUVEAU MOT DE PASSE VIDE OU MOINS DE 6 CARACTERES\nNEW PASSWORD EMPTY OR LESS THAN 6 CHARACTERS\n\n";
error = 1;
}
var confirm_new_password = document.modifpass.confirm_new_password.value;
if (confirm_new_password != new_password) {
error_message = error_message + "NOUVEAU MOT DE PASSE ET CONFIRMATION NE SONT PAS LES MEMES\nNEW PASSWORD AND CONFIRMATION ARE NOT THE SAME\n\n";
error = 1;
}
if (error == 1) { 
alert(error_message); 
return false; 
} else { submitted = true; 
return true; 
} 

} else {
alert("\n\nACTION ANNULEE\nTHIS ACTION IS CANCELLED\n");
}
}
