
//* Convenience DOM-Functions
function $(n, index, element, specification, state) {
/* Valid State Provided */
if(typeof(state) == 'string')
return $(n + '[' + index + ']', element, specification, state);
/* Valid Specification Provided */
if(typeof(specification) == 'string')
return $(n + '[' + index + ']', element, specification);
/* Valid Element Provided */
if(typeof(element) == 'string')
return $(n + '[' + index + ']', element);
/* Only Node Provided */
if(typeof(index) == 'undefined') {
if(typeof(n) == 'object')
return n;
if(typeof(n) != 'string')
return null;
return document.getElementById(n);
}
/* Valid Index Provided */
return $(n + '[' + index + ']');
}
function $_REVERSE(node) {
var n = $(node);
// Substract Values
var a = n.id.replace(/]/g, '').split('[');
// Return Value
var r = {};
r['n'] = a[0];
r['index'] = a[1];
r['element'] = a[2];
r['specification'] = a[3];
return r;
}
function $_EXIST(n, index, element, specification, state) {
return $(n, index, element, specification, state) != null;
}
function $Element(n, classname) {
var e = document.createElement(n);
if(classname)
e.className = classname;
return e;
}
function $Text(n, style) {
if(style != undefined) {
var span = $Span();
for(s in style)
span.style[s] = style[s];
span.appendChild(document.createTextNode(n));
return span;
}
else
return document.createTextNode(n);
}
function $Div(classname, width) {
var e = $Element('div', classname);
if(width != undefined)
e.style.width = width + 'px';
return e;
}
function $Span(classname, width) {
var e = $Element('span', classname);
if(width != undefined)
e.style.width = width + 'px';
return e;
}
function $Img(src, classname, width, height) {
var e = $Element('img', classname);
e.src = src;
if(width)
e.style.width = width + 'px';
if(height)
e.style.height = height + 'px';
return e;
}
function $Table(classname) {
return $Element('table', classname);
}
function $Tr(classname) {
return $Element('tr', classname);
}
function $Td(classname, colspan, width) {
var e = $Element('td', classname);
if(colspan)
e.colSpan = colspan;
if(width)
e.style.width = width + 'px';
return e;
}
function $Link(url, content, target, classname, title) {
var a = $Element('a', classname);
a.href = url;
if(target)
a.target = target;
if(typeof(content) == 'object')
a.appendChild(content);
else
a.appendChild($Text(content));
if(title)
a.setAttribute('title', title);
return a;
}
function setClass(e, classname, exclusive) {
e = $(e);
if(!e)
return;
exclusive = (exclusive == undefined) ? false : exclusive;
if(exclusive == true) {
e.className = classname;
return;
}
var cn = e.className.split(' ');
if(cn.indexOf(classname) != -1)
return;
cn.push(classname);
e.className = cn.join(' ');
}
function unsetClass(e, classname) {
e = $(e);
if(!e)
return;
var cn = e.className.split(' ');
var i = cn.indexOf(classname);
if(i == -1)
return;
cn.splice(i, 1);
e.className = cn.join(' ');
}
function display(node, type) {
var n = $(node);
if(!n)
return;
n.style.display = type;
}
function toggle_display(node, type_on, type_off) {
var n = $(node);
if(!n)
return;
if(n.style.display == type_on)
n.style.display = type_off;
else if(n.style.display == type_off)
n.style.display = type_on;
}
function show(node, optional_index) {
unsetClass($(node, optional_index), 'hide');
}
function hide(node, optional_index) {
setClass($(node, optional_index), 'hide');
}
function isHidden(node) {
return hasClass(node, 'hide');
}
function clear(node) {
var n = $(node);
if(!n)
return;
while(n.firstChild)
n.removeChild(n.firstChild)
}
function setText(node, s, style) {
clear(node);
if(typeof(s) != 'string')
return;
$(node).appendChild($Text(s, style));
}
function resetForm(node) {
var n = $(node);
if(!n)
return;
n.reset();
}
function getText(node) {
var n = $(node);
if(!n)
return '';
if(node.innerText)
return node.innerText;
if(node.textContent)
return node.textContent;
return '';
}
function nextNode(node, name) {
if(node == null)
return null;
var x = node.nextSibling;
while(x != null) {
if(x.nodeName.toLowerCase() == name)
return x;
x = x.nextSibling;
}
return null;
}
function getMaxHeight(node) {
var n = $(node);
if(!n)
return 0;
var posy = n.offsetTop;
while((n = n.offsetParent) != null)
posy += n.offsetTop;
var innerHeight = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight;
return (innerHeight - posy);
}
function maximizeElement(name, offset) {
var height = getMaxHeight(name) + offset;
$(name).style.height = height + 'px';
}
function swap_visibility(hide, show) {
display(hide, 'none');
display(show, '');
}
function getAbsolutePosition(node) {
var n = $(node);
var pos = {x: 0, y: 0};
pos.x = n.offsetLeft;
pos.y = n.offsetTop;
while((n = n.offsetParent) != null) {
pos.x += n.offsetLeft;
pos.y += n.offsetTop;
}
return pos;
}
function getDimension(node) {
var dim = { topleft: {x: 0, y: 0}, bottomright: {x: 0, y: 0}};
dim.topleft = getAbsolutePosition(node);
dim.bottomright.x = dim.topleft.x + node.offsetWidth;
dim.bottomright.y = dim.topleft.y + node.offsetHeight;
return dim;
}
function getRelativePosition(child, parent) {
var cpos = this.getAbsolutePosition(child);
var ppos = this.getAbsolutePosition(parent);
var pos = {x: 0, y: 0};
pos.x = cpos.x - ppos.x;
pos.y = cpos.y - ppos.y;
return pos;
}
function getPageDimension() {
var dim = {x: 0, y: 0};
if (document.body.scrollHeight > document.body.offsetHeight) {
dim.x = document.body.scrollWidth;
dim.y = document.body.scrollHeight;
}
else {
dim.x = document.body.offsetWidth;
dim.y = document.body.offsetHeight;
}
return dim;
}
function getInnerDimension() {
var dim = {x: 0, y: 0};
if (self.innerHeight) {
dim.x = self.innerWidth;
dim.y = self.innerHeight;
}
else if(document.documentElement && document.documentElement.clientHeight) {
dim.x = document.documentElement.clientWidth;
dim.y = document.documentElement.clientHeight;
}
else if(document.body) {
dim.x = document.body.clientWidth;
dim.y = document.body.clientHeight;
}
return dim;
}
//* AJAX Toolkit
//* Copyright 2006 OPAG Online Promotion AG
function AJAX(url, callback, data, sync) {
this.sync = sync || false;
if(window.ActiveXObject)
this.request = new ActiveXObject('Microsoft.XMLHTTP');
else
this.request = new XMLHttpRequest();
if(this.sync == false) {
this.request.open('POST', url + '?rand=' + Math.random(), true);
var a = this;
this.request.onreadystatechange = function() {
var r = a.request;
if(r.readyState == 4) {
try { a.ontransferend(); } catch(e) {}
if(r.status == 200)
a.callback(a.parseJSON(r.responseText), a.data);
else
a.callback(null, a.data);
}
};
}
else
this.request.open('POST', url + '?rand=' + Math.random(), false);
this.request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
if(callback)
this.callback = callback;
else
this.callback = this.success;
this.data = data;
this.parameter = '';
}
AJAX.prototype.success = function(s, d) {
alert(s);
}
AJAX.prototype.parseJSON = function(text) {
if(text.length == 0)
return null;
var rex = /[^,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t]/
var reprex = /"(\\.|[^"\\])*"/g
if(rex.test(text.replace(reprex, '')) == true)
return null;
var obj;
try {
obj = eval('(' + text + ')');
}
catch(e) {
obj = null;
}
return obj;
}
AJAX.prototype.setParameter = function(parameter, value) {
this.parameter = this.parameter + '&' + encodeURIComponent(parameter) + '=' + encodeURIComponent(value);
}
AJAX.prototype.setForm = function(fid) {
var f = document.getElementById(fid);
if(!f)
return;
var p = '';
for(var i = 0; i < f.elements.length; i++) {
switch(f.elements[i].type) {
case 'hidden':
case 'text':
case 'password':
case 'textarea':
p = p + '&' + encodeURIComponent(f.elements[i].name) + '=' + encodeURIComponent(f.elements[i].value);
break;
case 'checkbox':
case 'radio':
if(f[i].checked)
p = p + '&' + encodeURIComponent(f.elements[i].name) + '=' + encodeURIComponent(f.elements[i].value);
break;
case 'select-one':
p = p + '&' + encodeURIComponent(f.elements[i].name) + '=' + encodeURIComponent(f.elements[i].value);
break;
case 'select-multiple':
for(var j = 0; j < f.elements[i].options.length; j++) {
if(f.elements[i].options[j].selected)
p = p + '&' + encodeURIComponent(f.elements[i].name) + '=' + encodeURIComponent(f.elements[i].options[j].value);
}
break;
case 'button':
case 'submit':
case 'reset':
default:
break;
}
}
this.parameter = this.parameter + p;
}
AJAX.prototype.send = function() {
try { this.ontransferstart(); } catch(e) {}
this.request.send('utf8=ä' + this.parameter);
if(this.sync == false)
return;
if(this.request.status == 200) {
try { this.ontransferend(); } catch(e) {}
return this.parseJSON(this.request.responseText);
}
try { this.ontransferend(); } catch(e) {}
return null;
}
AJAX.prototype.ontransferstart = function() {}
AJAX.prototype.ontransferend = function() {}
function Crosshair() {
this.div = null;
this.dummydiv = null;
this.image = new Image();
this.image.src = '/img/crosshair.gif';
}
Crosshair.prototype = new GControl(false, false);
Crosshair.prototype.unload = function() {
this.div.parentNode.removeChild(this.div);
}
Crosshair.prototype.initialize = function(map) {
this.map = map;
this.div = $Div();
this.div.style.position = 'absolute';
var img = $Element('img');
img.src = this.image.src;
img.style.width = '15px';
img.style.height = '15px';
this.div.appendChild(img);
this.map.getPane(G_MAP_MAP_PANE).appendChild(this.div);
this.dummydiv = $Div();
this.dummydiv.style.display = 'none';
this.map.getContainer().appendChild(this.dummydiv);
this.update();
return this.dummydiv;
}
Crosshair.prototype.getDefaultPosition = function() {
return new GControlPosition(G_ANCHOR_TOP_RIGHT, new GSize(7, 35));
}
Crosshair.prototype.update = function() {
var position = this.map.fromLatLngToDivPixel(this.map.getCenter());
this.div.style.left = (position.x - 7) + 'px';
this.div.style.top = (position.y - 7) + 'px';
}
function ThumbMarker(width, height, webcamid, point) {
this.width = width;
this.height = height;
this.webcamid = webcamid;
this.point = point;
this.static = Math.round(Math.random() * 12345653) % 5;
}
ThumbMarker.prototype = new GOverlay();
ThumbMarker.prototype.initialize = function(map) {
this.map = map;
this.div = $Div();
this.div.style.border = '1px solid white';
this.div.style.width = (this.width) + 'px';
this.div.style.height = (this.height) + 'px';
this.div.style.position = 'absolute';
this.div.style.cursor = 'pointer';
this.div.style.zIndex = GOverlay.getZIndex(this.point.lat());
this.div.style.backgroundImage = 'url(http://static' + this.static + '.webcams.travel/icon/' + this.webcamid + '.png)';
var pane = this.map.getPane(G_MAP_MARKER_PANE);
pane.appendChild(this.div);
var self = this;
GEvent.addDomListener(this.div, 'click', function() {
GEvent.trigger(self, 'click', self.point);
});
GEvent.addDomListener(this.div, 'mouseover', function() {
GEvent.trigger(self, 'mouseover', self.point);
});
GEvent.addDomListener(this.div, 'mouseout', function() {
GEvent.trigger(self, 'mouseout', self.point);
});
}
ThumbMarker.prototype.remove = function() {
this.div.parentNode.removeChild(this.div);
}
ThumbMarker.prototype.copy = function() {
return new ThumbMarker(this.width, this.height, this.webcamid);
}
ThumbMarker.prototype.redraw = function(force) {
if(!force)
return;
var p = this.map.fromLatLngToDivPixel(this.point);
this.div.style.left = (p.x - this.width / 2 - 1) + 'px';
this.div.style.top = (p.y - this.height / 2 - 1) + 'px';
}
ThumbMarker.prototype.select = function() {
this.div.style.border = '2px solid red';
this.div.style.left = (parseInt(this.div.style.left) - 1) + 'px';
this.div.style.top = (parseInt(this.div.style.top) - 1) + 'px';
this.div.style.zIndex = GOverlay.getZIndex(-90);
}
ThumbMarker.prototype.unselect = function() {
this.div.style.border = '1px solid white';
this.div.style.left = (parseInt(this.div.style.left) + 1) + 'px';
this.div.style.top = (parseInt(this.div.style.top) + 1) + 'px';
this.div.style.zIndex = GOverlay.getZIndex(this.point.lat());
}
