
function SelectMenu(id){
	if (id!=""){
		$('#'+id).addClass('current');
	}
	$(function() {
		if ($('#tabs-menu-territoire #'+id).length!=0){$("#menu-onglet").tabs("select",0);}
		if ($('#tabs-menu-vivre #'+id).length!=0) {$("#menu-onglet").tabs("select",1);}
		if ($('#tabs-menu-spm #'+id).length!=0) {$("#menu-onglet").tabs("select",2);}
		if ($('#tabs-menu-communes #'+id).length!=0) {$("#menu-onglet").tabs("select",3);}
	})		
}

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();
		var dates = $( "#DD, #DF" ).datepicker({
			defaultDate: "+1w",
			changeMonth: true,
			numberOfMonths: 1,
			onSelect: function( selectedDate ) {
				var option = this.id == "DD" ? "minDate" : "maxDate",
					instance = $( this ).data( "datepicker" );
					date = $.datepicker.parseDate(
						instance.settings.dateFormat ||
						$.datepicker._defaults.dateFormat,
						selectedDate, instance.settings );
				dates.not( this ).datepicker( "option", option, date );
			}
		});
		} } );
	}	
}
function initmoteur(){
$(function(){
	($('#ParamS').val()!='')?SelectionListe2('S',$('#ParamS').val()):'';
	($('#ParamT').val()!='')?SelectionListe2('T',$('#ParamT').val()):'';
	($('#ParamCommune').val()!='')?SelectionListe2('Commune',$('#ParamCommune').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()):'';
	($('#ParamDD').val()!='')?SelectionInput2('DD',$('#ParamDD').val()):'';
	($('#ParamDF').val()!='')?SelectionInput2('DF',$('#ParamDF').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 SelectionInput2(NomChamp,Valeur) {
// Version JQuery MY
	$("input[name='"+NomChamp+"']").val(Valeur);
}



/****************************
	POPUP ATLAS ENERGIE
*****************************/


function FichesCarte(url){
//	aa=window.open(url,'popup','height=650,width=700,scrollbars=yes')
	window.location=url;
//	aa.focus();
}


