//JavaScript Document

var hotspots = new Array();
var currentRegion = null;
var map = null;
var hotspotLayer = null
var hotspotDragControl = null;
var hotspotSelectControl = null;
var currentHotspot = null;
var token = null;
var currentUser = null;
var tt_content = "<div id='tt_content'><h1>Loading...</h1><hr /><img src='/map/images/loadinfo.net.gif' /></div>";
var loginMsg = "";
var dragControl = null;
var popup = null;
var edit = false;
var adding = null; //set to hotspot_id when adding a new feature
var currentDetails = {};
var originalLoc = null; //used to reset illeagally moved features on the drag
var movingCurrentHotspot = null; //used by the drag function

var iconSize = new OpenLayers.Size(20,34);
var iconOffset = new OpenLayers.Pixel(-(iconSize.w/2), -iconSize.h);

//TODO: CURRENTLY SET MANUALLY, SHOULD REFACTOR FOR AUTO-GENERATION!!!
var icons = new Array();
icons['free'] = 'http://www.wifi-in-australia.com/map/images/free.png';
icons['paid'] = 'http://www.wifi-in-australia.com/map/images/paid.png';
icons['restricted'] = 'http://www.wifi-in-australia.com/map/images/restricted.png';
icons['edit'] = 'http://www.wifi-in-australia.com/map/images/edit.png';

function wiauLonLat(lon,lat) {
    return new OpenLayers.LonLat(lon, lat).transform(new OpenLayers.Projection("EPSG:4326"), map.getProjectionObject());
}

function revOsmLonLat(lon,lat) {
    return new OpenLayers.LonLat(lon, lat).transform(map.getProjectionObject(),new OpenLayers.Projection("EPSG:4326"));
}

function osmPoint(lon,lat) {
    return new OpenLayers.Geometry.Point(lon,lat).transform(new OpenLayers.Projection("EPSG:4326"), map.getProjectionObject());
}