var bLoggedIn=0;var ie=document.all;var ns6=document.getElementById&& !document.all;var varDvrChild=null;var varVhiChild=null;var GPSForm=null;var actGrpObj=null;var actGrpObj1=null;var dropmenuobj=null;var whichFocus=null;function OnPageClick(iPageNo){document.Fleetform.PageNo.value=iPageNo;document.Fleetform.submit();};function OnFocus(obj){whichFocus=obj;};function OnUserFocus(obj){whichFocus=obj;};function OnPassFocus(obj){whichFocus=obj;};function OnProfileFocus(obj){whichFocus=obj;};function alertkey(e){if(!e){if(window.event){e=window.event;}else{return;}}if(e.keyCode==27){if(ActMap!=null){ActMap.style.display="none";}if(map!=null){delete map;map=null;}hideled();return false;}if(event.keyCode==13){if(whichFocus!=null){if(whichFocus.name=="Profile"){document.Fleetform.Username.focus();document.Fleetform.Username.select();return false;}if(whichFocus.name=="Username"){document.Fleetform.Password.focus();document.Fleetform.Password.select();return false;}if(whichFocus.name=="Password"){return true;}}}if(e.keyCode==131111){if(whichFocus!=null){}}};function TL(){if(bLoggedIn){bLoggedIn=false;document.Fleetform.Username.value="";document.Fleetform.Password.value="";}document.Fleetform.ActionTaken.value="Login";document.Fleetform.submit();};function OnMenuPM(str){document.Fleetform.ActionTaken.value="Me_ControlPanel";document.Fleetform.ControlPanel.value=str;document.Fleetform.submit();};function OnMenu(action){if(bLoggedIn!=1){alert("You have not logged in");return;}if(action=="Me_CreateTrip"){if(document.Fleetform.m_RegNo!=null){document.Fleetform.m_RegNo.value="";document.Fleetform.TripID.value="";}}document.Fleetform.ActionTaken.value=action;document.Fleetform.submit();};function OnMenuX(action){alert("Yet to release");};function Logout(){if(bLoggedIn){bLoggedIn=false;document.Fleetform.Username.value="";document.Fleetform.Password.value="";document.Fleetform.ActionTaken.value="";document.Fleetform.ControlPanel.value="";}delete_cookie("user");document.Fleetform.submit();};function delete_cookie(cookie_name){var cookie_date=new Date();cookie_date.setTime(cookie_date.getTime()-1);document.cookie=cookie_name+="=; expires="+cookie_date.toGMTString();};function OnLoad1(){FillAdd();};function OnLocation(i,lat,lng){var point=new GLatLng(lat/600000,lng/600000);geocoder.getLocations(point,function(response){if(!response||response.Status.code!=200){document.getElementById("Loc_"+i).innerHTML="Unknown";}else{place=response.Placemark[0];document.getElementById("Loc_"+i).innerHTML=place.address;}});};function FillAdd(){var i=0;while(1){if(document.getElementById("Loc_"+i)){OnLocation(i,document.getElementById("Lat_"+i).value,document.getElementById("Lng_"+i).value);}else{break;}i++;}};function ClkClient(id){hidetip(this);var bOpenNew=false;if(varDvrChild==null){bOpenNew=true;}else{if(varDvrChild.closed){bOpenNew=true;}else{document.Clientform.Profile.value=document.Fleetform.Profile.value;document.Clientform.Username.value=document.Fleetform.Username.value;document.Clientform.id_dvr.value=id;document.Clientform.submit();varDvrChild.focus();}}if(bOpenNew){document.Clientform.Profile.value=document.Fleetform.Profile.value;document.Clientform.Username.value=document.Fleetform.Username.value;document.Clientform.id_dvr.value=id;varDvrChild=window.open('','ClientformView','resizable=no,left=50,top=100,screenX=0,screenY=100,scrollbars=yes,height=375,width=800');var a=window.setTimeout("document.Clientform.submit();",1000);}};function ClkGlb(){var bOpenNew=false;if(GPSForm==null){bOpenNew=true;}else{if(GPSForm.closed){bOpenNew=true;}else{GPSForm.focus();}}if(bOpenNew){document.GPSForm.Profile.value=document.Fleetform.Profile.value;document.GPSForm.Username.value=document.Fleetform.Username.value;document.GPSForm.Password.value=document.Fleetform.Password.value;document.GPSForm.ActionTaken.value="Login";GPSForm=window.open('','GPSFormView');var a=window.setTimeout("document.GPSForm.submit();",1000);}};function ClkGlbPt(unitid){var bOpenNew=false;if(GPSForm==null){bOpenNew=true;}else{if(GPSForm.closed){bOpenNew=true;}else{GPSForm.ParentRequest(unitid);GPSForm.focus();}}if(bOpenNew){document.GPSForm.Profile.value=document.Fleetform.Profile.value;document.GPSForm.Username.value=document.Fleetform.Username.value;document.GPSForm.Password.value=document.Fleetform.Password.value;document.GPSForm.ActionTaken.value="Login";document.GPSForm.QryData.value=unitid+"^";document.GPSForm.UnitFoc.value=unitid;GPSForm=window.open('','GPSFormView');var a=window.setTimeout("document.GPSForm.submit();",1000);}};function GetPureRegNo(reg){var iLen=reg.length;var newStr="";var iMode=4;reg=reg.toLowerCase();for(i=0;i<iLen;i++){if((reg.charAt(i)>='0')&&(reg.charAt(i)<='9')){if((iMode!=0)&&(i!=0))newStr+=' ';newStr+=reg.charAt(i);iMode=0;}if((reg.charAt(i)>='a')&&(reg.charAt(i)<='z')){if((iMode!=1)&&(i!=0))newStr+=' ';newStr+=reg.charAt(i);iMode=1;}}newStr=newStr.toUpperCase();return newStr;};function UpdatePrField(TblName,sFldName){var val;val=document.getElementById(sFldName).value;if(sFldName=="m_RegNo"){val=GetPureRegNo(document.getElementById(sFldName).value);document.getElementById(sFldName).value=val;}qstr="";qstr=qstr+'Profile='+document.getElementById("Profile").value;qstr=qstr+'&FieldName='+sFldName;qstr=qstr+'&FieldValue='+escape(val);qstr=qstr+'&TblName='+TblName;qstr=qstr+'&m_id='+document.getElementById("id_dvr").value;qstr=qstr+'&LastReqAction=update';xmlhttpPost("../inc/update.asp",qstr,"ActBox",sFldName)};function OnValueChange(tbl,obj,sSec,sField){whichFocus=obj;if(sSec!="1"){alert("Sorry. You have no permission to do this");return;}document.getElementById("Sv_"+sField).innerHTML="<img src='../Images/SaveIcon.gif' width='16' height='16' onClick='UpdatePrField(\""+tbl+"\",\""+sField+"\");'>";document.getElementById("Sv_"+sField).style.visibility='visible';};function xmlhttpPost(strURL,sFrmData,sTarget,sTargetImg){var xmlHttpReq=false;var self=this;document.getElementById(sTarget).innerHTML="<p><br><br><br>Please wait...<br><br><br></p>";if(window.XMLHttpRequest){self.xmlHttpReq=new XMLHttpRequest();}else if(window.ActiveXObject){self.xmlHttpReq=new ActiveXObject("Microsoft.XMLHTTP");}self.xmlHttpReq.open('POST',strURL,true);self.xmlHttpReq.setRequestHeader('Content-Type','application/x-www-form-urlencoded');self.xmlHttpReq.onreadystatechange=function(){if(self.xmlHttpReq.readyState==4){document.getElementById(sTarget).innerHTML=self.xmlHttpReq.responseText;if(self.xmlHttpReq.responseText.indexOf("Done")>0){document.getElementById("Sv_"+sTargetImg).style.visibility='hidden';}else{}}};self.xmlHttpReq.send(sFrmData);};function onkey(tbl,e){if(!e){if(window.event){e=window.event;}else{return;}}if(e.keyCode==27){blur();window.parent.document.focus();}if(e.keyCode==13){if(whichFocus!=null){UpdatePrField(tbl,whichFocus.name);return false;}}};function OnSelVehiX(obj,name,unitid){actGrpObj.value=name;hideled();};function hideled(){if((dropmenuobj!=null)&&(dropmenuobj!='undefined')){dropmenuobj.style.visibility="hidden"}};function OnClickSave(unitid){fldval=GetPureRegNo(document.getElementById('RegNo_'+unitid).value);document.getElementById('RegNo_'+unitid).value=fldval;qstr="";qstr=qstr+'FieldName=m_RegNo';qstr=qstr+'&FieldValue='+escape(fldval);qstr=qstr+'&TblName=tbl_profile_device';qstr=qstr+'&UnitID='+unitid;qstr=qstr+'&LastReqAction=SaveDevice';xmlhttpPost("inc/update.asp",qstr,"ActBox");OnClickEdit('black',true,unitid);};function ClkVehicle(regno){hidetip(this);var bOpenNew=false;if(varDvrChild==null){bOpenNew=true;}else{if(varDvrChild.closed){bOpenNew=true;}else{document.Vehicleform.Profile.value=document.Fleetform.Profile.value;document.Vehicleform.Username.value=document.Fleetform.Username.value;document.Vehicleform.regno.value=regno;document.Vehicleform.submit();varDvrChild.focus();}}if(bOpenNew){document.Vehicleform.Profile.value=document.Fleetform.Profile.value;document.Vehicleform.Username.value=document.Fleetform.Username.value;document.Vehicleform.regno.value=regno;varDvrChild=window.open('','VehicleformView','resizable=no,left=50,top=100,screenX=0,screenY=100,scrollbars=yes,height=375,width=800');var a=window.setTimeout("document.Vehicleform.submit();",1000);}};function ClkDvr(id){hidetip(this);var bOpenNew=false;if(varDvrChild==null){bOpenNew=true;}else{if(varDvrChild.closed){bOpenNew=true;}else{document.Driverform.Profile.value=document.Fleetform.Profile.value;document.Driverform.Username.value=document.Fleetform.Username.value;document.Driverform.id_dvr.value=id;document.Driverform.submit();varDvrChild.focus();}}if(bOpenNew){document.Driverform.Profile.value=document.Fleetform.Profile.value;document.Driverform.Username.value=document.Fleetform.Username.value;document.Driverform.id_dvr.value=id;varDvrChild=window.open('','DriverformView','resizable=no,left=50,top=100,screenX=0,screenY=100,scrollbars=yes,height=500,width=800');var a=window.setTimeout("document.Driverform.submit();",1000);}};function OnClickHistory(sUnitID){var bOpenNew=false;if(SIMchildHistory==null){bOpenNew=true;}else{if(SIMchildHistory.closed){bOpenNew=true;}else{SIMchildList.focus();}}if(bOpenNew){document.UnitHistoryForm.Profile.value=document.Fleetform.Profile.value;document.UnitHistoryForm.Username.value=document.Fleetform.Username.value;document.UnitHistoryForm.Password.value=document.Fleetform.Password.value;document.UnitHistoryForm.UnitID.value=sUnitID;SIMchildHistory=window.open('','MyUnitWinHistory','resizable=yes,left=0,top=100,screenX=0,screenY=100,scrollbars=yes,height=400,width=800');var a=window.setTimeout("document.UnitHistoryForm.submit();",1000);}};function OnClickEdit(col,edit,unitID){var sTemp;document.Fleetform.UnitIDEntered.value=unitID;document.getElementById("RegNo_"+unitID).readOnly=edit;document.getElementById("RegNo_"+unitID).style.color=col;};function OnValueChangeX(obj,sSec,unitid){whichFocus=obj;if(sSec!="1"){alert("Sorry. You have no permission to do this");return;}document.getElementById("Sv_"+unitid).innerHTML="<img src='Images/SaveIcon.gif' width='16' height='16' onClick='UpdateDvField(\""+unitid+"\");'>";document.getElementById("Sv_"+unitid).style.visibility='visible';};function UpdateDvField(unitid){var xmlHttpReq=false;var self=this;qstr="";qstr=qstr+'Profile='+document.getElementById("Profile").value;qstr=qstr+'&FieldName=m_RegNo';qstr=qstr+'&FieldValue='+escape(document.getElementById("Reg_"+unitid).value);qstr=qstr+'&unitid='+escape(unitid);qstr=qstr+'&LastReqAction=updateDivMgr';document.getElementById("DvMgr").innerHTML="<p><br><br><br>Please wait...<br><br><br></p>";if(window.XMLHttpRequest){self.xmlHttpReq=new XMLHttpRequest();}else if(window.ActiveXObject){self.xmlHttpReq=new ActiveXObject("Microsoft.XMLHTTP");}self.xmlHttpReq.open('POST',"inc/update.asp",true);self.xmlHttpReq.setRequestHeader('Content-Type','application/x-www-form-urlencoded');self.xmlHttpReq.onreadystatechange=function(){if(self.xmlHttpReq.readyState==4){document.getElementById("DvMgr").innerHTML=self.xmlHttpReq.responseText;document.getElementById("Sv_"+unitid).style.visibility='hidden';if(self.xmlHttpReq.responseText.indexOf("Done")== -1){}}else{}};self.xmlHttpReq.send(qstr);};function ClkX(unitid){OnValueChangeX("",'1',unitid);document.getElementById("Reg_"+unitid).value="";}