// Page inscription
function hideshowinput(bool,hiden,thediv){
	if(bool){
		var hid =hiden;
		var els = $(thediv).childNodes;
		for(i=0;i<els.length;i++){
			if(els[i].nodeName=="DL"){
				var els2 = els[i].childNodes;
				for(j=0;j<els2.length;j++){
					if(els2[j].nodeName=="DD"){
						var els3 = els2[j].childNodes;
						for(k=0;k<els3.length;k++){
							if(els3[k].nodeName=="INPUT"){
								els3[k].style.display=hid;
							}
						}
					}
				}
			}
		}
	}
}
window.addEvent("domready", function() { 
	var s3 = new CustomSelect($('civilite_client'), {
		theme : 'simplifica'
	});
	var s4 = new CustomSelect($('s_mois_date_client'), {
		theme : 'simplifica'
	});
	var s5 = new CustomSelect($('s_jour_date_client'), {
		theme : 'simplifica'
	});
	var s6 = new CustomSelect($('s_annee_date_client'), {
		theme : 'simplifica'
	});
	var s7 = new CustomSelect($('pays_factu_client'), {
		theme : 'simplifica',   
		onChange: function(el) {
			if($('pays_livr_client')) {
				$('pays_livr_client').selectedIndex=this.selectedIndex;
				s8.selectedIndex = this.selectedIndex;
				s8.select.selectedIndex = this.selectedIndex;
				s8.rebuild();
			}
		}
	});
	var s8 = new CustomSelect($('pays_livr_client'), {
		theme : 'simplifica'
	});
	var status = {
		'true': '&#9650;',
		'false': '&#9660;'
	};
	// ----- myVS2
	var myVS2 = new Fx.Slide('bd3',{
		duration: 1000,
		transition: Fx.Transitions.Pow.easeOut
	});
	$('adr').addEvent('click', function(e){ 
		myVS2.toggle();
		var hid ="none";
		hideshowinput(myVS2.open,hid,'bd3');
	});
	$('adr2').addEvent('click', function(e){
		myVS2.toggle();
		var hid ="none";
		hideshowinput(myVS2.open,hid,'bd3');
	});
	myVS2.addEvent('complete', function() {
		$('vstats2').set('html', status[myVS2.open]);
		var hid =(myVS2.open)?"":"none";
		hideshowinput(myVS2.open,hid,'bd3');
	});
	myVS2.hide();
	hideshowinput(true,"none",'bd3');
}); 
function CheckLen(Target,maxLength,type) {
	if (Target.value.length > maxLength) {
		Target.value = Target.value.substring(0,maxLength);
		CharsLeft = 0;
		myAlert.temp=5;
	} else {
		CharsLeft = maxLength - Target.value.length;      
	}
	var carac = eval("document.getElementById('"+type+"')");
	carac.value = CharsLeft;
}
