<?xml version="1.0" encoding="UTF-8" ?>

<Module>
  <ModulePrefs title="Destination360 Travel Guides"
	author="Destination 360"
	author_location="Seattle, WA"
  	author_affiliation="Destination360"
	author_link="http://www.destination360.com/igoogle/google-gadgets.php"
    author_email="studio360@gmail.com"
  	title_url="http://www.destination360.com"
  	description="Amazing photography by many world class photographers. Every visit to your iGoogle homepage displays a beautiful photo with links to more information about each world destination. No advertising, No spam, just great images!"
	singleton="false"
  	render_inline="never"
  	height="200"
  	screenshot="http://www.fullscreen360.com/igoogle/gadget/images/screenshot.png"
  	thumbnail="http://www.fullscreen360.com/igoogle/gadget/images/thumbnail.png"
  	>
	<Require feature="setprefs" />
	<Require feature="analytics" />
	<Require feature="dynamic-height" />
  </ModulePrefs>
<UserPref name="fresh" datatype="hidden" default_value="0" />


  <Content type="html"><![CDATA[ 
  <style>
	body {
		font-family: Helvetica;
		font-size: 80%;
	}
	#title {
		font-weight: bold;
		color:#660000;
		text-align:center;
	}
	#summary {
		text-align:right;
		font-size:95%;
		color:#111;
	}
  </style>
  <div id="title"></div>
  <div id="picture">
	<a target="_top" id="link" href="#"><img id="mainImage" style="display:none" border="0"/></a>
	<div id="sizer"></div> <!-- This is to tell us how wide things are -->
  </div>
  <div id="summary"></div>
  <script>
	String.prototype.trim = function() {
		return this.replace(/^\s+|\s+$/g,"");
	}
	String.prototype.ltrim = function() {
		return this.replace(/^\s+/,"");
	}
	String.prototype.rtrim = function() {
		return this.replace(/\s+$/,"");
	}

  	_IG_Analytics("UA-95782-22", "/gadget/");
	var prefs = new _IG_Prefs();
  			
	var mainImage = new Image();
	var addedResize__MODULE_ID__ = false;
	var isIE = (/MSIE (\d+\.\d+);/.test(navigator.userAgent));
		
  	var url = "http://www.destination360.com/igoogle/gadget/definition.xml";
	_IG_FetchXmlContent(url, response);
	function setupImage() {
		var sizer = _gel('sizer');
		width = sizer.offsetWidth;
		height = mainImage.height * width / mainImage.width;
		
		var miDiv    = _gel('mainImage');
		
		miDiv.src = mainImage.src;
		miDiv.style.height = height + 'px'; 
		miDiv.style.width = width + 'px'; 
		miDiv.style.display = "block";
		
		setTimeout(function(){
			_IG_AdjustIFrameHeight(); }, 50);
		
		if(!addedResize__MODULE_ID__) {
			addOnResize__MODULE_ID__(setupImage);
			addedResize__MODULE_ID__ = true;
		}
	}
		
	function response(domdata) {
	
		var baseurl = domdata.getElementsByTagName("baseurl").item(0).firstChild.nodeValue.trim();
		var locations = domdata.getElementsByTagName("location");
		var index = Math.floor(Math.random() * (locations.length - 0.000001));
		
		if(0) { // Set this to 1 for serial mode, and 0 for random mode
			index = parseInt(prefs.getInt("fresh"));
			prefs.set('fresh', (index+1) % locations.length);
			
		}
		
		var location = locations.item(index);

		text = location.getElementsByTagName("title").item(0).firstChild.nodeValue.trim();
		purl = location.getElementsByTagName("image").item(0).firstChild.nodeValue.trim();
		url  = location.getElementsByTagName("url").item(0).firstChild.nodeValue.trim();
		
		if(purl.indexOf('http') == -1)
			purl = baseurl + purl;
		purl = _IG_GetImageUrl(purl);
		
		mainImage.onload = setupImage;
		mainImage.src = purl;
		
		var summaryNodes = location.getElementsByTagName("summary");
		var sum = '';
		if(summaryNodes.length && summaryNodes.item(0)) {
			var allNodes = summaryNodes.item(0);
			for(i = 0; i < allNodes.childNodes.length; i++) {
				if(allNodes.childNodes[i].nodeValue.trim().length > 1)
					sum = allNodes.childNodes[i].nodeValue.replace(/href=/, "target='_top' href=");
			}
		}
		document.getElementById('summary').innerHTML = sum;
		document.getElementById('link').href = url;
		document.getElementById('title').innerHTML = text;

		setTimeout(function(){
			_IG_AdjustIFrameHeight(); }, 50);

	}
	function addOnResize__MODULE_ID__(newFunction) {
		if(isIE) {
			window.attachEvent("onresize", newFunction);
		} else {
			window.addEventListener("resize", newFunction,   false);
		}
	}
  </script>
  ]]></Content>
</Module>
