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"]();},load:function(A){this._modalCache[this.ID]=this.getTemplateType(A.responseJSON.d.evalJSON());this.showModal();},error:function(A){alert("This listing is currently unavailable.");},callWebService:function(){new Ajax.Request(this._webServicePath,{postBody:"{ID:'"+this.ID+"'}",contentType:"application/json; charset=utf-8",onSuccess:this.load.bind(this),onFailure:this.error.bind(this)});},showModal:function(){$("footer").insert({before:this._modalCache[this.ID]});document.fire("modal:show");}});SunGard.Listings.Product=Class.create(SunGard.Listings,{_webServicePath:"/webservices/BrandProductsService.asmx/GetProductsForBrand",initialize:function($super,A){this.container=A;$super();},getTemplateType:function(A){return new SunGard.Listings.Product.Template(A);}});SunGard.Listings.Product.Template=Class.create(SunGard.ModalTemplate,{initialize:function($super,E){$super(E);var C=new Element("a",{href:this.data.BrandUrl}).update(this.data.BrandTitle);var G=new Element("h1").insert(C);var B=(this.data.BrandSummary=="")?"":new Element("p").update(this.data.BrandSummary);var D=(this.data.RegionNames=="")?"":new Element("p").update("<strong>Where Available:</strong> "+this.data.RegionNames);var F=$A(this.data.AssociatedProducts);if(F.length>0){if(F.length==1&&this.data.BrandTitle==F[0].Title){C.href=F[0].FriendlyUrl;B=new Element("p").update(F[0].Summary);}else{var H=new Element("h2").update("What We Offer");var I=new Element("dl");F.each(function(J){var L=new Element("dt").insert(new Element("a",{href:J.FriendlyUrl}).update(J.Title));var K=new Element("dd").update(J.Summary);I.insert(L).insert(K);});}}var A=new Element("div",{id:"copy"}).insert(G).insert(B).insert(D).insert(H).insert(I);this.container=new Element("div",{id:"listings-product",className:this._className}).insert(this.controls).insert(A);}});SunGard.Listings.ContactInfo=Class.create(SunGard.Listings,{_webServicePath:"/webservices/BrandProductsService.asmx/GetContactInfoForBrand",initialize:function($super,A){this.container=A;$super();},getTemplateType:function(A){return new SunGard.Listings.ContactInfo.Template(A);}});SunGard.Listings.ContactInfo.Template=Class.create(SunGard.ModalTemplate,{initialize:function($super,D){$super(D);var F="<h1>"+this.data.BrandTitle+"</h1>";var B=(this.data.PDFFileLink==""||this.data.PDFFileLink==null)?"":'<p id="pdf"><a href="'+this.data.PDFFileLink+' ">All '+this.data.BrandTitle+" Contacts and Locations</a>"+SunGard.MediaTypeIcons.pdf+" [PDF, "+this.data.PDFFileSize+" KB]</p>";var C="";var A=$A(this.data.RegionalContactInfo);A.each(function(G,H){var L="<h2>"+G.Region+"</h2>";if(this.data.IsGeneralContact){C=L+"<p>"+G.SalesPhone+"</p>";return ;}var J=(G.Address=="")?"<dt>Main Office:</dt><dd><address>"+G.City+", "+G.State+" "+G.Zip+"</address></dd>":"<dt>Main Office:</dt><dd><address>"+G.Address+"<br />"+G.City+", "+G.State+" "+G.Zip+"</address></dd>";J=(G.City==""&&G.State==""&&G.Zip=="")?"<dt>Main Office:</dt><dd><address>"+G.Address+"</address></dd>":J;J=(G.Address==""&&G.City==""&&G.State==""&&G.Zip=="")?"":J;var K=(G.SalesPhone=="")?"":"<dt>Sales:</dt><dd>"+G.SalesPhone+"</dd>";var I=(G.SupportPhone=="")?"":"<dt>Support:</dt><dd>"+G.SupportPhone+"</dd>";C+=(J==""&&K==""&&I=="")?"":L+"<dl"+((H==A.length-1)?' class="end"':"")+">"+J+K+I+"</dl>";}.bind(this));email=(this.data.ContactEmail=="")?"":'<p id="email"'+((C=="")?' class="end"':"")+'>For all Sales & Support email inquires: <a href="mailto:'+this.data.ContactEmail+'">'+this.data.ContactEmail+"</a></p>";var E=new Element("div",{id:"copy"}).insert(F).insert(B).insert(C).insert(email);this.container=new Element("div",{id:"listings-contact-info",className:this._className}).insert(this.controls).insert(E);}});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);}});});