function Utility(){}
Utility.prototype.INLINE="inline";Utility.prototype.BLOCK="block";Utility.prototype.NONE="none";Utility.prototype.isValidObject=function(obj){if(null!==obj&&""!==obj&&typeof obj!='undefined'){return true;}
return false;};Utility.prototype.assert=function(test,msg){if(!test){throw(msg);}};Utility.prototype.printException=function(e){alert("An exception occurred in the script. Error: "+e.message);};Utility.prototype.getDOMElementByID=function(id){var element=document.getElementById(id);Utility.prototype.assert(Utility.prototype.isValidObject(element),"getDocumentElementByID() no "+id);return element;};Utility.prototype.showDOMElement=function(id,display){Utility.prototype.assert((Utility.prototype.INLINE==display||Utility.prototype.BLOCK==display),"showDOMElement() bad display input: "+display);var element=Utility.prototype.getDOMElementByID(id);if(Utility.prototype.isValidObject(element)){element.style.display=display;}};Utility.prototype.hideDOMElement=function(id){var element=Utility.prototype.getDOMElementByID(id);if(Utility.prototype.isValidObject(element)){element.style.display=Utility.prototype.NONE;}};Utility.prototype.toggleDisplayOfElement=function(id,display){Utility.prototype.assert((Utility.prototype.INLINE==display||Utility.prototype.BLOCK==display),"toggleDisplayOfElement() bad display input: "+display);var element=Utility.prototype.getDOMElementByID(id);if(Utility.prototype.isValidObject(element)){if(Utility.prototype.NONE===element.style.display||""===element.style.display){Utility.prototype.showDOMElement(id,display);}
else{Utility.prototype.hideDOMElement(id);}}};var gUtil=new Utility();function GMapFriendApp(){function loadLibraries(){try{google.load("maps","2");google.load("gdata","1.x");}
catch(e){gUtil.printException(e);alert("Sorry, either Google is currently down or your browser does not support Google's Javascript APIs.");return;}}
loadLibraries();var PAGE_ELEMENTS={controls:{name:"controls",display:Utility.prototype.BLOCK},searchForm:{name:"searchForm",display:Utility.prototype.BLOCK},location:{name:"location",display:Utility.prototype.INLINE},goToLocation:{name:"goToLocation",display:Utility.prototype.INLINE},mapMode:{name:"mapMode",display:Utility.prototype.INLINE},satelliteMode:{name:"satelliteMode",display:Utility.prototype.INLINE},hybridMode:{name:"hybridMode",display:Utility.prototype.INLINE},signIn:{name:"signIn",display:Utility.prototype.INLINE},signOut:{name:"signOut",display:Utility.prototype.INLINE},moreInfo:{name:"moreInfo",display:Utility.prototype.INLINE},sidebar:{name:"sidebar",display:Utility.prototype.BLOCK},showHideContacts:{name:"showHideContacts",display:Utility.prototype.INLINE},contactList:{name:"contactList",display:Utility.prototype.BLOCK},ads:{name:"ads",display:Utility.prototype.BLOCK},map:{name:"map",display:Utility.prototype.BLOCK},moreInfoWindow:{name:"moreInfoWindow",display:Utility.prototype.BLOCK},closeInfoWindow:{name:"closeInfoWindow",display:Utility.prototype.BLOCK},contactEntry:{name:"contactEntry",display:Utility.prototype.BLOCK},contactLink:{name:"contactLink",display:Utility.prototype.INLINE},smallLink:{name:"smallLink",display:Utility.prototype.INLINE},newContactForm:{name:"newContactForm",display:Utility.prototype.BLOCK},newContactField:{name:"newContactField",display:Utility.prototype.BLOCK},newName:{name:"newName",display:Utility.prototype.BLOCK,value:"name"},newEmail:{name:"newEmail",display:Utility.prototype.BLOCK,value:"email"},newPhone:{name:"newPhone",display:Utility.prototype.BLOCK,value:"phone"},newAddress:{name:"newAddress",display:Utility.prototype.BLOCK,value:"address"},editContact:{name:"editContact",display:Utility.prototype.BLOCK},editContactForm:{name:"editContactForm",display:Utility.prototype.BLOCK},editContactID:{name:"editContactID",display:Utility.prototype.NONE},editContactName:{name:"editContactName",display:Utility.prototype.INLINE},editContactEmail:{name:"editContactEmail",display:Utility.prototype.INLINE},editContactPhone:{name:"editContactPhone",display:Utility.prototype.INLINE},editContactAddress:{name:"editContactAddress",display:Utility.prototype.INLINE},cancelContactEdit:{name:"cancelContactEdit",display:Utility.prototype.INLINE},submitContactEdit:{name:"submitContactEdit",display:Utility.prototype.INLINE}};var mapControl=null;var contactService=null;var contacts=[];function contactHTML(contact){var h="";if(""!==contact.getName()){h+=contact.getName()+'<br/>';}
if(""!==contact.getEmailAddress()){h+='<a href="mailto:'+contact.getEmailAddress()+'">'+contact.getEmailAddress()+'</a><br/>';}
if(""!==contact.getPhoneNumber()){h+=contact.getPhoneNumber()+'<br/>';}
var address=contact.getAddress();if(""!==address){h+='<a href="#" onclick="gApp.setMapLocation(\''+address+'\');return false;">'+address+'</a><br/>'+'<a href="#" class="'+PAGE_ELEMENTS.smallLink.name+'" onclick="gApp.setMapLocation(\''+address+'\');return false;">show</a> ';}
var id=contact.getID();h+='<a href="#" class="'+PAGE_ELEMENTS.smallLink.name+'" onclick="gApp.popupEditContact(\''+id+'\');return false;">edit</a> '+'<a href="#" class="'+PAGE_ELEMENTS.smallLink.name+'" onclick="gApp.deleteContact(\''+id+'\');return false;">delete</a>';return h;}
this.createContact=function(){var name=gUtil.getDOMElementByID(PAGE_ELEMENTS.newName.name).value;if(PAGE_ELEMENTS.newName.value==name){name="";}
var email=gUtil.getDOMElementByID(PAGE_ELEMENTS.newEmail.name).value;if(PAGE_ELEMENTS.newEmail.value==email){email="";}
var phone=gUtil.getDOMElementByID(PAGE_ELEMENTS.newPhone.name).value;if(PAGE_ELEMENTS.newPhone.value==phone){phone="";}
var addr=gUtil.getDOMElementByID(PAGE_ELEMENTS.newAddress.name).value;if(PAGE_ELEMENTS.newAddress.value==addr){addr="";}
if(!(""===name&&""===email&&""===phone&&""===addr)){var c=contactService.createEntry(name,email,phone,addr);}};function addContact(newContact){contacts[newContact.getID()]={contact:newContact,mapMarker:null,html:contactHTML(newContact)};if(""!==newContact.getAddress()){mapControl.getLatitudeLongitude(newContact.getAddress(),function(latlng){contacts[newContact.getID()].mapMarker=mapControl.addMapMarker(latlng,newContact.getLabel(),contacts[newContact.getID()].html);});}}
this.addContact=function(newContact){addContact(newContact);};this.deleteContact=function(id){if(confirm("Are you sure you want to delete "+contacts[id].contact.getLabel()+"?")){contacts[id].contact.deleteEntry();contacts[id].contact.cleanUp();if(contacts[id].mapMarker){mapControl.removeMapMarker(contacts[id].mapMarker);}
delete contacts[id];this.refreshContactList();}};this.popupEditContact=function(id){var name=contacts[id].contact.getName();if(""===name){name=PAGE_ELEMENTS.newName.value;}
var email=contacts[id].contact.getEmailAddress();if(""===email){email=PAGE_ELEMENTS.newEmail.value;}
var phone=contacts[id].contact.getPhoneNumber();if(""===phone){phone=PAGE_ELEMENTS.newPhone.value;}
var addr=contacts[id].contact.getAddress();if(""===addr){addr=PAGE_ELEMENTS.newAddress.value;}
gUtil.getDOMElementByID(PAGE_ELEMENTS.editContactID.name).value=id;gUtil.getDOMElementByID(PAGE_ELEMENTS.editContactName.name).value=name;gUtil.getDOMElementByID(PAGE_ELEMENTS.editContactEmail.name).value=email;gUtil.getDOMElementByID(PAGE_ELEMENTS.editContactPhone.name).value=phone;gUtil.getDOMElementByID(PAGE_ELEMENTS.editContactAddress.name).value=addr;gUtil.showDOMElement(PAGE_ELEMENTS.editContact.name,PAGE_ELEMENTS.editContact.display);};this.updateContact=function(){var somethingChanged=false;var id=gUtil.getDOMElementByID(PAGE_ELEMENTS.editContactID.name).value;var name=gUtil.getDOMElementByID(PAGE_ELEMENTS.editContactName.name).value;var email=gUtil.getDOMElementByID(PAGE_ELEMENTS.editContactEmail.name).value;var phone=gUtil.getDOMElementByID(PAGE_ELEMENTS.editContactPhone.name).value;var address=gUtil.getDOMElementByID(PAGE_ELEMENTS.editContactAddress.name).value;gUtil.assert((contacts[id]),"updateContact(): bad id? "+id);if(name!=contacts[id].contact.getName()&&name!=PAGE_ELEMENTS.newName.value){contacts[id].contact.setName(name);somethingChanged=true;}
if(email!=contacts[id].contact.getEmailAddress()&&email!=PAGE_ELEMENTS.newEmail.value){contacts[id].contact.setEmailAddress(email);somethingChanged=true;}
if(phone!=contacts[id].contact.getPhoneNumber()&&phone!=PAGE_ELEMENTS.newPhone.value){contacts[id].contact.setPhoneNumber(phone);somethingChanged=true;}
if(address!=contacts[id].contact.getAddress()&&address!=PAGE_ELEMENTS.newAddress.value){somethingChanged=true;contacts[id].contact.setAddress(address);if(contacts[id].mapMarker){mapControl.removeMapMarker(contacts[id].mapMarker);}
if(""!==address){mapControl.getLatitudeLongitude(address,function(latlng){contacts[id].mapMarker=mapControl.addMapMarker(latlng,contacts[id].contact.getLabel(),contactHTML(contacts[id].contact));});}}
if(somethingChanged){contacts[id].contact.sendUpdate();contacts[id].html=contactHTML(contacts[id].contact);this.refreshContactList();}};this.clearNewContactFields=function(){gUtil.getDOMElementByID(PAGE_ELEMENTS.newName.name).value=PAGE_ELEMENTS.newName.value;gUtil.getDOMElementByID(PAGE_ELEMENTS.newEmail.name).value=PAGE_ELEMENTS.newEmail.value;gUtil.getDOMElementByID(PAGE_ELEMENTS.newPhone.name).value=PAGE_ELEMENTS.newPhone.value;gUtil.getDOMElementByID(PAGE_ELEMENTS.newAddress.name).value=PAGE_ELEMENTS.newAddress.value;};function setMapLocation(location){mapControl.requestSendMapToLocation(location);}
this.setMapLocation=function(location){setMapLocation(location);};function setMapToViewportHeight(){if(gUtil.isValidObject(window.innerHeight)){gUtil.getDOMElementByID(PAGE_ELEMENTS.map.name).style.height=window.innerHeight+"px";}}
function handleButtonClick(e){switch(YAHOO.util.Event.getTarget(e).id){case PAGE_ELEMENTS.cancelContactEdit.name:YAHOO.util.Event.preventDefault(e);gUtil.hideDOMElement(PAGE_ELEMENTS.editContact.name);break;case PAGE_ELEMENTS.newContactForm.name:YAHOO.util.Event.preventDefault(e);gApp.createContact();break;case PAGE_ELEMENTS.submitContactEdit.name:case PAGE_ELEMENTS.editContactForm.name:YAHOO.util.Event.preventDefault(e);gUtil.hideDOMElement(PAGE_ELEMENTS.editContact.name);gApp.updateContact();break;case PAGE_ELEMENTS.moreInfo.name:case PAGE_ELEMENTS.closeInfoWindow.name:gUtil.toggleDisplayOfElement(PAGE_ELEMENTS.moreInfoWindow.name,PAGE_ELEMENTS.moreInfoWindow.display);break;case PAGE_ELEMENTS.signIn.name:contactService.signIn();break;case PAGE_ELEMENTS.signOut.name:signedOut();contactService.signOut();mapControl.removeAllMarkers();break;case PAGE_ELEMENTS.showHideContacts.name:YAHOO.util.Event.preventDefault(e);gUtil.toggleDisplayOfElement(PAGE_ELEMENTS.contactList.name,PAGE_ELEMENTS.contactList.display);break;case PAGE_ELEMENTS.mapMode.name:mapControl.switchToMapMode(G_NORMAL_MAP);toggleMapButtons(YAHOO.util.Event.getTarget(e).id);break;case PAGE_ELEMENTS.satelliteMode.name:mapControl.switchToMapMode(G_SATELLITE_MAP);toggleMapButtons(YAHOO.util.Event.getTarget(e).id);break;case PAGE_ELEMENTS.hybridMode.name:mapControl.switchToMapMode(G_HYBRID_MAP);toggleMapButtons(YAHOO.util.Event.getTarget(e).id);break;case PAGE_ELEMENTS.goToLocation.name:case PAGE_ELEMENTS.searchForm.name:YAHOO.util.Event.preventDefault(e);var locationRequest=gUtil.getDOMElementByID(PAGE_ELEMENTS.location.name).value;if(""!==locationRequest){setMapLocation(locationRequest);}
break;default:break;}}
this.refreshContactList=function(){var contactListHTML='<div class="'+PAGE_ELEMENTS.contactEntry.name+'"> '+'<input class="'+PAGE_ELEMENTS.newContactField.name+'" type="text" id="'+PAGE_ELEMENTS.newName.name+'"/><br/>'+'<input class="'+PAGE_ELEMENTS.newContactField.name+'" type="text" id="'+PAGE_ELEMENTS.newEmail.name+'"/><br/>'+'<input class="'+PAGE_ELEMENTS.newContactField.name+'" type="text" id="'+PAGE_ELEMENTS.newPhone.name+'"/><br/>'+'<input class="'+PAGE_ELEMENTS.newContactField.name+'" type="text" id="'+PAGE_ELEMENTS.newAddress.name+'"/><br/>'+'<a href="#" class="'+PAGE_ELEMENTS.smallLink.name+'" onClick="gApp.createContact();return false;">add</a>   <a href="#" class="'+PAGE_ELEMENTS.smallLink.name+'" onClick="gApp.clearNewContactFields();return false;">clear</a></div>';for(var i in contacts){contactListHTML+='<div class="'+PAGE_ELEMENTS.contactEntry.name+'">'+contacts[i].html+'</div>';}
var element=gUtil.getDOMElementByID(PAGE_ELEMENTS.contactList.name);gUtil.assert(gUtil.isValidObject(element),"refreshContactList() - contact list is bad???");element.innerHTML=contactListHTML;gUtil.showDOMElement(PAGE_ELEMENTS.showHideContacts.name,PAGE_ELEMENTS.showHideContacts.display);gUtil.showDOMElement(PAGE_ELEMENTS.contactList.name,PAGE_ELEMENTS.contactList.display);this.clearNewContactFields();};function appendToContactList(html){var element=gUtil.getDOMElementByID(PAGE_ELEMENTS.contactList.name);gUtil.assert(gUtil.isValidObject(element),"appendToContactList() - contact list is bad???");element.innerHTML+=html;}
function deleteContacts(){deleteContactListHTML();for(var i in contacts){delete contacts[i];}}
function deleteContactListHTML(){gUtil.hideDOMElement(PAGE_ELEMENTS.contactList.name);gUtil.hideDOMElement(PAGE_ELEMENTS.showHideContacts.name);var element=gUtil.getDOMElementByID(PAGE_ELEMENTS.contactList.name);if(gUtil.isValidObject(element)){element.innerHTML="";}
gUtil.hideDOMElement(PAGE_ELEMENTS.showHideContacts.name);}
function showLocationSearch(){gUtil.showDOMElement(PAGE_ELEMENTS.location.name,PAGE_ELEMENTS.location.display);gUtil.showDOMElement(PAGE_ELEMENTS.goToLocation.name,PAGE_ELEMENTS.goToLocation.display);}
function hideLocationSearch(){gUtil.hideDOMElement(PAGE_ELEMENTS.location.name);gUtil.hideDOMElement(PAGE_ELEMENTS.goToLocation.name);}
function toggleMapButtons(currentModeButton){gUtil.assert((PAGE_ELEMENTS.mapMode.name==currentModeButton||PAGE_ELEMENTS.satelliteMode.name==currentModeButton||PAGE_ELEMENTS.hybridMode.name==currentModeButton),"toggleMapButtons() bad map mode "+currentModeButton);showMapButtons();gUtil.hideDOMElement(PAGE_ELEMENTS[currentModeButton].name);}
function showMapButtons(){gUtil.showDOMElement(PAGE_ELEMENTS.mapMode.name,PAGE_ELEMENTS.mapMode.display);gUtil.showDOMElement(PAGE_ELEMENTS.satelliteMode.name,PAGE_ELEMENTS.satelliteMode.display);gUtil.showDOMElement(PAGE_ELEMENTS.hybridMode.name,PAGE_ELEMENTS.hybridMode.display);}
function loadInterface(){try{YAHOO.util.Event.onAvailable(PAGE_ELEMENTS.map.name,setMapToViewportHeight);YAHOO.util.Event.addListener(window,'resize',setMapToViewportHeight);YAHOO.util.Event.addListener(PAGE_ELEMENTS.controls.name,'click',handleButtonClick);YAHOO.util.Event.addListener(PAGE_ELEMENTS.editContact.name,'click',handleButtonClick);YAHOO.util.Event.addListener(PAGE_ELEMENTS.editContactForm.name,'submit',handleButtonClick);YAHOO.util.Event.addListener(PAGE_ELEMENTS.closeInfoWindow.name,'click',handleButtonClick);YAHOO.util.Event.addListener(PAGE_ELEMENTS.searchForm.name,'submit',handleButtonClick);YAHOO.util.Event.addListener(PAGE_ELEMENTS.newContactForm.name,'submit',handleButtonClick);}
catch(e){gUtil.printException(e);}
showLocationSearch();gUtil.showDOMElement(PAGE_ELEMENTS.closeInfoWindow.name,PAGE_ELEMENTS.closeInfoWindow.display);gUtil.hideDOMElement(PAGE_ELEMENTS.moreInfoWindow.name);gUtil.showDOMElement(PAGE_ELEMENTS.moreInfo.name,PAGE_ELEMENTS.moreInfo.display);toggleMapButtons(PAGE_ELEMENTS.mapMode.name);}
function signedIn(){gUtil.showDOMElement(PAGE_ELEMENTS.signOut.name,PAGE_ELEMENTS.signOut.display);gUtil.hideDOMElement(PAGE_ELEMENTS.signIn.name);}
function signedOut(){deleteContacts();gUtil.hideDOMElement(PAGE_ELEMENTS.signOut.name);gUtil.showDOMElement(PAGE_ELEMENTS.signIn.name,PAGE_ELEMENTS.signIn.display);}
function init(){gUtil.assert((!mapControl&&!contactService),"calling init() twice?  members not null...");mapControl=new MapControl(PAGE_ELEMENTS.map.name);contactService=new GoogleContactsControl();if(!GBrowserIsCompatible()){alert("Sorry, either Google is currently down or your browser does not support Google's Javascript APIs. Attempting to continue.");}
mapControl.init();contactService.init();loadInterface();if(contactService.signedIn()){signedIn();contactService.requestContacts(addContact);}
else{signedOut();contactService.signOut();}}
function cleanUp(){mapControl.cleanUp();contactService.cleanUp();mapControl=null;contactService=null;contacts=null;GUnload();}
function listenForPageEvents(){try{YAHOO.util.Event.onDOMReady(init);YAHOO.util.Event.addListener(window,"unload",cleanUp);}
catch(e){gUtil.printException(e);}}
listenForPageEvents();}
var gApp=new GMapFriendApp();function GoogleContactsControl(){function ContactWrapper(googleEntry){gUtil.assert((gUtil.isValidObject(googleEntry)),"Contact(): bad google entry received");var entry=googleEntry;var name="";this.getName=function(){if(""!==name){return name;}
if(entry.getTitle()){name=entry.getTitle().getText();}
return name;};this.setName=function(n){gUtil.assert((name!=n),"setName(): setting name to current value");name=n;var obj=new google.gdata.atom.Text();obj.setText(name);entry.setTitle(obj);};var label="";this.getLabel=function(){if(""!==label){return label;}
if(this.getName()){label=this.getName();}
else{label=this.getEmailAddress();}
return label;};var uniqueID="";this.getID=function(){if(""!==uniqueID){return uniqueID;}
if(entry.getId()){uniqueID=entry.getId().getValue();}
else{uniqueID=this.getLabel();}
return uniqueID;};var email="";this.getEmailAddress=function(){if(""!==email){return email;}
if(entry.getEmailAddresses().length>0){email=entry.getEmailAddresses()[0].getAddress();}
return email;};this.setEmailAddress=function(addr){gUtil.assert((email!=addr),"setEmailAddress(): setting to current value");email=addr;if(""===email){var tempArray=[];var i=1;for(i=1;i<entry.getEmailAddresses().length;i++){tempArray[i-1]=entry.getEmailAddresses()[i];}
entry.setEmailAddresses(tempArray);}
else if(entry.getEmailAddresses().length>0){entry.getEmailAddresses()[0].setValue(email);}
else{var obj=new google.gdata.Email();obj.setAddress(email);obj.setRel(google.gdata.Email.REL_HOME);entry.addEmailAddress(obj);}};var phone="";this.getPhoneNumber=function(){if(""!==phone){return phone;}
if(entry.getPhoneNumbers().length>0){phone=entry.getPhoneNumbers()[0].getValue();}
return phone;};this.setPhoneNumber=function(num){gUtil.assert((phone!=num),"setPhoneNumber(): setting to current value");phone=num;if(""===phone){var tempArray=[];var i=1;for(i=1;i<entry.getPhoneNumbers().length;i++){tempArray[i-1]=entry.getPhoneNumbers()[i];}
entry.setPhoneNumbers(tempArray);}
else if(entry.getPhoneNumbers().length>0){entry.getPhoneNumbers()[0].setValue(phone);}
else{var obj=new google.gdata.PhoneNumber();obj.setValue(phone);obj.setRel(google.gdata.PhoneNumber.REL_HOME);entry.addPhoneNumber(obj);}};var address="";this.getAddress=function(){if(""!==address){return address;}
if(entry.getPostalAddresses().length>0){address=entry.getPostalAddresses()[0].getValue();}
return address;};this.setAddress=function(addr){gUtil.assert((address!=addr),"setAddress(): setting to current value");address=addr;if(""===address){var tempArray=[];var i=1;for(i=1;i<entry.getPostalAddresses().length;i++){tempArray[i-1]=entry.getPostalAddresses()[i];}
entry.setPostalAddresses(tempArray);}
else if(entry.getPostalAddresses().length>0){entry.getPostalAddresses()[0].setValue(address);}
else{var obj=new google.gdata.PostalAddress();obj.setValue(address);obj.setRel(google.gdata.PostalAddress.REL_HOME);entry.addPostalAddress(obj);}};this.deleteEntry=function(){entry.deleteEntry(function(){},gUtil.printException);};this.sendUpdate=function(){entry.updateEntry(function(){},gUtil.printException);};this.cleanUp=function(){entry=null;};}
var contactsService=null;var serviceScope='http://www.google.com/m8/feeds';var contactsFeedUri='http://www.google.com/m8/feeds/contacts/default/full';this.signedIn=function(){var token=google.accounts.user.checkLogin(serviceScope);if(gUtil.isValidObject(token)){return true;}
return false;};this.signIn=function(){var token=google.accounts.user.login(serviceScope);};this.signOut=function(){google.accounts.user.logout();};this.createEntry=function(name,email,phone,address){gUtil.assert(!(!name&&!email&&!phone&&!address),"createEntry() all inputs undefined?");var googleContactEntry=new google.gdata.contacts.ContactEntry();if(name&&""!==name){googleContactEntry.setTitle(google.gdata.Text.create(name));}
if(email&&""!==email){var emailObj=new google.gdata.Email();emailObj.setAddress(email);emailObj.setPrimary(true);emailObj.setRel(google.gdata.Email.REL_HOME);googleContactEntry.setEmailAddresses([emailObj]);}
if(phone&&""!==phone){var phoneObj=new google.gdata.PhoneNumber();phoneObj.setValue(phone);phoneObj.setPrimary(true);phoneObj.setRel(google.gdata.PhoneNumber.REL_HOME);googleContactEntry.setPhoneNumbers([phoneObj]);}
if(address&&""!==address){var addrObj=new google.gdata.PostalAddress();addrObj.setValue(address);addrObj.setPrimary(true);addrObj.setRel(google.gdata.PostalAddress.REL_HOME);googleContactEntry.setPostalAddresses([addrObj]);}
var contactWrapperMethod=ContactWrapper;contactsService.insertEntry(contactsFeedUri,googleContactEntry,function(){var c=new contactWrapperMethod(googleContactEntry);gApp.addContact(c);gApp.refreshContactList();},gUtil.printException,google.gdata.contacts.ContactEntry);};this.requestContacts=function(newContactCallback){try{var query=new google.gdata.contacts.ContactQuery(contactsFeedUri);query.setMaxResults(1000);contactsService.getContactFeed(query,function(results){var entries=results.feed.entry;for(var i=0;i<entries.length;i++){newContactCallback(new ContactWrapper(entries[i]));}
gApp.refreshContactList();},gUtil.printException);}
catch(e){gUtil.printException(e);}};this.init=function(){contactsService=new google.gdata.contacts.ContactsService('gmap-friends-1.0');};this.cleanUp=function(){contactsService=null;serviceScope=null;};}
function MapControl(id){var mapID=id;var map=null;var mapControl=null;var mapOverviewControl=null;var localClientGeocoder=null;var mapMarkerManager=null;this.getLatitudeLongitude=function(request,callback){var isSendMapToLocation=(callback==this.sendMapToLocation);localClientGeocoder.getLocations(request,function(responseFromGoogle){if(!responseFromGoogle||responseFromGoogle.Status.code!=200){if(isSendMapToLocation){alert("Sorry, "+request+" not found.");}}
else{var place=responseFromGoogle.Placemark[0];callback(new GLatLng(place.Point.coordinates[1],place.Point.coordinates[0]));}});};this.requestSendMapToLocation=function(request){this.getLatitudeLongitude(request,this.sendMapToLocation);};this.sendMapToLocation=function(latLong){map.setCenter(latLong,13);};this.switchToMapMode=function(mode){gUtil.assert((mode==G_NORMAL_MAP||mode==G_SATELLITE_MAP||mode==G_HYBRID_MAP),"switchToMapMode() bad input: "+mode);map.setMapType(mode);};this.addMapMarker=function(latLong,markerTitle,html){var marker=new GMarker(latLong,{title:markerTitle,draggable:true});mapMarkerManager.addMarker(marker,0);marker.bindInfoWindowHtml(html);return marker;};this.removeMapMarker=function(marker){mapMarkerManager.removeMarker(marker);};this.removeAllMarkers=function(){mapMarkerManager.clearMarkers();};this.init=function(){map=new GMap2(gUtil.getDOMElementByID(mapID));map.setCenter(new GLatLng(0,0),2);localClientGeocoder=new GClientGeocoder();mapMarkerManager=new MarkerManager(map);mapControl=new GLargeMapControl();map.addControl(mapControl);};this.cleanUp=function(){this.removeAllMarkers();mapID=null;map=null;mapControl=null;localClientGeocoder=null;mapMarkerManager=null;};}