//inscription
jQuery("#loading_img").ready(function($) {
	$("#loading_img").hide();
});
function send_form_insc(){
	//$("#td_sub_send").html('<img src="./images/loading.gif" border="0" />');
	$("#loading_img").show();
	$("#sub_register").hide();
	var str = $("#form_inc").serialize();
	
	$.ajax({
	  url: "aj_register.php",
	  cache: false,
	  data: str,
	  success: function(html){
		$("#results").html(html);
	  }
	});
}
//inscription


function writediv(texte){
	document.getElementById('pseudobox').innerHTML = texte;
}

function verifPseudo(pseudo){
	 
	if(pseudo != ''){
		writediv(file('verif_dipo_username.php?pseudo='+escape(pseudo)));
	}

}

function get_ville_list(){
	var ville_str, postal_code, pays;
	
	
	postal_code = $('#txt_postcode').val();
	pays = $('#txtinfopays').val();
	
	
	
	document.getElementById('txt_ville').readOnly = false;
	var len_str_cp;
	len_str_cp=postal_code.length;
	
	if (len_str_cp==5){
		//alert('pays : '+pays+" Post : "+postal_code);
		ville_str = file('get_ville_list.php?postal='+postal_code+'&pays='+pays);
		if (ville_str != ""){
			document.getElementById('td_ville').innerHTML = ville_str;
			var first_str = ville_str.substring(0,6);
			if (first_str=="<input"){
				document.getElementById('txt_ville').readOnly = true;
			}
			
		}else{
			//document.getElementById('txt_ville').readOnly = false;
		}
	}
}

function file(fichier){
     if(window.XMLHttpRequest) // FIREFOX
          xhr_object = new XMLHttpRequest();
     else if(window.ActiveXObject) // IE
          xhr_object = new ActiveXObject("Microsoft.XMLHTTP");
     else
          return(false);
     xhr_object.open("GET", fichier, false);
     xhr_object.send(null);
     if(xhr_object.readyState == 4) return(xhr_object.responseText);
     else return(false);
}

function clear_login(){
	if (document.form_login.txtlogin.value=="Votre pseudo") {
		document.form_login.txtlogin.value="";
	}
} 

function clear_pass(){
	if (document.form_login.txtpass.value=="Votre mot de passe") {
		document.form_login.txtpass.value="";
	}
}

function get_villes_suggestion(pays, cp, div_name, txtcity,villestr, width){

	get_villes = file('get_villes_suggestion.php?pays='+pays+'&amp;cp='+cp+'&amp;villestr='+villestr+'&amp;div_name='+div_name+'&amp;txtcity='+txtcity);
	if (get_villes!=""){
		document.getElementById(div_name).innerHTML = get_villes;
		document.getElementById(div_name).style.width = width+'px';
		document.getElementById(div_name).style.visibility = 'visible';		
	}
}

function hidde_suggestion(div_name){
	document.getElementById(div_name).style.visibility = 'hidden';
}

function start_hidde_suggestion(div_name){
	setTimeout("hidde_suggestion('"+div_name+"')", '1000') ;
}