if (typeof(OFFICER) == "undefined") { OFFICER = false; } // ---- BEGIN -- Util & Setting var getpointurl = "http://traffic.thai.net/rpc/getpoint.php"; var traffic_draw_mode = 'normal'; var camera_time_threshold = 3600; //camera not update in seconds showlinestart = 20; showlinestop = 20; showlinestart_edit = 2; showlinestop_edit = 12; showlinestart_ad = 2; showlinestop_ad = 12; var fetchtraffic = false; var checkfetchtrafficzoomtimer = false; monthLong = ["\u0E21\u0E01\u0E23\u0E32\u0E04\u0E21","\u0E01\u0E38\u0E21\u0E20\u0E32\u0E1E\u0E31\u0E19\u0E18\u0E4C","\u0E21\u0E35\u0E19\u0E32\u0E04\u0E21","\u0E40\u0E21\u0E29\u0E32\u0E22\u0E19","\u0E1E\u0E24\u0E29\u0E20\u0E32\u0E04\u0E21","\u0E21\u0E34\u0E16\u0E38\u0E19\u0E32\u0E22\u0E19","\u0E01\u0E23\u0E01\u0E0F\u0E32\u0E04\u0E21","\u0E2A\u0E34\u0E07\u0E2B\u0E32\u0E04\u0E21","\u0E01\u0E31\u0E19\u0E22\u0E32\u0E22\u0E19","\u0E15\u0E38\u0E25\u0E32\u0E04\u0E21","\u0E1E\u0E24\u0E28\u0E08\u0E34\u0E01\u0E32\u0E22\u0E19","\u0E18\u0E31\u0E19\u0E27\u0E32\u0E04\u0E21"]; monthShort = ["\u0E21.\u0E04.","\u0E01.\u0E1E.","\u0E21\u0E35.\u0E04.","\u0E40\u0E21.\u0E22.","\u0E1E.\u0E04.","\u0E21\u0E34.\u0E22.","\u0E01.\u0E04.","\u0E2A.\u0E04.","\u0E01.\u0E22.","\u0E15.\u0E04.","\u0E1E.\u0E22.","\u0E18.\u0E04."]; var jsonreqcnt = 0; var jsonreqnode = new Array(); var fflush = true; var statrotate = new Array(); var gettraffic_timer = false; var accident_customdiv = new Array(); var pointrequest; var search_keyword = ""; var searchdiv = new Array(); var showadroute = false; var adroutedata = {}; var adroutepart = []; var cronjobtimer = false; var dnews1timer = false; var dnews2timer = false; var updatestattimer = false; //----------police traffic------------ var viewoldevents = false; var ptf = false; var camrefresh = false; //----------------------------------- // set updateinterval = -1 to disable update function doCronJob(updateinterval) { //alert("Entering doCronjob(" + updateinterval + ")"); if (cronjobtimer) { clearTimeout(cronjobtimer); } if (updateinterval != -1) { if (accident_timer) { clearTimeout(accident_timer);}; accident_timer = setTimeout("mapupdate();", 1000); if (dnews1timer) { clearTimeout(dnews1timer);}; if(viewoldevents==false) { //add by Nutt ->& viewoldevents==false dnews1timer = setTimeout("dl(1)", 2000); } if(camrefresh) {clearTimeout(camrefresh);} camrefresh = setTimeout("refreshcamera()", 3000); if (dnews2timer) { clearTimeout(dnews2timer);}; dnews2timer = setTimeout("dl(2)", 2000); if (gettraffic_timer) {clearTimeout(gettraffic_timer);}; gettraffic_timer = setTimeout("gettraffic()", 3000); if (checkfetchtrafficzoomtimer) { clearTimeout(checkfetchtrafficzoomtimer);}; checkfetchtrafficzoomtimer = setTimeout("checkfetchtrafficzoom()", 4000); if (updatestattimer) { clearTimeout(updatestattimer);}; updatestattimer = setTimeout("updatestat()", 5000); cronjobtimer = setTimeout("doCronJob(" + updateinterval + ")",updateinterval); } } function addslashes(str) { str=str.replace(/\\/g,'\\\\'); str=str.replace(/\'/g,'\\\''); str=str.replace(/\"/g,'\\"'); str=str.replace(/\0/g,'\\0'); return str; } function replacethaimonth(str){ var convtab = { 'jan' : "ม.ค.", 'feb' : "ก.พ.", 'mar' : "มี.ค.", 'apr' : "เม.ย.", 'may' : "พ.ค.", 'jun' : "มิ.ย.", 'jul' : "ก.ค.", 'aug' : "ส.ค.", 'sep' : "ก.ย.", 'oct' : "ต.ค.", 'nov' : "พ.ย.", 'dec' : "ธ.ค." }; a = str.replace( /[a-z]+/ig, function (word) { if (typeof(convtab[word.toLowerCase()]) != 'undefined') return convtab[word.toLowerCase()]; else return word; } ); return a; } // ---- END -- Util & Setting // ---- BEGIN -- Map Event var debuginfo; function resizenewsdiv(){ var mid = document.getElementById("tabbodycontainer").offsetHeight/2 - 40 - 15; if (typeof(document.getElementById("newsdiv_body").scrollHeight) == 'undefined') n1s = 20; else n1s = document.getElementById("newsdiv_body").scrollHeight; //alert(n1s); if (typeof(document.getElementById("news2div_body").scrollHeight) == 'undefined') n2s = 20; else n2s = document.getElementById("news2div_body").scrollHeight; if (n1s < mid) { document.getElementById("newsdiv_body").style.height = n1s; document.getElementById("news2div_body").style.height = 0;//instead of 2*mid - n1s debuginfo = 1; } else if (n2s < mid) { document.getElementById("newsdiv_body").style.height = 2*mid - n2s; document.getElementById("news2div_body").style.height = 0;//instead of n2s debuginfo = 2; } else { document.getElementById("newsdiv_body").style.height = mid; document.getElementById("news2div_body").style.height = 0; //instead of mid debuginfo = 3; } //*/ // document.getElementById("newsdiv_body").style.maxHeight = document.getElementById("tabbodycontainer").offsetHeight/2 - 50; // document.getElementById("news2div_body").style.maxHeight = document.getElementById("tabbodycontainer").offsetHeight/2 - 50; } var fullscreen = false; function doGoFullScreen() { setFullScreen(true); document.getElementById('restorescreen').style.visibility = "visible"; document.getElementById('restorescreen').innerHTML = " "; document.getElementById('gofullscreen').style.visibility = "hidden"; document.getElementById('gofullscreen').innerHTML = ""; document.getElementById('fullscreentitle').style.visibility = "visible"; document.getElementById('disclaimer').style.visibility = "hidden"; } function doRestoreScreen() { setFullScreen(false); document.getElementById('restorescreen').style.visibility = "hidden"; document.getElementById('restorescreen').innerHTML = ""; document.getElementById('gofullscreen').style.visibility = "visible"; document.getElementById('gofullscreen').innerHTML = " "; document.getElementById('fullscreentitle').style.visibility = "hidden"; document.getElementById('disclaimer').style.visibility = "visible"; } function setFullScreen(_f) { fullscreen = _f; mapresize(); } function mapresize() { chkWinSize(); var newwidth; var newheight; var newtop; if (fullscreen) { newwidth = parseInt(ww) - 5 - 5; newheight = wh; newtop = 5; } else { newwidth = ww - 235; newheight = parseInt(wh) - 124 - 15 - 5 - document.getElementById('midbar').offsetHeight; newtop = 124 + document.getElementById('midbar').offsetHeight; // normal top } document.getElementById("rightpanel").style.display = 'block'; document.getElementById("rightpanel").style.left = parseInt(ww) - 235 - 5; document.getElementById("rightpanel").style.height = newheight; document.getElementById("mmmap_div").style.top = newtop; if (gmapjsloaded) { document.getElementById("googlemap_div").style.top = newtop; gmap.setSize(newwidth,newheight); } document.getElementById("rightpanel").style.top = 124 + document.getElementById('midbar').offsetHeight; document.getElementById("tabcontainer").style.height = newheight - parseInt(document.getElementById('searchbox_option').offsetHeight); tabupdate(); setTimeout("resizenewsdiv()",100); if (fullscreen) { document.getElementById("rightpanel").style.visibility = "hidden"; } else { document.getElementById("rightpanel").style.visibility = "visible"; } mmmap.setSize(newwidth,newheight); mmmap.rePaint(); } function popupformwindow(lat, lng){ var succ = window.open('popupform.php?lat=' + lat + '&long=' + lng + '',"accidentreport",'status=no,toolbar=no,menubar=no,location=no,resizable=yes,width=350,height=550'); if (!(succ)) alert("ตรวจพบโปรแกรมป้องกันการเปิดหน้าต่างใหม่\n" + "- ถ้ามีแถบสีเหลือง (Pop-up blocked) ปรากฏด้านบน\n ให้คลิกที่แถบนั้น และเลือก Always Allow Pop-ups from This Site\n\n" + "หากไม่มีแถบปรากฏด้านบน\n" +"- ถ้าคุณใช้ Internet Explorer\n ไปที่เมนู Tools > Pop-up Blocker > Always Allow Pop-ups from This Site\n- ถ้าคุณใช้ Firefox\n Tools > Options > Content ที่บรรทัด Block pop-up windows กด Exceptions \n ใส่ Address of web site เป็น traffic.thai.net กด Allow ตามด้วย Close"); //*/ } function myExtraRightClickFunction() { var txt = '
รายงานเหตุการณ์'; return txt; } function reportAccident(e,lat,lng) { if (!e) var e = window.event; e.cancelBubble = true; if (e.stopPropagation) e.stopPropagation(); e.returnValue = false; popupformwindow(lat,lng); return false; } // ---- END -- Map Event // ---- BEGIN -- Draw Accident var accident_timer = false; function getpoint(mode){ json_request(getpointurl,"","restmp","drawpoint(restmp)"); } function mapupdate(){ // load data and plot if (accident_timer) {clearTimeout(accident_timer); accident_timer = false;} getpoint('all'); } function drawpoint(res){ r = res; updatelock = false; statuscode = {"0": "ปลอดภัยแล้ว", "1": "กำลังจัดการ"}; severitycode = {"1": "โปรดระมัดระวัง", "2": "มีความเสี่ยง", "3": "อันตราย", "4": "งานก่อสร้าง"}; colorcode = {"1": "#FF0000", "2": "#FF9900", "3": "#FFFF00", "4": "#666666"}; pointcount = 0; debug=""; newpointarray = new Array(); newgpointarray = new Array(); newpointarrayinfo = new Array(); for(i=0;i"; } else { testdiv.innerHTML = ""; } popuptitle = testdiv.info.title; t1 = testdiv.info.start_time.substr(0,testdiv.info.start_time.indexOf(" ")); t2 = t1.split("-"); t3 = testdiv.info.start_time.substr(testdiv.info.start_time.indexOf(" ")); t3 = t3.substr(0, t3.lastIndexOf(":")); t2[1] = t2[1].replace(/^0/, ""); t2[2] = t2[2].replace(/^0/, ""); year = parseInt(t2[0]) + 543; sd = (t1 != "0000-00-00")?(t2[2] + " " + monthShort[parseInt(t2[1]) - 1] + " " + year + " " + t3):"ปัจจุบัน"; t1 = testdiv.info.stop_time.substr(0,testdiv.info.stop_time.indexOf(" ")); t2 = t1.split("-"); t2[1] = t2[1].replace(/^0/, ""); t2[2] = t2[2].replace(/^0/, ""); year = parseInt(t2[0]) + 543; t3 = testdiv.info.stop_time.substr(testdiv.info.stop_time.indexOf(" ")); t3 = t3.substr(0, t3.lastIndexOf(":")); td = (t1 != "0000-00-00")?(t2[2] + " " + monthShort[parseInt(t2[1]) - 1] + " " + year + " " + t3):"ปัจจุบัน"; divid = "accident_detail_div_" + testdiv.info.id; var text = ""; //text += "
 
"; // text += "
" + sd + " - " + td + "
" text += "
" + sd + " - " + td + "
" +"ผู้รายงาน: "+testdiv.info.contributor+"
" + "ทางหลวง #" + testdiv.info.routeno + ", กม. ที่ " + testdiv.info.km + ((testdiv.info.kmstop)?(' ถึง ' + testdiv.info.kmstop):'') + "
" + "ทิศทาง: " + testdiv.info.direction + "
" + "บริเวณ: " + testdiv.info.nearplace + "
" + "รายละเอียด: " + ((testdiv.info.comment != "")?testdiv.info.comment:"-") +((testdiv.info.img != '')?"
":'')+"
"; var popuptext = text + (OFFICER?("
  [แก้ไข]
"):''); newpointarray[pointcount] = mmmap.drawCustomDivLevelWithPopup(testdiv, r.result[i].latitude, r.result[i].longitude, popuptitle, 4, 14, popuptext); newpointarrayinfo[pointcount] = testdiv.info; accident_customdiv[testdiv.info.id] = pointcount; // add gpoint if (gmapjsloaded) { var point = new GLatLng(r.result[i].latitude, r.result[i].longitude); var marker = new GMarker(point, gicon[testdiv.info.severity - 1]); marker.mm_isdesc = true; marker.mm_desc = "" + popuptitle + "
" + text; newgpointarray[pointcount] = marker; gmap.gmap_object.addOverlay(marker); } pointcount++; } else { newpointarray[pointcount] = pointarray[matchindex]; newpointarrayinfo[pointcount] = pointarrayinfo[matchindex]; pointarray[matchindex] = -1; accident_customdiv[testdiv.info.id] = pointcount; pointcount++; } } for(i=0;i
[close]'; //imgdiv.style.position = 'absolute'; //imgdiv.onClick = function(){alert("lost");} //imgdiv.style.width = document.getElementById('mmmap_div').style.width; //imgdiv.style.height = document.getElementById('mmmap_div').style.height; //document.getElementById('mmmap_div').style.filter = 'alpha(opacity=50)'; //document.getElementById('mmmap_div').style.opacity = 0.4; //mmmap.drawCustomDiv(imgdiv, latitude, longitude, ""); document.getElementById('imagefrompolice').appendChild(imgdiv); } } function closeFullImg(id) { var todel = document.getElementById(id); todel.parentNode.removeChild(todel); if( document.getElementById('imagefrompolice').innerHTML=='') { document.getElementById('imagefrompolice').style.visibility = "hidden"; } } // ---- END -- Draw Accident // ---- BEGIN -- News Update & Rotate function map_flyto(lat,lng, id, src){ if (currentmode == 'gmap') { gmap.gmap_object.panTo(new GLatLng(lat, lng)); //alert('true'); } else { mmmap.moveTo(lat,lng); //alert('false'); if (id) { // alert('src:'+src+'\n'+'id:'+id+'\n'+pointarray[accident_customdiv[id]]); var dvid = (src=='oldevents')?id:pointarray[accident_customdiv[id]]; //alert(mmmap.getCustomDiv(dvid)); mmmap.getCustomDiv(dvid).onclick(); } } } newsname = ['stat','news','news2']; function dl(dnews){ //alert('dl'); json_request("http://traffic.thai.net/rpc/getnews.php","newsid=" + dnews,"tvar","updatenews('" + dnews + "')"); } function updatenews(dnews){ str = ""; var imgurl; var title; if (dnews == 1) { color = [ '#FF9999','#AA3333', ["#FFE1D5", "#FFEDE3"] ];// #FFD9D9 #FFBCBC typetext = ["","warning", "danger", "don't pass","construstion"]; str = ""; var today = new Date(); today.setHours(0,0,0,0); for(i=0;i" + title + ""; } } document.getElementById("newsdiv_body").innerHTML = str; curevents = str; //------nutt added-------- eventpage = 0; getNextEventsSet(1); //alert('ok'); //----------------------- } else if (dnews == 2) { color = [ '#AAFF99', '#66AA33', ["#E9FFD9", "#CCFFBC"] ]; trafficcolor = ['#AAFFAA','#AAFFAA','#FFD9BC', '#FFBCBC']; trafficcolorborder = ['#AAFFAA','#AAFFAA','#D9BCA0', '#FFA0A0']; //str += ""; //------nutt added------------------------ var today = new Date(); today.setHours(0,0,0,0); //---------------------------------------- for(i=0;i" + title + ""; //str += ""; //str += ""; } //str += "
  • " + title + "
  • "; /*------------- uncomment this when use police report----------- document.getElementById("news2div_body").innerHTML = str; ---------------------------------------------------------------*/ } /* if (fflush == true) { setTimeout("dl('" + (((dnews+1)%2)+1) + "')", 50); if ((dnews+1)%(newsname.length) == 0) fflush = false; } else { if (updateinterval != -1) { setTimeout("dl('" + (((dnews+1)%2)+1) + "')", updateinterval); } } */ setTimeout("resizenewsdiv()", 100); } // ---- END -- News Update & Rotate // ---- BEGIN -- tab management function tabupdate(tname){ tarray = ['main', 'search', 'route', 'help']; if ((tname != null) && (activetab != tname)) { for(i=0;iแก้ไข]'; } else { var textarea = document.createElement("textarea"); textarea.innerHTML = (container.innerHTML=='-')?'':container.innerHTML; container.orgtext = container.innerHTML; textarea.style.padding = 0; textarea.style.width = container.offsetWidth; if (container.offsetHeight < 20) textarea.style.height = 20; else textarea.style.height = container.offsetHeight + 3; textarea.onkeyup = function () { if (this.scrollHeight > this.offsetHeight) this.style.height = this.scrollHeight + 3; }; textarea.onmousedown = function (e){ if (!e) var e = window.event; e.cancelBubble = true; if (e.stopPropagation) e.stopPropagation(); e.returnValue = false; } container.innerHTML = ""; container.appendChild(textarea); textarea.focus(); document.onkeydown='return true'; container.editing = true; editlabel.innerHTML = '[บันทึก | ยกเลิก]'; } } function drawtraffic(id){ colorcode = ["#666666", "#33FF33","#FFFF00","#FF2020","","#0000AA"]; textcode = ["nodata", "Flow","Slow","Block"]; mmmap.gssetlinewidth(3); mmmap.gssetopacity(0.7); if ((roaddata[id] && roaddata[id].present) && (roaddata[id].change || !roaddata[id].opresent)) { if (roaddata[id].shape) { mmmap.removeVector(roaddata[id].shape); roaddata[id].shape = false; } if (roaddata[id].glshape) { gmap.gmap_object.removeOverlay(roaddata[id].glshape); roaddata[id].glshape = false; } if ((roaddata[id].status >= 0) && (roaddata[id].points.length > 1)) { var sls = showlinestart; var slp = showlinestop; var detail = " "; var detailpopup = ""; detail += "รหัส: " + id + "    กม.: " + roaddata[id].meta.startkm + "-" + roaddata[id].meta.stopkm + "
    ช่วง: " + '
    ' + ((roaddata[id].description=='')?'-':roaddata[id].description) + '
    '; if (!showadroute) detail += "
    ล่าสุด: " + roaddata[id].lastupdate.substr(roaddata[id].lastupdate.indexOf(' ') + 1, 5) + "
    "; if (traffic_draw_mode == 'edit') { detailpopup += "รหัส: " + id + "    กม.: " + roaddata[id].meta.startkm + "-" + roaddata[id].meta.stopkm + '
    [แก้ไข]
    ' + "
    ช่วง: " + '
    ' + ((roaddata[id].description=='')?'-':roaddata[id].description) + '
    ' + "
    ล่าสุด: " + roaddata[id].lastupdate.substr(roaddata[id].lastupdate.indexOf(' ') + 1, 5) + "
    "; detailpopup += "
    คลิกเลือกสถานะ
    " + "      " + "      " + "      " + "      " + "
    "; sls = showlinestart_edit; slp = showlinestop_edit; } if (showadroute) { sls = showlinestart_ad; slp = showlinestop_ad; } if (currentmode == "gmap") { var parr = []; var x; var y; for(var i=0; i= showlinestart && z <= showlinestop) || (traffic_draw_mode == 'edit')) { if (fetchtraffic != true) { fetchtraffic = true; updatetraffic(); } } else { fetchtraffic = false; } /* checkfetchtrafficzoomtimer = setTimeout("checkfetchtrafficzoom()", 1000); */ } function showadrouteline(routeid){ /*for(id in roaddata) { if(roaddata[id].status == 5){ roaddata[id].present = false; drawtraffic(id); } }*/ //json_request("http://traffic.thai.net/rpc/getadroute.php", "routeid=" + routeid, "arline", "convadrouteline();"); json_request("http://main.traffic.thai.net/rpc/getadroute.php", "routeid=" + routeid, "arline", "convadrouteline();"); // json_request("http://traffic.thai.net/rpc/getadroute.php", "routeid=" + routeid, "tresult", "showtraffic();"); } function convadrouteline(){ //alert(arline); arline_conv = []; for(var i in arline) arline_conv[arline_conv.length] = {'link_id': arline[i], 'status' : 5,'description' : ''}; tresult = {'result' : arline_conv} //alert(tresult); showtraffic(); } function getadroute(groupid){ showadroute = true; mmmap.hideoverlay(); // hide roads for(id in roaddata) { roaddata[id].present = false; drawtraffic(id); } //json_request("http://traffic.thai.net/rpc/getadroute.php", "groupid=" + groupid, "adresult", "showadroutechoice();"); json_request("http://main.traffic.thai.net/rpc/getadroute.php", "groupid=" + groupid, "adresult", "showadroutechoice();"); } function clearadroute(){ showadroute = false; mmmap.showoverlay(); for(id in roaddata) { roaddata[id].present = false; drawtraffic(id); } gettraffic(); } function showadroutebtn(){ var ac = document.getElementById("adrouteform").adroutechoice; var sroute = 0; for(var i=0;iลำดับ' +'
    ระยะทาง
    ' +'
    เส้นทาง
    '; resultn = '
    เส้นทางที่ไม่แนะนำ
    ' +'' +''; for(var i=0;i 0) { for(var j=0;j' + '
    ' + adresult[i].parts[j].distance +'
    ' + adresult[i].parts[j].description + ''; } } else { pdetail = ''+adresult[i].description+''; } var tmp = ".
    " + "" ; if (adresult[i].rank > 0) { oc++; resulto += "
    ลำดับ
    ระยะทาง
    ' +'
    เส้นทาง
    " + "
    "+adresult[i].distant+"
    " + "
    " + adresult[i].routename + ((adresult[i].reason != '')?("
    ("+adresult[i].reason+")
    "):'') + "
    " // + "" + "
    "+(oc)+tmp; } else { nc++; resultn += "
    "+(nc)+tmp; } /* result += "
    " + adresult[i].routename + "
    " + "" + "";*/ } } resulto += '

    '; resultn += '
    '; var tmp = ""; if (oc > 0) tmp += resulto; if (nc > 0) tmp += resultn; document.getElementById("adrouteresult").innerHTML = tmp; } } function showadroutepart(partid){ mmmap.showPopUp(adroutepart[partid].latitude, adroutepart[partid].longitude, 'เส้นทาง', adroutepart[partid].description); mmmap.moveTo(adroutepart[partid].latitude, adroutepart[partid].longitude); } // ---- END -- draw traffic function swap_operation_mode(mode){ var tomode = 'edit'; if (mode && mode != '') { if (mode != 'edit') tomode = 'normal'; } else { if (traffic_draw_mode != 'normal') tomode = 'normal'; } if (tomode == traffic_draw_mode) return false; if (tomode == "normal") { traffic_draw_mode = "normal"; str = "edit | view"; midbarcolor = "#F6DDDE"; mmmap.setShowOverLay(overlay_reso_start,overlay_reso_stop,"trafficoverlay"); if (!mmmap.ovl_enable) { mmmap.setAllImagesUsedButNotSetToEmpty(); mmmap.showoverlay(); mmmap.rePaint(); } else { mmmap.refreshoverlay(); } } else { traffic_draw_mode = "edit"; str = "edit | view"; //midbarcolor = "#FFAA00"; midbarcolor = "#FFCD68"; mmmap.setShowOverLay(0,0,"trafficoverlay"); mmmap.hideoverlay(); } document.getElementById("midbar").style.backgroundColor = midbarcolor; document.getElementById("operation_mode_div").innerHTML = str; /* if (gettraffic_timer) { clearTimeout(gettraffic_timer); gettraffic_timer = false; } */ document.getElementById("showtrafficcheckbox").checked = true; var id; for (id in roaddata) { if (roaddata[id]) { roaddata[id].present = false; if (roaddata[id].shape) { mmmap.removeVector(roaddata[id].shape); roaddata[id].shape = false; } } } updatetraffic(); } function officer_trafficstatus_popup(linkid){ window.open('office/updatestatus.php?linkid=' + linkid,"trafficstatus",'status=no,toolbar=no,menubar=no,location=no,resizable=no,width=320,height=220'); } function switchmapmode(){ var r = document.getElementById('showroadcheck'); var e = document.getElementById('showengcheck'); var f = document.getElementById('showtrafficcheckbox'); var c = document.getElementById('showcameracheckbox'); var mode; r.disabled = false; e.disabled = false; mode = (r.checked?'icons':'traffic') + (e.checked?'-en':''); mmmap.setMapMode(mode); mmmap.showCustomDivs(); updateshowtrafficstatus(f.checked); /* if (!c.checked) { // ?!?!?!? } */ mapresize(); } function setTrafficdataMode() { var cb = document.getElementById("trafficdatacheckbox"); //alert(cb.checked); if(cb.checked) { mmmap.setMapMode("trafficdata"); var f = document.getElementById('showtrafficcheckbox'); f.disabled = true; updateshowtrafficstatus(false); } else { switchmapmode(); var f = document.getElementById('showtrafficcheckbox'); f.disabled = false; updateshowtrafficstatus(true); //mmmap.setMapMode(document.getElementById('showroadcheck').checked?'normal':'traffic'); } } function updatestat(){ json_request("http://traffic.thai.net/rpc/getstat.php","","upstatvar","updatestat_callback()"); } function updatestat_callback() { document.getElementById("stat_accident_count").innerHTML = upstatvar.incident_count[2]; document.getElementById("stat_construct_count").innerHTML = upstatvar.incident_count[1]; document.getElementById("stat_badcar_count").innerHTML = upstatvar.incident_count[0]; } // ------------ camera_info = []; camvar = ""; function popupcamera(camid){ var campopup = window.open('http://main.traffic.thai.net/camview.php?camid=' + camid,"cameraview_"+camid,'status=no,toolbar=no,menubar=no,location=no,resizable=yes,width=720,height=640'); } function showcameradetail(id){ speedcolor = (camera_info[id].speed >= 80)?'#009900':((camera_info[id].speed >= 30)?'#999900':'#990000'); datetmp = camera_info[id].lastupdate.split(' ')[0]; var dateno = parseInt(datetmp.substr(8,2)); update = dateno + " " + monthShort[parseInt(datetmp.substr(5,2),10) - 1] + " " + (parseInt(datetmp.substr(0,4),10) + 543)%100; lanes = ''; var unittype = 'กม./ชม.'; if(camera_info[id].location_type=='PK') { unittype = '%'; } for(var i=0;i" + camera_info[id].lanes[i].speed + " "+unittype+"
    "; } detail = "
    ID: " + camera_info[id].camid + "" //+ '
    ข้อมูลเฉลี่ย 1 นาที
    ' +"
    " //+ camera_info[id].lanes[0].idlane+":" + camera_info[id].lanes[0].speed + " กม./ชม.
    " //+ camera_info[id].lanes[1].idlane+":" + camera_info[id].lanes[1].speed + " กม./ชม.
    " + lanes + "" + "วันที่: "+ update +"
    " + "" + "เวลา: "+ camera_info[id].lastupdate.split(' ')[1].substr(0,5) +"" //+ "
    [ดูภาพขยาย]
    "; + "
    " + "
    "; //height='60' mmmap.showPopUp(camera_info[id].latitude, camera_info[id].longitude, camera_info[id].remark , detail); } function drawcamera (){ //alert('drawcamera'); var c = camvar.length; var newcam = []; for(var i=0;i"; newcam[id].divid = mmmap.drawCustomDivLevel(camdiv, newcam[id].latitude,newcam[id].longitude,newcam[id].remark, 3,14); if (typeof(camera_info[id]) != 'undefined') { camera_info[id].deleted = true; } //} else { // newcam[id].divid = camera_info[id].divid; //} } // delete for(var i=0;i