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

 makeSearchCommand({
	 name: "download",
	 url: "http://en.softonic.com/s/{QUERY}",
	 description: "Find programs and games to download for free at Softonic",
	 preview: function(pblock, directObject) {
		 var searchTerm = directObject.text;
		 var url = "http://en.softonic.com/s/"+searchTerm+"/feed/ubiquity";
		 jQuery.get(url, null, function(data){
			 output = '<h3>Programs on Softonic related to your query</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 + "/download'>download</a></u><br />";
			 });
			 pblock.innerHTML = output;
		 });
	 }
});
