
//* 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;
}
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 Coordbox() {
this.div_ = null;
this.map_ = null;
}
Coordbox.prototype = new GControl(false, false);
Coordbox.prototype.initialize = function(map) {
this.div_ = $Div();
this.div_.style.color = 'white';
this.div_.style.fontWeight = 'bold';
map.getContainer().appendChild(this.div_);
this.map_ = map;
return this.div_;
}
Coordbox.prototype.getDefaultPosition = function() {
return new GControlPosition(G_ANCHOR_TOP_RIGHT, new GSize(280, 7));
}
Coordbox.prototype.update = function() {
var deg = get_degrees(this.map_.getCenter());
setText(this.div_, deg.lat + ' ' + deg.lng);
}
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 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 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 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;
}
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());
}
var _map = null;
var _timeout = null;
var _coordbox = null;
var _crosshair = null;
var _circle = null;
var _markerlist = new Array();
var _places = new Array();
var _previous_hash = '';
var _map_height = 0;
var _webcam_height = 110;
var _webcam_cols = 3;
var _webcams_pp = 0;
var _from = 0;
function load() {
var pos = getAbsolutePosition('find_place');
$('find_place_res').style.left = pos.x + 'px';
$('find_place_res').style.top = (pos.y + 23) + 'px';
parse_hash();
set_max_height();
if(GBrowserIsCompatible()) {
_coordbox = new Coordbox();
var center = new GLatLng(_lat, _lng)
_map = new GMap2(document.getElementById("map"));
_map.setCenter(center, _zoom);
_map.addMapType(G_PHYSICAL_MAP);
_map.addControl(new GHierarchicalMapTypeControl());
_map.addControl(new GLargeMapControl());
_map.addControl(_coordbox);
_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);
}
if(_userid != '')
load_user_webcams();
GEvent.addListener(_map, 'move', function() {
set_position_text('map_position', _map.getCenter());
_coordbox.update();
_crosshair.update();
});
GEvent.addListener(_map, 'moveend', function() {
_from = 0;
set_position_text('map_position', _map.getCenter());
_coordbox.update();
clearTimeout(_timeout);
_timeout = setTimeout(load_webcams, 1300);
save_hash();
});
_coordbox.update();
_crosshair = new Crosshair();
_map.addControl(_crosshair);
_circle = new Circle();
_map.addOverlay(_circle);
_timeout = setTimeout(load_webcams, 1300);
set_position_text('map_position', center);
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;
}
}
}
function unload() {
GUnload();
}
function resize() {
set_max_height();
_map.checkResize();
_from = 0;
load_webcams();
}
function set_max_height() {
var h = getMaxHeight('map') - 25;
$('map').style.height = h + 'px';
_map_height = h;
_webcams_pp = Math.floor(_map_height / _webcam_height) * _webcam_cols;
return h;
}
function load_user_webcams() {
var a = new AJAX('/ajax/webcams.php', null, null, true);
a.ontransferstart = function(){display('loadingwebcams', '');}
a.ontransferend = function(){display('loadingwebcams', 'none');}
a.setParameter('a', 'user');
a.setParameter('userid', _userid);
a.setParameter('favorites', _favorites ? '1' : '0');
response = a.send();
if(response == null)
return;
if(response.status != 200)
return;
var webcams = response.webcams;
var bounds = new GLatLngBounds();
for(var i = 0; i < webcams.length; i++)
bounds.extend(new GLatLng(webcams[i].lat, webcams[i].lng));
var _zoom = _map.getBoundsZoomLevel(bounds);
if(_zoom > 15)
_zoom = 15;
var sw = bounds.getSouthWest();
var ne = bounds.getNorthEast();
var center = new GLatLng((ne.lat() + sw.lat()) / 2, (ne.lng() + sw.lng()) / 2);
_lat = center.lat();
_lng = center.lng();
_map.setCenter(center, _zoom);
save_hash()
return;
}
function load_webcams() {
var center = _map.getCenter();
var bounds = _map.getBounds();
var ce_lat = center.lat();
var ce_lng = center.lng();
var sw_lat = bounds.getSouthWest().lat();
var sw_lng = bounds.getSouthWest().lng();
var ne_lat = bounds.getNorthEast().lat();
var ne_lng = bounds.getNorthEast().lng();
if(bounds.isFullLng() == true) {
sw_lng = center.lng() - 35.0;
ne_lng = center.lng() + 35.0;
}
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', 'map');
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('ce_lat', ce_lat);
a.setParameter('ce_lng', ce_lng);
a.setParameter('f', _from);
a.setParameter('w', _webcams_pp);
a.setParameter('userid', _userid);
a.setParameter('favorites', _favorites ? '1' : '0');
a.send();
}
function display_webcams(webcams) {
for(var i = 0; i < _markerlist.length; i++)
_map.removeOverlay(_markerlist[i]);
_markerlist = new Array();
var bounds = null;
display('nowebcams', 'none');
var t = $('thumbnails');
clear(t);
var marker = null;
var img = null;
var link = null;
for(var i = 0; i < webcams.length && i < _webcams_pp; i++) {
marker = new ThumbMarker(32, 32, webcams[i].webcamid, new GLatLng(webcams[i].lat, webcams[i].lng));
marker.wct_webcam = webcams[i];
GEvent.addListener(marker, 'click', function() {
window.open('http://' + window.location.hostname + '/webcam/' + this.wct_webcam['webcamid']);
});
GEvent.addListener(marker, 'mouseover', function() {
this.select();
mouseover_marker(this.wct_webcam['webcamid']);
});
GEvent.addListener(marker, 'mouseout', function() {
this.unselect();
mouseout_marker(this.wct_webcam['webcamid']);
});
_map.addOverlay(marker);
_markerlist.push(marker);
img = $Img('http://images.webcams.travel/thumbnail/' + webcams[i].webcamid + '.jpg');
link = $Link('/webcam/' + webcams[i].webcamid, img, '_blank', 'thumb');
link.id = 'webcam' + webcams[i].webcamid;
img.setAttribute('webcamid', webcams[i].webcamid);
img.setAttribute('title', webcams[i].title);
img.onmouseover = mouseover_thumbnail;
img.onmouseout = mouseout_thumbnail;
t.appendChild(link);
}
if(webcams.length == 0)
display('nowebcams', '');
if(webcams.length <= _webcams_pp)
disable_nav('next');
else
enable_nav('next');
if(_from <= 0)
disable_nav('previous');
else
enable_nav('previous');
}
function previous() {
_from -= _webcams_pp;
if(_from < 0)
_from = 0;
load_webcams();
}
function next() {
_from += _webcams_pp;
load_webcams();
}
function disable_nav(type) {
display(type + '_active', 'none');
display(type + '_inactive', '');
}
function enable_nav(type) {
display(type + '_inactive', 'none');
display(type + '_active', '');
}
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', '');
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');
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 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 + ' (' + place.countryCode + ')';
}
else {
text = place.name + ' (';
if(place.adminName1)
text = text + place.adminName1 + ', ';
text = text + place.countryName + ')';
}
link = $Link('javascript: center_place(' + _places.length + ')', text);
n.appendChild(link);
n.appendChild($Element('br'));
_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 mouseover_thumbnail() {
var webcamid = this.getAttribute('webcamid');
for(var i = 0; i < _markerlist.length; i++) {
if(_markerlist[i].wct_webcam['webcamid'] != webcamid)
continue;
//_circle.setPosition(_markerlist[i].getLatLng());
_markerlist[i].select();
break;
}
}
function mouseout_thumbnail() {
//_circle.setPosition(null);
var webcamid = this.getAttribute('webcamid');
for(var i = 0; i < _markerlist.length; i++) {
if(_markerlist[i].wct_webcam['webcamid'] != webcamid)
continue;
_markerlist[i].unselect();
break;
}
}
function mouseover_marker(webcamid) {
set_style('webcam' + webcamid, 'thumb thumb_referenced');
//$('webcam' + webcamid).style.borderColor = 'red';
}
function mouseout_marker(webcamid) {
set_style('webcam' + webcamid, 'thumb');
//$('webcam' + webcamid).style.borderColor = '#ddd';
}

