
//* 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;
}
//* Browser Compatibility
//* Copyright 2006 OPAG Online Promotion AG
if(!Array.indexOf) {
Array.prototype.indexOf = function(searchElement, fromIndex) {
fromIndex = fromIndex || 0;
for(var i = fromIndex; i < this.length; ++i) {
if(this[i] === searchElement)
return i;
}
return -1;
}
}
function set_cookie(name, value, days) {
if(days == undefined)
days = 30;
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 = 'wt_' + name + '=' + value + expires + '; path=/; domain=.webcams.travel;';
}
function get_cookie(name) {
var name = 'wt_' + 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(name) == 0)
return c.substring(name.length, c.length);
}
return null;
}
function delete_cookie(name) {
create_cookie(name, '', -1);
}
//* 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 Circle() {
this.position_ = new GPoint(0, 0);
this.coords_ = new GLatLng(90.0, 0.0);
this.div_ = null;
this.image_ = null;
}
Circle.prototype = new GOverlay();
Circle.prototype.unload = function() {
this.position_ = null;
this.coords_ = null;
this.div_ = null;
this.image_ = null;
this.map_ = null;
}
Circle.prototype.initialize = function(map) {
if(this.div_ == null) {
var div = $Div();
div.style.position = 'absolute';
this.image_ = $Element('img', 'circle');
this.image_.src = '/img/map/position.png';
this.image_.style.width = '70px';
this.image_.style.height = '69px';
div.appendChild(this.image_);
this.div_ = div;
}
map.getPane(G_MAP_MAP_PANE).appendChild(this.div_);
this.map_ = map;
}
Circle.prototype.remove = function() {
this.div_.parentNode.removeChild(this.div_);
}
Circle.prototype.copy = function() {
return new Circle();
}
Circle.prototype.redraw = function(force) {
if(!force)
return;
this.position_ = this.map_.fromLatLngToDivPixel(this.coords_);
this.div_.style.left = (this.position_.x - 35) + 'px'; // Anpassen wenn Icon aendert!
this.div_.style.top = (this.position_.y - 34) + 'px'; // Anpassen wenn Icon aendert!
}
Circle.prototype.setPosition = function(coords) {
if(coords == null)
this.coords_ = new GLatLng(90.0, 0.0);
else
this.coords_ = coords;
this.redraw(true);
}
Circle.prototype.getPosition = function() {
return this.coords_;
}
function get_icon(type, webcamid) {
if(typeof(type) == 'undefined')
type = 'marker';
if(typeof(webcamid) == 'undefined')
webcamid = '';
var icon = new GIcon();
if(type == 'bubble') {
icon.image = '/img/marker_bubble.png';
icon.shadow = '';
icon.iconSize = new GSize(28, 28);
icon.shadowSize = new GSize(0, 0);
icon.iconAnchor = new GPoint(14, 14);
icon.infoWindowAnchor = new GPoint(14, 0);
}
else if(type == 'icon') {
icon.image = 'http://images.webcams.travel/icon/' + webcamid + '.png';
icon.shadow = '';
icon.iconSize = new GSize(32, 32);
icon.shadowSize = new GSize(0, 0);
icon.iconAnchor = new GPoint(16, 16);
icon.infoWindowAnchor = new GPoint(16, 0);
}
else if(type == 'position') {
icon.image = '/img/map/position.png';
icon.shadow = '';
icon.iconSize = new GSize(70, 69);
icon.shadowSize = new GSize(0, 0);
icon.iconAnchor = new GPoint(35, 34);
icon.infoWindowAnchor = new GPoint(35, 0);
}
else {
icon.image = '/img/marker.png';
icon.shadow = '';
icon.iconSize = new GSize(20, 34);
icon.shadowSize = new GSize(0, 0);
icon.iconAnchor = new GPoint(9, 34);
icon.infoWindowAnchor = new GPoint(9, 2);
}
return icon;
}
function ThumbMarker(width, height, webcam, point) {
this.width = width;
this.height = height;
this.webcamid = webcam.webcamid;
this.webcamtitle = webcam.title;
this.city = webcam.city;
this.point = point;
this.static = Math.round(Math.random() * 12345653) % 10;
this.firsttimeout = null;
this.timeout = null;
}
ThumbMarker.prototype = new GOverlay();
ThumbMarker.prototype.initialize = function(map) {
this.map = map;
var self = this;
// Icon
this.divIcon = $Div('thumbIcon');
this.divIcon.style.position = 'absolute';
this.divIcon.style.zIndex = GOverlay.getZIndex(this.point.lat());
this.divIcon.setAttribute('title', this.webcamtitle);
var icon = $Div();
icon.style.backgroundImage = 'url(http://static' + this.static + '.webcams.travel/icon/' + this.webcamid + '.png)';
icon.style.width = (this.width) + 'px';
icon.style.height = (this.height) + 'px';
icon.style.cursor = 'pointer';
this.divIcon.appendChild(icon);
// Thumbnail
this.divThumb = $Div('thumbMap_active');
this.divThumb.style.width = '213px';
this.divThumb.style.height = '187px';
this.divThumb.style.position = 'absolute';
this.divThumb.style.display = 'none';
this.divThumb.style.zIndex = GOverlay.getZIndex(-90);
var divInpt = $Div('thumbMap_top');
var inpt = $Element('input');
inpt.setAttribute('type', 'button');
inpt.setAttribute('value', 'X');
inpt.onclick = function(){ self.unselect(); };
inpt.style.position = 'relative';
inpt.style.left = (_hldir == 'ltr') ? '0px' : '-140px';
divInpt.appendChild(inpt);
var img = $Img('http://static' + this.static + '.webcams.travel/thumbnail/' + this.webcamid + '.jpg', null, 128, 96);
var lnk = $Link('/webcam/' + this.webcamid, img, '_blank', 'thumb thumbMap');
lnk.appendChild($Element('br'));
lnk.appendChild($Text(do_dots(this.city, 'thumb')));
lnk.style.position = 'relative';
lnk.style.top = '2px';
lnk.style.left = (_hldir == 'ltr') ? '57px' : '-19px';
this.divThumb.appendChild(divInpt);
this.divThumb.appendChild(lnk);
var pane = this.map.getPane(G_MAP_MARKER_PANE);
pane.appendChild(this.divIcon);
pane.appendChild(this.divThumb);
var self = this;
GEvent.addDomListener(this.divIcon, 'click', function() {
GEvent.trigger(self, 'click', self.point);
});
GEvent.addDomListener(this.divIcon, 'mouseover', function() {
GEvent.trigger(self, 'mouseover', self.point);
_block_transparency = true;
_block_slider_collapse = true;
self.firsttimeout = setTimeout(function() {
GEvent.trigger(self, 'mouseout', self.point);
}, 300);
});
GEvent.addDomListener(this.divIcon, 'mouseout', function() {
_block_transparency = false;
_block_slider_collapse = false;
});
GEvent.addDomListener(this.divThumb, 'mouseover', function() {
if(self.firsttimeout != null) {
clearTimeout(self.firsttimeout);
self.firsttimeout = null;
}
clearTimeout(self.timeout);
self.timeout = null;
});
GEvent.addDomListener(this.divThumb, 'mouseout', function() {
if(self.firsttimeout != null) {
clearTimeout(self.firsttimeout);
self.firsttimeout = null;
}
self.timeout = setTimeout(function() {
GEvent.trigger(self, 'mouseout', self.point);
}, 50);
});
}
ThumbMarker.prototype.transparent = function() {
this.divIcon.style.opacity = '.4';
this.divIcon.style.MozOpacity = '.4';
this.divIcon.style.filter = 'alpha(opacity = 40)';
}
ThumbMarker.prototype.untransparent = function() {
this.divIcon.style.opacity = '1';
this.divIcon.style.MozOpacity = '1';
this.divIcon.style.filter = 'alpha(opacity = 100)';
}
ThumbMarker.prototype.remove = function() {
this.divIcon.parentNode.removeChild(this.divIcon);
}
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);
// Icon
this.divIcon.style.left = (p.x - 32) + 'px';
this.divIcon.style.top = (p.y - 32) + 'px';
// Thumb
this.divThumb.style.left = (p.x - 32) + 'px';
this.divThumb.style.top = (p.y - 32) + 'px';
}
ThumbMarker.prototype.select = function() {
this.divIcon.style.display = 'none';
this.divThumb.style.display = '';
}
ThumbMarker.prototype.unselect = function() {
this.divIcon.style.display = '';
this.divThumb.style.display = 'none';
}
ThumbMarker.prototype.highlight = function() {
this.select();
}
ThumbMarker.prototype.unhighlight = function() {
this.unselect();
}
function set_position_text(id, point) {
var deg = get_degrees(point);
setText(id, deg.lat + ' ' + deg.lng);
}
function get_degrees(center) {
var lat = center.lat();
var lng = center.lng();
var deg = new Object();
// Latitude
var sign = (lat > 0 ? 'N' : 'S');
lat = Math.abs(lat);
var degrees = Math.floor(lat);
var minutes = Math.floor((lat - degrees) * 60);
var seconds = Math.floor(((lat - degrees) * 60 - minutes) * 60);
deg.lat = degrees + '°' + minutes + '\' ' + seconds + '" ' + sign;
// Longitude
sign = (lng > 0 ? 'E' : 'W');
lng = Math.abs(lng);
degrees = Math.floor(lng);
minutes = Math.floor((lng - degrees) * 60);
seconds = Math.floor(((lng - degrees) * 60 - minutes) * 60);
deg.lng = degrees + '°' + minutes + '\' ' + seconds + '" ' + sign;
return deg;
}
var _map = null;
var _timeout = null;
var _crosshair = null;
var _markerlist = [];
var _places = [];
var _previous_hash = '';
var _processing = false;
var _block_transparency = false;
var _block_slider = false;
var _block_slider_collapse = false;
var _untransTimeout = null;
var _transTimeout = null;
var _place_results_visible = false;
var _performing_drag = false;
function transparent_all() {
if(!_block_transparency)
for(var i = 0; i < _markerlist.length; i++)
_markerlist[i].transparent();
}
function untransparent_all() {
for(var i = 0; i < _markerlist.length; i++)
_markerlist[i].untransparent();
}
function worldview() {
var bounds = new GLatLngBounds(new GLatLng(-80, -180), new GLatLng(80, 180));
var zoom = _map.getBoundsZoomLevel(bounds);
_map.setCenter(new GLatLng(0, 0), zoom);
close_places();
}
function show_suggestion_box() {
display('find_place_none', 'none');
display('find_place_loading', 'none');
display('find_place_results', 'none');
display('find_place_suggestions', '');
}
function load() {
parse_hash();
if(GBrowserIsCompatible()) {
_crosshair = new Crosshair();
var center = new GLatLng(_lat, _lng);
_map = new GMap2(document.getElementById("map"));
if(typeof _bbox != 'undefined') {
var bounds = new GLatLngBounds(new GLatLng(_bbox.sw_lat, _bbox.sw_lng), new GLatLng(_bbox.ne_lat, _bbox.ne_lng));
_zoom = _map.getBoundsZoomLevel(bounds);
center = bounds.getCenter();
window.location.href = '/map/#lat=' + center.lat().toFixed(6) + '&lng=' + center.lng().toFixed(6) + '&z=' + _zoom;
return;
}
_map.setCenter(center, _zoom);
_map.enableRotation();
_map.addMapType(G_PHYSICAL_MAP);
_map.addControl(new GOverviewMapControl());
_map.addControl(new GLargeMapControl3D(), new GControlPosition(G_ANCHOR_TOP_RIGHT, new GSize(15, 15)));
_map.addControl(new GMenuMapTypeControl(), new GControlPosition(G_ANCHOR_TOP_RIGHT, new GSize(100, 15)));
_map.addControl(new GScaleControl());
_map.enableDoubleClickZoom();
_map.enableContinuousZoom();
_map.enableScrollWheelZoom();
switch(_maptype) {
case 'n':
_map.setMapType(G_NORMAL_MAP);
break;
case 's':
_map.setMapType(G_SATELLITE_MAP);
break;
case 'p':
_map.setMapType(G_PHYSICAL_MAP);
break;
default:
_map.setMapType(G_HYBRID_MAP);
}
GEvent.addListener(_map, 'move', function() {
_crosshair.update();
});
GEvent.addListener(_map, 'moveend', function() {
clearTimeout(_timeout);
_timeout = setTimeout(load_webcams, 1000);
save_hash();
});
GEvent.addListener(_map, 'dragstart', function() {
transparent_all();
_performing_drag = true;
});
GEvent.addListener(_map, 'dragend', function() {
untransparent_all();
_performing_drag = false;
});
_map.addControl(_crosshair);
_timeout = setTimeout(load_webcams, 1000);
setInterval(check_hash, 1000);
$('find_place').onkeydown = function(e) {
if(!e)
e = window.event;
var key = null;
if(e.which)
key = e.which;
else
key = e.keyCode;
if(key == 10 || key == 13)
find_place();
return;
}
// Google Ads.............................
var publisher_id = 'pub-0219134797937958';
var adsManagerOptions = {
  maxAdsOnMap : 2,
  style: 'adunit',
  // The channel field is optional - replace this field with a channel number 
  // for Google AdSense tracking
  channel: '3612822701',
  position: new GControlPosition(G_ANCHOR_TOP_LEFT, new GSize(14, 110))
};
adsManager = new GAdsManager(_map, publisher_id, adsManagerOptions);
adsManager.enable();
// Google Ads............................./
}
}
function unload() {
GUnload();
}
function resize() {
_map.checkResize();
load_webcams();
}
function load_webcams() {
var bounds = _map.getBounds();
var sw_lat = bounds.getSouthWest().lat();
var sw_lng = bounds.getSouthWest().lng();
var ne_lat = bounds.getNorthEast().lat();
var ne_lng = bounds.getNorthEast().lng();
var zoom = _map.getZoom();
var a = new AJAX('/ajax/webcams.php', function(response, data) {
if(response == null)
return;
if(response.status != 200)
return;
display_webcams(response.webcams);
return;
}, null, false);
a.ontransferstart = function(){display('loadingwebcams', '');}
a.ontransferend = function(){display('loadingwebcams', 'none');}
a.setParameter('a', 'fullscreen');
a.setParameter('sw_lat', sw_lat);
a.setParameter('sw_lng', sw_lng);
a.setParameter('ne_lat', ne_lat);
a.setParameter('ne_lng', ne_lng);
a.setParameter('zoom', zoom);
a.send();
}
function display_webcams(webcams) {
var marker = null;
var newmarker = [];
var markerlist = [];
var webcamids = [];
var webcamidmap = {};
// Welche webcamids haben wir zur Zeit auf der Karte?
for(var i = 0; i < _markerlist.length; i++) {
webcamids.push(_markerlist[i].wt_webcam.webcamid);
webcamidmap[_markerlist[i].wt_webcam.webcamid] = i;
}
// Die neuen webcamids durchgehen
for(var i = 0; i < webcams.length; i++) {
// Ist diese Webcam schon auf der Karte?
var index = webcamids.indexOf(webcams[i].webcamid);
if(index == -1) {// Nein, neuen Marker erstellen und in die Liste mit den neuen Marker hinzufuegen
marker = new ThumbMarker(32, 32, webcams[i], new GLatLng(webcams[i].lat, webcams[i].lng));
marker.wt_webcam = webcams[i];
GEvent.addListener(marker, 'click', function() {
this.select();
});
GEvent.addListener(marker, 'mouseout', function() {
this.unselect();
});
newmarker.push(marker);
}
else {// Ja, diese Webcam aus der webcamid-Liste nehmen und den Marker in die Liste mit den bestehenden Marker hinzufuegen
webcamids[index] = '';
markerlist.push(_markerlist[index]);
}
}
// Die nicht mehr sichtbaren Marker von der Karte nehmen
for(var i = 0; i < webcamids.length; i++) {
if(webcamids[i].length == 0)
continue;
marker = _markerlist[webcamidmap[webcamids[i]]];
_map.removeOverlay(marker);
}
$('nowebcams').style.display = 'none';
// Die neuen Marker zur Karte hinzufugen
for(var i = 0; i < newmarker.length; i++) {
_map.addOverlay(newmarker[i]);
if(_performing_drag)
newmarker[i].transparent();
markerlist.push(newmarker[i]);
}
_markerlist = markerlist;
update_slider();
}
function update_slider() {
clear('slider_thumblist');
var width = 145 * _markerlist.length;
$('slider_thumblist').style.width = width + 'px';
var a = null;
var img = null;
for(var i = 0; i < _markerlist.length; i++) {
img = $Img('http://images.webcams.travel/thumbnail/' + _markerlist[i].wt_webcam.webcamid + '.jpg', null, 128, 96);
a = $Link('/webcam/' + _markerlist[i].wt_webcam.webcamid, img, '_blank', 'thumb');
a.setAttribute('title', _markerlist[i].wt_webcam.title);
a.setAttribute('index', i);
a.onmouseover = function() {
var index = this.getAttribute('index');
_markerlist[index].highlight();
};
a.onmouseout = function() {
var index = this.getAttribute('index');
_markerlist[index].unhighlight();
};
a.appendChild($Element('br'));
a.appendChild($Text(do_dots(_markerlist[i].wt_webcam.city, 'thumb')));
$('slider_thumblist').appendChild(a);
}
if(_markerlist.length == 0)
$('nowebcams').style.display = '';
}
function find_place() {
var n = $('find_place');
var place = n.value;
if(place.length == 0)
return;
display('find_place_res', '');
display('find_place_none', 'none');
display('find_place_results', 'none');
display('find_place_close', 'none');
display('find_place_loading', '');
display('find_place_suggestions', 'none');
var a = new AJAX('/ajax/findplace.php', function(response, data) {
display('find_place_loading', 'none');
display_places(response);
return;
}, null, false);
a.setParameter('p', place);
a.send();
}
function center_place(p) {
close_places();
var place = _places[p];
var zoom = 13;
if(place.fcl == 'A')
zoom = 6;
_map.setCenter(new GLatLng(place.lat, place.lng), zoom);
}
function display_places(places) {
var n = $('find_place_results');
_place_results_visible = true;
display('find_place_suggestions', 'none');
if(places == null) {
display('find_place_close', '');
display('find_place_none', '');
return;
}
if(places.totalResultsCount == 0) {
display('find_place_close', '');
display('find_place_none', '');
return;
}
clear(n);
display('find_place_close', '');
display(n, '');
_places = new Array();
var text = '';
var subtext = '';
var link = null;
var place = null;
for(var i = 0; i < places.geonames.length; i++) {
place = places.geonames[i];
if(place.fcl == 'A') {
text = place.name;
subtext = place.countryCode;
}
else {
text = place.name;
subtext = '';
if(place.adminName1)
subtext += place.adminName1 + ', ';
subtext += place.countryName;
}
var u = $Element('u');
u.appendChild($Text(text));
link = $Link('javascript: center_place(' + _places.length + ')', u);
// SubText
var small = $Element('small');
small.appendChild($Text(subtext));
link.appendChild(small);
n.appendChild(link);
_places.push(place);
}
if(_places.length == 1)
center_place(0);
}
function close_places() {
display('find_place_res', 'none');
}
function check_hash() {
var hash = window.location.hash.substring(1);
if(hash != _previous_hash) {
parse_hash();
_previous_hash = hash;
_map.setCenter(new GLatLng(_lat, _lng), _zoom);
switch(_maptype) {
case 'n':
_map.setMapType(G_NORMAL_MAP);
break;
case 's':
_map.setMapType(G_SATELLITE_MAP);
break;
case 'p':
_map.setMapType(G_PHYSICAL_MAP);
break;
default:
_map.setMapType(G_HYBRID_MAP);
}
}
}
function parse_hash() {
var hash = window.location.hash.substring(1);
if(hash.length == 0) {
hash = get_cookie('map');
if(hash == null)
return;
}
var p = hash.split('&');
var v = new Array();
for(var i = 0; i < p.length; i++) {
v = p[i].split('=');
switch(v[0]) {
case 'lat':
_lat = parseFloat(v[1]);
break;
case 'lng':
_lng = parseFloat(v[1]);
break;
case 'z':
_zoom = parseInt(v[1]);
break;
case 't':
_maptype = v[1];
break;
default:
break;
}
}
}
function save_hash() {
var point = _map.getCenter();
_lat = point.lat().toFixed(6);
_lng = point.lng().toFixed(6);
_zoom = _map.getZoom();
var m = _map.getCurrentMapType();
if(m == G_NORMAL_MAP)
_maptype = 'n';
else if(m == G_HYBRID_MAP)
_maptype = 'h';
else if(m == G_PHYSICAL_MAP)
_maptype = 'p';
else
_maptype = 's';
var hash = 'lat=' + _lat + '&lng=' + _lng + '&z=' + _zoom + '&t=' + _maptype;
_previous_hash = hash;
location.hash = hash;
set_cookie('map', hash)
}
function toggleFooter() {
var map = $('map');
var mapfooter = $('mapfooter');
var position = mapfooter.getAttribute('wctposition');
if(position == 'closed') {
mapfooter.style.height = '160px';
map.style.bottom = '160px';
display('slider_thumblist', '');
display('mapfooter_show', 'none');
display('mapfooter_hide', '');
mapfooter.setAttribute('wctposition', 'open');
}
else {
mapfooter.style.height = '27px';
map.style.bottom = '27px';
display('slider_thumblist', 'none');
display('mapfooter_hide', 'none');
display('mapfooter_show', '');
mapfooter.setAttribute('wctposition', 'closed');
}
resize();
}
