// auto completion
function findValue(li) {
	if( li == null ) return alert("No match!");

	// if coming from an AJAX call, let's use the CityId as the value
	if( !!li.extra ) var sValue = li.extra[0];

	// otherwise, let's just display the value in the text box
	else var sValue = li.selectValue;

	//alert("The value you selected was: " + sValue);
	OpenWindow( sValue ) ;
}

function selectItem(li) {
	findValue(li);
}

function formatItem(row) {
	return row[0] ;
}


function lookupLocal(){
	var oSuggest = $("#mot_recherche")[0].autocompleter;

	oSuggest.findValue();

	return false;
}


//boite pop up
function OpenWindow(terme_recherche) {
//var url_page = 'definition.php?terme='+terme_recherche;
var url_page = 'd,'+terme_recherche+'.html' ; // ça marche!
	//var hide_2 = $('.lien_pop');
	//var t = $('.jqmdMSG');
 $('#ex1').jqm({ajax: url_page , overlay: '80', toTop: true , ajaxText: '<div class="jqmWindow" id="ex1" style="z-index:3000;"> Please wait... <img src="images/loading.gif" alt="loading" /> </div>', onShow: function(h) { 																																																																																																																							
   h.o.show(); // show overlay
   h.w.fadeIn(888); // show window    
   //t.html('Veuillez patienter... <img src="images/loading.gif" alt="loading" />');  // Clear Content HTML on Hide. 	
    		},
onHide: function(i) { 
      //t.html('Veuillez patienter... <img src="images/loading.gif" alt="loading" />');  // Clear Content HTML on Hide.
      i.o.remove(); // remove overlay
      i.w.fadeOut(888); // hide window
	  }   }).jqmShow();
 //.jqmAddClose(hide_2)
}

//boite pop up Anglaise ou Française suivant le site
function OpenWindowEn(terme_recherche) {
var url_page = 'definition_en.php?terme='+terme_recherche;
//var url_page = 'http://www.en.dico.nifrance.fr/d,'+terme_recherche+'.html' ; // ça marche!
	//var hide_2 = $('.lien_pop');
	//var t = $('.jqmdMSG');
 $('#ex1').jqm({ajax: url_page , overlay: '80', toTop: true , ajaxText: '<div class="jqmWindow" id="ex1" style="z-index:3000;"> Please wait... <img src="images/loading.gif" alt="loading" /> </div>', onShow: function(h) { 																																																																																																																							
   h.o.show(); // show overlay
   h.w.fadeIn(888); // show window    
   //t.html('Veuillez patienter... <img src="images/loading.gif" alt="loading" />');  // Clear Content HTML on Hide. 	
    		},
onHide: function(i) { 
      //t.html('Veuillez patienter... <img src="images/loading.gif" alt="loading" />');  // Clear Content HTML on Hide.
      i.o.remove(); // remove overlay
      i.w.fadeOut(888); // hide window
	  }   }).jqmShow();
 //.jqmAddClose(hide_2)
}


//boite pop up Anglaise ou Française suivant le site
function OpenWindowFr(terme_recherche) {
	
var url_page = 'definition_fr.php?terme='+terme_recherche;
//var url_page = 'http://www.en.dico.nifrance.fr/d,'+terme_recherche+'.html' ; // ça marche!
	//var hide_2 = $('.lien_pop');
	//var t = $('.jqmdMSG');
 $('#ex1').jqm({ajax: url_page , overlay: '80', toTop: true , ajaxText: '<div class="jqmWindow" id="ex1" style="z-index:3000;"> Please wait... <img src="images/loading.gif" alt="loading" /> </div>', onShow: function(h) { 																																																																																																																							
   h.o.show(); // show overlay
   h.w.fadeIn(888); // show window    
   //t.html('Veuillez patienter... <img src="images/loading.gif" alt="loading" />');  // Clear Content HTML on Hide. 	
    		},
onHide: function(i) { 
      //t.html('Veuillez patienter... <img src="images/loading.gif" alt="loading" />');  // Clear Content HTML on Hide.
      i.o.remove(); // remove overlay
      i.w.fadeOut(888); // hide window
	  }   }).jqmShow();
 //.jqmAddClose(hide_2)
}

 //pour ouvrir une popup dans une popup!
 function jqmWindow(page,id){
 var le_div = '#fenetre_'+id;
      $(le_div).jqm({
             ajax: page,
             target: false,
			 overlay: 80,
			 closeClass: 'fermer'           
      }).jqmShow();
}

 //pour ouvrir une popup dans une popup!
 function jqmWindowEn(page,id){
 var le_div = '#fenetre_en_'+id;
      $(le_div).jqm({
             ajax: page,
             target: false,
			 overlay: 80,
			 closeClass: 'fermer'           
      }).jqmShow();
}


 //pour ouvrir une popup dans une popup!
// /en
 function jqmWindowFr(page,id){
 var le_div = '#fenetre_fr_'+id;
      $(le_div).jqm({
             ajax: page,
             target: false,
			 overlay: 80,
			 closeClass: 'fermer'           
      }).jqmShow();
}

// jquery
$(document).ready(function() {

// permet d'enlever le href des liens
// si on a jquery alors il faux que le onclick soit prioritaire du coup on supprime le href
 $("a.popup").attr("href", "#");
						   
// auto completion
		$("#mot_recherche").autocomplete(
		"autocomplete_ajax.php",
		{
			delay:10,
			minChars:1,
			matchSubset:1,
			matchContains:10,
			onItemSelect:selectItem,
			onFindValue:findValue,
			formatItem:formatItem,
			autoFill:true
		}
	);
	


// onglets
$('#onglets > ul').tabs({});
	
});// fin jquery


// le menu déroulant qui ouvre une pop up
function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  var le_lien = selObj.options[selObj.selectedIndex].value ;
  
  //$('#LabVIEW').addClass("selection_en_cours"),
  $(le_lien).animate({ backgroundColor: "#CCCCCC"}, 1000 );
	setTimeout(function() 
		  {
		  $(le_lien).animate({ backgroundColor: "#ffffff"}, 2000 );
			  setTimeout(function() 
			  {
			  $(le_lien).css({ backgroundColor: "" });
			  },2020 );
		  },3000
	  );
  if (restore) selObj.selectedIndex=0;
}



