<?xml version="1.0" encoding="UTF-8" ?>
<Module>
	<ModulePrefs
		title="TasteKid"
		title_url="http://www.tastekid.com/"
		directory_title="TasteKid | Find similar music, movies, books"
		description="Type in your favorite bands, movies, shows, books or authors and you will get recommendations based on what you like. A gadget that helps you explore your taste."
		screenshot="http://tastekid.com/gadget/files/screenshot.png"
		thumbnail="http://tastekid.com/gadget/files/thumbnail.png"
		height="200"
		scrolling="true"
		author="Felix Oghina"
		author_email="felix.oghina+gemmy@gmail.com"
		author_affiliation="TasteKid, Inc."
		author_location="Bucharest, Romania"
		author_photo="http://i80.photobucket.com/albums/j161/znupi/gclock/author_photo.png"
		author_aboutme="I'm a high-school student (this is being written on 8/7/2008), soon to be a college student. I'm 17 years old at the time of writing, and I love to code. Also like beer ;-)."
		author_quote="if you think every day that today is the last day of your life, one day you'll certainly be right!"
	>
		<Require feature="dynamic-height" />
		<Require feature="minimessage" /> 
		<Require feature="analytics" />
	</ModulePrefs>
	<Content type="html">
	<![CDATA[
		<style type="text/css">
			* { margin: 0; padding: 0; }
			div.inputDiv {
			}
			div.inputDiv input {
				display: block;
				width: 100%;
				background: url("http://tastekid.com/gadget/files/input.gif") 0 0 no-repeat;
				border: none;
				font: bold 13px "Trebuchet MS", Arial, sans-serif;
				height: 30px;
				padding: 5px 45px 0 10px;
				color: #fff;
				vertical-align: top;
			}
			div.inputDiv input:focus {
				outline: none;
			}
			a.submit {
				display: block;
				position: absolute;
				right: 0;
				top: 0;
				background: url("http://tastekid.com/gadget/files/button.gif") 0 0 repeat-y;
				border: none;
				width: 40px;
				height: 30px;
				cursor: pointer;
				vertical-align: top;
			}
			a.submit:hover {
				background-position: 0 -30px;
			}
			a.submit span {
				display: none;
			}
			div#loader {
				position: absolute;
				left: 0;
				top: 0;
				width: 100%;
				height: 100%;
				background: url("http://tastekid.com/gadget/files/load.gif") 50% 50% no-repeat #A5A5A5;
				opacity: 0.5;
				filter: alpha(opacity=50);
				display: none;
				z-index: 1;
			}
			div#expand {
				display: none;
			}
			div#collapse {
				background: url("http://tastekid.com/gadget/files/collapse.gif") 50% 50% no-repeat #F5F5F5;
				height: 30px;
				cursor: pointer;
			}
			div#collapse:hover {
				background-color: #EFEFEF;
			}
			div#content {
				margin: 5px 0;
				min-height: 130px;
			}
			h2 {
				font: bold 16px "Trebuchet MS", "Arial", sans-serif;
				color: #2592A9;
			}
			p {
				font: 12px "Trebuchet MS", "Arial", sans-serif;
			}
			a, a:visited {
				color: #00f;
			}
			a:hover {
				text-decoration: none;
			}
		</style>
		<script type="text/javascript">
			_IG_AdjustIFrameHeight(30);
			
			String.prototype.ucwords = function() {
				return (" " + this.toLowerCase()).replace(/\s+\w/g, function(s) {
    			return s.substr(0, s.length-1) + s.charAt(s.length-1).toUpperCase();
				}).substr(1)
			}
			if (!Array.prototype.indexOf) {
				Array.prototype.indexOf = function(elt) {
					for (var i=0; i < this.length; i++) {
						if (this[i] === elt) return i;
					}
					return -1;
				}
			}
			
			var maxItems = 1000;
			
			var mini = new _IG_MiniMessage(__MODULE_ID__);
			var suggestions = { };
			var order = [ ];
			var attributes = {
				"music": { "title": "Recommended Music" },
				"movie": { "title": "Recommended Movies" },
				"show": { "title": "Recommended Shows" },
				"book": { "title": "Recommended Books" },
				"author": { "title": "Recommended Authors" }
			};
			function inputFocused() {
				if (_gel('q').value == 'Bands, movies, books') _gel('q').value = '';
			}
			function inputBlurred() {
				if (_gel('q').value == '') _gel('q').value = 'Bands, movies, books';
			}
			function makeSmall() {
				_gel('expand').style.display = "none";
				_IG_AdjustIFrameHeight(30);
			}
			function fetchData() {
				_gel('loader').style.display = "block";
				var loc = "http://www.tastekid.com/ask/ws?g=1&q=" + encodeURIComponent(_gel('q').value);
				_IG_FetchXmlContent(loc, handleData);
				return false;
			}
			function handleData(xml) {
				if (xml == null || typeof(xml) != "object" || xml.firstChild == null) {
					mini.createTimerMessage("There was a problem communicating with the server. Please try again in a few moments.", 5, makeSmall);
					_IG_AdjustIFrameHeight(60);
					_gel('loader').style.display = "none";
					return;
				}
				suggestions = { };
				order = [ ];
				var resources = xml.getElementsByTagName("results").item(0).getElementsByTagName("resource");
				if (!resources.length) {
					html = "<h2>No Recommendations Found</h2><p>Please write only bands, artists, movies or book titles, separated by commas. E.g.: Beethoven, Britney Spears, Trainspotting</p>";
					_gel('content').innerHTML = html;
					_gel('expand').style.display = "block";
					_IG_AdjustIFrameHeight(200);
					_gel('loader').style.display = "none";
					return;
				}
				var rName;
				var rType;
				for (var i=0; i < Math.min(resources.length, 20); i++) {
					rName = resources.item(i).getElementsByTagName("name").item(0).firstChild.nodeValue;
					rType = resources.item(i).getElementsByTagName("type").item(0).firstChild.nodeValue;
					if (!suggestions[rType]) suggestions[rType] = [ ];
					suggestions[rType].push(rName);
					if (order.indexOf(rType) == -1) order.push(rType);
				}
				var loc = "http://www.tastekid.com/ask?q=" + encodeURIComponent(_gel('q').value) + "&utm_source=gg_more&utm_campaign=platforms&utm_medium=gadget&utm_content=search&utm_term=" + encodeURIComponent(_gel('q').value);
				var html = "";
				for (var i in order) {
					var type = order[i];
					html += "<h2>" + attributes[type]["title"] + "</h2><p>";
					for (var j in suggestions[type]) {
						html += suggestions[type][j].ucwords() + ", ";
					}
					html = html.substr(0, html.length - 2);
					html += ' <a href="' + loc + '" target="_blank">More on TasteKid &raquo;</a>';
				}
				_gel('content').innerHTML = html;
				_gel('expand').style.display = "block";
				_IG_AdjustIFrameHeight(200);
				_gel('loader').style.display = "none";
			}
			
			_IG_Analytics('UA-2716740-10', '/gadget')
		</script>
		<div id="loader"></div>
		<div class="inputDiv"><form onsubmit="return fetchData()"><input type="text" id="q" value="Bands, movies, books" onfocus="inputFocused()" onblur="inputBlurred()"><a class="submit" href="" onclick="return fetchData"><span>Suggest</span></a></form></div>
		<div id="expand">
			<div id="content"></div>
			<div id="collapse" title="Collapse" onclick="makeSmall()"></div>
		</div>
	]]>
	</Content>
</Module>

