var wall=wall?wall:{wWall:825,hImage:75,wImage:75,imageFadeIn:300,pageTransition:2500,hoverSize:15,hoverBorder:4,imagesPerPage:66,requiredPerPage:12,imageUrlPrefix:"http://wall.indebted.com",page:1,animated:false,images:{},locations:["0x0","75x0","150x0","225x0","300x0","375x0","450x0","525x0","600x0","675x0","750x0","0x75","75x75","150x75","225x75","300x75","375x75","450x75","525x75","600x75","675x75","750x75","0x150","75x150","150x150","225x150","300x150","375x150","450x150","525x150","600x150","675x150","750x150","0x225","75x225","150x225","225x225","300x225","375x225","450x225","525x225","600x225","675x225","750x225","0x300","75x300","150x300","225x300","300x300","375x300","450x300","525x300","600x300","675x300","750x300","0x375","75x375","150x375","225x375","300x375","375x375","450x375","525x375","600x375","675x375","750x375"],init:function(){$("#wall p").remove();var d=$("#wall");$('<img id="loadingImg" src="images/wall_loading.gif" alt="loading" />').appendTo(d);$('<div id="wallScroller"></div>').appendTo(d);$("#nextPage, #previousPage").click(wall.goToPage);$(".closeModal, #modalOverlay").click(function(f){f.preventDefault();wall.modalClose()});$("#joinButton").click(function(f){f.preventDefault();$("#formModal, #modalOverlay").show()});$("#formModal div.modalContent").html('<iframe src="http://wall.indebted.com/submission-form/" frameborder="0" marginwidth="0" marginheight="0" scrolling="no" height="767" width="617" />');this.loadPage();var e=["wall_pop_frame.png","wall_pop_tr.png","wall_pop_bl.png","wall_caption_deficit.png","wall_caption_entitlements.png","wall_caption_healthcare.png","wall_caption_reduce.png","wall_caption_wakeup.png"],c=e.length;for(var b=0;b<c;b++){var a=new Image();a.src=wall.imageUrlPrefix+"/images/"+e[b]}},loadPage:function(){if($("#page"+wall.page).length===0){var a=$('<div id="page'+wall.page+'" class="wallPage" style="left: '+(wall.wWall*(wall.page-1))+'px;">').click(function(b){b.preventDefault();wall.imageModal.call(b.target)}).appendTo("#wallScroller");if(!wall.images[wall.page]){wall.images[wall.page]=[]}$.get(wall.imageUrlPrefix+"/feed-xml/?s="+(((wall.page-1)*66)+1),null,function(e){var b=$(e).find("submission"),j=b.size();b.each(function(l){if(l<wall.imagesPerPage){$this=$(this);wall.images[wall.page].push({name:$this.attr("firstName")+" "+$this.attr("lastInitial")+".",city:$this.attr("city"),state:$this.attr("state"),caption:$this.attr("caption"),statement:$this.attr("statement"),thumb:$this.attr("thumbPhoto"),large:$this.attr("largePhoto")})}});if(j<wall.imagesPerPage+wall.requiredPerPage){$("#nextPage").hide();if(j<wall.imagesPerPage){var h=[],c=0,g=0,f=wall.images[wall.page].length;for(var d=0;d<f;d++){h.push(c+"x"+g);c+=wall.wImage;if(c>=wall.wWall){c=0;g+=wall.hImage}}}}else{$("#nextPage").css("display","block");wall.images[wall.page+1]=[]}var k=h||wall.locations.slice();k.sort(function(){return 0.5-Math.random()});$("#loadingImg").css("display","none");wall.loadImages(wall.page,wall.images[wall.page],k)})}else{if(!wall.images[wall.page+1]){$("#nextPage").hide()}}},loadImages:function(d,b,a){var e=a.pop().split("x"),c=b.pop();$("<img>").attr("rel",wall.imageUrlPrefix+c.large).attr("title",c.statement).data("caption",c.caption).data("byline","<strong>"+c.name+"</strong> from "+c.city+", "+c.state).data("left",e[0]+"px").data("top",e[1]+"px").attr("style","display: none; left: "+e[0]+"px; top: "+e[1]+"px;").load(function(){$(this).fadeIn(wall.imageFadeIn);if(b.length&&a.length){wall.loadImages(d,b,a)}}).hover(function(){var f=$(this);if(f.queue().length===0){f.queue(function(){f.css("z-index","2");f.css("border",wall.hoverBorder+"px solid #fff");f.dequeue()}).animate({left:f.css("left").replace("px","")-(wall.hoverSize+wall.hoverBorder*2)/2+"px",top:f.css("top").replace("px","")-(wall.hoverSize+wall.hoverBorder*2)/2+"px",height:this.height+wall.hoverSize+"px",width:this.width+wall.hoverSize+"px"},100)}},function(){var f=$(this);f.animate({height:wall.hImage+"px",left:f.data("left"),top:f.data("top"),width:wall.wImage+"px"},50,function(){f.css("border","0").css("z-index","1")})}).appendTo($("#page"+d)).attr("src",wall.imageUrlPrefix+c.thumb)},goToPage:function(a){a.preventDefault();if(!wall.animated){wall.animated=true;wall.modalClose();var c=wall.page;if(this.id=="nextPage"){$("#previousPage").css("display","block");wall.page++}else{$("#nextPage").css("display","block");wall.page--}if(wall.page==1){$("#previousPage").hide()}wall.loadPage();var b=parseInt("-"+(c-1)*wall.wWall,10);b=c<wall.page?b-wall.wWall:b+wall.wWall;$("#wallScroller").animate({marginLeft:b+"px"},wall.pageTransition,function(){wall.animated=false})}},imageModal:function(a){var b=$(this),c=$("#imageModal div.modalContent");c.html("").css("height","300px");$("#modalOverlay").show();$('<img src="'+b.attr("rel")+'" alt="" />').load(function(){var d=this.width,g=this.height;if(!d){var j=new Image();j.src=b.attr("rel");d=j.width||300;g=j.height||300}c.css("width",d+"px");$("#imageModal").css("left",(parseInt(b.data("left").replace("px",""),10)+50-(d/2))+"px").css("top",parseInt(b.data("top").replace("px",""),10)+60+"px");$("#imageModal").show();var f=(d/2)-(185/2);var k=b.attr("title").split("|"),e=k[0],h=k[1];var i='<div><h4 class="caption '+b.data("caption")+'" style="left: '+f+'px;">'+b.data("caption")+'</h4><img src="'+b.attr("rel")+'" alt="" /></div><p>'+b.attr("title")+'</p><p class="byline">'+b.data("byline")+'</p><p class="report"><a href="/report-abuse/?o='+encodeURIComponent(b.data("byline").replace(/<strong>([^<]+)<\/strong>/,"$1"))+'">report abuse</a></p>';c.html(i).css("height","auto")})},modalClose:function(){$("#imageModal:visible").children("div.modalcontent").html("").css("height","300px");$("div.modal, #modalOverlay").hide()}};
