function popup(page,largeur,hauteur){
	var top=(screen.height-hauteur)/2;
	var left=(screen.width-largeur)/2;
	window.open(page,"","top="+top+",left="+left+",width="+largeur+",height="+hauteur);
}

function TransfertListe(idOrigine, idDestination)
{	var objOrigine = $(idOrigine);
	var objDestination = $(idDestination);
	if (objOrigine.options.selectedIndex<0) return false;
	if (VerifValeurDansListe(idDestination, objOrigine.options[objOrigine.options.selectedIndex].value, true)) return false;
	var ADeplacer = new Option(objOrigine.options[objOrigine.options.selectedIndex].text, objOrigine.options[objOrigine.options.selectedIndex].value);
	objDestination.options[objDestination.length]=ADeplacer;
	objOrigine.options[objOrigine.options.selectedIndex]=null;
}

function VerifValeurDansListe(IdListe, Valeur, blnAlerte) {
	var objListe = $(IdListe);
	for (i=objListe.length-1;i>=0;i--) if (objListe.options[i].value == Valeur) {if (blnAlerte) alert('Déjà présent.'); return true;}
	return false;
}

function CheckAllDiscipline(){
  var liste = document.forms['affiliation'].dis2;
  for (i=0;i<liste.length;i++){liste.options[i].selected = true;}
  document.forms['affiliation'].dis2.name = "discipline[]";
}

function CheckAllTypeArbitre(){
  var liste = document.forms['arbitre'].arb2;
  for (i=0;i<liste.length;i++){liste.options[i].selected = true;}
  document.forms['arbitre'].arb2.name = "arbitre[]";
}

TRHover = function() {
	var sfEls = $("tab_liste").getElementsByTagName("TR");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+="trhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp("trhover\\b"), "");
		}
	}
}

LIHover = function() {
	var sfEls = $("menu_top").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+="sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp("sfhover\\b"), "");
		}
	}
}

function is_int(event){
  var Key = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode;
  if(Key==13 || Key==8 || Key==9 || Key==46 || Key==37 || Key==39 || (Key >= 48 && Key <=57)) return true;
  else return false;
}

var myGlobalHandlers = {
        onCreate: function(){Element.show('chargement');},
        onComplete: function(){if(Ajax.activeRequestCount == 0){Element.hide('chargement');}}  
};
Ajax.Responders.register(myGlobalHandlers);

function GenerePDF(nom_pdf, liste_dml_id, url, resultat){

	var params = 'nom_pdf=' + nom_pdf + '&liste_dml_id=' + liste_dml_id + '&resultat=' + resultat;
  var myAjax = new Ajax.Request(
        				url, 
        				{	
        					method: 'post',
        					parameters: params, 
        					onSuccess: function (xhr) {
        							$(resultat).innerHTML = xhr.responseText;
        					}
        				}
	);		
} 

/* Génération d'une seule licence au format PDF */
function GenererLicencePDF(nom_pdf, lic_id, ins_id, url, resultat){

	var params = 'nom_pdf=' + nom_pdf + '&lic_id=' + lic_id + '&ins_id=' + ins_id;
  var myAjax = new Ajax.Request(
        				url, 
        				{	
        					method: 'post',
        					parameters: params, 
        					onSuccess: function (xhr) {
        							$('id_licence_pdf').show();
        							$(resultat).innerHTML = xhr.responseText;
        					}
        				}
	);		
}

function Deconnexion(usr_id){
	/*if(usr_id==3){alert('ok3')};
	var params = 'usr_id=' + usr_id;
    var url = 'ajax/deconnexion.php';
    var myAjax = new Ajax.Request(
        url, {method: 'post',parameters: params}
	);	*/
	
}


function periodicalUpdate() {
    new PeriodicalExecuter(refreshNews, 10);
}

function refreshNews() {
   alert('ok');
}

//periodicalUpdate();

function TestSlash(champ){
	var lg = $F(champ).length;
	if(lg == 2 || lg == 5){ $(champ).value += '/'; }
}

function TestPoint(champ){
	var lg = $F(champ).length;
	if(lg == 2 || lg == 5 || lg == 8 || lg == 11){ $(champ).value += '.'; }
}


function HighLightField(champ_id,class_on,class_off) { 	
	if($(champ_id).hasClassName(class_off)){
		$(champ_id).toggleClassName(class_on);
  }else{
  	$(champ_id).toggleClassName(class_off);
  } 
}
