SunGard.Listings=Class.create({_modalCache:{},initialize:function(){this.nav=$("nav-listings");this.attachEvents();},attachEvents:function(){this.container.observe("click",this.onClick.bindAsEventListener(this));this.nav.select("li.disabled a").invoke("observe","click",this.onDisabledNavClick.bindAsEventListener(this));},onDisabledNavClick:function(A){Event.stop(A);},onClick:function(B){Event.stop(B);var A=Event.element(B);if(A.tagName!="A"){return ;}$(A).blur();this.ID=A.hash.substr(1);this[(this._modalCache[this.ID])?"showModal":"callWebService"]();},callWebService:function(){new Ajax.Request(this._webServicePath,{postBody:"{ID:'"+this.ID+"'}",contentType:"application/json; charset=utf-8",onSuccess:this.createModal.bind(this),onFailure:this.error.bind(this)});},createModal:function(A){this._modalCache[this.ID]=this.getTemplateType(this.ID,A.responseJSON.d.evalJSON());this.showModal();},showModal:function(){document.fire("modal:open",{id:this.ID});},error:function(A){alert("This listing is currently unavailable.");}});SunGard.Listings.Product=Class.create(SunGard.Listings,{_webServicePath:"/webservices/BrandProductsService.asmx/GetProductsForBrand",initialize:function($super,A){this.container=A;$super();},getTemplateType:function(B,A){A.id=B;return new SunGard.Listings.Product.Template(A);}});SunGard.Listings.Product.Template=Class.create(SunGard.ModalTemplate,{initialize:function($super,D){this.type="listings-product";this.canPrint=true;var B=new Element("a",{href:D.BrandUrl}).update(D.BrandTitle);var F=new Element("h1").insert(B);var A=(D.BrandSummary=="")?"":new Element("p").update(D.BrandSummary);var C=(D.RegionNames=="")?"":new Element("p").update("<strong>Where Available:</strong> "+D.RegionNames);var E=$A(D.AssociatedProducts);if(E.length>0){if(E.length==1&&D.BrandTitle==E[0].Title){B.href=E[0].FriendlyUrl;A=new Element("p").update(E[0].Summary);}else{var G=new Element("h2").update("What We Offer");var H=new Element("dl");E.each(function(I){var K=new Element("dt").insert(new Element("a",{href:I.FriendlyUrl}).update(I.Title));var J=new Element("dd").update(I.Summary);H.insert(K).insert(J);});}}this.copy=new Element("div",{id:"copy"}).insert(F).insert(A).insert(C).insert(G).insert(H);$super(D);}});SunGard.Listings.ContactInfo=Class.create(SunGard.Listings,{_webServicePath:"/webservices/BrandProductsService.asmx/GetContactInfoForBrand",initialize:function($super,A){this.container=A;$super();},getTemplateType:function(B,A){A.id=B;return new SunGard.Listings.ContactInfo.Template(A);}});SunGard.Listings.ContactInfo.Template=Class.create(SunGard.ModalTemplate,{initialize:function($super,D){this.type="listings-contact-info";this.canPrint=true;var E="<h1>"+D.BrandTitle+"</h1>";var B=(D.PDFFileLink==""||D.PDFFileLink==null)?"":'<p id="pdf"><a href="'+D.PDFFileLink+' ">All '+D.BrandTitle+" Contacts and Locations</a>"+SunGard.MediaTypeIcons.pdf+" [PDF, "+D.PDFFileSize+" KB]</p>";var C="";var A=$A(D.RegionalContactInfo);A.each(function(F,G){var K="<h2>"+F.Region+"</h2>";if(D.IsGeneralContact){C=K+"<p>"+F.SalesPhone+"</p>";return ;}var I=(F.Address=="")?"<dt>Main Office:</dt><dd><address>"+F.City+", "+F.State+" "+F.Zip+"</address></dd>":"<dt>Main Office:</dt><dd><address>"+F.Address+"<br />"+F.City+", "+F.State+" "+F.Zip+"</address></dd>";I=(F.City==""&&F.State==""&&F.Zip=="")?"<dt>Main Office:</dt><dd><address>"+F.Address+"</address></dd>":I;I=(F.Address==""&&F.City==""&&F.State==""&&F.Zip=="")?"":I;var J=(F.SalesPhone=="")?"":"<dt>Sales:</dt><dd>"+F.SalesPhone+"</dd>";var H=(F.SupportPhone=="")?"":"<dt>Support:</dt><dd>"+F.SupportPhone+"</dd>";C+=(I==""&&J==""&&H=="")?"":K+"<dl"+((G==A.length-1)?' class="end"':"")+">"+I+J+H+"</dl>";}.bind(this));email=(D.ContactEmail=="")?"":'<p id="email"'+((C=="")?' class="end"':"")+'>For all Sales & Support email inquires: <a href="mailto:'+D.ContactEmail+'">'+D.ContactEmail+"</a></p>";this.copy=new Element("div",{id:"copy"}).insert(E).insert(B).insert(C).insert(email);$super(D);}});document.observe("dom:loaded",function(){var A=$$(".listings");if(A==null){return ;}A.each(function(B){if(B.hasClassName("product")){new SunGard.Listings.Product(B);}if(B.hasClassName("contact")){new SunGard.Listings.ContactInfo(B);}});});