
if (!Prototype) {
	// Inclure prototype !
	document.write('<'+'script type="text/javascript" src="/js-tools/prototype-1.6.js"><'+'/script>');
}

function checkString(sval,sopt,sadd) {
var l1_digit = "0123456789";
var l2_alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
var l3_accent = "ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÑÒÓÔÕÖØÙÚÛÜÝßàáâãäåæçèéêëìíîïñòóôõöøùúûüý";
var ls_tot = "";
var rs_ch = "";
var no_ch = "";
var nb_sp = 0;
	if(sval == null || sval == "") return false;
	if(sopt == null) ls_tot = l1_digit + l2_alpha;
	else for(i=0; i<sopt.length; i++) {
		rs_ch = "" + sopt.charAt(i);
		     if(rs_ch == "1") ls_tot += l1_digit;
		else if(rs_ch == "2") ls_tot += l2_alpha;
		else if(rs_ch == "3") ls_tot += l3_accent;
	}
	if(sadd != null && sadd != "") ls_tot += sadd;
	for(i=0; i < sval.length; i++) {
		rs_ch = "" + sval.charAt(i);
		if(ls_tot.indexOf(rs_ch) < 0) { no_ch += rs_ch; break; }
		if(rs_ch == " ") nb_sp++;
	}
	if(no_ch != "" || nb_sp == sval.length) return false;
	return true;
}

function msg_OnTandC(opt) {
var ma_EN = new Array( "You must read & accept Terms & Conditions!" );
var ma_FR = new Array( "Vous devez lire et accepter les Conditions Générales !" );
var pmsg = "";
	if(opt <= 0 || opt > 1) opt = 1;
	opt -= 1;
	if(myLang == "FR") pmsg = ma_FR[opt]; else pmsg = ma_EN[opt];
	alert(pmsg);
}

function msg_OnPseudo(opt) {
var ma_EN = new Array( "You must give a Pseudonym!", "Invalid Pseudonym!\n(minimum length of 4 characters)", "Bad characters in the Pseudonym field!\n(only the alphnumeric, underscore, hyphen and dot characters are allowed)" );
var ma_FR = new Array( "Un Pseudonyme est obligatoire !", "Pseudonyme invalide !\n(longueur minimum de 4 caractères)", "Caractères invalides dans le champ Pseudonyme !\n(seuls les caractères alphanumériques, soulignement, tiret et le point sont autorisés)" );
var pmsg = "";
	if(opt <= 0 || opt > 3) opt = 2;
	opt -= 1;
	if(myLang == "FR") pmsg = ma_FR[opt]; else pmsg = ma_EN[opt];
	alert(pmsg);
}

function msg_OnPasswd(opt) {
var mp_EN = new Array( "You must give a password!", "Invalid password!\n(minimum length of 5 characters)", "Bad characters in the password field!\n(only the alphnumeric characters are allowed)" );
var mp_FR = new Array( "Le Mot de passe est obligatoire !", "Mot de passe invalide !\n(longueur minimum de 5 caractères)", "Caractères invalides dans le champ Mot de passe !\n(seuls les caracteres alphanumériques sont autorisés)" );
var pmsg = "";
	if(opt <= 0 || opt > 3) opt = 2;
	opt -= 1;
	if(myLang == "FR") pmsg = mp_FR[opt]; else pmsg = mp_EN[opt];
	alert(pmsg);
}

//var win_dial = null;
//function winDial() {
//	zz_BwScreenSize();	// dans browser.js
//	win_dial = open("","winBEURONLINE",zz_opFullScreen(false)+",resizable=yes,scrollbars=yes,status=no,statusbar=no,toolbar=no,menubar=no,location=no");
//	win_dial.focus();
//	return win_dial;
//}

function popContact() {
	var url_cont = "http://www.addworks.fr/contact/?Act=1&Serv=cbeur&Lang=" + myLang ;
	var pop_cont = window.open(url_cont,"popDIAL","width=400,height=350,resizable=no,scrollbars=yes,status=no,statusbar=no,toolbar=no,menubar=no,location=no");
	pop_cont.focus();
}

function popDelete() {
	var url_pass = "/cgi-beuronline/Delchk.cgi?Lang=" + myLang;
	var pop_pass = window.open(url_pass,"popDIAL","width=360,height=400,resizable=no,scrollbars=yes,status=no,statusbar=no,toolbar=no,menubar=no,location=no");
	pop_pass.focus();
}

function popPasswd() {
	var url_pass = "/cgi-beuronline/Pwdchk.cgi?Lang=" + myLang;
	var pop_pass = window.open(url_pass,"popDIAL","width=360,height=400,resizable=no,scrollbars=yes,status=no,statusbar=no,toolbar=no,menubar=no,location=no");
	pop_pass.focus();
}

function popTandC() {
	var url_tc = "/" + myLang + "_pop_tandc.html";
	var pop_tc = window.open(url_tc,"popDIAL","width=550,height=500,resizable=yes,scrollbars=yes,status=no,statusbar=no,toolbar=no,menubar=no,location=no");
	pop_tc.focus();
}

function popHelp() {
	var url_help = "/" + myLang + "_pop_help.html";
	var pop_help = window.open(url_help,"popDIAL","width=400,height=250,resizable=yes,scrollbars=yes,status=no,statusbar=no,toolbar=no,menubar=no,location=no");
	pop_help.focus();
}


function FormLOGINval(theForm)
{
	if(theForm.TandC) { // Conditions
		if(theForm.TandC.checked) {
			theForm.PhotPub.value = "1";
		} else {
			theForm.PhotPub.value = "0";
			msg_OnTandC(1); theForm.TandC.focus();
			return false;
		}
	}
  if(theForm.LogPseudo) { // Pseudo
	if(theForm.LogPseudo.value == "") {
		msg_OnPseudo(1); theForm.LogPseudo.focus();
		return false;
	}
	if(theForm.LogPseudo.value.length < 4) {
		msg_OnPseudo(2); theForm.LogPseudo.focus();
		return false;
	}
	if(!checkString(theForm.LogPseudo.value,"123","-._ ")) {
		msg_OnPseudo(3); theForm.LogPseudo.focus();
		return false;
	}
  }
  if(theForm.LogPasswd) { // Password
	if(theForm.LogPasswd.value == "") {
		msg_OnPasswd(1); theForm.LogPasswd.focus();
		return false;
	}
	if(theForm.LogPasswd.value.length < 5) {
		msg_OnPasswd(2); theForm.LogPasswd.focus();
		return false;
	}
	if(!checkString(theForm.LogPasswd.value,"12","")) {
		msg_OnPasswd(3); theForm.LogPasswd.focus();
		return false;
	}
  }
  return true;
}

function identifyDIAL() {
	var theForm = $('FormLOGIN');
	if (!theForm) theForm = document.FormLOGIN;
	if(theForm.TTLstamp) {
		var dnow = new Date();
		theForm.TTLstamp.value = dnow.getTime();
	}
	if(FormLOGINval(theForm)) {
		//var w = winDial(myLang);
		//theForm.target = "winBEURONLINE";
		theForm.submit();
		//w.focus();
	}
}
function registerDIAL() {
	var theForm = $('FormREGIS');
	if (!theForm) theForm = document.FormREGIS;
	if(theForm.TTLstamp) {
		var dnow = new Date();
		theForm.TTLstamp.value = dnow.getTime();
	}
	//var w = winDial(myLang);
	//theForm.target = "winBEURONLINE";
	theForm.submit();
	//w.focus();
}

