var http=getHTTPObject();function getOfficeList(cityId){var url='getOfficeList.do?cityId='+cityId;http.open("GET",url,false);http.send(null);var officeList=document.getElementById("officeId");select_innerHTML(officeList,http.responseText);initializeMapForCity();setDestinationDetails();}
function select_innerHTML(objeto,innerHTML){objeto.innerHTML=""
var selTemp=document.createElement("micoxselect")
var opt;selTemp.id="micoxselect1"
document.body.appendChild(selTemp)
selTemp=document.getElementById("micoxselect1")
selTemp.style.display="none"
if(innerHTML.indexOf("<option")<0){innerHTML="<option>"+innerHTML+"</option>"}
innerHTML=innerHTML.replace(/<option/g,"<span").replace(/<\/option/g,"</span")
selTemp.innerHTML=innerHTML
for(var i=0;i<selTemp.childNodes.length;i++){var spantemp=selTemp.childNodes[i];if(spantemp.tagName){opt=document.createElement("OPTION")
if(document.all){objeto.add(opt)}else{objeto.appendChild(opt)}
for(var j=0;j<spantemp.attributes.length;j++){var attrName=spantemp.attributes[j].nodeName;var attrVal=spantemp.attributes[j].nodeValue;if(attrVal){try{opt.setAttribute(attrName,attrVal);opt.setAttributeNode(spantemp.attributes[j].cloneNode(true));}catch(e){}}}
if(spantemp.style){for(var y in spantemp.style){try{opt.style[y]=spantemp.style[y];}catch(e){}}}
opt.value=spantemp.getAttribute("value")
opt.text=spantemp.innerHTML
opt.selected=spantemp.getAttribute('selected');opt.className=spantemp.className;}}
document.body.removeChild(selTemp)
selTemp=null}
function getOfficeCoordinates(officeId){var url='getOfficeCoordinates.do?officeId='+officeId;http.open("GET",url,false);http.send(null);handleOfficeCoordinatesResponse();}
function handleOfficeCoordinatesResponse(){var response=http.responseText;var firstSeparator=response.indexOf(",");var secondSeparator=response.indexOf(",",firstSeparator+1);var lat=response.substring(0,firstSeparator);var lng=response.substring(firstSeparator+1,secondSeparator);var name=response.substring(secondSeparator+1,response.length);map.setCenter(new GLatLng(lat,lng));var tempMarker=new GMarker(new GLatLng(lat,lng),{draggable:false,icon:toIcon});tempMarker.value="toLocation";infoWindowHtml=name+" is the office you work out of. If not,select a different location from the drop down above.";map.addOverlay(tempMarker);tempMarker.bindInfoWindow(infoWindowHtml);document.getElementById(tempMarker.value).value=lat+","+lng+","+cityId+","+name;var locationId=document.getElementById("toLocationId");locationId.innerHTML=name;map.openInfoWindowHtml(map.getCenter(),name+" is the office you work out of. Now please identify your home location by clicking on the map.");}
function getHTTPObject(){var xmlhttp;if(window.XMLHttpRequest){xmlhttp=new XMLHttpRequest();}else if(window.ActiveXObject){xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");}
return xmlhttp;}
