var pointer;
var map;
var selectedMap = new Array();
var bMap = new Array();	var marker = new Array();	var gmapcfg = new Array();
var MapList = new Array();	var MarkerList = new Array();	var butClose;	var makeOnce = 0;	var makeTinyOnce = 0;	var idmarker = 0;
var idmap = 0;
var mrk = 0;
var i = 0;
function createButton() {
butClose = document.createElement("div");
butClose.setAttribute('id', 'butClose');
butClose.style.display = "none";
butClose.style.width=250;
butClose.style.height=25;
Event.observe(butClose, 'click', HideObjects);
objBody.appendChild(butClose);
butClose.style.left = parseInt($('bigmap').style.left) + parseInt($('bigmap').style.width) - parseInt(butClose.style.width) -1;
butClose.style.top = parseInt($('bigmap').style.top) + parseInt($('bigmap').style.height) - parseInt(butClose.style.height)-1;
document.getElementById('butClose').innerHTML = "[ Voltar ]";
}
function HideObjects() {
$('butClose').style.display = "none";
$('bigmap').style.display = "none";
$('overlayz').style.display = 'none';
objBody.style.overflow = 'auto';
}
function ShowObjects() {
new Effect.Appear('overlayz', { duration: .3, from: 0.0, to: 0.9, position: 'front' });
new Effect.Appear('bigmap', { duration: 0.5,   position: 'end' });
new Effect.Appear('butClose', { duration: 0.5,   position: 'end' });
objBody.style.overflow = 'hidden';
}
function centerMap(objMap) {
var arrayPageSize = getPageSize();
objMap.style.left = (arrayPageSize[2]-parseInt(objMap.style.width))/2;
objMap.style.top = (arrayPageSize[3]-parseInt(objMap.style.height))/2;
}
function createMarker( pointer, html, a ) {
marker[a] = new GMarker( pointer );
if (html!='') {
GEvent.addListener(
marker[a],
"click",
function() {
marker[a].openInfoWindowHtml('<div style="text-align: center">' + html + '</div>');
}
);
}
return marker[a];
}
function insertMarkers(mapname) {
for (a = 1; a <= idmarker; a++) {
if (MarkerList[a]['map']==mapname) {
bMap[object['name']].addOverlay( createMarker( MarkerList[a]['pointer'], MarkerList[a]['html'], a) );
}
}
}
function addMarker(mapname, lon, lat, html) {
idmarker++;
MarkerList[idmarker] = new Array();
MarkerList[idmarker]['pointer']=new GLatLng( lon, lat );
MarkerList[idmarker]['html']=html;
MarkerList[idmarker]['map']=mapname;
}
function createMap(name, type, width, height) {
idmap++;
MapList[idmap] = new Array();
MapList[idmap]['name']=name;
MapList[idmap]['width']=width;
MapList[idmap]['height']=height;
MapList[idmap]['type']=type;
}
function selectMap(name) {
for (z=1; z < MapList.length; z++) {
if (MapList[z]['name'] == name) {
return MapList[z];
}
}
}
function buildMap( config, object, center, appendObject) {
var varName = document.createElement("div");
varName.setAttribute('id', object['name']);
varName.style.width = object['width'];
varName.style.height = object['height'];
if (center=='center') {centerMap(varName)};
if (appendObject  != null) {
appendObject.appendChild(varName);	}
bMap[object['name']] = new GMap2(document.getElementById(object['name']));
bMap[object['name']].setCenter(new GLatLng(config['lon_center'], config['lat_center']), config['zoom']);
for (a = 1; a <= idmarker; a++) {
if (MarkerList[a]['map']==object['name']) {
bMap[object['name']].addOverlay( createMarker( MarkerList[a]['pointer'], MarkerList[a]['html'], a) );
}
}
if (object['type']=="full") {
objBody.style.overflow="hidden";
createButton()
}
}
function smallMap() {
if (makeTinyOnce==0) {
addMarker('map', gmapcfg['lon'], gmapcfg['lat'], '');
createMap('map', '', gmapcfg['width'], gmapcfg['height']);
selectedMap=selectMap('map');
buildMap(gmapcfg, selectedMap, '');
bMap[selectedMap['name']].disableDragging();
GEvent.addListener(
bMap[selectedMap['name']], "click", ShowOverlay
);
makeTinyOnce=1;
}
}
function fullMap() {
if (makeOnce==0) {
addMarker('bigmap', gmapcfg['lon'], gmapcfg['lat'], gmapcfg['markerhtml']);
createMap('bigmap', 'full', 800, 600);
selectedMap = selectMap('bigmap');
buildMap(gmapcfg, selectedMap, 'center', objBody)
bMap[selectedMap['name']].addControl(new GLargeMapControl());
bMap[selectedMap['name']].addControl(new GMapTypeControl());
makeOnce = 1;
}
HideObjects();
ShowObjects();
}