function SelectMenu(id){
	if (id!=""){
		$('#'+id).addClass('current');
	}	
}


function SelectionMenu(IdCell) {
 if((IdCell!='')&&(document.getElementById(IdCell)!=null)){
  document.getElementById(IdCell).className="SelectMenu";
 }
}

function ActiveBoxyVideo()
{
	$(".boxyvideo").click(function() {
		var lien = $(this);
		var url = $("input",lien).val();
		//closeText:'<img src="gdoc/images/bt-fermer.png" border="0"/>'
		var boite = new Boxy("<div class='ContenuVideo'></div>",{modal:true,title:lien.attr('title'),unloadOnHide:true,afterShow:function() {
			var dv =$(this).get(0).getContent();
			dv.flash({width:600,height: 450, src :url,allowFullScreen: 'true',allowScriptAccess:'always',wmode:'transparent',flashvars:"autostart=true"});
		}});
		
	});
}



function addDaysToDate(old_date, delta_days)
{
   var split_date = old_date.split('/');
   var new_date = new Date(split_date[2], split_date[1]*1 - 1, split_date[0]*1 + delta_days);
   var new_day = new_date.getDate();
       new_day = ((new_day < 10) ? '0' : '') + new_day; // ajoute un zéro devant pour la forme  
   var new_month = new_date.getMonth() + 1;
       new_month = ((new_month < 10) ? '0' : '') + new_month; // ajoute un zéro devant pour la forme  
   var new_year = new_date.getYear();
       new_year = ((new_year < 200) ? 1900 : 0) + new_year; // necessaire car IE et FF retourne pas la meme chose  
   var new_date_text = new_day + '/' + new_month + '/' + new_year;
   return new_date_text;
}

function initmoteurfiltrage(page,id){
	if(page!='' && id!=''){
		jQuery.ajax( { url:page, dataType:"html", success:function(data){ $('#'+id).html(data);initmoteur()} } );
	}	
}
function initmoteur(){
	($('#ParamO').val()!='')?SelectionListe2('O',$('#ParamO').val()):'';
	($('#ParamCommune').val()!='')?SelectionListe2('Office'+$('#ParamO').val(),$('#ParamCommune').val()):'';
	($('#ParamT').val()!='')?SelectionListe2('T',$('#ParamT').val()):'';
	($('#ParamST').val()!='')?SelectionListe2('Rubrique'+$('#ParamT').val(),$('#ParamST').val()):'';
	AfficheListesTypes();
	AfficheThCommerces();
	($('#ParamTH').val()!='')?SelectionListe2('TH'+$('#T').attr("selectedIndex"),$('#ParamTH').val()):'';

	($('#ParamCL').val()!='')?SelectionListe2('CL',$('#ParamCL').val()):'';
	($('#ParamC').val()!='')?SelectionListe2('C',$('#ParamC').val()):'';
	($('#ParamD').val()!='')?SelectionListe2('D',$('#ParamD').val()):'';
	($('#ParamCT').val()!='')?SelectionCheckbox2('CT',$('#ParamCT').val()):'';
	($('#ParamS').val()!='')?SelectionCheckbox2('S',$('#ParamS').val()):'';
	($('#ParamTH').val()!='')?SelectionListe2('TH',$('#ParamTH').val()):'';
}
function SelectionCheckbox2(NomChamp,Valeur) {
// Version JQuery MY
	var tval=Valeur.split(',');
	$(":checkbox[name='"+NomChamp+"']").each(function(index, value){
		for(i=0;i<tval.length;i++){
			if($(value).val()==tval[i]){
				$(value).attr('checked', true);
			}
		}
	});
}
function SelectionListe2(NomChamp,Valeur) {
// Version JQuery MY
	$("select[name='"+NomChamp+"']").val(Valeur);
}


function MasqueListesTypes(){
	$('.BlocOffice').hide();
	$("#Commune").val(0);
}

function AfficheListesTypes(){
	var NumTypeSelect=$('#O').val();
	MasqueListesTypes();

	if ($("#BlocType"+NumTypeSelect)){
		$("#BlocType"+NumTypeSelect).show();
		$("#Commune").val($("#LZone"+NumTypeSelect).val());
	} else {
		$("#Commune").val(0);
	}

}



function MasqueListesTypesTh(){
	$('.BlocTh').hide();
	$("#TH").val(0);
}

function AfficheThCommerces(){
	var NumTypeSelect=$('#T').attr("selectedIndex");
	MasqueListesTypesTh();

	if ($("#BlocType"+NumTypeSelect)){
		$("#BlocType"+NumTypeSelect).show();
		$("#TH").val($("#TH"+NumTypeSelect).val());
		
	} else {
		$("#TH").val(0);
	}

}
