/* http://www.JSON.org/json2.js 2010-03-20 Public Domain. NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK. See http://www.JSON.org/js.html This code should be minified before deployment. See http://javascript.crockford.com/jsmin.html USE YOUR OWN COPY. IT IS EXTREMELY UNWISE TO LOAD CODE FROM SERVERS YOU DO NOT CONTROL. This file creates a global JSON object containing two methods: stringify and parse. JSON.stringify(value, replacer, space) value any JavaScript value, usually an object or array. replacer an optional parameter that determines how object values are stringified for objects. It can be a function or an array of strings. space an optional parameter that specifies the indentation of nested structures. If it is omitted, the text will be packed without extra whitespace. If it is a number, it will specify the number of spaces to indent at each level. If it is a string (such as '\t' or ' '), it contains the characters used to indent at each level. This method produces a JSON text from a JavaScript value. When an object value is found, if the object contains a toJSON method, its toJSON method will be called and the result will be stringified. A toJSON method does not serialize: it returns the value represented by the name/value pair that should be serialized, or undefined if nothing should be serialized. The toJSON method will be passed the key associated with the value, and this will be bound to the value For example, this would serialize Dates as ISO strings. Date.prototype.toJSON = function (key) { function f(n) { // Format integers to have at least two digits. return n < 10 ? '0' + n : n; } return this.getUTCFullYear() + '-' + f(this.getUTCMonth() + 1) + '-' + f(this.getUTCDate()) + 'T' + f(this.getUTCHours()) + ':' + f(this.getUTCMinutes()) + ':' + f(this.getUTCSeconds()) + 'Z'; }; You can provide an optional replacer method. It will be passed the key and value of each member, with this bound to the containing object. The value that is returned from your method will be serialized. If your method returns undefined, then the member will be excluded from the serialization. If the replacer parameter is an array of strings, then it will be used to select the members to be serialized. It filters the results such that only members with keys listed in the replacer array are stringified. Values that do not have JSON representations, such as undefined or functions, will not be serialized. Such values in objects will be dropped; in arrays they will be replaced with null. You can use a replacer function to replace those with JSON values. JSON.stringify(undefined) returns undefined. The optional space parameter produces a stringification of the value that is filled with line breaks and indentation to make it easier to read. If the space parameter is a non-empty string, then that string will be used for indentation. If the space parameter is a number, then the indentation will be that many spaces. Example: text = JSON.stringify(['e', {pluribus: 'unum'}]); // text is '["e",{"pluribus":"unum"}]' text = JSON.stringify(['e', {pluribus: 'unum'}], null, '\t'); // text is '[\n\t"e",\n\t{\n\t\t"pluribus": "unum"\n\t}\n]' text = JSON.stringify([new Date()], function (key, value) { return this[key] instanceof Date ? 'Date(' + this[key] + ')' : value; }); // text is '["Date(---current time---)"]' JSON.parse(text, reviver) This method parses a JSON text to produce an object or array. It can throw a SyntaxError exception. The optional reviver parameter is a function that can filter and transform the results. It receives each of the keys and values, and its return value is used instead of the original value. If it returns what it received, then the structure is not modified. If it returns undefined then the member is deleted. Example: // Parse the text. Values that look like ISO date strings will // be converted to Date objects. myData = JSON.parse(text, function (key, value) { var a; if (typeof value === 'string') { a = /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2}(?:\.\d*)?)Z$/.exec(value); if (a) { return new Date(Date.UTC(+a[1], +a[2] - 1, +a[3], +a[4], +a[5], +a[6])); } } return value; }); myData = JSON.parse('["Date(09/09/2001)"]', function (key, value) { var d; if (typeof value === 'string' && value.slice(0, 5) === 'Date(' && value.slice(-1) === ')') { d = new Date(value.slice(5, -1)); if (d) { return d; } } return value; }); This is a reference implementation. You are free to copy, modify, or redistribute. */ /*jslint evil: true, strict: false */ /*members "", "\b", "\t", "\n", "\f", "\r", "\"", JSON, "\\", apply, call, charCodeAt, getUTCDate, getUTCFullYear, getUTCHours, getUTCMinutes, getUTCMonth, getUTCSeconds, hasOwnProperty, join, lastIndex, length, parse, prototype, push, replace, slice, stringify, test, toJSON, toString, valueOf */ // Create a JSON object only if one does not already exist. We create the // methods in a closure to avoid creating global variables. if (!this.JSON) { this.JSON = {}; } (function () { function f(n) { // Format integers to have at least two digits. return n < 10 ? '0' + n : n; } if (typeof Date.prototype.toJSON !== 'function') { Date.prototype.toJSON = function (key) { return isFinite(this.valueOf()) ? this.getUTCFullYear() + '-' + f(this.getUTCMonth() + 1) + '-' + f(this.getUTCDate()) + 'T' + f(this.getUTCHours()) + ':' + f(this.getUTCMinutes()) + ':' + f(this.getUTCSeconds()) + 'Z' : null; }; String.prototype.toJSON = Number.prototype.toJSON = Boolean.prototype.toJSON = function (key) { return this.valueOf(); }; } var cx = /[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g, escapable = /[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g, gap, indent, meta = { // table of character substitutions '\b': '\\b', '\t': '\\t', '\n': '\\n', '\f': '\\f', '\r': '\\r', '"' : '\\"', '\\': '\\\\' }, rep; function quote(string) { // If the string contains no control characters, no quote characters, and no // backslash characters, then we can safely slap some quotes around it. // Otherwise we must also replace the offending characters with safe escape // sequences. escapable.lastIndex = 0; return escapable.test(string) ? '"' + string.replace(escapable, function (a) { var c = meta[a]; return typeof c === 'string' ? c : '\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4); }) + '"' : '"' + string + '"'; } function str(key, holder) { // Produce a string from holder[key]. var i, // The loop counter. k, // The member key. v, // The member value. length, mind = gap, partial, value = holder[key]; // If the value has a toJSON method, call it to obtain a replacement value. if (value && typeof value === 'object' && typeof value.toJSON === 'function') { value = value.toJSON(key); } // If we were called with a replacer function, then call the replacer to // obtain a replacement value. if (typeof rep === 'function') { value = rep.call(holder, key, value); } // What happens next depends on the value's type. switch (typeof value) { case 'string': return quote(value); case 'number': // JSON numbers must be finite. Encode non-finite numbers as null. return isFinite(value) ? String(value) : 'null'; case 'boolean': case 'null': // If the value is a boolean or null, convert it to a string. Note: // typeof null does not produce 'null'. The case is included here in // the remote chance that this gets fixed someday. return String(value); // If the type is 'object', we might be dealing with an object or an array or // null. case 'object': // Due to a specification blunder in ECMAScript, typeof null is 'object', // so watch out for that case. if (!value) { return 'null'; } // Make an array to hold the partial results of stringifying this object value. gap += indent; partial = []; // Is the value an array? if (Object.prototype.toString.apply(value) === '[object Array]') { // The value is an array. Stringify every element. Use null as a placeholder // for non-JSON values. length = value.length; for (i = 0; i < length; i += 1) { partial[i] = str(i, value) || 'null'; } // Join all of the elements together, separated with commas, and wrap them in // brackets. v = partial.length === 0 ? '[]' : gap ? '[\n' + gap + partial.join(',\n' + gap) + '\n' + mind + ']' : '[' + partial.join(',') + ']'; gap = mind; return v; } // If the replacer is an array, use it to select the members to be stringified. if (rep && typeof rep === 'object') { length = rep.length; for (i = 0; i < length; i += 1) { k = rep[i]; if (typeof k === 'string') { v = str(k, value); if (v) { partial.push(quote(k) + (gap ? ': ' : ':') + v); } } } } else { // Otherwise, iterate through all of the keys in the object. for (k in value) { if (Object.hasOwnProperty.call(value, k)) { v = str(k, value); if (v) { partial.push(quote(k) + (gap ? ': ' : ':') + v); } } } } // Join all of the member texts together, separated with commas, // and wrap them in braces. v = partial.length === 0 ? '{}' : gap ? '{\n' + gap + partial.join(',\n' + gap) + '\n' + mind + '}' : '{' + partial.join(',') + '}'; gap = mind; return v; } } // If the JSON object does not yet have a stringify method, give it one. if (typeof JSON.stringify !== 'function') { JSON.stringify = function (value, replacer, space) { // The stringify method takes a value and an optional replacer, and an optional // space parameter, and returns a JSON text. The replacer can be a function // that can replace values, or an array of strings that will select the keys. // A default replacer method can be provided. Use of the space parameter can // produce text that is more easily readable. var i; gap = ''; indent = ''; // If the space parameter is a number, make an indent string containing that // many spaces. if (typeof space === 'number') { for (i = 0; i < space; i += 1) { indent += ' '; } // If the space parameter is a string, it will be used as the indent string. } else if (typeof space === 'string') { indent = space; } // If there is a replacer, it must be a function or an array. // Otherwise, throw an error. rep = replacer; if (replacer && typeof replacer !== 'function' && (typeof replacer !== 'object' || typeof replacer.length !== 'number')) { throw new Error('JSON.stringify'); } // Make a fake root object containing our value under the key of ''. // Return the result of stringifying the value. return str('', {'': value}); }; } // If the JSON object does not yet have a parse method, give it one. if (typeof JSON.parse !== 'function') { JSON.parse = function (text, reviver) { // The parse method takes a text and an optional reviver function, and returns // a JavaScript value if the text is a valid JSON text. var j; function walk(holder, key) { // The walk method is used to recursively walk the resulting structure so // that modifications can be made. var k, v, value = holder[key]; if (value && typeof value === 'object') { for (k in value) { if (Object.hasOwnProperty.call(value, k)) { v = walk(value, k); if (v !== undefined) { value[k] = v; } else { delete value[k]; } } } } return reviver.call(holder, key, value); } // Parsing happens in four stages. In the first stage, we replace certain // Unicode characters with escape sequences. JavaScript handles many characters // incorrectly, either silently deleting them, or treating them as line endings. text = String(text); cx.lastIndex = 0; if (cx.test(text)) { text = text.replace(cx, function (a) { return '\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4); }); } // In the second stage, we run the text against regular expressions that look // for non-JSON patterns. We are especially concerned with '()' and 'new' // because they can cause invocation, and '=' because it can cause mutation. // But just to be safe, we want to reject all unexpected forms. // We split the second stage into 4 regexp operations in order to work around // crippling inefficiencies in IE's and Safari's regexp engines. First we // replace the JSON backslash pairs with '@' (a non-JSON character). Second, we // replace all simple value tokens with ']' characters. Third, we delete all // open brackets that follow a colon or comma or that begin the text. Finally, // we look to see that the remaining characters are only whitespace or ']' or // ',' or ':' or '{' or '}'. If that is so, then the text is safe for eval. if (/^[\],:{}\s]*$/. test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g, '@'). replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, ']'). replace(/(?:^|:|,)(?:\s*\[)+/g, ''))) { // In the third stage we use the eval function to compile the text into a // JavaScript structure. The '{' operator is subject to a syntactic ambiguity // in JavaScript: it can begin a block or an object literal. We wrap the text // in parens to eliminate the ambiguity. j = eval('(' + text + ')'); // In the optional fourth stage, we recursively walk the new structure, passing // each name/value pair to a reviver function for possible transformation. return typeof reviver === 'function' ? walk({'': j}, '') : j; } // If the text is not JSON parseable, then a SyntaxError is thrown. throw new SyntaxError('JSON.parse'); }; } }()); function Utils() { this.roundTo = function(number, places) { var n = Math.pow(10, places); number = Math.round(number * n); return number / n; } } var utils = new Utils(); var map = null; var marker = null; var geocoder = null; var polyPoints = Array(); var activeObjectPosition; function search_address() { showAddress(document.getElementById('address').value); } function gpsToReal(g, m, s) { return g + m / 60 + s / 3600; } /** Converts numeric degrees to radians */ if (typeof (Number.prototype.toRad) === "undefined") { Number.prototype.toRad = function() { return this * Math.PI / 180; } } /** Converts numeric radians to degrees */ if (typeof (Number.prototype.toDeg) === "undefined") { Number.prototype.toDeg = function() { return this * 180 / Math.PI; } } function showStreetView(position, objTitle) { if (objTitle == undefined) { title = "StreetView"; } activeObjectPosition = position; var location = new google.maps.LatLng(parseFloat(position.n), parseFloat(position.e)); var webService = new google.maps.StreetViewService(); //console.log(position); webService.getPanoramaByLocation(location, 50, function(data, status) { //console.log(status); if (status == google.maps.StreetViewStatus.OK) { $("#modal-dialog").dialog({ width: 900, height: 500, modal: true, title: objTitle }); if (data.location.latLng) { var lat1 = parseFloat(activeObjectPosition.n); var lon1 = parseFloat(activeObjectPosition.e); var lat2 = parseFloat(data.location.latLng.hb); var lon2 = parseFloat(data.location.latLng.ib); // TODO treba vymysliet ako nastavit smer pohladu na budovu (vypocitat azimut) // http://www.movable-type.co.uk/scripts/latlong.html var dLat = (lat2 - lat1).toRad(); var dLon = (lon2 - lon1).toRad(); var lat1 = lat1.toRad(); var lon1 = lon1.toRad(); var lat2 = lat2.toRad(); var lon2 = lon2.toRad(); var y = Math.sin(dLon) * Math.cos(lat2); var x = Math.cos(lat1) * Math.sin(lat2) - Math.sin(lat1) * Math.cos(lat2) * Math.cos(dLon); var bearing = Math.atan2(y, x).toDeg(); var azimut = (bearing + 180) % 360; if (!isFinite(azimut)) azimut = 0; var panoOptions = { position: data.location.latLng, addressControlOptions: { position: google.maps.ControlPosition.BOTTOM }, linksControl: true, panControl: false, zoomControlOptions: { style: google.maps.ZoomControlStyle.SMALL }, enableCloseButton: false }; var panorama = new google.maps.StreetViewPanorama(document.getElementById('modal-dialog-content'), panoOptions); panorama.setPov({ heading: azimut, zoom: 1, pitch: 0 }); panorama.setVisible(true); } } else { //$("#modal-dialog").dialog("close"); alert('Vo vzdialenosti 50m od objektu nie je panoráma k dispozicii!'); } } ); } function realToGps(r) { var g = Math.floor(r); var m = Math.floor((r - g) * 60); var s = (((r - g) * 60) - Math.floor((r - g) * 60)) * 60; return g + '°' + m + '\'' + s + '"'; } function realToGpsG(r) { var g = Math.floor(r); var m = Math.floor((r - g) * 60); var s = (((r - g) * 60) - Math.floor((r - g) * 60)) * 60; return g; } function realToGpsM(r) { var g = Math.floor(r); var m = Math.floor((r - g) * 60); var s = (((r - g) * 60) - Math.floor((r - g) * 60)) * 60; return m; } function realToGpsS(r) { var g = Math.floor(r); var m = Math.floor((r - g) * 60); var s = (((r - g) * 60) - Math.floor((r - g) * 60)) * 60; return s; } function center_map() { map.setCenter(new google.maps.LatLng(marker.getLatLng().lat(), marker.getLatLng().lng())); } /** * Nacitanie markerov definovanych pomocou url do mapy * */ function mapShowNearObject(object_id, distance) { var elm = document.getElementById('map_canvas_obj_' + object_id); var mapOptions = { mapTypeId: google.maps.MapTypeId.ROADMAP }; var bounds = new google.maps.LatLngBounds(); var map = new google.maps.Map(elm, mapOptions); xmlhttp = getXmlHttp(); Url = baseUrl + '/ajax/objectmapdata/lang/' + locale + '/object_id/' + object_id + '/mode/1/distance/' + distance; //alert(Url); xmlhttp.onreadystatechange = function() { if (xmlhttp.readyState == 4) { var xmlDoc = xmlhttp.responseXML; var markersData = xmlDoc.getElementsByTagName('object'); var latlngbounds = new google.maps.LatLngBounds(); // hranice oblasti s markermi - kvoli centrovaniu mapy //alert(markersData.length); for (var i = 0; i < markersData.length; i++) { var point = new google.maps.LatLng(parseFloat(markersData[i].getAttribute("gps_n")), parseFloat(markersData[i].getAttribute("gps_e"))); var info = markersData[i].childNodes[0].data; // info o markeri v html formate latlngbounds.extend(point); // rozsirim hranicu o novy marker - kvoli centrovaniu mapy var image = new google.maps.MarkerImage( baseUrl + "/public/pictures/markers/" + markersData[i].getAttribute("color") + ".png", new google.maps.Size(20, 32), // size new google.maps.Point(0, 0), // origin new google.maps.Point(10, 32) // anchor ); var marker = new google.maps.Marker({ position: point, map: map, icon: image, info: info, title: markersData[i].getAttribute("name"), //zIndex: beach[3] }); var infowindow = new google.maps.InfoWindow(); google.maps.event.addListener(marker, "click", function() { infowindow.setContent(this.info); infowindow.open(map, this); }); google.maps.event.addListener(marker, "mouseover", function() { document.getElementById("map_info_obj_" + object_id).innerHTML = this.title; }); google.maps.event.addListener(marker, "mouseout", function() { document.getElementById("map_info_obj_" + object_id).innerHTML = ' '; }); } // alert(map.getBoundsZoomLevel(latlngbounds)); map.setCenter(latlngbounds.getCenter()); map.fitBounds(latlngbounds); map.setZoom(map.getZoom() + 1); } } xmlhttp.open("GET", Url, true); xmlhttp.send(null); } function mapShowSearch() { var mapOptions = { mapTypeId: google.maps.MapTypeId.ROADMAP }; var bounds = new google.maps.LatLngBounds(); map = new google.maps.Map(document.getElementById("map_canvas"), mapOptions); xmlhttp = getXmlHttp(); url = baseUrl + '/search/map/lang/' + locale; //alert(url); xmlhttp.onreadystatechange = function() { if (xmlhttp.readyState == 4) { var xmlDoc = xmlhttp.responseXML; var markersData = xmlDoc.getElementsByTagName('object'); var latlngbounds = new google.maps.LatLngBounds(); // hranice oblasti s markermi - kvoli centrovaniu mapy //alert(markersData.length); for (var i = 0; i < markersData.length; i++) { var point = new google.maps.LatLng(parseFloat(markersData[i].getAttribute("gps_n")), parseFloat(markersData[i].getAttribute("gps_e"))); var info = markersData[i].childNodes[0].data; // info o markeri v html formate latlngbounds.extend(point); // rozsirim hranicu o novy marker - kvoli centrovaniu mapy var image = new google.maps.MarkerImage( baseUrl + "/public/pictures/markers/" + markersData[i].getAttribute("color") + ".png", new google.maps.Size(20, 32), // size new google.maps.Point(0, 0), // origin new google.maps.Point(10, 32) // anchor ); var marker = new google.maps.Marker({ position: point, map: map, icon: image, info: info, title: markersData[i].getAttribute("name"), //zIndex: beach[3] }); var infowindow = new google.maps.InfoWindow(); google.maps.event.addListener(marker, "click", function() { infowindow.setContent(this.info); infowindow.open(map, this); }); google.maps.event.addListener(marker, "mouseover", function() { }); google.maps.event.addListener(marker, "mouseout", function() { }); } // alert(map.getBoundsZoomLevel(latlngbounds)); //console.log(zoomLevel); if (markersData.length > 0) { map.setCenter(latlngbounds.getCenter()); map.fitBounds(latlngbounds); map.setZoom(map.getZoom()); } else { zoomLevel = 7; map.setCenter(new google.maps.LatLng(48.70, 19.5)); map.setZoom(zoomLevel); } } }; xmlhttp.open("GET", url, true); xmlhttp.send(null); } function mapShowSRRegions() { var mapOptions = { mapTypeId: google.maps.MapTypeId.ROADMAP }; var bounds = new google.maps.LatLngBounds(); var map = new google.maps.Map(document.getElementById("map_canvas"), mapOptions); var colors = [ "#ffffff", "#ff0000", "#0000ff", "#00ff00", "#ff77ff", "#ff7733", "#777777", "#ffff00", "#ff00ff" ]; xmlhttp = getXmlHttp(); url = baseUrl + '/ajax/borderregionsmapdata/lang/' + locale + '/border.txt'; //alert(url); xmlhttp.onreadystatechange = function() { if (xmlhttp.readyState == 4) { /* * Regiony */ /* * JSON */ var xmlDoc = xmlhttp.responseText; var borderData; // borderData = JSON.parse(xmlDoc); borderData = eval(xmlDoc); var points = Array(); var polygons = Array(); for (var j = 0; j <= 8; j++) { points = Array(); for (var i = 0; i < borderData[j].length; i++) { // alert(borderData[j][i]); try { var e = parseFloat(borderData[j][i][0]); var n = parseFloat(borderData[j][i][1]); var point = new google.maps.LatLng(e, n); bounds.extend(point); points.push(point); } catch (ex) { // chybne data // alert(borderData[j][i]); } } var strokeColor = "#000077"; var strokeWeight = 2; var strokeOpacity = 1; var fillColor = colors[j]; var fillOpacity; if (j > 0) fillOpacity = 0.4; else fillOpacity = 0.0; polygon = new google.maps.Polygon( { paths: points, strokeColor: strokeColor, strokeOpacity: strokeOpacity, strokeWeight: strokeWeight, fillColor: fillColor, fillOpacity: fillOpacity }); if (j > 0) { google.maps.event.addListener(polygon, "click", function(latlng) { window.location = "http://www.cestovnyinformator.sk" + baseUrl + "/" + locale + "/regiony/" + this.id + "/region.html"; }); } polygon.id = j; polygon.setMap(map); polygons.push(polygon); } /* * centrovanie na region */ map.setCenter(bounds.getCenter()); map.fitBounds(bounds); map.setZoom(map.getZoom() + 1); } } xmlhttp.open("GET", url, true); xmlhttp.send(null); } function mapShowSR() { var mapOptions = { scaleControl: true, scrollwheel: false, mapTypeId: google.maps.MapTypeId.ROADMAP }; var bounds = new google.maps.LatLngBounds(); var map = new google.maps.Map(document.getElementById("map_canvas"), mapOptions); xmlhttp_region = getXmlHttp(); url_region = baseUrl + '/ajax/bordersrmapdata/lang/' + locale + '/border.txt'; xmlhttp_region.onreadystatechange = function() { if (xmlhttp_region.readyState == 4) { /* * Region */ var points = Array(); /* * JSON */ var xmlDoc = xmlhttp_region.responseText; // var borderData = JSON.parse(xmlDoc); // IE ma problem s JSON var borderData = eval(xmlDoc); for (i = 0; i < borderData.length; i++) { try { var point = new google.maps.LatLng(parseFloat(borderData[i][0]), parseFloat(borderData[i][1])); bounds.extend(point); points.push(point); } catch (ex) { // cybne data } } var strokeColor = "#000077"; var strokeWeight = 1; var strokeOpacity = 1; var fillColor = "#0000ff"; var fillOpacity = 0.2; var polygon = new google.maps.Polygon( { paths: points, strokeColor: strokeColor, strokeOpacity: strokeOpacity, strokeWeight: strokeWeight, fillColor: fillColor, fillOpacity: fillOpacity }); polygon.setMap(map); /* * centrovanie na region */ map.setCenter(bounds.getCenter()); map.fitBounds(bounds); map.setZoom(map.getZoom() + 1); } } xmlhttp_region.open("GET", url_region, true); xmlhttp_region.send(null); } function mapShowSRObjects() { var mapOptions = { mapTypeId: google.maps.MapTypeId.ROADMAP }; var bounds = new google.maps.LatLngBounds(); var map = new google.maps.Map(document.getElementById("map_canvas"), mapOptions); xmlhttp_region = getXmlHttp(); url_region = baseUrl + '/ajax/bordersrmapdata/lang/' + locale + '/border.txt'; xmlhttp_objects = getXmlHttp(); url_objects = baseUrl + '/ajax/regionmapdata/lang/' + locale + '/data.xml'; xmlhttp_region.onreadystatechange = function() { if (xmlhttp_region.readyState == 4) { /* * Region */ var points = Array(); /* * XML */ /* var xmlDoc = xmlhttp_region.responseXML; var borderData = xmlDoc.getElementsByTagName('object'); for (i = 0; i < borderData.length; i++) { var point = new GLatLng(parseFloat(borderData[i].getAttribute("gps_n")), parseFloat(borderData[i].getAttribute("gps_e"))); points.push(point); } */ /* * JSON */ var xmlDoc = xmlhttp_region.responseText; // var borderData = JSON.parse(xmlDoc); var borderData = eval(xmlDoc); for (i = 0; i < borderData.length; i++) { try { var point = new google.maps.LatLng(parseFloat(borderData[i][0]), parseFloat(borderData[i][1])); bounds.extend(point); points.push(point); } catch (ex) { // chybne data } } var strokeColor = "#000077"; var strokeWeight = 3; var strokeOpacity = 1; var fillColor = "#0000ff"; var fillOpacity = 0.2; var polygon = new google.maps.Polygon( { paths: points, strokeColor: strokeColor, strokeOpacity: strokeOpacity, strokeWeight: strokeWeight, fillColor: fillColor, fillOpacity: fillOpacity }); polygon.setMap(map); /* * centrovanie na region */ map.setCenter(bounds.getCenter()); map.fitBounds(bounds); map.setZoom(map.getZoom + 1); } } xmlhttp_objects.onreadystatechange = function() { if (xmlhttp_objects.readyState == 4) { var xmlDoc = xmlhttp_objects.responseXML; /* * Objekty */ var markersData = xmlDoc.getElementsByTagName('object'); var latlngbounds = new google.maps.LatLngBounds(); // hranice oblasti s markermi - kvoli centrovaniu mapy //alert(markersData.length); for (i = 0; i < markersData.length; i++) { var point = new google.maps.LatLng(parseFloat(markersData[i].getAttribute("gps_n")), parseFloat(markersData[i].getAttribute("gps_e"))); var info = markersData[i].childNodes[0].data; // info o markeri v html formate latlngbounds.extend(point); // rozsirim hranicu o novy marker - kvoli centrovaniu mapy var image = new google.maps.MarkerImage( baseUrl + "/public/pictures/markers/" + markersData[i].getAttribute("color") + ".png", new google.maps.Size(20, 32), // size new google.maps.Point(0, 0), // origin new google.maps.Point(10, 32) // anchor ); var marker = new google.maps.Marker({ position: point, map: map, icon: image, info: info, title: markersData[i].getAttribute("name"), //zIndex: beach[3] }); var infowindow = new google.maps.InfoWindow(); google.maps.event.addListener(marker, "click", function() { infowindow.setContent(this.info); infowindow.open(map, this); }); } } } xmlhttp_region.open("GET", url_region, true); xmlhttp_objects.open("GET", url_objects, true); xmlhttp_region.send(null); xmlhttp_objects.send(null); } function regionShowObjects(regionId, types, districtId) { $(".filtered-objects").fadeOut('slow'); $.ajax({ type: "GET", url: baseUrl + "/ajax/filteredobjects/lang/" + locale + '/districtId/' + districtId + '/types/' + types }).done(function(data) { $("#filtered-objects").html(data); $("#filtered-objects").fadeIn('slow'); $("#region-details-container").fadeOut('slow'); }); mapShowRegion(regionId, types, districtId); } function mapShowRegion(region_id, type, districtId) { if (typeof type == 'undefined') { type = 4; } if (typeof districtId == 'undefined') { districtId = 0; } var mapOptions = { zoom: 7, mapTypeId: google.maps.MapTypeId.ROADMAP }; var bounds = new google.maps.LatLngBounds(); map = new google.maps.Map(document.getElementById("map_canvas"), mapOptions); xmlhttp_region = getXmlHttp(); url_region = baseUrl + '/ajax/bordermapdata/lang/' + locale + '/region_id/' + region_id + '/border.txt'; xmlhttp_objects = getXmlHttp(); url_objects = baseUrl + '/ajax/regionmapdata/lang/' + locale + '/region_id/' + region_id + '/type/' + type + '/okres_id/' + districtId + '/data.xml'; xmlhttp_region.onreadystatechange = function() { if (xmlhttp_region.readyState == 4) { /* * Region */ var points = Array(); /* * JSON */ var xmlDoc = xmlhttp_region.responseText; // var borderData = JSON.parse(xmlDoc); var borderData = eval(xmlDoc); for (i = 0; i < borderData.length; i++) { try { var point = new google.maps.LatLng(parseFloat(borderData[i][0]), parseFloat(borderData[i][1])); bounds.extend(point); points.push(point); } catch (ex) { // chybne data } } var strokeColor = "#000077"; var strokeWeight = 3; var strokeOpacity = 1; var fillColor = "#0000ff"; var fillOpacity = 0.2; polygon = new google.maps.Polygon( { paths: points, strokeColor: strokeColor, strokeOpacity: strokeOpacity, strokeWeight: strokeWeight, fillColor: fillColor, fillOpacity: fillOpacity }); polygon.setMap(map); /* * centrovanie na region */ map.setCenter(bounds.getCenter()); map.fitBounds(bounds) //map.setZoom(map.getZoom()+2); } } xmlhttp_objects.onreadystatechange = function() { if (xmlhttp_objects.readyState == 4) { var xmlDoc = xmlhttp_objects.responseXML; /* * Objekty */ var markersData = xmlDoc.getElementsByTagName('object'); var latlngbounds = new google.maps.LatLngBounds(); // hranice oblasti s markermi - kvoli centrovaniu mapy //alert(markersData.length); for (i = 0; i < markersData.length; i++) { var point = new google.maps.LatLng(parseFloat(markersData[i].getAttribute("gps_n")), parseFloat(markersData[i].getAttribute("gps_e"))); var info = markersData[i].childNodes[0].data; // info o markeri v html formate latlngbounds.extend(point); // rozsirim hranicu o novy marker - kvoli centrovaniu mapy var image = new google.maps.MarkerImage( baseUrl + "/public/pictures/markers/" + markersData[i].getAttribute("color") + ".png", new google.maps.Size(20, 32), // size new google.maps.Point(0, 0), // origin new google.maps.Point(10, 32) // anchor ); var marker = new google.maps.Marker({ position: point, map: map, icon: image, info: info, title: markersData[i].getAttribute("name"), //zIndex: beach[3] }); var infowindow = new google.maps.InfoWindow(); google.maps.event.addListener(marker, "click", function() { //showStreetView(this.position); //console.log(this.position) ; infowindow.setContent(this.info); infowindow.open(map, this); }); google.maps.event.addListener(marker, "mouseover", function() { // alert(this.name.id + ': ' + this.name.b); //document.getElementById("map_info_region").innerHTML = this.title; }); google.maps.event.addListener(marker, "mouseout", function() { //document.getElementById("map_info_region").innerHTML = ' '; }); } } } xmlhttp_region.open("GET", url_region, true); xmlhttp_objects.open("GET", url_objects, true); xmlhttp_region.send(null); xmlhttp_objects.send(null); } /** * Nacitanie markerov definovanych pomocou url do mapy * */ function mapShowObject(object_id) { var elm = document.getElementById('map_canvas_obj_' + object_id); var mapOptions = { zoom: 15, mapTypeId: google.maps.MapTypeId.ROADMAP }; map = new google.maps.Map(elm, mapOptions); Url = baseUrl + '/ajax/objectmapdata/lang/' + locale + '/object_id/' + object_id + '/mode/0'; xmlhttp = getXmlHttp(); xmlhttp.onreadystatechange = function() { if (xmlhttp.readyState == 4) { var xmlDoc = xmlhttp.responseXML; var markersData = xmlDoc.getElementsByTagName('object'); var point = new google.maps.LatLng(parseFloat(markersData[0].getAttribute("gps_n")), parseFloat(markersData[0].getAttribute("gps_e"))); var image = new google.maps.MarkerImage( baseUrl + "/public/pictures/markers/" + markersData[0].getAttribute("color") + ".png", new google.maps.Size(20, 32), // size new google.maps.Point(0, 0), // origin new google.maps.Point(10, 32) // anchor ); var marker = new google.maps.Marker({ position: point, map: map, icon: image, title: markersData[0].getAttribute("name") }); var infowindow = new google.maps.InfoWindow(); google.maps.event.addListener(marker, "click", function() { //console.log(markersData[0]); showStreetView({"n": parseFloat(markersData[0].getAttribute("gps_n")), "e": parseFloat(markersData[0].getAttribute("gps_e"))}, markersData[0].getAttribute("name")); }); google.maps.event.addListener(marker, "mouseover", function() { //document.getElementById("map_info_obj_" + object_id).innerHTML = this.title; }); google.maps.event.addListener(marker, "mouseout", function() { //document.getElementById("map_info_obj_" + object_id).innerHTML = ' '; }); map.setCenter(point); } } xmlhttp.open("GET", Url, true); xmlhttp.send(null); } /** * Nacitanie markerov definovanych pomocou url do mapy * */ function getMarkers(Url, map) { xmlhttp = getXmlHttp(); //alert(Url); xmlhttp.onreadystatechange = function() { /* if (xmlhttp.readyState > 0 && xmlhttp.readyState < 4) { if (tagId != null) document.getElementById(tagId).innerHTML = "Aktualizujem..."; } else */ if (xmlhttp.readyState == 4) { var xmlDoc = xmlhttp.responseXML; var markersData = xmlDoc.getElementsByTagName('object'); var latlngbounds = new google.maps.LatLngBounds(); // hranice oblasti s markermi - kvoli centrovaniu mapy //alert(markersData.length); for (i = 0; i < markersData.length; i++) { var point = new google.maps.LatLng(parseFloat(markersData[i].getAttribute("gps_n")), parseFloat(markersData[i].getAttribute("gps_e"))); var info = markersData[i].childNodes[0].data; // info o markeri v html formate latlngbounds.extend(point); // rozsirim hranicu o novy marker - kvoli centrovaniu mapy marker = new GMarker(point, {draggable: false, name: info}); map.addOverlay(marker); GEvent.addListener(marker, "click", function() { this.openInfoWindowHtml(this.name); }); } map.setCenter(latlngbounds.getCenter( ), map.getBoundsZoomLevel(latlngbounds)); } } xmlhttp.open("GET", Url, true); xmlhttp.send(null); } /** * @author jsilaci */ var hladaj_v_krajine = 'slovensko'; /** * Pridanie event listeneru k elementu * @param {String} elementID - element, ku ktoremu pridavame listener * @param {String} action - akcia, ktora aktivuje listener bez predpony "on" * @param {Function} fnc - funkcia, ktora sa zavola po aktivacii */ function addListener(elementId, action, fnc) { var elm = document.getElementById(elementId); if (elm != null) { if (elm.addEventListener) { elm.addEventListener(action, fnc, false); elm.addEventListener(action, fnc, false); } else if (el.attachEvent) { elm.attachEvent("on" + action, fnc); elm.attachEvent("on" + action, fnc); } } } /** * @author * Funkcia vytvori objekt typu xmlHTTPRequest a vrati ho. Objekt bude vytvoreny v zavislosti od typu prehliadaca. */ function getXmlHttp() { var xmlhttp = false; if (!xmlhttp && typeof XMLHttpRequest != 'undefined') { try { xmlhttp = new XMLHttpRequest(); } catch (e) { xmlhttp = false; } } if (!xmlhttp && window.createRequest) { try { xmlhttp = window.createRequest(); } catch (e) { xmlhttp = false; } } return xmlhttp; } // vytvorim novy xmlhttprequest objekt na komunikaciu //var xmlhttp = getXmlHttp(); /** * Nacitanie textu zo zadanej url do HTML elementu pomocou aobjektu xmlhttprequest * @param {Object} textUrl - adresa subor, ktoreho obsah sa nacita * @param {Object} tagId - id HTML elementu, ktoreho obsah sa nahradi (innerHTML) * @param {Function} onLoad - nazov funkcie, ktora sa zavola po ukonceni requestu - zadava sa nazov fcie bez () a bez uvodzoviek */ function getContent(Url, tagId, onLoad) { // var xmlhttp = new XMLHttpRequest(); var xmlhttp = getXmlHttp(); // otvorim poziadavku xmlhttp.open("GET", Url, true); // pridam funkciu pre spracovanie zmeny stavu xmlhttp requestu - anonymna fcia /* * Stavy objektu XMLHttpRequest * 0 poziadavka nebola inicializovana * 1 poziadavka je pripravena * 2 poziadavka bola odoslana * 3 pozidavka sa spracuva * 4 poziadavka je dokoncena */ xmlhttp.onreadystatechange = function() { if (xmlhttp.readyState > 0 && xmlhttp.readyState < 4) { if (tagId != null) document.getElementById(tagId).innerHTML = "Aktualizujem..."; } else if (xmlhttp.readyState == 4) { if (tagId != null) document.getElementById(tagId).innerHTML = xmlhttp.responseText; // alert(xmlhttp.responseText); if (onLoad != null) { onLoad(); } } } // poslem poziadavku xmlhttp.send(null); } function anketa_hlasuj(anketa_id, odpoved_id, locale) { getContent(baseUrl + "/ajax/anketa/odpoved_id/" + odpoved_id + "/anketa_id/" + anketa_id + '/locale/' + locale, 'anketa', null); } function search_setRegion(region_id) { if (hladaj_v_krajine == 'slovensko') getContent(baseUrl + "/ajax/getskokresy/region_id/" + region_id + '/locale/' + locale, 'SEARCH_OKRES', null); else getContent(baseUrl + "/ajax/getczokresy/region_id/" + region_id + '/locale/' + locale, 'SEARCH_OKRES', null); } function search_setTyp(typ_id) { if (hladaj_v_krajine == 'slovensko') getContent(baseUrl + "/ajax/getskdruhy/typ_id/" + typ_id + '/locale/' + locale, 'SEARCH_DRUH', null); else getContent(baseUrl + "/ajax/getczdruhy/typ_id/" + typ_id + '/locale/' + locale, 'SEARCH_DRUH', null); } function filter_setTyp(typ_id) { if (hladaj_v_krajine == 'slovensko') getContent(baseUrl + "/ajax/getdruhy/typ_id/" + typ_id + '/locale/' + locale, 'filter_druh', null); } function search_krajina(krajina) { hladaj_v_krajine = krajina; if (hladaj_v_krajine == 'slovensko') { getContent(baseUrl + "/ajax/getskregiony/locale/" + locale, 'SEARCH_REGION', null); getContent(baseUrl + "/ajax/getskokresy/region_id/" + 0 + '/locale/' + locale, 'SEARCH_OKRES', null); getContent(baseUrl + "/ajax/getsktypy/locale/" + locale, 'SEARCH_TYP', null); getContent(baseUrl + "/ajax/getskdruhy/typ_id/" + 0 + '/locale/' + locale, 'SEARCH_DRUH', null); } else { getContent(baseUrl + "/ajax/getczregiony/locale/" + locale, 'SEARCH_REGION', null); getContent(baseUrl + "/ajax/getczokresy/region_id/" + 0 + '/locale/' + locale, 'SEARCH_OKRES', null); getContent(baseUrl + "/ajax/getcztypy/locale/" + locale, 'SEARCH_TYP', null); getContent(baseUrl + "/ajax/getczdruhy/typ_id/" + 0 + '/locale/' + locale, 'SEARCH_DRUH', null); } }/** * @author jsilaci */ function checkFormRezeracia() { // alert('test'); var ok = true; var form = document.getElementById('reservation_form'); if (form.REZ_MENO.value == '') { form.REZ_MENO.style.backgroundColor = '#f00'; ok = false; } else { form.REZ_MENO.style.backgroundColor = '#0f0'; } if (form.REZ_PRIEZVISKO.value == '') { form.REZ_PRIEZVISKO.style.backgroundColor = '#f00'; ok = false; } else { form.REZ_PRIEZVISKO.style.backgroundColor = '#0f0'; } if (form.REZ_EMAIL.value == '') { form.REZ_EMAIL.style.backgroundColor = '#f00'; ok = false; } else { if (!form.REZ_EMAIL.value.match('^[a-zA-z1-9\\.\\-_]+@[a-zA-z1-9\\-_]+\\.{1}[a-zA-z1-9\\-\\._]+')) { form.REZ_EMAIL.style.backgroundColor = '#f00'; ok = false; } else { form.REZ_EMAIL.style.backgroundColor = '#0f0'; } } return ok; } function checkFormMessage() { // alert('test'); var ok = true; var form = document.getElementById('reservation_form'); if (form.REZ_MENO.value == '') { form.REZ_MENO.style.backgroundColor = '#f00'; ok = false; } else { form.REZ_MENO.style.backgroundColor = '#0f0'; } if (form.REZ_EMAIL.value == '') { form.REZ_EMAIL.style.backgroundColor = '#f00'; ok = false; } else { if (!form.REZ_EMAIL.value.match('^[a-zA-z1-9\\.\\-_]+@[a-zA-z1-9\\-_]+\\.{1}[a-zA-z1-9\\-\\._]+')) { form.REZ_EMAIL.style.backgroundColor = '#f00'; ok = false; } else { form.REZ_EMAIL.style.backgroundColor = '#0f0'; } } return ok; }// Script for NiftyPlayer 1.7, by tvst from varal.org // Released under the MIT License: http://www.opensource.org/licenses/mit-license.php var FlashHelper = { movieIsLoaded : function (theMovie) { if (typeof(theMovie) != "undefined") return theMovie.PercentLoaded() == 100; else return false; }, getMovie : function (movieName) { if (navigator.appName.indexOf ("Microsoft") !=-1) return window[movieName]; else return document[movieName]; } }; function niftyplayer(name) { this.obj = FlashHelper.getMovie(name); if (!FlashHelper.movieIsLoaded(this.obj)) return; this.play = function () { this.obj.TCallLabel('/','play'); }; this.stop = function () { this.obj.TCallLabel('/','stop'); }; this.pause = function () { this.obj.TCallLabel('/','pause'); }; this.playToggle = function () { this.obj.TCallLabel('/','playToggle'); }; this.reset = function () { this.obj.TCallLabel('/','reset'); }; this.load = function (url) { this.obj.SetVariable('currentSong', url); this.obj.TCallLabel('/','load'); }; this.loadAndPlay = function (url) { this.load(url); this.play(); }; this.getState = function () { var ps = this.obj.GetVariable('playingState'); var ls = this.obj.GetVariable('loadingState'); // returns // 'empty' if no file is loaded // 'loading' if file is loading // 'playing' if user has pressed play AND file has loaded // 'stopped' if not empty and file is stopped // 'paused' if file is paused // 'finished' if file has finished playing // 'error' if an error occurred if (ps == 'playing') if (ls == 'loaded') return ps; else return ls; if (ps == 'stopped') if (ls == 'empty') return ls; if (ls == 'error') return ls; else return ps; return ps; }; this.getPlayingState = function () { // returns 'playing', 'paused', 'stopped' or 'finished' return this.obj.GetVariable('playingState'); }; this.getLoadingState = function () { // returns 'empty', 'loading', 'loaded' or 'error' return this.obj.GetVariable('loadingState'); }; this.registerEvent = function (eventName, action) { // eventName is a string with one of the following values: onPlay, onStop, onPause, onError, onSongOver, onBufferingComplete, onBufferingStarted // action is a string with the javascript code to run. // // example: niftyplayer('niftyPlayer1').registerEvent('onPlay', 'alert("playing!")'); this.obj.SetVariable(eventName, action); }; return this; } /* Slimbox v2.03 - The ultimate lightweight Lightbox clone for jQuery (c) 2007-2009 Christophe Beyls MIT-style license. */ var var_counter_text = "{x} / {y}"; (function(w){var E=w(window),u,g,F=-1,o,x,D,v,y,L,s,n=!window.XMLHttpRequest,e=window.opera&&(document.compatMode=="CSS1Compat")&&(w.browser.version>=9.3),m=document.documentElement,l={},t=new Image(),J=new Image(),H,a,h,q,I,d,G,c,A,K;w(function(){w("body").append(w([H=w('
')[0],a=w('
')[0],G=w('
')[0]]).css("display","none"));h=w('
').appendTo(a).append(q=w('
').append([I=w('').click(B)[0],d=w('').click(f)[0]])[0])[0];c=w('
').appendTo(G).append([w('').add(H).click(C)[0],A=w('
')[0],K=w('
')[0],w('
')[0]])[0]});w.slimbox=function(O,N,M){u=w.extend({loop:false,overlayOpacity:0.8,overlayFadeDuration:400,resizeDuration:400,resizeEasing:"swing",initialWidth:250,initialHeight:250,imageFadeDuration:400,captionAnimationDuration:400,counterText:var_counter_text,closeKeys:[27,88,67],previousKeys:[37,80],nextKeys:[39,78]},M);if(typeof O=="string"){O=[[O,N]];N=0}y=E.scrollTop()+((e?m.clientHeight:E.height())/2);L=u.initialWidth;s=u.initialHeight;w(a).css({top:Math.max(0,y-(s/2)),width:L,height:s,marginLeft:-L/2}).show();v=n||(H.currentStyle&&(H.currentStyle.position!="fixed"));if(v){H.style.position="absolute"}w(H).css("opacity",u.overlayOpacity).fadeIn(u.overlayFadeDuration);z();k(1);g=O;u.loop=u.loop&&(g.length>1);return b(N)};w.fn.slimbox=function(M,P,O){P=P||function(Q){return[Q.href,Q.title]};O=O||function(){return true};var N=this;return N.unbind("click").click(function(){var S=this,U=0,T,Q=0,R;T=w.grep(N,function(W,V){return O.call(S,W,V)});for(R=T.length;Q=0)?C():(M(N,u.nextKeys)>=0)?f():(M(N,u.previousKeys)>=0)?B():false}function B(){return b(x)}function f(){return b(D)}function b(M){if(M>=0){F=M;o=g[F][0];x=(F||(u.loop?g.length:0))-1;D=((F+1)%g.length)||(u.loop?0:-1);r();a.className="lbLoading";l=new Image();l.onload=j;l.src=o}return false}function j(){a.className="";w(h).css({backgroundImage:"url("+o+")",visibility:"hidden",display:""});w(q).width(l.width);w([q,I,d]).height(l.height);w(A).html(g[F][1]||"");w(K).html((((g.length>1)&&u.counterText)||"").replace(/{x}/,F+1).replace(/{y}/,g.length));if(x>=0){t.src=g[x][0]}if(D>=0){J.src=g[D][0]}L=h.offsetWidth;s=h.offsetHeight;var M=Math.max(0,y-(s/2));if(a.offsetHeight!=s){w(a).animate({height:s,top:M},u.resizeDuration,u.resizeEasing)}if(a.offsetWidth!=L){w(a).animate({width:L,marginLeft:-L/2},u.resizeDuration,u.resizeEasing)}w(a).queue(function(){w(G).css({width:L,top:M+s,marginLeft:-L/2,visibility:"hidden",display:""});w(h).css({display:"none",visibility:"",opacity:""}).fadeIn(u.imageFadeDuration,i)})}function i(){if(x>=0){w(I).show()}if(D>=0){w(d).show()}w(c).css("marginTop",-c.offsetHeight).animate({marginTop:0},u.captionAnimationDuration);G.style.visibility=""}function r(){l.onload=null;l.src=t.src=J.src=o;w([a,h,c]).stop(true);w([I,d,h,G]).hide()}function C(){if(F>=0){r();F=x=D=-1;w(a).hide();w(H).stop().fadeOut(u.overlayFadeDuration,k)}return false}})(jQuery); // AUTOLOAD CODE BLOCK (MAY BE CHANGED OR REMOVED) if (!/android|iphone|ipod|series60|symbian|windows ce|blackberry/i.test(navigator.userAgent)) { jQuery(function($) { $("a[rel^='lightbox']").slimbox({/* Put custom options here */}, null, function(el) { return (this == el) || ((this.rel.length > 8) && (this.rel == el.rel)); }); }); }function createCookie(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=/"; } function readCookie(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; } function eraseCookie(name) { createCookie(name,"",-1); } function initHeaderSlideshow() { $('#header-slideshow').anythingSlider( { buildNavigation: false, // If true, buildsa list of anchor links to link to each panel autoPlay: true // This turns off the entire slideshow FUNCTIONALY, not just if it starts running or not } ); $('#header-slideshow').show(); if (readCookie('Weather') == null) { $('#infobanner-popup').fadeIn('slow'); setTimeout("$('#infobanner-popup').fadeOut('slow')", 15000); } } function searchObjects(text) { $.ajax({ url: baseUrl + "/ajax/search", data: { text: text, lang: locale, ubytovanie: false, kupaliska: false, lyzovanie: false, restauracie: false, kultura: false }, async: true, success: function(data){ $('#quick_results').html(data); if (data.length > 0) $('#quick_results').show(); } }); } function initSearchForm() { $searchField = $('#header_search_field'); $searchField.bind('focus', function() { $searchField.val(''); $searchField.css('color', '#337'); }); $searchField.bind('focusout', function() { //$searchField.val(translate['search'] + '...'); //$searchField.css('color', '#fff'); setTimeout("$('#quick_results').hide();", 500); }); $searchField.bind('keyup', function() { var text = $searchField.val(); if (text.length > 2) { searchObjects(text); } else { $('#quick_results').hide(); } }); } /** * EXAMPLE * * kukni aj https://developers.google.com/maps/documentation/directions/#Waypoints */ function RoutePlanner() { var directionDisplay; var directionsService = new google.maps.DirectionsService(); //var map = null; var markersArray = new Array(); this.clearMarkers = function() { if (markersArray) { for (i in markersArray) { markersArray[i].setMap(null); } } } this.initMap = function() { directionsDisplay = new google.maps.DirectionsRenderer(); var mapOptions = { zoom: 7, mapTypeId: google.maps.MapTypeId.ROADMAP, center: new google.maps.LatLng(gpsToReal(48, 44, 9), gpsToReal(19, 8, 37.58)) }; map = new google.maps.Map(document.getElementById('map_canvas'), mapOptions); directionsDisplay.setMap(map); directionsDisplay.setPanel(document.getElementById('map_directions')); //var control = document.getElementById(''); //map.controls[google.maps.ControlPosition.TOP].push(control); } this.calcRoute = function() { var wayPointNames = new Array(); $points = $("input[name='point']"); /* Zaujimaju ma len tie, ktore maju nejaky nazov */ for (var j = 0; j < $points.size(); j++) { var name = $points.eq(j).val(); if (name != '') { wayPointNames.push({ location: $points.eq(j).val(), stopover: true }); } } console.log(wayPointNames); if (wayPointNames[0] === undefined) { return; } var start = wayPointNames[0].location; var end = wayPointNames[wayPointNames.length - 1].location; // odstranit start a ciel z medzizastavok wayPointNames.pop(); wayPointNames.shift(); // vyhnut sa dialniciam var highways; if ($('#planner_highways').attr('checked') == 'checked') noHighways = true; else noHighways = false; var request = { origin: start, waypoints: wayPointNames, destination: end, travelMode: google.maps.DirectionsTravelMode.DRIVING, avoidHighways: noHighways, avoidTolls: noHighways, region: 'sk' }; directionsService.route(request, function(response, status) { if (status == google.maps.DirectionsStatus.OK) { directionsDisplay.setDirections(response); //console.log(response.routes[0]); var distance = 0; var duration = 0; for (var i = 0; i < response.routes[0].legs.length; i++) { // console.log(response.routes[0].legs[i].end_address, response.routes[0].legs[i].distance.text, response.routes[0].legs[i].duration.text); distance += response.routes[0].legs[i].distance.value; duration += response.routes[0].legs[i].duration.value; } routePlanner.showNearObjects(response.routes[0].overview_path); distance = distance / 1000; var hours = Math.round(duration / 3600); var minutes = Math.round(duration % 3600 / 60); var fuel = utils.roundTo($('#planner_fuelCons').val() * distance / 100, 2); var price = utils.roundTo($('#planner_fuelPrice').val() * fuel, 2); $('#planner_distance').html(distance + 'km'); $('#planner_time').html(hours + 'hod ' + minutes + 'min'); $('#planner_fuel').html(fuel + ' l'); $('#planner_price').html(price + ' €'); $('#planner_statistics').fadeIn(); } }); } this.showNearObjects = function(route) { $.ajax({ url: baseUrl + "/ajax/route", type: 'POST', dataType: 'xml', data: { route: JSON.stringify(route) }, success: function(xmlDoc) { var markersData = xmlDoc.getElementsByTagName('object'); var latlngbounds = new google.maps.LatLngBounds(); // hranice oblasti s markermi - kvoli centrovaniu mapy routePlanner.clearMarkers(); for (var i = 0; i < markersData.length; i++) { var point = new google.maps.LatLng(parseFloat(markersData[i].getAttribute("gps_n")), parseFloat(markersData[i].getAttribute("gps_e"))); var info = markersData[i].childNodes[0].data; // info o markeri v html formate latlngbounds.extend(point); // rozsirim hranicu o novy marker - kvoli centrovaniu mapy var image = new google.maps.MarkerImage( baseUrl + "/public/pictures/markers/" + markersData[i].getAttribute("color") + ".png", new google.maps.Size(20, 32), // size new google.maps.Point(0, 0), // origin new google.maps.Point(10, 32) // anchor ); var marker = new google.maps.Marker({ position: point, map: map, icon: image, info: info, title: markersData[i].getAttribute("name"), //zIndex: beach[3] }); // markery odkladam do pola, aby som ich mohol potom vymazat markersArray.push(marker); var infowindow = new google.maps.InfoWindow(); google.maps.event.addListener(marker, "click", function() { infowindow.setContent(this.info); infowindow.open(map, this); }); google.maps.event.addListener(marker, "mouseover", function() { }); google.maps.event.addListener(marker, "mouseout", function() { }); } //map.setCenter(latlngbounds.getCenter()); //map.fitBounds(latlngbounds); //map.setZoom(map.getZoom()); } }); } this.showStreetView = function(data, status) { if (status == google.maps.StreetViewStatus.OK) { if (data.location.latLng) { var panorama = map.getStreetView(); panorama.setPosition(data.location.latLng); panorama.setPov({ heading: 265, zoom: 1, pitch: 0 }); panorama.setVisible(true); } } } this.addThroughPoint = function() { $("#route_through").append('
'); } } var routePlanner = new RoutePlanner();