function moreinfos(infos) {	
	if( $('#tnt_description_'+infos).is(":visible") ) {		
		$('#tnt_description_'+infos).hide();
		$('.more_'+infos).show();
		$('.less_'+infos).hide();
	} else {
		$('.more_'+infos).hide();
		$('.less_'+infos).show();
		$('#tnt_description_'+infos).show();
	}
}

function radioCheck(){
	
	if ($('#JD').length && $('#JD').is(":checked")){
		$("#tnt_cp").hide();
		$("#tnt_relais").val("");
		$('#openRelais').click();
		$("#tnt_pr").show();
		$("#tnt_pr_choix").hide();
		
	} else {
		if($('#tnt_pr').length) { $('#tnt_pr').hide(); }
		$("#tnt_relais").val("");
		$("#tnt_pr_choix").innerHTML = '';
		$("#tnt_pr_choix").hide();
				
		fetchVille($('#city_url').val(), 'villes');
		$('#tnt_cp').show();
		
		if ($('#JZ').length && $("#JZ").is(":checked")){
    	   $("#comp_entreprise").hide();
    	   $("#comp_domicile").show();
       }
       if ($('#J').length && $("#J").is(":checked")){
    	   $("#comp_domicile").hide();
    	   $("#comp_entreprise").show();
       }
	}
}

function fetchVille(url,area){
	var address = $('#address').val();
	//var address2 = $('#address2').val();
	var zipcode = $('#zipcode').val();
	var city = $('#city').val();
	var company = $('#company').val();

	$.ajax({
		type: "POST",
		url: url,
		data: "address="+address+"&zipcode="+zipcode+"&city="+city+"&company="+company+"&ajax=checkville",
		beforeSend:function(){
			$('#loadingvilleswait').show();},
		error:function(msg){
			alert( "Error !: " + msg );
		},
		success:function(data){
			$('#loadingvilleswait').hide();
			//affiche le contenu du fichier dans le conteneur dédié
			$('#'+area).html(data);
	}});
}

function shippingMethodTnt(url){
		
	if ($('#JD').length && $('#JD').is(":checked")){
		
		if( $("#tnt_relais").val() != '' ) {
			var radioValue = $("#tnt_relais").val();
		}
		
		 
		if(radioValue){		
		}
		else {
			alert ("Vous devez choisir un Relais Colis®");
			return false;
		}
	}
		
	if( ($('#AZ').length && $('#AZ').is(":checked")) 
			|| ($('#TZ').length && $('#TZ').is(":checked"))
			|| ($('#MZ').length && $('#MZ').is(":checked"))
			|| ($('#JZ').length && $('#JZ').is(":checked"))
			|| ($('#A').length && $('#A').is(":checked"))
			|| ($('#T').length && $('#T').is(":checked"))
			|| ($('#M').length && $('#M').is(":checked"))
			|| ($('#J').length && $('#J').is(":checked")) ){
		
		var radioGrp = document['forms']['checkout_address']['tnt_ville'];
			
		if (radioGrp){
			for(i=0; i < radioGrp.length; i++){
			    if (radioGrp[i].checked == true) {
			        var radioValue = radioGrp[i].value;
			    }
			}
		}
		
		if(!radioValue && $('#tnt_ville1').is(":checked")){
			var radioValue = $('#tnt_ville1').val();
		}
		
		if(radioValue){
		}
		else {
			alert ("Vous devez choisir une ville de livraison");
			return false;
		}
		
		var info_comp = '';
		if($("#JZ").length && $("#JZ").is(":checked")) {
			
			if( $("#portable").val() != '' ) {
				var regex = new RegExp(/^(06|07|08)[0-9]{8}/gi);

				if(regex.test($("#portable").val())) {					
				}
				else {
					alert("Vérifiez le numéro de téléphone portable");
					return false;
				}
			} 
			
			info_comp = $("#portable").val()+"&&&"+$("#code").val()+"&&&"+$("#etage").val()+"&&&"+$("#batiment").val();
		}
		if($("#J") && $("#J").is(":checked")) {
			info_comp = $("#compl").val();
		}
	}
	
	document['forms']['checkout_address'].submit();	
}
