function verifierFormInscription() {
	Expression = new RegExp("^[0-9a-zA-Z_\.-]+@[0-9a-zA-Z-]{2,}\.[a-zA-Z]{2,4}$","");
	var erreur = 0;
	
	
	if (!Expression.test($('email_inscription').value)) {
		erreur = 1;
	}
	
	if ($('mdp_inscription').value.length < 4) {
		erreur = 1;
	}
	
	if ($('pseudo_inscription').value.length < 2) {
		erreur = 1;
	}
	
	if ($('cgu_ok').checked != true) {
		erreur = 1;
	}
	
	if (erreur == 0) {
		$('register').disabled = false;
	}
	else {
		$('register').disabled = true;
	}
}

function inscrireMembre() {
	desactiver('register');
	
	var chk="";
	
	if ($('cgu_ok').checked == true) {
		chk="&cgu_ok=1";
	}

	ajaxCall('/inscription-ajax.html', "email_inscription="+ $('email_inscription').value +"&mdp_inscription="+ $('mdp_inscription').value +"&pseudo_inscription="+ $('pseudo_inscription').value + chk, 'bloc_register');

	setTimeout("$('bloc_register_err').fade('out')",5000)
}

function voirTousAmis(membre,page) {
	ajaxCall('/voir-tous-amis.html', "membre="+membre+"&page="+ page, 'friends_data_'+membre);
}

function changerMdp() {  
	if ($('mdp_courant').value.length >= 4 && $('nouveau_mdp').value.length >= 4 && $('confirm_mdp').value.length >= 4) {
		$('erreurTousChamps').className = 'hidden';
		
		if ($('nouveau_mdp').value == $('confirm_mdp').value) {
			//desactiver('changer_mdp');
			$('erreurMdpDifferents').className = 'hidden';
			
			ajaxCall('/changer-mdp-ajax.html', "mdp_courant="+ $('mdp_courant').value +"&nouveau_mdp="+ $('nouveau_mdp').value +"&confirm_mdp="+ $('confirm_mdp').value, 'private_profil_bloc_data_change_pwd');
		}
		else {
			$('erreurMdpDifferents').className = 'blocErreur';
		}
	}
	else {
		$('erreurTousChamps').className = 'blocErreur';
	}
}

function verifierFormNews() {
	var txt = $('corps_news').value;
	var nb = txt.length;
	var max = 250;
	
	if (nb > max) { 
		$('corps_news').value = txt.substring(0, max);
		nb = max;
	}
	$('nb_news').innerHTML= max - nb;
	
	var erreur = 0;
	
	if ($('sujet_news').value.length == 0) {
		erreur = 1;
	}
	
	if ($('corps_news').value.length == 0) {
		erreur = 1;
	}
	
	if (erreur == 0) {
		$('private_profile_submit').disabled = false;
	}
	else {
		$('private_profile_submit').disabled = true;
	}
}

function posterNews() {
	desactiver('private_profile_submit');
	
	ajaxCall('/gerer-news-ajax.html', "action=ecrire&sujet_news="+ $('sujet_news').value +"&corps_news="+ $('corps_news').value, 'private_profil_bloc_news_background');
	$('sujet_news').value = '';
	$('corps_news').value = '';
}

function updateProfil() {
	ajaxCall('/update-profil-ajax.html', "user_name="+$('user_name').value+"&user_name_h="+$('user_name_h').value+"&type_artiste="+ $('type_artiste').value +"&country="+ $('country').value +"&city="+ $('city').value +"&site_1="+ $('site_1').value +"&site_2="+ $('site_2').value +"&style1="+ $('style1').value +"&style2="+ $('style2').value +"&style3="+ $('style3').value +"&bio="+ $('bio').value, 'confirmMaj');
	$('user_name_h').value=$('user_name').value;
	$('confirmMaj').className = '';
}

function supprimerNews(NewsId) {
	ajaxCall('/gerer-news-ajax.html', "action=supprimer&id_news="+ NewsId, 'private_profil_bloc_news_background');
}

function publierNews(NewsId) {
	ajaxCall('/gerer-news-ajax.html', "action=publier&id_news="+ NewsId, '');
	$("pub"+NewsId).innerHTML='<a href="#" onclick="depublierNews('+ NewsId +'); return false;"><img src="_images/design/btn_news_unpublish.png" alt="Unpublish This News" /></a>';
}

function depublierNews(NewsId) {
	ajaxCall('/gerer-news-ajax.html', "action=depublier&id_news="+ NewsId, '');
	$("pub"+NewsId).innerHTML='<a href="#" onclick="publierNews('+ NewsId +'); return false;"><img src="_images/design/btn_news_publish.png" alt="Publish This News" /></a>';
}

function compterBio() {
	var txt = $('bio').value;
	var nb = txt.length;
	var max = 1000;
	
	if (nb > max) { 
		$('bio').value = txt.substring(0, max);
		nb = max;
	}
	$('nb_bio').innerHTML= max - nb;
}

function voirToutesNews(page) {
	ajaxCall('/voir-toutes-news-ajax.html', "page="+ page, 'private_profil_bloc_news_background');
}

function SoumettreTrack() {
	$("bc_artist").value="";
	$("bc_titre").value="";
	
}

function changerPaypal() {
	Expression = new RegExp("^[0-9a-zA-Z_\.-]+@[0-9a-zA-Z-]{2,}\.[a-zA-Z]{2,4}$","");
	
	if (Expression.test($('paypal').value)) {
		$('erreurEmailPaypal').className = 'hidden';
		
		ajaxCall('/changer-paypal-ajax.html', "paypal="+ $('paypal').value, 'recapPaypal');
		display('private_profil_paypal_config');
	}
	else {
		$('erreurEmailPaypal').className = 'blocErreur';
	}
}

function switchBio() {
	if (!bio_state) 
		showBio()
	else
		hideBio()
	bio_state=1-bio_state
}
function showBio() {
	
	var action = {};
	action[0] = {height:300,
				opacity:1}
	bio.start(action)
	bio_text=$('bio-button-switch').get('text')
	//$('bio-button-switch').set('text','x')
}

function hideBio() {
	var action = {};
	action[0] = {height:80,
				opacity:1}
	bio.start(action)
	$('bio-button-switch').set('text',bio_text)
}

function voirToutesNewsProfil(page, idProfil) {
	if(idProfil){curProfil=idProfil;}
	else{idProfil=curProfil;}
	
	ajaxCall('/voir-toutes-news-ajax-profil.html', "page="+ page +"&idProfil="+ idProfil, 'profil_news_data');
}

function ajouterAmi(idProfil) {
	ajaxCall('/ajouter-ami.html', "idAmi="+ idProfil, '');
	$('demandeAmi').innerHTML= tradDemandeAmiEnvoyee;
}
