var COLORS=[["red","#ff0000"],["orange","#ff8800"],["green","#008000"],["blue","#000080"],["purple","#800080"]];var options={};var lineCounter_=0;var shapeCounter_=0;var markerCounter_=0;var colorIndex_=0;var map;var last_marker;var last_poly;var points=new Array(0);var id_lat,id_lng,id_zoom,id_enpoly,id_enlevel,id_form;var vnrec;var geocoder;var center_marker;function initialize(){}function select(a){document.getElementById("hand_b").className="unselected";document.getElementById("shape_b").className="unselected";document.getElementById("line_b").className="unselected";document.getElementById("placemark_b").className="unselected";document.getElementById(a).className="selected"}function stopEditing(){select("hand_b")}function getColor(a){return COLORS[(colorIndex_++)%COLORS.length][a?0:1]}function getPoints(d){var b=new Array(0);for(var c=0;c<d.getVertexCount();c++){b.push(d.getVertex(c))}return b}function encode(c){myNumLevels=18;myZoomFactor=2;verySmall=0.00001;var d=new PolylineEncoder(myNumLevels,myZoomFactor,verySmall,true);var b=d.dpEncode(c);id_enpoly.value=b.encodedPoints;id_enlevel.value=b.encodedLevels}function placeMarker(){select("placemark_b");var a=GEvent.addListener(map,"click",function(d,e,b){if(e||b){if(b){e=b}select("hand_b");GEvent.removeListener(a);if(vnrec.containsLatLng(e)){var c=getColor(true);marker=new GMarker(e,{icon:getIcon(),draggable:true});if(last_marker){map.removeOverlay(last_marker)}map.addOverlay(marker);last_marker=marker;updateMarker(marker);GEvent.addListener(marker,"dragend",function(){updateMarker(marker)});GEvent.addListener(marker,"click",function(){updateMarker(marker)})}}})}function startLine(){select("line_b");var b=getColor(false);var a=new GPolyline([],b,2);startDrawing(a,"Line "+(++lineCounter_),function(){points=getPoints(a);encode(points)},b)}function startShape(){select("shape_b");var a=getColor(false);var b=new GPolygon([],a,2,0.7,a,0.2);startDrawing(b,"Shape "+(++shapeCounter_),function(){points=getPoints(b);encode(points)},a)}function startDrawing(d,c,b,a){if(last_poly){map.removeOverlay(last_poly)}id_enpoly.value="";id_enlevel.value="";map.addOverlay(d);last_poly=d;d.enableDrawing(options);d.enableEditing({onEvent:"mouseover"});d.disableEditing({onEvent:"mouseout"});GEvent.bind(d,"lineupdated","",b);GEvent.addListener(d,"endline",function(){select("hand_b");GEvent.addListener(d,"click",function(g,f){if(typeof f=="number"){d.deleteVertex(f)}else{var e=getColor(false);d.setStrokeStyle({color:e,weight:4})}})})}function updateMarker(a){if(a){id_lat.value=a.getPoint().y;id_lng.value=a.getPoint().x;id_zoom.value=map.getZoom()}}function clearMarker(){if(last_marker){map.removeOverlay(last_marker)}last_marker=null;id_lat.value="";id_lng.value="";id_zoom.value="";select("hand_b")}function clearPoly(){if(last_poly){map.removeOverlay(last_poly)}last_poly=null;id_enpoly.value="";id_enlevel.value="";select("hand_b")}function clearAll(){clearMarker();clearPoly()}function bindMarker(){if(last_marker){map.removeOverlay(last_marker);marker=new GMarker(last_marker.getPoint(),{icon:getIcon(),draggable:true});map.addOverlay(marker);last_marker=marker;updateMarker(marker);GEvent.addListener(marker,"dragend",function(){updateMarker(marker)});GEvent.addListener(marker,"click",function(){updateMarker(marker)})}}function changePlace(c,a,b){map.setCenter(new GLatLng(c,a),b)}function MoreControl(){}MoreControl.prototype=new GControl();MoreControl.prototype.initialize=function(c){var a=document.createElement("div");var b=document.createElement("div");this.setButtonStyle_(b);b.appendChild(document.createTextNode("Show..."));a.appendChild(b);a.appendChild(document.getElementById("options"));GEvent.addDomListener(b,"click",function(){showOptions()});c.getContainer().appendChild(a);return a};MoreControl.prototype.getDefaultPosition=function(){return new GControlPosition(G_ANCHOR_TOP_RIGHT,new GSize(230,7))};MoreControl.prototype.setButtonStyle_=function(a){a.style.backgroundColor="white";a.style.border="1px solid black";a.style.borderStyle="outset";a.style.borderRightColor="#b0b0b0";a.style.borderBottomColor="#b0b0b0";a.style.padding="1px";a.style.display="block";a.style.textAlign="center";a.style.width="70px";a.style.cursor="pointer";a.id="btnShow"};function showOptions(){if("none"==document.getElementById("options").style.display){document.getElementById("options").style.display="block";document.getElementById("btnShow").innerHTML="Hide..."}else{document.getElementById("options").style.display="none";document.getElementById("btnShow").innerHTML="Show..."}}function GotoControl(){}GotoControl.prototype=new GControl();GotoControl.prototype.initialize=function(c){var a=document.createElement("div");var b=document.createElement("div");this.setButtonStyle_(b);b.appendChild(document.createTextNode("Goto"));a.appendChild(b);a.appendChild(document.getElementById("goto"));c.getContainer().appendChild(a);return a};GotoControl.prototype.getDefaultPosition=function(){return new GControlPosition(G_ANCHOR_TOP_RIGHT,new GSize(310,7))};GotoControl.prototype.setButtonStyle_=function(a){};function gotoAddress(a){if(geocoder){if(a){geocoder.setBaseCountryCode("vn");geocoder.setViewport(vnrec);geocoder.getLatLng("vietnam, "+a,function(b){if(!b){}else{if(vnrec.containsLatLng(b)){map.setCenter(b)}}})}}}function getIcon(c){var b=new GIcon();if(!c){for(var a=0;a<id_form.type.length;a++){if(id_form.type[a].checked){c=id_form.type[a].value;break}}if(!c){c=0}}else{if(c<0){c=0}}b.image="/content/images/map_icons/"+c+".png";b.shadow="/content/images/map_icons/shadow.png";b.iconSize=new GSize(32,37);b.shadowSize=new GSize(51,37);b.iconAnchor=new GPoint(16,35);b.infoWindowAnchor=new GPoint(16,5);return b}function getCenterIcon(){var a=new GIcon();a.image="/content/images/map_icons/center.png";a.iconSize=new GSize(12,12);a.iconAnchor=new GPoint(6,6);return a};
