/* utilise jquery */

function displayArmee(frm){
	if ( frm.adresse_armee.checked ){
	// Si armmée
		 $(".visible_si_armee").each(function() {
		   $(this).show();
		 });
		 $(".cache_si_armee").each(function() {
		   $(this).hide();
		 });
		 
		 $("#street_adress_th .inputRequirement").empty();
		 frm.postcode.setAttribute("maxlength","5");
		 frm.postcode.setAttribute("size","5");
		 // si le code postal est vide on met 00
		 if (frm.postcode.value == ''){
		 	frm.postcode.value = '00';
		 }
		 // on positionne sur france metropolitaine adresse armée
		
		 for ( var i=0; i < frm.country.options.length; i++ ){
		 	if (frm.country.options[i].value == '74'){
				frm.country.selectedIndex = i;
				frm.country.disabled = true;
				break;
			}
		 }
		 
	} else {
		 $(".visible_si_armee").each(function() {
		   $(this).hide();
		 });
		 $(".cache_si_armee").each(function() {
		   $(this).show();
		 });
		 frm.postcode.setAttribute("maxlength","9");
		 frm.postcode.setAttribute("size","9");	
		 if (frm.postcode.value == '00'){
		 	frm.postcode.value = '';
		 }
		 frm.country.disabled = false;
	}
}

function displayArmeeLivraison(frm){
	if ( frm.adresse_armee_livraison.checked ){
	// Si il y a une adresse armée de livraison 
		 $("#adresse_livraison .visible_si_armee_livraison").each(function() {
		   $(this).show();
		 });
		 $("#adresse_livraison .cache_si_armee_livraison").each(function() {
		   $(this).hide();
		 });
		 frm.ship_postal.setAttribute("maxlength","5");
		 frm.ship_postal.setAttribute("size","5");	
		 // si le code postal est vide on met 00
		 if (frm.ship_postal.value == ''){
		 	frm.ship_postal.value = '00';
		 }		 	 
		 // on positionne sur france metropolitaine adresse armée et on géle le champ
		
		 for ( var i=0; i < frm.ship_country.options.length; i++ ){
		 	if (frm.ship_country.options[i].value == '74'){
				frm.ship_country.selectedIndex = i;
				frm.ship_country.disabled = true;
				break;
			}
		 }		 
	} else {
		 $("#adresse_livraison .visible_si_armee_livraison").each(function() {
		   $(this).hide();
		 });
		 $("#adresse_livraison .cache_si_armee_livraison").each(function() {
		   $(this).show();
		 });
		 frm.ship_postal.setAttribute("maxlength","9");
		 frm.ship_postal.setAttribute("size","9");
		 if (frm.ship_postal.value == '00'){
		 	frm.ship_postal.value = '';
		 }		 
		 frm.ship_country.disabled = false;		 	
	}
}