/* * Ensemble of Javascript functions for GBIF-Sweden's portal * * Copyright 2007-2008 Mickaël Graf & The Swedish Museum of Natural History * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the * Free Software Foundation * 51 Franklin Street, 5th Floor * Boston, MA 02110-1301 USA */ var mapXmlHttp; var colXmlHttp; var classificationMode = ''; function displaySearchBox (obj) { var menus = document.getElementsByTagName ("span"); var boxes = document.getElementsByTagName ("div"); for (i = 0; i < menus.length; i++) { if (/search_menu/.test(menus[i].className)) { menus[i].style.backgroundColor = "transparent"; menus[i].style.color = "#000000"; } } for (i = 0; i < boxes.length; i++){ if (/search_box/.test(boxes[i].className)) { /* Everybody becomes like the invisible man...*/ boxes[i].style.visibility = "hidden"; } } /* now show the box chosen */ document.getElementById(obj.id).style.backgroundColor = "#52983d"; document.getElementById(obj.id).style.color = "#ffffff"; document.getElementById(obj.id + "_search").style.position = "absolute"; document.getElementById(obj.id + "_search").style.top = "20px"; document.getElementById(obj.id + "_search").style.visibility = "visible"; } function showWarning (txt) { document.getElementById("warning").innerHTML = txt; } function removeWarning () { document.getElementById("warning").innerHTML = ""; } function searchRecords () { var q = document.getElementById("q_records").value; if (q.length > 0) { removeWarning (); window.location.assign("http://www.gbif.se/search/" + document.getElementById("q_records").value); } else { showWarning ("Du måste skriva in en artnamn i sökrutan ovanför."); } } function searchMaps () { var q = document.getElementById("q_maps").value; if (q.length > 0) { removeWarning (); window.location.assign("http://observer.gbif.se/search/" + document.getElementById("q_maps").value + "/map/World/"); } else { showWarning ("Du måste skriva in en artnamn i sökrutan ovanför."); } } function startSearching (e, type) { if (window.event) { keynum = e.keyCode; } else if (e.which) { keynum = e.which; } if (keynum == 13) { if (type == "r") { searchRecords(); } else if (type == "m") { searchMaps(); } } } function GetXmlHttpObject() { var objXMLHttp=null; if (window.XMLHttpRequest) { objXMLHttp = new XMLHttpRequest(); } else if (window.ActiveXObject) { objXMLHttp = new ActiveXObject("Microsoft.XMLHTTP"); } return objXMLHttp; } function drawMap (lat, long, width, height) { var url = "http://observer.gbif.se/buildsmallmap.php"; if (!lat || !long) { return false; } url = url + "?la=" + lat + "&lo=" + long + "&w=" + width + "&h=" + height; document.getElementById("map").style.width = width + "px"; document.getElementById("map").style.height = height + "px"; document.getElementById("map").style.border = "1px solid #52983d"; document.getElementById("map").innerHTML = "