function connexion(champ,valeur){
	if(document.getElementById(champ).value == valeur){
		document.getElementById(champ).value = "";
	}
}

function string_generator(nb_caract,id) {
	var chaine = Array('a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','0','1','2','3','4','5','6','7','8','9');
	var pass = '';
	var nb, u;
	for (u=1; u <= nb_caract; u++) {
	nb = chaine.length;
	nb = Math.round(Math.random()*chaine.length);
	pass += chaine[nb];
	}
	document.getElementById(id).value = pass;
}

//Permet de sélectionner tout les checkbox
function toggleAll(name) {
var inputs = document.getElementsByTagName('input');
var count  = inputs.length;

for (m = 0; m < count; m++) {
  _input = inputs.item(m);
  if (_input.type == 'checkbox' && _input.id.indexOf('chk-' + name) != -1) {
      _input.checked = document.getElementById(name + '-all').checked;
      }
  }
}


//Fonction ajax
function creeXMLHttpRequestObject(){ try{ Req = new ActiveXObject("Microsoft.XMLHTTP"); } catch(Error){ try{Req = new ActiveXObjet("MSXML2.XMLHTTP");} catch(Error){try{Req = new XMLHttpRequest();} catch(Error){alert("Impossible de créer l'objet");}}} return Req; }


function affiche_menu(id,nb){
	
	for(i=0;i<nb;i++){
		if(document.getElementById('sub_menu_bis_'+i).style.display == 'block'){
			$('#sub_menu_bis_'+i).slideUp("slow");
			document.getElementById('title_menu_'+i).style.display = 'block';
			document.getElementById('title_menu_selected_'+i).style.display = 'none';
		}		
	}	
		
	$('#sub_menu_bis_'+id).slideDown("slow");
	document.getElementById('title_menu_selected_'+id).style.display = 'block';
	document.getElementById('title_menu_selected_'+id).style.background = '#b8bbbb';
	document.getElementById('title_menu_'+id).style.display = 'none';
}

function cache_menu(id){
		$('#sub_menu_bis_'+id).slideUp("slow");
		document.getElementById('title_menu_'+id).style.display = 'block';
		document.getElementById('title_menu_selected_'+id).style.display = 'none';
		
}

function OuvrirPopup(page,nom,option) { window.open(page,nom,option); }

function tick_change(id_img,id_input){
	if(document.getElementById(id_input).value == "1"){
		document.getElementById(id_input).value = "0";
		document.getElementById(id_img).src = "images/tick_no.png";
	}else{
		document.getElementById(id_input).value = "1";
		document.getElementById(id_img).src = "images/tick_yes.png";
	}
}

function play_sport_in_home(nb,img_select){

    new_nb = nb - 1;
	for(i=1;i<=nb;i++){
        $('#img_sport_'+i).fadeOut('slow');
    }
    
    if(img_select < nb){
    	new_i = img_select + 1;
    }else if(img_select == nb){
    	new_i = 1;
    }
    $('#img_sport_'+new_i).fadeIn('slow');

    setTimeout("play_sport_in_home("+ nb +","+ new_i +")",5000);
}

function vide_champ(id,text){
	if(document.getElementById(id).value == text){
		document.getElementById(id).value = "";
	}
}
function remplir_champ(id,text){
	if(document.getElementById(id).value == ""){
		document.getElementById(id).value = text;
	}
}

function show_subsub(id){
	
	if(document.getElementById(id) && document.getElementById(id).style.display == "none"){ 
	$('#'+id).fadeIn('slow');
	}else{
	$('#'+id).fadeOut('slow');
	}
}

