

/**
	
*/
var GoogleInterface = {
	activeGeoData : null,
	activeIframe : false,
	init : function (list) {
		$.each(list, function(i,geoData) {
			geoData.accuracy = parseInt(geoData.accuracy);
			//console.log(geoData);
			if (geoData.accuracy >= 4) {
				//Create link to map
				$('#address_'+geoData.asset_id+' .adr')
					.append('<br /><a href="javascript:void();" class="view-map" title="view map">View Map</a>')
					.bind('click', function(){ GoogleInterface.showMap(geoData)});
			}
		});
		var box = '<div id="modalWindow" class="jqmWindow mapWindow">';
		box += '<a class="jqmClose">[close window]</a></div>';
		$('body').append(box);
		
		//custom open function 
		var onOpen = function(hash) {
			hash.w.fadeIn('500'); 
		};
		
		//custom close function
		var onClose = function(hash) { 
			hash.w.fadeOut('1500', 
				function() { 
					hash.o.remove();
				});
		};
		
		$('#modalWindow').jqm({onHide: onClose, onShow: onOpen});
	},
	showMap: function(geoData) {
		//set active variable as the current geoData object
		GoogleInterface.activeGeoData = geoData;
		//create our modal window for the iframe
		var $modal = $('#modalWindow');
		if (!GoogleInterface.activeIframe) {
			$modal.append('<iframe src="/index/googleMap" scrolling="no" id="map-iframe" name="map-iframe"></iframe>');
			GoogleInterface.activeIframe = true;
		} else {
			window['map-iframe'].GoogleMaps.loadPoint(geoData);
		}
		
		$modal.jqmShow();
	}
}



















