forked from SouthernFriedDNN/Map
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Map.js
729 lines (708 loc) · 21.8 KB
/
Map.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
//<![CDATA[
var TBL; //****
var PGS; //****
var map = false;
var DETECT = navigator.userAgent.toLowerCase();
var SPINWAIT = 0;
var SCROLLER;
var STATUS;
var TMID = 0 ;
var CURRENT = 0;
var XML = false;
var XMLA = false
var DATA = false;
var DATAA = false;
var ICONS = false;
var HASSTARTED = false;
var alternator = false;
var CURRENTPAGE = 0;
var DATALENGTH = 0;
var STARTDELAY = 0;
var listeners = new Array();
//NORMAL SETTING WHICH ARE OVERRIDDEN
var WURL = '';
var LOCALE_ADDADDRESS1 = 'The Address was located at (';
var LOCALE_ADDADDRESS2 = '). Would you like to add the point?';
var LOCALE_ADDRESS = 'Address';
var LOCALE_CITY = 'City';
var LOCALE_STATE = 'Region';
var LOCALE_COUNTRY = 'Country';
var LOCALE_ZIP = 'Postal Code';
var LOCALE_GO = 'Find Address';
var LOCALE_SAVE = 'Save';
var LOCALE_DELETE = 'Delete';
var LOCALE_CANCEL = 'Cancel';
var LOCALE_EDIT = 'Edit';
var LOCALE_ICONINDEX = 'Icon';
var LOCALE_INDEX = 'Index';
var LOCALE_TIMER = 'Sequence';
var LOCALE_TIMERINFO = 'Sequence Info';
var LOCALE_LATITUDE = 'Latitude';
var LOCALE_LONGITUDE = 'Longitude';
var LOCALE_DESCRIPTION = 'Description';
var LOCALE_ADDADDRESS = 'Find Address';
var LOCALE_NEW = 'New';
var LOCALE_PAGEFIRST = 'First';
var LOCALE_PAGELAST = 'Last';
var LOCALE_PAGENEXT = 'Next';
var LOCALE_PAGEBACK = 'Back';
var LOCALE_STATUS1 = 'Rendering Data...';
var LOCALE_STATUS2 = 'Fetching Data...';
var LOCALE_STATUS3 = 'Data Failure.';
var LOCALE_STATUS4 = 'AJAX: Asynchronous XML with Javascript is not supported by your browser.';
var LOCALE_STATUS5 = 'There was a problem retrieving the XML data:\n';
var LOCALE_STATUS6 = 'Updating record...';
var LOCALE_STATUS7 = 'Finding Address...';
var LOCALE_STATUS8 = 'Could not locate ';
var LOCALE_STATUS9 = '. Try a different address.';
var LOCALE_STATUS10 = 'Adding Point...';
var LOCALE_MAPPLOT = 'Plot';
var LOCALE_MAPCLEAR = 'Clear';
var LOCALE_ZOOMHIDE = 'Zoom (Hide)';
var LOCALE_ZOOM = 'Zoom (Show)';
var LOCALE_DSEP = '.';
function startDataWizard()
{
//-----------------
//STARTUP
//-----------------
if (GBrowserIsCompatible && GBrowserIsCompatible()) {
Map_Initiate(); }
//-----------------
}
function GBrowserIsCompatible()
{
return true;
}
function Map_BrowserType(string)
{
return DETECT.indexOf(string) + 1;
}
function Map_Initiate()
{
if (Map_BrowserType('msie') && document.readyState != 'complete')
{ window.setTimeout('Map_Initiate();', SPINWAIT) }
else
{ Map_onLoad(); }
}
function Map_onLoad()
{
if (GBrowserIsCompatible && GBrowserIsCompatible()) {
TBL = document.getElementById("tbl"); //******
STATUS = document.getElementById("Status"); //*****
PGS = document.getElementById("pgs"); //*****
if (window.goMap_LoadIcons) {
goMap_LoadIcons();
}
//Map_mapdisplay();
Map_Fetch();
}
}
function Map_Load()
{
if (HASSTARTED)
{
if (TBL && DATA)
{
STATUS.innerHTML = LOCALE_STATUS1;
HASSTARTED = false;
Map_Render();
}
STATUS.innerHTML = '';
Map_BuildPageControl();
}
else
{
HASSTARTED = true;
window.setTimeout('Map_Load();',STARTDELAY);
}
}
//-----------------
//MANAGER FUNCTIONS
//-----------------
//DATA BUILDING FUNCTIONALITY
//GET THE DATA POINTS FROM THE DOM OBJECT
function Map_DataPoints(dom) {
if (dom)
{
DATALENGTH = Map_Value(dom,"Total", 0);
return dom.getElementsByTagName('anyType');
}
else
{
return false;
}
}
function Map_Style()
{
strValue = '';
strValue += '<style>\n';
strValue += '.ColText {font-family: arial;font-size: 11px;color: black;}\n';
strValue += '.ColHead {font-family: arial;font-size: 11px;color: white;background: #555555;font-weight: bold;}\n';
strValue += '.ColItem {font-family: arial;font-size: 11px;color: black;background: #eeeeee;}\n';
strValue += '.ColAltItem {font-family: arial;font-size: 11px;color: black;background: #dddddd;}\n';
strValue += '</style>\n';
return strValue;
}
//GET A VALUE OF A NODE WITHIN A DATAPOINT
function Map_Value(obj,name,def)
{
if (obj)
{
nodes = obj.getElementsByTagName(name);
if (nodes && nodes.length > 0 && nodes.item(0) && nodes.item(0).firstChild && nodes.item(0).firstChild.nodeValue)
{
return (nodes.item(0).firstChild.nodeValue);
}
else
{
return (def);
}
}
}
//DATA AJAX FUNCTIONALITY
function Map_Fetch(page)
{
STATUS.innerHTML = LOCALE_STATUS2;
if (!page)
{
page = 0;
}
if (!CURRENTPAGE)
{
CURRENTPAGE = 0;
}
if (page >= 0 && ((DATALENGTH == 0 && page == 0) || ((page) <= Math.round((DATALENGTH/10) + 0.5))))
{
CURRENTPAGE = page;
DATA = false;
}
if (!DATA)
{
Map_FetchStart();
}
else
{
Map_Load();
}
}
function Map_FetchStart()
{
try
{
CZOOM=-1;
eval('MapRead();');
eval('STATUS').innerHTML = LOCALE_STATUS2;
}
catch(e)
{
eval('STATUS').innerHTML = LOCALE_STATUS4;
}
}
function Map_FetchEnd(ID)
{
eval('DATA = Map_DataPoints(DATA' + ID + ',' + ID + ');');
if (DATA)
{
CURRENT = 0;
Map_Load();
}
}
function Map_DataPoints(result,ID) {
var results;
eval(result);
return results;
}
//RENDER THE RESULTING TABLE
function Map_Number(value,target)
{
if (target!=undefined || LOCALE_DSEP != '.')
if (target==undefined)
value = (value+'').replace(/\./g,LOCALE_DSEP);
else
if (target!=LOCALE_DSEP)
eval('value = (value+\'\').replace(/' + LOCALE_DSEP + '/g,\'.\');');
return value;
}
function Map_Render()
{
var strvalue = '';
if (TBL && DATA) {
TBL.innerHTML = '';
strvalue += '<table width=100% border=0 cellpadding=0 cellspacing=0 class=Normal><tr>' +
'<td><img src="images/spacer.gif" height=1 width=16></td>' +
'<td><img src="images/spacer.gif" height=1 width=16></td>' +
'<td><img src="images/spacer.gif" height=1 width=16></td>' +
'<td><img src="images/spacer.gif" height=1 width=50></td>' +
'<td><img src="images/spacer.gif" height=1 width=150></td>' +
'<td><img src="images/spacer.gif" height=1 width=150></td>' +
'<td><img src="images/spacer.gif" height=1 width=50></td>' +
'<td><img src="images/spacer.gif" height=1 width=50></td>' +
'</tr><tr>' +
'<td class=GridHeader> </td>' +
'<td class=GridHeader colspan=2>' + LOCALE_EDIT + '</td>' +
'<td class=GridHeader>' + LOCALE_TIMER + '</td>' +
'<td class=GridHeader>' + LOCALE_LATITUDE + '</td>' +
'<td class=GridHeader>' + LOCALE_LONGITUDE + '</td>' +
'<td class=GridHeader>' + LOCALE_ZOOM + '</td>' +
'<td class=GridHeader width=100%>' + LOCALE_ADDRESS + '</td>' +
'</tr>';
while (CURRENT < DATA.length)
{
var i = CURRENT;
for (i = 0; CURRENT < DATA.length; i++)
{
if (alternator)
cname='DataGridAlternatingItem';
else
cname='DataGridItem';
alternator = !alternator;
address = DATA[i][0];
description = DATA[i][1];
distance = DATA[i][2];
index = DATA[i][3];
latitude = DATA[i][4];
longitude = DATA[i][5];
iconindex = DATA[i][6];
timer = DATA[i][7];
timerinfo = DATA[i][8];
zoom = DATA[i][9];
zoomhide = DATA[i][10];
summarycount = DATA[i][11];
iconvalue = '<img src=\'' + WURL + 'spacer.gif\' width=16 height=16>';
if (ICONS && ICONS.length > iconindex)
{
iconvalue = '<img src=\'' + ICONS[iconindex].image + '\'>';
}
strvalue += '<tr>' +
'<td class=' + cname + '>' + iconvalue + '</td>' +
'<td class=' + cname + '>' + '<a href=\'javascript:Map_Edit(' + i + ');\'>' + '<img border=0 src=\'' + WURL + 'edit.gif' + '\'>' + '</a>' + '</td>' +
'<td class=' + cname + '>' + '<a href=\'javascript:Map_PointDrop(' + index + ');\'>' + '<img border=0 src=\'' + WURL + 'delete.gif' + '\'>' + '</a>' + '</td>' +
'<td class=' + cname + '>' + '<a href="javascript:Map_Edit(' + i + ');">' + timer + '</a></td>' +
'<td class=' + cname + '>' + Map_Number(latitude) + '</td>' +
'<td class=' + cname + '>' + Map_Number(longitude) + '</td>' +
'<td class=' + cname + '>' + zoom + '</td>' +
'<td class=' + cname + '>' + address + '</td>' +
'</tr>';
CURRENT = CURRENT + 1;
}
}
CURRENT = 0;
strvalue += '</table>';
TBL.innerHTML = strvalue;
}
}
//BUILD PAGING CONTROL FOR THE RENDERED TABLE
function Map_BuildPageControl()
{
PGS.innerHTML = '<a href="javascript:Map_Edit(-1);">' + LOCALE_NEW + '</a> | <a href="javascript:Map_Address();">' + LOCALE_ADDADDRESS + '</a> | </td>';
PGS.innerHTML += '</td>';
minPage = (CURRENTPAGE + 1) - 4;
lastPage = Math.round((DATALENGTH/10) + 0.5) - 1;
if (minPage < 1)
{
minPage = minPage + Math.abs(minPage)
}
maxPage = minPage + 6;
if (maxPage > lastPage)
{
maxPage = lastPage;
}
if (maxPage == lastPage && maxPage - 6 > 0)
{
minPage = maxPage - 6;
}
else if (maxPage == lastPage)
{
maxPage = maxPage - 6 + Math.abs(maxPage - 6);
}
if (minPage > 0)
{
PGS.innerHTML += '<a href="javascript:Map_Fetch(CURRENTPAGE - 1);">' + LOCALE_PAGEBACK + '</a> ... ';
PGS.innerHTML += '<a href="javascript:Map_Fetch(' + 0 + ');">' + LOCALE_PAGEFIRST + '</a> | ';
}
else
{
PGS.innerHTML += '' + LOCALE_PAGEBACK + ' ... ';
PGS.innerHTML += '' + LOCALE_PAGEFIRST + ' | ';
}
for (x=minPage;x<=maxPage;x++)
{
if (x==CURRENTPAGE)
PGS.innerHTML += (x+1);
else
PGS.innerHTML += '<a href="javascript:Map_Fetch(' + x + ');">' + (x+1) + '</a>';
PGS.innerHTML += ' ';
}
if (CURRENTPAGE < lastPage)
{
PGS.innerHTML += '| <a href="javascript:Map_Fetch(' + lastPage + ');">' + LOCALE_PAGELAST + '</a> ... ';
PGS.innerHTML += '<a href="javascript:Map_Fetch(CURRENTPAGE + 1);">' + LOCALE_PAGENEXT + '</a>';
}
else
{
PGS.innerHTML += '| ' + LOCALE_PAGELAST + ' ... ';
PGS.innerHTML += '' + LOCALE_PAGENEXT + '';
}
}
//CLOSE THE UTILITY WINDOW (ADDRESS AND POINT)
function Map_CloseUtility()
{
if (pwin)
{
try
{ pwin.close(); }
catch(ex)
{}
pwin = false;
}
}
function Map_MapPlot()
{
if (map && DATA)
{
for (mi = 0; mi < DATA.length; mi++)
{
address = DATA[mi][0];
description = DATA[mi][1];
distance = DATA[mi][2];
index = DATA[mi][3];
latitude = DATA[mi][4];
longitude = DATA[mi][5];
iconindex = DATA[mi][6];
timer = DATA[mi][7];
timerinfo = DATA[mi][8];
zoom = DATA[mi][9];
zoomhide = DATA[mi][10];
summarycount= DATA[mi][11];
//null = ICONARRAY[iconindex]
iconvalue = null;
if (ICONS && ICONS.length > iconindex)
{
iconvalue = ICONS[iconindex];
}
map.addOverlay(Map_MakeMark(new GPoint(longitude, latitude),mi,description,iconvalue));
}
}
}
function Map_MapClear()
{
if (map)
{
map.clearOverlays();
for(i=0;i<listeners.length;i++)
{
try
{
GEvent.removeListener(listeners[i]);
}
catch(ex)
{
alert(ex);
}
}
listeners = new Array();
}
}
function Map_MakeMark(point, number, html, icon) {
var marker;
if (icon) { marker = new GMarker(point,icon); }
else { marker = new GMarker(point); }
// Show this marker's html in the info window when it is clicked
listeners[listeners.length] = GEvent.addListener(marker, "click", function() {marker.openInfoWindowHtml(html);});
return marker;
}
//UTILITYWINDOW - EDIT A MAP POINT VALUE
function Map_Edit(index,lat,lon,address)
{
Map_CloseUtility();
var description;
var distance;
var pointid;
var latitidue;
var longitude;
var iconindex;
var timer;
var timerinfo;
var zoom;
var zoomhide;
if ((DATA && index < DATA.length) || index==-1)
{
if (index >= 0)
{
address = DATA[index][0];
description = DATA[index][1];
distance = DATA[index][2];
pointid = DATA[index][3];
latitude = DATA[index][4];
longitude = DATA[index][5];
iconindex = DATA[index][6];
timer = DATA[index][7];
timerinfo = DATA[index][8];
zoom = DATA[index][9];
zoomhide = DATA[index][10];
summarycount= DATA[index][11];
}
else
{
pointid = -1;
latitude = 0.0;
if (lat)
{
latitude = lat;
}
longitude = 0.0;
if (lon)
{
longitude = lon;
}
iconindex = 0;
timer = 0;
timerinfo = '';
description = '';
zoom = 0;
if (address == undefined)
{
address = '';
}
zoomhide = 17;
}
pwin = window.open('about:blank',null,'height=432,width=400,status=no,statusbar=0,scrollbars=0,resizable=no,toolbar=no,menubar=no,location=no');
pwin.document.write('<html><head><title>Point Editor</title></head><body>' + Map_Style() + '<form>' +
'<table style="width: 100%; height:100%; border: 1px solid #cccccc;" class=ColText border=0 cellpadding=1 cellspacing=0>')
//'<tr>' + '<td width=100px>' + LOCALE_ICONINDEX + ':</td><td width=100%><input style="width:100%;" id=txtIcon value="' + iconindex + '"></td>' + '</tr>' +
if (ICONS && ICONS.length > 0)
{
pwin.document.write('<tr>' + '<td width=100px>' + LOCALE_ICONINDEX + ':</td><td width=100%>');
for(j=0; j<ICONS.length; j++)
{
pwin.document.write('<input name=txtIcon type=RADIO value="' + j + '"');
if (iconindex == j)
{
pwin.document.write(' checked');
}
pwin.document.write('/>' + '<img src=\'' + ICONS[j].image + '\'>');
}
pwin.document.write('</td>' + '</tr>');
}
else
{
pwin.document.write('<tr>' + '<td width=100px>' + LOCALE_ICONINDEX + ':</td><td width=100%>');
pwin.document.write('<input style="width:300px;" id=txtIcon type=text value="' + iconindex + '">')
pwin.document.write('</td>' + '</tr>');
}
pwin.document.write('<tr>' + '<td width=100px>' + LOCALE_LATITUDE + ':</td><td width=100%><input style="width:300px;" id=txtLatitude value="' + Map_Number(latitude) + '"></td>' + '</tr>' +
'<tr>' + '<td width=100px>' + LOCALE_LONGITUDE + ':</td><td width=100%><input style="width:300px;" id=txtLongitude value="' + Map_Number(longitude) + '"></td>' + '</tr>' +
'<tr>' + '<td width=100px>' + LOCALE_TIMER + ':</td><td width=100%><input style="width:300px;" id=txtTimer value="' + timer + '"></td>' + '</tr>' +
'<tr>' + '<td width=100px>' + LOCALE_TIMERINFO + ':</td><td width=100%><input style="width:300px;" id=txtTimerInfo value="' + timerinfo + '"></td>' + '</tr>' +
'<tr>' + '<td width=100px>' + LOCALE_ADDRESS + ':</td><td width=100%><textarea id=txtAddress maxlength=300 width=300px style="width:300px; height: 100px;">' + address + '</textarea></td>' + '</tr>' +
'<tr>' + '<td width=100px>' + LOCALE_DESCRIPTION + ':</td><td width=100%><textarea id=txtSelect maxlength=1000 width=300px style="width:300px; height: 100px;">' + description + '</textarea></td>' + '</tr>' +
'<tr>' + '<td width=100px>' + LOCALE_ZOOM + ':</td><td width=100%><SELECT style="width:300px;" id=txtZoom>');
for (x=0;x<17;x++)
{
if (x==zoom)
pwin.document.write('<OPTION value="' + x + '" selected=true>' + x + '</OPTION>');
else
pwin.document.write('<OPTION value="' + x + '">' + x + '</OPTION>');
}
pwin.document.write('</SELECT></td>' + '</tr>')
pwin.document.write(
'<tr>' + '<td width=100px>' + LOCALE_ZOOMHIDE + ':</td><td width=100%><SELECT style="width:300px;" id=txtZoomHide>');
for (x=0;x<17;x++)
{
if (x==zoomhide)
pwin.document.write('<OPTION value="' + x + '" selected=true>' + x + '</OPTION>');
else
pwin.document.write('<OPTION value="' + x + '">' + x + '</OPTION>');
}
pwin.document.write('</SELECT></td>' + '</tr>' +
'<tr>' + '<td colspan=2 class=ColAltItem width=100% align=right><a href="javascript:window.opener.Map_PointUpdate(' + pointid + ',document.forms[0]);">' + LOCALE_SAVE + '</a> | ' + '<a href="javascript:window.opener.Map_PointDrop(' + pointid + ');">' + LOCALE_DELETE + '</a> | ' + '<a href="javascript:window.close();">' + LOCALE_CANCEL + '</a>' + '</td></tr>' +
'</table>' +
'</form></body></html>');
}
}
//HANDLE THE MAP POINT UPDATE
function Map_PointUpdate(index,fvalue)
{
STATUS.innerHTML = LOCALE_STATUS6;
var itemvalue = 0;
var iconcount = 0;
radio = true;
for (pos=0;pos<fvalue.elements.length && radio;pos++)
{
radio = false;
if (fvalue.elements[pos].name == 'txtIcon')
{
if (fvalue.elements[pos].checked)
{
itemvalue = fvalue.elements[pos].value;
}
iconcount += 1;
radio=true;
}
}
pos-=1;
if (iconcount == 0)
{
pos=1;
itemvalue = fvalue.elements[0].value;
}
Map_SetPoint(index,itemvalue,fvalue.elements[pos + 2].value,fvalue.elements[pos + 3].value,fvalue.elements[pos + 4].value,fvalue.elements[pos + 5].value,fvalue.elements[pos + 1].value,fvalue.elements[pos + 0].value, fvalue.elements[pos + 6].value, fvalue.elements[pos + 7].value);
Map_CloseUtility();
}
function Map_PointDrop(index)
{
STATUS.innerHTML = LOCALE_STATUS6;
Map_SetPoint(index,-9000,0,0,0,0,0,0,0,0);
Map_CloseUtility();
}
//BUILD THE SET POINT URL AND HANDLE UPDATE/INSERT INTERACTION
var SDATA;
function Map_SetPoint(index,iconindex,sequence,sequenceinfo,address,description,longitude,latitude,zoom,zoomhide)
{
latitude = Map_Number(latitude,'.');
longitude = Map_Number(longitude,'.');
if (isNaN(index)) index = -1;
if (isNaN(iconindex)) icondindex = 0;
if (isNaN(sequence)) sequence = 0;
if (isNaN(longitude)) longitude = 0;
if (isNaN(latitude)) latitude = 0;
if (isNaN(zoom)) zoom = 0;
if (isNaN(zoomhide)) zoomhide = 0;
var distance=0;
SDATA = new Array();
SDATA[0] = address;
SDATA[1] = description;
SDATA[2] = distance;
SDATA[3] = index;
SDATA[4] = latitude;
SDATA[5] = longitude;
SDATA[6] = iconindex;
SDATA[7] = sequence;
SDATA[8] = sequenceinfo;
SDATA[9] = zoom;
SDATA[10] = zoomhide;
eval('MapWrite();');
}
//UTILITYWINDOW - GET THE ADDRESS
var pwin = false;
var pwinurl = false;
function Map_Address()
{
//OPEN A NEW WINDOW - ADD THE ADDRESS FIELDS NECESSARY
Map_CloseUtility();
pwin = window.open('about:blank',null,'height=172,width=400,status=no,statusbar=0,scrollbars=0,resizable=no,toolbar=no,menubar=no,location=no');
pwin.document.write('<html><head><title>Address Locator</title></head><body>' + Map_Style() + '<form>' +
'<table class=ColText style="width: 100%; height:100%; border: 1px solid #cccccc;" border=0 cellpadding=0 cellspacing=0>' +
'<tr>' + '<td width=100px>' + LOCALE_ADDRESS + ':</td><td width=100%><input style="width:100%;" id=txtAddress1></td>' + '</tr>' +
'<tr>' + '<td width=100px> </td><td width=100%><input style="width:100%;" id=txtAddress2></td>' + '</tr>' +
'<tr>' + '<td width=100px>' + LOCALE_COUNTRY + ':</td><td width=100%><input style="width:100%;" id=txtCountry></td>' + '</tr>' +
'<tr>' + '<td width=100px>' + LOCALE_CITY + ':</td><td width=100%><input style="width:100%;" id=txtCity></td>' + '</tr>' +
'<tr>' + '<td width=100px>' + LOCALE_STATE + ':</td><td width=100%><input style="width:100%;" id=txtState></td>' + '</tr>' +
'<tr>' + '<td width=100px>' + LOCALE_ZIP + ':</td><td width=100%><input style="width:100%;" id=txtZip></td>' + '</tr>' +
'<tr>' + '<td colspan=2 class=ColAltItem width=100% align=right><a href="javascript:window.opener.Map_SetAddress(document.forms[0]);window.opener.setTimeout(\'Map_FetchGeo();\',0);">' + LOCALE_GO + '</a></td>' + '</tr>' +
'</table>' +
'</form></body></html>');
}
//ADDRESS AJAX FUNCTIONALITY
var pAddress = '';
function Map_FetchGeoStart()
{
try
{
eval('MapGeo();');
eval('STATUS').innerHTML = LOCALE_STATUS2;
}
catch(e)
{
alert(e.toString());
eval('STATUS').innerHTML = LOCALE_STATUS4;
}
}
function Map_FetchGeoEnd(ID)
{
eval('DATAA = Map_DataPoints(DATA' + ID + ',' + ID + ');');
if (DATAA)
{
if (DATAA[0])
{
//SUCCESS
Map_Edit(-1,DATAA[1], DATAA[2],DATAA[3])
}
else
{
alert('Sorry, we are unable to locate a point for that address. Please try again.');
}
}
}
//BUILD THE ADDRESS URL
var ADDRESS;
function Map_SetAddress(fvalues)
{
ADDRESS = new Array();
ADDRESS[0] = fvalues.elements[0].value;
ADDRESS[1] = fvalues.elements[1].value;
ADDRESS[2] = fvalues.elements[2].value;
ADDRESS[3] = fvalues.elements[3].value;
ADDRESS[4] = fvalues.elements[4].value;
ADDRESS[5] = fvalues.elements[5].value;
}
function Map_GeoLookup(moduleID)
{
var str = 'GEO:' + moduleID + '|' + pAddress;
pAddress = '';
return str;
}
//FETCH THE ADDRESS LON/LAT BASED ON URL
function Map_FetchGeo()
{
if (pwin)
{
pwin.close();
pwin = false;
}
Map_FetchGeoStart();
}
//THE ADDRESS HAS BEEN FOUND, PARSE THE RETURN
function Map_AddAddress()
{
STATUS.innerHTML = LOCALE_STATUS7;
if (TBL && DATAA)
{
address = DATAA[0][0];
description = DATAA[0][1];
distance = DATAA[0][2];
index = DATAA[0][3];
latitude = DATAA[0][4];
longitude = DATAA[0][5];
iconindex = DATAA[0][6];
timer = DATAA[0][7];
timerinfo = DATAA[0][8];
zoom = DATAA[0][9];
zoomhide = DATAA[0][10];
if (latitude == 0 && longitude == 0)
{
alert(LOCALE_STATUS8 + description + LOCALE_STATUS9);
}
else
{
if (DATAA)
{
if (window.confirm(LOCALE_ADDADDRESS1 + Map_Number(latitude) + ',' + Map_Number(longitude) + LOCALE_ADDADDRESS2))
{
STATUS.innerHTML = LOCALE_STATUS10;
Map_SetPoint(-1, iconindex, timerinfo, timer, address, description, longitude, latitude, zoom, zoomhide);
}
}
}
}
DATAA = false;
DATA = false;
STATUS.innerHTML = '';
}
function Map_clickPoint(overlay, point) {
if (point) {
Map_Edit(-1,point.y,point.x);
}
}
//]]>