var DH = {
initialized: false,
isIE6CSS: (document.compatMode && document.compatMode.indexOf("CSS1") >= 0) ? true : false,
isIE: false,
isSafari : (navigator.userAgent && navigator.vendor && (navigator.userAgent.toLowerCase().indexOf("applewebkit") != -1 || navigator.vendor.indexOf("Apple") != -1)),
baseDir: null,
timestamp: 0,
debugWindow: null,
messages: new Array(),
messagesIndex: 0,
includes: new Array(),
onReady: null,
scriptCount: -1,
debug: function(flag, label, value) {
if (flag == false) {
return;
}
var funcName = "none";
if (DH.debug.caller) {
funcName = DH.debug.caller.toString()
funcName = funcName.substring(9, funcName.indexOf(")") + 1)
}
var msg = "-" + funcName + ": " + label + "=" + value
var now = new Date()
var elapsed = now - DH.timestamp
if (elapsed < 10000) {
msg += " (" + elapsed + " msec)"
}
DH.timestamp = now;
if ((DH.debugWindow == null) || DH.debugWindow.closed) {
DH.debugWindow = window.open("", "DebugWin", "toolbar=no,scrollbars=yes,resizable=yes,width=600,height=400");
}
DH.messages[DH.messagesIndex++] = msg;
DH.debugWindow.document.writeln('<html><head><title>Debug Window</title></head><body bgcolor=#DDDDDD>');
for (var i = 0; i < DH.messagesIndex; i++) {
DH.debugWindow.document.writeln('<pre>' + i + ': ' + DH.messages[i] + '</pre>');
}
DH.debugWindow.document.writeln('</body></html>');
DH.debugWindow.document.close();
DH.debugWindow.focus();
},
init: function() {
if (DH.initialized == true) {
return;
}
DH.isIE = !window.opera && navigator.userAgent.indexOf('MSIE') != -1;
if (!document.getElementById || !document.getElementsByTagName) {
alert('Your browser does not support W3C DHTML, use a modern browser like FireFox');
return;
}
if (window.ActiveXObject && !window.XMLHttpRequest) {
window.XMLHttpRequest = function() {
var msxmls = new Array(
'Msxml2.XMLHTTP.5.0',
'Msxml2.XMLHTTP.4.0',
'Msxml2.XMLHTTP.3.0',
'Msxml2.XMLHTTP',
'Microsoft.XMLHTTP');
for (var i = 0; i < msxmls.length; i++) {
try {
return new ActiveXObject(msxmls[i]);
} catch (e) {
}
}
return null;
};
}
if (!window.ActiveXObject && window.XMLHttpRequest) {
window.ActiveXObject = function(type) {
switch (type.toLowerCase()) {
case 'microsoft.xmlhttp':
case 'msxml2.xmlhttp':
case 'msxml2.xmlhttp.3.0':
case 'msxml2.xmlhttp.4.0':
case 'msxml2.xmlhttp.5.0':
return new XMLHttpRequest();
}
return null;
};
}
try {
Document.prototype.__defineGetter__("xml", function () {
return (new XMLSerializer()).serializeToString(this);
});
} catch(e) {
}
DH.initialized = true;
},
addUniqueParm: function(url) {
var extraParm = 'tt=' + new Date().getTime();
if (url.indexOf("?") > 0) {
extraParm = '&' + extraParm;
} else {
extraParm = '?' + extraParm;
}
return url + extraParm;
},
onLoadScript: function() {
if (DH.checkScriptReadyState(this)) {
DH.scriptCount--;
}
if (DH.scriptCount == 0) {
DH.onReady();
}
},
checkIncludes: function() {
if (document.readyState != null) {
var lastReady = 'dono';
while (DH.includes.length > 0 && DH.checkScriptReadyState(DH.includes[0])) {
lastReady = DH.includes[0].readyState;
DH.includes.shift();
}
if (DH.includes.length == 0) {
clearInterval(DH.includesTimer);
alert('loading ready document.readyState != null last=' + lastReady)
DH.onReady();
return true;
} else {
return false;
}
}
else {
clearInterval(DH.includesTimer);
alert('loading ready document.readyState == null')
DH.onReady();
return true;
}
},
checkScriptReadyState: function(scriptObject) {
if (document.readyState == null) {
return true;
}
if (DH.isIE) {
return scriptObject.readyState == "complete" || scriptObject.readyState == "loaded";
} else {
return scriptObject.readyState == "complete" || scriptObject.readyState == "loaded" || scriptObject.readyState == null;
}
},
addEvent: function(elm, evType, callback, useCapture) {
var obj = DH.getObject(elm);
if (obj == null) {
return;
}
if (obj.addEventListener) {
obj.addEventListener(evType, callback, useCapture);
return true;
} else if (obj.attachEvent) {
var r = obj.attachEvent('on' + evType, callback);
return r;
} else {
obj['on' + evType] = callback;
}
},
removeEvent: function(elm, evType, callback) {
var obj = DH.getObject(elm);
if (obj == null) {
return;
}
if (obj.removeEventListener) {
obj.removeEventListener(evType, callback, false);
return true;
} else if (obj.detachEvent) {
var r = obj.detachEvent('on' + evType, callback);
return r;
} else {
obj['on' + evType] = null;
}
},
getEvent: function(e) {
return window.event ? window.event : e;
},
getEventTarget: function(e) {
var target = window.event ? window.event.srcElement : e ? e.target : null;
if (target != null && target.nodeType == 3) {
target = target.parentNode;
}
return target;
},
cancelEvent: function(e) {
if (window.event) {
window.event.cancelBubble = true;
window.event.returnValue = false;
return;
}
if (e) {
e.stopPropagation();
e.preventDefault();
}
},
getEventX: function(e) {
var x;
if (e.pageX) {
x = e.pageX;
} else if (e.clientX) {
x = e.clientX;
if (DH.isIE) {
x += document.body.scrollLeft;
}
}
return x;
},
getEventY: function(e) {
var y;
if (e.pageY) {
y = e.pageY;
} else if (e.clientY) {
y = e.clientY;
if (DH.isIE) {
y += document.body.scrollTop;
}
}
return y;
},
blink: function(elm, cnt, interval) {
var obj = DH.getObject(elm)
if (cnt <= 0) {
DH.show(obj);
return;
}
DH.toggleVisibility(obj);
setTimeout(function() {
DH.blink(obj, cnt - 1, interval)
}, interval);
},
fixPNG: function(myImage) {
var arVersion = navigator.appVersion.split("MSIE")
var version = parseFloat(arVersion[1])
if ((version >= 5.5) && (version < 7) && (document.body.filters))
{
var imgID = (myImage.id) ? "id='" + myImage.id + "' " : ""
var imgClass = (myImage.className) ? "class='" + myImage.className + "' " : ""
var imgTitle = (myImage.title) ?
"title='" + myImage.title + "' " : "title='" + myImage.alt + "' "
var imgStyle = "display:inline-block;" + myImage.style.cssText
var strNewHTML = "<span " + imgID + imgClass + imgTitle
+ " style=\"" + "width:" + myImage.width
+ "px; height:" + myImage.height
+ "px;" + imgStyle + ";"
+ "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
+ "(src=\'" + myImage.src + "\', sizingMethod='scale');\"></span>"
myImage.outerHTML = strNewHTML
}
},
getBaseDir: function() {
if (DH.baseDir != null) {
return DH.baseDir;
}
var head = document.getElementsByTagName('head')[0];
var nodes = head.childNodes;
for (var i = 0; i < nodes.length; ++i) {
var src = nodes.item(i).src;
DH.debug(false, 'src', src)
if (src) {
var index = src.indexOf("/DHTML.js");
if (index < 0) {
index = src.indexOf("/all");
}
if (index >= 0) {
DH.baseDir = src.substring(0, index);
break;
}
}
}
return DH.baseDir;
},
getInsideWindowWidth: function () {
if (window.innerWidth) {
return window.innerWidth;
} else if (DH.isIE6CSS) {
return document.body.parentElement.clientWidth
} else if (document.body && document.body.clientWidth) {
return document.body.clientWidth;
}
return 0;
},
getInsideWindowHeight: function () {
if (window.innerHeight) {
return window.innerHeight;
} else if (DH.isIE6CSS) {
return document.body.parentElement.clientHeight
} else if (document.body && document.body.clientHeight) {
return document.body.clientHeight;
}
return 0;
},
getObject: function(obj) {
if (typeof obj == "string") {
return document.getElementById(obj);
} else {
return obj;
}
},
getObjectInWindow: function(winId, objId) {
try {
var winObj = eval(winId);
return winObj.document.getElementById(objId);
} catch(e) {
return null;
}
},
getStyleObject: function(obj) {
try {
return DH.getObject(obj).style;
} catch(e) {
return null;
}
},
getObjectX: function(obj) {
obj = DH.getObject(obj);
var curLeft = 0;
if (obj.offsetParent) {
do {
curLeft += obj.offsetLeft;
} while (obj = obj.offsetParent);
} else if (obj.x) {
curLeft += obj.x;
}
return curLeft;
},
getObjectY: function(obj) {
obj = DH.getObject(obj);
var curTop = 0;
if (obj.offsetParent) {
do {
curTop += obj.offsetTop;
} while (obj = obj.offsetParent);
} else if (obj.y) {
curTop += obj.y;
}
return curTop;
},
getObjectLeft: function (obj) {
var styleObj = DH.getStyleObject(obj);
if (styleObj == null) {
return 0;
}
return parseInt(styleObj.left);
},
getObjectTop: function (obj) {
var styleObj = DH.getStyleObject(obj);
if (styleObj == null) {
return 0;
}
return parseInt(styleObj.top);
},
getObjectWidth: function (obj) {
var elem = DH.getObject(obj);
var result = 0;
if (elem.offsetWidth) {
result = elem.offsetWidth;
} else if (elem.clip && elem.clip.width) {
result = elem.clip.width;
} else if (elem.style && elem.style.pixelWidth) {
result = elem.style.pixelWidth;
}
return parseInt(result);
},
getObjectHeight: function (obj) {
var elem = DH.getObject(obj);
var result = 0;
if (elem.offsetHeight) {
result = elem.offsetHeight;
} else if (elem.clip && elem.clip.height) {
result = elem.clip.height;
} else if (elem.style && elem.style.pixelHeight) {
result = elem.style.pixelHeight;
}
return parseInt(result);
},
_getParameter: function(string, parm, delim) {
if (string.length == 0) {
return '';
}
var sPos = string.indexOf(parm + "=");
if (sPos == -1) {
return '';
}
sPos = sPos + parm.length + 1;
var ePos = string.indexOf(delim, sPos);
if (ePos == -1) {
ePos = string.length;
}
return unescape(string.substring(sPos, ePos));
}
,
getPageParameter: function(parameterName, defaultValue) {
var s = self.location.search;
if ((s == null) || (s.length < 1)) {
return defaultValue;
}
s = DH._getParameter(s, parameterName, '&');
if ((s == null) || (s.length < 1)) {
s = defaultValue;
}
return s;
}
,
getMSDomDocumentPrefix:  function() {
if (DH.msDomDocumentPrefix) {
return DH.msDomDocumentPrefix;
}
var prefixes = ["MSXML2", "Microsoft", "MSXML", "MSXML3"];
var o;
for (var i = 0; i < prefixes.length; i++) {
try {
o = new ActiveXObject(prefixes[i] + ".DomDocument");
return DH.msDomDocumentPrefix = prefixes[i];
}
catch (ex) {
}
}
alert("Could not find an installed MSXML parser");
},
createXmlDocument: function () {
try {
if (document.implementation && document.implementation.createDocument) {
var doc = document.implementation.createDocument("", "", null);
if (doc.readyState == null) {
doc.readyState = 1;
doc.addEventListener("load", function () {
doc.readyState = 4;
if (typeof doc.onreadystatechange == "function")
doc.onreadystatechange();
}, false);
}
return doc;
}
if (window.ActiveXObject) {
return new ActiveXObject(DH.getMSDomDocumentPrefix() + ".DomDocument");
}
}
catch (ex) {
}
alert("Sorry, your browser does not support XmlDocument objects");
},
escape : function(s) {
return s.replace(/&/g, "&amp;")
.replace(/</g, "&lt;")
.replace(/>/g, "&gt;")
.replace(/"/g, "&quot;")
.replace(/'/g, "&apos;");
},
getXML: function(url, callback) {
DH._xhrBusy();
var xmlhttp = new XMLHttpRequest();
if (!xmlhttp || xmlhttp == null) {
alert('No browser XMLHttpRequest (AJAX) support');
return;
}
var cb = callback;
var async = false;
if (cb) {
async = true;
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == 4) {
if (xmlhttp.status == 200) {
cb(xmlhttp.responseXML);
DH._xhrReady();
} else {
alert('Problem retrieving XML data:\n' + xmlhttp.statusText);
}
}
};
}
xmlhttp.open('GET', url, async);
xmlhttp.send(null);
if (!cb) {
DH._xhrReady();
if (xmlhttp.status != 200) {
alert('Problem retrieving XML data:\n' + xmlhttp.statusText);
return null;
}
return xmlhttp.responseXML;
}
}
,
postXML: function(url, doc, callback) {
DH._xhrBusy();
var xmlhttp = new XMLHttpRequest();
if (!xmlhttp || xmlhttp == null) {
alert('No browser XMLHttpRequest (AJAX) support');
return;
}
var cb = callback;
var async = false;
if (cb) {
async = true;
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == 4) {
if (xmlhttp.status == 200) {
cb(xmlhttp.responseXML);
DH._xhrReady();
} else {
alert('Problem retrieving XML data using async POST:\n' + xmlhttp.statusText);
}
}
};
}
xmlhttp.open('POST', url, async);
if (this.isSafari) {
xmlhttp.send(doc);
} else {
xmlhttp.send(doc.xml);
}
if (!cb) {
DH._xhrReady();
if (xmlhttp.status != 200) {
alert('Problem retrieving XML data using async POST:\n' + xmlhttp.statusText);
return null;
}
return xmlhttp.responseXML;
}
}
,
getURL: function(url, callback) {
url = DH.addUniqueParm(url);
var xmlhttp = new XMLHttpRequest();
if (!xmlhttp || xmlhttp == null) {
alert('No browser XMLHttpRequest (AJAX) support');
return;
}
var cb = callback;
var async = false;
if (cb) {
async = true;
xmlhttp.onreadystatechange = function() {
DH._xhrReady();
if (xmlhttp.readyState == 4) {
if (xmlhttp.status == 200) {
cb(xmlhttp.responseText);
} else {
alert('Problem retrieving URL data (' + xmlhttp.status + ')\n' + xmlhttp.statusText);
}
}
};
}
DH._xhrBusy();
xmlhttp.open('GET', url, async);
xmlhttp.send(null);
if (!cb) {
DH._xhrReady();
if (xmlhttp.status != 200) {
alert('Problem retrieving URL data:\n' + xmlhttp.statusText);
return null;
}
return xmlhttp.responseText;
}
}
,
_xhrBusy: function() {
},
_xhrReady: function(httpStatus) {
},
include: function(url) {
var fullPath = DH.getBaseDir() + '/' + url;
fullPath = DH.addUniqueParm(fullPath);
var agent = navigator.userAgent;
var docWrite = (agent.match("MSIE") || agent.match("Safari"));
if (!document.getElementById(url)) {
var script = document.createElement('script');
script.type = "text/javascript";
script.src = fullPath;
script.id = url;
script.onload = DH.onLoadScript;
script.onreadystatechange = DH.onLoadScript;
if (DH.scriptCount == -1) {
DH.scriptCount = 0;
}
DH.scriptCount++;
document.getElementsByTagName('head')[0].appendChild(script);
DH.includes.push(script);
}
},
setObjectXY: function(obj, x, y) {
var theObj = DH.getStyleObject(obj);
if (theObj != null) {
var units = (typeof theObj.left == "string") ? 'px' : 0;
if (x) theObj.left = x + units;
if (y) theObj.top = y + units;
}
}
,
setObjectWH: function(obj, w, h) {
var theObj = DH.getStyleObject(obj);
if (theObj != null) {
var units = (typeof theObj.left == "string") ? 'px' : 0;
if (w) theObj.width = w + units;
if (h) theObj.height = h + units;
}
}
,
setObjectXYWH: function(obj, x, y, w, h) {
DH.setObjectXY(obj, x, y);
DH.setObjectWH(obj, w, h);
}
,
shiftTo: function(obj, x, y) {
DH.setObjectXY(obj, x, y);
}
,
shiftTo: function(obj, x, y) {
var theObj = DH.getStyleObject(obj);
if (theObj != null) {
var units = (typeof theObj.left == "string") ? 'px' : 0;
theObj.left = x + units;
theObj.top = y + units;
}
}
,
shiftBy: function(obj, deltaX, deltaY) {
var theObj = DH.getStyleObject(obj);
if (theObj != null) {
var units = (typeof theObj.left == "string") ? 'px' : 0;
theObj.left = (parseInt(theObj.left) + deltaX) + units;
theObj.top = (parseInt(theObj.top) + deltaY) + units;
}
}
,
setBGColor: function(obj, color) {
var theObj = DH.getStyleObject(obj);
if (theObj != null) {
theObj.backgroundColor = color;
}
}
,
setHTML: function(obj, html) {
var theObj = DH.getObject(obj);
if (theObj != null) {
theObj.innerHTML = html;
}
}
,
addHTML: function(obj, html) {
var theObj = DH.getObject(obj);
if (theObj != null) {
theObj.innerHTML += html;
}
}
,
setOpacity: function(obj, val) {
var o = DH.getObject(obj);
if (o != null) {
if (typeof(o.style.filter) == 'string') {
o.style.filter = 'alpha(opacity:' + val * 100 + ')';
}
if (typeof(o.style.KHTMLOpacity) == 'string') {
o.style.KHTMLOpacity = val;
}
if (typeof(o.style.MozOpacity) == 'string') {
o.style.MozOpacity = val;
}
if (typeof(o.style.opacity) == 'string') {
o.style.opacity = val;
}
}
}
,
setZIndex: function(obj, zOrder) {
var theObj = DH.getStyleObject(obj);
if (theObj != null) {
theObj.zIndex = zOrder;
}
}
,
show: function(obj) {
var theObj = DH.getStyleObject(obj);
if (theObj != null) {
theObj.visibility = "visible";
}
}
,
isVisible: function(obj) {
var theObj = DH.getStyleObject(obj);
if (theObj == null) {
return false;
}
return theObj.visibility == "visible" ? true : false;
}
,
toggleVisibility: function(obj) {
var theObj = DH.getStyleObject(obj);
if (theObj != null) {
theObj.visibility = (theObj.visibility == "visible") ? "hidden" : "visible";
}
}
,
toggleDisplay: function(obj) {
var theObj = DH.getStyleObject(obj);
if (theObj != null) {
theObj.display = (theObj.display == "none") ? "block" : "none";
}
}
,
displayOn: function(obj) {
var theObj = DH.getStyleObject(obj);
if (theObj != null) {
theObj.display = 'block';
}
}
,
displayOff: function(obj) {
var theObj = DH.getStyleObject(obj);
if (theObj != null) {
theObj.display = 'none';
}
}
,
hide: function(obj) {
var theObj = DH.getStyleObject(obj);
if (theObj != null) {
theObj.visibility = "hidden";
}
}
,
dragging: false,
dragTarget
:
null,
dragStartX
:
0,
dragStartY
:
0,
dragEnable
:
function (target, onStart, onDrag, onEnd) {
target.onStart = onStart;
target.onDrag = onDrag;
target.onEnd = onEnd;
DH.addEvent(target, 'mousedown', DH._dragStart, false);
}
,
dragDisable: function (target) {
target.onStart = null;
target.onDrag = null;
target.onEnd = null;
DH.removeEvent(target, 'mousedown', DH._dragStart);
}
,
_dragStart: function (e) {
DH.dragging = true;
DH.dragTarget = DH.getEventTarget(e);
e = DH.getEvent(e);
DH.dragStartX = DH.getEventX(e);
DH.dragStartY = DH.getEventY(e);
DH.addEvent(document, 'mousemove', DH._dragMove, false);
DH.addEvent(document, 'mouseup', DH._dragEnd, false);
if (DH.dragTarget.onStart != null) {
DH.dragTarget.onStart(DH.dragTarget, DH.dragStartX, DH.dragStartY);
}
}
,
_dragMove: function (e) {
if (DH.dragging == true) {
e = DH.getEvent(e);
var ex = DH.getEventX(e);
var ey = DH.getEventY(e);
if (DH.dragTarget.onDrag != null) {
DH.dragTarget.onDrag(DH.dragTarget, ex, ey, ex - DH.dragStartX, ey - DH.dragStartY);
}
DH.dragStartX = ex;
DH.dragStartY = ey;
return true;
} else {
return false;
}
}
,
_dragEnd: function (e) {
e = DH.getEvent(e);
if (DH.dragTarget.onEnd != null) {
DH.dragTarget.onEnd(DH.dragTarget, DH.getEventX(e), DH.getEventY(e));
}
DH.dragging = false;
DH.dragTarget = null;
DH.cancelEvent(e);
DH.removeEvent(document, 'mousemove', DH._dragMove);
DH.removeEvent(document, 'mouseup', DH._dragEnd);
return false;
}
}
DH.addEvent(window, 'load', DH.init, false);
var GMAP = {
map: null,
mapDiv: null,
mapTypes: [],
defaultCenter: null,
defaultZoom: 10,
defaultMapName: 'satellite',
DEGREES_PER_RADIAN: 360 / (2 * Math.PI),
RAD_PER_DEGREE: 0.01745566,
keyNone : {
key: "",
reg: "^"
},
keyArray : new Array(),
addKey: function(aName, aKey, aURLRegExp) {
GMAP.keyArray[aName] = { key: aKey, reg: aURLRegExp };
},
addMapType: function(aName, aSpec) {
GMAP.mapTypes[aName] = aSpec;
},
addTileMap: function(aTileSpec) {
var tileLayer = new GTileLayer(new GCopyrightCollection("GT"),
aTileSpec.minZoom ? aTileSpec.minZoom : 1,
aTileSpec.maxZoom ? aTileSpec.maxZoom: 20);
tileLayer.getTileUrl = function(point, zoom) {
return aTileSpec.baseURL + "/" + zoom + "/" + point.x + "/" + point.y + "." + aTileSpec.imageType;
}
tileLayer.isPng = function() {
return aTileSpec.imageType == 'png';
}
tileLayer.getOpacity = function() {
return 1.0;
}
var mapLayers = [tileLayer];
var mapType = new GMapType(mapLayers, G_SATELLITE_MAP.getProjection(), aTileSpec.id);
GMAP.addMapType(aTileSpec.id, mapType);
},
setMapType: function(aName) {
GMAP.map.setMapType(GMAP.mapTypes[aName]);
},
getMapSize: function(aName) {
return new GSize(DH.getObjectWidth(GMAP.mapDiv), DH.getObjectHeight(GMAP.mapDiv));
},
loadGoogleMapScript: function(aVersion) {
var version = '2';
if (aVersion) {
version = aVersion;
}
var k;
for (k in GMAP.keyArray) {
var key = GMAP.keyArray[k];
var regexp = new RegExp(key.reg);
if (regexp.test(window.location.href)) {
document.write('<' + 'script src="http://maps.google.com/maps?file=api&amp;v=' + version + '&amp;key=' + key.key + '" type="text/javascript"><' + '/script>');
break;
}
}
},
setDefaultMapParms: function(aCenter, aZoom, aMapName) {
GMAP.defaultCenter = aCenter;
GMAP.defaultZoom = aZoom;
GMAP.defaultMapName = aMapName;
},
showMap: function() {
var center = DH.getPageParameter('center', null);
if (center == null) {
if (GMAP.defaultCenter == null) {
GMAP.defaultCenter = new GLatLng(52.37261, 4.900435);
}
center = GMAP.defaultCenter;
} else {
var llArr = center.split(',');
center = new GLatLng(llArr[1], llArr[0]);
}
var mapName = DH.getPageParameter('map', GMAP.defaultMapName);
var zoomLevel = DH.getPageParameter('zoom', null);
if (zoomLevel == null) {
zoomLevel = GMAP.defaultZoom;
} else {
zoomLevel = parseInt(zoomLevel);
}
GMAP.map.setCenter(center, zoomLevel, GMAP.mapTypes[mapName]);
},
pixelToLatLon: function(x, y) {
return GMAP.map.fromContainerPixelToLatLng(new GPoint(x,y));
},
createGMap: function(divId) {
GMAP.mapDiv = DH.getObject(divId);
GMAP.resize();
var mapOpts = {
size: GMAP.getMapSize(),
draggableCursor:"default",
draggingCursor:"default"
}
GMAP.map = new GMap2(GMAP.mapDiv, mapOpts);
for (var i in GMAP.mapTypes) {
GMAP.map.addMapType(GMAP.mapTypes[i]);
}
},
isInBox: function(pt, bounds) {
return (pt.x > bounds.minX && pt.y > bounds.minY && pt.x < bounds.maxX && pt.y < bounds.maxY);
},
distance: function(a, b) {
if (a.x == b.x && a.y == b.y) {
return 0.0;
}
var rad = 0.01745566;
Lo = Math.abs(a.x - b.x);
Drad = Math.acos((Math.sin(a.y * rad) * Math.sin(b.y * rad)) + (Math.abs(Math.cos(a.y * rad)) * Math.abs(Math.cos(b.y * rad)) * Math.cos(Lo * rad)));
Crad = Math.acos((Math.sin(b.y * rad) - (Math.sin(a.y * rad) * Math.cos(Drad))) / (Math.cos(a.y * rad) * Math.sin(Drad)));
var Cdeg = Crad * 57.295779;
return Drad * 57.295779 * 69.06 * 1.6094;
},
heading: function(lat1, lon1, lat2, lon2) {
var v1, v2;
lat1 = lat1 * GMAP.RAD_PER_DEGREE;
lon1 = lon1 * GMAP.RAD_PER_DEGREE;
lat2 = lat2 * GMAP.RAD_PER_DEGREE;
lon2 = lon2 * GMAP.RAD_PER_DEGREE;
v1 = Math.sin(lon1 - lon2) * Math.cos(lat2);
v2 = Math.cos(lat1) * Math.sin(lat2) - Math.sin(lat1) * Math.cos(lat2) * Math.cos(lon1 - lon2);
if (Math.abs(v1) < 1e-15) {
v1 = 0.0;
}
if (Math.abs(v2) < 1e-15) {
v2 = 0.0;
}
var course = Math.atan2(v1, v2);
course = course * GMAP.DEGREES_PER_RADIAN
if (course < 0) {
course = -course;
}
if (lon2 < lon1) {
course = 360 - course;
}
return course;
},
speed: function(a, b) {
return (a.distanceFrom(b) / 1000) / ((b.time - a.time) / 3600000);
},
positionOverview: function () {
var mapOverview = DH.getObject('map_overview');
DH.setObjectXY(mapOverview, DH.getObjectWidth(GMAP.mapDiv) - DH.getObjectWidth(mapOverview) - 4, DH.getObjectTop(GMAP.mapDiv) + 4);
},
resize: function() {
var topAnchor = DH.getObject("topanchor");
var bottomAnchor = DH.getObject("bottomanchor");
DH.setObjectXYWH(GMAP.mapDiv, 0, DH.getObjectY(topAnchor), DH.getObjectX(bottomAnchor), DH.getInsideWindowHeight() - DH.getObjectY(topAnchor));
if (GMAP.map) {
GMAP.map.checkResize();
if (DH.getObject('map_overview')) {
setTimeout("GMAP.positionOverview()", 1);
}
}
}
}
var MAGIC_NUMBER = 6356752.3142;
var DEG2RAD = 0.0174532922519943;
var PI = 3.14159267;
function dd2MercMetersLng(p_lng) {
return MAGIC_NUMBER * (p_lng * DEG2RAD);
}
function dd2MercMetersLat(p_lat) {
if (p_lat >= 85) p_lat = 85;
if (p_lat <= -85) p_lat = -85;
return MAGIC_NUMBER * Math.log(Math.tan(((p_lat * DEG2RAD) + (PI / 2)) / 2));
}
var CustomGetTileUrl = function(a, b, c) {
if (typeof(window['this.myMercZoomLevel']) == "undefined") this.myMercZoomLevel = 0;
if (typeof(window['this.myStyles']) == "undefined") this.myStyles = "";
var lULP = new GPoint(a.x * 256, (a.y + 1) * 256);
var lLRP = new GPoint((a.x + 1) * 256, a.y * 256);
var lUL = G_NORMAL_MAP.getProjection().fromPixelToLatLng(lULP, b, c);
var lLR = G_NORMAL_MAP.getProjection().fromPixelToLatLng(lLRP, b, c);
if (this.myMercZoomLevel != 0 && map.getZoom() < this.myMercZoomLevel) {
var lBbox = dd2MercMetersLng(lUL.lngDegrees) + "," + dd2MercMetersLat(lUL.latDegrees) + "," + dd2MercMetersLng(lLR.lngDegrees) + "," + dd2MercMetersLat(lLR.latDegrees);
var lSRS = "EPSG:54004";
} else {
var lBbox = lUL.x + "," + lUL.y + "," + lLR.x + "," + lLR.y;
var lSRS = "EPSG:4326";
}
var lURL = this.myBaseURL;
lURL += "&REQUEST=GetMap";
lURL += "&SERVICE=WMS";
lURL += "&VERSION=" + this.myVersion;
lURL += "&LAYERS=" + this.myLayers;
lURL += "&STYLES=" + this.myStyles;
lURL += "&FORMAT=" + this.myFormat;
lURL += "&BGCOLOR=" + this.myBgColor;
lURL += "&TRANSPARENT=TRUE";
lURL += "&SRS=" + lSRS;
lURL += "&BBOX=" + lBbox;
lURL += "&WIDTH=256";
lURL += "&HEIGHT=256";
lURL += "&reaspect=false";
return lURL;
}
function createWMSSpec(wmsURL, gName, gShortName, wmsLayers, wmsStyles, wmsFormat, wmsVersion, wmsBgColor, wmsSrs) {
var tile = new GTileLayer(new GCopyrightCollection(""), 1, 17);
tile.myLayers = wmsLayers;
tile.myStyles = (wmsStyles ? wmsStyles : "");
;
tile.myFormat = (wmsFormat ? wmsFormat : "image/gif");
;
tile.myVersion = (wmsVersion ? wmsVersion : "1.1.1");
tile.myBgColor = (wmsBgColor ? wmsBgColor : "0xFFFFFF");
tile.myBaseURL = wmsURL;
tile.getTileUrl = CustomGetTileUrl;
var layer = [tile];
var mapType = new GMapType(layer, G_SATELLITE_MAP.getProjection(), gName, G_SATELLITE_MAP);
return mapType;
}
function createWMSOverlaySpec(gSpec, wmsSpec, gName, gShortName) {
wmsSpec.getTileLayers()[0].getOpacity = function() {
return 1.0;
}
var layers = [gSpec.getTileLayers()[0], wmsSpec.getTileLayers()[0]];
return new GMapType(layers, gSpec.getProjection(), gShortName);
}
var SIG = '<a style="background-color:#555555; font:10px verdana;text-decoration:none;padding:2px;color:yellow;" href="#" onClick="window.open(\'http://www.geotracing.com\'); return false;">GeoTracing Powered</a>';
GMAP.addKey("geosailing",
"ABQIAAAAD3bxjYK2kuWoA5XU4dh89xQn2YD0JRirps1oizQoTMsokgappBTgXt1Fd17zk16JQE0496gzzwLrZQ",
"^https?://.*.geosailing.com/.*" );
GMAP.loadGoogleMapScript('2.132d');
var GW = {
url: '/proto.srv',
timeoutMins : 5,
protocolVersion : '4.0',
userId: null,
agentKey: null,
onNegRsp: null,
webRoot: null,
IS_SAFARI : (navigator.userAgent && navigator.vendor && (navigator.userAgent.toLowerCase().indexOf("applewebkit") != -1 || navigator.vendor.indexOf("Apple") != -1)),
loginReqDoc: null,
recovering: false,
user: null,
pwd: null,
init: function(nrspCallback, theTimeoutMins, theWebRoot) {
if (!document.getElementsByTagName) {
alert('No browser XML support');
return;
}
GW.onNegRsp = nrspCallback;
GW.timeoutMins = theTimeoutMins ? theTimeoutMins : GW.timeoutMins;
if (theWebRoot) {
GW.webRoot = theWebRoot;
} else {
GW.webRoot = GW._getWebRoot();
}
GW.url = GW.webRoot + GW.url;
GW.request(GW.createRequest('ses-create-req'), null);
},
isLoggedIn: function() {
return GW.userId != null;
},
createCallback: function(cbFunOrObj, name) {
if (cbFunOrObj == null) {
return null;
}
var callback;
if (name && cbFunOrObj[name + 'Rsp']) {
callback = new GWCallbackObj(cbFunOrObj, name + 'Rsp', name + 'NegRsp');
} else {
callback = new GWCallbackFun(cbFunOrObj);
}
return callback;
},
createRequest: function(tag) {
var xmlDoc = XmlDocument.create();
var elm = xmlDoc.createElement(tag);
xmlDoc.appendChild(elm);
return xmlDoc;
},
login: function(callback, user, password) {
var doc = GW.createRequest('ses-login-req');
var xml = doc.documentElement;
xml.setAttribute('name', user);
xml.setAttribute('password', password);
xml.setAttribute('agent', "web");
GW.user = user;
GW.pwd = password;
xml.setAttribute('protocolVersion', GW.protocolVersion);
GW.loginReqDoc = doc;
GW.request(doc, GW.createCallback(callback, 'login'));
},
logout: function(callback) {
var doc = GW.createRequest('ses-logout-req');
GW.request(doc, GW.createCallback(callback, 'logout'));
},
selectApp: function() {
alert('selectApp is no longer required, pls remove from your code')
},
request: function(aReqDoc, aCallback) {
if (aCallback == null || !aCallback) {
return GW._send(null, aReqDoc);
} else {
var cb = aCallback;
if (!cb instanceof GWCallbackObj && !cb instanceof GWCallbackFun) {
cb = GW.createCallback(aCallback);
}
GW._send(cb, aReqDoc);
}
},
isPositive: function(element) {
return element.tagName.lastIndexOf('-rsp') != -1;
},
storeSession: function() {
GW._createCookie('agentkey', GW.agentKey, 1);
},
restoreSession: function() {
GW.agentKey = GW._readCookie('agentkey');
},
clearAccount: function() {
GW.user = ' ';
GW.pwd = ' ';
GW._eraseCookie('kwacc');
},
storeAccount: function() {
GW._createCookie('kwacc', GW.user + ',' + GW.pwd, 365);
},
getAccountData: function() {
var data = GW._readCookie('kwacc');
return (data && data != null && data.length > 0) ? data.split(',') : null;
},
_camelizeCmd: function(s) {
if (s.indexOf('-nrsp') > 0) {
s = s.substring(0, s.indexOf('-nrsp')) + '-neg-rsp';
}
return GW._camelize(s.substring(s.indexOf('-') + 1, s.length));
},
_camelize: function(s) {
var parts = s.split('-'), len = parts.length;
if (len == 1) return parts[0];
var camelized = s.charAt(0) == '-'
? parts[0].charAt(0).toUpperCase() + parts[0].substring(1)
: parts[0];
for (var i = 1; i < len; i++)
camelized += parts[i].charAt(0).toUpperCase() + parts[i].substring(1);
return camelized;
},
_getWebRoot: function() {
var webRoot;
var head = document.getElementsByTagName('head')[0];
var nodes = head.childNodes;
for (var i = 0; i < nodes.length; ++i) {
var src = nodes.item(i).src;
if (src) {
var index = src.indexOf("GWClient.js");
if (index < 0) {
index = src.indexOf("all");
}
if (index >= 0) {
if (src.indexOf("lib") >= 0) {
index = src.indexOf("lib");
}
webRoot = src.substring(0, index);
break;
}
}
}
return webRoot;
},
_negativeRsp: function(callback, element) {
var errorId = element.getAttribute('errorId'),
errorStr = element.getAttribute('error'),
details = element.getAttribute('details'), tagName = element.tagName;
try {
callback.doNegRsp(errorId, errorStr, details, tagName);
} catch(ex) {
throw ex;
}
},
_recoverSession: function(callback, reqDoc) {
GW.agentKey = null;
GW.userId = null;
GW.recovering = true;
var onLoginRsp = function(rsp) {
GW.agentKey = rsp.getAttribute('agentkey');
GW.userId = rsp.getAttribute('userid');
GW.recovering = false;
return GW._send(callback, reqDoc);
}
GW._send(GW.createCallback(onLoginRsp), GW.loginReqDoc);
},
_send: function(callback, doc) {
var xmlhttp = new XMLHttpRequest();
var async = false;
if (callback) {
async = true;
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == 4) {
var element = xmlhttp.responseXML.documentElement;
var tagName = element.tagName;
if (GW.isPositive(element)) {
switch (tagName) {
case 'ses-create-rsp':
GW.agentKey = element.getAttribute('agentkey');
break;
case 'ses-login-rsp':
GW.agentKey = element.getAttribute('agentkey');
GW.userId = element.getAttribute('userid');
break;
case 'ses-logout-rsp':
GW.userId = null;
break;
}
try {
callback.doRsp(element);
} catch(ex) {
throw ex;
}
} else if (element.getAttribute('errorId') == '4007') {
if (GW.isLoggedIn()) {
GW._recoverSession(callback, doc);
} else if (GW.recovering) {
setTimeout(function() {
GW._send(callback, doc)
}, 3000);
} else {
GW._negativeRsp(callback, element);
}
} else {
GW._negativeRsp(callback, element);
}
}
}
}
var qs = GW.agentKey == null ? '?gw_timeout=' + GW.timeoutMins : '?agentkey=' + GW.agentKey;
qs += '&gw_t=' + (new Date().getTime());
var method = 'POST';
if (doc.documentElement.childNodes.length == 0) {
method = 'GET';
qs += '&gw_cmd=' + doc.documentElement.nodeName;
var attrs = doc.documentElement.attributes;
var i;
for (i = 0; i < attrs.length; i++) {
qs += '&' + attrs[i].name + '=' + attrs[i].value;
}
}
xmlhttp.open(method, GW.url + qs, async);
if (method == 'POST') {
xmlhttp.setRequestHeader('Content-Type', 'text/xml');
if (this.IS_SAFARI) {
xmlhttp.send(doc);
} else {
xmlhttp.send(doc.xml);
}
} else {
xmlhttp.send(null);
}
if (!callback) {
if (xmlhttp.status != 200) {
alert('Problem retrieving XML data:\n' + xmlhttp.statusText);
return null;
}
var element = xmlhttp.responseXML.documentElement;
if (element.getAttribute('errorId') == '4007') {
if (GW.isLoggedIn()) {
return GW._recoverSession(callback, doc);
} else if (GW.recovering) {
setTimeout(function() {
GW._send(callback, doc)
}, 3000);
return;
}
}
if (GW.isPositive(element)) {
switch (element.tagName) {
case 'ses-create-rsp':
GW.agentKey = element.getAttribute('agentkey');
break;
case 'ses-login-rsp':
GW.agentKey = element.getAttribute('agentkey');
GW.userId = element.getAttribute('userid');
break;
case 'ses-logout-rsp':
GW.userId = null;
break;
}
}
return element;
}
},
_createCookie: function(name, value, days) {
if (days) {
var date = new Date();
date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
var expires = "; expires=" + date.toGMTString();
}
else var expires = "";
document.cookie = name + "=" + value + expires + "; path=/";
},
_readCookie: function(name) {
var nameEQ = name + "=";
var ca = document.cookie.split(';');
for (var i = 0; i < ca.length; i++) {
var c = ca[i];
while (c.charAt(0) == ' ') {
c = c.substring(1, c.length);
}
if (c.indexOf(nameEQ) == 0) {
return c.substring(nameEQ.length, c.length);
}
}
return null;
},
_eraseCookie: function(name) {
GW._createCookie(name, "", -1);
}
}
function GWCallbackObj(obj, rsp, nrsp) {
this.obj = obj;
this.rsp = rsp;
if (!this.obj[this.rsp]) {
alert('He JoeS de functie ' + rsp + ' moet wel bestaan in je object !!');
}
this.nrsp = nrsp;
}
GWCallbackObj.prototype.doRsp = function(element) {
this.obj[this.rsp](element);
}
GWCallbackObj.prototype.doNegRsp = function(errorId, errorStr, details, tagName) {
if (this.obj[this.nrsp]) {
this.obj[this.nrsp](errorId, errorStr, details, tagName);
} else {
GW.onNegRsp(errorId, errorStr, details, tagName);
}
}
function GWCallbackFun(fun) {
this.fun = fun;
}
GWCallbackFun.prototype.doRsp = function(element) {
this.fun(element);
}
GWCallbackFun.prototype.doNegRsp = function(errorId, errorStr, details, tagName) {
GW.onNegRsp(errorId, errorStr, details, tagName);
}
function getDomDocumentPrefix() {
if (getDomDocumentPrefix.prefix)
return getDomDocumentPrefix.prefix;
var prefixes = ["MSXML2", "Microsoft", "MSXML", "MSXML3"];
var o;
for (var i = 0; i < prefixes.length; i++) {
try {
o = new ActiveXObject(prefixes[i] + ".DomDocument");
return getDomDocumentPrefix.prefix = prefixes[i];
}
catch (ex) {
}
;
}
throw new Error("Could not find an installed XML parser");
}
function getXmlHttpPrefix() {
if (getXmlHttpPrefix.prefix)
return getXmlHttpPrefix.prefix;
var prefixes = ["MSXML2", "Microsoft", "MSXML", "MSXML3"];
var o;
for (var i = 0; i < prefixes.length; i++) {
try {
o = new ActiveXObject(prefixes[i] + ".XmlHttp");
return getXmlHttpPrefix.prefix = prefixes[i];
}
catch (ex) {
}
;
}
throw new Error("Could not find an installed XML parser");
}
function XmlDocument() {
}
XmlDocument.create = function () {
try {
if (document.implementation && document.implementation.createDocument) {
var doc = document.implementation.createDocument("", "", null);
if (doc.readyState == null) {
doc.readyState = 1;
doc.addEventListener("load", function () {
doc.readyState = 4;
if (typeof doc.onreadystatechange == "function")
doc.onreadystatechange();
}, false);
}
return doc;
}
if (window.ActiveXObject)
return new ActiveXObject(getDomDocumentPrefix() + ".DomDocument");
}
catch (ex) {
}
throw new Error("Your browser does not support XmlDocument objects");
};
if (window.DOMParser &&
window.XMLSerializer &&
window.Node && Node.prototype && Node.prototype.__defineGetter__) {
Document.prototype.loadXML = function (s) {
var doc2 = (new DOMParser()).parseFromString(s, "text/xml");
while (this.hasChildNodes())
this.removeChild(this.lastChild);
for (var i = 0; i < doc2.childNodes.length; i++) {
this.appendChild(this.importNode(doc2.childNodes[i], true));
}
};
try {
Document.prototype.__defineGetter__("xml", function () {
return (new XMLSerializer()).serializeToString(this);
});
} catch(e) {
}
}
if (window.ActiveXObject && !window.XMLHttpRequest) {
window.XMLHttpRequest = function() {
var msxmls = new Array(
'Msxml2.XMLHTTP.5.0',
'Msxml2.XMLHTTP.4.0',
'Msxml2.XMLHTTP.3.0',
'Msxml2.XMLHTTP',
'Microsoft.XMLHTTP');
for (var i = 0; i < msxmls.length; i++) {
try {
return new ActiveXObject(msxmls[i]);
} catch (e) {
}
}
return null;
};
}
if (!window.ActiveXObject && window.XMLHttpRequest) {
window.ActiveXObject = function(type) {
switch (type.toLowerCase()) {
case 'microsoft.xmlhttp':
case 'msxml2.xmlhttp':
case 'msxml2.xmlhttp.3.0':
case 'msxml2.xmlhttp.4.0':
case 'msxml2.xmlhttp.5.0':
return new XMLHttpRequest();
}
return null;
};
}
function copyChildNodes(nodeFrom, nodeTo) {
if ((!nodeFrom) || (!nodeTo)) {
throw "Both source and destination nodes must be provided";
}
;
var ownerDoc = nodeTo.nodeType == Node.DOCUMENT_NODE ? nodeTo : nodeTo.ownerDocument;
var nodes = nodeFrom.childNodes;
if (ownerDoc.importNode) {
for (var i = 0; i < nodes.length; i++) {
nodeTo.appendChild(ownerDoc.importNode(nodes[i], true));
}
;
} else {
for (var i = 0; i < nodes.length; i++) {
nodeTo.appendChild(nodes[i].cloneNode(true));
}
}
}
GW.CMT = {
add: function(callback, commentObj) {
var req = GW.createRequest('cmt-insert-req');
GW.UTIL.addObject(req, 'comment', commentObj);
GW.request(req, GW.createCallback(callback, 'add'));
},
markRead: function(callback, commentId, targetId) {
var req = GW.createRequest('cmt-update-state-req');
GW.UTIL.setAttr(req, 'state', 2);
GW.UTIL.setOptAttr(req, 'id', commentId);
GW.UTIL.setOptAttr(req, 'target', targetId);
GW.request(req, GW.createCallback(callback, 'markRead'));
},
markReadForTarget: function(callback, targetId) {
GW.CMT.markRead(callback, null, targetId);
},
markReadForComment: function(callback, commentId) {
GW.CMT.markRead(callback, commentId, null);
},
del: function(callback, commentId) {
var req = GW.createRequest('cmt-delete-req');
GW.UTIL.setAttr(req, 'id', commentId);
GW.request(req, GW.createCallback(callback, 'del'));
},
delForTarget: function(callback, targetId) {
var req = GW.createRequest('cmt-delete-for-target-req');
GW.UTIL.setAttr(req, 'targetid', targetId);
GW.request(req, GW.createCallback(callback, 'delForTarget'));
}
}
GW.EVENT = {
FETCH_INTERVAL_MILLIS: 8000,
listener: null,
send: function(callback, topic, argObj) {
var req = GW.createRequest('event-send-req');
GW.UTIL.setAttr(req, 'topic', topic);
if (argObj) {
GW.UTIL.setAttrs(req, argObj);
}
GW.request(req, GW.createCallback(callback, 'send'));
},
subscribe: function(callback, topics) {
var req = GW.createRequest('event-subscribe-req');
GW.UTIL.setAttr(req, 'topics', topics);
GW.request(req, GW.createCallback(callback, 'subscribe'));
},
start: function(callback, aListener) {
GW.EVENT.listener = aListener;
var startRsp = function(xmlElm) {
GW.EVENT._fetchReq();
if (callback != null) {
GW.createCallback(callback, 'start').doRsp(xmlElm);
}
}
GW.request(GW.createRequest('event-start-req'), GW.createCallback(startRsp));
},
stop: function(callback) {
GW.EVENT.listener = null;
GW.request(GW.createRequest('event-stop-req'), GW.createCallback(callback, 'stop'));
},
unsubscribe: function(callback, topics) {
var req = GW.createRequest('event-unsubscribe-req');
if (topics) {
GW.UTIL.setAttr(req, 'topics', topics);
}
GW.request(req, GW.createCallback(callback, 'unsubscribe'));
},
_fetchReq: function() {
GW.request(GW.createRequest('event-fetch-req'), GW.createCallback(GW.EVENT, '_fetch'));
},
_fetchRsp: function(xmlElm) {
if (GW.EVENT.listener == null) {
return;
}
try {
var indicationElms = xmlElm.childNodes;
for (var i = 0; i < indicationElms.length; i++) {
GW.EVENT.listener.onIndication(indicationElms[i]);
}
} catch (e) {
throw e;
}
setTimeout(GW.EVENT._fetchReq, GW.EVENT.FETCH_INTERVAL_MILLIS);
},
_fetchNegRsp: function(errorId, errorStr, details, tagName) {
if (GW.EVENT.listener == null) {
return;
}
setTimeout(GW.EVENT._fetchReq, GW.EVENT.FETCH_INTERVAL_MILLIS);
}
}
GW.MEDIA = {
iframeCnt: 0,
callback: null,
getBaseURL: function() {
return GW.webRoot + '/media.srv';
},
addRef: function(callback, argObj) {
var req = GW.createRequest('medium-insert-req');
if (argObj.userid == -1) {
argObj.userId = undefined;
}
GW.UTIL.addObject(req, 'medium', argObj);
GW.request(req, GW.createCallback(callback, 'addRef'));
},
upload: function(callback, form) {
var rsp = document.createElement('input');
rsp.name = 'rsp';
rsp.type = 'hidden';
rsp.value = 'jsonjs';
form.appendChild(rsp);
var agentkey = document.createElement('input');
agentkey.name = 'agentkey';
agentkey.type = 'hidden';
agentkey.value = GW.agentKey;
form.appendChild(agentkey);
var iframeId = 'kwrspframe' + GW.MEDIA.iframeCnt;
form.target = iframeId;
if (!form.name.value) {
form.name.value = 'unnamed';
}
GW.MEDIA._createRspIFrame(iframeId);
form.submit();
GW.MEDIA.callback = callback;
GW.MEDIA.iframeCnt++;
return false;
},
del: function(callback, id) {
var req = GW.createRequest('medium-delete-req');
GW.UTIL.setAttr(req, 'id', id);
GW.request(req, GW.createCallback(callback, 'del'));
},
update: function(callback, id, name, desc) {
var req = GW.createRequest('medium-update-req');
GW.UTIL.setAttr(req, 'id', id);
var elm = req.createElement('medium');
GW.UTIL.addOptTextElement(elm, 'name', name);
GW.UTIL.addOptTextElement(elm, 'description', desc);
req.documentElement.appendChild(elm);
GW.request(req, GW.createCallback(callback, 'update'));
},
_serverRsp: function(jsonRsp) {
if (GW.MEDIA.callback != null) {
GW.MEDIA.callback(jsonRsp);
GW.MEDIA.callback = null;
}
},
_checkRspIFrame: function(callback, iframeId) {
var iframe = window.frames[iframeId];
if (!iframe) {
iframe = DH.getObject(iframeId);
if (!iframe) {
alert('cannot get rspFrame: ' + iframeId);
return;
}
}
var iframeDoc;
if (iframe.contentDocument) {
iframeDoc = iframe.contentDocument;
} else if (iframe.contentWindow) {
iframeDoc = iframe.contentWindow.document;
} else if (iframe.document) {
iframeDoc = iframe.document;
}
if (iframeDoc && iframeDoc.documentElement && iframeDoc.documentElement.tagName.indexOf('rsp') != -1) {
callback(iframeDoc.documentElement);
} else {
var f = function() {
GW.MEDIA._checkRspIFrame(callback, iframeId);
}
if (iframeDoc && iframeDoc.documentElement && iframeDoc.documentElement.innerHTML.indexOf('rsp') != -1) {
var id = iframeDoc.body.getElementsByTagName('B')[0].innerHTML;
var rsp = GW.createRequest('medium-insert-rsp');
rsp.documentElement.setAttribute('id', id);
callback(rsp.documentElement);
return;
}
setTimeout(f, 50);
}
},
_createRspIFrame: function(iframeId) {
var iframeDiv = document.createElement('DIV');
iframeDiv.style.visibility = 'hidden';
iframeDiv.style.position = 'absolute';
iframeDiv.style.top = '0px';
iframeDiv.style.left = '0px';
iframeDiv.style.width = '0px';
iframeDiv.style.height = '0px';
iframeDiv.innerHTML = '<iframe id="' + iframeId + '"  name="' + iframeId + '" style="width: 0px; height: 0px; border: 0px;"><\/iframe>';
document.body.appendChild(iframeDiv);
return true;
}
}
GW.TAG = {
add: function(callback, itemIds, tags) {
var req = GW.createRequest('tagging-tag-req');
GW.UTIL.setAttr(req, 'items', itemIds);
GW.UTIL.setAttr(req, 'tags', tags);
GW.UTIL.setAttr(req, 'mode', 'add');
GW.request(req, GW.createCallback(callback, 'add'));
},
replace: function(callback, itemIds, tags) {
var req = GW.createRequest('tagging-tag-req');
GW.UTIL.setAttr(req, 'items', itemIds);
GW.UTIL.setAttr(req, 'tags', tags);
GW.UTIL.setAttr(req, 'mode', 'replace');
GW.request(req, GW.createCallback(callback, 'replace'));
},
remove: function(callback, itemIds, tags) {
var req = GW.createRequest('tagging-untag-req');
GW.UTIL.setAttr(req, 'items', itemIds);
GW.UTIL.setAttr(req, 'tags', tags);
GW.request(req, GW.createCallback(callback, 'remove'));
}
}
GW.TRACE = {
addMediumToTrace: function(callback, mediumId, userId) {
var req = GW.createRequest('trace-add-medium-req');
GW.UTIL.setAttr(req, 'id', mediumId);
GW.UTIL.setOptAttr(req, 'userid', userId);
GW.request(req, GW.createCallback(callback, 'addMediumToTrace'));
},
create: function(callback, name) {
var req = GW.createRequest('trace-create-req');
GW.UTIL.setOptAttr(req, 'name', name);
GW.request(req, GW.createCallback(callback, 'create'));
},
get: function(callback, id, argObj) {
var req = GW.createRequest('trace-export-req');
GW.UTIL.setAttr(req, 'id', id);
if (argObj) {
GW.UTIL.setAttrs(req, argObj);
}
GW.request(req, GW.createCallback(callback, 'get'));
},
write: function(callback, lon, lat, time, ele) {
var req = GW.createRequest('trace-write-req');
var pt = req.createElement('pt');
GW.UTIL.setAttr(pt, 'lon', lon);
GW.UTIL.setAttr(pt, 'lat', lat);
GW.UTIL.setOptAttr(pt, 't', time);
GW.UTIL.setOptAttr(pt, 'ele', ele);
req.documentElement.appendChild(pt);
GW.request(req, GW.createCallback(callback, 'write'));
},
suspend: function(callback, id) {
var req = GW.createRequest('trace-suspend-req');
GW.UTIL.setOptAttr(req, 'id', id);
GW.request(req, GW.createCallback(callback, 'suspend'));
},
resume: function(callback, id) {
var req = GW.createRequest('trace-resume-req');
GW.UTIL.setOptAttr(req, 'id', id);
GW.request(req, GW.createCallback(callback, 'resume'));
},
del: function(callback, id) {
var req = GW.createRequest('trace-delete-req');
GW.UTIL.setAttr(req, 'id', id);
GW.request(req, GW.createCallback(callback, 'del'));
}
}
GW.QUERY = {
queryStore: function(aCmd, aCallback, theOtherArgs) {
var req = GW.createRequest('query-store-req');
var argv = GW.QUERY.queryStore.arguments;
var argc = arguments.length;
if (argc < 2) {
alert('get command must have at least 2 argv (cmd+callback)');
return;
}
GW.UTIL.setAttr(req, 'cmd', aCmd);
if (typeof theOtherArgs == 'object') {
for (var field in theOtherArgs) {
GW.UTIL.setAttr(req, field, theOtherArgs[field]);
}
} else {
for (var i = 2; i < argc; i++) {
GW.UTIL.setAttr(req, argv[i], argv[++i]);
}
}
if (aCallback != null) {
var qr = new GW.QUERY._queryRspHandler(aCallback);
GW.request(req, GW.createCallback(qr.onQueryRsp));
} else {
return GW.QUERY._rsp2XMLRecords(GW.request(req));
}
},
_rsp2XMLRecords: function(xmlElm) {
var records = [];
if (!xmlElm) {
return records;
}
var recordElements = xmlElm.getElementsByTagName('record');
for (var i = 0; i < recordElements.length; i++) {
records.push(new XMLRecord(recordElements[i]));
}
return records;
},
_queryRspHandler: function(cb) {
this.onQueryRsp = function(rsp) {
GW.createCallback(cb, 'queryStore').doRsp(GW.QUERY._rsp2XMLRecords(rsp));
}
}
}
GW.USER = {
create: function(callback, name, password, email, fullname, role) {
var req = GW.createRequest('user-create-req');
GW.UTIL.setAttr(req, 'name', name);
GW.UTIL.setAttr(req, 'password', password);
GW.UTIL.setAttr(req, 'email', email);
GW.UTIL.setAttr(req, 'fullname', fullname);
GW.UTIL.setOptAttr(req, 'role', role);
GW.request(req, GW.createCallback(callback, 'create'));
},
getProfile: function(callback) {
var req = GW.createRequest('user-get-profile-req');
return GW.request(req, GW.createCallback(callback, 'getProfile'));
},
update: function(callback, id, name, password, email) {
var req = GW.createRequest('user-update-req');
GW.UTIL.setAttr(req, 'id', id);
GW.UTIL.setOptAttr(req, 'name', name);
GW.UTIL.setOptAttr(req, 'password', password);
GW.UTIL.setOptAttr(req, 'email', email);
GW.request(req, GW.createCallback(callback, 'update'));
},
updateProfile: function(callback, profileObj) {
var req = GW.createRequest('user-update-profile-req');
GW.UTIL.addObject(req, 'profile', profileObj);
return GW.request(req, GW.createCallback(callback, 'updateProfile'));
},
del: function(callback, id) {
var req = GW.createRequest('user-delete-req');
GW.UTIL.setAttr(req, 'id', id);
GW.request(req, GW.createCallback(callback, 'del'));
}
}
GW.UTIL = {
escape : function(s) {
return s.replace(/&/g, "&amp;")
.replace(/</g, "&lt;")
.replace(/>/g, "&gt;")
.replace(/"/g, "&quot;")
.replace(/'/g, "&apos;");
},
expandQueryString: function(qs, name, value) {
if (value && value != null) {
qs += ('&' + name + '=' + value);
}
return qs;
},
addArray: function(parent, name, arr) {
var doc = parent.ownerDocument;
if (parent.nodeName == '#document') {
doc = parent;
parent = doc.documentElement;
}
var arrElm = doc.createElement(name);
var elmName = name.substring(0, name.indexOf('list'));
for (var i = 0; i < arr.length; i++) {
if (arr[i]) {
if (typeof arr[i] == 'object') {
GW.UTIL.addObject(arrElm, elmName, arr[i]);
} else {
GW.UTIL.addTextElement(arrElm, elmName, arr[i]);
}
}
}
parent.appendChild(arrElm);
return arrElm;
},
addOptArray: function(parent, name, arr) {
if (arr && arr != null) {
return GW.UTIL.addArray(parent, name, arr);
}
},
addObject: function(parent, name, obj) {
var doc = parent.ownerDocument;
if (parent.nodeName == '#document') {
doc = parent;
parent = doc.documentElement;
}
var elm = doc.createElement(name);
var field, value, type;
for (field in obj) {
value = obj[field];
type = typeof value;
if (type == 'object' && value && value.constructor == (new Array).constructor) {
type = 'array';
}
if (value == undefined || value == null) {
GW.UTIL.addTextElement(elm, field, null);
continue;
}
switch (type) {
case 'object' :
GW.UTIL.addObject(elm, field, value);
break;
case 'array' :
GW.UTIL.addArray(elm, field, value);
break;
case 'boolean' :
GW.UTIL.addTextElement(elm, field, value ? 'true' : 'false');
break;
case 'number' :
case 'string' :
if (field == 'id' || (field == 'name' && parent.nodeName == 'mediumlist')) {
GW.UTIL.setAttr(elm, field, value);
} else {
GW.UTIL.addTextElement(elm, field, value);
}
break;
default:
break;
}
}
parent.appendChild(elm);
return elm;
},
addOptObject: function(parent, name, obj) {
if (obj && obj != null) {
return GW.UTIL.addObject(parent, name, obj);
}
},
addElement: function(parent, name) {
var doc = parent.ownerDocument;
if (parent.nodeName == '#document') {
doc = parent;
parent = doc.documentElement;
}
var elm = doc.createElement(name);
parent.appendChild(elm);
return elm;
},
addTextElement: function(parent, name, text) {
var elm = GW.UTIL.addElement(parent, name);
if (text != undefined && text != null) {
var doc = parent.ownerDocument;
if (parent.nodeName == '#document') {
doc = parent;
}
var textNode = doc.createTextNode(text);
elm.appendChild(textNode);
}
return elm;
},
addOptTextElement: function(parent, name, text) {
if (text != undefined && text != null) {
return GW.UTIL.addTextElement(parent, name, text);
}
},
addTextElements: function(node, obj) {
var name;
for (name in obj) {
GW.UTIL.addOptTextElement(node, name, obj[name]);
}
},
setAttrs: function(node, obj) {
var name;
for (name in obj) {
GW.UTIL.setOptAttr(node, name, obj[name]);
}
},
setAttr: function(node, name, value) {
if (node.nodeName == '#document') {
node = node.documentElement;
}
if (value == undefined || value == null) {
alert('error: no value passed for attr ' + name);
return;
}
node.setAttribute(name, value);
},
setOptAttr: function(node, name, value) {
if (value != undefined && value != null) {
GW.UTIL.setAttr(node, name, value);
}
}
}
function Record(anObj) {
this.getField = function(name) {
return null;
}
this.toHTML = function() {
return null;
}
}
function ObjRecord(anObj) {
Record.apply(this);
this.rec = anObj;
this.getField = function(name) {
return this.rec[name];
}
this.toHTML = function() {
var html = '<pre>';
var fieldCount = fields.length;
var nextField;
for (j  in this.recs) {
nextField = fields[j];
html += j + '=' + this.rec[j];
html += '\n';
}
html += '\n</pre>';
return html;
}
}
function XMLRecord(xmlElement) {
Record.apply(this);
this.xml = xmlElement;
this.id = -1;
if (this.xml.attributes && this.xml.getAttribute("id")) {
this.id = this.xml.getAttribute("id");
} else  if (this.getField("id") != null) {
this.id = this.getField("id");
}
this.getField = function(name) {
if (name == 'id' && this.id > 0) {
return this.id;
}
var field = this.getXMLField(name);
if (field != null && field.childNodes.length > 0) {
return field.childNodes[0].nodeValue;
} else {
return null;
}
}
this.getXMLField = function(name) {
var list = this.xml.getElementsByTagName(name);
if (list && list.length > 0) {
return list[0];
} else {
return null;
}
}
this.toHTML = function() {
var html = '<pre>';
var xml = this.xml;
html += (xml.tagName + ' id=' + this.id + '\n');
var fields = xml.childNodes;
var fieldCount = fields.length;
var nextField;
for (j = 0; j < fieldCount; j++) {
nextField = fields[j];
html += (nextField.tagName + '=');
if (nextField.childNodes[0]) {
html += nextField.childNodes[0].nodeValue;
}
html += '\n';
}
html += '\n</pre>';
return html;
}
}
var CMT = {
commentPanel: null,
currentTarget: '0',
panelOpen: false,
commentList: 'empty',
addComment: function() {
var cmtForm = DH.getObject('commentform');
var commentObj = {target: CMT.currentTarget,
content: cmtForm.content.value,
author: cmtForm.name.value,
url: cmtForm.url.value,
email: cmtForm.email.value};
GW.CMT.add(CMT.addCommentRsp, commentObj);
return false;
},
addCommentRsp: function(aRspDoc) {
CMT.hideAddCommentForm();
if (aRspDoc != null) {
} else {
alert('NULL response');
}
CMT.displayComments();
},
displayComments: function() {
var cmtList = DH.getObject('commentlist');
if (cmtList) {
cmtList.innerHTML = 'loading comments...';
}
GW.QUERY.queryStore('q-by-example', CMT.displayCommentsRsp, {table: 'gw_comment', target: CMT.currentTarget});
},
displayCommentsRsp: function(records) {
var html = records.length + ' comments for ' + CMT.currentType + ' "' + CMT.currentName + '"<br/>';
var date;
var url;
for (var i = 0; i < records.length; i++) {
html += '<hr>'
html = html + '<p>From: ' + records[i].getField('author') + '<br/>';
time = new Number(records[i].getField('creationdate'));
date = new Date(time);
html = html + 'Date: ' + date.format("DDD D MMM YYYY HH:mm:ss") + '<br/>';
url = records[i].getField('url');
if (url != null) {
html = html + 'Website: <a href="' + url + '" target="_new">' + url + '</a></p>';
}
html = html + '<p><i>' + records[i].getField('content') + '</i></p>';
}
CMT.commentList = html;
CMT._waitForPanelLoaded();
},
isCommentPanelOpen: function() {
return CMT.panelOpen;
},
onPanelClose: function() {
CMT.panelOpen = false;
},
showCommentPanel: function(aTargetId, aTargetType, aTargetName) {
if (CMT.commentPanel == null) {
CMT.commentPanel = new Panel('commentpanel', '#000044', 'white', null, CMT.onPanelClose);
CMT.commentPanel.setDimension(500, 500);
CMT.commentPanel.setXY(50, 50);
}
CMT.currentTarget = aTargetId + '';
CMT.currentType = aTargetType;
CMT.currentName = aTargetName;
CMT.commentPanel.show();
CMT.commentPanel.loadContent('content/comment.html');
CMT.commentPanel.setTitle('Comments for ' + CMT.currentType + '[' + CMT.currentTarget + ']' );
CMT.displayComments();
CMT.panelOpen = true;
return false;
},
hideAddCommentForm: function() {
DH.getStyleObject('commentform').display = 'none';
DH.show('addcommentlink');
},
showAddCommentForm: function() {
DH.getStyleObject('commentform').display = 'block';
DH.hide('addcommentlink');
},
_waitForPanelLoaded: function(html) {
var cmtList = DH.getObject('commentlist');
if (cmtList) {
cmtList.innerHTML = CMT.commentList;
} else {
setTimeout("CMT._waitForPanelLoaded()", 75);
}
}
}
Date.MONTHS = [
'January', 'February', 'March', 'April', 'May', 'June', 'July',
'August', 'September', 'October', 'November', 'December'
];
Date.DAYS = [
'Sunday', 'Monday', 'Tuesday', 'Wednesday',
'Thursday', 'Friday', 'Saturday'
];
Date.SUFFIXES = [
'st','nd','rd','th','th','th','th','th','th','th',
'th','th','th','th','th','th','th','th','th','th',
'st','nd','rd','th','th','th','th','th','th','th',
'st'
];
Date.prototype.format = function(mask) {
var formatted = ( mask != null ) ? mask : 'DD-MMM-YY';
var letters = 'DMYHdhmst'.split('');
var temp = new Array();
var count = 0;
var regexA;
var regexB = /\[(\d+)\]/;
var day = this.getDay();
var date = this.getDate();
var month = this.getMonth();
var year = this.getFullYear().toString();
var hours = this.getHours();
var minutes = this.getMinutes();
var seconds = this.getSeconds();
var formats = new Object();
formats[ 'D' ] = date;
formats[ 'd' ] = date + Date.SUFFIXES[ date - 1 ];
formats[ 'DD' ] = ( date < 10 ) ? '0' + date : date;
formats[ 'DDD' ] = Date.DAYS[ day ].substring(0, 3);
formats[ 'DDDD' ] = Date.DAYS[ day ];
formats[ 'M' ] = month + 1;
formats[ 'MM' ] = ( month + 1 < 10 ) ? '0' + ( month + 1 ) : month + 1;
formats[ 'MMM' ] = Date.MONTHS[ month ].substring(0, 3);
formats[ 'MMMM' ] = Date.MONTHS[ month ];
formats[ 'Y' ] = ( year.charAt(2) == '0' ) ? year.charAt(3) : year.substring(2, 4);
formats[ 'YY' ] = year.substring(2, 4);
formats[ 'YYYY' ] = year;
formats[ 'H' ] = hours;
formats[ 'HH' ] = ( hours < 10 ) ? '0' + hours : hours;
formats[ 'h' ] = ( hours > 12 || hours == 0 ) ? Math.abs(hours - 12) : hours;
formats[ 'hh' ] = ( formats[ 'h' ] < 10 ) ? '0' + formats[ 'h' ] : formats[ 'h' ];
formats[ 'm' ] = minutes;
formats[ 'mm' ] = ( minutes < 10 ) ? '0' + minutes : minutes;
formats[ 's' ] = seconds;
formats[ 'ss' ] = ( seconds < 10 ) ? '0' + seconds : seconds;
formats[ 't' ] = ( hours < 12 ) ?  'A' : 'P';
formats[ 'tt' ] = ( hours < 12 ) ?  'AM' : 'PM';
for (var i = 0; i < letters.length; i++) {
regexA = new RegExp('(' + letters[ i ] + '+)');
while (regexA.test(formatted)) {
temp[ count ] = RegExp.$1;
formatted = formatted.replace(RegExp.$1, '[' + count + ']');
count++;
}
}
while (regexB.test(formatted)) {
formatted = formatted.replace(regexB, formats[ temp[ RegExp.$1 ] ]);
}
return formatted;
}
var FEAT = {
current: null
}
function Feature(theId, name, desc, type, time, lon, lat) {
this.id = theId;
this.name = name;
this.type = type;
this.desc = desc;
if (!this.desc || this.desc == null || this.desc == 'null') {
this.desc = 'no description';
}
this.time = new Number(time);
this.tlabel = null;
this.iconId = 'featicon' + this.id;
this.previewId = 'feat' + this.id;
this.previewTileId = 'featurepreview';
this.bgColor = GTW.FEATURE_BG_COLOR;
this.fgColor = GTW.FEATURE_FG_COLOR;
if (lon && lat) {
this.gLatLng = new GLatLng(lat, lon);
}
this.userName = null;
this.record = null;
this.blink = function(cnt) {
DH.blink(this.iconId, cnt, 150);
}
this.blowUp = function(cnt) {
GMAP.map.showMapBlowup(this.getGLatLng());
}
this.display = function() {
FEAT.current = this;
if (this.record != null && this.record != -1) {
this._display();
return;
}
this._queryInfo();
}
this.getBGColor = function() {
return this.bgColor;
}
this.getDate = function() {
var date = new Date(this.time);
return date.format("DDD D MMM YYYY HH:mm:ss");
}
this.getGLatLng = function() {
return this.gLatLng;
}
this.getTitle = function() {
return this.name;
}
this.getPreviewTile = function() {
return DH.getObject(this.previewTileId);
}
this.remove = function() {
if (this.tlabel == null) {
return;
}
GMAP.map.removeTLabel(this.tlabel);
this.tlabel = null;
}
this.show = function() {
if (this.getGLatLng() == null) {
return;
}
var tl = new TLabel(true);
tl.id = 'tlab' + this.id;
tl.anchorLatLng = this.getGLatLng();
tl.anchorPoint = 'center';
tl.content = this.getIconDiv();
tl.setScaling(this.iconId, 16, 16, .2);
GMAP.map.addTLabel(tl);
this.tlabel = tl;
var self = this;
this.onMouseOverIcon = function (e) {
self.display();
DH.cancelEvent(e);
}
DH.addEvent(DH.getObject(this.iconId), 'mouseover', this.onMouseOverIcon, false);
}
this._display = function() {
if (FEAT.current != this && this.record != null && this.record != -1) {
return;
}
this._displayTitle();
this._displayInfo();
this._displayPreview();
this._displayDescr();
this._displayUser();
}
this._displayTitle = function() {
DH.setHTML('featuretitle', this.getTitle());
}
this._displayUser = function() {
this.userName = this.record.getField('user');
if (this.userName != null) {
DH.setHTML('tracerinfo', this.userName);
var tracer = GTW.getTracer(this.userName);
if (!tracer || tracer == null) {
tracer = GTW.createTracer(this.userName);
}
tracer.showInfo();
}
}
this._displayInfo = function() {
DH.setHTML('featureinfo', this.getDate() + ' <span class="cmtlink"><a href="#" onclick="CMT.showCommentPanel(' + this.id + ',\'' + this.type + '\',\'' + this.name + '\')" >comments (' + this.record.getField('comments') + ')</a></span>');
if (CMT.isCommentPanelOpen() == true) {
}
}
this._displayDescr = function() {
DH.setHTML('featuredesc', this.desc);
}
this._queryInfo = function() {
if (this.record == -1) {
return;
}
var self = this;
this.onGetRecord = function(result) {
self.record = -1;
if (result != null && result.length > 0) {
self.record = result[0];
}
self._display();
}
this.record = -1;
GW.QUERY.queryStore("q-medium-info", this.onGetRecord, {id: this.id});
}
}
function FeatureSet() {
this.features = [];
this.index = 0;
this.getFeature = function(index) {
if (this.features.length == 0 || index < 0 || index >= this.features.length) {
return null;
}
return this.features[index];
}
this.getFeatureById = function(id) {
for (var i = 0; i < this.features.length; i++) {
if (this.features[i].id == id) {
return this.features[i];
}
}
return undefined;
}
this.addMedia = function(records) {
for (var i = 0; i < records.length; i++) {
this.addMedium(records[i]);
}
}
this.addMedium = function(record) {
var medium = GTW.createMediumByRecord(record);
this.addFeature(medium);
}
this.addFeature = function(feature) {
this.features[this.features.length] = feature;
}
this.clear = function () {
for (var i = 0; i < this.features.length; i++) {
if (this.features[i]) {
this.features[i].remove();
}
}
}
this.dispose = function () {
for (var i = 0; i < this.features.length; i++) {
if (this.features[i]) {
this.features[i].remove();
delete this.features[i];
}
}
this.features = [];
}
this.getCurrent = function () {
return this.features[this.index];
}
this.show = function () {
for (var i = 0; i < this.features.length; i++) {
if (this.features[i]) {
this.features[i].show();
}
}
}
this.displayFirst = function(centerMap) {
this.index = 0;
return this._displayFeature(this.features[this.index], centerMap);
}
this.displayLast = function (centerMap) {
this.index = this.features.length - 1;
return this._displayFeature(this.features[this.index], centerMap);
}
this.displayNext = function (centerMap) {
if (++this.index >= this.features.length) {
this.index = 0;
}
return this._displayFeature(this.features[this.index], centerMap);
}
this.displayPrev = function (centerMap) {
if (--this.index <= 0) {
this.index = this.features.length - 1;
}
return this._displayFeature(this.features[this.index], centerMap);
}
this._displayFeature = function(feature, centerMap) {
if (feature) {
var blinks = 12;
if (centerMap && centerMap == true) {
GMAP.map.panTo(feature.getGLatLng());
blinks = 20;
}
feature.display();
feature.blink(blinks);
return feature;
}
}
}
function FeaturePlayer() {
this.featureSet = new FeatureSet();
this.controls = DH.getObject('featurecontrols');
var self = this;
this.onFirst = function(e) {
DH.cancelEvent(e);
self.featureSet.displayFirst(false);
}
this.onPrev = function(e) {
DH.cancelEvent(e);
self.featureSet.displayPrev(false);
}
this.onNext = function(e) {
DH.cancelEvent(e);
self.featureSet.displayNext(false);
}
this.onLast = function(e) {
DH.cancelEvent(e);
self.featureSet.displayLast(false);
}
DH.addEvent('featfirst', 'click', self.onFirst, false);
DH.addEvent('featprev', 'click', self.onPrev, false);
DH.addEvent('featnext', 'click', self.onNext, false);
DH.addEvent('featlast', 'click', self.onLast, false);
this.setFeatureSet = function (fc) {
this.featureSet = fc;
}
this.show = function() {
DH.show(this.controls);
}
this.hide = function() {
DH.hide(this.controls)
}
}
function Factory(theClassDefs) {
this.classDefs = [];
if (theClassDefs) {
this.classDefs = theClassDefs;
}
this.create = function(aName) {
var className = this.classDefs[aName];
if (!className) {
alert('cannot find real class name for ' + aName);
return null;
}
var obj = null;
if (arguments.length > 1) {
var argv = [];
var argStr = ' ';
for (var i = 1; i < arguments.length; i++) {
argv[i-1] = arguments[i];
argStr += 'argv[' + (i-1) + ']';
if (i < arguments.length - 1) {
argStr += ', ';
}
}
obj = eval('new ' + className + '(' + argStr + ')');
} else {
obj = eval('new ' + className + '()');
}
return obj;
}
this.getClassDef = function(aName) {
return this.classDefs[aName];
}
this.setClassDef = function(aName, aClassName) {
this.classDefs[aName] = aClassName;
}
}
var GTW = {
TRACE_COLOR: '#ff9900',
TRACER_ICON_URL: 'media/blueball.gif',
FEATURE_BG_COLOR: '#ff0000',
FEATURE_FG_COLOR: '#ffffff',
tracers: [],
followTracer: null,
featureSet:null,
tracePlayer: null,
featurePlayer: null,
traceAutoPlayer: null,
imageFullPanel: null,
polyLineWidth: 3,
polyLineOpacity: 0.80,
minTracePtDist: 12,
maxTracePt: 1000,
factory: null,
boot: function() {
GTW.factory = new Factory();
GTW.factory.setClassDef('Tracer', 'Tracer');
GTW.factory.setClassDef('Medium', 'Medium');
},
getFactory: function() {
return GTW.factory;
},
init: function() {
GTW.featureSet = new FeatureSet();
GTW.clearPanels();
},
clearFeatures: function() {
GTW.featureSet.dispose();
},
clearMap: function() {
GTW.clearTracers();
GTW.clearFeatures();
GTW.stopAutoPlay();
GTW.clearPanels();
},
clearFeaturePlayer: function() {
if (GTW.featurePlayer != null) {
GTW.featurePlayer.hide();
}
},
clearPanels: function() {
GTW.clearFeaturePlayer();
GTW.clearTracePlayer();
DH.setHTML('tracerinfo', ' ');
DH.setHTML('traceinfo', ' ');
DH.setHTML('traceview', 'trace info');
DH.setHTML('featuretitle', ' ');
DH.setHTML('featureinfo', ' ');
DH.setHTML('featurepreview', 'feature preview');
DH.setHTML('featuredesc', 'feature description (if avail)');
},
clearTracePlayer: function() {
if (GTW.tracePlayer != null) {
GTW.tracePlayer.hide();
}
},
clearTracers: function() {
var tracerName;
for (tracerName in GTW.tracers) {
var t = GTW.getTracer(tracerName);
t.clear();
t.hide();
}
},
createMedium: function(id, name, desc, type, mime, time, lon, lat) {
var medium = GTW.factory.create('Medium', id, name, desc, type, mime, time, lon, lat);
return medium;
},
createMediumByRecord: function(record) {
var medium = GTW.createMedium(record.getField('id'),
record.getField('name'),
record.getField('description'),
record.getField('kind'),
record.getField('mime'),
record.getField('creationdate'),
record.getField('lon'),
record.getField('lat'));
if (record.getField('user') != null) {
medium.userName = record.getField('user');
}
if (record.getField('owner') != null) {
medium.userId = record.getField('owner');
}
return medium;
},
createTracer: function(name, lon, lat, time) {
var tracer = GTW.getTracer(name);
if (tracer) {
if (lon && lat) {
tracer.setLocation(new GLatLng(lat, lon), time);
}
return tracer;
}
var point;
if (lon && lat) {
point = new GLatLng(lat, lon);
}
tracer = GTW.factory.create('Tracer', name, GTW.TRACE_COLOR, GTW.TRACER_ICON_URL, point, time);
tracer.init();
GTW.tracers[name] = tracer;
return tracer;
},
createTracerByRecord: function(record) {
var userName = record.getField('user');
if (userName == null) {
userName = record.getField('name');
}
var tracer = GTW.createTracer(userName,
record.getField('lon'), record.getField('lat'), record.getField('time'));
tracer.id = record.id;
if (record.getField('color') != null) {
tracer.color = record.getField('color');
}
return tracer;
},
displayMedia: function(records) {
GTW.featureSet.dispose();
GTW.featureSet.addMedia(records);
GTW.featureSet.show();
GTW.getFeaturePlayer().setFeatureSet(GTW.featureSet);
GTW.getFeaturePlayer().show()
GTW.featureSet.displayFirst();
},
displayTracePlayer: function() {
GTW.getTracePlayer().show();
},
formatDate: function(time) {
var date = new Date(time);
return date.format("DD-MM-YY");
},
formatTime: function(time) {
var date = new Date(time);
return date.format("HH:mm:ss");
},
formatDateAndTime: function(time) {
try {
var date = new Date(time);
return date.format("DD-MM-YY HH:mm:ss");
} catch(e) {
return 'date format error: t=' + time + ' e=' + e;
}
},
getImageFullPanel: function() {
if (GTW.imageFullPanel == null) {
GTW.imageFullPanel = new Panel('imagefullpanel', 'red', 'white');
GTW.imageFullPanel.setDimension(640, 510);
GTW.imageFullPanel.setXY(50, 50);
}
GTW.imageFullPanel.show();
return GTW.imageFullPanel;
},
getTracer: function(name) {
return GTW.tracers[name];
},
getTracePlayer: function() {
if (GTW.tracePlayer == null) {
GTW.tracePlayer = new TracePlayer();
}
return GTW.tracePlayer;
},
getFeaturePlayer: function() {
if (GTW.featurePlayer == null) {
GTW.featurePlayer = new FeaturePlayer();
}
return GTW.featurePlayer;
},
getTracers: function() {
return GTW.tracers;
},
startAutoPlay: function() {
GTW.stopAutoPlay();
GTW.traceAutoPlayer = new TraceAutoPlayer();
GTW.traceAutoPlayer.start();
},
stopAutoPlay: function() {
if (GTW.traceAutoPlayer != null) {
GTW.traceAutoPlayer.stop();
GTW.traceAutoPlayer = null;
}
},
showStatus: function(msg) {
DH.setHTML('status', msg);
}
}
function LiveListener(aStatusElm) {
this.statusElm = DH.getObject(aStatusElm);
this.clearStatus = function() {
DH.setHTML(this.statusElm, '&nbsp;');
}
this.showStatus = function(aTracer, aMsg) {
DH.setHTML(this.statusElm, aTracer.name + ' ' + aMsg);
DH.blink(this.statusElm, 4, 150);
}
this.onCommentAdd = function(event) {
}
this.onMove = function(tracer, event) {
tracer.setLive();
if (tracer.activeTrace == null) {
tracer.newTrace(event.getAttribute('traceid'), event.getAttribute('tracename'));
tracer.show();
}
tracer.move(event.getAttribute('lon'), event.getAttribute('lat'), event.getAttribute('t'));
this.showStatus(tracer, 'moves');
}
this.onHeartbeat = function(tracer, event) {
this.showStatus(tracer, 'sends heartbeat');
}
this.onMediumAdd = function(tracer, event) {
var medium = GTW.createMedium(event.getAttribute('id'),
event.getAttribute('name'),
'live upload by ' + tracer.name,
event.getAttribute('kind'),
event.getAttribute('mime'),
event.getAttribute('time'),
event.getAttribute('lon'),
event.getAttribute('lat'));
medium.userName = tracer.name;
tracer.addMedium(medium);
medium.show();
medium.blink(20);
medium.display();
this.showStatus(tracer, 'adds ' + event.getAttribute('kind'));
}
this.onTraceCreate = function(tracer, event) {
tracer.newTrace(event.getAttribute('id'), event.getAttribute('name'));
this.showStatus(tracer, 'creates trace ' + event.getAttribute('name'));
}
this.onTraceDelete = function(tracer, event) {
tracer.deleteTrace(event.getAttribute('id'), event.getAttribute('name'));
this.showStatus(tracer, 'deletes trace ' + event.getAttribute('name'));
}
this.onTraceSuspend = function(tracer, event) {
tracer.suspendTrace();
this.showStatus(tracer, 'suspends trace');
}
this.onTraceResume = function(tracer, event) {
tracer.resumeTrace();
this.showStatus(tracer, 'resumes trace');
}
this.onTraceResume = function(tracer, event) {
tracer.resumeTrace();
this.showStatus(tracer, 'resumes trace');
}
this.onIndication = function (event) {
var eventType = event.getAttribute('event');
var tracerName = event.getAttribute('username');
var tracer = GTW.getTracer(tracerName);
if (!tracer && eventType != 'comment-add') {
tracer = GTW.createTracer(tracerName, event.getAttribute('lon'), event.getAttribute('lat'), event.getAttribute('time'));
}
if (GTAPP.mode != 'live') {
this.showStatus(tracer, '<a href="#" onclick="GTAPP.mLive();return false">is live &lt;show it!&gt;</a>');
return;
}
if (eventType == 'user-move') {
this.onMove(tracer, event);
} else if (eventType == 'user-hb') {
this.onHeartbeat(tracer, event);
} else if (eventType == 'medium-add') {
this.onMediumAdd(tracer, event);
} else if (eventType == 'trace-create') {
this.onTraceCreate(tracer, event);
} else if (eventType == 'trace-delete') {
this.onTraceDelete(tracer, event);
} else if (eventType == 'trace-suspend') {
this.onTraceSuspend(tracer, event);
} else if (eventType == 'trace-resume') {
this.onTraceResume(tracer, event);
} else if (eventType == 'comment-add') {
this.onCommentAdd(event);
} else {
this.showStatus(tracer, 'unhandled event ' + eventType);
}
}
}
function Medium(id, name, desc, type, mime, time, lon, lat) {
Feature.apply(this, new Array(id, name, desc, type, time, lon, lat))
this.mime = mime;
this.url = 'media.srv?id=' + this.id;
this.init = function() {
}
this.getIconDiv = function() {
if (this.type == 'text') {
var src = 'media/poi.gif';
var img = '<img id="' + this.iconId + '" title="' + this.getTitle() + '" src="' + src + '" border="0"  alt="" />';
return '<div class="texticon" style="border: 1px solid ' + this.bgColor + ';" >' + img + '</div>';
} else {
return '<div class="medicon" id="' + this.iconId + '" style="background-color:' + this.getBGColor() + ';" >&nbsp;&nbsp;&nbsp;&nbsp;</div>';
}
}
this.getTitle = function() {
return this.name + ' [' + this.id + ']';
}
this._displayPreview = function() {
if (this.type == 'video') {
this._displayVideo();
} else if (this.type == 'image') {
this._displayImage();
} else if (this.type == 'audio') {
this._displayAudio();
} else if (this.type == 'text') {
this._displayText();
}
}
this.displayImageFull = function() {
var url = this.url + '&resize=640x480';
var panel = GTW.getImageFullPanel();
panel.setTitle(this.getTitle());
panel.setContent('<img title="' + this.getTitle() + '" src="' + url + '" border="0"  />');
}
this._displayAudio = function() {
var previewTile = this.getPreviewTile()
previewTile.innerHTML = '<img class="mediumpreview" id="' + this.previewId + '" title="click to play" src="media/audioicon.jpg" border="0"  />';
var medium = this;
this.onClick = function(e) {
DH.cancelEvent(e);
var url = medium.url;
content = '<embed src="' + medium.url + '"/>';
previewTile.innerHTML = content;
}
DH.addEvent(this.previewId, 'click', this.onClick, false);
}
this._displayImage = function() {
var src = this.url + '&resize=320x240';
var previewTile = this.getPreviewTile()
previewTile.innerHTML = '<img class="mediumpreview" id="' + this.previewId + '" title="click to see larger image" src="' + src + '" border="0"  />';
var medium = this;
this.onClick = function(e) {
DH.cancelEvent(e);
medium.displayImageFull();
}
DH.addEvent(this.previewId, 'click', this.onClick, false);
}
this._displayText = function() {
var src = this.url + '&resize=320x240';
var previewTile = this.getPreviewTile()
previewTile.innerHTML = 'getting text...';
var self = this;
this.onLoadText = function(text) {
self.getPreviewTile().innerHTML = text;
}
DH.getURL(this.url, this.onLoadText);
}
this._displayVideo = function() {
var previewTile = this.getPreviewTile()
this.url = GW.MEDIA.getBaseURL() + '%3Fid=' + this.id;
previewTile.innerHTML = '<p id="jwplayer"><a href="http://www.macromedia.com/go/getflashplayer">Get the Flash Player</a> to see this player.</p>';
var s1 = new SWFObject(DH.getBaseDir() + '/mediaplayer.swf',"single","288","216","7");
s1.addParam("allowfullscreen","true");
s1.addVariable("file", this.url + '%26format=flv');
s1.addVariable("image",this.url + '%26format=jpg');
s1.addVariable("type", "flv");
s1.addVariable("width","288");
s1.addVariable("height","216");
s1.write("jwplayer");
}
}
function Menu(anId) {
Widget.apply(this, new Array(anId));
this.replaceItem = function(id, name, fn, arg) {
var li = DH.getObject(id);
if (!li) {
return;
}
var a = li.getElementsByTagName('a')[0];
a.innerHTML = name;
if (fn) {
a.setAttribute('fn', fn);
if (arg) {
a.setAttribute('arg', arg);
}
}
}
this.replaceItemText = function(id, text) {
var li = DH.getObject(id);
if (!li) {
return;
}
var a = li.getElementsByTagName('a')[0];
a.innerHTML = text;
}
this.removeItem = function(id) {
var li = DH.getObject(id);
if (!li) {
return;
}
this._unbindLink(li.getElementsByTagName('a')[0]);
li.parentNode.removeChild(li);
delete li;
}
this._onSelect = function (e) {
var anchor = DH.getEventTarget(e);
DH.cancelEvent(e);
var fn = anchor.getAttribute('fn');
if (fn) {
var arg = anchor.getAttribute('arg');
if (!arg) {
eval(fn + '()');
} else {
eval(fn + '("' + arg + '")');
}
}
}
this._bindLink = function(link) {
var onSelect = this._onSelect;
DH.addEvent(link, 'click', onSelect, false);
}
this._unbindLink = function(link) {
var onSelect = this._onSelect;
DH.removeEvent(link, 'click', onSelect);
}
this._fixIE = function(li) {
li.onmouseover = function() {
this.className += " sfhover";
}
li.onmouseout = function() {
this.className = this.className.replace(new RegExp(" sfhover\\b"), "");
}
}
var links = this.getContainer().getElementsByTagName('a');
for (var i = 0; i < links.length; i++) {
this._bindLink(links[i]);
}
if (DH.isIE == true) {
var sfEls = this.getContainer().getElementsByTagName("LI");
for (var i = 0; i < sfEls.length; i++) {
this._fixIE(sfEls[i]);
}
}
}
function Panel(id, bgColor, fgColor, onActivate, onClose) {
Widget.apply(this, new Array(id));
this.activate = function() {
this.setZ(Widget.curZ++);
this.show();
if (this.onActivate != null && DH.isVisible(this.getContainer()) == true) {
this.onActivate();
}
}
this.clear = function() {
if (this.content) {
}
this.content.innerHTML = ' ';
}
this.close = function() {
this.clear();
this.hide();
if (this.onClose != null) {
this.onClose();
}
}
this.hideFooter = function() {
DH.hide(this.footer);
DH.hide(this.resizer);
}
this.loadContent = function(url, onLoad) {
this.clear();
this.setContent('LOADING...');
var panel = this;
this.onLoadContent = function(cont) {
panel.setContent(cont);
if (onLoad) {
onLoad();
}
}
DH.getURL(url, this.onLoadContent);
}
this.setContent = function(cont) {
this.clear();
if (typeof cont == "string") {
this.content.innerHTML = cont;
} else {
this.content.appendChild(cont);
}
}
this.setTitle = function(title) {
this.header.innerHTML = title;
}
this.setBGColor = function(color) {
this.bgcolor = color;
DH.setBGColor(this.header, color);
DH.setBGColor(this.footer, color);
}
this.setFGColor = function(color) {
this.fgcolor = color;
DH.getStyleObject(this.header).color = color;
DH.getStyleObject(this.footer).color = color;
}
this.setDimension = function(w, h) {
DH.getStyleObject(this.getContainer()).width = w + 'px';
DH.getStyleObject(this.getContainer()).height = h + 'px';
this._fixIEScroll();
}
this._fixIEScroll = function() {
if (DH.isIE == true) {
var ch = DH.getObjectHeight(this.container) - DH.getObjectHeight(this.header) - DH.getObjectHeight(this.footer);
DH.getStyleObject(this.content).height = ch + 'px';
var cw = DH.getObjectWidth(this.container);
DH.getStyleObject(this.content).width = cw + 'px';
}
}
this.container = document.createElement('div');
var container = this.container;
container.className = 'pn-container';
container.id = container.className + id;
var header = document.createElement('div');
header.className = 'pn-header';
header.id = header.className + id;
var closer = document.createElement('div');
closer.className = 'pn-closer';
closer.id = closer.className + id;
var content = document.createElement('div');
content.className = 'pn-content';
content.id = content.className + id;
var footer = document.createElement('div');
footer.className = 'pn-footer';
footer.id = footer.className + id;
var resizer = document.createElement('div');
resizer.className = 'pn-resizer';
resizer.id = resizer.className + id;
container.appendChild(header);
container.appendChild(content);
container.appendChild(footer);
container.appendChild(resizer);
container.appendChild(closer);
document.body.appendChild(container);
this.header = header;
this.closer = closer;
this.resizer = resizer;
this.content = content;
this.footer = footer;
this.onActivate = null;
this.onClose = null;
if (onActivate) {
this.onActivate = onActivate;
}
if (onClose) {
this.onClose = onClose;
}
this.setXY((Math.round((Math.random() * 600) + 1)), 100 + (Math.round((Math.random() * 300) + 1)))
this.setContent('');
this.setBGColor(bgColor);
this.setFGColor(fgColor);
this.setTitle(id);
this._fixIEScroll();
var panel = this;
this.onCloserClick = function(e) {
panel.close();
DH.cancelEvent(e);
}
this.onDragStart = function(target, x, y) {
panel.activate();
}
this.onDrag = function(target, x, y, dx, dy) {
if (target.className == 'pn-header' || target.className == 'pn-footer') {
panel.setXY(panel.container.offsetLeft + dx, panel.container.offsetTop + dy);
} else if (target.className == 'pn-resizer') {
panel.setDimension(x - panel.container.offsetLeft, y - panel.container.offsetTop);
}
}
DH.addEvent(this.closer, 'click', this.onCloserClick, true);
DH.dragEnable(this.header, this.onDragStart, this.onDrag, null);
DH.dragEnable(this.resizer, this.onDragStart, this.onDrag, null);
DH.dragEnable(this.closer, this.onDragStart, this.onDrag, null);
DH.dragEnable(this.footer, this.onDragStart, this.onDrag, null);
}
function Selector(title, id, callback) {
Widget.apply(this, new Array(id));
this.addOption = function(name, label, value) {
var option = document.createElement('option');
option.id = this.getId() + 'o' + Widget.curOptionId++;
option.name = name;
option.value = value;
option.label = label;
var text = document.createTextNode(label);
option.appendChild(text)
this.select.appendChild(option);
}
this.clear = function() {
while (this.select.hasChildNodes() == true) {
this.select.removeChild(this.select.childNodes[0])
}
this.addOption('title', this.title, this.title);
}
this.remove = function() {
this.hide();
this.clear();
document.body.removeChild(this.form);
}
this.setCallback = function(fun) {
this.callback = fun;
}
this.callback = callback;
var form = document.createElement('form');
form.className = 'sel-form';
form.id = this.getId();
var select = document.createElement('select');
select.className = 'sel-select';
select.id = select.className + this.getId();
form.appendChild(select);
document.body.appendChild(form);
this.form = form;
this.select = select;
this.title = title;
this.addOption('title', this.title, this.title);
var selector = this;
this.onSelect = function(e) {
var option = selector.select.options[selector.select.selectedIndex];
if (selector.select.selectedIndex != 0) {
selector.callback(option.name, option.childNodes.item(0).nodeValue, option.value);
}
DH.cancelEvent(e);
}
DH.addEvent(this.select, 'change', selector.onSelect, false);
}
var TRACER = {
current: null,
BLINK_INTERVAL_SHOW: 250,
BLINK_INTERVAL_HIDE: 250,
MARKER_OFFSET_X: 5,
MARKER_OFFSET_Y: 5
}
function Tracer(name, color, iconURL, pt, time) {
this.record = null;
this.id = -1;
this.name = name;
this.color = color;
this.point = pt;
if (this.point && time) {
this.point.time = new Number(time);
}
this.iconURL = iconURL;
this.activeTrace = null;
this.tlabel = null;
this.hidden = false;
this.live = false;
this.full = false;
this.lastPoint = null;
this.thumbId = null;
this.thumbURL = 'media/default-user-thumb-4x3.jpg';
this.init = function() {
if (this.point) {
this.setLocation(this.point);
}
}
this.activate = function () {
if (this.activeTrace != null && GTW.tracePlayer != null) {
GTW.tracePlayer.setTrace(this.activeTrace);
}
this.panTo();
}
this.addMedium = function (medium) {
if (this.activeTrace != null) {
this.activeTrace.featureSet.addFeature(medium);
}
}
this.blink = function() {
DH.toggleVisibility(this.iconId);
this.blinkInterval = DH.isVisible(this.iconId) ? TRACER.BLINK_INTERVAL_SHOW : TRACER.BLINK_INTERVAL_HIDE;
var self = this;
setTimeout(function() {
self.blink();
}, this.blinkInterval);
}
this.clear = function () {
this.hide();
this.deleteTrace();
}
this.createTLabel = function () {
this.iconId = 'icon' + this.name;
var html = '<a href="#"><span class="tracer"><img id="' + this.iconId + '" src="' + this.iconURL + '" border="0" />&nbsp;<span class="tracername" >' + this.name + '</span></span></a>';
tl = new TLabel();
tl.glide = true;
tl.id = 'tlab' + this.name;
tl.anchorLatLng = this.point;
tl.anchorPoint = 'topLeft';
tl.content = html;
tl.markerOffset = new GSize(TRACER.MARKER_OFFSET_X, TRACER.MARKER_OFFSET_Y);
return tl;
}
this.getColor = function () {
if (this.record != null && this.record != -1) {
var userColor =  this.record.getField('color');
if (userColor != null) {
this.color  = userColor;
}
}
return this.color;
}
this.deleteTrace = function () {
if (this.activeTrace != null) {
this.activeTrace.remove();
}
this.activeTrace = null;
}
this.hasTrace = function () {
return this.activeTrace != null;
}
this.getActiveTrace = function () {
return this.activeTrace;
}
this.newTrace = function (id, name) {
this.deleteTrace(id, name);
this.activeTrace = new Trace(id, name, this);
}
this.readTrace = function (id, name, doDraw) {
var tracer = this;
this.onGetTraceRsp = function (rspElm) {
tracer.deleteTrace();
var trace = new Trace(id, name, tracer);
trace.setGTX(rspElm.getElementsByTagName('gtx')[0]);
if (doDraw == true) {
trace.draw();
}
tracer.showInfo();
var lastPoint = trace.getLastPoint();
if (lastPoint != null) {
tracer.setLocation(lastPoint, lastPoint.time, true);
}
tracer.activeTrace = trace;
if (GTW.tracePlayer != null) {
GTW.tracePlayer.setTrace(trace);
}
trace.showTitle();
trace.showInfo();
GTW.showStatus('trace drawn');
}
GTW.showStatus('drawing trace ' + name + '...');
var args = {format: 'gtx', attrs: 'lon,lat,t', media: 'true', mindist: GTW.minTracePtDist, maxpoints: GTW.maxTracePt};
GW.TRACE.get(this.onGetTraceRsp, id, args);
}
this.getLocation = function() {
return this.point;
}
this.setLocation = function(point, time, force) {
if (point == null) {
return;
}
this.lastPoint = this.point;
this.point = point;
if (time) {
this.point.time = new Number(time);
}
if (this.tlabel == null) {
this.tlabel = this.createTLabel();
GMAP.map.addTLabel(this.tlabel);
var self = this;
this.onClick = function(e) {
DH.cancelEvent(e);
self.showInfo();
self.popupInfoWindow();
}
DH.addEvent(this.tlabel.elm, 'click', this.onClick, false);
} else {
if (force) {
this.tlabel.forceToLatLng(this.point);
} else {
this.tlabel.moveToLatLng(this.point);
}
}
}
this.move = function(lon, lat, time) {
pt = new GLatLng(lat, lon);
if (time) {
pt.time = new Number(time);
}
this.setLocation(pt);
if (this.activeTrace != null) {
this.activeTrace.addLivePoint(pt);
}
this.showLiveInfo();
}
this.show = function() {
if (this.tlabel != null) {
DH.show(this.tlabel.id);
}
this.showInfo();
this.hidden = false;
}
this.hide = function() {
if (this.tlabel != null) {
DH.hide(this.tlabel.id);
}
this.hidden = true;
}
this.isLive = function() {
return this.live;
}
this.resumeTrace = function() {
}
this.popupInfoWindow = function() {
var html = '<h3>' + this.name + '</h3>';
html += 'Was here on ' + GTW.formatDateAndTime(this.point.time) + '<br/>at ' + this.point.lng() + ', ' + this.point.lat();
GMAP.map.openInfoWindowHtml(this.point, html);
}
this.setLive = function() {
if (this.live == true) {
return;
}
this.live = true;
this.blink();
}
this.showLiveInfo = function() {
this.showInfo();
var speed = 'unknown';
if (this.point != null && this.lastPoint != null) {
speed = GMAP.speed(this.lastPoint, this.point);
speed = speed.toFixed(2) + ' km/h';
}
DH.setHTML('traceview', GTW.formatDateAndTime(this.point.time) + ' <br/>' + speed);
}
this.showInfo = function() {
DH.setHTML('tracerid', this.name);
if (!DH.getObject("tracerimg").src) {
DH.getObject("tracerimg").src = this.thumbURL;
}
DH.setHTML('tracerdesc', '&nbsp;');
TRACER.current = this;
if (this.record != null && this.record != -1) {
this._showInfo();
return;
}
this._queryInfo();
}
this.suspendTrace = function() {
}
this.isVisible = function() {
return this.hidden == false;
}
this.panTo = function () {
if (this.point != null) {
GMAP.map.setCenter(this.point, GMAP.map.getZoom());
}
}
this._showInfo = function() {
if (TRACER.current != this && this.record != null && this.record != -1) {
return;
}
DH.getObject("tracerimg").src = this.thumbURL;
var desc = this.record.getField('desc');
if (desc == null) {
desc = ' ';
}
DH.setHTML('tracerdesc', '<i>' + desc + '</i> <br/><span class="cmtlink"><a title="Show list of traces from ' + this.name + '" href="#" onclick="GTAPP.mUserTraces(\'' + this.name + '\')" >traces (' + this.record.getField('traces') + ')</a>&nbsp;&nbsp;<a title="Show all media (photos etc) from this user" href="#" onclick="GTAPP.mShowMediaByUser(\'' + this.name + '\')" >media (' + this.record.getField('media') + ')</a>&nbsp;&nbsp;<a href="#" title="Show user\'s messages or send message to this user" onclick="CMT.showCommentPanel(' + this.id + ',\'user\',\'' + this.name + '\')" >msgs (' + this.record.getField('comments') + ')</a>&nbsp;&nbsp;</span>');
if (CMT.isCommentPanelOpen() == true) {
}
}
this._queryInfo = function() {
if (this.record == -1) {
return;
}
var self = this;
this.onGetRecord = function(result) {
self.record = -1;
if (result != null && result.length > 0) {
self.record = result[0];
self.id = self.record.getField("id");
self.thumbId = self.record.getField("iconid");
if (self.thumbId != null) {
self.thumbURL = 'media.srv?id=' + self.thumbId + "&resize=80x60!";
}
}
self._showInfo();
}
this.record = -1;
GW.QUERY.queryStore("q-user-info", this.onGetRecord, {user: this.name});
}
}
function Trace(id, name, tracer) {
this.id = id;
this.name = name;
this.startDate = 0;
this.endDate = 0;
this.tracer = tracer;
this.segments = [];
this.featureSet = new FeatureSet();
this.polyLines = [];
this.color = tracer.getColor();
this.addPoint = function (aPoint) {
if (this.segments.length == 0) {
this.segments[0] = [];
}
this.segments[this.segments.length - 1].push(aPoint);
}
this.addLivePoint = function (aPoint) {
var lastPoint = this.getLastPoint();
this.addPoint(aPoint);
if (lastPoint != null) {
this.clearPolyLines();
for (var i = 0; i < this.segments.length; i++) {
this.drawPoints(this.segments[i]);
}
}
}
this.addMedium = function (medium) {
this.featureSet.addFeature(medium);
medium.show();
}
this.clear = function () {
this.clearPolyLines();
this.featureSet.clear();
}
this.clearPolyLines = function () {
for (var i = 0; i < this.polyLines.length; i++) {
GMAP.map.removeOverlay(this.polyLines[i]);
}
this.polyLines = [];
}
this.draw = function () {
var bounds;
for (var i = 0; i < this.segments.length; i++) {
this.drawPoints(this.segments[i]);
}
for (var i = 0; i < this.polyLines.length; i++) {
if (i == 0) {
bounds = this.polyLines[i].getBounds();
} else {
var nextBounds = this.polyLines[i].getBounds();
bounds.extend(nextBounds.getSouthWest());
bounds.extend(nextBounds.getNorthEast());
}
}
if (bounds) {
var zoom = GMAP.map.getBoundsZoomLevel(bounds);
GMAP.map.setCenter(bounds.getCenter(), zoom);
}
GTW.getFeaturePlayer().setFeatureSet(this.featureSet);
this.featureSet.show();
this.featureSet.displayFirst();
}
this.drawPoints = function (ptArr) {
if (ptArr.length > 200) {
this.drawPoints(ptArr.slice(0, 200));
this.drawPoints(ptArr.slice(200));
return;
}
var pl = new GPolyline(ptArr, this.color, GTW.polyLineWidth, GTW.polyLineOpacity);
GMAP.map.addOverlay(pl);
this.polyLines.push(pl);
}
this.getLastPoint = function () {
var segment = this.getSegment(this.segments.length - 1);
if (segment == null) {
return null;
}
return this.getPoint(this.segments.length - 1, segment.length - 1);
}
this.getPoint = function (segIndex, ptIndex) {
var segment = this.getSegment(segIndex);
if (segment == null) {
return null;
}
if (segment.length == 0 || ptIndex < 0 || ptIndex >= segment.length) {
return null;
}
return segment[ptIndex];
}
this.getSegment = function (segIndex) {
if (this.segments.length <= 0 || segIndex < 0 || segIndex >= this.segments.length) {
return null;
}
return this.segments[segIndex];
}
this.getTracer = function() {
return this.tracer;
}
this.remove = function () {
this.clear();
this.polyLines = [];
this.segments = [];
this.featureSet.clear();
DH.setHTML('tracetitle', '&nbsp;');
DH.setHTML('traceview', 'trace info');
}
this.setGTX = function (gtx) {
if (gtx.documentElement) {
gtx = gtx.documentElement;
}
var infoElm = gtx.getElementsByTagName('info')[0];
if (infoElm) {
this.name = infoElm.getAttribute('name');
this.startDate = new Number(infoElm.getAttribute('startdate'));
this.endDate = new Number(infoElm.getAttribute('enddate'));
}
var segElms = gtx.getElementsByTagName('seg');
this.segments = [];
if (segElms) {
this.distance = 0;
for (i = 0; i < segElms.length; i++) {
var ptElements = segElms[i].getElementsByTagName('pt');
if (!ptElements || ptElements.length == 0) {
continue;
}
var ptArr = [];
var nextPt;
for (j = 0; j < ptElements.length; j++) {
nextPt = new GLatLng(ptElements[j].getAttribute('lat'), ptElements[j].getAttribute('lon'));
nextPt.time = new Number(ptElements[j].getAttribute('t'));
nextPt.distance = 0;
nextPt.speed = 0;
if (j > 0) {
nextPt.distance = GMAP.distance(ptArr[j - 1], nextPt);
nextPt.speed = nextPt.distance / ((nextPt.time - ptArr[j - 1].time) / 3600000);
this.distance += nextPt.distance;
}
ptArr.push(nextPt);
}
this.segments.push(ptArr);
}
}
var mediumElements = gtx.getElementsByTagName('medium');
this.media = [];
if (mediumElements) {
var nextMedium;
var nextDesc = 'no description';
for (i = 0; i < mediumElements.length; i++) {
nextMedium = mediumElements[i];
if (nextMedium.childNodes[0]) {
nextDesc = nextMedium.childNodes[0].nodeValue;
}
medium = GTW.createMedium(nextMedium.getAttribute('id'),
nextMedium.getAttribute('name'),
nextDesc,
nextMedium.getAttribute('kind'),
nextMedium.getAttribute('mime'),
nextMedium.getAttribute('time'),
nextMedium.getAttribute('lon'),
nextMedium.getAttribute('lat'));
medium.userName = this.tracer.name;
this.featureSet.addFeature(medium);
}
}
}
this.showInfo = function() {
DH.setHTML('traceview', 'start: ' + GTW.formatDateAndTime(this.startDate) + '<br/>end: ' + GTW.formatDateAndTime(this.endDate) + '<br/>distance: ' + this.distance.toFixed(2) + ' km'
+ '<br/><span class="cmtlink"><a title="Show or make comments on this trace" href="#" onclick="CMT.showCommentPanel(' + this.id + ',\'trace\',\'' + this.name + '\')" >[comments]</a>&nbsp;&nbsp;<a target="_new" title="A direct link to this trace. Use right-mouse to copy." href="index.html?cmd=showtrace&id=' + this.id + '&user=' + this.tracer.name +'">[link]</a>&nbsp;&nbsp;<a title="A link to the GPX file for this trace. Use right-mouse to copy link." target="_new" href="proto.srv?gw_cmd=trace-export-req&format=gpx&mindist=20&id=' + this.id + '">[gpx]</a></span>');
if (CMT.isCommentPanelOpen() == true) {
CMT.showCommentPanel(this.id, 'trace', this.name);
}
}
this.showTitle = function() {
DH.setHTML('traceinfo', this.name + ' [' + this.id + ']');
}
this.showTitle();
}
function TraceAutoPlayer() {
this.INTERVAL_MILLIS = 2000;
this.intervalId = null;
this.tracer = null;
this.lastTracer = null;
this.state = 'IDLE';
this.n = 0;
this.start = function() {
this.stop();
var self = this;
this.intervalId = setInterval(function() {
self._doWork()
}, this.INTERVAL_MILLIS);
}
this.stop = function() {
if (this.intervalId == null) {
return;
}
clearInterval(this.intervalId);
this.intervalId = null;
}
this._doWork = function() {
if (this.intervalId == null) {
return;
}
if (this.state == 'IDLE') {
if (this.tracer != null) {
this.lastTracer = this.tracer;
this.tracer = null;
}
this.state = 'READING';
this._getRandomTrace();
} else if (this.state == 'READING') {
GTW.showStatus('reading next trace... ' + (this.n++));
if (this.tracer != null && this.tracer.getActiveTrace() != null) {
this.state = 'READY';
}
} else if (this.state == 'READY') {
GTW.showStatus('ready');
var trace = this.tracer.getActiveTrace();
var tracePlayer = GTW.getTracePlayer();
this.tracer.show();
tracePlayer.setTrace(trace);
tracePlayer.hide();
tracePlayer.play();
this.state = 'PLAYING';
} else if (this.state == 'PLAYING') {
var tracePlayer = GTW.getTracePlayer();
if (tracePlayer.isPlaying() == false) {
this.state = 'IDLE';
} else if (this.tracer.getActiveTrace() != null) {
GTW.showStatus('playing ' + this.tracer.name + '/' + this.tracer.getActiveTrace().name);
}
}
}
this._getRandomTrace = function() {
var player = this;
this.onQueryTraceRsp = function (records) {
GTW.showStatus('read ' + records[0].getField('name'));
player.tracer = GTW.createTracerByRecord(records[0]);
player.tracer.readTrace(records[0].getField('id'), records[0].getField('name'), false);
if (player.lastTracer != null) {
player.lastTracer.clear();
player.lastTracer = null;
}
}
GW.QUERY.queryStore('q-random-trace', this.onQueryTraceRsp);
}
}
function TracePlayer() {
this.trace = null;
this.active = false;
this.playing = false;
this.intervalId = null;
this.segIndex = 0;
this.pointIndex = 0;
this.featureIndex = 0;
this.nextFeature = null;
this.playPoints = [];
this.FEATURE_DISPLAY_TIME = 2000;
this.POINT_INTERVAL_TIME = 100;
this.featureShowing = false;
this.controls = DH.getObject('tracecontrols')
var self = this;
this.onPlayPause = function(e) {
DH.cancelEvent(e);
if (self.isActive() == false) {
self.play();
return;
}
if (self.isPlaying()) {
self.pause();
} else {
self.resume();
}
}
this.onStop = function(e) {
DH.cancelEvent(e);
self.stop();
if (self.trace != null) {
self.trace.draw();
}
}
this.onNext = function(e) {
DH.cancelEvent(e);
self.next();
}
this.onPrev = function(e) {
DH.cancelEvent(e);
self.prev();
}
DH.addEvent('traceplaypause', 'click', this.onPlayPause, true);
DH.addEvent('tracestop', 'click', this.onStop, true);
DH.addEvent('tracenext', 'click', this.onNext, true);
DH.addEvent('traceprev', 'click', this.onPrev, true);
this.hide = function() {
DH.hide(this.controls);
GTW.getFeaturePlayer().hide();
}
this.isActive = function() {
return this.active;
}
this.isPlaying = function() {
return this.active == true && this.playing == true;
}
this.next = function() {
if (this.isPlaying() == true) {
return;
}
if (this.isActive() == false) {
this._initPlay();
}
this._playNext();
}
this.prev = function() {
this.showInfo('not yet implemented');
}
this.showInfo = function(msg) {
DH.setHTML('traceview', msg);
}
this.showTraceInfo = function() {
this.showInfo('start: ' + GTW.formatDateAndTime(this.trace.startDate) + '<br/>end: ' + GTW.formatDateAndTime(this.trace.endDate) + '<br/>distance: ' + this.trace.distance.toFixed(2) + ' km');
}
this.pause = function() {
this.playing = false;
if (this.playPoints.length > 0) {
this.trace.drawPoints(this.playPoints);
var lastPt = this.playPoints[this.playPoints.length - 1]
this.playPoints = [];
this.playPoints.push(lastPt);
}
this.showInfo('paused');
this._stopLoop();
}
this.play = function() {
if (this.isActive() == false) {
this._initPlay();
}
this.playing = true;
this.showInfo('playing');
this._startLoop(this.POINT_INTERVAL_TIME);
}
this.resume = function() {
GTW.showStatus('playing resumed');
this.playing = true;
var player = this;
this._startLoop(this.POINT_INTERVAL_TIME);
}
this.show = function() {
DH.show(this.controls);
GTW.getFeaturePlayer().show();
}
this.stop = function() {
this.pause();
this.active = false;
this.intervalId = null;
this.segIndex = 0;
this.pointIndex = 0;
this.curPoint = null;
this.featureIndex = 0;
this.nextFeature = null;
this.playPoints = [];
this.trace.showInfo();
}
this.setTrace = function(trace) {
if (this.trace == trace) {
return;
}
if (this.isActive() == true) {
this.stop();
}
this.trace = trace;
GTW.getFeaturePlayer().setFeatureSet(trace.featureSet);
this.trace.showInfo();
}
this._initPlay = function() {
if (this.trace == null) {
return;
}
this.trace.clear();
this.segIndex = 0;
this.pointIndex = 0;
this.featureIndex = 0;
this.distance = 0;
this.nextFeature = this.trace.featureSet.getFeature(this.featureIndex++);
this.curPoint = this.trace.getPoint(0, this.pointIndex++);
if (this.curPoint == null) {
return;
}
GMAP.map.panTo(this.curPoint);
this.active = true;
}
this._startLoop = function(interval) {
this._stopLoop();
var player = this;
this.intervalId = setInterval(function() {
player._playNext()
}, interval);
}
this._stopLoop = function() {
if (this.intervalId == null) {
return;
}
clearInterval(this.intervalId);
this.intervalId = null;
}
this._playNext = function() {
try {
if (this.isPlaying() == true && this.featureShowing == true) {
this.featureShowing == false;
this._startLoop(this.POINT_INTERVAL_TIME);
}
var segment = this.trace.getSegment(this.segIndex);
if (this.curPoint != null) {
if (!GMAP.map.getBounds().contains(this.curPoint)) {
GMAP.map.panTo(this.curPoint);
if (this.isPlaying() == true) {
this.featureShowing = true;
this._startLoop(this.FEATURE_DISPLAY_TIME);
}
}
var endOfSeg = this.pointIndex >= segment.length - 1;
var endOfTrace = endOfSeg && (this.segIndex >= this.trace.segments.length - 1);
if (this.nextFeature != null && (this.curPoint.time >= this.nextFeature.time || endOfTrace == true)) {
this._playFeature(this.nextFeature);
this.nextFeature = this.trace.featureSet.getFeature(this.featureIndex++);
return;
}
this.trace.getTracer().setLocation(this.curPoint, this.curPoint.time, true);
this.playPoints.push(this.curPoint);
this.distance += this.curPoint.distance;
if (this.playPoints.length % 5 == 0 || this.isPlaying() == false) {
this.showInfo(GTW.formatDateAndTime(this.curPoint.time) + ' - ' + this.distance.toFixed(2) + ' km - ' + this.curPoint.speed.toFixed(2) + ' km/h');
}
if (this.playPoints.length % 5 == 0 || endOfSeg == true) {
this.trace.drawPoints(this.playPoints);
this.playPoints = [];
if (endOfSeg == false) {
this.playPoints.push(this.curPoint);
}
}
}
if (segment != null && ++this.pointIndex >= segment.length) {
this.playPoints = [];
this.showInfo('end of segment');
this.pointIndex = 0;
++this.segIndex;
}
if (this.segIndex >= this.trace.segments.length && this.nextFeature == null) {
this.stop();
} else {
this.curPoint = this.trace.getPoint(this.segIndex, this.pointIndex);
}
} catch(e) {
this.stop();
this.showInfo('traceplay canceled');
}
}
this._playFeature = function(feature) {
feature.show();
feature.blink(6);
feature.display();
this.featureShowing = true;
if (this.isPlaying() == true) {
this._startLoop(this.FEATURE_DISPLAY_TIME);
}
}
}
Widget.curZ = 10000;
Widget.curOptionId = 1;
function BBox(x, y, w, h) {
this.x = x;
this.y = y;
this.w = w;
this.h = h;
this.toString = function() {
return 'x=' + this.x + ' y=' + this.y + ' w=' + this.w + ' h=' + this.h;
}
}
function Widget(id) {
this.container = null;
this.id = id;
this.getContainer = function() {
if (this.container == null) {
this.container = DH.getObject(this.id);
}
return this.container;
}
this.getBBox = function() {
var cont = this.getContainer();
return new BBox(DH.getObjectX(cont), DH.getObjectY(cont), DH.getObjectWidth(cont), DH.getObjectHeight(cont));
}
this.hide = function() {
DH.hide(this.getContainer());
}
this.getId = function() {
return this.id;
}
this.isVisible = function() {
DH.isVisible(this.getContainer());
}
this.setOpacity = function(o) {
DH.setOpacity(this.getContainer(), o);
}
this.setXY = function(x, y) {
DH.shiftTo(this.getContainer(), x, y);
}
this.setWidth = function(w) {
DH.getStyleObject(this.getContainer()).width = w;
}
this.setZ = function(z) {
DH.setZIndex(this.getContainer(), z);
}
this.show = function() {
DH.show(this.getContainer());
}
}
if(typeof deconcept=="undefined"){var deconcept=new Object();}if(typeof deconcept.util=="undefined"){deconcept.util=new Object();}if(typeof deconcept.SWFObjectUtil=="undefined"){deconcept.SWFObjectUtil=new Object();}deconcept.SWFObject=function(_1,id,w,h,_5,c,_7,_8,_9,_a){if(!document.getElementById){return;}this.DETECT_KEY=_a?_a:"detectflash";this.skipDetect=deconcept.util.getRequestParameter(this.DETECT_KEY);this.params=new Object();this.variables=new Object();this.attributes=new Array();if(_1){this.setAttribute("swf",_1);}if(id){this.setAttribute("id",id);}if(w){this.setAttribute("width",w);}if(h){this.setAttribute("height",h);}if(_5){this.setAttribute("version",new deconcept.PlayerVersion(_5.toString().split(".")));}this.installedVer=deconcept.SWFObjectUtil.getPlayerVersion();if(!window.opera&&document.all&&this.installedVer.major>7){deconcept.SWFObject.doPrepUnload=true;}if(c){this.addParam("bgcolor",c);}var q=_7?_7:"high";this.addParam("quality",q);this.setAttribute("useExpressInstall",false);this.setAttribute("doExpressInstall",false);var _c=(_8)?_8:window.location;this.setAttribute("xiRedirectUrl",_c);this.setAttribute("redirectUrl","");if(_9){this.setAttribute("redirectUrl",_9);}};deconcept.SWFObject.prototype={useExpressInstall:function(_d){this.xiSWFPath=!_d?"expressinstall.swf":_d;this.setAttribute("useExpressInstall",true);},setAttribute:function(_e,_f){this.attributes[_e]=_f;},getAttribute:function(_10){return this.attributes[_10];},addParam:function(_11,_12){this.params[_11]=_12;},getParams:function(){return this.params;},addVariable:function(_13,_14){this.variables[_13]=_14;},getVariable:function(_15){return this.variables[_15];},getVariables:function(){return this.variables;},getVariablePairs:function(){var _16=new Array();var key;var _18=this.getVariables();for(key in _18){_16[_16.length]=key+"="+_18[key];}return _16;},getSWFHTML:function(){var _19="";if(navigator.plugins&&navigator.mimeTypes&&navigator.mimeTypes.length){if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","PlugIn");this.setAttribute("swf",this.xiSWFPath);}_19="<embed type=\"application/x-shockwave-flash\" src=\""+this.getAttribute("swf")+"\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\" style=\""+this.getAttribute("style")+"\"";_19+=" id=\""+this.getAttribute("id")+"\" name=\""+this.getAttribute("id")+"\" ";var _1a=this.getParams();for(var key in _1a){_19+=[key]+"=\""+_1a[key]+"\" ";}var _1c=this.getVariablePairs().join("&");if(_1c.length>0){_19+="flashvars=\""+_1c+"\"";}_19+="/>";}else{if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","ActiveX");this.setAttribute("swf",this.xiSWFPath);}_19="<object id=\""+this.getAttribute("id")+"\" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\" style=\""+this.getAttribute("style")+"\">";_19+="<param name=\"movie\" value=\""+this.getAttribute("swf")+"\" />";var _1d=this.getParams();for(var key in _1d){_19+="<param name=\""+key+"\" value=\""+_1d[key]+"\" />";}var _1f=this.getVariablePairs().join("&");if(_1f.length>0){_19+="<param name=\"flashvars\" value=\""+_1f+"\" />";}_19+="</object>";}return _19;},write:function(_20){if(this.getAttribute("useExpressInstall")){var _21=new deconcept.PlayerVersion([6,0,65]);if(this.installedVer.versionIsValid(_21)&&!this.installedVer.versionIsValid(this.getAttribute("version"))){this.setAttribute("doExpressInstall",true);this.addVariable("MMredirectURL",escape(this.getAttribute("xiRedirectUrl")));document.title=document.title.slice(0,47)+" - Flash Player Installation";this.addVariable("MMdoctitle",document.title);}}if(this.skipDetect||this.getAttribute("doExpressInstall")||this.installedVer.versionIsValid(this.getAttribute("version"))){var n=(typeof _20=="string")?document.getElementById(_20):_20;n.innerHTML=this.getSWFHTML();return true;}else{if(this.getAttribute("redirectUrl")!=""){document.location.replace(this.getAttribute("redirectUrl"));}}return false;}};deconcept.SWFObjectUtil.getPlayerVersion=function(){var _23=new deconcept.PlayerVersion([0,0,0]);if(navigator.plugins&&navigator.mimeTypes.length){var x=navigator.plugins["Shockwave Flash"];if(x&&x.description){_23=new deconcept.PlayerVersion(x.description.replace(/([a-zA-Z]|\s)+/,"").replace(/(\s+r|\s+b[0-9]+)/,".").split("."));}}else{if(navigator.userAgent&&navigator.userAgent.indexOf("Windows CE")>=0){var axo=1;var _26=3;while(axo){try{_26++;axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash."+_26);_23=new deconcept.PlayerVersion([_26,0,0]);}catch(e){axo=null;}}}else{try{var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");}catch(e){try{var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");_23=new deconcept.PlayerVersion([6,0,21]);axo.AllowScriptAccess="always";}catch(e){if(_23.major==6){return _23;}}try{axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash");}catch(e){}}if(axo!=null){_23=new deconcept.PlayerVersion(axo.GetVariable("$version").split(" ")[1].split(","));}}}return _23;};deconcept.PlayerVersion=function(_29){this.major=_29[0]!=null?parseInt(_29[0]):0;this.minor=_29[1]!=null?parseInt(_29[1]):0;this.rev=_29[2]!=null?parseInt(_29[2]):0;};deconcept.PlayerVersion.prototype.versionIsValid=function(fv){if(this.major<fv.major){return false;}if(this.major>fv.major){return true;}if(this.minor<fv.minor){return false;}if(this.minor>fv.minor){return true;}if(this.rev<fv.rev){return false;}return true;};deconcept.util={getRequestParameter:function(_2b){var q=document.location.search||document.location.hash;if(_2b==null){return q;}if(q){var _2d=q.substring(1).split("&");for(var i=0;i<_2d.length;i++){if(_2d[i].substring(0,_2d[i].indexOf("="))==_2b){return _2d[i].substring((_2d[i].indexOf("=")+1));}}}return "";}};deconcept.SWFObjectUtil.cleanupSWFs=function(){var _2f=document.getElementsByTagName("OBJECT");for(var i=_2f.length-1;i>=0;i--){_2f[i].style.display="none";for(var x in _2f[i]){if(typeof _2f[i][x]=="function"){_2f[i][x]=function(){};}}}};if(deconcept.SWFObject.doPrepUnload){if(!deconcept.unloadSet){deconcept.SWFObjectUtil.prepUnload=function(){__flash_unloadHandler=function(){};__flash_savedUnloadHandler=function(){};window.attachEvent("onunload",deconcept.SWFObjectUtil.cleanupSWFs);};window.attachEvent("onbeforeunload",deconcept.SWFObjectUtil.prepUnload);deconcept.unloadSet=true;}}if(!document.getElementById&&document.all){document.getElementById=function(id){return document.all[id];};}var getQueryParamValue=deconcept.util.getRequestParameter;var FlashObject=deconcept.SWFObject;var SWFObject=deconcept.SWFObject;
var MYAPP = {
WINDOW_TITLE: 'Geosailing - Frisian Solar Challenge 2008 Live',
DOC_TITLE: 'Geosailing',
APP_NAME: 'fsc08',
MAP_CENTERS: [],
MAP_INIT_CENTER: undefined,
MAP_INIT_ZOOM: 10,
BOAT_LIST_SIZE: 8,
liveMedia: new FeatureSet(),
dateSelected: undefined,
addLiveMedium: function(aMedium) {
MYAPP.liveMedia.addFeature(aMedium);
},
createLiveListener: function() {
GTAPP.liveListener = new SailLiveListener('livestatus');
},
clearMap: function() {
GTW.clearTracers();
GTW.clearFeatures();
MYAPP.liveMedia.dispose();
BOAT.mediaSet.dispose();
GMAP.map.clearOverlays();
},
createMap: function() {
GTAPP.blinkStatus('Creating map...');
G_PHYSICAL_MAP.getMinimumResolution = function () {
return 8
};
G_NORMAL_MAP.getMinimumResolution = function () {
return 8
};
G_SATELLITE_MAP.getMinimumResolution = function () {
return 8
};
G_HYBRID_MAP.getMinimumResolution = function () {
return 8
};
GMAP.addMapType('satellite', G_SATELLITE_MAP);
GMAP.addMapType('map', G_NORMAL_MAP);
GMAP.addMapType('hybrid', G_HYBRID_MAP);
GMAP.createGMap('map');
GMAP.map.addControl(new GLargeMapControl());
GMAP.map.addControl(new GMapTypeControl());
GMAP.map.addControl(new GScaleControl());
GMAP.map.enableContinuousZoom();
GMAP.map.enableDoubleClickZoom();
var center = MYAPP.MAP_INIT_CENTER;
var zoom = MYAPP.MAP_INIT_ZOOM;
var dateStr = new Date().format('YYMMDD');
var centerData = MYAPP.MAP_CENTERS[dateStr];
if (centerData) {
center = centerData.pt;
zoom = centerData.zoom;
MYAPP.selectDayButton(dateStr);
}
GMAP.setDefaultMapParms(center, zoom, 'satellite');
GMAP.showMap();
GTAPP.showStatus('Map created');
},
doPageCommand: function() {
var cmd = DH.getPageParameter('cmd', null);
if (cmd == null) {
return;
}
if (cmd == 'redactie') {
RED.init();
return true;
}
return false;
},
drawActiveTrace: function(aLoginName) {
GW.QUERY.queryStore('q-traces-by-user', MYAPP.onQueryUserTraces, 'user', aLoginName);
},
followBoat: function(aBoatName) {
var tracer = GTW.getTracer(aBoatName);
if (!tracer) {
alert('kan boot genaamd ' + aBoatName + ' niet vinden !!');
return;
}
if (!tracer.getLocation() || tracer.getLocation() == null) {
alert('De boot ' + aBoatName + ' heeft nog geen locatie.');
return;
}
tracer.followToggle();
},
zoomOut: function() {
GMAP.map.setCenter(MYAPP.MAP_INIT_CENTER, MYAPP.MAP_INIT_ZOOM);
MYAPP.selectDayButton(undefined);
},
onQueryUserTraces: function(records) {
var activeTraceRec;
for (var i = 0; i < records.length; i++) {
if (records[i].getField('state') == 1) {
activeTraceRec = records[i];
break;
}
}
if (!activeTraceRec) {
alert('sorry, geen active route gevonden !');
return;
}
var userName = activeTraceRec.getField('user');
var tracer = GTW.getTracer(userName);
tracer.readTrace(activeTraceRec.getField('id'), userName, true);
},
setMapCenter: function(aDate) {
var centerData = MYAPP.MAP_CENTERS[aDate];
GMAP.map.setCenter(centerData.pt, centerData.zoom);
MYAPP.selectDayButton(aDate);
},
selectDayButton: function(aDate) {
if (MYAPP.dateSelected) {
DH.getObject(MYAPP.dateSelected).className = undefined;
}
if (aDate) {
DH.getObject(aDate).className = 'selected';
MYAPP.dateSelected = aDate;
}
},
showUserDetails: function(aLoginName) {
var tracer = GTW.getTracer(aLoginName);
BOAT.show(aLoginName);
},
hideRoutesOverlay: function() {
var linkElm = DH.getObject('routesoverlay');
GMAP.map.removeOverlay(MYAPP.routesOverlay);
MYAPP.routesOverlay = undefined;
linkElm.innerHTML = 'routes aan';
linkElm.className = 'routesbutton';
},
hideTracerOverlays: function() {
var tracers = GTW.getTracers();
var tracerName;
for (tracerName in tracers) {
GTW.getTracer(tracerName).hideRouteOverlay();
}
},
showRoutesOverlay: function() {
var tileLayer = new GTileLayer(new GCopyrightCollection(), 8, 16);
tileLayer.getTileUrl = function(tile, zoom) {
return MYAPP.TILE_ROOT + '/' + zoom + '/' + tile.x + "/" + tile.y + "/all.png?t=" + new Date().getTime();
};
tileLayer.isPng = function() {
return true;
}
tileLayer.getOpacity = function() {
return 1.0;
}
MYAPP.routesOverlay = new GTileLayerOverlay(tileLayer);
GMAP.map.addOverlay(MYAPP.routesOverlay);
var linkElm = DH.getObject('routesoverlay');
linkElm.innerHTML = 'routes uit';
linkElm.className = 'selected';
},
toggleRoutesOverlay: function() {
MYAPP.hideTracerOverlays();
if (MYAPP.routesOverlay) {
MYAPP.hideRoutesOverlay();
} else {
MYAPP.showRoutesOverlay();
}
},
toggleTracerOverlay: function(aLoginName) {
var tracer = GTW.getTracer(aLoginName);
tracer.toggleRouteOverlay();
},
empty: function() {
},
init: function() {
MYAPP.WEBROOT = '/' + MYAPP.APP_NAME;
MYAPP.TILE_ROOT = '/tile/' + MYAPP.APP_NAME;
GTAPP.createMap = MYAPP.createMap;
TRACER.BLINK_INTERVAL_SHOW = 1500;
TRACER.BLINK_INTERVAL_HIDE = 400;
TRACER.MARKER_OFFSET_X = 10;
TRACER.MARKER_OFFSET_Y = 10;
TRACER.SMOOTH_FACTOR = .025;
GTW.TRACER_ICON_URL = '/media/icons/';
GTW.minTracePtDist = 300;
GTAPP.createMenu = MYAPP.empty;
GTAPP.createLiveListener = MYAPP.createLiveListener;
GTAPP.doPageCommand = MYAPP.doPageCommand;
GTW.getFactory().setClassDef('Tracer', 'SailTracer');
GTW.getFactory().setClassDef('Medium', 'SailMedium');
MYAPP.MAP_INIT_CENTER = new GLatLng(53.084127, 5.824127);
POI.init = MYPOI.init;
BOAT.onShowInfo = MYBOAT.onShowInfo;
MYAPP.MAP_CENTERS['080622'] = {pt: new GLatLng(53.22486734836976,5.809565504846262), zoom: 13};
MYAPP.MAP_CENTERS['080623'] = {pt: new GLatLng(53.12626937585681,5.760039187983765), zoom: 11};
MYAPP.MAP_CENTERS['080624'] = {pt: new GLatLng(52.95020283374407,5.567428445964879), zoom: 11};
MYAPP.MAP_CENTERS['080625'] = {pt: new GLatLng(52.9764251065679,5.462908578085802), zoom: 11};
MYAPP.MAP_CENTERS['080626'] = {pt: new GLatLng(53.1270444510368,5.488778484518548), zoom: 11};
MYAPP.MAP_CENTERS['080627'] = {pt: new GLatLng(53.26124137783174,5.800499686653409), zoom: 11};
MYAPP.MAP_CENTERS['080628'] = {pt: new GLatLng(53.26204055446655,5.921994553079756), zoom: 11};
var xtraSig = '&nbsp;&nbsp;<a href="http://www.sensoruniverse.eu" target="_new" style="font:10px verdana;text-decoration:none;margin:0px;padding:2px;background: #ccc; color:#2B5D9D;">powered by Sensor Universe</a>';
GTAPP.SIG += xtraSig;
},
mShowPanel: function (name, url) {
var helpPanel = new Panel(name, '#072855', 'white');
helpPanel.setXY(60, 60);
helpPanel.setDimension(600, 400);
helpPanel.loadContent(url);
},
onQueryAllUsers: function (records) {
var tracer;
var userListHTML = '';
for (var i = 0; i < records.length; i++) {
tracer = GTW.createTracerByRecord(records[i]);
tracer.name = records[i].getField('name');
userListHTML += tracer.createStatusLine();
}
DH.setHTML('list-boat', userListHTML);
},
start: function() {
GTAPP.mode = 'live';
GW.QUERY.queryStore('q-all-users', MYAPP.onQueryAllUsers, 'role', 2);
POI.init();
POI.show();
MAR.init();
MYAPP.showRoutesOverlay();
window.setTimeout('GMAP.resize()', 3000);
},
trimString: function(value) {
value = value.replace(/^\s+/, '');
value = value.replace(/\s+$/, '');
return value;
}
}
CMT.showCommentPanel = function(aTargetId, aTargetType, aTargetName) {
if (CMT.commentPanel == null) {
CMT.commentPanel = new Panel('commentpanel', '#5e0000', 'white', null, CMT.onPanelClose);
CMT.commentPanel.setDimension(640, 500);
CMT.commentPanel.setXY(50, 50);
}
CMT.currentTarget = aTargetId + '';
CMT.currentType = aTargetType;
CMT.currentName = aTargetName;
CMT.commentPanel.show();
CMT.commentPanel.loadContent('content/comment.html');
CMT.commentPanel.setTitle('Commentaar');
CMT.displayComments();
CMT.panelOpen = true;
return false;
}
GMAP.resize = function() {
var sidebar = DH.getObject("sidebar_wrap");
var marquee = DH.getObject("bottom_interface");
DH.setObjectXYWH(GMAP.mapDiv, 0, 0, DH.getObjectX(sidebar), DH.getObjectY(marquee));
if (GMAP.map) {
GMAP.map.checkResize();
if (DH.getObject('map_overview')) {
setTimeout("GMAP.positionOverview()", 1);
}
}
}
var MYBOAT = {
onShowInfo : function() {
DH.getStyleObject('boatpopupmedia').display = 'none';
DH.getStyleObject('boatpopupinfo').display = 'block';
BOAT.mediaSet.dispose();
var tracer = GTW.getTracer(BOAT.boatName);
var record = tracer.record;
var boatColor = '&nbsp;<span style="background-color: ' + tracer.color + '">&nbsp;&nbsp;&nbsp;&nbsp;</span>&nbsp;&nbsp;';
DH.setHTML("tracerid", boatColor + BOAT.boatName);
tracer.thumbId = record.getField("iconid");
if (tracer.thumbId != null) {
tracer.thumbURL = GW.MEDIA.getBaseURL() + '?id=' + tracer.thumbId + "&resize=90x68!";
}
DH.getObject('tracerimg').src = tracer.thumbURL;
var regnr = record.getField("regnr");
if (regnr != null) {
DH.setHTML("regnr", regnr);
}
var plaats = record.getField("plaats");
if (plaats != null) {
DH.setHTML("plaats", plaats);
}
var fullName = record.getField("fullname");
if (fullName == null) {
fullName = '(onbekend)';
}
DH.setHTML("schipper", fullName);
var land = record.getField("land");
if (land != null) {
DH.setHTML("land", land);
}
var url = record.getField("url");
if (url != null) {
DH.setHTML("url", '<a target="_blanc" href="http://' + url + '" >' + url + '</a>');
}
BOAT.showLocationInfo(tracer);
}
}
var MYPOI = {
init: function() {
POI.ICONS['Boei'] = 'media/icons/boei.png';
POI.ICONS['Keerpunt'] = 'media/icons/vlag_neutral.png';
POI.ICONS['Herstart'] = 'media/icons/vlag_start.png';
POI.ICONS['Start en Finish'] = 'media/icons/vlag_start.png';
POI.ICONS['Tussenfinish'] = 'media/icons/vlag_start.png';
POI.ICONS['Finish'] = 'media/icons/vlag_finish.png';
POI.ICONS['Klunplak'] = 'media/icons/vlag_finish.png';
new Poi("Start en Finish", "Prinsentuin", 5.795226637289672,53.20524547115532,
'Start proloog zondag 22 juni<br/> Start etappe 1 naar Sneek 23 juni<br/> Finish etappe 6 vanaf Dokkum, 28 juni');
new Poi("Keerpunt", "Proloog", 5.827490917311806,53.23836052255991,
'Keerpunt Prolog zondag 22 juni');
new Poi("Start en Finish", "Sneek Waterpoort ", 5.658313947504183,53.02908127181453,
'Finish etappe 1, 23 juni<br/>Start etappe 2, 24 juni');
new Poi("Start en Finish", "Finish etappe dag 2, 24 juni, start etappe 3, 25 juni", 5.364065212690917,52.88606355922894);
new Poi("Start en Finish", "Finish etappe 3, 25 juni, start etappe 4, juni 26", 5.51987444788729,53.05961682256378);
new Poi("Tussenfinish", "Etappe 4, 26 juni", 5.424389682242023,53.17275513222194);
new Poi("Herstart", "Etappe 4, 26 juni", 5.42453466107176,53.17458550819977);
new Poi("Start en Finish", "Finish etappe 4, 26 juni, Start etappe 5, 27 juni", 5.544085330785322,53.18417067329982);
new Poi("Start en Finish", "Finish etappe 5, 27 juni, Start etappe 6, 28 jun", 5.99388741105156,53.32456540910222);
new Poi("Klunplak", "Wier", 5.630612762299634,53.25236107330824);
new Poi("Klunplak", "Oude Leije", 5.721587163894284,53.28307303984753);
}
}
var GTAPP = {
statusId: null,
mode: 'none',
mediaSelectFun: null,
defaultMode: 'live',
menu: null,
userSelector: null,
traceSelector: null,
SIG: '<a title="software by 7Scenes" href="http://7scenes.com" target="_new"><img src="media/7s-logo.png" width="75" height="25" border="0" onload="DH.fixPNG(this)" /></a>',
initialized: false,
liveListener: null,
busyIcon: null,
init: function() {
if (GTAPP.initialized == true) {
return;
}
DH.init();
GTAPP.addBusyIndicator();
GTAPP.busyOn();
GTW.boot();
MYAPP.init();
document.title = 'Please set MYAPP.WINDOW_TITLE to appear here';
if (MYAPP.WINDOW_TITLE) {
document.title = MYAPP.WINDOW_TITLE;
}
if (DH.getObject('title')) {
DH.setHTML('title', MYAPP.DOC_TITLE);
}
DH.hide(DH.getObject('help'));
GTAPP.showStatus('Initializing...');
GTAPP.createMap();
GTAPP.addSig();
GTW.init();
GTAPP.createMenu();
GTAPP.showStatus('init OK');
GMAP.resize();
DH.addEvent(window, 'resize', GMAP.resize, false);
GW.init(GTAPP.onError, 5, MYAPP.WEBROOT);
GTAPP.startEventListener();
GTAPP.doPageCommand();
GTAPP.initialized = true;
if (MYAPP.start) {
MYAPP.start();
}
GTAPP.busyOff();
GEvent.addListener(GMAP.map, "moveend", GTAPP.bboxChange);
},
startEventListener: function() {
GTAPP.createLiveListener();
GW.EVENT.start(GTAPP.onResponse, GTAPP.liveListener);
},
addSig: function() {
var id = 'gtsig';
if (!DH.getObject(id)) {
var b = document.createElement('div');
b.id = id;
b.style.position = 'absolute';
b.style.left = '30%';
b.style.bottom = '5px';
if (DH.getObject('bottom_interface') != null) {
b.style.bottom = (DH.getObjectHeight('bottom_interface') + 5) + 'px';
}
b.style.zIndex = 25600;
b.innerHTML = GTAPP.SIG;
document.body.appendChild(b);
}
},
addBusyIndicator: function() {
var id = 'busyicon';
if (!DH.getObject(id)) {
var b = document.createElement('img');
b.id = id;
b.style.position = 'absolute';
b.style.left = '30%';
b.style.top = '40%';
b.style.zIndex = 30000;
b.src = "media/loading.gif";
document.body.appendChild(b);
GTAPP.busyIcon = DH.getObject(id);
DH.hide(GTAPP.busyIcon);
DH._xhrBusy = GTAPP.busyOn;
DH._xhrReady = GTAPP.busyOff;
}
},
bboxChange: function() {
if (GTAPP.mode != 'media') {
return;
}
if (GTAPP.mediaSelectFun != null) {
GTAPP.mediaSelectFun(GTAPP.mediaSelectArg);
}
},
createLiveListener: function() {
GTAPP.liveListener = new LiveListener('livestatus');
},
createMap: function() {
alert('createMap needs to be defined in your app');
},
createMenu: function() {
DH.setHTML('menucontainer', DH.getURL('mainmenu.html'));
GTAPP.menu = new Menu('mainmenu');
},
doPageCommand: function() {
var cmd = DH.getPageParameter('cmd', null);
if (cmd == null) {
return;
}
if (cmd == 'showtrace') {
var id = DH.getPageParameter('id', null);
var tracerName = DH.getPageParameter('user', null);
if (id == null || tracerName == null) {
alert('need trace id (id) and user name (user)');
return;
}
GTAPP.showStatus('Drawing trace for user ' + tracerName);
GTAPP.onTraceSelect(id, null, tracerName);
GTW.displayTracePlayer();
GTAPP.showStatus('Trace drawn for user ' + tracerName);
return true;
} else if (cmd == 'autoplay') {
if (GTAPP.menu != null) {
GTAPP.menu.hide();
}
GTAPP.mAutoPlay();
} else if (cmd == 'live') {
var tracerName = DH.getPageParameter('user', null);
if (tracerName != null) {
GTW.followTracer = tracerName;
}
GTAPP.mLive();
} else if (cmd == 'archive') {
var tracerName = DH.getPageParameter('user', null);
if (tracerName != null) {
GTAPP.onUserSelect(null, tracerName);
}
} else {
return false;
}
},
onResponse: function(xmlElm) {
switch(xmlElm.tagName) {
case 'event-start-rsp':
GW.EVENT.subscribe(GW.onResponse, '/gt');
break;
case 'event-subscribe-rsp':
break;
default:
GTAPP.showStatus(xmlElm.tagName + ' rcvd');
break;
}
},
onError: function(id, error, details) {
alert('error response: ' + error + ' details: ' + details);
},
onQueryActiveUsers: function(records) {
GTAPP.showStatus(records.length + ' active users');
GTAPP.userSelector = new Selector('Follow User', 'usersel', GTAPP.onActiveUserSelect);
GTAPP.userSelector.hide();
for (i = 0; i < records.length; i++) {
traceId = records[i].getField('id');
traceName = records[i].getField('name');
tracerName = records[i].getField('user');
GTAPP.userSelector.addOption(traceId, tracerName + ' - ' + traceName, tracerName);
tracer = GTW.createTracerByRecord(records[i]);
if (GTW.followTracer != null && GTW.followTracer == tracerName) {
GTAPP.showStatus('following ' + tracerName + '...');
GTAPP.onActiveUserSelect(traceId, traceName, tracerName);
GTW.followTracer = null;
}
}
GTAPP.mode = 'live';
GTAPP.showMode();
var bbox = GTAPP.menu.getBBox();
GTAPP.userSelector.setXY((bbox.x + bbox.w + 40), bbox.y);
GTAPP.userSelector.show();
GTAPP.showStatus('Live Mode - ' + records.length + ' users');
},
onQueryTraces: function (records) {
GTAPP.traceSelector = new Selector('Select a Trace', 'tracesel', GTAPP.onTraceSelect);
GTAPP.traceSelector.hide();
var traceId, traceName, tracerName;
for (var i = 0; i < records.length; i++) {
traceId = records[i].getField('id');
traceName = records[i].getField('name');
tracerName = records[i].getField('user');
GTAPP.traceSelector.addOption(traceId, tracerName + ' - ' + traceName, tracerName);
}
var bbox = GTAPP.menu.getBBox();
GTAPP.traceSelector.setXY((bbox.x + bbox.w + 40), bbox.y);
GTAPP.traceSelector.show();
GTAPP.showStatus('Archive Mode - ' + records.length + ' traces');
},
onQueryAllUsers: function (records) {
GTAPP.showStatus('Got ' + records.length + ' users');
GTAPP.userSelector = new Selector('Select a User', 'usersel', GTAPP.onUserSelect);
GTAPP.userSelector.hide();
var userId, userName;
for (var i = 0; i < records.length; i++) {
userId = records[i].getField('id');
userName = records[i].getField('name');
GTAPP.userSelector.addOption(userId, userName, userName);
}
GTAPP.userSelector.setWidth(10);
var bbox = GTAPP.menu.getBBox();
GTAPP.userSelector.setXY((bbox.x + bbox.w + 40), bbox.y);
GTAPP.userSelector.show();
GTAPP.showStatus('Archive Mode - ' + records.length + ' users');
},
onQueryUserTraces: function (records) {
GTAPP.traceSelector = new Selector('Select a Trace', 'tracesel', GTAPP.onTraceSelect);
GTAPP.traceSelector.hide();
var traceId, traceName, userName;
for (var i = 0; i < records.length; i++) {
traceId = records[i].getField('id');
traceName = records[i].getField('name');
userName = records[i].getField('user');
GTAPP.traceSelector.addOption(traceId, traceName, userName);
}
var bbox = null;
if (GTAPP.userSelector && GTAPP.userSelector != null) {
bbox = GTAPP.userSelector.getBBox();
GTAPP.traceSelector.setXY((bbox.x + bbox.w + 40), bbox.y);
} else {
bbox = GTAPP.menu.getBBox();
GTAPP.traceSelector.setXY((bbox.x + bbox.w + 40), bbox.y);
}
GTAPP.traceSelector.show();
GTAPP.showStatus('Archive - user has ' + records.length + ' traces');
},
onQueryMedia: function (records) {
GTAPP.showStatus('Found ' + records.length + ' media, displaying...');
GTW.displayMedia(records);
GTAPP.showStatus('Displaying ' + records.length + ' media');
},
clearMap: function () {
GTW.clearMap();
},
hideStatus: function() {
DH.hide('status');
if (GTAPP.statusId != null) {
clearInterval(GTAPP.statusId);
GTAPP.statusId = null;
}
},
blinkStatus: function(txt) {
GTAPP.hideStatus();
DH.setHTML('status', txt);
GTAPP.statusId = setInterval(function() {
DH.toggleVisibility('status')
}, 400);
},
showMode: function() {
DH.setHTML('mode', GTAPP.mode);
},
showStatus: function(txt) {
GTAPP.hideStatus();
DH.setHTML('status', txt);
DH.show('status');
},
_deleteSelectors: function() {
if (GTAPP.traceSelector != null) {
GTAPP.traceSelector.remove();
GTAPP.traceSelector = null;
}
if (GTAPP.userSelector != null) {
GTAPP.userSelector.remove();
GTAPP.userSelector = null;
}
},
onTraceSelect: function(traceId, traceName, tracerName) {
GTAPP.clearMap();
GTW.displayTracePlayer();
var tracer = GTW.createTracer(tracerName);
tracer.readTrace(traceId, traceName, true);
tracer.show();
},
onActiveUserSelect: function(traceId, traceName, tracerName) {
var tracer = GTW.getTracer(tracerName);
if (!tracer) {
GTAPP.showStatus('no tracer for ' + tracerName);
return;
}
GTW.displayTracePlayer();
tracer.panTo();
tracer.readTrace(traceId, traceName, true);
tracer.show();
},
onUserSelect: function(userId, loginName) {
if (GTAPP.traceSelector && GTAPP.traceSelector != null) {
GTAPP.traceSelector.remove();
GTAPP.traceSelector = null;
}
var tracer = GTW.createTracer(loginName);
tracer.showInfo();
GTAPP.blinkStatus('Getting traces for ' + loginName + "...");
GW.QUERY.queryStore('q-traces-by-user', GTAPP.onQueryUserTraces, {user: loginName});
},
mAutoPlay: function() {
if (GTAPP.mode == 'autoplay') {
return;
}
GTAPP.showStatus('autoplay');
GTAPP.mode = 'autoplay';
GTAPP.showMode();
GTAPP.clearMap();
GTAPP._deleteSelectors();
GTW.startAutoPlay();
},
mArchive: function() {
if (GTAPP.mode == 'archive') {
return;
}
GTAPP.mode = 'archive';
GTAPP.showMode();
GTAPP.clearMap();
GTAPP._deleteSelectors();
GTAPP.blinkStatus('Getting all users...');
GW.QUERY.queryStore('q-all-users', GTAPP.onQueryAllUsers);
},
mLive: function(e) {
GTAPP.showMode();
if (GTAPP.mode == 'live') {
return;
}
GTAPP.liveListener.clearStatus();
GTAPP.clearMap();
GTAPP._deleteSelectors();
GTAPP.blinkStatus('Getting active users...');
GW.QUERY.queryStore('q-active-traces', GTAPP.onQueryActiveUsers);
},
mLastTraces: function(max) {
GTAPP.mode = 'traces';
GTAPP.showMode();
GTAPP.clearMap();
GTAPP._deleteSelectors();
GTAPP.blinkStatus('Getting last ' + max + ' traces...');
GW.QUERY.queryStore('q-recent-traces', GTAPP.onQueryTraces, {max: max});
},
mUserTraces: function(loginName) {
GTAPP.mode = 'traces';
GTAPP.showMode();
GTAPP.clearMap();
GTAPP._deleteSelectors();
GTAPP.blinkStatus('Getting traces for ' + loginName + "...");
GW.QUERY.queryStore('q-traces-by-user', GTAPP.onQueryUserTraces, {user: loginName});
},
mAllTraces: function() {
GTAPP.mode = 'traces';
GTAPP.showMode();
GTAPP.clearMap();
GTAPP._deleteSelectors();
GTAPP.blinkStatus('Getting all traces...');
GW.QUERY.queryStore('q-all-traces', GTAPP.onQueryTraces);
},
mMy: function() {
window.open('my', 'MyGeoTracing');
},
mWebTracer: function() {
window.open('webtracer', 'WebTracer');
},
mShowMedia: function(max) {
GTAPP.mode = 'media';
GTAPP.showMode();
GTAPP.mediaSelectFun = GTAPP.mShowMedia;
GTAPP.mediaSelectArg = max;
GTAPP.clearMap();
GTAPP._deleteSelectors();
GTAPP.blinkStatus('Getting random media...');
GW.QUERY.queryStore('q-locative-media', GTAPP.onQueryMedia, {random: true, max: max});
},
mShowRecentMedia: function(max) {
GTAPP.mode = 'media';
GTAPP.showMode();
GTAPP.mediaSelectFun = GTAPP.mShowRecentMedia;
GTAPP.mediaSelectArg = max;
GTAPP.clearMap();
GTAPP._deleteSelectors();
GTAPP.blinkStatus('Getting last ' + max + ' media...');
GW.QUERY.queryStore('q-recent-media', GTAPP.onQueryMedia, {max: max});
},
mShowRecentMediaInBbox: function(max) {
GTAPP.mode = 'media';
GTAPP.showMode();
GTAPP.mediaSelectFun = GTAPP.mShowRecentMediaInBbox;
GTAPP.mediaSelectArg = max;
GTAPP.clearMap();
GTAPP._deleteSelectors();
GTAPP.blinkStatus('Getting last ' + max + ' media in area...');
var bounds = GMAP.map.getBounds();
var bbox = bounds.getSouthWest().x + ',' + bounds.getSouthWest().y + ',' + bounds.getNorthEast().x + ',' + bounds.getNorthEast().y;
GW.QUERY.queryStore('q-recent-media', GTAPP.onQueryMedia, {max: max, bbox: bbox});
},
mShowMediaByUser: function(user) {
GTAPP.mode = 'media';
GTAPP.showMode();
GTAPP.mediaSelectFun = null;
GTAPP.clearMap();
GTAPP._deleteSelectors();
GTAPP.blinkStatus('Getting media for ' + user + '...');
GW.QUERY.queryStore('q-media-by-user', GTAPP.onQueryMedia, {user: user});
},
mShowMediaInBbox: function(max) {
GTAPP.mode = 'media';
GTAPP.showMode();
GTAPP.mediaSelectFun = GTAPP.mShowMediaInBbox;
GTAPP.mediaSelectArg = max;
GTAPP.clearMap();
GTAPP._deleteSelectors();
GTAPP.blinkStatus('Getting random media in area...');
var bounds = GMAP.map.getBounds();
var bbox = bounds.getSouthWest().x + ',' + bounds.getSouthWest().y + ',' + bounds.getNorthEast().x + ',' + bounds.getNorthEast().y;
GW.QUERY.queryStore('q-locative-media', GTAPP.onQueryMedia, {random: true, max: max, bbox: bbox});
},
mShowHelp: function(url) {
var helpPanel = new Panel('INFO', '#000044', 'white');
helpPanel.setXY(100, 100);
helpPanel.setDimension(600, 500);
helpPanel.loadContent(url);
},
mSetMap: function(type) {
GMAP.setMapType(type);
},
busyOn: function() {
if (GTAPP.busyIcon) {
DH.show(GTAPP.busyIcon);
}
},
busyOff: function() {
if (GTAPP.busyIcon) {
DH.hide(GTAPP.busyIcon);
}
}
}
DH.addEvent(window, 'load', GTAPP.init, false);
var diffpos = function(x, y) {
this.x = x;
this.y = y;
}
var diffusions = new Array(new diffpos(-5, -5), new diffpos(0, -5), new diffpos(5, -5), new diffpos(-5, 0), new diffpos(0, 0), new diffpos(5, 0), new diffpos(-5, 5), new diffpos(0, 5), new diffpos(5, 5), new diffpos(10, 5));
var TLABEL = {
SMOOTH_FACTOR: .050,
ANIMATE_INTERVAL: 150,
DEBUG: false,
G_MAP_PANE: undefined
}
function TLabel(diffuse) {
this.diffuse = false;
this.elm = null;
this.glide = false;
if (diffuse) {
this.diffuse = diffuse;
}
if (!TLABEL.G_MAP_PANE) {
TLABEL.G_MAP_PANE = G_MAP_MARKER_PANE;
GMap2.prototype.addTLabel = function(a) {
a.initialize(this);
}
GMap2.prototype.removeTLabel = function(a) {
this.getPane(TLABEL.G_MAP_PANE).removeChild(a.elm);
delete(b);
}
}
}
TLabel.prototype.debug = function(s) {
if (TLABEL.DEBUG == true) {
GLog.write(s);
}
}
TLabel.prototype.initialize = function(a) {
if (typeof(a.TLabelBugged == 'undefined')) {
this.addTBug(a);
}
this.map = a;
var b = document.createElement('span');
b.setAttribute('id', this.id);
b.innerHTML = this.content;
if (navigator.userAgent.toLowerCase().indexOf('safari') != -1) {
document.body.appendChild(b);
}
b.style.position = 'absolute';
b.style.zIndex = 25000;
if (this.percentOpacity) {
this.setOpacity(this.percentOpacity);
}
this.elm = b;
this.w = this.elm.offsetWidth;
this.h = this.elm.offsetHeight;
this.mapTray = this.map.getPane(TLABEL.G_MAP_PANE);
this.mapTray.appendChild(b);
if (!this.markerOffset) {
this.markerOffset = new GSize(0, 0);
}
this.moveToXY();
GEvent.bind(a, "moveend", this, this.forceToXY);
}
TLabel.prototype.forceToLatLng = function(aGLatLng) {
this.anchorLatLng = aGLatLng;
this.forceToXY();
}
TLabel.prototype.moveToLatLng = function(aGLatLng) {
this.anchorLatLng = aGLatLng;
this.moveToXY();
}
TLabel.prototype.forceToXY = function() {
this.getXY();
if (this.glide == true) {
this.x = this.targetX;
this.y = this.targetY;
}
this.moveElm();
}
TLabel.prototype.moveToXY = function() {
this.getXY();
if (this.glide == true) {
this.animate();
} else {
this.moveElm();
}
}
TLabel.prototype.moveElm = function() {
this.elm.style.left = this.x + 'px';
this.elm.style.top = this.y + 'px';
}
TLabel.prototype.getXY = function(a, b) {
var xy = this.map.fromLatLngToDivPixel(this.anchorLatLng)
var x = parseInt(xy.x);
var y = parseInt(xy.y);
with (Math) {
switch (this.anchorPoint) {
case 'topLeft':break;
case 'topCenter':x -= floor(this.w / 2);break;
case 'topRight':x -= this.w;break;
case 'midRight':x -= this.w;y -= floor(this.h / 2);break;
case 'bottomRight':x -= this.w;y -= this.h;break;
case 'bottomCenter':x -= floor(this.w / 2);y -= this.h;break;
case 'bottomLeft':y -= this.h;break;
case 'midLeft':y -= floor(this.h / 2);break;
case 'center':x -= floor(this.w / 2);y -= floor(this.h / 2);break;
default:break;
}
}
if (this.scaleElmId) {
var zoom = this.map.getZoom();
if (this.lastZoom && (zoom == this.lastZoom)) {
}
this.lastZoom = zoom;
var scale = Math.pow(3, (zoom / 8)) / 12;
scale = Math.max(this.minScaleFactor, scale);
var sw = Math.round(scale * this.maxW);
var sh = Math.round(scale * this.maxH);
var icon = document.getElementById(this.scaleElmId);
if (!icon) {
return;
}
icon.style.width = sw + 'px';
icon.style.height = sh + 'px';
this.markerOffset.width = sw / 2;
this.markerOffset.height = sh / 2;
}
if (this.diffuse == true) {
x = x - this.markerOffset.width + diffusions[Math.floor(Math.random() * 10)].x;
y = y - this.markerOffset.height + diffusions[Math.floor(Math.random() * 10)].y;
} else {
x = x - this.markerOffset.width;
y = y - this.markerOffset.height;
}
if (this.glide == true) {
this.targetX = x;
this.targetY = y;
if (!this.x) {
this.x = x;
this.y = y;
}
} else {
this.x = x;
this.y = y;
}
xy.x = x;
xy.y = y;
return xy;
}
TLabel.prototype.setScaling = function(aScaleElmId, aMaxW, aMaxH, aMinScaleFactor) {
this.scaleElmId = aScaleElmId;
this.maxW = aMaxW;
this.maxH = aMaxH;
this.minScaleFactor = .3;
if (aMinScaleFactor) {
this.minScaleFactor = aMinScaleFactor;
}
}
TLabel.prototype.animate = function(show) {
var obj = this;
this.debug('animate enter');
if (!this.animating || this.animating == null) {
this.debug('start animation');
this.animating = window.setInterval(function() {
obj.glideElm()
}, TLABEL.ANIMATE_INTERVAL);
}
}
TLabel.prototype.glideElm = function() {
var diffX = Math.abs(this.targetX - this.x);
var diffY = Math.abs(this.targetY - this.y);
if (diffX <= 1 && diffY <= 1) {
if (this.animating) {
this.debug('stop animation');
window.clearTimeout(this.animating);
this.animating = null;
}
this.moveElm();
return;
}
var deltaX = TLABEL.SMOOTH_FACTOR * (this.targetX - this.x);
var deltaY = TLABEL.SMOOTH_FACTOR * (this.targetY - this.y);
if (Math.abs(deltaX) <= 1 && Math.abs(deltaY) <= 1) {
deltaX = deltaX < 0 ? -1.0 : 1.0;
deltaY = deltaY < 0 ? -1.0 : 1.0;
}
this.x = this.x + deltaX;
this.y = this.y + deltaY;
this.x = Math.round(this.x);
this.y = Math.round(this.y);
this.moveElm();
}
TLabel.prototype.setOpacity = function(b) {
if (b < 0) {
b = 0;
}
if (b > 100) {
b = 100;
}
var c = b / 100;
var d = this.elm;
if (typeof(d.style.filter) == 'string') {
d.style.filter = 'alpha(opacity:' + b + ')';
}
if (typeof(d.style.KHTMLOpacity) == 'string') {
d.style.KHTMLOpacity = c;
}
if (typeof(d.style.MozOpacity) == 'string') {
d.style.MozOpacity = c;
}
if (typeof(d.style.opacity) == 'string') {
d.style.opacity = c;
}
}
TLabel.prototype.addTBug = function(a) {
if (typeof(a.TLabelBugged) == 'undefined') {
var b = document.createElement('div');
b.id = 'TLabelBug';
b.style.position = 'absolute';
b.style.right = '0px';
if (a.TBugged > 0) {
b.style.bottom = '32px';
} else {
b.style.bottom = '20px';
}
b.style.backgroundColor = '#f2efe9';
b.style.zIndex = 25500;
b.innerHTML = '<a href="http://gmaps.tommangan.us/tlabel.html" style="font:10px verdana;text-decoration:none;margin:0px;padding:2px;color:#000;">Made with TLabel</a>';
document.getElementById(a.getContainer().id).appendChild(b);
var c = 0.7;
var d = document.getElementById(b.id);
if (typeof(d.style.filter) == 'string') {
d.style.filter = 'alpha(opacity:' + c * 100 + ')';
}
if (typeof(d.style.KHTMLOpacity) == 'string') {
d.style.KHTMLOpacity = c;
}
if (typeof(d.style.MozOpacity) == 'string') {
d.style.MozOpacity = c;
}
if (typeof(d.style.opacity) == 'string') {
d.style.opacity = c;
}
a.TLabelBugged = 1;
}
}
var LIVE_STATS = new Array('-','-','-','-','-','-','-','-');
var LIVE_TIMES = new Array('-','-','-','-','-','-','-','-');
function SailLiveListener(aStatusElm) {
LiveListener.apply(this, new Array(aStatusElm));
this.clearStatus = function() {
}
this.onCommentAdd = function(event) {
var type = event.getAttribute('type');
var what = type == 1 ? ' reactie' : 'nieuws';
var author = event.getAttribute('author');
if (author == null) {
author = 'anoniem';
}
this.showStatus(author, 'stuurt ' + what);
MAR.onCommentAdd(event.getAttribute('id'), type);
}
this.onHeartbeat = function(tracer, event) {
}
this.showStatus = function(name, aMsg) {
var date = new Date();
var dateStr = date.format("HH:mm");
var time = '[' + dateStr + ']';
var msg = name + ' - ' + aMsg;
LIVE_TIMES[7] = LIVE_TIMES[6];
LIVE_TIMES[6] = LIVE_TIMES[5];
LIVE_TIMES[5] = LIVE_TIMES[4];
LIVE_TIMES[4] = LIVE_TIMES[3];
LIVE_TIMES[3] = LIVE_TIMES[2];
LIVE_TIMES[2] = LIVE_TIMES[1];
LIVE_TIMES[1] = LIVE_TIMES[0];
LIVE_TIMES[0] = time;
LIVE_STATS[7] = LIVE_STATS[6];
LIVE_STATS[6] = LIVE_STATS[5];
LIVE_STATS[5] = LIVE_STATS[4];
LIVE_STATS[4] = LIVE_STATS[3];
LIVE_STATS[3] = LIVE_STATS[2];
LIVE_STATS[2] = LIVE_STATS[1];
LIVE_STATS[1] = LIVE_STATS[0];
LIVE_STATS[0] = msg;
for (var i=0; i < LIVE_STATS.length; i++) {
DH.setHTML('livestatus' + i, LIVE_STATS[i]);
DH.setHTML('livetime' + i, LIVE_TIMES[i]);
if (i == 0) {
DH.blink('livestatus' + i, 4, 150);
}
}
}
this.onTraceCreate = function(tracer, event) {
}
this.onTraceDelete = function(tracer, event) {
}
this.onTraceSuspend = function(tracer, event) {
}
this.onTraceResume = function(tracer, event) {
}
this.onPOIAdd = function(tracer, event) {
}
this.onMediumAdd = function(tracer, event) {
var medium = GTW.createMedium(event.getAttribute('id'),
event.getAttribute('name'),
'live upload by ' + tracer.name,
event.getAttribute('kind'),
event.getAttribute('mime'),
event.getAttribute('time'),
event.getAttribute('lon'),
event.getAttribute('lat'));
medium.userName = tracer.name;
this.showStatus(tracer.name, 'stuurt ' + event.getAttribute('kind'));
MAR.onMediumAdd(medium);
}
this.onMove = function(tracer, event) {
tracer.setLive();
if (tracer.activeTrace == null) {
tracer.newTrace(event.getAttribute('traceid'), event.getAttribute('tracename'));
tracer.show();
}
tracer.move(event.getAttribute('lon'), event.getAttribute('lat'), event.getAttribute('t'), event.getAttribute('icon'));
var tracerLink = '<a href="#" onclick="MYAPP.showUserDetails(\'' + tracer.name + '\')" name="meer info over boot" title="bekijk meer info over deze boot">' + tracer.name + '</a>';
this.showStatus(tracerLink, tracer.speed + ' mph - ' + tracer.courseStr);
BOAT.onMove(tracer);
}
}
var COURSES_NL = new Array('N', 'NO', 'O', 'ZO', 'Z', 'ZW', 'W', 'NW', 'N');
function SailTracer(name, color, iconURL, pt, time) {
Tracer.apply(this, new Array(name, color, iconURL, pt, time));
this.course = 0;
this.courseStr = '-';
this.speed = 0;
this.routeOverlay = undefined;
this.moveMode = 0;
this.newMoveMode = 0;
this.createTLabel = function () {
this.color = MYAPP.trimString(this.color);
this.iconId = 'icon' + this.id;
var iconPath = this.getIconPath('N');
var html = '<a href="#" title="' + this.name + '" ><img border="0" id="' + this.iconId + '" src="' + iconPath + '" onload="DH.fixPNG(this)" /></a>';
var tl = new TLabel();
tl.glide = true;
tl.id = 'trclab' + this.id;
tl.anchorLatLng = this.point;
tl.anchorPoint = 'topLeft';
tl.content = html;
tl.setScaling(this.iconId, 45, 45, .3);
tl.markerOffset = new GSize(20, 20);
return tl;
}
this.followToggle = function () {
var linkElm = DH.getObject('follow' + this.id)
if (this.isFollowed()) {
TRACER.follow = null;
linkElm.className = 'boat-option';
linkElm.innerHTML = 'volg';
} else {
if (TRACER.follow && TRACER.follow != null) {
var t = DH.getObject('follow' + TRACER.follow.id)
t.innerHTML = 'volg';
t.className = 'boat-option';
}
this.zoomTo();
TRACER.follow = this;
linkElm.className = 'boat-option-selected';
linkElm.innerHTML = 'stop';
}
}
this.createStatusLine = function() {
var id = this.id;
var displayName = this.name;
var maxNameLen = 13;
if (displayName.length > maxNameLen) {
displayName = displayName.substring(0, maxNameLen - 2) + '..';
}
var div = '<li><a id="user' + id + '" href="#" onclick="MYAPP.showUserDetails(\'' + this.name + '\'); return false;" name="meer info over boot" title="bekijk meer info over deze boot">';
div += '<span class="boat-color" id="color' + id + '" style="background-color: ' + this.color + '">&nbsp;&nbsp;&nbsp;&nbsp;</span>';
div += '<span class="boat-name">' + displayName + '</span>';
div += '<span class="boat-kmh" id="speed' + id + '">0 mph</span>';
div += '<span class="boat-direction" id="course' + id + '">-</span>';
div += '</a>';
div += '<a id="route' + id + '" class="boat-option" href="#" onclick="MYAPP.toggleTracerOverlay(\'' + this.name + '\')" name="teken route van boot op de kaart" title="teken route van boot op de kaart">route</a>';
div += '<a id="follow' + id + '" class="boat-option" href="#" onclick="MYAPP.followBoat(\'' + this.name + '\')" name="zoom in en volg boot op de kaart" title="zoom in en volg boot op de kaart">volg</a></li>';
return div;
}
this.getIconPath = function(aCourseStr) {
var path = GTW.TRACER_ICON_URL;
var colorStr = this.color.substring(1, 7);
if (this.moveMode > 1) {
path += 'land/' + colorStr + '/land-' + colorStr + '-' + aCourseStr + '.png';
} else {
path += 'boten/' + colorStr + '/boot-' + colorStr + '-' + aCourseStr + '.png';
}
if (this.name.indexOf('Rabo') != -1 && ((this.course % 8 == 0) || this.moveMode > 1)) {
path = GTW.TRACER_ICON_URL + 'land/rabo.png';
}
return path;
}
this.isFollowed = function () {
return (TRACER.follow && TRACER.follow == this) ? true : false;
}
this.move = function(lon, lat, time, moveMode) {
pt = new GLatLng(lat, lon);
if (time) {
pt.time = new Number(time);
}
if (moveMode) {
this.newMoveMode = new Number(moveMode);
}
this.setLocation(pt);
this.speed = 0.00;
if (this.point != null && this.lastPoint != null) {
this.speed = GMAP.speed(this.lastPoint, this.point);
this.speed = (this.speed/1.85200).toFixed(2);
}
this.showLiveInfo();
if (this.isFollowed() == true) {
if (this.activeTrace != null) {
this.activeTrace.addLivePoint(pt);
}
this.panTo();
}
}
this.moveModeChanged = function() {
return this.newMoveMode != this.moveMode;
}
this.openInfoWindow = function() {
}
this.popupInfoWindow = function() {
BOAT.show(this.name);
}
this.panTo = function () {
if (this.point != null) {
GMAP.map.panTo(this.point);
}
}
this.showInfo = function() {
TRACER.current = this;
if (this.record != null && this.record != -1) {
this._showInfo();
return;
}
this._queryInfo();
}
this.showLiveInfo = function() {
this.showInfo();
var statusVisible = (DH.getObject('user' + this.id) != null);
if (statusVisible) {
DH.blink('color' + this.id, 6, 250);
}
if (this.point != null && this.lastPoint != null) {
var oldCourseIndex = Math.round(this.course / 45);
this.course = GMAP.heading(this.lastPoint.lat(), this.lastPoint.lng(), this.point.lat(), this.point.lng());
var courseIndex = Math.round(this.course / 45);
this.courseStr = COURSES_NL[courseIndex];
if (oldCourseIndex != courseIndex || this.moveModeChanged()) {
if (this.moveModeChanged()) {
this.moveMode = this.newMoveMode;
}
var iconSrc = this.getIconPath(this.courseStr);
DH.getObject(this.iconId).src = iconSrc;
DH.fixPNG(DH.getObject(this.iconId));
}
if (this.speed > 1000) {
this.speed /= 100;
}
if (this.speed > 200) {
this.speed /= 10;
}
if (statusVisible) {
DH.getObject('speed' + this.id).innerHTML = Math.round(this.speed) + ' mph';
DH.getObject('course' + this.id).innerHTML = this.courseStr;
}
}
}
this.showRouteOverlay = function() {
if (this.routeOverlay) {
return;
}
var self = this;
var tileLayer = new GTileLayer(new GCopyrightCollection(), 8, 16);
tileLayer.getTileUrl = function(tile, zoom) {
return MYAPP.TILE_ROOT + '/' + zoom + '/' + tile.x + '/' + tile.y + '/' + self.name + '.png?t=' + new Date().getTime();
}
tileLayer.isPng = function() {
return true;
}
tileLayer.getOpacity = function() {
return 1.0;
}
this.routeOverlay = new GTileLayerOverlay(tileLayer);
GMAP.map.addOverlay(this.routeOverlay);
var linkElm = DH.getObject('route' + this.id);
linkElm.className = 'boat-option-selected';
linkElm.innerHTML = 'wis';
}
this.hideRouteOverlay = function() {
if (this.routeOverlay) {
GMAP.map.removeOverlay(this.routeOverlay);
this.routeOverlay = undefined;
var linkElm = DH.getObject('route' + this.id);
linkElm.className = 'boat-option';
linkElm.innerHTML = 'route';
}
}
this.toggleRouteOverlay = function() {
if (this.routeOverlay) {
this.hideRouteOverlay()
} else {
this.showRouteOverlay();
}
}
this.zoomTo = function () {
if (this.point != null) {
var zoom = GMAP.map.getZoom();
zoom = (zoom > 13) ? zoom : 13;
GMAP.map.setZoom(zoom);
GMAP.map.panTo(this.point);
}
}
this._showInfo = function() {
if (TRACER.current != this && this.record != null && this.record != -1) {
return;
}
var desc = this.record.getField('desc');
if (desc == null) {
desc = ' ';
}
if (CMT.isCommentPanelOpen() == true) {
}
}
}
function SailMedium(id, name, desc, type, mime, time, lon, lat) {
if (!desc) {
desc = '&nbsp;';
}
Medium.apply(this, new Array(id, name, desc, type, mime, time, lon, lat));
if (!this.gLatLng) {
this.gLatLng = GMAP.map.getCenter();
}
this.bgColor = '#FF0000';
if (this.type == 'video') {
this.bgColor = '#FFFF00';
} else if (this.type == 'audio') {
this.bgColor = '#0081FF';
}
this.getBGColor = function() {
return this.bgColor;
}
this.getIconDiv = function() {
if (this.type == 'image') {
return '<a href="#" title="' + this.name + '"><img id="' + this.iconId + '" src="media/icons/foto.png"  border="0" onload="DH.fixPNG(this)" /></a>';
} else if (this.type == 'video') {
return '<a href="#" title="' + this.name + '"><img id="' + this.iconId + '" src="media/icons/video.png"  border="0" onload="DH.fixPNG(this)" /></a>';
} else if (this.type == 'audio') {
return '<div class="medicon" id="' + this.iconId + '" style="background-color:' + this.getBGColor() + ';" >&nbsp;&nbsp;&nbsp;&nbsp;</div>';
}
}
this.display = function() {
if (!this.userName || this.userName == null) {
return;
}
if (BOAT.boatName != null && BOAT.boatName == this.userName) {
this._displayTitle();
this._displayInfo();
this._displayPreview();
this._displayDescr();
}
}
this.show = function() {
if (this.getGLatLng() == null) {
return;
}
var tl = new TLabel(false);
tl.id = 'tlab' + this.id;
tl.anchorLatLng = this.getGLatLng();
tl.anchorPoint = 'topLeft';
tl.content = this.getIconDiv();
tl.setScaling(this.iconId, 48, 48, .3);
tl.markerOffset = new GSize(24, 24);
GMAP.map.addTLabel(tl);
this.tlabel = tl;
var self = this;
this.onClickIcon = function (e) {
self.openInfoWindow();
DH.cancelEvent(e);
}
this.onMouseOverIcon = function (e) {
DH.cancelEvent(e);
}
DH.addEvent(this.tlabel.elm, 'mouseover', this.onMouseOverIcon, false);
DH.addEvent(this.tlabel.elm, 'click', this.onClickIcon, false);
}
this.openInfoWindow = function() {
if (!this.userName) {
this.userName = 'Grutte Pier';
}
var contentHTML;
if (this.type == 'image') {
var src = this.url + '&resize=280x210';
contentHTML = '<p><img width="280" height="210" id="' + this.previewId + '" title="" src="' + src + '" border="0" /></p>';
} else if (this.type == 'video') {
this.url = GW.MEDIA.getBaseURL() + '%3Fid=' + this.id;
contentHTML = '<p id="jwplayer"><a href="http://www.macromedia.com/go/getflashplayer">Get the Flash Player</a> to see this player.</p>';
} else if (this.type == 'audio') {
this.url = GW.MEDIA.getBaseURL() + '%3Fid=' + this.id;
contentHTML = '<p id="jwplayer"><a href="http://www.macromedia.com/go/getflashplayer">Get the Flash Player</a> to see this player.</p>';
}
var html = '<div style="width:320px"><p><b>' + this.name + '</b></p>' + contentHTML + '<p>' + this.userName + ' - ' + this.getDate() + '</p><p><i>'+ this.desc +'</i></p><p>&nbsp;</p></div>';
GMAP.map.openInfoWindowHtml(this.getGLatLng(), html);
GMAP.map.panTo(this.getGLatLng());
var s1;
if (this.type == 'video') {
s1 = new SWFObject(DH.getBaseDir() + '/mediaplayer.swf',"single","320","240","7");
s1.addParam("allowfullscreen","true");
s1.addVariable("file", this.url + '%26format=flv');
s1.addVariable("image", this.url + '%26format=jpg');
s1.addVariable("type", "flv");
s1.addVariable("width","320");
s1.addVariable("height","240");
s1.write("jwplayer");
} else if (this.type == 'audio') {
s1 = new SWFObject(DH.getBaseDir() + '/mediaplayer.swf',"single","160","120","7");
s1.addParam("allowfullscreen","true");
s1.addVariable("file", this.url);
s1.addVariable("image", "media/audioicon.jpg");
s1.addVariable("type", "mp3");
s1.addVariable("width","160");
s1.addVariable("height","120");
s1.write("jwplayer");
}
}
this._displayInfo = function() {
DH.setHTML('featureinfo', this.getDate());
}
}
var POI = {
pois: new Array(),
ICONS: [],
init: function() {
POI.ICONS['Boei'] = 'media/icons/boei.png';
POI.ICONS['Neutral'] = 'media/icons/vlag_neutral.png';
POI.ICONS['Haveningang'] = POI.ICONS['Neutral'] ;
POI.ICONS['Start'] = 'media/icons/vlag_start.png';
POI.ICONS['Finish'] = 'media/icons/vlag_finish.png';
new Poi("Boei", "KZ1", 5.333863333333333, 53.08188833333333);
new Poi("Boei", "BO7", 5.326841666666667, 53.081495);
new Poi("Boei", "BO1", 5.303786666666666, 53.08134666666667);
new Poi("Boei", "D20", 5.2595616666666665, 53.06307);
new Poi("Boei", "D8", 5.139278333333333, 53.03785333333333);
new Poi("Boei", "D2", 5.058933333333333, 53.04246666666667);
new Poi("Boei", "T27", 4.990338333333334, 53.06007833333334);
new Poi("Boei", "T23", 4.9309, 53.06007833333334);
new Poi("Boei", "OS1", 4.8611716666666664, 53.0388);
new Poi("Boei", "SO2", 5.025366666666667, 53.06272);
new Poi("Boei", "SO4", 5.047475, 53.06265333333333);
new Poi("Boei", "SO14", 5.120205, 53.085211666666666);
new Poi("Boei", "SO22", 5.179128333333333, 53.09179666666667);
new Poi("Boei", "SO34", 5.175445, 53.12715);
new Poi("Boei", "SO48", 5.164075, 53.15372833333333);
new Poi("Boei", "IN17/SO56", 5.1857283333333335, 53.16486333333334);
new Poi("Boei", "IN10", 5.147903333333334, 53.19921333333333);
new Poi("Boei", "VL5", 5.1650833333333335, 53.3064);
new Poi("Boei", "VL1", 5.146983333333333, 53.31647);
new Poi("Boei", "ZS13", 5.121861666666667, 53.31462);
new Poi("Boei", "ZS11/VS2", 5.099305, 53.31088);
new Poi("Boei", "VS6", 5.106995, 53.30506166666667);
new Poi("Boei", "VS14", 5.093616666666667, 53.293038333333335);
new Poi("Boei", "BS2", 5.178886666666667, 53.26657);
new Poi("Boei", "BS4", 5.1776333333333335, 53.24643833333333);
new Poi("Boei", "BS6", 5.18958, 53.237696666666665);
new Poi("Boei", "BS8", 5.20645, 53.233455);
new Poi("Boei", "BS11", 5.259925, 53.229753333333335);
new Poi("Boei", "BS13", 5.285846666666667, 53.222408333333334);
new Poi("Boei", "BS20", 5.306925, 53.19933);
new Poi("Boei", "BO44", 5.39805, 53.17675833333333);
new Poi("Boei", "VL8/WM1", 5.1843216666666665, 53.28971333333333);
new Poi("Boei", "WM6", 5.235713333333333, 53.301786666666665);
new Poi("Boei", "NM4/S21", 5.2575, 53.31699666666667);
new Poi("Boei", "SG15/S2", 5.195188333333333, 53.34153666666667);
new Poi("Boei", "BO18", 5.37108, 53.10505333333333);
new Poi("Boei", "BO9/KZ2", 5.338236666666667, 53.083666666666666);
new Poi("Haveningang", "Terschelling", 5.219, 53.35435);
new Poi("Finish", "Hindelopen", 5.402408838272095, 52.9452439138168);
new Poi("Start", "Stavoren", 5.353083333333333, 52.88625);
new Poi("Haveningang", "Vlieland", 5.091333333333333, 53.295833333333334);
new Poi("Haveningang", "Harlingen", 5.403833333333333, 53.17658333333333);
new Poi("Haveningang", "Texel-Waddenhaven/Oudeschild", 4.852983333333333, 53.03908333333333);
new Poi("Neutral", "Kornwerderzand", 5.3341666666666665, 53.07866666666666);
},
show: function() {
for (var i = 0; i < POI.pois.length; i++) {
POI.pois[i].show();
}
},
hide: function() {
for (var i = 0; i < POI.pois.length; i++) {
POI.pois[i].hide();
}
}
}
function Poi(type, name, lon, lat, desc) {
this.name = name;
this.type = type;
this.point = new GLatLng(lat, lon);
this.tlabel = null;
this.iconId = 'poiimg' + name;
this.desc = ' ';
if (desc) {
this.desc = '<br/>' + desc;
}
POI.pois.push(this);
this.getIconPath = function() {
return POI.ICONS[this.type];
}
this.show = function() {
var tl = new TLabel(false);
tl.id = 'poi' + this.name;
tl.anchorLatLng = this.point;
tl.anchorPoint = 'topLeft';
tl.content = '<a href="#" title="' + this.type + ' - ' + this.name + '" ><img border="0" id="' + this.iconId + '" src="' + this.getIconPath() + '" onload="DH.fixPNG(this)" /></a>';
tl.markerOffset = new GSize(5, 5);
tl.setScaling(this.iconId, 25, 25, .3);
GMAP.map.addTLabel(tl);
this.tlabel = tl;
var poi = this;
this.onClickIcon = function (e) {
poi.openInfoWindow();
}
DH.addEvent(this.tlabel.elm, 'click', this.onClickIcon, false);
}
this.hide = function() {
if (this.tlabel == null) {
return;
}
GMAP.map.removeTLabel(this.tlabel);
this.tlabel = null;
}
this.openInfoWindow = function() {
var html = this.type + " <b>" + this.name + "</b>" + this.desc + "<br/>lon,lat =  " + this.point.lng().toFixed(6) + ', ' + this.point.lat().toFixed(5) + ' (DD)';
GMAP.map.openInfoWindowHtml(this.point, html);
}
}
var BOAT = {
panel: null,
boatName: null,
panelOpen: false,
initContent: null,
mediaPlayer: null,
mediaSet: new FeatureSet(),
isCommentPanelOpen: function() {
return BOAT.panelOpen;
},
onMove: function(tracer) {
if (tracer.name != BOAT.boatName) {
return;
}
BOAT.showLocationInfo(tracer);
},
onPanelClose: function() {
BOAT.panelOpen = false;
BOAT.panel.hide();
BOAT.boatName = null;
},
onShowMedia: function() {
DH.getStyleObject('boatpopupinfo').display = 'none';
DH.getStyleObject('boatpopupmedia').display = 'block';
var records = GW.QUERY.queryStore("q-media-by-user", null, "user", BOAT.boatName);
BOAT.mediaSet.dispose();
BOAT.mediaSet.addMedia(records);
for (var i = 0; i < BOAT.mediaSet.features.length; i++) {
if (BOAT.mediaSet.features[i]) {
BOAT.mediaSet.features[i].userName = BOAT.boatName;
}
}
BOAT.mediaSet.show();
BOAT.mediaPlayer.setFeatureSet(BOAT.mediaSet);
if (records.length > 0) {
var tracer = GTW.getTracer(BOAT.boatName);
if (tracer.activeTrace != null) {
tracer.activeTrace.featureSet.dispose();
}
BOAT.mediaSet.displayFirst();
}
DH.setHTML("mediacount", '(' + records.length + ')');
},
onShowInfo: function() {
DH.getStyleObject('boatpopupmedia').display = 'none';
DH.getStyleObject('boatpopupinfo').display = 'block';
BOAT.mediaSet.dispose();
var tracer = GTW.getTracer(BOAT.boatName);
var record = tracer.record;
var boatColor = '&nbsp;<span style="background-color: ' + tracer.color + '">&nbsp;&nbsp;&nbsp;&nbsp;</span>&nbsp;&nbsp;';
DH.setHTML("tracerid", boatColor + BOAT.boatName);
tracer.thumbId = record.getField("iconid");
if (tracer.thumbId != null) {
tracer.thumbURL = GW.MEDIA.getBaseURL() + '?id=' + tracer.thumbId + "&resize=90x68!";
}
DH.getObject('tracerimg').src = tracer.thumbURL;
var slogan = record.getField("slogan");
if (slogan != null) {
DH.setHTML("slogan", slogan);
}
var bootType = record.getField("boot");
if (bootType != null) {
DH.setHTML("boottype", bootType);
}
var regnr = record.getField("regnr");
if (regnr != null) {
DH.setHTML("regnr", regnr);
}
var thuishaven = record.getField("thuishaven");
if (thuishaven != null) {
DH.setHTML("thuishaven", thuishaven);
}
var fullName = record.getField("fullname");
if (fullName == null) {
fullName = '(onbekend)';
}
DH.setHTML("schipper", fullName);
var crewlid1 = record.getField("crewlid1");
if (crewlid1 != null) {
DH.setHTML("crewlid1", crewlid1);
}
var crewlid2 = record.getField("crewlid2");
if (crewlid2 != null) {
DH.setHTML("crewlid2", crewlid2);
}
var fietser = record.getField("fietser");
if (fietser != null) {
DH.setHTML("fietser", fietser);
}
var hardloper = record.getField("hardloper");
if (hardloper != null) {
DH.setHTML("hardloper", hardloper);
}
var url = record.getField("url");
if (url != null) {
DH.setHTML("url", '<a target="_blanc" href="http://' + url + '" >' + url + '</a>');
}
BOAT.showLocationInfo(tracer);
},
show: function(aBoatName) {
if (BOAT.panel == null) {
BOAT.panel = new Panel(aBoatName, '#444444', 'white', null, BOAT.onPanelClose);
BOAT.panel.setXY(200, 100);
BOAT.panel.setDimension(330, 400);
BOAT.initContent = DH.getURL('content/boat.html');
}
BOAT.boatName = aBoatName;
BOAT.panel.setTitle(aBoatName);
BOAT.panel.setContent(BOAT.initContent);
BOAT.mediaPlayer = new FeaturePlayer();
BOAT.panel.show();
BOAT.panelOpen = true;
BOAT.mediaSet.dispose();
var tracer = GTW.getTracer(BOAT.boatName);
if (tracer.record == null) {
var records = GW.QUERY.queryStore("q-user-info", null, "user", BOAT.boatName);
tracer.record = records[0];
}
BOAT.onShowInfo();
return false;
},
showLocationInfo: function(tracer) {
var location = tracer.getLocation();
if (!location || location == null) {
if (tracer.record != null && tracer.record.getField("lon") != null) {
location = new GLatLng(tracer.record.getField("lat"), tracer.record.getField("lon"));
location.time = new Number(tracer.record.getField("lonlattime"));
}
}
if (!location || location == null) {
return;
}
DH.setHTML("tracerloc", location.lng() + ', ' + location.lat());
DH.setHTML("tracerlocdate", '(niet bekend)');
if (location.time) {
var lonLatTime = new Number(location.time);
var date = new Date(lonLatTime);
DH.setHTML("tracerlocdate", date.format("DDD D MMM YYYY HH:mm:ss"));
}
DH.setHTML("tracerspeed", '-');
DH.setHTML("tracercourse", '-');
if (tracer.speed) {
DH.setHTML("tracerspeed", tracer.speed + ' mph');
}
if (tracer.course) {
DH.setHTML("tracercourse", Math.round(tracer.course) + ' ~ ' + tracer.courseStr);
}
}
}
var MAR = {
newsHeadings:  null,
reactionsHeadings: null,
reactionsHeadingsRecords: null,
newsSet: null,
mediaSet: null,
DATE_FORMAT: 'HH:mm',
MAX_MEDIA_HEADINGS: 6,
MAX_HEADING_LINES: 3,
MAX_HEADING_CHARS: 150,
MAX_REACTIONS_DISPLAY: 200,
LAST_REACTIONS_COUNT: 0,
reactFormPanel: null,
reactionsPanel: null,
mediaPanel: null,
oldestMediumDate: 0,
newestMediumDate: 2000000000000,
mediumPage: 1,
init: function() {
MAR.newsHeadings = DH.getObject('newsheads');
MAR.reactionsHeadings = DH.getObject('reactheads');
MAR.refreshCommentHeadings();
MAR.refreshMediaHeadings();
},
onMediumAdd: function(medium) {
if (!MAR.mediaSet) {
MAR.mediaSet = new FeatureSet();
}
medium.show();
medium.blink(20);
MAR.mediaSet.addFeature(medium);
MAR.refreshMediaHeadings();
},
nextMediaHeadings: function() {
DH.setHTML('mediaheadsL', 'media ophalen...');
DH.setHTML('mediaheadsR', ' ');
MAR.mediumPage++;
GW.QUERY.queryStore('q-recent-media', MAR.onLoadMediaHeadings, 'max', MAR.MAX_MEDIA_HEADINGS, 'before', MAR.oldestMediumDate);
return false;
},
prevMediaHeadings: function() {
if (MAR.mediumPage == 1) {
alert('je bent al op eerste pagina');
return false;
}
DH.setHTML('mediaheadsL', 'media ophalen...');
DH.setHTML('mediaheadsR', ' ');
MAR.mediumPage--;
GW.QUERY.queryStore('q-recent-media', MAR.onLoadMediaHeadings, 'max', MAR.MAX_MEDIA_HEADINGS, 'after', MAR.newestMediumDate);
return false;
},
refreshMediaHeadings: function() {
DH.setHTML('mediaheadsL', 'media ophalen...');
DH.setHTML('mediaheadsR', ' ');
GW.QUERY.queryStore('q-recent-media', MAR.onLoadMediaHeadings, 'max', MAR.MAX_MEDIA_HEADINGS);
},
onLoadMediaHeadings: function(records) {
DH.show('mediaprevbut');
DH.show('medianextbut');
if (MAR.mediumPage == 1) {
DH.hide('mediaprevbut');
}
if (records.length < MAR.MAX_MEDIA_HEADINGS) {
DH.hide('medianextbut');
}
if (records.length == 0) {
DH.setHTML('mediaheadsL', 'geen media gevonden')
DH.setHTML('mediaheadsR', ' ');
DH.setHTML('mediapage', ' ');
if (MAR.mediumPage > 1) {
MAR.mediumPage--;
}
return;
}
DH.setHTML('mediaheadsR', ' ');
DH.setHTML('mediaheadsL', ' ');
DH.setHTML('mediapage', 'pag ' + MAR.mediumPage);
var title, user, kind, ref, date, rec, id, url, wh_attrs;
var mediaLines = '';
for (var i = 0; i < records.length; i++) {
rec = records[i];
date = new Date(new Number(rec.getField('creationdate')));
title = rec.getField('name');
user = rec.getField('user');
id = rec.getField('id');
kind = rec.getField('kind');
ref = rec.getField('ref');
wh_attrs = ' ';
url = GW.MEDIA.getBaseURL() + '?id=' + id + '&resize=40x30!&format=jpg';
if (kind == 'video') {
if (ref != null) {
url = 'media/videoicon.png'
}
wh_attrs = 'width="40" height="30"'
} else if (kind == 'audio') {
url = 'media/audioicon.jpg'
wh_attrs = 'width="30" height="30"'
}
mediaLines += '<a href="#" class="item" onclick="MAR.showMediumPopup(\'' + id + '\')"><img src="' + url + '" ' + wh_attrs + ' />';
mediaLines += '<p class="time">' + date.format(MAR.DATE_FORMAT) + '</p>';
mediaLines += '<p class="name">' + user + '</p>';
mediaLines += '<p class="text">' + kind + '</p>';
mediaLines += '</a>';
if (i == 2) {
DH.setHTML('mediaheadsL', mediaLines);
mediaLines = '';
}
}
MAR.newestMediumDate = records[0].getField('creationdate');
MAR.oldestMediumDate = records[records.length - 1].getField('creationdate');
if (records.length > 3) {
DH.setHTML('mediaheadsR', mediaLines);
} else {
DH.setHTML('mediaheadsL', mediaLines);
}
},
toggleMediaOnMap: function() {
var mediaToggle = DH.getObject('mediatoggle');
if (MAR.mediaSet) {
MAR.mediaSet.dispose();
MAR.mediaSet = null;
mediaToggle.className = 'show_on_map';
return;
}
mediaToggle.className = 'show_on_map_checked';
GW.QUERY.queryStore('q-locative-media', MAR.onQueryLocativeMedia);
return false;
},
onQueryLocativeMedia: function(records) {
MAR.mediaSet = new FeatureSet();
MAR.mediaSet.addMedia(records);
MAR.mediaSet.show();
},
showMediumPopup: function(mediumId) {
GW.QUERY.queryStore('q-medium-info', MAR.onQueryMediumInfo, 'id', mediumId);
return false;
},
onQueryMediumInfo: function(records) {
if (records.length == 0) {
alert('no medium info found');
return;
}
var medium = GTW.createMediumByRecord(records[0]);
medium.openInfoWindow();
},
onMediaPanelClose: function() {
},
addReaction: function() {
var reactForm = DH.getObject('reactform');
if (!reactForm.content.value) {
alert('je bent vergeten iets in te tikken ! of je hebt te snel geklikt. vul in wat je wilt zeggen en probeer opnieuw');
return;
}
if (!reactForm.name.value) {
alert('je bent vergeten je naam op te geven ! of je hebt te snel geklikt, vul je/een naam in en probeer nogmaals.');
return;
}
if (!MAR.reactAuthor) {
MAR.reactAuthor = reactForm.name.value;
}
var commentObj = {target: -1,
content: reactForm.content.value,
author: reactForm.name.value,
url: reactForm.url.value,
email: reactForm.email.value};
GW.CMT.add(MAR.addReactionRsp, commentObj);
return false;
},
addReactionRsp: function(aRspDoc) {
DH.getStyleObject('reactform').display = 'none';
var resultElm = DH.getObject('reactaddrsp');
DH.setHTML(resultElm, 'Ok je reactie is toegevoegd!');
DH.show(resultElm);
MAR.reactFormPanel.close();
},
addReactionNegRsp: function() {
DH.getStyleObject('reactform').display = 'none';
DH.setHTML('reactaddrsp', 'Helaas er is een fout opgetreden. Heb je de verplichte velden ingevuld ?');
},
showReactFormPanel: function() {
MAR.reactFormPanel = new Panel('reactform', '#555555', 'white', null);
MAR.reactFormPanel.setDimension(400, 350);
MAR.reactFormPanel.setXY(40, 40);
MAR.reactFormPanel.show();
MAR.reactFormPanel.loadContent('content/reactform.html', MAR.onLoadReactFormPanel);
MAR.reactFormPanel.setTitle('Reactie Formulier');
MAR.reactFormPanelOpen = true;
return false;
},
onLoadReactFormPanel: function() {
var reactForm = DH.getObject('reactform');
if (MAR.reactAuthor) {
reactForm.name.value = MAR.reactAuthor;
}
},
showReactionsPanel: function() {
if (MAR.reactionsPanel == null) {
MAR.reactionsPanel = new Panel('reactionspanel', '#555555', 'white', null, MAR.onReactionsPanelClose);
MAR.reactionsPanel.setDimension(500, 400);
MAR.reactionsPanel.setXY(50, 50);
MAR.reactionsPanel.loadContent('content/reactions.html', MAR.loadReactions);
MAR.reactionsPanel.setTitle('Reacties');
MAR.reactionsPanel.clear = function() {
};
} else {
DH.displayOn('reactionlist');
}
MAR.reactionsPanel.show();
MAR.panelOpen = true;
return false;
},
loadReactions: function() {
var reactionList = DH.getObject('reactionlist');
if (reactionList) {
reactionList.innerHTML = 'Laatste reacties ophalen...';
}
GW.QUERY.queryStore('q-comments-by-type', MAR.onLoadReactions, 'type', 1, 'last', 'true', 'max', MAR.MAX_REACTIONS_DISPLAY);
},
loadAllReactions: function() {
var reactionList = DH.getObject('reactionlist');
if (reactionList) {
reactionList.innerHTML = 'ALLE reacties ophalen...(even geduld a.u.b.)';
}
GW.QUERY.queryStore('q-comments-by-type', MAR.onLoadReactions, 'type', 1, 'last', 'true');
},
onLoadReactions: function(records) {
MAR.LAST_REACTIONS_COUNT = records.length;
DH.setHTML('reactioncount', '<p>De laatste ' + MAR.LAST_REACTIONS_COUNT + ' reacties. &nbsp;&nbsp&nbsp; [<a href="#" onclick="MAR.loadAllReactions()">Toon alle reacties</a>]</p>');
var html = ' ';
for (var i = 0; i < records.length; i++) {
html += MAR.formatComment(records[i]);
}
DH.setHTML('reactionlist', html);
},
onReactionsPanelClose: function() {
MAR.panelOpen = false;
DH.displayOff('reactionlist');
},
showNewsPanel: function() {
if (MAR.newsPanel == null) {
MAR.newsPanel = new Panel('newspanel', '#555555', 'white', null, MAR.onNewsPanelClose);
MAR.newsPanel.setDimension(500, 400);
MAR.newsPanel.setXY(40, 30);
MAR.newsPanel.loadContent('content/news.html', MAR.loadNews);
MAR.newsPanel.setTitle('Nieuws');
MAR.newsPanel.clear = function() {
};
} else {
DH.displayOn('newslist');
}
MAR.newsPanel.show();
MAR.newsPanelOpen = true;
return false;
},
toggleNewsOnMap: function() {
var newsToggle = DH.getObject('newstoggle');
if (MAR.newsSet) {
MAR.newsSet.dispose();
MAR.newsSet = null;
newsToggle.className = 'show_on_map';
return false;
}
newsToggle.className = 'show_on_map_checked';
GW.QUERY.queryStore('q-comments-by-type', MAR.onQueryLocativeNews, 'type', 2);
return false;
},
createNewsItem: function(record) {
return new NewsItem(record.id,
record.getField('author'),
record.getField('title'),
record.getField('content'),
record.getField('creationdate'),
record.getField('lon'),
record.getField('lat'));
},
createNewsSet: function(records) {
MAR.newsSet = new FeatureSet();
var record;
for (var i = 0; i < records.length; i++) {
record = records[i];
if (!record.getField('lon')) {
continue;
}
MAR.newsSet.addFeature(MAR.createNewsItem(record));
}
},
onQueryLocativeNews: function(records) {
MAR.createNewsSet(records);
MAR.newsSet.show();
},
loadNews: function() {
var newsList = DH.getObject('newslist');
if (newsList) {
newsList.innerHTML = 'nieuws ophalen...';
}
GW.QUERY.queryStore('q-comments-by-type', MAR.onLoadNews, 'type', 2, 'last', 'true');
},
onLoadNews: function(records) {
MAR.createNewsSet(records);
DH.setHTML('newscount', records.length + ' nieuwsberichten');
var html = '';
for (var i = 0; i < records.length; i++) {
html += MAR.formatComment(records[i]);
}
DH.setHTML('newslist', html);
},
onNewsPanelClose: function() {
MAR.newsPanelOpen = false;
DH.displayOff('newslist');
},
showNewsPopup: function(id) {
var newsItem = MAR.newsSet.getFeatureById(id);
if (newsItem) {
newsItem.show();
newsItem.openInfoWindow();
}
},
onCommentAdd: function(id, type) {
if (type == 2) {
MAR.refreshNewsHeadings();
}
GW.QUERY.queryStore('q-comment-by-id', MAR.onCommentGetRsp, 'id', id);
},
onCommentGetRsp: function(records) {
if (records.length == 0) {
return;
}
var commentRec = records[0];
var type = new Number(commentRec.getField('type'));
var listObj = DH.getObject(type == 1 ? 'reactionlist' : 'newslist');
if (listObj) {
listObj.innerHTML = MAR.formatComment(commentRec) + listObj.innerHTML;
if (type == 1) {
MAR.LAST_REACTIONS_COUNT++;
DH.setHTML('reactioncount', '<p>De laatste ' + MAR.LAST_REACTIONS_COUNT + ' reacties. &nbsp;&nbsp&nbsp; [<a href="#" onclick="MAR.loadAllReactions()">Toon alle reacties</a>]</p>');
}
}
if (type == 2 && commentRec.getField('lon')) {
if (!MAR.newsSet) {
MAR.createNewsSet(records);
MAR.newsSet.show();
} else {
var newsItem = MAR.createNewsItem(commentRec);
MAR.newsSet.addFeature(newsItem);
newsItem.show();
newsItem.blink(20);
}
}
if (type == 1 && MAR.reactionsHeadingsRecords) {
var newRecords = new Array();
newRecords[0] = commentRec;
for (var i=1; i < MAR.MAX_HEADING_LINES; i++) {
newRecords[i] = MAR.reactionsHeadingsRecords[i-1];
}
MAR.reactionsHeadingsRecords = newRecords;
MAR.showReactionHeadings();
}
},
refreshCommentHeadings: function(type) {
if (!type) {
MAR.refreshNewsHeadings();
MAR.refreshReactionHeadings();
return;
}
if (type == 1) {
MAR.refreshReactionHeadings();
} else if (type == 2) {
MAR.refreshNewsHeadings();
}
},
refreshNewsHeadings: function() {
MAR.newsHeadings.innerHTML = 'nieuws ophalen...';
GW.QUERY.queryStore('q-comments-by-type', MAR.onQueryNewsHeadings, 'type', 2, 'last', 'true', 'max', MAR.MAX_HEADING_LINES);
},
onQueryNewsHeadings: function(records) {
var title, content, author, date, rec;
var newsLines = ' ';
var heading;
for (var i = 0; i < records.length; i++) {
rec = records[i];
date = new Date(new Number(rec.getField('creationdate')));
title = rec.getField('title');
content = rec.getField('content');
author = rec.getField('author');
content = title + ' -- ' + content;
heading = MAR.formatHeading(date, author, content);
heading = '<a class="item" href="#" title="Toon alle nieuwsberichten" onclick=\"MAR.showNewsPanel()\">' + heading + '</a>';
newsLines += heading;
}
MAR.newsHeadings.innerHTML = newsLines;
},
refreshReactionHeadings: function() {
MAR.reactionsHeadings.innerHTML = 'Laatste' + MAR.MAX_HEADING_LINES + ' reacties ophalen...';
GW.QUERY.queryStore('q-comments-by-type', MAR.onQueryReactionHeadings, 'type', 1, 'last', 'true', 'max', MAR.MAX_HEADING_LINES);
},
showReactionHeadings: function() {
var records = MAR.reactionsHeadingsRecords;
var author, content, date, rec;
var newsLines = ' ';
var heading;
for (var i = 0; i < records.length; i++) {
rec = records[i];
if (!rec) {
continue;
}
date = new Date(new Number(rec.getField('creationdate')));
author = rec.getField('author');
if (author == null) {
author = 'anoniem';
}
content = rec.getField('content');
heading = MAR.formatHeading(date, author, content);
heading = '<a class="item" href="#" title="Toon alle reacties" onclick=\"MAR.showReactionsPanel()\">' + heading + '</a>';
newsLines += heading;
}
MAR.reactionsHeadings.innerHTML = newsLines;
},
onQueryReactionHeadings: function(records) {
MAR.reactionsHeadingsRecords = records;
MAR.showReactionHeadings();
},
formatComment: function(record) {
var html;
var author = record.getField('author');
if (author == null) {
author = 'anoniem';
}
var date = new Date(new Number(record.getField('creationdate'))).format('DDD D MMM YYYY HH:mm:ss');
html = '<hr/>' + author + ' - ' + date;
if (record.getField('lon') != null) {
html += '&nbsp;&nbsp;&nbsp;<a href="#" title="toon in kaart" class="item" onclick="MAR.showNewsPopup(\'' + record.id + '\')">toon op kaart &gt;</a>'
}
html += '<br/>';
var title = record.getField('title');
if (title != null) {
html += '<b>' + title + '</b><br/>';
}
var url = record.getField('url');
if (url != null) {
html += '<a href="' + url + '" target="_new">' + url + '</a>';
}
var content = record.getField('content');
if (content != null) {
html += '<p><i>' + content + '</i></p>';
}
return html;
},
formatHeading: function(date, author, content) {
var dateStr = date.format(MAR.DATE_FORMAT);
var heading = '<span class="time">' + dateStr + '</span><span>(' + author + ') ' + content;
if (heading.length > MAR.MAX_HEADING_CHARS) {
heading = heading.substring(0, MAR.MAX_HEADING_CHARS - 3);
}
return heading + '</span> <span class="more">meer...</span>';
}
}
function NewsItem(id, user, title, text, time, lon, lat) {
Feature.apply(this, new Array(id, title, text, 'news', time, lon, lat))
if (!this.gLatLng) {
this.gLatLng = GMAP.map.getCenter();
this.fakeLoc = true;
}
this.user = user;
this.getIconDiv = function() {
return '<a href="#" title="' + this.name + '"><img id="' + this.iconId + '" src="media/icons/nieuws.png" border="0" onload="DH.fixPNG(this)" /></a>';
}
this.display = function() {
this._displayTitle();
this._displayInfo();
this._displayPreview();
this._displayDescr();
}
this.show = function() {
if (this.fakeLoc) {
return;
}
var tl = new TLabel(false);
tl.id = 'news' + this.id;
tl.anchorLatLng = this.getGLatLng();
tl.anchorPoint = 'topLeft';
tl.content = this.getIconDiv();
tl.setScaling(this.iconId, 48, 48, .3);
tl.markerOffset = new GSize(24, 24);
GMAP.map.addTLabel(tl);
this.tlabel = tl;
var self = this;
this.onClickIcon = function (e) {
self.openInfoWindow();
}
DH.addEvent(this.tlabel.elm, 'click', this.onClickIcon, false);
}
this.openInfoWindow = function() {
var html = '<div  style="width: 280px"><p><b>' + this.name + '</b><br/>' + this.user + ' - ' + this.getDate() + '</p><p><i>'+ this.desc +'</i></p><p>&nbsp;</p></div>';
GMAP.map.openInfoWindowHtml(this.getGLatLng(), html);
GMAP.map.panTo(this.getGLatLng());
}
this._displayInfo = function() {
DH.setHTML('featureinfo', this.getDate());
}
}
var RED = {
loginName: null,
panel: null,
latLon: null,
menu: null,
marker: null,
selectedUserId: -1,
exit: function() {
RED.removeMarker();
},
init: function() {
RED.panel = new Panel('REDACTIE', '#555555', 'white', null, RED.exit);
RED.panel.setXY(300, 100);
RED.panel.setDimension(500, 400);
RED.panel.loadContent('content/redactie.html', RED.initScreen);
},
initScreen: function() {
RED.menu = new Menu('redmenu');
RED.menu.setXY(0,0);
RED.menu.setWidth(300);
RED.clearScreen();
RED.drawLogin();
},
login: function() {
RED.loginName = document.forms['loginform'].username.value;
GW.login(RED, RED.loginName, document.forms['loginform'].password.value);
},
loginRsp: function(element) {
RED.role = element.getAttribute("role");
if (RED.role == "0" || RED.role == "1") {
RED.drawWelcome(RED.loginName);
GW.storeAccount();
RED.menu.replaceItem('redmenusession', 'Logout', 'RED.logout');
} else if (RED.role == "2") {
RED.drawError("This page is not available for users.");
RED.logout();
}
},
loginNegRsp: function(errorId, errorStr, details, tagName) {
RED.onProtocolError(errorId, errorStr, details, tagName);
},
logout: function() {
GW.logout(RED, 'regular logout');
},
logoutRsp: function() {
RED.menu.replaceItem('redmenusession', 'Login', 'RED.drawLogin');
RED.drawLogin();
},
logoutNegRsp: function(errorId, errorStr, details, tagName) {
RED.onProtocolError(errorId, errorStr, details, tagName);
RED.menu.replaceItem('redmenusession', 'Login', 'RED.drawLogin');
RED.state = 0;
},
onProtocolError: function(errorId, errorStr, details, tagName) {
RED.drawError('ERROR: ' + tagName + ' error=' + errorStr + ' errorId=' + errorId + ', details=' + details);
},
addNews: function() {
if (!RED.checkFields(document.forms['addnewsform'])) {
return;
}
var commentObj = {target: -1,
type: 2,
title: document.forms['addnewsform'].title.value,
content: document.forms['addnewsform'].content.value,
author: RED.loginName,
email: 'redactie@geosailing.com'};
if (RED.marker != null) {
commentObj.lon = RED.marker.getLatLng().lng();
commentObj.lat = RED.marker.getLatLng().lat();
}
GW.CMT.add(RED, commentObj);
},
addRsp: function(element) {
RED.drawMessage('News item added id=' + element.getAttribute('id'));
RED.clearAddNews();
},
addNegRsp: function(errorId, errorStr, details, tagName) {
RED.onProtocolError(errorId, errorStr, details, tagName);
},
addMedium: function() {
var mediumForm = DH.getObject('addmediumform');
var selectedUserIndex = mediumForm.userlist.selectedIndex;
if (RED.marker != null) {
DH.getObject('lon').value = RED.marker.getLatLng().lng();
DH.getObject('lat').value = RED.marker.getLatLng().lat();
}
RED.selectedUserId = -1;
if (selectedUserIndex > 0) {
RED.selectedUserId = mediumForm.userlist.options[selectedUserIndex].label;
}
if (mediumForm.ref.value) {
GW.MEDIA.addRef(RED, { 'ref' : mediumForm.ref.value, 'name':  mediumForm.name.value, 'description':  mediumForm.description.value, 'lon':  mediumForm.lon.value, 'lat':  mediumForm.lat.value, 'userid' : RED.selectedUserId} );
} else {
GW.MEDIA.upload(RED.uploadRsp, mediumForm);
}
RED.drawMessage('Bezig met versturen (geduld is een schone zaak)...');
return false;
},
addRefRsp: function(element) {
RED.clearScreen();
var id = element.getAttribute('id');
RED.drawMessage('Medium ref added id=' + id);
if (RED.marker != null) {
RED.removeMarker();
}
if (RED.selectedUserId > 0) {
GW.TRACE.addMediumToTrace(RED, id, RED.selectedUserId);
}
},
addRefNegRsp: function(errorId, errorStr, details, tagName) {
RED.onProtocolError(errorId, errorStr, details, tagName);
},
uploadRsp: function(element) {
RED.clearScreen();
var msg = 'Medium toegevoegd=' + element.result + ' id=' + element.id;
if (RED.marker != null) {
RED.removeMarker();
}
RED.drawMessage(msg);
if (RED.selectedUserId > 0) {
GW.TRACE.addMediumToTrace(RED, element.id, RED.selectedUserId);
} else {
GW.QUERY.queryStore('q-medium-info', RED.sendMediumUploadInd, 'id', element.id);
}
},
sendMediumUploadInd: function(records) {
if (records.length == 0) {
return;
}
var record = records[0];
GW.EVENT.send(RED, '/gt', {'event' : 'medium-add',
'id' : record.id,
'name' : record.getField('name'),
'username' : 'redactie',
'kind' : record.getField('kind'),
'mime' : record.getField('mime'),
'lon' : record.getField('lon'),
'lat' : record.getField('lat'),
'time' : record.getField('creationdate')});
RED.drawMessage('Medium upload event sending...');
},
sendRsp: function() {
RED.drawMessage('Medium upload event sent OK');
},
sendNegRsp: function(errorId, errorStr, details, tagName) {
RED.onProtocolError(errorId, errorStr, details, tagName);
},
addMediumToTraceRsp: function() {
RED.clearScreen();
RED.drawMessage('OK!! Medium verstuurd en toegevoegd aan boot.');
},
addMediumToTraceNegRsp: function(errorId, errorStr, details, tagName) {
RED.onProtocolError(errorId, errorStr, details, tagName);
},
uploadNegRsp: function(errorId, errorStr, details, tagName) {
RED.onProtocolError(errorId, errorStr, details, tagName);
},
drawLogin: function() {
var accData = GW.getAccountData();
var user = '';
var pw = '';
if (accData != null && accData[0] != '' && accData[0].length > 0) {
user = accData[0];
pw = accData[1];
}
var text = DH.getObject('redcontent');
text.innerHTML = '';
var str = '';
str += '<h2>Login</h2>';
str += '<form action="javascript:RED.login();" method="post" id="loginform" name="loginform">';
str += '<table cellpadding="5" >';
str += '<tr>';
str += '<td>username</td>';
str += '<td><input type="text" name="username" value="' + user + '" /></td>';
str += '</tr>';
str += '<tr>';
str += '<td>password</td>';
str += '<td><input type="password" name="password" value="' + pw + '" /></td>';
str += '</tr>';
str += '<tr>';
str += '<td colspan="2" align="right"><input type="submit" value="login" class="button" /></td>';
str += '</tr>';
str += '</table>';
str += '</form>';
text.innerHTML = str;
text.style.display = 'block';
document.forms['loginform'].username.focus();
},
clearLogin: function() {
document.forms['loginform'].username.value = '';
document.forms['loginform'].password.value = '';
},
drawAddNews: function() {
RED.clearScreen();
var text = document.getElementById('redcontent');
text.innerHTML = "";
var str = '';
str += '<p>Add synopsis (title), content and optional location.</p>';
str += '<form action="javascript:RED.addNews();" method="post" id="addnewsform">';
str += '<table cellpadding="5" >';
str += '<tr>';
str += '<td><input type="text" size="40" name="title" value="" /></td>';
str += '</tr>';
str += '<tr>';
str += '<td><textarea rows="10" cols="40" name="content"></textarea></td>';
str += '</tr>';
str += '<tr>';
str += '<td>location&nbsp;&nbsp;<input onclick="return RED.toggleMarker();" type="checkbox" name="redlocation" id="redlocation">&nbsp;&nbsp;&nbsp;<span id="medlon"></span>&nbsp;<span id="medlat"></span></td>';
str += '</tr>';
str += '<tr>';
str += '<td><input type="submit" value="cancel" class="button" onclick="return RED.clearScreen();"/>&nbsp;&nbsp;<input type="submit" value="add" class="button" /></td>';
str += '</tr>';
str += '</table>';
str += '</form>';
text.innerHTML = str;
text.style.display = 'block';
document.forms['addnewsform'].title.focus();
},
drawNewsList: function(records) {
var text = document.getElementById('textlist');
text.innerHTML = "";
var str = '';
str += '<h2>List of news articles</h2>';
str += '<table id="listtexts" cellpadding="5">';
str += '<tr>';
str += '<td><strong>name</strong></td>';
str += '<td><strong>content</strong></td>';
str += '<td><strong>lang</strong></td>';
str += '<td></td>';
str += '</tr>';
for (var i = 0; i < records.length; i++) {
str += '<tr>' +
'<td>' + records[i].getField('name') + '</td>' +
'<td>' + records[i].getField('content') + '</td>' +
'<td>' + records[i].getField('lang') + '</td>' +
'<td><a href="#top' + '" onclick="RED.drawUpdateText(' + records[i].id + ',\'' + records[i].getField('name') + '\',\'' + records[i].getField('content') + '\',\'' + records[i].getField('lang') + '\');">update</a></td>' +
'<td><a href="javascript://delete' + '" onclick="RED.deleteText(' + records[i].id + ');">del</a><td>' +
'<td />' +
'<td />' +
'</tr>';
}
str += '</table>';
text.innerHTML = str;
text.style.display = 'block';
},
drawAddMedium: function() {
RED.clearScreen();
RED.mediumLatLon = null;
var text = document.getElementById('redcontent');
text.innerHTML = "";
var str = '';
str += '<p>Voeg een foto of video (VIDEO ALLEEN .flv EN ALS URL) toe</p>';
str += '<form action="' + GW.MEDIA.getBaseURL() +  ' " method="post" enctype="multipart/form-data"  id="addmediumform" name="addmediumform">';
str += '<table cellpadding="5" >';
str += '<tr>';
str += '<td>titel</td><td><input name="name" id="name" value="" /></td>';
str += '</tr>';
str += '<tr>';
str += '<td>file</td><td><input type="file" name="file" /><input type="hidden" name="lon" id="lon" value=""/><input type="hidden" name="lat" id="lat" value=""/> ALLEEN FOTOOS</td>';
str += '</tr>';
str += '<tr>';
str += '<td>url</td><td><input name="ref" id="ref" value="" size="32" /> ALLEEN VIDEO</td>';
str += '</tr>';
str += '<tr>';
str += '<td>beschrijving</td><td><textarea rows="5" cols="40" id="description" name="description"></textarea></td>';
str += '</tr>';
str += '<tr>';
str += '<td>location</td><td><input onclick="return RED.toggleMarker();" type="checkbox" name="redlocation" id="redlocation">&nbsp;&nbsp;&nbsp;<span id="medlon"></span>&nbsp;<span id="medlat"></span></td>';
str += '</tr>';
str += '<tr>';
str += '<td>boat (optional)</td><td><select id="userlist" name="userlist">';
str += '<option id="-1">select a boat</option>';
var userList = GTW.getTracers();
var userName, user;
for (userName in userList) {
user = userList[userName];
str += '<option label="' + user.id + '">' + user.name + '</option>';
}
str += '</select></td>';
str += '</tr>';
str += '<tr>';
str += '<td><input type="submit" value="cancel" class="button" onclick="return RED.clearScreen();"/></td><td><input type="submit" value="upload" class="button" onclick="return RED.addMedium();"/></td>';
str += '</tr>';
str += '</table>';
str += '</form>';
text.innerHTML = str;
text.style.display = 'block';
},
drawMarker: function() {
RED.removeMarker();
var panelBBox = RED.panel.getBBox();
var markerPos = GMAP.pixelToLatLon(panelBBox.x-40, panelBBox.y+120);
RED.marker = new GMarker(markerPos, {icon: new GIcon(G_DEFAULT_ICON, "media/bigmarker.png"), draggable: true});
RED.drawLocation();
GEvent.addListener(RED.marker, "dragstart", function() {
GMAP.map.closeInfoWindow();
});
GEvent.addListener(RED.marker, "dragend", function() {
RED.drawLocation();
});
GEvent.addListener(RED.marker, "drag", function() {
RED.drawLocation();
});
GMAP.map.addOverlay(RED.marker);
},
drawLocation: function() {
var ll = RED.marker.getLatLng();
DH.setHTML('medlon', ll.lng().toFixed(6));
DH.setHTML('medlat', ll.lat().toFixed(5));
},
removeMarker: function() {
if (RED.marker != null) {
GMAP.map.removeOverlay(RED.marker);
RED.marker = null;
}
},
toggleMarker: function() {
DH.getObject('redlocation').checked ? RED.drawMarker() : RED.removeMarker();
},
drawMediumLoc: function() {
if (RED.mediumLatLon != null) {
DH.getObject('medlon').innerHTML = RED.mediumLatLon.lng().toFixed(5);
DH.getObject('medlat').innerHTML = RED.mediumLatLon.lat().toFixed(5);
}
},
drawWelcome: function(name) {
DH.setHTML('redcontent', '<h2>Welcome</h2><p>Welcome ' + name + ' to this redaction app.</p>')
},
clearAddNews: function() {
document.forms['addnewsform'].title.value = '';
document.forms['addnewsform'].content.value = '';
},
drawMessage: function(data) {
DH.setHTML('redmessage', '<span><strong>' + data + '</strong>&nbsp;<input type="button" v' +
'alue="clear" onclick="RED.clearDiv(\'redmessage\');" /></span><br /><br />');
DH.displayOn('redmessage');
DH.setBGColor('redmessage', '#000072');
},
drawError: function(data) {
RED.drawMessage(data);
DH.setBGColor('redmessage', '#720000');
},
clearScreen: function() {
RED.clearDiv('redmessage');
RED.clearDiv('redcontent');
RED.removeMarker();
},
clearDiv: function(divname) {
DH.setHTML(divname, '&nbsp;');
DH.displayOff(divname);
},
checkFields: function(form) {
for (var i = 0; i < form.elements.length; i++) {
if (!RED.checkField(form.elements[i])) {
return false;
}
}
return true;
},
checkField: function(field) {
if (field.value == '' || field.value == 'null' || field.selectedIndex == 0) {
RED.drawMessage('Fill in a value for ' + field.name);
field.focus();
return false;
}
return true;
}
}
if(typeof deconcept=="undefined"){var deconcept=new Object();}if(typeof deconcept.util=="undefined"){deconcept.util=new Object();}if(typeof deconcept.SWFObjectUtil=="undefined"){deconcept.SWFObjectUtil=new Object();}deconcept.SWFObject=function(_1,id,w,h,_5,c,_7,_8,_9,_a){if(!document.getElementById){return;}this.DETECT_KEY=_a?_a:"detectflash";this.skipDetect=deconcept.util.getRequestParameter(this.DETECT_KEY);this.params=new Object();this.variables=new Object();this.attributes=new Array();if(_1){this.setAttribute("swf",_1);}if(id){this.setAttribute("id",id);}if(w){this.setAttribute("width",w);}if(h){this.setAttribute("height",h);}if(_5){this.setAttribute("version",new deconcept.PlayerVersion(_5.toString().split(".")));}this.installedVer=deconcept.SWFObjectUtil.getPlayerVersion();if(!window.opera&&document.all&&this.installedVer.major>7){deconcept.SWFObject.doPrepUnload=true;}if(c){this.addParam("bgcolor",c);}var q=_7?_7:"high";this.addParam("quality",q);this.setAttribute("useExpressInstall",false);this.setAttribute("doExpressInstall",false);var _c=(_8)?_8:window.location;this.setAttribute("xiRedirectUrl",_c);this.setAttribute("redirectUrl","");if(_9){this.setAttribute("redirectUrl",_9);}};deconcept.SWFObject.prototype={useExpressInstall:function(_d){this.xiSWFPath=!_d?"expressinstall.swf":_d;this.setAttribute("useExpressInstall",true);},setAttribute:function(_e,_f){this.attributes[_e]=_f;},getAttribute:function(_10){return this.attributes[_10];},addParam:function(_11,_12){this.params[_11]=_12;},getParams:function(){return this.params;},addVariable:function(_13,_14){this.variables[_13]=_14;},getVariable:function(_15){return this.variables[_15];},getVariables:function(){return this.variables;},getVariablePairs:function(){var _16=new Array();var key;var _18=this.getVariables();for(key in _18){_16[_16.length]=key+"="+_18[key];}return _16;},getSWFHTML:function(){var _19="";if(navigator.plugins&&navigator.mimeTypes&&navigator.mimeTypes.length){if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","PlugIn");this.setAttribute("swf",this.xiSWFPath);}_19="<embed type=\"application/x-shockwave-flash\" src=\""+this.getAttribute("swf")+"\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\" style=\""+this.getAttribute("style")+"\"";_19+=" id=\""+this.getAttribute("id")+"\" name=\""+this.getAttribute("id")+"\" ";var _1a=this.getParams();for(var key in _1a){_19+=[key]+"=\""+_1a[key]+"\" ";}var _1c=this.getVariablePairs().join("&");if(_1c.length>0){_19+="flashvars=\""+_1c+"\"";}_19+="/>";}else{if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","ActiveX");this.setAttribute("swf",this.xiSWFPath);}_19="<object id=\""+this.getAttribute("id")+"\" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\" style=\""+this.getAttribute("style")+"\">";_19+="<param name=\"movie\" value=\""+this.getAttribute("swf")+"\" />";var _1d=this.getParams();for(var key in _1d){_19+="<param name=\""+key+"\" value=\""+_1d[key]+"\" />";}var _1f=this.getVariablePairs().join("&");if(_1f.length>0){_19+="<param name=\"flashvars\" value=\""+_1f+"\" />";}_19+="</object>";}return _19;},write:function(_20){if(this.getAttribute("useExpressInstall")){var _21=new deconcept.PlayerVersion([6,0,65]);if(this.installedVer.versionIsValid(_21)&&!this.installedVer.versionIsValid(this.getAttribute("version"))){this.setAttribute("doExpressInstall",true);this.addVariable("MMredirectURL",escape(this.getAttribute("xiRedirectUrl")));document.title=document.title.slice(0,47)+" - Flash Player Installation";this.addVariable("MMdoctitle",document.title);}}if(this.skipDetect||this.getAttribute("doExpressInstall")||this.installedVer.versionIsValid(this.getAttribute("version"))){var n=(typeof _20=="string")?document.getElementById(_20):_20;n.innerHTML=this.getSWFHTML();return true;}else{if(this.getAttribute("redirectUrl")!=""){document.location.replace(this.getAttribute("redirectUrl"));}}return false;}};deconcept.SWFObjectUtil.getPlayerVersion=function(){var _23=new deconcept.PlayerVersion([0,0,0]);if(navigator.plugins&&navigator.mimeTypes.length){var x=navigator.plugins["Shockwave Flash"];if(x&&x.description){_23=new deconcept.PlayerVersion(x.description.replace(/([a-zA-Z]|\s)+/,"").replace(/(\s+r|\s+b[0-9]+)/,".").split("."));}}else{if(navigator.userAgent&&navigator.userAgent.indexOf("Windows CE")>=0){var axo=1;var _26=3;while(axo){try{_26++;axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash."+_26);_23=new deconcept.PlayerVersion([_26,0,0]);}catch(e){axo=null;}}}else{try{var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");}catch(e){try{var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");_23=new deconcept.PlayerVersion([6,0,21]);axo.AllowScriptAccess="always";}catch(e){if(_23.major==6){return _23;}}try{axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash");}catch(e){}}if(axo!=null){_23=new deconcept.PlayerVersion(axo.GetVariable("$version").split(" ")[1].split(","));}}}return _23;};deconcept.PlayerVersion=function(_29){this.major=_29[0]!=null?parseInt(_29[0]):0;this.minor=_29[1]!=null?parseInt(_29[1]):0;this.rev=_29[2]!=null?parseInt(_29[2]):0;};deconcept.PlayerVersion.prototype.versionIsValid=function(fv){if(this.major<fv.major){return false;}if(this.major>fv.major){return true;}if(this.minor<fv.minor){return false;}if(this.minor>fv.minor){return true;}if(this.rev<fv.rev){return false;}return true;};deconcept.util={getRequestParameter:function(_2b){var q=document.location.search||document.location.hash;if(_2b==null){return q;}if(q){var _2d=q.substring(1).split("&");for(var i=0;i<_2d.length;i++){if(_2d[i].substring(0,_2d[i].indexOf("="))==_2b){return _2d[i].substring((_2d[i].indexOf("=")+1));}}}return "";}};deconcept.SWFObjectUtil.cleanupSWFs=function(){var _2f=document.getElementsByTagName("OBJECT");for(var i=_2f.length-1;i>=0;i--){_2f[i].style.display="none";for(var x in _2f[i]){if(typeof _2f[i][x]=="function"){_2f[i][x]=function(){};}}}};if(deconcept.SWFObject.doPrepUnload){if(!deconcept.unloadSet){deconcept.SWFObjectUtil.prepUnload=function(){__flash_unloadHandler=function(){};__flash_savedUnloadHandler=function(){};window.attachEvent("onunload",deconcept.SWFObjectUtil.cleanupSWFs);};window.attachEvent("onbeforeunload",deconcept.SWFObjectUtil.prepUnload);deconcept.unloadSet=true;}}if(!document.getElementById&&document.all){document.getElementById=function(id){return document.all[id];};}var getQueryParamValue=deconcept.util.getRequestParameter;var FlashObject=deconcept.SWFObject;var SWFObject=deconcept.SWFObject;