var Picture={id:"Picture",title:"Picture",UpdateSectionDialog:"updatesectiondialog/103398349.js",EditPictureDialog:"editpicturedialog/114916332.js",noOpenSection:true,noCollapse:true,_11:10,_12:2,picId:1,_0:"#f0eeef",defaultSectionHeight:275,_9:function(){return Theme.c0.darkest},_14:function(){return Theme.c0.lighter},renderStyle:function(w){w("");w(".sp-empty-img {display: block; margin: 0 auto 10px auto; width: 62px; height: 43px; cursor: pointer; background: transparent ",Theme.url("Base/i/img_singlePicEmpty.png"),"no-repeat center center;}",".pic-empty-or {width: 24px; height: 28px; background: transparent ",Theme.url("Base/i/img_or.png")," no-repeat left bottom;}",".pic-empty-upload {position: relative; top: -5px;}")},isHidden:function(s){var hidden=false;if(P.kind=="Page"&&!s["well"+Picture.picId]&&!s.permissions.edit){hidden=true}return hidden},renderEmpty:function(w,s){var t=Picture;if(!s.permissions.edit){return}var onclick="Picture.addWellImg("+s.nodeId+", 0);return false";var atts={onclick:onclick};var onclickUpload="Picture.addWellImg("+s.nodeId+", 1);return false";var attsUpload={className:"pic-empty-upload",onclick:onclickUpload};w("<div class='empty bg-alt'>",HtmlFactory.img({className:'sp-empty-img',src:ImgSrc.blank,onclick:onclick}),Html.formatRenderedContent(EmptyState,"renderButton",["Click to add picture from Shutterfly",atts]),"<br/>",HtmlFactory.img({className:'pic-empty-or',src:ImgSrc.blank}),Html.a("","Upload new picture",attsUpload),"</div>")},updateSection:function(s){s=PageNode.get(s);if(s){Module.showDialog(Picture,"UpdateSectionDialog",{section:s})}},createSectionMenuItems:function(menu,s){var t=Picture;var sp=s.permissions;var id=s.nodeId;if(U.un&&sp.edit){var wellPicture=s["well"+t.picId];var wellHasPicture=t.wellHasPicture(wellPicture);menu.addDivider();if(!wellHasPicture){menu.add("Add picture...",t.addWellImg,id)}else{menu.add("Edit picture...",t.editWellImg,id);menu.add("Clear Picture",t.clearPicture,[id,t.picId])}menu.addDivider();menu.add("Adjust section height...",t.updateSection,id)}},addWellImg:function(sid,tab){var t=Picture;var s=PageNode.get(sid);if(!U.id){SigninPopup.dialog("addPics","add your picture to this site","Picture","addWellImg",[sid,tab]);return}if(s){var c={parentId:s.nodeId,beforeId:t.picId,destType:"picture",onAdd:t._3,onUpload:t._6,tab:tab};C.addPictures(c)}},editWellImg:function(s){var t=Picture;s=PageNode.get(s);if(s){var sectionHeight=s.sectionHeight;var sectionWidth=t.getSectionWidth(s);var c={s:s.nodeId,sectionWidth:sectionWidth,sectionHeight:sectionHeight};Module.showDialog(t,"EditPictureDialog",c)}},clearPicture:function(s,wellPicId){var t=Picture;s=PageNode.get(s);if(s){s.sectionHeight=0;var wellPicture=s["well"+wellPicId];if(wellPicture){var msg={section:s.nodeId,wellpicId:wellPicId};C.beginExec("picture/clearwellpicture",msg);s["well"+wellPicId]=null;Section.refreshContentHtml(s)}}},_3:function(parentId,wellPicId,item){var t=Picture;var s=page.nodes[parentId];if(item.nodeType=="shutterflyAItem"){var msg={parent:parentId,beforeId:wellPicId,shutterflyId:item.shutterflyId,width:item.width,height:item.height};C.beginExec("picture/add",msg,t._5,{s:s.nodeId,wellPicId:wellPicId})}},_5:function(response,state){if(!response.error){Dialog.close(Dialog.context.did)}},_6:function(args){var success=false;var c=Dialog.context||{};args.siteId=S.id;var response=C.exec("picture/addfromupload",args);if(!response.error){success=true;Dialog.close(c.did)}return success},renderContent:function(w,s){var t=Picture;if(!s["well"+t.picId]){t.renderEmpty(w,s);return}w("<div class='picture' >","<div class='marquee-1'>",t._7(s,1),"<br style='clear: both; font-size: 1px;'/>","</div>","</div>")},_7:function(s){var t=Picture;var sp=s.permissions;var canEdit=sp.edit;var sb=new StringBuilder();var w=sb.write;var wellPicId=t.picId;var sectionHeight=(s.sectionHeight)?s.sectionHeight:t.defaultSectionHeight;var sectionWidth=t.getSectionWidth(s);var wellPicture=s["well"+wellPicId];var hasPicture=t.wellHasPicture(wellPicture);var url;if(hasPicture){if(wellPicture.destWidth==sectionWidth&&wellPicture.destHeight==sectionHeight){url=t._1(s,wellPicture)}else{url=t._8(s,wellPicture)}}var id=t._10(s,wellPicId);w("<div style='width: ",sectionWidth,"px; height: ",sectionHeight,"px; background-color: ",t._0,";border: 1px solid ",Theme.c0.darker,";' ",(canEdit?" class='picture-pic picture-pic-"+wellPicId+"'"+Menu.contextAtts("Picture.SectionMenu",id,true):" class='picture-pic picture-pic-"+wellPicId+"'")," id='n_",id,"'>");if(canEdit&&!hasPicture){w("<div style='position: relative;'>",t._13(s),"</div>")}w("<div>");var imgSizer=new ImageSizer(sectionWidth,sectionHeight,{clip:true,onLoadImageDone:t._4});imgSizer.render(w,{src:url,sid:s.nodeId});w("</div>","</div>");return sb.toString()},_4:function(e,args){var t=Picture;var sId=Dom.getAttribute(e,"sid");if(sId){var s=page.nodes[sId];if(s){var sectionHeight=s.sectionHeight;var sectionWidth=t.getSectionWidth(s);var wellPicture=s["well"+t.picId];if(wellPicture&&(!wellPicture.manualCrop||wellPicture.destHeight!=sectionHeight||wellPicture.destWidth!=sectionWidth)){if(wellPicture.height==0||e.height==0)return;var wellPicRatio=wellPicture.width/wellPicture.height*100;var realPicRatio=e.width/e.height*100;if(Math.abs(wellPicRatio-realPicRatio)>1){wellPicture.width=e.width;wellPicture.height=e.height}if(!s.sectionHeight){s.sectionHeight=Math.round(sectionWidth/ (realPicRatio /100));sectionHeight=s.sectionHeight}var bounds=Shutterfly.getBestFitBounds(wellPicture,t.getSectionWidth(s),s.sectionHeight);wellPicture.leftOffset=bounds.x/bounds.width;wellPicture.bottomOffset=1-((bounds.y+sectionHeight)/bounds.height);wellPicture.rightOffset=(bounds.x+sectionWidth)/bounds.width;wellPicture.topOffset=1-(bounds.y/bounds.height);wellPicture.destHeight=sectionHeight;wellPicture.destWidth=sectionWidth;wellPicture.manualCrop=true;var url=t._1(s,wellPicture);Section.refreshContentHtml(s);var sp=s.permissions;var canEdit=sp.edit;if(U.id&&canEdit){setTimeout("Picture._2("+sId+");",0)}}}}},_2:function(sId){var t=Picture;var s=page.nodes[sId];if(!s)return;var sectionHeight=s.sectionHeight;var sectionWidth=t.getSectionWidth(s);var wellPicture=s["well"+t.picId];if(!wellPicture)return;var params={page:P.id,version:page.version,section:s.nodeId,wellPictureId:t.picId,width:wellPicture.width,height:wellPicture.height,destWidth:sectionWidth,destHeight:sectionHeight,leftOffset:wellPicture.leftOffset,bottomOffset:wellPicture.bottomOffset,rightOffset:wellPicture.rightOffset,topOffset:wellPicture.topOffset,sectionHeight:s.sectionHeight};C.beginExec("picture/editpicture",params,null,null,true)},_1:function(s,wellPicture){var t=Picture;var sectionHeight=s.sectionHeight;var sectionWidth=t.getSectionWidth(s);return Shutterfly.formatCroppedImgSrc(wellPicture,sectionWidth,sectionHeight,wellPicture.leftOffset,wellPicture.bottomOffset,wellPicture.rightOffset,wellPicture.topOffset)},_8:function(s,wellPicture){var t=Picture;var bounds=Shutterfly.getBestFitBounds(wellPicture,t.getSectionWidth(s),s.sectionHeight);return Shutterfly.formatImgSrc(wellPicture,Math.max(bounds.width,bounds.height))+"?v="+new Date().getTime().toString()},wellHasPicture:function(well){return(well&&well.shutterflyId&&true)},_13:function(s){var t=Picture;var sectionHeight=(s.sectionHeight)?s.sectionHeight:t.defaultSectionHeight;var sectionWidth=t.getSectionWidth(s);var wellPicId=t.picId;var cpHeight=48;var cpWidth=170;var cpHOffset=(sectionWidth*0.5);var cpVOffset=(sectionHeight*0.5)-(cpHeight/2);var sb=new StringBuilder();sb.write("<div style='position: absolute; text-align: center; left: ",cpHOffset,"px; top: ",cpVOffset,"px;'>","<div style='position: absolute; width: ",cpWidth,"px; left: -",(cpWidth/2),"px; height: ",cpHeight,"px; background-color: ",t._0,"; padding-top: 7px; text-align: center;' >","<a href=# classx=showLink onclick='Picture.addWellImg(",s.nodeId,"); return false;'>","<div>","<img src='",A.imageUrl("pictureadd.gif"),"' style='width: 29px; height: 23px;' />","</div>","Click to add picture here","</a>","</div>","</div>");return sb.toString()},_16:function(){return S.templateName||"p_photo";},_15:function(borderRight,borderBottom){var t=Picture;if(borderRight||borderBottom){return"border-"+(borderRight?"right":"bottom")+": "+t._12+"px solid "+t._9()+";"}return""},_10:function(s,wellPicId){return s.nodeId+"-"+wellPicId},getSectionWidth:function(s){var t=Picture;var z=s.zone;var columns=page.layout.length;var isSingleColumn=(columns==1);var isLastZone=(z.id==(columns-1));var width=z.width-t._11*(isLastZone&&!isSingleColumn?2:3);width-=2;return width},SectionMenu:{getHoverLocation:function(b,sz){return{x:b.x+b.width-sz.width-4,y:b.y+5}},createMenuItems:function(m,args){var id=args;if(!id)return;var pictureIdParts=id.split("-");var sid=pictureIdParts[0];var wellPicId=parseInt(pictureIdParts[1],10);var s=P.nodes[sid];if(!s)return;var wellPicture=s["well"+wellPicId];var wellHasPicture=Picture.wellHasPicture(wellPicture);if(!wellHasPicture){m.add("Add picture...",Picture.addWellImg,[sid])}else{m.add("Edit picture...",Picture.editWellImg,[sid]);m.addDivider();m.add("Clear picture",Picture.clearPicture,[sid,Picture.picId],{image:"delete.gif"})}}}};if(window.Module)Module.add(Picture);