
function fxButton (buttonText,buttonLink) {
	document.write("<a href='buttonLink'><span style='color:white;'>"+buttonText+"</span></a>");
	
}

function loadurl (wurl) {
window.document.location.href=wurl;
}

function phpmail_reload(lien){
if (lien != "") {
	var nbre = 1+Math.floor(Math.random()*1000000); 
	document.imagetag.src="data/image.php?z="+nbre+"&"+lien;
	}
}

function affich(numero){ // http://www.javascriptfr.com/forum/sujet-LIRE-JS-DANS-JAVASCRIPT_1207000.aspx
var w = 300;
var h = 650;
var hw = window.open('_vote2.php?id='+numero,'_tremplin','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,width='+w+',height='+h);
hw.resizeTo(w, h); // taille non prise en compte sous Chrome ! http://www.toutjavascript.com/reference/reference.php?ref=resizeTo&parent=6 
hw.moveTo((screen.width-w)/2,(screen.height-h)/2);  // pas de reprise de focus sous Safari ! http://www.toutjavascript.com/reference/reference.php?ref=resizeTo&parent=6
if (top.document.getElementById && top.document.getElementById('cell_'+numero) && top.document.getElementById('cell_show_'+numero)) {
	document.getElementById('cell_'+numero).style.display = 'none';
	document.getElementById('cell_show_'+numero).style.display = 'block';
	}
//hw.document.close();
hw.focus();
}

function affich_after(numero){ // http://www.javascriptfr.com/forum/sujet-LIRE-JS-DANS-JAVASCRIPT_1207000.aspx
var w = 300;
var h = 750;
var hw = window.open('_vote2.php?id='+numero,'_tremplin','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,width='+w+',height='+h);
hw.resizeTo(w, h); // taille non prise en compte sous Chrome ! http://www.toutjavascript.com/reference/reference.php?ref=resizeTo&parent=6 
hw.moveTo((screen.width-w)/2,(screen.height-h)/2);  // pas de reprise de focus sous Safari ! http://www.toutjavascript.com/reference/reference.php?ref=resizeTo&parent=6
hw.focus();
}


	// http://www.commentcamarche.net/forum/affich-812243-verifier-l-email-dans-un-formulaire
	isEmail = function(emailStr) {
		var checkTLD = 1;
		var knownDomsPat = /^(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|­pro|museum|fr)$/;
		var emailPat = /^(.+)@(.+)$/;
		var specialChars = "\\(\\)><@,;:\\\\\\\"\\.\\[\\]";
		var validChars = "\[^\\s" + specialChars + "\]";
		var quotedUser = "(\"[^\"]*\")";
		var ipDomainPat = /^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;
		var atom = validChars + '+';
		var word = "(" + atom + "|" + quotedUser + ")";
		var userPat = new RegExp("^" + word + "(\\." + word + ")*$");
		var domainPat = new RegExp("^" + atom + "(\\." + atom +")*$");
		var matchArray = emailStr.match(emailPat);
		if (matchArray == null) { return false; }
		var user = matchArray[1];
		var domain = matchArray[2];
		for (i=0; i<user.length; i++) {
			if (user.charCodeAt(i) > 127) { return false; }
		}
		for (i=0; i<domain.length; i++) {
			if (domain.charCodeAt(i) > 127) { return false; }
		}
		if (user.match(userPat) == null) { return false; }
		var IPArray=domain.match(ipDomainPat);
		if (IPArray != null) {
			for (var i=1; i<=4; i++) {
				if (IPArray[i] > 255) { return false; }
			}
			return true;
		}
		var atomPat = new RegExp("^" + atom + "$");
		var domArr = domain.split(".");
		var len = domArr.length;
		for (i=0; i<len; i++) {
			if (domArr[i].search(atomPat) == -1) { return false; }
		}
		if (checkTLD && domArr[domArr.length-1].length!=2 && domArr[domArr.length-1].search(knownDomsPat)==-1) { return false; }
		if (len < 2) { return false; }
		return true;
	}

	function ValidFormLogin_new (CurrentForm){
	if (CurrentForm.cnx_login.value == ""){alert("\nVeuillez saisir votre pseudo.");content=CurrentForm.cnx_login.focus();return false;}
	if (CurrentForm.cnx_passw.value == ""){alert("\nVeuillez saisir votre mot de passe.");content=CurrentForm.cnx_passw.focus();return false;}
	if (CurrentForm.cnx_passwbis.value == ""){alert("\nVeuillez saisir à nouveau votre mot de passe.");content=CurrentForm.cnx_passwbis.focus();return false;}
	if (CurrentForm.cnx_passw.value != CurrentForm.cnx_passwbis.value){alert("\nErreur sur la confirmation du mot de passe.");content=CurrentForm.cnx_passw.focus();return false;}
	//if (CurrentForm.cnx_passw.value == CurrentForm.cnx_login.value){alert("\nLe mot de passe doit être différent du pseudo.");content=CurrentForm.cnx_passw.focus();return false;}
	if (CurrentForm.cnx_email.value == ""){alert("\nVeuillez saisir votre adresse email.");content=CurrentForm.cnx_email.focus();return false;}
	if (CurrentForm.cnx_emailbis.value == ""){alert("\nVeuillez saisir à nouveau votre adresse email.");content=CurrentForm.cnx_emailbis.focus();return false;}
	if (CurrentForm.cnx_email.value != CurrentForm.cnx_emailbis.value){alert("\nErreur sur la confirmation de l'adresse email");content=CurrentForm.cnx_email.focus();return false;}
	if (! isEmail(CurrentForm.cnx_email.value)){alert("\nVotre adresse email n'est pas valide.");content=CurrentForm.cnx_email.focus();return false;}
	CurrentForm.cnx_action.disabled = true;	
	return true;
	}

	function ValidFormLogin_cnx (CurrentForm){
	if (CurrentForm.cnx_login.value == ""){alert("\nVeuillez saisir votre pseudo.");content=CurrentForm.cnx_login.focus();return false;}
	if (CurrentForm.cnx_passw.value == ""){alert("\nVeuillez saisir votre mot de passe.");content=CurrentForm.cnx_passw.focus();return false;}
	CurrentForm.cnx_action.disabled = true;	
	return true;
	}

	function ValidFormLogin_forget (CurrentForm){
	if ((CurrentForm.cnx_login.value == "") && (CurrentForm.cnx_email.value == "")) {alert("\nVeuillez saisir pseudo ou adresse email.");content=CurrentForm.cnx_login.focus();return false;}
	if ((CurrentForm.cnx_login.value != "") && (CurrentForm.cnx_email.value != "")) {alert("\nVeuillez saisir pseudo ou adresse email.");content=CurrentForm.cnx_login.focus();return false;}
	CurrentForm.cnx_action.disabled = true;	
	return true;
	}

	function ValidFormArtiste_new (CurrentForm){
	if (CurrentForm.new_nom.value == ""){alert("\nVeuillez saisir le nom de l'artiste.");content=CurrentForm.new_nom.focus();return false;}
	if (CurrentForm.new_urlmp3a.value == ""){alert("\nVeuillez saisir l'URL du MP3.");content=CurrentForm.new_urlmp3a.focus();return false;}
	if (CurrentForm.new_urlmp3b.value == ""){alert("\nVeuillez saisir l'URL du MP3.");content=CurrentForm.new_urlmp3b.focus();return false;}
	if (CurrentForm.new_urlmp3c.value == ""){alert("\nVeuillez saisir l'URL du MP3.");content=CurrentForm.new_urlmp3c.focus();return false;}
	CurrentForm.cnx_action.disabled = true;	
	return true;
	}

	function ValidFormArtisteUpdate (CurrentForm){
	if (CurrentForm.new_nom.value == ""){alert("\nVeuillez saisir le nom de l'artiste.");content=CurrentForm.new_nom.focus();return false;}
	if (CurrentForm.new_urlmp3a.value == ""){alert("\nVeuillez saisir l'URL du MP3.");content=CurrentForm.new_urlmp3a.focus();return false;}
	if (CurrentForm.new_urlmp3b.value == ""){alert("\nVeuillez saisir l'URL du MP3.");content=CurrentForm.new_urlmp3b.focus();return false;}
	if (CurrentForm.new_urlmp3c.value == ""){alert("\nVeuillez saisir l'URL du MP3.");content=CurrentForm.new_urlmp3c.focus();return false;}
	CurrentForm.cnx_action.disabled = true;	
	return true;
	}

	function ValidFormContact (CurrentForm){
	if (CurrentForm.name.value == ""){alert("\nVeuillez saisir votre nom.");content=CurrentForm.name.focus();return false;}
	if (CurrentForm.email.value == ""){alert("\nVeuillez saisir votre adresse email.");content=CurrentForm.email.focus();return false;}
	if (CurrentForm.emailbis.value == ""){alert("\nVeuillez saisir à nouveau votre adresse email.");content=CurrentForm.emailbis.focus();return false;}
	if (CurrentForm.email.value != CurrentForm.emailbis.value){alert("\nErreur sur la confirmation de l'adresse email");content=CurrentForm.email.focus();return false;}
	if (! isEmail(CurrentForm.email.value)){alert("\nVotre adresse email n'est pas valide.");content=CurrentForm.email.focus();return false;}
	if (CurrentForm.subject.value == ""){alert("\nVeuillez saisir l'objet de votre message.");content=CurrentForm.subject.focus();return false;}
	if (CurrentForm.message.value == ""){alert("\nVeuillez saisir votre message.");content=CurrentForm.message.focus();return false;}
	if (CurrentForm.kod.value == ""){alert("\nVeuillez saisir le code de l'image.");content=CurrentForm.kod.focus();return false;}
	//CurrentForm.cnx_action.disabled = true;	
	return true;
	}

	function ValidFormChangePassword (CurrentForm){
	if (CurrentForm.cnx_passw.value == ""){alert("\nVeuillez saisir l'ancien mot de passe.");content=CurrentForm.cnx_passw.focus();return false;}
	if (CurrentForm.new_passw.value == ""){alert("\nVeuillez saisir le nouveau mot de passe.");content=CurrentForm.new_passw.focus();return false;}
	if (CurrentForm.new_passwbis.value == ""){alert("\nVeuillez saisir à nouveau le nouveau mot de passe.");content=CurrentForm.new_passwbis.focus();return false;}
	if (CurrentForm.new_passw.value != CurrentForm.new_passwbis.value){alert("\nErreur sur la confirmation du nouveau mot de passe");content=CurrentForm.new_passw.focus();return false;}
	if (CurrentForm.cnx_passw.value == CurrentForm.new_passw.value){alert("\nLe nouveau mot de passe doit être différent de l'ancien");content=CurrentForm.new_passw.focus();return false;}
	CurrentForm.cnx_action.disabled = true;	
	return true;
	}

	function ValidFormChangeProfil (CurrentForm){
	//	if ((CurrentForm.cnx_pseudo.selectedIndex == -1) || (CurrentForm.cnx_pseudo.selectedIndex == 0)){alert("\nVeuillez sélectionner un pseudo.");content=CurrentForm.cnx_pseudo.focus();return false;}
		if ((CurrentForm.cnx_pseudo.selectedIndex > 0) && (CurrentForm.cnx_email.selectedIndex > 0)){alert("\nVeuillez sélectionner un pseudo ou un email.");content=CurrentForm.cnx_pseudo.focus();return false;}
		if ((CurrentForm.cnx_pseudo.selectedIndex <= 0) && (CurrentForm.cnx_email.selectedIndex <= 0)){alert("\nVeuillez sélectionner un pseudo ou un email.");content=CurrentForm.cnx_pseudo.focus();return false;}
		if (CurrentForm.cnx_pseudo.selectedIndex > 0) {
			pseudo = CurrentForm.cnx_pseudo.options[CurrentForm.cnx_pseudo.selectedIndex].text;
			}
		if (CurrentForm.cnx_email.selectedIndex > 0) {
			pseudo = CurrentForm.cnx_email.options[CurrentForm.cnx_email.selectedIndex].text;
			}
	if ((CurrentForm.cnx_profil.selectedIndex == -1) || (CurrentForm.cnx_profil.selectedIndex == 0)){alert("\nVeuillez sélectionner le nouveau profil.");content=CurrentForm.cnx_profil.focus();return false;}
	if (CurrentForm.cnx_passw.value == ""){alert("\nVeuillez saisir le mot de passe.");content=CurrentForm.cnx_passw.focus();return false;}
	CurrentForm.cnx_action.disabled = true;	
	return true;
	}

	function ValidFormChangePlayer (CurrentForm){
	if (CurrentForm.cnx_passw.value == ""){alert("\nVeuillez saisir le mot de passe.");content=CurrentForm.cnx_passw.focus();return false;}
	CurrentForm.cnx_action.disabled = true;	
	return true;
	}

	function ValidFormParticipeJeu (CurrentForm){
	if (CurrentForm.cnx_passw.value == ""){alert("\nVeuillez saisir le mot de passe.");content=CurrentForm.cnx_passw.focus();return false;}
	if (CurrentForm.cnx_participate.selectedIndex == 0) {
		rc = confirm("Attention, vous avez choisi de ne pas participer au tirage au sort !");
		if (rc) CurrentForm.cnx_action.disabled = true;	
		return rc;
		}
	else {
		CurrentForm.cnx_action.disabled = true;	
		return true;
		}
	}

	function ValidFormChangeEmail (CurrentForm){
	if (CurrentForm.cnx_email.value == ""){alert("\nVeuillez saisir votre adresse email actuelle.");content=CurrentForm.cnx_email.focus();return false;}
	if (CurrentForm.new_email.value == ""){alert("\nVeuillez saisir la nouvelle adresse email.");content=CurrentForm.new_email.focus();return false;}
	if (CurrentForm.new_emailbis.value == ""){alert("\nVeuillez saisir à nouveau la nouvelle adresse email.");content=CurrentForm.new_emailbis.focus();return false;}
	if (CurrentForm.new_email.value != CurrentForm.new_emailbis.value){alert("\nErreur sur la confirmation de la nouvelle adresse email");content=CurrentForm.new_emailbis.focus();return false;}
	if (CurrentForm.cnx_email.value == CurrentForm.new_email.value){alert("\nLa nouvelle adresse email doit être différente de l'actuelle");content=CurrentForm.new_email.focus();return false;}
	if (CurrentForm.cnx_passw.value == ""){alert("\nVeuillez saisir votre mot de passe.");content=CurrentForm.cnx_passw.focus();return false;}
	CurrentForm.cnx_action.disabled = true;	
	return true;
	}

	function ValidFormKillProfil (CurrentForm,bIsAdmin){
	if (bIsAdmin) {
		if ((CurrentForm.cnx_pseudo.selectedIndex > 0) && (CurrentForm.cnx_email.selectedIndex > 0)){alert("\nVeuillez sélectionner un pseudo ou un email.");content=CurrentForm.cnx_pseudo.focus();return false;}
		if ((CurrentForm.cnx_pseudo.selectedIndex <= 0) && (CurrentForm.cnx_email.selectedIndex <= 0)){alert("\nVeuillez sélectionner un pseudo ou un email.");content=CurrentForm.cnx_pseudo.focus();return false;}
		if (CurrentForm.cnx_pseudo.selectedIndex > 0) {
			pseudo = CurrentForm.cnx_pseudo.options[CurrentForm.cnx_pseudo.selectedIndex].text;
			}
		if (CurrentForm.cnx_email.selectedIndex > 0) {
			pseudo = CurrentForm.cnx_email.options[CurrentForm.cnx_email.selectedIndex].text;
			}
		}
	else {
		pseudo = CurrentForm.cnx_pseudo.value;
		}
	if (CurrentForm.cnx_passw.value == ""){alert("\nVeuillez saisir le mot de passe.");content=CurrentForm.cnx_passw.focus();return false;}
	rc = confirm("Confirmez la suppression définitive du compte ["+pseudo+"] ??");
	if (rc) CurrentForm.cnx_action.disabled = true;	
	return rc;
	}

	function ValidFormOptoutProfil (CurrentForm,bIsAdmin){
	if (bIsAdmin) {
//		if ((CurrentForm.cnx_pseudo.selectedIndex == -1) || (CurrentForm.cnx_pseudo.selectedIndex == 0)){alert("\nVeuillez sélectionner un pseudo.");content=CurrentForm.cnx_pseudo.focus();return false;}
		if ((CurrentForm.cnx_pseudo.selectedIndex > 0) && (CurrentForm.cnx_email.selectedIndex > 0)){alert("\nVeuillez sélectionner un pseudo ou un email.");content=CurrentForm.cnx_pseudo.focus();return false;}
		if ((CurrentForm.cnx_pseudo.selectedIndex <= 0) && (CurrentForm.cnx_email.selectedIndex <= 0)){alert("\nVeuillez sélectionner un pseudo ou un email.");content=CurrentForm.cnx_pseudo.focus();return false;}
		if (CurrentForm.cnx_pseudo.selectedIndex > 0) {
			pseudo = CurrentForm.cnx_pseudo.options[CurrentForm.cnx_pseudo.selectedIndex].text;
			}
		if (CurrentForm.cnx_email.selectedIndex > 0) {
			pseudo = CurrentForm.cnx_email.options[CurrentForm.cnx_email.selectedIndex].text;
			}
		if ((CurrentForm.cnx_optout.selectedIndex == -1) || (CurrentForm.cnx_optout.selectedIndex == 0)){alert("\nVeuillez sélectionner opt-in / opt-out.");content=CurrentForm.cnx_optout.focus();return false;}
		}
	else {
		if (CurrentForm.cnx_optout.selectedIndex == -1) {alert("\nVeuillez sélectionner opt-in / opt-out.");content=CurrentForm.cnx_optout.focus();return false;}
		}
	if (CurrentForm.cnx_passw.value == ""){alert("\nVeuillez saisir le mot de passe.");content=CurrentForm.cnx_passw.focus();return false;}
	CurrentForm.cnx_action.disabled = true;	
	return true;
	}
