// Class Google AJAX API
// Simon - egzakt.com
// 2008-10-20
//
// @param	conteneur_id	conteneur recevant les resultats au format HTML


var app;
function OnLoad() {
  app = new App('searchcontrol');
}

function App(conteneur_id) {
		
	var place_holder_recherche = document.getElementById(conteneur_id);
	
	var searchControl = new google.search.SearchControl();
	var siteSearch = new google.search.WebSearch();
	var options = new google.search.SearcherOptions();
	
	siteSearch.setSiteRestriction(gsc_source);
	
	searchControl.setLinkTarget(google.search.Search.LINK_TARGET_SELF);	
	options.setExpandMode(google.search.SearchControl.EXPAND_MODE_OPEN);
	
	searchControl.addSearcher(siteSearch, options);
	searchControl.draw();
	searchControl.setResultSetSize(google.search.Search.LARGE_RESULTSET);
	searchControl.draw(place_holder_recherche);
	searchControl.execute(document.frm_recherche.mots_cles.value);

	searchControl.setSearchCompleteCallback(this, App.prototype.OnSearchComplete);
	
	return;
	
}

App.prototype.OnSearchComplete = function(sc, searcher) {

	// if we have local search results, put them on the map
	if ( searcher.results && searcher.results.length > 0) {
		$("#aucun_resultat").hide();
	} else {
		$("#aucun_resultat").show();
	}
}

GSearch.setOnLoadCallback(OnLoad);