com.qualcomm.Page.locations={insertViewAll:function(){var D=$("map");var C=D.map.data.structure.officeCount;var E=$("view-all-button");var A=$("countries-dropdown");var B=new Element("a",{href:"#"}).update("View All "+C+" Worldwide Locations");E.insert(B);B.observe("click",function(){$("map").map.goTo("all");A.selectedIndex=0;$("offices-dropdown").selectedIndex=0;$("offices-dropdown").disable()})},init:function(){new com.qualcomm.locations.Data("/worldwide/media/map_locations.xml",{onSuccess:function(A){var B=new com.qualcomm.locations.Map("map",A,{onUpdate:function(C){com.qualcomm.locations.insertSelectedOffices(C);var D=new com.qualcomm.Sifr.replacement("current-office")}});B.goTo("all");com.qualcomm.locations.insertOfficesDropdown("United States");com.qualcomm.locations.insertCountriesDropdown();com.qualcomm.Page.locations.insertViewAll()}})}};Util.runAfterEvent("init-screen-finished",com.qualcomm.Page.locations.init);com.qualcomm.locations={fmtOffice:function(B){var C=new Element("div",{"class":"office"});var A=new Element("div",{"class":"address"});if(B.headquarters){A.insert(new Element("h4").update("HEADQUARTERS"))}A.insert(new Element("h4").update(B.city));A.insert(new Element("h1").update("Bldg. "+B.building));B.addresses.last().addressLines.each(function(D){A.insert(new Element("div",{"class":"address-line"}).update(D))});if(B.location.country.name=="United States"){A.insert(new Element("span",{"class":"city"}).update(B.city));A.insert(", ");A.insert(new Element("span",{"class":"state"}).update(B.state));A.insert(" ");A.insert(new Element("span",{"class":"zip"}).update(B.zip))}A.insert({bottom:new Element("div",{"class":"country"}).update(B.location.country.name.toUpperCase())});C.insert({bottom:A});if(B.phone){C.insert({bottom:new Element("div",{"class":"phone"}).update("P: "+B.phone)})}if(B.fax){C.insert({bottom:new Element("div",{"class":"fax"}).update("F: "+B.fax)})}return C},insertOfficesDropdown:function(C,E){var D=$("map");var A=$("map-controls");var B=new Element("select",{name:"offices",id:"offices-dropdown"});B.update(new Element("option",{value:""}).update("- Select an office -"));D.map.data.structure.countries.each(function(F){if(C==F.name){F.locations.each(function(G){var H=new Element("optgroup",{label:G.name});G.offices.each(function(J){var I=new Element("option",{value:J.building}).update("Bldg. "+J.building+" - "+J.addresses.last().addressLines.first());if(E!=undefined&&E==J.name){I.writeAttribute("selected","selected")}H.insert(I)});B.insert(H)});B.observe("change",function(){if($F("offices-dropdown")&&$F("offices-dropdown")!=""){$("map").map.goTo(this.value)}})}});if(!$("offices-dropdown")){A.insert(B)}else{$("offices-dropdown").replace(B)}},insertCountriesDropdown:function(D){var E=$("map");var C=$("map-controls");var A=new Element("select",{name:"countries",id:"countries-dropdown"});A.update(new Element("option",{value:""}).update("- Select a Country -"));var B=E.map.data.structure.countries.each(function(G){var F=new Element("option",{value:G.name}).update(G.name);if(D!=undefined&&D==G.name){F.writeAttribute("selected","selected")}A.insert({bottom:F})});A.observe("change",function(){if($F("countries-dropdown")&&$F("countries-dropdown")!=""){com.qualcomm.locations.insertOfficesDropdown($F("countries-dropdown"))}else{$("offices-dropdown").disable()}});$("offices-dropdown").insert({before:A});if(D==undefined){$("offices-dropdown").disable()}},insertSelectedOffices:function(A){var B=new Element("div",{id:"current-office"});if(A.at=="all"){B.insert({top:com.qualcomm.locations.fmtOffice(A.data.structure.headquarters)})}else{B.insert({top:com.qualcomm.locations.fmtOffice(A.currentOffices.first())})}if(!$("current-office")){A.element.insert({before:B})}else{$("current-office").replace(B)}}};com.qualcomm.locations.Data=Class.create({initialize:function(B,A){this.url=B;this.structure={};this.options={onSuccess:function(){}};Object.extend(this.options,A||{});this._load()},findOffice:function(A){var B;this.structure.countries.each(function(C){C.locations.each(function(D){D.offices.each(function(E){if(E.building==A){B=E}})})});return B},_load:function(){new Ajax.Request(this.url,{method:"get",onSuccess:function(A){this._parse(A);this.options.onSuccess(this)}.bind(this)})},_parse:function(C){var B={};var A;if(Prototype.Browser.IE){A=$A(C.responseXML.childNodes[1].getElementsByTagName("country"))}else{A=$A(C.responseXML.getElementsByTagName("country"))}B.officeCount=0;B.countries=new Array();A.each(function(E){B.countries.push({name:E.getElementsByTagName("name")[0].firstChild.nodeValue});var D=$A(E.getElementsByTagName("location"));B.countries.last().locations=new Array();D.each(function(F){B.countries.last().locations.push({country:B.countries.last(),name:F.getElementsByTagName("name")[0].firstChild.nodeValue});var G=$A(F.getElementsByTagName("office"));B.countries.last().locations.last().offices=new Array();G.each(function(N){var K=N.getElementsByTagName("fax")[0];var O=N.getElementsByTagName("phone")[0];var H=N.getElementsByTagName("longitude")[0];var P=N.getElementsByTagName("latitude")[0];var J=N.getElementsByTagName("zip")[0];var M=N.getElementsByTagName("city")[0];var I=N.getElementsByTagName("state")[0];B.countries.last().locations.last().offices.push({headquarters:N.getElementsByTagName("headquarters")[0].firstChild.nodeValue=="true"?true:false,location:B.countries.last().locations.last(),building:N.getElementsByTagName("building")[0].firstChild.nodeValue,phone:O.firstChild?O.firstChild.nodeValue:null,fax:K.firstChild?K.firstChild.nodeValue:null,city:M.firstChild?M.firstChild.nodeValue:null,state:I.firstChild?I.firstChild.nodeValue:null,zip:J.firstChild?J.firstChild.nodeValue:null,latitude:P.firstChild?P.firstChild.nodeValue:null,longitude:H.firstChild?H.firstChild.nodeValue:null,approximate:N.getElementsByTagName("approximate")[0].firstChild.nodeValue=="true"?true:false,country:B.countries.last().name});var L=$A(N.getElementsByTagName("address"));B.countries.last().locations.last().offices.last().addresses=new Array();L.each(function(Q){B.countries.last().locations.last().offices.last().addresses.push({addressLines:$A(Q.getElementsByTagName("line")).collect(function(R){return R.firstChild.nodeValue})});B.officeCount++;if(B.countries.last().locations.last().offices.last().headquarters){B.headquarters=B.countries.last().locations.last().offices.last()}})})});B.countries.last().locations=B.countries.last().locations.sortBy(function(F){return F.id})});B.countries=B.countries.sortBy(function(D){return D.name});this.structure=B}});com.qualcomm.locations.Map=Class.create({initialize:function(B,C,A){this.element=$(B);this.data=C;this.options={onUpdate:function(){}};Object.extend(this.options,A||{});this.element.map=this;this._load()},_load:function(){if(GBrowserIsCompatible()){this.google={};this.google.map=new GMap2(document.getElementById(this.element.id));this.google.smallMapControl=new GSmallMapControl();this.google.mapTypeControl=new GMapTypeControl();this.google.map.addControl(this.google.smallMapControl);this.google.map.addControl(this.google.mapTypeControl)}else{if(this.element){this.element.update('Sorry, the Google Maps API is not compatible with this browser. <a href="/about/locations_noflash.html">Click here</a> to view a complete list of worldwide office locations.')}else{alert('Sorry, the Google Maps API is not compatible with this browser. Click the link below the "Office Location Finder" to view a complete list of worldwide office locations.')}}},goTo:function(A){var B;this.at=A;if(A=="headquarters"){B=new Array(this.data.structure.headquarters)}else{if(A=="all"){B=this.data.structure.countries.inject(new Array(),function(C,D){D.locations.each(function(E){E.offices.each(function(F){C.push(F)})});return C})}else{if(Object.isString(A)){B=new Array(this.data.findOffice(A))}}}this._update(B)},_update:function(A){this.currentOffices=A;A.each(function(C){C.point=new GLatLng(C.latitude,C.longitude)});this.google.map.clearOverlays();this.markers=A.inject(new Array(),function(E,D,C){if(!D.headquarters){E.push(this.createMarker(D,C));this.google.map.addOverlay(E.last())}else{this.headquarters=D}return E}.bind(this));this.google.map.addOverlay(this.createCustomMarker(this.headquarters,this.markers.length+1));if(A.length>1){var B=A.find(function(C){return C.headquarters==true});this.google.map.setCenter(B.point,1)}else{if(A.any(function(C){return C.approximate==true})){this.google.map.removeControl(this.google.smallMapControl);this.google.map.removeControl(this.google.mapTypeControl);this.google.map.setCenter(A.first().point,7)}else{this.google.map.addControl(this.google.smallMapControl);this.google.map.addControl(this.google.mapTypeControl);this.google.map.setCenter(A.first().point,13)}}this.options.onUpdate(this)},createMarker:function(C,D){var A=new GMarker(C.point,{zIndex:D});var B='<div class="infowindow"><h3>';B+="</h3>";B+="<h3>"+C.city+"</h3>";B+='<div class="address"><strong>Bldg. '+C.building+"</strong>";B+="<br />"+C.addresses.last().addressLines.join("<br />");if(C.location.country.id=="US"){B+="<br />"+C.city+", "+C.state+" "+C.zip}B+="<br />"+C.country.toUpperCase();B+="</div>";B+=C.phone?"P: "+C.phone:"";B+=C.fax?"<br />F: "+C.fax:"";B+="</div>";GEvent.addListener(A,"click",function(){A.openInfoWindowHtml(B)});return A},createCustomMarker:function(C,F){var D=$$(".gmnoprint");var E=new GIcon(G_DEFAULT_ICON);E.iconSize=new GSize(27,50);E.iconAnchor=new GPoint(13,50);E.image="http://www.qualcomm.com/common/images/headquarters-pin.gif";markerOptions={icon:E,zIndex:F};var A=new GMarker(C.point,markerOptions);var B='<div class="infowindow"><h3>';B+="</h3>";B+='<div class="headquarters-marker">HEADQUARTERS';B+="<br />"+C.city;B+="</div>";B+='<div class="address"><strong>Bldg. '+C.building+"</strong>";B+="<br />"+C.addresses.last().addressLines.join("<br />");B+="<br />"+C.city+", "+C.state+" "+C.zip;B+="<br />"+C.country.toUpperCase();B+="</div>";B+=C.phone?"P: "+C.phone:"";B+=C.fax?"<br />F: "+C.fax:"";B+="</div>";GEvent.addListener(A,"click",function(){A.openInfoWindowHtml(B)});return A}});