function geocodeLatLng(geocoder, input) { var latlngStr = input.split(',', 2); var lat = latlngStr[0]; var lng = latlngStr[1]; var latlng = {lat: parseFloat(lat), lng: parseFloat(lng)}; geocoder.geocode({'location': latlng}, function(results, status) { if (status === google.maps.GeocoderStatus.OK) { if (results) { current_center = results[0].geometry.location; for (i=0;i 0) { toilet_list = toilet_list.split(','); toilet_list_length = toilet_list.length; for (i=0;i -1) { current_list = current.split(','); for (i=0;i 0) { for (var i = 0; i < fail_list.length; i++) { element_name = fail_list[i]; document.getElementById(element_name).style.backgroundColor = 'red'; } return false; } else {return true;} } function clear_boxes(which) { current_value = document.getElementById(which).value; new_value = current_value.replace(/[^a-zA-Z0-9, -]/, ""); document.getElementById(which).value = new_value; document.getElementById(which).style.backgroundColor = ''; document.getElementById(which + '_lat').value = ''; document.getElementById(which + '_lng').value = ''; } function clear_box_list(which) { list = which.split(','); for (var i = 0; i < list.length; i++) { box_name = list[i]; document.getElementById(box_name).value = ''; } } function empty_boxes(which) { color = document.getElementById(which).style.backgroundColor; if (color == 'red') { document.getElementById(which).value = ''; document.getElementById(which).style.backgroundColor = ''; } } function remove_green() { flightPath.setMap(null); document.getElementById('directions_1').style.display = 'none'; document.getElementById('directions_1_unhide').style.display = 'inline'; document.getElementById('directions_2_button').style.display = 'none'; document.getElementById('directions_2').style.width = '96%'; window.scroll(0, 380); } function remove_red() { flightPath_short.setMap(null); document.getElementById('directions_2').style.display = 'none'; document.getElementById('directions_2_unhide').style.display = 'inline'; document.getElementById('directions_1_button').style.display = 'none'; document.getElementById('directions_1').style.width = '96%'; window.scroll(0, 380); } function add_green() { flightPath.setMap(map); document.getElementById('directions_1').style.display = ''; document.getElementById('directions_1_unhide').style.display = ''; document.getElementById('directions_2_button').style.display = ''; document.getElementById('directions_2').style.width = '48%'; window.scroll(0, 380); } function add_red() { flightPath_short.setMap(map); document.getElementById('directions_2').style.display = ''; document.getElementById('directions_2_unhide').style.display = ''; document.getElementById('directions_1_button').style.display = ''; document.getElementById('directions_1').style.width = '48%'; window.scroll(0, 380); } function check_size() { device = navigator.userAgent; if (device.match(/iPhone|iPad|iPod|Android/i)) { $('head').append(''); $('#head_style').remove(); if (document.getElementById('is_mobile')) { document.getElementById('is_mobile').value = '1'; } else { document.getElementById('is_mobile').value = ''; } url = window.location.href; url = url.split('?'); url_end = url[1]; if (url_end) {if (url_end.substr(0,7) == 'ref=app') {sessionStorage.setItem('popped', 'true');}} var popped = sessionStorage.getItem('popped'); if ((popped != 'true') && (url[1] != 'ref=app')) { var inner_width = window.innerWidth; var inner_height = window.innerHeight; var popup_width = inner_width - 100; var popup_height = inner_height - 600; if (inner_height < inner_width) {var popup_height = 450} if (device.match(/iPhone|iPad|iPod/i)) { if (device.match(/iPad/i)) {var user_device = 'iPad';} else if (device.match(/iPod/i)) {var user_device = 'iPod';} else {var user_device = 'iPhone';} var user_store = 'App Store'; var user_link = 'https://itunes.apple.com/us/app/changing-places-toilet-finder/id1160975684?ls=1&mt=8'; } else { var user_device = 'Android device'; var user_store = 'Play Store'; var user_link = 'https://play.google.com/store/apps/details?id=changingplaces.map1'; } var msg = "

This website works much better when viewed on a PC

" + "

Our free phone app has slightly different features which will work better on your " + user_device + "

" + "

Would you like to download it?

"; $("#dialog").html(msg); $("#dialog").dialog({ resizable: false, modal: true, title: "You are using an " + user_device, height: popup_height, minHeight: 600, width: popup_width, position: { my: "center top", at: "center top", of: window }, buttons: { "Continue to website": function() { sessionStorage.setItem('popped', 'true'); $(this).dialog('close'); }, "Download / open app" : function() { sessionStorage.setItem('popped', 'true'); $(this).dialog('close'); location.replace(user_link); } } }); } } } function check_new_toilet() { var radios = document.getElementsByName('type'); i = 0; while (i < radios.length) { if (radios[i].checked === true) {return true;} i++; } document.getElementById('toilet_type_error').style.display = 'block'; return false; } function movePage(form_name) { height_to_move = document.getElementById(form_name).offsetTop; window.scroll(0, height_to_move); } function print_me(area_name, wrapper) { var head = ""; var body = '<'+wrapper+'>' + document.getElementById(area_name).innerHTML + ''; var content = head + body; myWindow=window.open('','Directions','width=800,height=600'); myWindow.document.write(content); myWindow.document.close(); myWindow.focus(); } function check_public() { var via = document.getElementById('via').value; var toilet_list = document.getElementById('toilet_list').value; var msg = ""; if (via != '') { if (toilet_list != '') { if (toilet_list.indexOf(',') > 0) {var s = 's';} else {var s = '';} msg = "

Due to limitations of Google Maps, on the bus and train routes, the map can't show more than one stop enroute.

" + "

Therefore if you continue to the public transport map, your enroute toilet choice"+ s +" will be deselected.

"; } } else if (toilet_list != '') { if (toilet_list.indexOf(',') > 0) { msg = "

Due to limitations of Google Maps, the map can only have one added toilet on public transportation routes.

" + "

Therefore if you continue to the public transport map, your enroute toilet choices will be deselected.

"; } } if (msg != '') { device = navigator.userAgent; if (device.match(/iPhone|iPad|iPod|Android/i)) { var popup_width = window.innerWidth - 100; var popup_height = window.innerHeight - 200; } else { var popup_height = 500; var popup_width = 580; } $("#dialog_route").html(msg); $("#dialog_route").dialog({ resizable: false, modal: true, title: "Public Transport", height: popup_height, minHeight: 300, width: popup_width, position: { my: "center top", at: "center top", of: window }, buttons: { "Continue anyway": function() { document.getElementById('toilet_list').value = ''; document.getElementById('travel_mode').value = 'transit'; document.getElementById('route_planner').submit(); }, "Stay where I am": function() { $(this).dialog('close'); } } }); } else { document.getElementById('travel_mode').value = 'transit'; document.getElementById('route_planner').submit(); } } function check_dest () { var origin = document.getElementById('origin').value; var dest = document.getElementById('dest').value; if ((origin != '') && (dest != '')) { document.getElementById('travel_mode').value = 'driving'; document.getElementById('route_planner').submit(); } } function radio_select (radio_id, div_id) { document.getElementById('toilet_type_1').style.bgColor = ''; document.getElementById('toilet_type_2').style.bgColor = ''; document.getElementById('toilet_type_3').style.bgColor = ''; document.getElementById('toilet_type_4').style.bgColor = ''; document.getElementById('toilet_type_5').style.bgColor = ''; document.getElementById(radio_id).checked = true; document.getElementById(div_id).style.bgColor = 'red'; }