function setImagesAsJs(d){if(d){var c="Set this image as my icon, profile pic or background...";var a="/profile/get-profile-image/?image_id="+d}else{var c="Change your icon, profile or background image(s).";var a="/profile/get-profile-image/"}var b=new LaunchPad.Base({titleTextStr:c,url:a});b.open("get");b.addEvent("openComplete",function(){if($("jsRemoveBg")){$("jsRemoveBg").addEvent("click",function(){$("remove_background").value="1";$("jsBgImage").setStyles({opacity:".5"});$("jsRemoveBg").addClass("dn");$("jsUndoRemoveBg").removeClass("dn")})}if($("jsUndoRemoveBg")){$("jsUndoRemoveBg").addEvent("click",function(){$("remove_background").value="";$("jsBgImage").setStyles({opacity:"1"});$("jsUndoRemoveBg").addClass("dn");$("jsRemoveBg").removeClass("dn")})}$("jsImagesSetCancel").addEvent("click",function(){b.hide()});$("jsImagesSetSave").addEvent("click",function(){var e=$("jsImagesSetForm").toQueryString();b.options.stage.empty();b.loading(true);new VinesAjax("/profile/edit-profile-image/",{method:"POST",data:e,onFailure:function(){alert("Sorry, we failed.")},onComplete:function(f){var f=JSON.decode(f);b.hide();if(!f.success){vinesLoadingMask(false);return}vinesLoadingMask(true);var g=false;if($("js-main-image")){g=$("js-main-image").getElement("img#js-main-image-img")}if(f.changes&&f.changes.imageicon_src){if(g){$$(".js-imageicon").each(function(l){copy_image_to_image(g,l)})}else{var i=f.changes.imageicon_src;var k=new Asset.image(i,{onload:function(){k.inject(document.body);$$(".js-imageicon").each(function(l){copy_image_to_image(k,l)})}})}}if(f.changes&&f.changes.imageprofile_src){if(g){$$(".js-imageprofile").each(function(l){copy_image_to_image(g,l)})}else{var i=f.changes.imageprofile_src;var j=new Asset.image(i,{onload:function(){j.inject(document.body);$$(".js-imageprofile").each(function(l){copy_image_to_image(j,l)})}})}}if(f.changes&&f.changes.imagebg_src){var i=f.changes.imagebg_src;if(i=="false"){document.body.setStyle("background-image","url("+i+")");vinesLoadingMask(false)}else{var h=new Asset.image(i,{onload:function(){h.inject(document.body);document.body.setStyle("background-image","url("+i+")");vinesLoadingMask(false)}})}}}}).request()})})}function copy_image_to_image(g,h){var e=g.clone();var i=g.getPosition();var a="imageClone"+$random(1,100);e.setProperty("id",a).injectAfter(g).setStyles({"z-index":"20002",position:"fixed",top:i.y,left:i.x});var d=h.getPosition();var f=d.y-document.documentElement.scrollTop;var b=d.x;vinesLoadingMask(false);var j={top:f,left:b,width:h.getCoordinates().width,height:h.getCoordinates().height};var c=new Fx.Morph(e,{duration:600,wait:false});c.options.transition=Fx.Transitions.Expo.easeOut;c.start(j).chain(function(){h.src=g.src;e.remove()})}function setObjectMainImageJs(d,c,b){var a=confirm("Set this image as the main image");if(!a){return false}vinesLoadingMask(true);new Request.JSON({url:"/image/process-content-object-image/",method:"post",onSuccess:function(e){var f=e.success;if(f=="yes"){vinesLoadingMask(false);var h=false;if($("js-main-image")){h=$("js-main-image").getElement("img#js-main-image-img")}var g=$("js-object-image");if(h&&g){copy_image_to_image(h,g)}else{alert("Thank you, set. Refresh page to see changes.")}}else{vinesLoadingMask(false);alert("Sorry, I was not able to compute that.")}}.bind(this)}).send({image_id:d,content_type_id:c,object_id:b})}function removeImage(d,c,b){var a=confirm("Remove this image from this page?  Are you sure?!");if(!a){return false}vinesLoadingMask(true);new Request.JSON({url:"/image/remove-image/",method:"post",onSuccess:function(e){vinesLoadingMask(false);if(e.success=="yes"){alert("Done! Refresh the page to see your change.")}else{alert("Could not delete.")}}}).send({image_id:d,content_type_id:c,object_id:b})}function deleteImageJs(d){var c=confirm("STAFF ONLY:\n\nDelete this image completely from the site? \n\nUse this only to delete bad/pornographic images. \nOtherwise just use the normal moderation tools to remove image from a ContentObject or Gallery!");if(!c){return false}lploading=new LaunchPad.Base();lploading.show();lploading.loading(true);var b="/image/process-image-delete-completely/?image_id="+d;var a;var e="get";new VinesAjax(b,{method:e,update:a,onComplete:function(f){var f=JSON.decode(f);var g=f.success;lploading.hide();if(g=="yes"){alert("Image has been obliterated")}else{alert(f.message)}}.bind(this)}).request()}function deleteUsersImagesJs(b){var d=confirm("STAFF ONLY:\n\nDelete all user's images completely from the site? \n\nUse this only to delete bad/pornographic images. \nOtherwise just use the normal moderation tools to remove image from a ContentObject or Gallery!");if(!d){return false}lploading=new LaunchPad.Base();lploading.show();lploading.loading(true);var c="/image/process-user-images-delete/?user_profile_id="+b;var a;var e="get";new VinesAjax(c,{method:e,update:a,onComplete:function(f){var f=JSON.decode(f);var g=f.success;lploading.hide();if(g=="yes"){alert("All images have been obliterated")}else{alert(f.message)}}.bind(this)}).request()}function getBrowserWidth(){if(window.innerWidth){return window.innerWidth}else{if(document.documentElement&&document.documentElement.clientWidth!=0){return document.documentElement.clientWidth}else{if(document.body){return document.body.clientWidth}}}return 0}function dynamicLayout(){var a=getBrowserWidth();if(a<1025){$$("#js-img-gallery").each(function(b){b.className="";b.addClass("img-gallery-3w")})}if((a>=1025)&&(a<=1200)){$$("#js-img-gallery").each(function(b){b.className="";b.addClass("img-gallery-4w")})}if((a>=1200)&&(a<=1500)){$$("#js-img-gallery").each(function(b){b.className="";b.addClass("img-gallery-5w")})}if(a>1500){$$("#js-img-gallery").each(function(b){b.className="";b.addClass("img-gallery-6w")})}}window.addEvent("domready",dynamicLayout);window.addEvent("resize",dynamicLayout);var SingleImageWidget=new Class({initialize:function(a){this.img=$(a).getElement("img");this.input=$(a).getElement("input");this.loader=$(a).getElement(".jsSingleImageLoading");this.texter=$(a).getElement(".jsSingleImageText");this.image_panel=false;this.img.addEvent("click",function(){this.open_image_lp(a)}.bind(this));this.el=a},open_image_lp:function(){if(this.image_panel){this.image_panel.show()}else{var a={title:"Upload an image",onFinish:this.images_selected.bind(this),image_limit:1};this.image_panel=new ImagePanel(["browse","myimages","search"],a)}},images_selected:function(a){a=a[0];this.loader.removeClass("dn");this.texter.addClass("dn");if(a=="null"||a==null){alert("Oh no, no images were found!");return}new VinesAjax("/image/ajax_post/",{method:"Post",data:{method:"get_image_by_ids",size:"thumb",ids:a},onFailure:function(){this.loader.addClass("dn");alert("Sorry, there was an error")}.bind(this),onComplete:function(b){var b=JSON.decode(b);img=b[0];var d=img.id;var c=img.src;this.src=c;this.input.value=d;new Asset.image(c,{id:d,title:"image",onload:function(){this.loader.addClass("dn");this.img.setProperty("src",c)}.bind(this)});this.input.fireEvent("change",{target:this.input,type:"change"})}.bind(this)}).request()}});var ImageMonster=new Class({initialize:function(a){if(!vinesLoginRequired()){return}this.image_panel=false;this.content_type_id=a.getProperty("rel_ct_id");this.object_id=a.getProperty("rel_ob_id");this.object_name=a.getProperty("rel_ob_name");this.gallery_name="";if(a.getProperty("rel_gallery_name")){this.gallery_name=a.getProperty("rel_gallery_name")}this.rollup_ct_id=a.getProperty("rollup_ct_id");this.rollup_ob_id=a.getProperty("rollup_ob_id");this.rollup_gallery_name="";if(a.getProperty("rollup_gallery_name")){this.rollup_gallery_name=a.getProperty("rollup_gallery_name")}this.rollup_ct_id2=a.getProperty("rollup_ct_id2");this.rollup_ob_id2=a.getProperty("rollup_ob_id2");this.rollup_gallery_name2="";if(a.getProperty("rollup_gallery_name2")){this.rollup_gallery_name2=a.getProperty("rollup_gallery_name2")}if(!this.object_id){this.open_search_lp()}else{this.open_image_lp()}},open_search_lp:function(){var b="Add images to...";var a="/image/imagemonster/?ct_id="+this.content_type_id;this.searchLp=new LaunchPad.Base({titleTextStr:b,url:a,styles:{width:"400px"}});this.searchLp.addEvent("openComplete",function(){if(this.object_id){$("js-monsterimage-search").addClass("dn");this.open_image_lp()}else{var f=$("js-search-monsterimage");var d=f.getProperty("rel_ctid");var c="fireAcSelected";var e=new VinesSearchAC(f,"/autosearch/?ct_ids="+d,{allow_create:false,callBackEvent:c});f.addEvent(c,function(g,h){if(!g.object_id){}else{searchLp.hide();this.object_name=g.name;this.content_type_id=g.content_type_id;this.object_id=g.object_id;this.open_image_lp()}}.bind(this))}}.bind(this));this.searchLp.open()},open_image_lp:function(){if(this.image_panel){this.image_panel.show()}else{this.image_panel=new ImagePanel(["browse","myimages"],{title:"Upload images to "+this.object_name+"'s '",content_type_id:this.content_type_id,object_id:this.object_id,onFinish:this.images_selected.bind(this)})}},images_selected:function(a){vinesLoadingMask(true);var c={content_type_id:this.content_type_id,object_id:this.object_id,image_ids:a,rollup_ob_id:this.rollup_ob_id,rollup_ct_id:this.rollup_ct_id,rollup_ob_id2:this.rollup_ob_id2,rollup_ct_id2:this.rollup_ct_id2,gallery_name:this.gallery_name,rollup_gallery_name:this.rollup_gallery_name,rollup_gallery_name2:this.rollup_gallery_name2};var b=new Request.JSON({url:"/image/add-images-to-object/",method:"post",onSuccess:this.image_selected_cb.bind(this)}).send(c)},image_selected_cb:function(a){vinesLoadingMask(false);if(a.success=="yes"){var b=new LaunchPad.Base({titleTextStr:"Yay, success!"});b.open();b.insert(a.html)}else{alert("So sorry, there was an error. Try again?")}}});window.addEvent("domready",function(){$$(".js-imagemonster").addEvent("click",function(b){var a=new ImageMonster(this);return})});var GalleryMonster=new Class({initialize:function(e){var d=vinesLoginRequired();if(!d){return}this.image_panel=false;var c=e.getProperty("rel_galleryname");this.gallery_name=c;var a=e.getProperty("rel_ct_name");var f="Add "+c+" images to...";var b="/image/gallerymonster/?gallery_name="+c+"&ct_name="+a;lp=new LaunchPad.Base({titleTextStr:f,url:b,styles:{width:"400px"}});lp.addEvent("openComplete",function(){var j=$("js-search-monstergallery");var h=j.getProperty("rel_ctid");var g="fireAcSelected";var i=new VinesSearchAC(j,"/autosearch/?ct_ids="+h,{allow_create:false,callBackEvent:g});j.addEvent(g,function(k,l){if(!k.object_id){}else{lp.toggleLoading(true,$("js-monstergallery"));this.object_name=k.name;this.content_type_id=k.content_type_id;this.object_id=k.object_id;this.open_image_lp()}}.bind(this))}.bind(this));lp.open()},open_image_lp:function(){if(this.image_panel){this.image_panel.show()}else{this.image_panel=new ImagePanel(["browse","myimages"],{title:"Upload images to "+this.object_name+"'s '"+this.gallery_name+"' Gallery",content_type_id:this.content_type_id,object_id:this.object_id,onFinish:this.images_selected.bind(this)})}},images_selected:function(a){var c={content_type_id:this.content_type_id,object_id:this.object_id,gallery_name:this.gallery_name,image_ids:a};var b=new Request.JSON({url:"/image/add-images-to-gallery/",method:"post",onSuccess:this.image_selected_cb.bind(this)}).send(c)},image_selected_cb:function(a){lp.toggleLoading(false,$("js-monstergallery"));if(a.success=="yes"){$$(".js-success-href").setProperty("href",a.gallery_url);$("js-success-img").setProperty("src",a.gallery_image);$("js-monstergallery-success").removeClass("dn");$("js-monstergallery-search").addClass("dn")}else{alert("So sorry, there was an error. Try again?")}}});window.addEvent("domready",function(){$$(".js-gallerymonster").addEvent("click",function(){var a=new GalleryMonster(this)})});var filmStrip=new Class({initialize:function(){this.image_id=0;this.gallery_id=0;this.filmstrip=null;this.offset=-1;this.next_offset=false;this.prev_offset=false;this.context_url="";this.total_images=0;this.recieved=false;this.strips=[];this.direction=false;this.leftLi=false;this.fx=[];this.navTimer=false;window.addEvent("domready",this.ready.bind(this))},ready:function(){if(!$("js-tab-content")){return}var b=$("js-main-image");var a=$(b).getElement("img#js-main-image-img");var c=new Asset.image(a.src,{id:"myImage",title:"myImage",onload:function(){b.setStyle("height",a.height)}});this.img=a;this.gallery_id=$("js-tab-content").getProperty("default_gallery_id");this.context_url=$("js-tab-content").getProperty("default_context_url");this.image_id=$("js-tab-content").getProperty("default_image_id");this.filmstrip=$("js-filmstrip");var d=$("js-main-image");$$(".js-gal-tab").each(function(e){e.addEvent("click",function(){this.selectGallery(e)}.bind(this))}.bind(this));this.offset=d.getProperty("offset").toInt();this.total_images=d.getProperty("total_count").toInt();this.leftLi=false;if($("js-filmstrip-ul").getFirst()){this.leftLi=$("js-filmstrip-ul").getFirst().id}this.strips.include(this.offset);this.startImageNav();this.receivedFilmstrip();$("js-filmstrip-backwards").addEvent("click",this.backwards.bind(this));$("js-filmstrip-forwards").addEvent("click",this.forwards.bind(this));this.scrollFx=new Fx.Scroll("js-filmstrip",{overflown:[$("js-filmstrip")]})},requestFilmstrip:function(){if(!this.mask){this.mask=new Element("div",{"class":"opacity-mask loading"});this.mask.inject("js-filmstrip").addEvent("click",function(c){(new Event(c)).stop()})}if(this.strips.contains(this.offset)){this.receivedFilmstrip()}else{var b={image_id:this.image_id,gallery_id:this.gallery_id};if(this.offset>-1){b.offset=this.offset}this.params=Object.toQueryString(b);var a=new Request.JSON({url:"/image/get-filmstrip/",method:"post",onSuccess:this.receivedFilmstrip.bind(this)}).send(b)}},receivedFilmstrip:function(e){if(this.mask){this.mask.remove()}if(e){this.total_images=e.total_images;var f=new Element("ul",{html:e.html});this.offset=f.getFirst().getProperty("offset").toInt();this.strips.include(this.offset);f.getElements("li").each(function(j){if($(j.id)){j.destroy()}else{var k=j.getElement("img");if(k.complete){k.fade("in")}else{k.setStyle("opacity",0).addEvent("load",function(){this.fade("in")})}}}.bind(this));if($("js-filmstrip-ul").getChildren().length>0){var c=$("js-filmstrip-ul").getChildren().length+f.getElements("li").length;var a=$("js-filmstrip-ul").getElement("li");var i=a.getCoordinates().width+a.getStyle("margin-left").toInt()+a.getStyle("margin-right").toInt();var b=$("js-filmstrip-ul").getCoordinates().width;var d=c*i;$("js-filmstrip-ul").setStyle("width",d)}if(this.direction&&this.direction=="left"){f.getChildren().reverse().inject("js-filmstrip-ul","top")}else{if(!this.direction||this.direction=="right"){f.getChildren().inject("js-filmstrip-ul")}}f.destroy()}if(this.direction){if(!$(this.leftLi)){this.leftLi=$("js-filmstrip-ul").getFirst().id}var h=$(this.leftLi);var g=0;while(h&&g<10){next=this.direction=="right"?h.getNext():h.getPrevious();if(!next||!next.getTag()=="li"){break}else{var h=next;g++}}if(h){this.leftLi=h.id;this.scrollFx.toElement(h)}}this.direction=false;$("js-filmstrip-forwards").setStyle("display",this.offset>=this.total_images-10?"none":"inline");$("js-filmstrip-backwards").setStyle("display",this.offset<=0?"none":"inline")},startImageNav:function(){this.interval=window.setInterval(function(){if(this.img.getCoordinates().height>0){clearInterval(this.interval);this.buildImageNav()}}.bind(this),100)},buildImageNav:function(){var d=this.img,b,e,h,a;b=$("js-filmstrip-ul").getElement(".on")?$("js-filmstrip-ul").getElement(".on"):$("js-filmstrip-ul").getFirst();if(!b){return}a=this.img.getCoordinates().height;if(b.getPrevious()){e=b.getPrevious().getElement("a").getProperty("href");if(this.offset>-1){e+="?offset="+this.offset}var c=new Element("a",{"class":"img-prev",href:e});c.inject("js-main-image")}var f=new Element("a",{"class":"img-zoom"});f.inject("js-main-image").addEvent("click",this.zoom.bind(this));if(b.getNext()){h=b.getNext().getElement("a").getProperty("href");if(this.offset>-1){h+="?offset="+this.offset}var g=new Element("a",{"class":"img-next",href:h});g.inject("js-main-image")}$("js-zoom").inject(document.body);window.addEvent("keydown",function(i){i=new Event(i);if(i.key=="right"&&h){vinesLoadingMask(true);window.document.location=h}else{if(i.key=="left"&&e){vinesLoadingMask(true);window.document.location=e}}});this.imageLoaded=false},zoom:function(){var b=$("js-zoom"),e=$("js-zoom-image"),c=new Fx.Transition(Fx.Transitions.Bounce,1);if(!this.imageLoaded){vinesLoadingMask(true);var d=new Element("div",{top:0,left:0});b.store("wrapper",d).setStyles({display:"block",visibility:"hidden"});var a=new Asset.image(e.getProperty("image_url"),{id:"zoomImage",title:"Original Size",onload:function(f){this.imageLoaded=true;vinesLoadingMask(false);this.zoomFx=new Fx.Slide(b,{transition:c.easeOut,mode:"vertical"});this.zoomFx.hide();b.setStyle("visibility","visible");this.zoomFx.slideIn()}.bind(this)});a.inject(e).addEvent("click",function(){this.zoomFx.slideOut()}.bind(this))}else{this.zoomFx.slideIn()}b.getElements(".js-zoom-close").addEvent("click",function(){this.zoomFx.slideOut()}.bind(this))},backwards:function(){this.direction="left";this.offset-=10;if(this.offset<0){this.offset=0}this.requestFilmstrip()},forwards:function(){this.direction="right";this.offset+=10;this.requestFilmstrip()},selectGallery:function(a){this.offset=0;this.gallery_id=a.getProperty("gallery_id");this.context_url=a.getProperty("context_url");this.total_images=a.getProperty("total_images");$("js-tab-content").getElements("a").each(function(b){if(b.hasClass("on")){b.removeClass("on")}});$$("#js-tab-content li").removeClass("on");$(a).getParent().addClass("on");$("js-filmstrip-ul").empty().setStyle("width","auto");this.scrollFx.toLeft();this.strips=[];this.leftLi=false;this.requestFilmstrip()}});filmStrip.implement(new Events);filmStrip.implement(new Options);ImagePanel=new Class({get_options:function(){return options={rte:false,content_type_id:"",object_id:"",gallery_id:"",title:"Add Images",image_limit:null,image_ids:[],sizes:["small","medium","large"]}},initialize:function(c,b){var a=vinesLoginRequired("Hi, you need to login or signup to edit images.");if(!a){return}this.options=this.get_options();this.setOptions(b);this.rte=this.options.rte;this.content_type_id=this.options.content_type_id;this.object_id=this.options.object_id;this.gallery_id=this.options.gallery_id;this.title=this.options.title;this.onFinish=b.onFinish;this.image_limit=this.options.image_limit;this.image_ids=this.options.image_ids;if(this.onFinish){this.addEvent("onFinish",this.onFinish)}var d=(["browse","myimages","mygalleries","search","flickr"]);if(!c){var c=d}this.pad=new LaunchPad.Base({destroy_on_hide:false,titleTextStr:this.title,url:VINES_BASE_URL+"/image/open_template/?tpl=buttons"});this.pad.addEvent("openComplete",function(){this.buttonsHolder=new Element("div").inject(this.pad.options.stage,"before").set("html",this.pad.options.stage.innerHTML);this.pad.options.stage.set("html"," ");d.each(function(e){var f=this.buttonsHolder.getElement(".js-image-"+e);if(f){c.contains(e)?f.setStyle("display","inline-block"):f.setStyle("display","none")}}.bind(this));c.each(function(e){if(e=="browse"){this.start_browse()}else{this.buttonsHolder.getElement(".js-image-"+e).addEvent("click",function(){this.hideNav();switch(e){case"myimages":this.start_myimages();break;case"mygalleries":this.start_mygalleries();break;case"search":this.start_search();break;case"flickr":this.start_flickr();break}}.bind(this))}}.bind(this))}.bind(this));this.pad.open()},loading:function(a){if(a){this.pad.options.stage.empty()}this.pad.loading(a)},close:function(){this.pad.hide()},show:function(){this.image_ids=[];this.pad.options.stage.set("html","");this.showNav();this.pad.show();this.reset_browse()},hideNav:function(){this.buttonsHolder.getElement(".upload-buttons").setStyles({height:0,overflow:"hidden",padding:0});this.hide_browse_button()},showNav:function(){this.buttonsHolder.getElement(".upload-buttons").setStyles({height:"auto",visibility:"visible",padding:20});this.show_browse_button()},finished:function(){if(this.image_ids.length==0){alert("Oops, no images were selected.");return false}if(this.onFinish){this.close();this.fireEvent("onFinish",[this.image_ids])}else{if(this.rte){this.start_positioner()}}},okButton:function(){if($(document.body).getElement(".jsCancel")){$(this.pad.options.stage).getElement(".jsCancel").addEvent("click",function(){this.pad.hide()}.bind(this))}var a=$(this.pad.options.stage).getElement(".jsOk");if(this.image_ids.length>0){a.removeClass("dn")}a.removeEvents("click");a.addEvent("click",function(){this.finished()}.bind(this))},selectItems:function(){$(this.pad.options.stage).getElements(".js-item").each(function(a){id=$(a).getElement("img").getProperty("id");this.image_ids.contains(id)?a.addClass("js-item-selected"):null;a.addEvent("click",function(b){id=$(a).getElement("img").getProperty("id");if(this.image_limit==1){$(this.pad.options.stage).getElements(".js-item-selected").each(function(d){d.removeClass("js-item-selected")});this.image_ids=[]}var c=$(this.pad.options.stage).getElement(".jsOk");if(a.hasClass("js-item-selected")){a.removeClass("js-item-selected");this.image_ids.remove(id);if(this.image_ids.length==0){c.addClass("dn")}}else{a.addClass("js-item-selected");this.image_ids.include(id);c.removeClass("dn")}}.bind(this))}.bind(this))},start_positioner:function(){this.loading(true);new Request.JSON({url:"/image/ajax_post/",method:"post",onSuccess:this.show_positioner.bind(this)}).send({method:"positioner"})},show_positioner:function(a){this.pad.options.stage.innerHTML=a.html;this.loading(false);if(this.image_ids.length>1){this.multi_positioner()}else{this.single_positioner()}},multi_positioner:function(){var a=null;var b=$(this.pad.options.stage).getElement(".jsOk");$("js-position-layout").removeClass("dn");$$(".js-position-layout").each(function(c){c.addEvent("click",function(){b.removeClass("dn");$(this.pad.options.stage).getElements(".js-position-layout").each(function(d){d.removeClass("on")});a=c.getProperty("rel_layout");c.addClass("on")}.bind(this))}.bind(this));$(this.pad.options.stage).getElement(".jsOk").addEvent("click",function(){var c=null;if(!a){c="Please pick Stack or Side by Side.\n"}if(c){alert(c);return false}this.loading(true);new Request.JSON({url:"/image/ajax_post/",method:"post",onSuccess:this.insert_positioned.bind(this)}).send({method:"get_formated_image",ids:this.image_ids,layout:a,uploaded_images:this.uploaded_images})}.bind(this))},single_positioner:function(){var a=null;var c=null;var b=$(this.pad.options.stage).getElement(".jsOk");$("js-position-size").removeClass("dn");$(this.pad.options.stage).getElements(".js-position-size").each(function(e){var d=e.getProperty("rel");if(!this.options.sizes.contains(d)){e.setStyle("display","none");if(d=="large"){$("js-position-center").setStyle("display","none")}}else{e.addEvent("click",function(){$(this.pad.options.stage).getElements(".js-position-size").each(function(f){f.removeClass("on")});e.addClass("on");a=e.getProperty("rel");if(a=="large"){$("js-position-left").setStyles({opacity:".3",cursor:"default"}).removeEvents("click");$("js-position-right").setStyles({opacity:".3",cursor:"default"}).removeEvents("click");$("js-position-center").setStyles({opacity:"1",cursor:"pointer"}).addClass("on");b.removeClass("dn");c="center"}else{$("js-position-center").setStyles({opacity:".3",cursor:"default"}).removeEvents("click");$("js-position-left").setStyles({opacity:"1",cursor:"pointer"}).addEvent("click",function(){$(this.pad.options.stage).getElements(".js-position-alignment").each(function(f){f.removeClass("on")});$("js-position-left").addClass("on");b.removeClass("dn");c="left"}.bind(this));$("js-position-right").setStyles({opacity:"1",cursor:"pointer"}).addEvent("click",function(){$(this.pad.options.stage).getElements(".js-position-alignment").each(function(f){f.removeClass("on")});$("js-position-right").addClass("on").removeClass("dn");b.removeClass("dn");c="right"}.bind(this))}$("js-position-alignment").removeClass("dn")}.bind(this))}}.bind(this));$$(".js-position-alignment").each(function(d){d.addEvent("click",function(){b.removeClass("dn");$(this.pad.options.stage).getElements(".js-position-alignment").each(function(e){e.removeClass("on")});c=d.getProperty("rel_align");d.addClass("on")}.bind(this))}.bind(this));$(this.pad.options.stage).getElement(".jsOk").addEvent("click",function(){var d=null;if(!a){d="Please pick a size.\n"}if(!c){d="Please pick left, center or right.\n"}if(d){alert(d);return false}this.loading(true);new Request.JSON({url:"/image/ajax_post/",method:"post",onSuccess:this.insert_positioned.bind(this)}).send({method:"get_formated_image",ids:this.image_ids,size:a,alignment:c,uploaded_images:this.uploaded_images})}.bind(this))},insert_positioned:function(a){var c=a.html;var b=new Element("span").set("html",c);var f=b.getElements("img");var d=[];f.each(function(g){d.include(g.getProperty("src"))});b.destroy();var e=new Asset.images(d,{onComplete:function(){this.close();this.fireEvent("return_html",[a.html],20)}.bind(this)})},start_browse:function(){if(this.Uploader){}else{new Request.JSON({url:"/image/show-upload/",method:"post",onSuccess:this.show_browse.bind(this)}).send({})}},reset_browse:function(){if(this.Uploader){this.Uploader.customSettings.count_in_queue=0;this.Uploader.customSettings.count_of_uploads=0;this.Uploader.customSettings.current_upload_order=0;this.Uploader.customSettings.image_ids=[]}this.set_events_browse()},show_browse_button:function(){if(this.browseButton){var d=this.pad.options.stage.getCoordinates();var a=this.buttonsHolder.getElement(".js-image-browse").getCoordinates();var f="30px";var e=a.left-d.left;var b=a.width;var c=a.height;this.browseButton.setStyles({position:"absolute","z-index":"20000",top:f,left:e,width:b,height:c,cursor:"pointer"})}},hide_browse_button:function(){if(this.browseButton){this.browseButton.setStyles({left:"-1000px"})}},show_browse:function(c){var d=c.html;this.uploaderDiv=new Element("div").setHTML(c.html).inject(this.pad.options.stage,"before").addClass("dn");this.browseButton=new Element("div").inject(this.buttonsHolder).set("html",c.html_btn);this.show_browse_button();var b=c.image_upload_location;var a=70;if(this.image_limit){a=this.image_limit}this.Uploader=new SWFUpload({flash_url:"/image/swfupload.swf",upload_url:b,file_size_limit:"202400",file_types:"*.jpg; *.jpeg; *.gif; *.png; *.tif; *.bmp; *.tga",file_types_description:"Image Files",file_upload_limit:a,file_queue_limit:0,file_dialog_start_handler:fileDialogStart,file_queued_handler:fileQueued,file_queue_error_handler:fileQueueError,file_dialog_complete_handler:fileDialogComplete,upload_start_handler:uploadStart,upload_progress_handler:uploadProgress,upload_error_handler:uploadError,upload_success_handler:uploadSuccess,upload_complete_handler:uploadComplete,button_placeholder_id:"upload-button",button_width:117,button_height:117,custom_settings:{progressTarget:this.uploaderDiv,count_of_uploads:1,count_in_queue:0,current_upload_order:0,image_ids:[]},debug:false});this.set_events_browse()},set_events_browse:function(){window.removeEvents("images_queued");window.addEvent("images_queued",function(){this.check_for_embargo();this.pad.options.stage.empty();this.uploaderDiv.removeClass("dn")}.bind(this));window.removeEvents("upload_start");window.addEvent("upload_start",function(){this.hideNav();this.uploaderDiv.removeClass("dn")}.bind(this));window.removeEvents("images_done_uploading");window.addEvent("images_done_uploading",function(a){this.done_browse(a)}.bind(this))},done_browse:function(a){this.uploaderDiv.addClass("dn");this.image_ids=a.image_ids;this.embargo_images();this.uploaded_images=true;this.finished()},check_for_embargo:function(){if($("jsImageEmbargoDate")){this.embargo_date=$("jsImageEmbargoDate").value;this.embargo_time=$("jsImageEmbargoTime").value;clog("date "+this.embargo_date+"  time "+this.embargo_time);if(this.embargo_date.trim()==""){this.embargo_date=false}}this.hideNav()},embargo_images:function(){if(!this.embargo_date){return}new Request.JSON({url:"/image/ajax_post/",method:"post",onSuccess:function(){alert("Images embargoed.")}}).send({method:"embargo_images",ids:this.image_ids,date:this.embargo_date,time:this.embargo_time})},start_myimages:function(b){var a="/image/open_template/";if(b){a+=b+"&tpl=myimages"}this.loading(true);new Request.JSON({url:a,method:"post",onSuccess:this.show_myimages.bind(this)}).send({tpl:"myimages"})},show_myimages:function(a){this.pad.options.stage.innerHTML=a.html;this.selectItems();this.loading(false);this.okButton();$(this.pad.options.stage).getElements(".jsPaginate a").each((function(b){var c=b.href;var d=c.substring(c.indexOf("?"),c.length);b.addEvent("click",(function(f){new Event(f).stop();this.start_myimages(d)}).bind(this))}).bind(this))},start_mygalleries:function(a){url="/image/open_template/";if(a){url+=a+"&tpl=mygalleries"}this.loading(true);new Request.JSON({url:url,method:"post",onSuccess:this.show_mygalleries.bind(this)}).send({tpl:"mygalleries"})},show_mygalleries:function(a){this.pad.options.stage.innerHTML=a.html;this.loading(false);if($(document.body).getElement(".jsCancel")){$(this.pad.options.stage).getElement(".jsCancel").addEvent("click",function(){this.pad.hide()}.bind(this))}var b=$(this.pad.options.stage).getElement(".jsOk");if(!this.gallery_id){b.removeClass("dn")}$(this.pad.options.stage).getElements(".jsPaginate a").each((function(c){var d=c.href;var e=d.substring(d.indexOf("?"),d.length);c.addEvent("click",(function(f){new Event(f).stop();this.start_mygalleries(e)}).bind(this))}).bind(this));$(this.pad.options.stage).getElements(".js-item").each(function(c){id=$(c).getElement("img").getProperty("id");this.image_ids.contains(id)?c.addClass("js-item-selected"):null;c.addEvent("click",function(d){id=$(c).getElement("img").getProperty("id");$(this.pad.options.stage).getElements(".js-item-selected").each(function(e){e.removeClass("js-item-selected")});if(c.hasClass("js-item-selected")){c.removeClass("js-item-selected");this.gallery_id=null;if(this.image_ids.length==0){b.addClass("dn")}}else{c.addClass("js-item-selected");this.gallery_id=id;b.removeClass("dn")}}.bind(this))}.bind(this));b.removeEvents("click");b.addEvent("click",function(){new Request.JSON({url:"/image/ajax_post/",method:"post",onSuccess:this.insert_positioned.bind(this)}).send({method:"get_formated_gallery",gallery_id:this.gallery_id})}.bind(this))},start_search:function(){this.loading(true);new Request.JSON({url:"/image/open_template/",method:"post",onSuccess:this.show_search.bind(this)}).send({tpl:"search"})},show_search:function(b){if($(this.pad.options.stage).getElement(".jsPaginate")){$(this.pad.options.stage).getElement(".jsPaginate").remove()}this.pad.options.stage.innerHTML=b.html;this.selectItems();this.loading(false);this.okButton();if($(this.pad.options.stage).getElements(".jsPaginate a")){if($(this.pad.options.stage).getElement(".jsPaginate")){var d=$(this.pad.options.stage).getElement(".jsPaginate");var c=$(this.pad.options.stage).getElement(".jsHolder");d.inject(c,"after")}$(this.pad.options.stage).getElements(".jsPaginate a").each((function(g){var h=g.href;var i=h.substring(h.indexOf("?"),h.length);g.addEvent("click",(function(j){(new Event(j)).stop();new Request.JSON({url:"/image/ajax_post/"+i,method:"post",onSuccess:this.show_search.bind(this)}).send({method:"search_gallery_results",content_type_id:this.search_content_type_id,object_id:this.search_object_id})}).bind(this))}).bind(this))}var f="js-search-galleries";var a="fireAcSelected";var e=new VinesSearchAC.WithSubMenus(f,"/autosearch/",{ignore_no_image:true,url2:"/image/process-gallery-search/",callBackEvent:a});$(f).addEvent(a,function(g,h){e.destroy();this.loading(true);this.search_content_type_id=g.content_type_id;this.search_object_id=g.object_id;new Request.JSON({url:"/image/ajax_post/",method:"post",onSuccess:this.show_search.bind(this)}).send({method:"search_gallery_results",content_type_id:g.content_type_id,object_id:g.object_id})}.bind(this))},start_flickr:function(b){this.loading(true);if(!b){b=false}var a=new VinesAjax("/image/flickr/",{method:"POST",data:b,onFailure:function(){alert("Sorry, there was an error.")}.bind(this),onComplete:function(c){this.show_flickr(c)}.bind(this)}).request()},show_flickr:function(a){a=JSON.decode(a);this.pad.options.stage.innerHTML=a.html;this.selectItems();this.loading(false);this.okButton();$("jsImagesFlickrForm").addEvent("submit",(function(d){(new Event(d)).stop();var c=$("jsImagesFlickrForm").toQueryString();this.start_flickr(c)}).bind(this));$("jsImagesFlickrFormSubmit").addEvent("click",(function(d){(new Event(d)).stop();var c=$("jsImagesFlickrForm").toQueryString();this.start_flickr(c)}).bind(this));var b=$(this.pad.options.stage).getElement(".jsOk");b.removeEvents("click");b.addEvent("click",function(){this.loading(true);var c="";$each(this.image_ids,function(f,e){c+=f+","});var d=new VinesAjax("/image/flickr-process/?ids="+c,{method:"GET",onFailure:function(){alert("Sorry, there was an error.");this.loading(false)}.bind(this),onComplete:function(e){this.loading(false);var e=JSON.decode(e);this.done_flickr(e)}.bind(this)}).request()}.bind(this))},done_flickr:function(a){this.image_ids=a.image_ids;this.finished()}});ImagePanel.implement(new Events);ImagePanel.implement(new Options);
