// Copyright 2009 Google Inc. All Rights Reserved.
var gweb=gweb||{};gweb.privacy=gweb.privacy||{};gweb.privacy.Promo=function(a){this.container=a.container;this.url=a.url;this.template=a.template;this.itemTemplate=a.itemTemplate;this.topToMain=a.topToMain;google.load('feeds','1');google.setOnLoadCallback(this.createApiLoadHandler_())};gweb.privacy.Promo.prototype.createApiLoadHandler_=function(){var a=this;return function(){gweb.feed.loadSpreadsheet(a.createDataHandler_(),a.url)}};gweb.privacy.Promo.prototype.createDataHandler_=function(){var b=this;return function(a){b.data=a;b.displayPromo_()}};gweb.privacy.Promo.prototype.displayPromo_=function(){var a=this.data;var b=[];for(var i=this.topToMain?1:0,len=a.length;i<len;i++){b.push(gweb.privacy.Promo.templatize_(a[i],this.itemTemplate))}var c=this.topToMain?a[0]:{};c.items=b.join('');var d=gweb.privacy.Promo.templatize_(c,this.template);this.container.innerHTML=d};gweb.privacy.Promo.templatize_=function(c,d){return d.replace(/{(.*?)}/g,function(a,b){return c[b]||''})};