<?xml version="1.0" encoding="UTF-8" ?> 
<Module>
  <ModulePrefs  scrolling="true" height="300" width="320"  
    title="rpgCardz - High Scores"
    description="Shows ranking for rpgCardz.com, a strategy pbbg game"
    author="mobeamer" 
    author_email="mobeamer@battleforcesonline.com" 
    title_url="http://www.rpgcardz.com"  >
  </ModulePrefs>

  <Content type="html">
    
  <![CDATA[ 
	<style>
		div, td, body, html { margin:0; padding:0; background:#FFF; color:#000; font-size: 10px; }
		.label { font-weight:bold; }
		a, a:link, a:visited { text-decoration: none; color: #33C }
		a:hover { text-decoration:underline; color: #66A; }
		h1 { font-size: 18px; font-family: Verdana, serif; margin:2px; border-bottom: 1px solid #600;}
	</style>

    <script type="text/javascript">
      
	var requestType = "highscores";
	var timer = null;

	function getHighScores()
	{	
		requestType = "highscores";
		url = 'http://www.rpgcardz.com/feeds/highscores.php'
		//send request using google API
		_IG_FetchContent(url, responseHandler, { refreshInterval: (10) }); 
	}


	function getStats()
	{	
		requestType = "stats";
		url = 'http://www.rpgcardz.com/feeds/gameStats.php'
		//send request using google API
		_IG_FetchContent(url, responseHandler, { refreshInterval: (10) }); 
	}

	function responseHandler(response) 
	{ 
		if (response == null || typeof(response) != "string") 
		{
    			$("mainDiv").innerHTML = "<i>It appears that no one is online...</i>";
    			return;
    		}
    		
    		fullText  =response;
    		if(requestType == "highscores")
		{
			 //take contents and shove it into the mainDiv
			 var d = document.getElementById("mainDiv");
			d.innerHTML = fullText;

			//Refresh in 10 min
			getStats();
		
		}

    		if(requestType == "stats")
		{
			 //take contents and shove it into the mainDiv
			 var d = document.getElementById("statDiv");
			d.innerHTML = fullText;

			//Refresh in 10 min
			timer = setTimeout("getHighScores()", 600000);
		
		}
	}

	//call the function when the gadget loads
	//another google api function
	_IG_RegisterOnloadHandler(getHighScores);
	
    </script>
	<center>
    
    	<a href="http://www.rpgCardz.com"  target=blank
    	><img src="http://www.rpgCardz.com/iGoogle/logo.jpg" border=0></a>
    

	<h1>Game Stats</h1>
	<div id="statDiv" style=" background-color: #EEE; margin:0 auto;">
	Loading...
	</div>

	<h1>Rankings</h1>
	<div id="mainDiv" style=" background-color: #EEE; margin:0 auto;">
	Loading...
	</div>

    	
	</center>

    	
  ]]> 
  </Content>
</Module>

