var e = document.getElementsByTagName("path"); //alert(); //alert(COLORING); //alert(getColorOfId(3707)); for(var i = 0; i < e.length; i++){ //e[i].setAttribute("onclick","click("+i+")"); //alert(e.length); //continue; var gid = e[i].getAttribute("id"); //alert(gid); var gclass = e[i].getAttribute("class"); if(gid != null){ e[i].setAttribute("onclick","click("+gid+")"); if(COLORING == 1){ if( ((gclass == "KRAJ" | gclass == "PRAHA") && TYPE == "kraje")| ((gclass == "OBEC" | gclass == "PRAHA") && TYPE == "obce") ) { var mColor = getColorOfId(gid); var plusClass = ""; if(mColor == 0)plusClass = "areaNoData"; e[i].setAttribute("style","opacity:"+mColor+";"); e[i].setAttribute("class",gclass+" coloring "+plusClass); } else e[i].setAttribute("class",gclass+" nocoloring"); } if(gid == SELECTED_AREA){ if(gclass == "KRAJ" | gclass == "PRAHA")TYPE = "kraje"; if(gclass == "OBEC")TYPE = "obce"; e[i].setAttribute("class",gclass+" active"); } } if(i==e.length-1)break; } //if(COLORING == 1){ // if(TYPE == "kraje")document.getElementById("active_style").href = "PHP/applets/mapSVG/coloring_kraje_active.css"; // else document.getElementById("active_style").href = "PHP/applets/mapSVG/coloring_obce_active.css"; //} //else { if(TYPE == "kraje")document.getElementById("active_style").href = "CSS/kraje_active.css"; else document.getElementById("active_style").href = "CSS/obce_active.css"; //} function click(gid){ if(TYPE == "obce" & gid < 14)return; var elemMin = document.getElementById("pathSelected"); if(elemMin != null) { if(elemMin.getAttribute("gid") == gid)document.location.href = "http://www.prijmeni.cz/oblast/"+gid+""; elemMin.parentNode.removeChild(elemMin); elemMin = null; } var elem = document.getElementById(gid); var elem2 = elem.cloneNode(true); elem.parentNode.appendChild(elem2); elem2.setAttribute("gid",gid); elem2.setAttribute("style",""); elem2.setAttribute("id","pathSelected"); mapClick(gid); } function getColorOfId(id){ var arr_ids = str_ids.split("*"); var arr_counts = str_counts.split("*"); var pos = -1; for(var i in arr_ids) if(arr_ids[i] == id)pos = i; if(pos == -1)return 0; var ret = parseInt(arr_counts[pos]*1); ret = ((ret/100)*0.8)+0.2; return ret; //ret = rgbToHex(255,255-ret,255-ret); //return ret; } function componentToHex(c) { var hex = c.toString(16); return hex.length == 1 ? "0" + hex : hex; } function rgbToHex(r, g, b) { return "#" + componentToHex(r) + componentToHex(g) + componentToHex(b); }