<?xml version="1.0" encoding="UTF-8" ?> 
<Module>
	<ModulePrefs title="WI Humane - Featured Animal"
		title_url="http://wihumane.org/animals/featureanimal.aspx"
		height="425"
		width="300"
		author="Ben L."
		author_link="http://llamaslayers.net/"
		author_email="ben+wihumane.gadgets@llamaslayers.net"
		description="See the current featured animal at the Wisconsin Humane Society right from your iGoogle homepage!"
		screenshot="http://llamaslayers.googlecode.com/svn/gadgets/whs/featured-animal-screenshot.png"
		thumbnail="http://llamaslayers.googlecode.com/svn/gadgets/whs/featured-animal-thumbnail.png"
		category="lifestyle">
		<Require feature="dynamic-height"/>
		<Preload href="http://wihumane.org/animals/featureanimal.aspx"/>
		<Icon>http://llamaslayers.googlecode.com/svn/gadgets/whs/paw.png</Icon>
	</ModulePrefs>
	<Content type="html">
		<![CDATA[
<base href="http://www.wihumane.org/animals/featureanimal.aspx" target="_top"/>
			<div id="content_div" style="text-align: center; margin-top: 5px">
				<big>Loading...</big>
				<div id="c" style="display: none">
					<h1></h1>
				</div>
			</div>
		<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
		<script type="text/javascript">
function strip_tags(d,e){var f='',g=false;var h=[];var j=[];var l='';var i=0;var k='';var m='';var n=function(a,b,c){return c.split(a).join(b)};if(e){j=e.match(/([a-zA-Z]+)/gi)}d+='';h=d.match(/(<\/?[\S][^>]*>)/gi);for(f in h){if(isNaN(f)){continue}m=h[f].toString();g=false;for(k in j){l=j[k];i=-1;if(i!=0){i=m.toLowerCase().indexOf('<'+l+'>')}if(i!=0){i=m.toLowerCase().indexOf('<'+l+' ')}if(i!=0){i=m.toLowerCase().indexOf('</'+l)}if(i==0){g=true;break}}if(!g){d=n(m,"",d)}}return d}

                                $('img').live('load', function(){gadgets.window.adjustHeight()});

				function getTheData(){
					var params = {};
					params[gadgets.io.RequestParameters.CONTENT_TYPE] = gadgets.io.ContentType.TEXT;
					var url = "http://wihumane.org/animals/featureanimal.aspx";
					gadgets.io.makeRequest(url, parseTheData, params);
				}
				function parseTheData(obj){
					$('body').css({backgroundColor: 'transparent'});

					var wihumane = $(obj.text).find('img').each(function(){
						this.src = gadgets.io.getProxyUrl($(this).attr('src').substr(0, 4) == 'http' ? $(this).attr('src') : ($(this).attr('src')[0] == '/' ? 'http://www.wihumane.org' + $(this).attr('src') : 'http://www.wihumane.org/animals/' + $(this).attr('src')));
					}).end(),
					featuredanimal = wihumane.find('p.title'),
					content = featuredanimal.next().find('div').find('br, p:last').remove().end().find('p').removeAttr('align').end(),
					img = $('<img/>').attr({src: content.find('img').remove().attr('src')}).css({border: '1px solid #ccc', maxWidth: 300}).load(function(){
						if (this.width >= 300)
							$(this).css({borderWidth: '1px 0'});
					});

					$('h1').css({margin: '0 0 5px'}).text('Meet ' + featuredanimal.text().replace(/^Featured Animals?: | $/g, '') + ':').after(img);
					$('#c').append(content.find('p').each(function(){
						if ($.trim($(this).text().replace(/\u00a0/g, ' ')) == '')
							$(this).remove();
						$(this).html($.trim(strip_tags($(this).html(), '<p><a>').replace(/&nbsp;|\u00a0/g, ' ')));
					}).find('a').each(function(){
						$(this).attr({href: 'http://wihumane.org/animals/' + $(this).attr('href')});
					}).end().css({margin: '1em 5px', textAlign: 'justify'})).css({margin: '25px auto 0', textAlign: 'center', width: 300, background: '#eee', border: '1px solid #ccc', MozBorderRadius: '10px', WebkitBorderRadius: '10px', borderRadius: '10px', font: '16px/1 "Lucida Sans", Tahoma, Helvetica, Verdana, Arial, sans-serif'}).animate({height: 'show', opacity: 'show', marginTop: 0}, 2500, 'swing', gadgets.window.adjustHeight);
					$('big').hide('slow', function(){
						$(this).remove();
					});
				}
				gadgets.util.registerOnLoadHandler(getTheData);
			</script>
		]]>
	</Content>
</Module>

