/* FONCTION POPUP */
function repositionne_elems(){
	//positionne div_foreground_content au milieu de l'écran (en hauteur)
	if (navigator.appName == 'Microsoft Internet Explorer') {
		//document.getElementById('result_ajax').style.top = document.documentElement.scrollTop+'px';
		document.getElementById('div_foreground_content').style.top =  screen.height/5 + document.documentElement.scrollTop+'px';
		document.getElementById('div_foreground').style.height = screen.height + document.documentElement.scrollTop+'px';
	}
	else {
		//document.getElementById('result_ajax').style.top = window.pageYOffset + 'px';
		document.getElementById('div_foreground_content').style.top = (window.innerHeight/4 + window.pageYOffset) + 'px';
		document.getElementById('div_foreground').style.height = (window.innerHeight+window.pageYOffset)+'px';
	}
}

function hidePopup(){
	var elem = document.getElementById('div_foreground');
	elem.style.display = 'none';
	cache_div_foreground_content();
}

function cache_div_foreground_content(){
	elem = document.getElementById('div_foreground_content');
	elem.style.display = 'none';
}
/* ! FONCTION POPUP ! */

function check_tel(num_tel) {
	// Definition du motif a matcher
	var regex = new RegExp(/^(01|02|03|04|05|06|07|08)[0-9]{8}/gi);
	// Definition de la variable booleene match
	var match = false;
	// Test sur le motif
	if(regex.test(num_tel)) { match = true ; }
	else                    { match = false; }
	// On renvoie match
	return match;
}

function check_mail(email) {
   var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
   return reg.test(email);
}

function _(elem) {
	return document.getElementById(elem);
}

/**************************/

function check_sd()      { xajax_check_sd($("#url").val()); }
function check_login()   { xajax_check_login($("#login").val()); }
function check_cb()    	 { xajax_check_cb($("#code_beta").val()); }
function check_captcha() { xajax_check_captcha($("#captcha").val()); }

function connexion() {
	xajax_connexion($("#login").val(), $("#mdp").val());
	return false;
}

function validFormInscription() {
	var erreur = "";
	
	/*if(!$("#message_cb"		).hasClass("valide")) { erreur += "Code béta invalide.\n"; }*/
	if(!$("#message_sd"		).hasClass("valide")) { erreur += "Sous-domaine invalide.\n"; }
	if(!$("#message_lg"		).hasClass("valide")) { erreur += "Login invalide.\n"; }
	if(!$("#message_captcha").hasClass("valide")) { erreur += "Texte de vérification invalide.\n"; }

	if(erreur) {
		alert(erreur);
		return false;
	}
	else { return true; }
}

