<?xml version="1.0" encoding="UTF-8" ?> 
<Module>
  <ModulePrefs title="Bicing Station Watchdog" 
     title_url="http://www.domocat.com/bicingadget/bicingadget.xml" 
     height="85" 
     author="Pedro Hernández" 
     author_email="pedro@domocat.com" />
  <Content type="html">
  <![CDATA[ 
  <div id="content_div"></div>
  <script type="text/javascript"> 
	// This gadget fetches data from the bicing.com stations information page and 
	// extracts the information needed. It corresponds to the variable station, that is the 
	// address of the bicing station to be watched. 
	// If the station address is changed, the offset and start point of the information may
	// need change. The variables that store this information are called preshift and postshift.
	// Finally, the auxiliary variable nummins is used as the cache refresh for google to update
	// the page fetched.
	
	// Global vars for general functionality
	var station = "C/ Bruc 45 amb Gran Via"
	var preshift = 94
	var postshift = 207
	var nummins = 5
	
 	_IG_FetchContent('http://www.bicing.com/localizaciones/localizaciones.php?TU5fTE9DQUxJWkFDSU9ORVM%3D&MQ%3D%3D', function (responseText) {

     	// Set CSS for div.
       	var html = "<div style='padding: 5px;background-color: #FFFFBF;font-family:Arial, Helvetica;" 
       	+ "text-align:left;font-size:90%'>"; 
       
     	// Use the search function to find the position in the text of the station data
     	var  pos_stat = responseText.search(station);
	var  stationdata = responseText.substring(pos_stat-preshift,pos_stat+station.length+postshift);
          
	// Append substrings to html.
	html += stationdata;
	html += " ";
    	html += "</div>";
    	// Output html in div.
    	_gel('content_div').innerHTML = html; 
	}, nummins*60); 
	</script>
     ]]>
  </Content> 
</Module>
