<?xml version="1.0" encoding="UTF-8"?>
<Module>
<ModulePrefs title="Find Checkins Around You" 
             description="Checkin Mania: Find People checking in around you using Foursquare and Gowalla" 
             author="Rakshith" 
             author_email="info+mapplet@checkinmania.com" 
             screenshot="http://www.checkinmania.com/checkinmania_mapplet_preview.png"
             thumbnail="http://www.checkinmania.com/checkinmania_mapplet_thumbnail.png"
             height="640"
             author_location="Portland, Oregon, USA"
             title_url="http://www.checkinmania.com"
             author_link="http://blog.checkinmania.com">
  <Require feature="sharedmap"/>
  <Require feature="analytics" />
</ModulePrefs>
<Content type="html"><![CDATA[

    <style type="text/css">
	  .divs {
	    background-color:#ffffff;
        font-family: Arial, sans-serif;
        font-size: 10pt;
        border:0px solid #ffffff;
        padding:3px;
        margin: 0;
        width:320px;
		align:center;
	    overflow: hidden;
      }	
	  .adBox {
	    background-color:#fff;
        font-family: Arial, sans-serif;
        font-size: 10pt;
        border:6px solid #D5DDF3;
        padding:3px;
        margin: 0;
        width:320px;
		height:330px;
		align:center;
	    overflow: hidden;
		-moz-border-radius: 5px;
        -webkit-border-radius: 5px;		
      }		  
	  #controls {
		display:none;
	    background-color:#D5DDF3;
        font-family: Arial, sans-serif;
        font-size: 10pt;
        border:6px solid #D5DDF3;
        padding:3px;
        margin: 0;
        width:320px;
		align:center;
	    overflow: hidden;
		-moz-border-radius-topright: 5px;
        -webkit-border-top-right-radius: 5px;
		-moz-border-radius-topleft: 5px;
        -webkit-border-top-left-radius: 5px;		
      }
	  #buttons {
		display:none;
	    background-color:#D5DDF3;
        font-family: Arial, sans-serif;
        font-size: 10pt;
        border:6px solid #D5DDF3;
        padding:3px;
        margin: 0;
        width:320px;
		align:center;
	    overflow: hidden;		
      }
	  #buttonVenue, #buttonOther {
		display: table-cell;  
		display: inline-block;
		cursor:pointer;
	    background-color:#D5DDF3;
        font-family: Arial, sans-serif;
        font-size: 10pt;
        border:2px solid #e8ecf9;
        padding:3px;
        margin: 0;
        width:80px;
		align:center;
	    overflow: hidden;
		-moz-border-radius: 5px;
        -webkit-border-radius: 5px;		
      }        
	  #sidebar {
	  	display:none;
	    background-color:#ffffff;
        font-family: Arial, sans-serif;
        font-size: 10pt;
        border:6px solid #e8ecf9;
        padding:3px;
        color:#222;
        margin: 0;
        height:370px;
        width:320px;
	    align:left;
	    overflow-y: auto;
	    overflow-x: hidden;
      }
	  #details {
	    display:none;
	    background-color:#ffffff;
        font-family: Arial, sans-serif;
        font-size: 10pt;
		border:6px solid #D5DDF3;
		padding:3px;
        color:#222;
        margin: 0;
        height: 0px;
		width:320px;
		align:left;
	    overflow-y: auto;
	    overflow-x: hidden;		
      }	  	  
      .venue{
        padding:3px;
        border-top:1px solid #D5DDF3;
		color:#eee;
        cursor:pointer;
      }
      .venue-hover{
        padding:3px;
        border-top:1px solid #D5DDF3;
		background:#D5DDF3;
		color:#222;
        cursor:pointer;
        -moz-border-radius: 5px;
        -webkit-border-radius: 5px;
      }
      .venue-infowin{
		color:#222;
      }  
      .title-text{
		font-size:10pt;
      }
      .subtitle-text{
		font-size:8pt;
      }
	  #buttonFSQ, #buttonGOW {
	 	display: inline;
  	 	padding: 5px;
		cursor:pointer;
  	 	-moz-border-radius-topleft: 7px;
  		-webkit-border-top-left-radius: 7px;
  	 	-moz-border-radius-topright: 7px;
  		-webkit-border-top-right-radius: 7px;  		
      }      
        </style>
        <div align="left">
        <div id="logo" class="divs" align="center"><a href="http://www.checkinmania.com" target="_blank"><img src="http://www.checkinmania.com/checkinmania_logo.png" width=200 border=0></a></div>
		<div id="tabs" class="divs" align="center">
			<div id="buttonFSQ" onclick="toggleService(0)" onmouseover="if(service==0)this.style.backgroundColor='#D5DDF3';else this.style.backgroundColor='#e8ecf9'" onmouseout="if(service!=0)this.style.backgroundColor='#fff'"><img src="http://www.checkinmania.com/foursquare_logo.png" height="30" border=0 alt="FourSquare"></div>
			<div id="buttonGOW" onclick="toggleService(1)" onmouseover="if(service==1)this.style.backgroundColor='#D5DDF3';else this.style.backgroundColor='#e8ecf9'" onmouseout="if(service!=1)this.style.backgroundColor='#fff'"><img src="http://www.checkinmania.com/gowalla_logo.png" height="30" border=0 alt="Gowalla"></div>
		</div>
		<div id="adBox" class="adBox" align="center">
			<div align="center" style="font:bold 9pt Arial;color:#222;background:#e8ecf9;padding:10px">Find people checking in around you using foursquare or Gowalla, select a service above.</div>
				<br>
				<script type="text/javascript"><!--
				google_ad_client = "pub-2773616400896769";
				/* checkinmania_mapplet_300x250 */
				google_ad_slot = "5532257928";
				google_ad_width = 300;
				google_ad_height = 250;
				//-->
				</script>
				<script type="text/javascript"
				src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
				</script>
		</div>
		<div id="controls" style="" align="center">
			<input id="panSearch" type="checkbox" CHECKED value="panSearch" name="panSearch" onclick="togglePanSearch()"/><b class="subtitle-text">Update on Drag</b> | 
			<input id="where" type="text" value="Enter a City" style="width:140px;" onFocus="this.value=''" onKeyPress="if ((event.which && event.which == 13) || (event.keyCode && event.keyCode == 13)) {changeCity();return false;} else return true;"> 
			<input id="Go" type="button" value="Go" onclick="changeCity()">		
		</div>
		<div id="buttons" style="" align="center">
			<div id="buttonVenue" onclick="toggleDataType(0)" onmouseover="this.style.backgroundColor='#e8ecf9'" onmouseout="if(type!=0)this.style.backgroundColor='#D5DDF3'"><b>Venues</b></div>
			<img src="http://www.checkinmania.com/blank.gif" width=30 height=1>
			<div id="buttonOther" onclick="toggleDataType(1)" onmouseover="this.style.backgroundColor='#e8ecf9'" onmouseout="if(type!=1)this.style.backgroundColor='#D5DDF3'"><b>Tips</b></div>
		</div>		
        <div id="sidebar"></div>
		<div id="details"></div>
		<div id="debug"></div>
        </div>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>         
<script type="text/javascript">

var map, bounds, checkin, manMaker, currentPosition, service, busy, isManMarker, type;
var manIcon, iconGOW, iconFSQ;
var GOWVenues = [];
var FSQVenues = [];
map = new GMap2();
map.setCenter(new GLatLng(37.77675098675219,-122.43414580821991),16);
isManMarker = 0;
checkin = 0;
service = 99;
type = 0;
busy = 0;

manIcon = new GIcon();
manIcon.image = "http://www.checkinmania.com/man.png";
manIcon.iconSize = new GSize(50, 50);
manIcon.iconAnchor = new GPoint(16, 50);
manIcon.infoWindowAnchor = new GPoint(14, 5);
iconGOW = new GIcon();
iconGOW.image = "";
iconGOW.iconSize = new GSize(24, 24);
iconGOW.iconAnchor = new GPoint(12, 12);
iconGOW.infoWindowAnchor = new GPoint(12, 12);
iconFSQ = new GIcon();
iconFSQ.image = "";
iconFSQ.iconSize = new GSize(24, 24);
iconFSQ.iconAnchor = new GPoint(12, 12);
iconFSQ.infoWindowAnchor = new GPoint(12, 12);

getFSQTips = function(lat,lng){
  busy = 1; type=1;
  hideDetails();
  $("#sidebar").html("<img src='http://www.checkinmania.com/20_loading_icon.gif'>");
  var url = "http://api.foursquare.com/v1/tips.json?l=50&geolat="+lat+"&geolong="+lng; 
  _IG_FetchContent(url, function(jsonFeed) {
  	var data = eval('(' + jsonFeed + ')');
	for (var i=0; i<FSQVenues.length; i++) {
		map.removeOverlay(FSQVenues[i].marker());
	}
	$("#sidebar").html("");
	manMarker.setPoint(new GLatLng(lat,lng));
	currentPosition = new GLatLng(lat,lng);
	bounds = new GLatLngBounds();
	bounds.extend(new GLatLng(lat,lng));
	if(data.error){
	    $("#sidebar").html("");
	    manMarker.openInfoWindowHtml("<div style='font-size:9pt'><br><b>"+data.error+"</b></div>",{maxWidth:200});		
	} else {
	  	for(var i=0;i<data.groups[0].tips.length;i++) {
	  		FSQVenues.push(new FSQVenue(data.groups[0].tips[i]));
		}
	}
	manMarker.closeInfoWindow();
	busy = 0;
  });		
};

getFSQVenues = function(lat,lng){
  busy = 1; type=0;
  hideDetails();
  $("#sidebar").html("<img src='http://www.checkinmania.com/20_loading_icon.gif'>");
  var url = "http://api.foursquare.com/v1/venues.json?l=50&geolat="+lat+"&geolong="+lng; 
  _IG_FetchContent(url, function(jsonFeed) {
  	var data = eval('(' + jsonFeed + ')');
	for (var i=0; i<FSQVenues.length; i++) {
		map.removeOverlay(FSQVenues[i].marker());
	}
	$("#sidebar").html("");
	manMarker.setPoint(new GLatLng(lat,lng));
	currentPosition = new GLatLng(lat,lng);	
	bounds = new GLatLngBounds();
	bounds.extend(new GLatLng(lat,lng));
	if(data.error){
	    $("#sidebar").html("");
	    manMarker.openInfoWindowHtml("<div style='font-size:9pt'><br><b>"+data.error+"</b></div>",{maxWidth:200});		
	} else {
	  	for(var i=0;i<data.groups[0].venues.length;i++) {
	  		if(checkin == 1) {
	  			if(data.groups[0].venues[i].stats.herenow != 0){
	  				FSQVenues.push(new FSQVenue(data.groups[0].venues[i])); 
	  			}	
	  		} else {
	  			FSQVenues.push(new FSQVenue(data.groups[0].venues[i]));
	  		}
		}
	}
	manMarker.closeInfoWindow();
	busy = 0;
  });		
};
 
FSQVenue = function(result) {
	this.result_ = result;
	map.addOverlay(this.marker());
	return;
};
 
FSQVenue.prototype.marker = function() {
	if (this.marker_) return this.marker_;
	iconFSQ.image = "http://foursquare.com/img/categories/question.png";
	if(type == 0){
		if(this.result_.primarycategory)
			if(this.result_.primarycategory.iconurl)
				iconFSQ.image = this.result_.primarycategory.iconurl;	
		var marker = new GMarker(new GLatLng(parseFloat(this.result_.geolat), parseFloat(this.result_.geolong)), {icon:iconFSQ, title:this.result_.name});	
		bounds.extend(new GLatLng(this.result_.geolat,this.result_.geolong));
		$("#sidebar").append(this.infoWin(1));
	} else if(type == 1){
		if(this.result_.venue.primarycategory)
			if(this.result_.venue.primarycategory.iconurl)
				iconFSQ.image = this.result_.venue.primarycategory.iconurl;	
		var marker = new GMarker(new GLatLng(parseFloat(this.result_.venue.geolat), parseFloat(this.result_.venue.geolong)), {icon:iconFSQ, title:this.result_.venue.name});	
		bounds.extend(new GLatLng(this.result_.venue.geolat,this.result_.venue.geolong));
		$("#sidebar").append(this.infoWin(1));	
	}
	GEvent.bind(marker, "click", this, function() {
		marker.openInfoWindow(this.infoWin(0),{maxWidth:200});
	});	
	this.marker_ = marker;
	return marker;
};	
 
FSQVenue.prototype.infoWin = function(isSidebar) {
	var container = document.createElement("div");
	if(isSidebar)
		container.className = "venue";
	else
		container.className = "venue-infowin";
	var category_name = "";
	var category_image = "http://foursquare.com/img/categories/question.png";
	if(type == 0){
		if(this.result_.primarycategory) {
			if(this.result_.primarycategory.nodename)
				category_name = this.result_.primarycategory.nodename;
			if(this.result_.primarycategory.iconurl)
				category_image = this.result_.primarycategory.iconurl;			
		}
		container.innerHTML = "<table><tr><td style='padding-right:15px;'><img src='"+category_image+"'></td><td><div style='font:bold 10pt Arial'>"+this.result_.name+"</div><div style='font:9pt Arial'>"+category_name+"</div></td></tr></table>";
		if(!isSidebar) container.innerHTML += "<hr size=1>";
	} else if(type == 1){
		if(this.result_.venue.primarycategory) {
			if(this.result_.venue.primarycategory.nodename)
				category_name = this.result_.venue.primarycategory.nodename;
			if(this.result_.venue.primarycategory.iconurl)
				category_image = this.result_.venue.primarycategory.iconurl;			
		}
		var lastname = "";
		if(this.result_.user.lastname) lastname = this.result_.user.lastname;
		container.innerHTML = "<div style='padding:4px;font-size:8pt;'><table cellpadding=0 cellspacing=0 border=0><tr><td valign='top'><a href='http://www.foursquare.com/user/-"+this.result_.user.id+"' target='_blank'><img src='"+this.result_.user.photo+"' style='height:48px; width:48px' border=0></a></td><td valign=top><div style='padding:2px;font-size:9pt'><b> "+this.result_.user.firstname+" "+lastname+" - </b>"+this.result_.text+" <b> - @ <a href='http://foursquare.com/venue/"+this.result_.venue.id+"' target='_blank'>"+this.result_.venue.name+"</a></b></div></td></tr></table></div>";
		if(!isSidebar) container.innerHTML += "<hr size=1>"; 
	}
	if(isSidebar) {
      GEvent.bindDom(container, "mouseover", this, function() {
        this.marker_.openInfoWindow(container.innerHTML + "<hr size=1>",{maxWidth:200});
		container.className = "venue-hover";
      });	
      GEvent.bindDom(container, "mouseout", this, function() { 
		container.className = "venue";
      });
      GEvent.bindDom(container, "click", this, function() {  
		container.className = "venue-hover";
		if(type == 0) this.showDetails(container);
      });
	}
	return container;
};
 
FSQVenue.prototype.showDetails = function (content) {
	var hover = document.getElementById("details");
	$("#sidebar").height(137);
	$("#details").height(200);
	$("#details").hide();
	$("#details").html(content.innerHTML);
    GEvent.bindDom(hover, "mouseover", this, function() {
        this.marker_.openInfoWindow(content.innerHTML,{maxWidth:200});
    });		
	$("#details").fadeIn('slow');
	getFSQVenueDetails(this.result_.id);
	return;
};
 
getFSQVenueDetails = function(vid){
	$("#details").append("<img src='http://www.checkinmania.com/20_loading_icon.gif'>");
	var url = "http://api.foursquare.com/v1/venue.json?vid="+vid;
	_IG_FetchContent(url, function(jsonFeed) {
		var data = eval('(' + jsonFeed + ')');
		var category_name = "";
		var category_image = "http://foursquare.com/img/categories/question.png";
		if(data.venue.primarycategory) {
			if(data.venue.primarycategory.nodename)
				category_name = data.venue.primarycategory.nodename;
			if(data.venue.primarycategory.iconurl)
				category_image = data.venue.primarycategory.iconurl;
		}
		$("#details").html("<div style='border:2px solid #D5DDF3;-moz-border-radius-bottomleft: 5px;-webkit-border-bottom-left-radius: 5px;-moz-border-radius-bottomright: 5px;-webkit-border-bottom-right-radius: 5px;cursor:pointer' onclick='window.open(\"http://www.foursquare.com/venue/"+vid+"\", \"_blank\")' onmouseover='this.style.backgroundColor=\"#e8ecf9\"' onmouseout='this.style.backgroundColor=\"#fff\"'><table><tr><td style='padding-right:15px'><a href='http://foursquare.com/venue/"+vid+"' target='_blank'><img src='"+category_image+"' height=32 width=32 border=0></a></td><td><div class='title-text'><span style='font-size:12pt'>"+data.venue.name+"</span></div><div class='subtitle-text'>"+category_name+"</div></td></tr></table></div>");
		$("#details").append("<div style='padding:4px;font-size:8pt'>");
		if(data.venue.tags)
			for(var i=0;i<data.venue.tags.length;i++)
				$("#details").append("<span style='font-size:8pt'> "+data.venue.tags[i]+" .</span>");	
		$("#details").append("</div>");		
		$("#details").append("<div style='padding:4px;font-size:8pt' align='center'><table cellpadding=0 cellspacing=3 border=0 width='100%'><tr><td align='center'><div style='-webkit-border-radius:5px;-moz-border-radius: 5px;border:5px solid #D5DDF3;width:80px;background:#D5DDF3'><span style='font-size:24pt;font-weight:bold'>"+data.venue.stats.checkins+"</span><br><span style='font-size:10pt'>checkins</span></div></td></tr></table></div>");
		if(data.venue.stats.mayor){
			var lastname = "";
			if(data.venue.stats.mayor.user.lastname) lastname = data.venue.stats.mayor.user.lastname;
			$("#details").append("<div style='padding:4px;font-size:8pt'>Mayor:</div>");
			$("#details").append("<div style='padding:4px;font-size:8pt;background:#D5DDF3;-moz-border-radius: 5px;-webkit-border-radius: 5px;cursor:pointer' onclick='window.open(\"http://www.foursquare.com/user/-"+data.venue.stats.mayor.user.id+"\", \"_blank\")' onmouseover='this.style.backgroundColor=\"#e8ecf9\"' onmouseout='this.style.backgroundColor=\"#D5DDF3\"'><table cellpadding=0 cellspacing=0 border=0><tr><td><a href='http://www.foursquare.com/user/-"+data.venue.stats.mayor.user.id+"' target='_blank'><img src='"+data.venue.stats.mayor.user.photo+"' height=48 width=48 border=0></a></td><td valign=top><div style='padding:2px;font-size:14pt'><b> "+data.venue.stats.mayor.user.firstname+" "+lastname+"</b></div><div style='padding:2px;font-size:8pt'><span style='font-size:14pt'>"+data.venue.stats.mayor.count+"</span> chekins</div></td></tr></table></div>");
		}
		if(data.venue.tips) {
			$("#details").append("<div style='padding:4px;font-size:8pt'>Tips:</div>");
			for(var i=0;i<data.venue.tips.length;i++) {
				var lastname = "";
				if(data.venue.tips[i].user.lastname) lastname = data.venue.tips[i].user.lastname;
				$("#details").append("<div style='padding:4px;font-size:8pt;border-bottom:1px solid #e8ecf9'><table cellpadding=0 cellspacing=0 border=0><tr><td valign='top'><a href='http://www.foursquare.com/user/-"+data.venue.tips[i].user.id+"' target='_blank'><img src='"+data.venue.tips[i].user.photo+"' height=48 width=48 border=0></a></td><td valign=top><div style='padding:2px;font-size:9pt'><b> "+data.venue.tips[i].user.firstname+" "+lastname+" - </b>"+data.venue.tips[i].text+"</div></td></tr></table></div>");
			}
		}
	});
}

getGOWVenues = function(lat,lng){
  busy = 1; type = 0;
  hideDetails();
  $("#sidebar").fadeIn('slow');
  $("#sidebar").html("<img src='http://www.checkinmania.com/20_loading_icon.gif'>");
  var url = "http://api.gowalla.com/spots.json?radius=50&lat="+lat+"&lng="+lng; 
  _IG_FetchContent(url, function(jsonFeed) {
  	var data = eval('(' + jsonFeed + ')');
	for (var i=0; i<GOWVenues.length; i++) {
		map.removeOverlay(GOWVenues[i].marker());
	} 
	$("#sidebar").html("");
	bounds = new GLatLngBounds();
	bounds.extend(new GLatLng(lat,lng));
  	for(var i=0;i<data.spots.length;i++) {
  		if(checkin == 1) {
  			if(data.spots[i].trending_level != 0){
  				GOWVenues.push(new GOWVenue(data.spots[i]));
  			}	
  		} else {
  			GOWVenues.push(new GOWVenue(data.spots[i]));
  		}
	 }
	 manMarker.closeInfoWindow();
	 zoomFitMarkers();
	 busy = 0;
  });
};  

GOWVenue = function(result) {
	this.result_ = result;
	map.addOverlay(this.marker());
	return;
};

GOWVenue.prototype.marker = function() {
	if (this.marker_) return this.marker_;
	iconGOW.image = this.result_.image_url;;
	var marker = new GMarker(new GLatLng(parseFloat(this.result_.lat), parseFloat(this.result_.lng)), {icon:iconGOW, title:this.result_.name});	
	bounds.extend(new GLatLng(this.result_.lat,this.result_.lng));
	$("#sidebar").append(this.infoWin(1));
	GEvent.bind(marker, "click", this, function() {
		marker.openInfoWindow(this.infoWin(0),{maxWidth:200});
	});	
	this.marker_ = marker;
	return marker;
};

GOWVenue.prototype.infoWin = function(isSidebar) {
	var container = document.createElement("div");
	if(isSidebar)
		container.className = "venue";
	else
		container.className = "venue-infowin";
	var category_name = "";
	var category_image = "";
	if(this.result_.address)
		if(this.result_.address.locality)
			category_name = this.result_.address.locality;
	if(this.result_.image_url)
		category_image = this.result_.image_url;			
	container.innerHTML = "<table><tr><td style='padding-right:15px;'><img src='"+category_image+"' height=32 width=32'></td><td><div style='font:bold 10pt Arial'>"+this.result_.name+"</div><div style='font:9pt Arial'>"+category_name+"</div></td></tr></table>";
	if(!isSidebar) container.innerHTML += "<hr size=1>";
	if(isSidebar){
      GEvent.bindDom(container, "mouseover", this, function() {
        this.marker_.openInfoWindow("<table align=left><tr><td style='padding-right:15px;'><img src='"+category_image+"' style='height:48px;width:48px'></td><td><div style='font:bold 10pt Arial'>"+this.result_.name+"</div><div style='font:9pt Arial'>"+category_name+"</div></td></tr></table>",{maxWidth:200});
		container.className = "venue-hover";
      });	
      GEvent.bindDom(container, "mouseout", this, function() {  
		container.className = "venue";
      });
      GEvent.bindDom(container, "click", this, function() {  
		container.className = "venue-hover";
		this.showDetails(container);
      });	  
	}
	return container;
};

GOWVenue.prototype.showDetails = function (content) {
	var hover = document.getElementById("details");
	$("#sidebar").height(137);
	$("#details").height(230);
	$("#details").hide();
	$("#details").html(content.innerHTML);
    GEvent.bindDom(hover, "mouseover", this, function() {
        this.marker_.openInfoWindow(content.innerHTML,{maxWidth:200});
    });		
	$("#details").fadeIn('slow');
	getGOWVenueDetails(this.result_.url);
	return;
};
 
getGOWVenueDetails = function(vid){
	$("#details").append("<img src='http://www.checkinmania.com/20_loading_icon.gif'>");
	var url = "http://www.checkinmania.com/jsonp?url=http://api.gowalla.com"+vid+".json";
	_IG_FetchContent(url, function(jsonFeed) {
		var data = eval('(' + jsonFeed + ')');
		$("#details").html("<div style='border:2px solid #D5DDF3;-moz-border-radius-bottomleft:5px;-webkit-border-bottom-left-radius:5px;-moz-border-radius-bottomright: 5px;-webkit-border-bottom-right-radius: 5px;cursor:pointer' onclick='window.open(\"http://www.gowalla.com"+vid+"\", \"_blank\")' onmouseover='this.style.backgroundColor=\"#e8ecf9\"' onmouseout='this.style.backgroundColor=\"#fff\"'><table><tr><td><a href='http://www.gowalla.com"+vid+"' target='_blank'><img src='"+data.image_url+"' height=48 width=48 border=0></a></td><td><div class='title-text'><span style='font-size:12pt'>"+data.name+"</span></div><div class='subtitle-text'>"+data.spot_categories[0].name+"</div></td></tr></table></div>");
		$("#details").append("<div style='padding:4px;font-size:8pt'>"+data.description+"</div>");
		$("#details").append("<div style='padding:4px;font-size:8pt'><table cellpadding=0 cellspacing=3 border=0 width='100%'><tr><td align='center'><div style='-webkit-border-radius:5px;-moz-border-radius: 5px;border:5px solid #D5DDF3;width:80px;background:#D5DDF3'><span style='font-size:24pt;font-weight:bold'>"+data.checkins_count+"</span><br><span style='font-size:10pt'>checkins</span></div></td><td align='center'><div style='-webkit-border-radius:5px;-moz-border-radius: 5px;border:5px solid #D5DDF3;width:80px;background:#D5DDF3'><span style='font-size:24pt;font-weight:bold'>"+data.users_count+"</span><br><span style='font-size:10pt'>users</span></div></td></tr></table></div>");			
		if(data.top_10) {
			$("#details").append("<div style='padding:4px;font-size:8pt'>Top Users:</div>");
			$("#details").append("<div style='padding:4px;font-size:8pt;background:#D5DDF3;-moz-border-radius:5px;-webkit-border-radius:5px;cursor:pointer' onclick='window.open(\"http://www.gowalla.com"+data.top_10[0].url+"\", \"_blank\")' onmouseover='this.style.backgroundColor=\"#e8ecf9\"' onmouseout='this.style.backgroundColor=\"#D5DDF3\"'><table cellpadding=0 cellspacing=3 border=0><tr><td valign='top'><a href='http://www.gowalla.com"+data.top_10[0].url+"' target='_blank'><img src='"+data.top_10[0].image_url+"' height=48 width=48 border=0></a></td><td valign=top><div style='padding:2px;font-size:9pt'><b> "+data.top_10[0].first_name+" "+data.top_10[0].last_name+"</b></div><div><span style='font-size:14pt'>"+data.top_10[0].checkins_count+" </span>checkins</div></td></tr></table></div>");
			for(var i=1;i<data.top_10.length;i++){
				$("#details").append("<div style='padding:4px;font-size:8pt;-moz-border-radius:5px;-webkit-border-radius:5px;border-bottom:1px solid #e8ecf9;cursor:pointer' onclick='window.open(\"http://www.gowalla.com"+data.top_10[i].url+"\", \"_blank\")' onmouseover='this.style.backgroundColor=\"#e8ecf9\"' onmouseout='this.style.backgroundColor=\"#fff\"'><table cellpadding=0 cellspacing=3 border=0><tr><td valign='top'><a href='http://www.gowalla.com"+data.top_10[0].url+"' target='_blank'><img src='"+data.top_10[i].image_url+"' height=48 width=48 border=0></a></td><td valign=top><div style='padding:2px;font-size:9pt'><b> "+data.top_10[i].first_name+" "+data.top_10[i].last_name+"</b></div><div><span style='font-size:14pt'>"+data.top_10[i].checkins_count+" </span>checkins</div></td></tr></table></div>");
			}
		}
	});
}

addMashman = function(latlng) {
	if(!isManMarker){
		isManMarker = 1;
		manMarker = new GMarker(latlng, {icon:manIcon, draggable: true, bouncy: true, title: "Drag Me!"});				
		map.addOverlay(manMarker);
		GEvent.addListener(manMarker, "dragend", function(){
			manMarker.closeInfoWindow();
			manMarker.getPointAsync(function(point){
			getData(0);
			});
		});	
	}
};

zoomFitMarkers = function(){
	map.getBoundsZoomLevelAsync(bounds, function(zoomLevel){
		map.setCenter(bounds.getCenter(), zoomlevel);
	});
};

hideDetails = function(){
	manMarker.closeInfoWindow();
};

changeCity = function() {
	hideDetails();
	if(_gel("where").value != "" || _gel("where").value != "Change City") {
		var geocoder = new GClientGeocoder();
		geocoder.getLatLngAsync(_gel("where").value,function(point) {
			manMarker.setPoint(point);
			map.setCenter(point);
			currentPosition = point;
			getData(0.001);			
		});
	}
	return false;
};

togglePanSearch = function(){
	if(document.getElementById("panSearch").checked == true){
		moveListener = GEvent.addListener(map, 'dragend', function() {
			map.getCenterAsync(function(center) {
				currentPosition = center;
				manMarker.setPoint(center);
				manMarker.openInfoWindowHtml("<div align='center'><br>Hold on, I'm searching...<br><img src='http://www.checkinmania.com/20_loading_icon.gif'></div>",{disableGoogleLinks:true});
				getData(0);			
			});
		});		
	} else {
		if(moveListener) GEvent.removeListener(moveListener);
	}
};

hideDetails = function(){
	$("#adBox").hide();
	$("#adBox").html("");
	$("#controls").fadeIn('fast');
	$("#sidebar").height(370);
	$("#details").height(0);
	$("#details").html("");
	$("#details").hide();
	$("#sidebar").hide();
	$("#sidebar").fadeIn('slow');
}

getData = function(offset){
	if(service == 0)
		getFSQData(offset);
	else if(service == 1)
		getGOWVenues(currentPosition.lat(), currentPosition.lng());
};

getFSQData = function(offset){
	if(type == 0)
		getFSQVenues(currentPosition.lat()+offset, currentPosition.lng());
	else if(type == 1)
		getFSQTips(currentPosition.lat()+offset, currentPosition.lng());
};

toggleService = function(value){
	map.getCenterAsync(function(center) {
		map.setCenter(center, 16);
		currentPosition = center;
		addMashman(center);
		if(service != value && busy != 1) {
			hideDetails();
			service = value;
			togglePanSearch();
			toggleDataType(type);
		}
	});	
};

toggleDataType = function(value){
    type = value;
    if(service == 0){
	    $("#buttons").slideDown('slow');
	    $("#buttons").show();
    } else if(service == 1){
	    $("#buttons").slideUp('slow');
	}
    if(type == 0){
		document.getElementById('buttonVenue').style.background='#e8ecf9';
		document.getElementById('buttonOther').style.background='#D5DDF3';
    } else if (type == 1){
		document.getElementById('buttonVenue').style.background='#D5DDF3';
		document.getElementById('buttonOther').style.background='#e8ecf9';
    }
	if(service == 0){
		document.getElementById('buttonFSQ').style.background='#D5DDF3';
		document.getElementById('buttonGOW').style.background='#ffffff';
		for (var i=0; i<GOWVenues.length; i++) {	
			map.removeOverlay(GOWVenues[i].marker());
		}
		getFSQData(0);
	} else if(service == 1) {
		document.getElementById('buttonFSQ').style.background='#ffffff';
		document.getElementById('buttonGOW').style.background='#D5DDF3';
		for (var i=0; i<FSQVenues.length; i++) {
			map.removeOverlay(FSQVenues[i].marker());
		}	
		getGOWVenues(currentPosition.lat(), currentPosition.lng());
	}	
};

GEvent.addListener(map, 'click', function(overlay, point) {
 if(!overlay)
	if(point){
		currentPosition = point;
		manMarker.setPoint(point);
		getData(0);
	} 
});

_IG_Analytics("UA-2417064-26", "/checkinmania_mapplet");
</script>       
        ]]></Content>
</Module>