/**
 * General dependences of Softonic's Ubiquity Javascript Library:
 * - Jquery Library ( http://jquery.com/ )
 */

 makeSearchCommand({
	 name: "telecharger",
	 url: "http://www.softonic.fr/s/{QUERY}",
	 description: "Softonic: trouver des logiciels et des jeux en téléchargement gratuit",
	 preview: function(pblock, directObject) {
		 var searchTerm = directObject.text;
		 var url = "http://www.softonic.fr/s/"+searchTerm+"/feed/ubiquity";
		 jQuery.get(url, null, function(data){
			 output = '<h3>Programmes associées à la recherche sur Softonic</h3>';
			 jQuery('item', data).each( function() {
				 title = jQuery('title',this).text();
				 description = jQuery('description',this).text();           
				 link = jQuery('link',this).text();
				 output += "-<strong>" + title + "</strong> - <u><a href='" + link + "/telecharger'>Télécharger</a></u><br />";
			 });
			 pblock.innerHTML = output;
		 });
	 }
});