// JavaScript Document
var couche=2000;
var calend_ouvert=new Array();
var und;
/*function calendrier(nom_champ,champ_precedent){
	var undi;
	//alert(tab_close[nom_champ]);
	for(var i=0;i<calend_ouvert.length;i++){
		close_calendrier(calend_ouvert[i]);
		calend_ouvert.splice(i,1);
		}
	//on detect si lechamp précedent existe
	var  pre=nom_champ.substring(0,nom_champ.lastIndexOf("_")+1)+"0";
	//on detect les loc_d
	if(nom_champ=="date_f")champ_precedent="date_d";
	if(nom_champ.substr(0,6)=="loc_au"&&document.getElementById("loc_du__"+nom_champ.substr(8))!=und)champ_precedent="loc_du__"+nom_champ.substr(8);
	//alert("loc_du__"+parseInt(nom_champ));
	if(champ_precedent!==false&&(document.getElementById( nom_champ).value==""||document.getElementById( nom_champ).value==format_date)){
		var the_date=document.getElementById(champ_precedent).value;
	}else{
		var the_date=document.getElementById( nom_champ).value;
	}
	if(the_date==format_date)the_date="";
	
	
	var flashvar='lg='+lang+'&date_d='+the_date+'&date_f=&separateur='+separateur+'&champs='+nom_champ+'&test=1';
	var width=180;
	var height=235;
	document.getElementById('calend_content_'+nom_champ).innerHTML='<'+'object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0" width="'+width+'" height="'+height+'" '+'><'+'param name="movie" value="http://www.kawan-villages.com/xprod/s/calend_kawan.swf"'+'><'+'param name="quality" value="high"'+'><'+'param name="allowScriptAccess" value="always"'+'><'+'param name="flashvars" value="'+flashvar+'"'+'><PARAM NAME=bgcolor VALUE=#0c84c1><'+'embed src="http://www.kawan-villages.com/xprod/s/calend_kawan.swf" width="'+width+'" height="'+height+'" quality="high" bgcolor="#0c84c1" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash"  allowscriptaccess="always" flashvars="'+flashvar+'"'+'><'+'/embed'+'><'+'/object'+'>';
							
	document.getElementById("calend_"+nom_champ).style.display="block";
	couche++;
	
	document.getElementById("porte_calend_"+nom_champ).style.zIndex=couche;
	document.getElementById('calend_content_'+nom_champ).style.zIndex=couche;
	calend_ouvert.push(nom_champ);
	
	

	
	}*/
function calendrier(nom_champ,champ_precedent){
	var undi;
	//alert(tab_close[nom_champ]);
	for(var i=0;i<calend_ouvert.length;i++){
		close_calendrier(calend_ouvert[i]);
		calend_ouvert.splice(i,1);
		}
	//on detect si lechamp précedent existe
	var  pre=nom_champ.substring(0,nom_champ.lastIndexOf("_")+1)+"0";
	//on detect les loc_d
	if(nom_champ=="date_f")champ_precedent="date_d";
	if(nom_champ.substr(0,6)=="loc_au"&&document.getElementById("loc_du__"+nom_champ.substr(8))!=und)champ_precedent="loc_du__"+nom_champ.substr(8);
	//alert("loc_du__"+parseInt(nom_champ));
	if(champ_precedent!==false&&(document.getElementById( nom_champ).value==""||document.getElementById( nom_champ).value==format_date)){
		var the_date=document.getElementById(champ_precedent).value;
	}else{
		var the_date=document.getElementById( nom_champ).value;
	}
	if(the_date==format_date)the_date="";
	//alert(champ_precedent);
	if(champ_precedent!=und&&champ_precedent!==false){
		
		if(document.getElementById(champ_precedent).value!=format_date && document.getElementById(champ_precedent).value!=0 && document.getElementById(champ_precedent).value!="" && document.getElementById(nom_champ).value!=format_date && document.getElementById(nom_champ).value!=0 && document.getElementById(nom_champ).value!=""){
		var td=document.getElementById(champ_precedent).value.split("/");
		var tf=document.getElementById(nom_champ).value.split("/");
		var d=new Date( td[2],td[1],td[0]);
		var f=new Date( tf[2],tf[1],tf[0]);
		if(d>=f)the_date=document.getElementById(champ_precedent).value;
	
	}
	}
	var flashvar='lg='+lang+'&date_d='+the_date+'&date_f=&separateur='+separateur+'&champs='+nom_champ+'&test=1';
	var width=180;
	var height=235;
	document.getElementById('calend_content_'+nom_champ).innerHTML='<'+'object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0" width="'+width+'" height="'+height+'" '+'><'+'param name="movie" value="http://www.kawan-villages.com/xprod/s/calend_kawan.swf"'+'><'+'param name="quality" value="high"'+'><'+'param name="allowScriptAccess" value="always"'+'><'+'param name="flashvars" value="'+flashvar+'"'+'><PARAM NAME=bgcolor VALUE=#0c84c1><'+'embed src="http://www.kawan-villages.com/xprod/s/calend_kawan.swf" width="'+width+'" height="'+height+'" quality="high" bgcolor="#0c84c1" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash"  allowscriptaccess="always" flashvars="'+flashvar+'"'+'><'+'/embed'+'><'+'/object'+'>';
							
	document.getElementById("calend_"+nom_champ).style.display="block";
	couche++;
	
	document.getElementById("porte_calend_"+nom_champ).style.zIndex=couche;
	document.getElementById('calend_content_'+nom_champ).style.zIndex=couche;
	calend_ouvert.push(nom_champ);
	
	

	
	}


function close_calendrier(nom_champ){
	document.getElementById('calend_content_'+nom_champ).innerHTML="";
	if(document.getElementById(nom_champ).value==0){
		document.getElementById(nom_champ).value=format_date;
	}
	couche--;
	document.getElementById("porte_calend_"+nom_champ).style.zIndex=couche-1;
	document.getElementById("calend_"+nom_champ).style.display="none";
	document.getElementById("calend_image_"+nom_champ).focus();
	
	
	
	}

function calendrier_change(nom_champ,date_d){
	if(date_d==0)date_d=format_date;
	document.getElementById(nom_champ).value=date_d;
	close_calendrier(nom_champ);
	
	
	}
