function createCookie(C,D,E){if(E){var B=new Date();B.setTime(B.getTime()+(E*24*60*60*1000));var A="; expires="+B.toGMTString()}else{var A=""}document.cookie=C+"="+D+A+"; path=/; domain= .photobucket.com"}function readCookie(B){var D=B+"=";var A=document.cookie.split(";");for(var C=0;C<A.length;C++){var E=A[C];while(E.charAt(0)==" "){E=E.substring(1,E.length)}if(E.indexOf(D)==0){return E.substring(D.length,E.length)}}return null}var PBLayeredPanel=Class.create({initialize:function(B,A){this.width=A;this.elemId=B;this.elem=$(this.elemId);if(photobucket.browser.isIE){this.appendIframe()}},appendIframe:function(){var A=document.createElement("iframe");A.setAttribute("src","/include/iframe.html");A.className="PBLayeredPanelIFrame";var B=this.getOffsetDimensions();width=(this.width)?this.width:B.width-1;A.setAttribute("width",width);A.setAttribute("height",B.height-1);A.setAttribute("frameBorder",0);A.setAttribute("marginWidth",0);A.setAttribute("marginHeight",0);A.setAttribute("scrolling","no");A.setAttribute("allowtransparency","true");Element.insert(this.elem,{top:A});this.elem.addClassName("withIframe")},getOffsetDimensions:function(){var B=this.elem.style;var E=B.visibility;var C=B.position;var A=B.display;B.visibility="hidden";B.position="absolute";B.display="block";var F=this.elem.offsetWidth;var D=this.elem.offsetHeight;B.display=A;B.position=C;B.visibility=E;return{width:F,height:D}}});var Bubble=Class.create(PBLayeredPanel,{pbType:"Bubble",initialize:function($super,A){$super(A.elemId);this.id=A.elemId||null;this.targetId=A.targetId||null;this.targetElem=$(this.targetId);this.posOffset=A.posOffset||null;this.eventOn=A.eventOn||null;this.eventOff=A.eventOff||null;this.callbackOn=A.callbackOn||null;this.callbackOff=A.callbackOff||null;this.callbackClose=A.callbackClose||null;this.offsetX=A.offsetX||0;this.offsetY=A.offsetY||0;if(this.eventOn){Event.observe(this.targetElem,this.eventOn,this.handleBubbleShow.bindAsEventListener(this),false)}if(this.eventOff){Event.observe(this.targetElem,this.eventOff,this.handleBubbleHide.bindAsEventListener(this),false)}var B;if((B=$$("#"+this.elemId+" .closebox"))!=null){B=B[0];Event.observe(B,"click",this.handleCloseLink.bindAsEventListener(this),false)}this.setPosition()},handleBubbleShow:function(C){var B=this.getEventLink(C);var A=true;if(B&&typeof (B.tagName)!="undefined"&&B.tagName=="A"){A=false}if(typeof (this.callbackOn)!="function"||this.callbackOn(C)){this.setPosition();Element.show(this.elem)}return A},handleBubbleHide:function(C){var B=this.getEventLink(C);var A=true;if(B&&typeof (B.tagName)!="undefined"&&B.tagName=="A"){A=false}if(typeof (this.callbackOff)!="function"||this.callbackOff(C)){Element.hide(this.elem)}return A},handleCloseLink:function(A){if(typeof (this.callbackClose)!="function"||this.callbackClose()){Element.hide(this.elem)}return false},show:function(){return this.handleBubbleShow(null)},hide:function(){return this.handleBubbleHide(null)},close:function(){return this.handleCloseLink(null)},getEventLink:function(A){return(A&&A.type=="click")?Event.findElement(A,"A"):null},setPosition:function(){if(!Element.visible(this.elem)){if(this.posOffset){var C=Element.positionedOffset(this.targetElem)}else{var C=Element.cumulativeOffset(this.targetElem)}var B=this.elem.style;var A=B.visibility;B.visibility="hidden";Element.show(this.elem);B.left=C.left-this.elem.offsetWidth+this.offsetX+"px";B.top=C.top+this.offsetY+"px";B.visibility=A;Element.hide(this.elem)}}});var BubbleController=Class.create({initialize:function(){this.bubbles={};this.currentBubble=null;for(var A=0;A<arguments.length;A++){this.addBubble(arguments[A])}},addBubble:function(A){if(A.pbType&&A.pbType=="Bubble"){this.bubbles[A.id]=A}},close:function(B){var A=this.bubbles[B];if(typeof (A)!="undefined"){this.closeBubble(A)}},hide:function(B){var A=this.bubbles[B];if(typeof (A)!="undefined"){this.hideBubble(A)}},show:function(B){var A=this.bubbles[B];if(typeof (A)!="undefined"){this.showBubble(A)}},getBubbleByTargetId:function(D){var B=null;for(var C in this.bubbles){var A=this.bubbles[C];if(A.targetId==D){B=A;break}}return B},getBubbleByElementId:function(D){var B=null;for(var C in this.bubbles){var A=this.bubbles[C];if(A.elemId==D){B=A;break}}return B},showBubble:function(A){if(this.currentBubble&&this.currentBubble!==A){this.currentBubble.hide()}if(A){A.show()}this.currentBubble=A},hideBubble:function(A){if(A){A.hide()}if(A===this.currentBubble){this.currentBubble=null}},closeBubble:function(A){if(A){A.close()}if(A===this.currentBubble){this.currentBubble=null}}});var PBUpload=Class.create({initialize:function(A){this.linkWhiteList={swfuploadCancelButtonId:1,linkErrorPanelClose:1,bttnCopy_album:1,bttnUpload_web:1};this.uploadVersionCookie="upload_version";this.panels={};this.config=A;if(!this.config){this.config={}}if(typeof (this.config.validImageFiles)!="undefined"){this.config.validImageFiles=this.config.validImageFiles.split(",")}if(typeof (this.config.validVideoFiles)!="undefined"){this.config.validVideoFiles=this.config.validVideoFiles.split(",")}for(var B in this.config){this[B]=this.config[B]}this.menu=new PBUploadMenu();this.bubbles=new PBUploadBubbles();this.boundBlockClickHander=this.blockClickHandler.bindAsEventListener(this);Event.observe(document,PBUpload.MESSAGE.UPLOAD_STARTED,this.uploadStartedHandler.bindAsEventListener(this),false);Event.observe(document,PBUpload.MESSAGE.QUEUE_COMPLETE,this.queueCompleteHandler.bindAsEventListener(this),false);Event.observe(document,PBUpload.MESSAGE.UPLOAD_CANCELED,this.queueCompleteHandler.bindAsEventListener(this),false);Event.observe(document,PBUpload.MESSAGE.ERROR,this.printErrorMessage.bindAsEventListener(this),false);Event.observe(document,PBUpload.MESSAGE.CLEAR_ERROR,this.clearErrorMessage.bindAsEventListener(this),false);Event.observe(document,PBUpload.MESSAGE.DOWNGRADE,this.downgradeHandler.bindAsEventListener(this),false);Event.observe(document,PBUpload.MESSAGE.OPTIONS_UPDATED,this.handleImageDimsUpdate.bindAsEventListener(this),false);Event.observe(document,PBUploader.MESSAGE.AFTER_SUBMIT,this.uploadStartedHandler.bindAsEventListener(this))},handleImageDimsUpdate:function(D){var C=null;if(typeof (D.memo)!="undefined"&&typeof (D.memo.currentOptionValue)!="undefined"){C=D.memo.currentOptionValue}var B=$("image_size_Local","image_size_Web");for(var A=0;C&&B&&A<B.length;A++){this.setSelectedImageSizeOption(B[A],C)}document.fire(PBUpload.MESSAGE.CLOSE_OPTIONS_PANEL)},uploadStartedHandler:function(A){this.startBlocking()},queueCompleteHandler:function(A){this.stopBlocking()},blockClickHandler:function(E){var C=Event.element(E);var D=Event.findElement(E,"A");if(!(C.id in this.linkWhiteList)){var A=C.tagName.toUpperCase();if(A=="IMG"||A=="A"||C.type=="button"||(D&&D.tagName=="A")){var B=confirm("Clicking on this could interrupt your upload.\n\nAre you sure you want to do this?");if(!B){Event.stop(E);this.stopBlocking();return false}}}},handleSuppressReturn:function(A){if(A.keyCode==Event.KEY_RETURN){Event.stop(A)}return true},printErrorMessage:function(A){if(typeof (controllerMessagePanel)!="undefined"){controllerMessagePanel.printMessage({message:A.memo.message,details:A.memo.details,type:MessagePanelController.MSSG_TYPE_ERROR})}},clearErrorMessage:function(){if(typeof (controllerMessagePanel)!="undefined"){controllerMessagePanel.clearMessage()}},downgradeHandler:function(A){v=(A.memo&&A.memo.noFlash)?0:1;createCookie(this.uploadVersionCookie,v,90);var B=window.location.href.replace(/\?first=1/,"");window.location.replace(B)},addPanel:function(C,A){for(var B in this.config){A[B]=this.config[B]}this.panels[C]=A;if(typeof A.onAdded=="function"){A.onAdded()}},startBlocking:function(){Event.observe(document,"click",this.boundBlockClickHander,true);this.menu.locked=true},stopBlocking:function(){Event.stopObserving(document,"click",this.boundBlockClickHander,true);this.menu.locked=false},setSelectedImageSizeOption:function(D,A){var C=$A(D.options).toArray();D.options[D.selectedIndex].selected=false;for(var B=0;B<D.options.length;B++){var E=D.options[B].text.toString();if(E.indexOf(A)>-1){D.options[B].selected=true;break}}}});PBUpload=Object.extend(PBUpload,{MESSAGE:{DOWNGRADE:"pb:Downgrade",ERROR:"pb:Error",CLEAR_ERROR:"pb:ClearError",UPLOAD_DIALOG_OPEN:"pb:UploadDialogOpen",UPLOAD_STARTED:"pb:UploadStarted",UPLOAD_CHANGE:"pb:UploadChange",UPLOAD_COMPLETE:"pb:UploadComplete",UPLOAD_CANCELED:"pb:UploadCanceled",ENCODING_CHANGE:"pb:EncodingChange",QUEUE_COMPLETE:"pb:QueueComplete",OPTIONS_UPDATED:"pb:OptionsUpdated",CLOSE_OPTIONS_PANEL:"pb:CloseOptionsPanel",OPEN_OPTIONS_PANEL:"pb:OpenOptionsPanel",MENU_ITEM_CLICKED:"pb:MenuItemClicked",THUMBNAIL_LOADED:"pb:ThumbnailLoaded"}});var PBUploadBubbles=Class.create({initialize:function(){this.bubbleCookie="pbuBbbl";this.cookieLifespan=90;this.cookieValDelimeter="|";this.closedBubbles=this.getClosedBubbles();this.initialBubble=null;this.controller=new BubbleController();this.localUploadBubbleElemId="bubbleLocalUploadHelp";Event.observe(document,PBUpload.MESSAGE.MENU_ITEM_CLICKED,this.onMenuItemClicked.bindAsEventListener(this),false);Event.observe(document,"dom:loaded",this.onDOMLoadHandler.bindAsEventListener(this));Event.observe(document,PBUpload.MESSAGE.UPLOAD_DIALOG_OPEN,this.uploadDialogOpenHandler.bindAsEventListener(this),false)},onDOMLoadHandler:function(A){if(this.initialBubble){this.controller.show(this.initialBubble.id)}},onMenuItemClicked:function(B){if(this.controller.currentBubble){this.controller.hide(this.controller.currentBubble.id)}var A=this.controller.getBubbleByElementId(this.getBubbleElementId(B.memo.menuItemIndex));if(A){this.controller.show(A.id)}},setOpen:function(){var A=this.self.controller.getBubbleByElementId(this.elemId);if(this.self.closedBubbles[A.id]){return false}else{return true}},setClosed:function(){var A=this.self.controller.getBubbleByElementId(this.elemId);return this.self.close(A.id)},uploadDialogOpenHandler:function(){var A=this.controller.getBubbleByElementId(this.localUploadBubbleElemId);this.controller.close(A.id)},addBubble:function(G,D,C,F,A,H,E){var B=new Bubble({elemId:G,targetId:D,eventOn:"click",callbackOn:(C)?this.setOpen.bind({self:this,elemId:G}):null,callbackClose:(F)?this.setClosed.bind({self:this,elemId:G}):null,offsetX:A,offsetY:H});this.controller.addBubble(B);if(E){this.initialBubble=B}},close:function(A){this.closedBubbles[A]=true;this.setClosedBubbleCookie(A);return true},setClosedBubbleCookie:function(B){var A=readCookie(this.bubbleCookie);if(A&&A.indexOf(B)==-1){A+=this.cookieValDelimeter+B}else{if(!A||A==""){A=B}}createCookie(this.bubbleCookie,A,this.cookieLifespan)},getClosedBubbles:function(){var B={};var D;if(D=readCookie(this.bubbleCookie)){var A=D.split(this.cookieValDelimeter);for(var C=0;C<A.length;C++){B[A[C]]=true}}return B},getBubbleElementId:function(A){return"bubble"+A+"UploadHelp"}});var PBUploadMenu=Class.create({initialize:function(){this.activeUploadPanel=null;this.listPanels=(new Array()).toArray();this.listTabs=(new Array()).toArray();this.locked=false;Event.observe(document,PBUpload.MESSAGE.OPEN_OPTIONS_PANEL,this.moreOptionsHandler.bindAsEventListener(this),false);Event.observe(document,PBUpload.MESSAGE.CLOSE_OPTIONS_PANEL,this.hideMoreOptionsHandler.bindAsEventListener(this),false)},handleUploadMenuItemClick:function(D){if(this.locked){return false}var B=Event.findElement(D,"LI");var A=this.getIdSuffix(B.id);var C;if(A&&!Element.hasClassName(B,"current")&&(C=$("panelUploader_"+A))!=null){this.resetTabsAndPanels();Element.addClassName(B,"current");Element.show(C);this.activeUploadPanel=C;document.fire(PBUpload.MESSAGE.MENU_ITEM_CLICKED,{menuItemIndex:A})}return true},moreOptionsHandler:function(A){APIRequest.track("UPLOAD_MORE_OPTIONS");var C,B;if((C=$("panelUploader_Options"))!=null&&(B=$("groupUploadPanels"))!=null){document.fire(PBUpload.MESSAGE.MENU_ITEM_CLICKED,{menuItemIndex:""});Element.hide(B);Element.show(C)}},hideMoreOptionsHandler:function(B){var D,C;if((D=$("panelUploader_Options"))!=null&&(C=$("groupUploadPanels"))!=null){var A;Element.show(C);Element.hide(D);if(this.activeUploadPanel&&(A=this.getIdSuffix(this.activeUploadPanel.id))!=null){document.fire(PBUpload.MESSAGE.MENU_ITEM_CLICKED,{menuItemIndex:A})}}},addItem:function(C,B){var A=$(C);var D=$(B);if(A!=null&&D!=null){this.listTabs[this.listTabs.length]=D;this.listPanels[this.listPanels.length]=A;Event.observe(D,"click",this.handleUploadMenuItemClick.bindAsEventListener(this),false);if(Element.visible(A)){this.activeUploadPanel=A}}},getIdSuffix:function(B){var A=null;B=B.split("_");if(B.length>=2){A=B[1]}return A},resetTabsAndPanels:function(){var A;for(A=0;A<this.listTabs.length;A++){if(Element.hasClassName(this.listTabs[A],"current")){Element.removeClassName(this.listTabs[A],"current")}}for(A=0;A<this.listPanels.length;A++){if(Element.visible(this.listPanels[A])){Element.hide(this.listPanels[A])}}}});var PBUploadPanel=Class.create({initialize:function(A){this.id="PBUploadPanel";this.progressPanelId="panelUploader_Progress";this.bUserPremium=false;this.validImageFiles=new Array();this.formId="";this.formCompleteId="";this.uploader=null;this.uploadStrategy=null;for(var B in A){this[B]=A[B]}Event.observe(document,PBUploader.MESSAGE.AFTER_SUBMIT,this.onAfterSubmit.bindAsEventListener(this),false);Event.observe(document,PBUploader.MESSAGE.BEFORE_UPLOAD_COMPLETE,this.onBeforeUploadComplete.bindAsEventListener(this),false);Event.observe(document,PBUpload.MESSAGE.UPLOAD_CANCELED,this.onUploadCanceled.bindAsEventListener(this),false)},onAfterSubmit:function(A){try{var C=A.memo.id;if(C==this.id){this.afterSubmit();uploadController.panels.progress.id=this.id;this.toggleProgressUI(true)}}catch(B){}},onBeforeUploadComplete:function(A){try{var D=A.memo.id;var B=A.memo.form;if(D==this.id){this.beforeUploadCompleteSubmit(B)}}catch(C){}},onUploadCanceled:function(A){try{var C=A.memo;if(C==this.id){this.toggleProgressUI(false)}}catch(B){}},onAdded:function(){switch(this.uploadStrategy){case PBUploadPanel.UPLOAD_STRATEGY.SWFUPLOADER:this.upload=null;break;default:var A={id:this.id,formId:this.formId,formCompleteId:this.formCompleteId};this.upload=new SerialUploader(A);break}},afterSubmit:function(){},beforeUploadCompleteSubmit:function(A){},toggleProgressUI:function(A){if(A){Element.hide($(this.id));Element.show($(this.progressPanelId))}else{Element.show($(this.id));Element.hide($(this.progressPanelId))}}});PBUploadPanel=Object.extend(PBUploadPanel,{UPLOAD_STRATEGY:{SERIAL:0,SWFUPLOADER:1}});var PBUploadPanelAlbum=Class.create(PBUploadPanel,{fetchLimit:50,preloadCount:20,fetchTriggerPoint:40,totalFileCount:0,initialize:function($super,A){$super(A);this.formCompleteId="frmUploadAlbumComplete";this.imageContainerId="albumImageContainer";this.disabledClass="button_disabled";this.uploadButtonId="bttnCopy_album";this.menuOptionId="tabUpload_Album";this.id="panelUploader_Album";this.progressContainerId="progressContainer";this.fetchingMessageIdPrefix="fetching_";this.messageElem=null;this.selectedAlbumId=null;this.fetcher=new PBAlbumMediaFetcher({limit:this.fetchLimit});this.fileCounter=0;this.selectionCounter=0;Event.observe(document,PBUpload.MESSAGE.THUMBNAIL_LOADED,this.onThumbnailLoaded.bindAsEventListener(this),false);Event.observe(document,PBFetcher.MESSAGE.FETCH_STARTED,this.handleFetchStarted.bindAsEventListener(this),false);Event.observe(document,PBFetcher.MESSAGE.FETCH_COMPLETE,this.handleFetchCompleted.bindAsEventListener(this),false)},onAdded:function($super){$super();this.uploadButton=$(this.uploadButtonId);this.firstDisplay=this.handleFirstDisplay.bindAsEventListener(this);Event.observe(document,PBUpload.MESSAGE.MENU_ITEM_CLICKED,this.firstDisplay,false)},handleFirstDisplay:function(A){if(A.memo.menuItemIndex=="Album"){Event.stopObserving(document,PBUpload.MESSAGE.MENU_ITEM_CLICKED,this.firstDisplay,false);this.switchAlbum()}},select:function(B,C){Event.stop(B);this.selectionCounter++;var A=this.generateFile(C,this.selectionCounter);A.select();this.upload.add(C,A);this.enableUpload();return false},remove:function(B,C){var A=this.upload.get(C);A.deselect();this.selectionCounter--;this.upload.remove(C);Event.stop(B);if(this.upload.isEmpty()){this.disableUpload()}return false},switchAlbum:function(A){this.fetch();var B=this.getSelectedAlbum();var C=B.value;if(this.selectedAlbumId!=null){$(this.selectedAlbumId).hide()}$(C).show();this.selectedAlbumId=C},onThumbnailLoaded:function(A){var B=A.memo;if(!B.wasPreloaded&&B.count==this.fetchTriggerPoint&&this.fileCounter<this.totalFileCount){this.fetch()}B=null},onUploadCanceled:function($super,A){$super(A);this.selectionCounter=0},handleFetchStarted:function(A){var B=A.memo.custom.targetId;var C=$(B);if(C){this.removeMessage();this.messageElem=document.createElement("div");this.messageElem.setAttribute("id",this.fetchingMessageIdPrefix+B);this.messageElem.className="fetching";var D=document.createTextNode("loading images...");this.messageElem.appendChild(D);C.appendChild(this.messageElem)}},handleFetchCompleted:function(H){var I=H.memo.requestOptions;var D=H.memo.response;if(!D.media){return }var A=D.media.toArray();this.removeMessage();var C=$(I.targetId);var F=C.innerHTML;for(var E=0;E<A.length;E++){F+=this.createImageHTML(A[E])}C.innerHTML=F;var G=0;for(var E=0;E<A.length;E++){var B=A[E];B.count=++G;this.add(B)}},enableUpload:function(){Element.removeClassName(this.uploadButton,this.disabledClass)},disableUpload:function(){Element.addClassName(this.uploadButton,this.disabledClass)},fetch:function(){this.fetcher.fetch({selectedAlbum:this.getSelectedAlbum()})},createImageHTML:function(A){var C=A.name;var B='<a id="'+C+'" media="'+A.type+'" style="display:none" class="imageSelector" ';B+=' href="'+A.mURL+'" title="'+A.tURL+'" ';B+=" onclick=\"return uploadController.panels.album.select(event,'"+C+"');\"> ";B+='<img id="'+C+'_image" src="http://pic.photobucket.com/spacer.gif"/>';B+='<div id="'+C+'_temp" class="temp"></div>';B+='<div id="'+C+'_remove" class="remove" onclick="uploadController.panels.album.remove(event,\''+C+"');\"></div>";B+='<div id="'+C+'_add" class="add"></div>';B+="</a>";return B},add:function(A){this.fileCounter++;var C={id:A.name,url:A.mURL,thumb:A.tURL,count:A.count,validExtArray:this.validImageFiles,album:this.album,groupHash:this.groupHash};var B=new PBAlbumFile(C);if(A.count<=this.preloadCount){B.wasPreloaded=true;B.load();B=null}else{B.pollVisibility(this.imageContainerId)}},generateFile:function(E,D){var C=$(E);var A={id:E,url:C.href,thumb:C.title,count:D,validExtArray:this.validImageFiles,album:this.album,groupHash:this.groupHash,media:C.attributes.media.value};var B=new PBAlbumFile(A);return B},beforeUploadCompleteSubmit:function(A){try{this.upload.addCompletionInput(A,"skiptagging","1")}catch(B){return false}return true},getSelectedAlbum:function(){var A=$("albumSelector");return A.options[A.selectedIndex]},removeMessage:function(){if(this.messageElem){Element.remove(this.messageElem);this.messageElem=null}}});var PBUploadPanelComputer=Class.create({initialize:function(A){this.id="panelUploader_Local";this.videoThreshold=3000000;this.videoSponsor="",this.videoBanner=false,this.videoPlaying=false;this.videoWidth=300;this.videoHeight=250;this.swfVersion="1.0.0";this.videoMinFlashVersion="9.0.0";this.videoDivId="swfuploadMovieId";this.containerId="swfuploadContainer";this.moreOptionsLinkId="moreUploadOptions_Local";this.msgOptionsLinkId="linkUploadOptions_statusmessage";this.downgradeLinkId="oldUploaderLinkId";this.progressPanelId="panelUploader_Progress";this.adId="panelAdv";this.sponsorVideoId="sponsoredVideo";this.uploadLimit=50;this.authCookie="pbauth";this.guestCookie="pbguest";this.validImageFiles=new Array();this.validVideoFiles=new Array();this.bUserPremium=false;this.groupHash=null;for(var B in A){this[B]=A[B]}if($(this.moreOptionsLinkId)){Event.observe(this.moreOptionsLinkId,"click",this.moreOptionsHandler.bindAsEventListener(this),false)}if($(this.msgOptionsLinkId)){Event.observe(this.msgOptionsLinkId,"click",this.moreOptionsHandler.bindAsEventListener(this),false)}Event.observe(this.downgradeLinkId,"click",this.downgradeHandler.bindAsEventListener(this),false);Event.observe(document,PBUpload.MESSAGE.QUEUE_COMPLETE,this.uploadCompleteHandler.bindAsEventListener(this),false);Event.observe(document,PBUpload.MESSAGE.UPLOAD_STARTED,this.uploadStartedHandler.bindAsEventListener(this),false)},uploadStartedHandler:function(A){try{var B=false;for(var D in A.memo.files){if(A.memo.files[D].isVideo){B=true;break}}uploadController.panels.progress.id=this.id;this.toggleUploadUI(true,B);if(this.videoSponsor!=""&&A.memo.totalUploadSize>this.videoThreshold){this.startSponsorVideo()}}catch(C){}},uploadCompleteHandler:function(A){var B=A.memo;if(this.id==B){this.toggleUploadUI(false)}},moreOptionsHandler:function(){document.fire(PBUpload.MESSAGE.OPEN_OPTIONS_PANEL)},downgradeHandler:function(){if(typeof (window.event)!="undefined"){window.event.returnValue=false}document.fire(PBUpload.MESSAGE.DOWNGRADE)},onAdded:function(){var A=new SWFUpload(this.getSwfConfig());A.registerHandlers()},getSwfConfig:function(){var B=[this.validImageFiles,this.validVideoFiles];var A={upload_url:this.getUploadURL(),flash_url:"/include/swf/uploader/flash9/PBUpload.swf?v="+encodeURIComponent(this.swfVersion),file_size_limit:"100 MB",file_types_description:"Image and Video Files",file_upload_limit:this.uploadLimit,file_queue_limit:this.uploadLimit,file_types:"*."+B.flatten().compact().join(";*."),video_file_types:"*."+this.validVideoFiles.flatten().compact().join(";*."),custom_settings:{auth:decodeURIComponent(readCookie(this.authCookie)),guest:decodeURIComponent(readCookie(this.guestCookie)),selectButtonId:"swfuploadSelectButtonId",validVideoFiles:this.validVideoFiles,bPremiumUser:this.bUserPremium,videoMaxLength:(this.bUserPremium)?10:5,parentId:this.containerId,groupHash:this.groupHash},debug:(location.search.indexOf("debug=true")>0)};return A},getUploadURL:function(){var A=document.location.href;if(photobucket.browser.isSafari){A=encodeURI(A)}return A},startSponsorVideo:function(){var C=$(this.sponsorVideoId);if(C&&!this.videoPlaying){var A=new SWFObject(this.videoSponsor,this.sponsorVideoId+"Obj",this.videoWidth,this.videoHeight,this.videoMinFlashVersion);A.useExpressInstall("/flash/playerProductInstall.swf");A.addParam("quality","high");A.addParam("menu","false");A.addParam("wmode","transparent");A.addParam("allowScriptAccess","always");if(A.write(C)){this.videoPlaying=true;$(this.adId).hide();C.show();if(this.videoBanner){var B=document.createElement("iframe");B.src=this.videoBanner;B.setAttribute("width","300");B.setAttribute("height","25");B.setAttribute("marginWidth","0");B.setAttribute("marginHeight","0");B.setAttribute("frameBorder","0");B.setAttribute("scrolling","no");Element.insert(C,{top:B})}APIRequest.track("SPONSOR_VIDEO_STARTED")}}},toggleUploadUI:function(B,A){if(B){Element.hide($(this.id));Element.show($(this.progressPanelId));if(A){$(this.videoDivId).style.display="block"}}else{Element.show($(this.id));Element.hide($(this.progressPanelId))}}});var PBUploadPanelWeb=Class.create(PBUploadPanel,{webInputCount:3,webInputMax:20,strDefaultWebFileText:"paste web URL here",initialize:function($super,A){$super(A);this.classInitWebFileInput="noFileWeb";this.formId="frmUploadWeb";this.formCompleteId="frmUploadWebComplete";this.moreOptionsLinkId="moreUploadOptions_Web";this.imageSizeFieldName="image_size";this.id="panelUploader_Web";if($(this.moreOptionsLinkId)){Event.observe(this.moreOptionsLinkId,"click",this.moreOptionsHandler.bindAsEventListener(this),false)}},handleAddMoreInputs:function(B){for(var A=this.webInputCount;A<this.webInputMax;A++){$("text_web_"+A).show()}$("linkAddMore_web").hide();$("linkRemoveMore_web").show();$(this.id).addClassName("autoHeight")},handleRemoveMoreInputs:function(B){for(var A=this.webInputCount;A<this.webInputMax;A++){$("text_web_"+A).hide()}$("linkAddMore_web").show();$("linkRemoveMore_web").hide();$(this.id).removeClassName("autoHeight")},handleWebFileInputFocus:function(B){var A=Event.element(B);if(A!=null){if(A.value==this.strDefaultWebFileText){A.value="";Element.removeClassName(A,this.classInitWebFileInput)}}return true},handleFileInputChange:function(E){var B=Event.element(E);var D=$(this.formId);var A={validExtArray:this.validImageFiles,id:B.value,url:B.value,album:D.album.value,groupHash:this.groupHash};var C=new PBWeb(A);C.validate(this.bUserPremium);if(C.hasInvalidProtocol){document.fire(PBUpload.MESSAGE.ERROR,{message:"Upload Error",details:C.protocolErrorMessage});this.resetWebInput(B);return false}else{if(C.hasInvalidExtension){document.fire(PBUpload.MESSAGE.ERROR,{message:"Upload Error",details:C.fileTypeErrorMessage});this.resetWebInput(B);return false}}this.upload.add(B.id,C);document.body.fire(PBUpload.MESSAGE.CLEAR_ERROR);return true},moreOptionsHandler:function(){document.fire(PBUpload.MESSAGE.OPEN_OPTIONS_PANEL)},onUploadCanceled:function($super,A){$super(A);for(var B=0;B<this.webInputMax;B++){this.resetWebInput($("text_web_"+B))}},afterSubmit:function($super){if(this.upload.isEmpty()){document.fire(PBUploadMessages.ERROR,{message:"Attention",details:"Please select a url to upload."})}else{$super()}},beforeUploadCompleteSubmit:function(A){try{var C;if((C=this.getResizeValue($(this.formId)))!=null){this.upload.addCompletionInput(A,"resize",C)}}catch(B){return false}return true},resetWebInput:function(A){Element.addClassName(A,this.classInitWebFileInput);A.value=this.strDefaultWebFileText},getResizeValue:function(C){var B=C[this.imageSizeFieldName];var A=B.options[B.selectedIndex];var D=null;if(!A.defaultSelected){D=A.value}return D}});var PBUploadPanelOptions=Class.create({initialize:function(){var A;if((A=$("bttnSaveOptions1"))!=null){Event.observe(A,"click",this.handleSaveOptionsPanel.bindAsEventListener(this),false)}if((A=$("bttnSaveOptions2"))!=null){Event.observe(A,"click",this.handleSaveOptionsPanel.bindAsEventListener(this),false)}if((A=$("bttnCancelOptions1"))!=null){Event.observe(A,"click",this.handleCloseOptionsPanel.bindAsEventListener(this),false)}if((A=$("bttnCancelOptions2"))!=null){Event.observe(A,"click",this.handleCloseOptionsPanel.bindAsEventListener(this),false)}},handleCloseOptionsPanel:function(A){document.fire(PBUpload.MESSAGE.CLOSE_OPTIONS_PANEL);return true},handleSaveOptionsPanel:function(I){this.toggleButtonState("bttnCancelOptions1",true);this.toggleButtonState("bttnCancelOptions2",true);this.toggleButtonState("bttnSaveOptions1",true);this.toggleButtonState("bttnSaveOptions2",true);var J=Form.getElements("form_upload_options");var G=null;for(i=0;J&&i<J.length;i++){if(J[i]!=null&&J[i].name=="image_size"&&J[i].checked==true){G=J[i]}}var F=$("auto_tagging");var D=0;if(F&&F.checked==true){D=1}var A=$("scramble_filename");var C=new Date();var B=null;if(A.checked){C.setTime(C.getTime()+(90*24*60*60*1000));B="expires="+C.toGMTString();document.cookie="scramble_filename = true; "+B+"; domain=.photobucket.com; path=/"}else{C.setTime(C.getTime()-(90*24*60*60*1000));B="expires="+C.toGMTString();document.cookie="scramble_filename = false; "+B+"; domain=.photobucket.com; path=/"}if(G!=null){var E={default_image_size:G.value,auto_tagging:D};var H=$("group_hash_value");if(H){E.group_hash_value=H.value}new APIRequest("setuploadoptions",false,E,this.handleSuccessSaveOptions.bind(this),this.handleFailureSaveOptions.bind(this))}},handleSuccessSaveOptions:function(B){if(B.stat=="ok"){this.toggleButtonState("bttnCancelOptions1",false);this.toggleButtonState("bttnCancelOptions2",false);this.toggleButtonState("bttnSaveOptions1",false);this.toggleButtonState("bttnSaveOptions2",false);var A=Form.getElements("form_upload_options");var D=null;var C=null;for(i=0;A&&i<A.length;i++){if(A[i].name=="image_size"){D=Element.up(A[i],"td");if(D){if(A[i].checked==true){Element.addClassName(D,"checked");Element.removeClassName(D,"unchecked");C=A[i]}else{Element.addClassName(D,"unchecked");Element.removeClassName(D,"checked")}}}}document.fire(PBUpload.MESSAGE.OPTIONS_UPDATED,{currentOptionValue:C.value})}},handleFailureSaveOptions:function(A){var B=error.msg;alert("Error saving options: "+B);this.toggleButtonState("bttnCancelOptions1",false);this.toggleButtonState("bttnCancelOptions2",false);this.toggleButtonState("bttnSaveOptions1",false);this.toggleButtonState("bttnSaveOptions2",false);document.fire(PBUpload.MESSAGE.CLOSE_OPTIONS_PANEL)},toggleButtonState:function(C,B){var A;if(C&&(A=$(C))!=null){A.disabled=B;if(B){if(!Element.hasClassName(A,"button_disabled")){Element.addClassName(A,"button_disabled")}if(C.indexOf("Save")>-1){A.value="Saving"}}else{if(Element.hasClassName(A,"button_disabled")){Element.removeClassName(A,"button_disabled")}if(C.indexOf("Save")>-1){A.value="Save"}}}}});var PBUploadPanelProgress=Class.create({initialize:function(A){this.cancelButtonId=A.cancelId;this.id="";this.progressBarMaxWidth=168;this.progressPercentElem=null;this.progressBarElem=null;this.progressFilesElem=null;this.progressContainerId="totalProgress";this.progressBarId="totalProgressBar";this.progressPercentId="totalProgressPercent";Event.observe(this.cancelButtonId,"click",this.cancelQueueHandler.bindAsEventListener(this),false);Event.observe(document,PBUploadPanelProgress.MESSAGE.TOTAL_PROGRESS_UPDATE,this.uploadTotalProgress.bindAsEventListener(this))},cancelQueueHandler:function(A){document.fire(PBUpload.MESSAGE.UPLOAD_CANCELED,this.id);document.fire(PBUpload.MESSAGE.QUEUE_COMPLETE,this.id)},uploadTotalProgress:function(A){var D=(isNaN(A.memo))?0:A.memo;var C=Math.ceil(D*100);var B=Math.ceil(D*this.progressBarMaxWidth);if(!this.progressPercentElem){this.progressPercentElem=$(this.progressPercentId)}if(this.progressPercentElem){this.progressPercentElem.innerHTML=C}if(!this.progressBarElem){this.progressBarElem=$(this.progressBarId)}if(this.progressBarElem){this.progressBarElem.style.width=B+"px"}}});PBUploadPanelProgress=Object.extend(PBUploadPanelProgress,{MESSAGE:{TOTAL_PROGRESS_UPDATE:"PBUploadPanelProgress:TOTAL_PROGRESS_UPDATE"}});var PBProgressBar=Class.create({pbType:"PBProgress",initialize:function(A){this.progressContainerId="fsUploadProgress";this.progressTextIdPrefix="progressName";this.progressBarIdPrefix="progressBar";this.progressBarMaxWidth=0;this.progressBarElem=null;this.progressTextElem=null;this.id="";for(var B in A){this[B]=A[B]}this.addUIComponent();this.setText(this.id,this.count,0)},update:function(B){if(this.progressBarMaxWidth==0){this.progressBarMaxWidth=$(this.progressContainerId).offsetWidth}var A=Math.ceil(B*this.progressBarMaxWidth);this.progressBarElem.style.width=A+"px"},setText:function(C,B,A){if(A){C+=" ("+B+" of "+A+")"}this.progressTextElem.innerHTML=C},hide:function(){Effect.Fade(this.id)},addUIComponent:function(){var A=$(this.progressContainerId);if(A!=null){this.progressBarMaxWidth=A.offsetWidth;this.progressTextElem=document.createElement("div");this.progressTextElem.className="progressStatus";this.progressTextElem.id=this.progressTextIdPrefix+this.id;this.progressBarElem=document.createElement("div");this.progressBarElem.className="progressBar";this.progressBarElem.id=this.progressBarIdPrefix+this.id;var B=document.createElement("div");B.className="progressContainer";if(this.count%2==1){B.className+=" odd"}B.id=this.id;B.appendChild(this.progressBarElem);B.appendChild(this.progressTextElem);A.appendChild(B)}}});var PBUploader=Class.create({pbType:"PBUploader",initialize:function(A){this.id="",this.formCompleteId="";this.formId="";this.queue={};this.queueLocked=false;this.canceled=false;this.totalUploaded=0;this.totalUploadSize=0;for(var B in A){this[B]=A[B]}Event.observe(document,PBUpload.MESSAGE.UPLOAD_CANCELED,this.uploadCanceledHandler.bindAsEventListener(this),false);Event.observe(document,PBUpload.MESSAGE.UPLOAD_CHANGE,this.fileChangeHandler.bindAsEventListener(this),false)},submit:function(A){},uploadCanceledHandler:function(A){for(var B in this.queue){this.queue[B].cancel()}this.canceled=true;this.reset()},fileChangeHandler:function(B){var C=B.memo;if(!this.queue[C.id]){return false}var A=0;for(var D in this.queue){A+=this.queue[D].getBytesUploaded()}this.totalUploaded=A;document.fire(PBUploadPanelProgress.MESSAGE.TOTAL_PROGRESS_UPDATE,(this.totalUploaded/this.totalUploadSize))},add:function(B,A){if(!this.queueLocked){this.queue[B]=A;this.totalUploadSize+=A.getSize()}},remove:function(A){if(!this.queueLocked){this.totalUploadSize-=this.queue[A].getSize();delete this.queue[A]}},get:function(A){return this.queue[A]},isEmpty:function(){for(var A in this.queue){return false}return true},updateFileStatusBarText:function(){for(var B in this.queue){var A=this.queue[B];A.updateProgressBarText(this.getCount())}},uploadComplete:function(){var B=$(this.formCompleteId);if(B!=null){var D=false;var A=0;var C=0;for(var G in this.queue){D=true;var E=this.queue[G];if(E.bVideo){A++}else{C++}for(var F in E.uploadResp){this.addCompletionInput(B,F+"[]",E.uploadResp[F])}}if(D){document.fire(PBUploader.MESSAGE.BEFORE_UPLOAD_COMPLETE,{id:this.id,form:B});if(!this.canceled){if(C>0){this.addCompletionInput(B,"imageCount",C)}if(A>0){this.addCompletionInput(B,"videoCount",A)}B.submit()}}this.reset()}},addCompletionInput:function(B,C,A){new Insertion.Bottom(B,'<input type="hidden" name="'+C+'" value="'+A+'">')},reset:function(){try{this.queue={};this.canceled=false;this.queueLocked=false;this.totalUploaded=0;this.totalUploadSize=0}catch(A){}},getCount:function(){var A=0;for(var B in this.queue){A++}return A}});PBUploader=Object.extend(PBUploader,{MESSAGE:{AFTER_SUBMIT:"PBUploader:AfterSubmit",BEFORE_UPLOAD_COMPLETE:"PBUploader:BeforeUploadComplete"}});var SerialUploader=Class.create(PBUploader,{uploadId:null,uploadInterval:500,uploadingFileIndex:null,uploadingFileArray:null,pbType:"SerialUploader",initialize:function($super,A){$super(A);this.uploadingFileArray=(new Array()).toArray();this.uploadingFileIndex=0;Event.observe(document,PBUpload.MESSAGE.UPLOAD_COMPLETE,this.onFileUploaded.bindAsEventListener(this),false)},submit:function(D){if(!this.statusPollingId){if(!this.isEmpty()){var B=0;for(var C in this.queue){var A=this.queue[C];A.setProgress(++B);this.uploadingFileArray[this.uploadingFileArray.length]=A}this.updateFileStatusBarText();this.upload(this.uploadingFileArray[this.uploadingFileIndex]);this.queueLocked=true;document.fire(PBUploader.MESSAGE.AFTER_SUBMIT,{id:this.id})}else{document.fire(PBUpload.MESSAGE.ERROR,{message:"Alert",details:"Please select some files."})}}return false},onFileUploaded:function(B){var D=B.memo;if(D.canceled){return }var C=this.uploadingFileArray[this.uploadingFileIndex];if(C&&D.id==C.id&&!this.canceled){var A=this.uploadingFileArray.length-1;if(this.uploadingFileIndex<A){this.upload(this.uploadingFileArray[++this.uploadingFileIndex])}else{this.uploadComplete()}}},upload:function(A){if(!A.canceled&&A.beforeUpload(this)){A.upload()}},reset:function($super){$super();this.uploadingFileIndex=0;this.uploadingFileArray=(new Array()).toArray()}});var PBFetcher=Class.create({pbType:"PBFetcher",initialize:function(A){this.limit=10;for(var B in A){this[B]=A[B]}this.fetchSuccess=this.handleFetch.bindAsEventListener(this)},fetch:function(A){A=this.getFetchConfig(A);if(A){new Ajax.Request(A.url,{method:"get",evalJSON:"force",onSuccess:this.fetchSuccess,custom:A.custom});document.fire(PBFetcher.MESSAGE.FETCH_STARTED,A)}},getFetchConfig:function(){return{url:"",options:{}}},handleFetch:function(D){var C=D.responseJSON.response;var A=D.request.options.custom;if(!C){return }var B={response:C,requestOptions:A};document.fire(PBFetcher.MESSAGE.FETCH_COMPLETE,B)}});PBFetcher=Object.extend(PBFetcher,{MESSAGE:{FETCH_STARTED:"PBFetcher:FetchStarted",FETCH_COMPLETE:"PBFetcher:FetchComplete"}});var PBAlbumMediaFetcher=Class.create(PBFetcher,{pbType:"PBAlbumMediaFetcher",initialize:function($super,A){$super(A);this.fetchedAlbums={}},getFetchConfig:function(G){var C=G.selectedAlbum;var D=(C.attributes.mediaCount)?C.attributes.mediaCount.value:0;var I=(C.defaultSelected)?null:C.attributes.location.value;var H=this.getAlbum(C.value);var E="getalbummedia";var B=H.mediaCount;var F=Math.min(H.mediaCount+this.limit,D);if(B>=F){return null}var A=location.pathname+"?action="+E+"&start="+B+"&end="+F;if(I){A+="&album="+I}A+="&cb="+(new Date()).getTime();var G={url:A,custom:{targetId:C.value}};return G},handleFetch:function($super,F){$super(F);var B=F.request.options.custom;var D=F.responseJSON.response.media;var E=B.targetId;var A=this.getAlbum(E);var C=D.length;A.mediaCount+=C;this.setAlbum(E,A)},getAlbum:function(A){if(this.fetchedAlbums[A]){return this.fetchedAlbums[A]}else{return{mediaCount:0}}},setAlbum:function(B,A){this.fetchedAlbums[B]=A}});var PBUploadQueue=Class.create({initialize:function(){this.files={};this.totalUploadSize=0;this.totalUploaded=0;this.totalFileCount=0;this.resizeSelectName="image_size";this.completeFormId="frmUploadComplete";this.completeForm=null;this.canceled=false},registerHandlers:function(A){Event.observe(document,PBUpload.MESSAGE.UPLOAD_COMPLETE,this.fileCompleteHandler.bindAsEventListener(this),false);Event.observe(document,PBUpload.MESSAGE.UPLOAD_CANCELED,this.uploadCanceledHandler.bindAsEventListener(this),false);Event.observe(document,PBUpload.MESSAGE.ENCODING_CHANGE,this.fileChangeHandler.bindAsEventListener(this),false);Event.observe(document,PBUpload.MESSAGE.UPLOAD_CHANGE,this.fileChangeHandler.bindAsEventListener(this),false);this.completeForm=$(this.completeFormId)},fileChangeHandler:function(B){var C=B.memo;if(!this.files[C.id]){return false}var A=0;for(var D in this.files){A+=this.files[D].getBytesUploaded()}this.totalUploaded=A;document.fire(PBUploadPanelProgress.MESSAGE.TOTAL_PROGRESS_UPDATE,(this.totalUploaded/this.totalUploadSize))},fileCompleteHandler:function(A){var B=A.memo;if(!this.files[B.id]){return false}if(this.isComplete()){document.fire(PBUpload.MESSAGE.QUEUE_COMPLETE,this);this.onComplete()}},uploadCanceledHandler:function(A){this.canceled=true},addFile:function(A){A.setCount(++this.totalFileCount);this.files[A.id]=A;this.totalUploadSize+=A.getSize();A.setResize(this.getResizeValue());for(var B in this.files){this.files[B].updateProgressBarText(this.totalFileCount)}this.canceled=false},isComplete:function(){return(this.totalUploadSize==this.totalUploaded)},reportError:function(B,A){document.fire(PBUpload.MESSAGE.ERROR,{message:"Attention",details:A})},getResizeValue:function(){var B=this.completeForm[this.resizeSelectName];var A=B.options[B.selectedIndex];var C=null;if(!A.defaultSelected){C=A.value}return C},reset:function(){this.files={};this.totalUploadSize=0;this.totalUploaded=0;this.totalFileCount=0;this.canceled=false},onComplete:function(){if(this.completeForm!=null&&this.totalFileCount>0&&!this.canceled){var B=0;var C=0;var A="local";for(var H in this.files){var D=this.files[H];if(D.isVideo){B++}else{C++}for(var G in D.uploadResp){this.addCompletionInput(G+"[]",D.uploadResp[G])}}var F;if((F=this.getResizeValue())!=null){this.addCompletionInput(G+"[]",D.uploadResp[G])}var E="video";if(C>0&&B>0){E="mixed";this.addCompletionInput("imageCount",C);this.addCompletionInput("videoCount",B)}else{if(C>0){E="image"}}this.addCompletionInput("media",E);this.addCompletionInput("addtype",A);this.completeForm.submit()}this.reset()},addCompletionInput:function(B,A){if(this.completeForm!=null){new Insertion.Top(this.completeForm,'<input type="hidden" name="'+B+'" value="'+A+'">')}}});var PBFileUtils=Class.create({initialize:function(A){this.validExtArray=A||new Array()},getFilename:function(D){var A="";var C="([^=;\\\\/#\\?&:]+\\.("+this.validExtArray.join("|")+"))";var B=new RegExp(C,"gi");if((m=D.match(B))!=null){A=m[0]}return A}});var PBFile=Class.create({initialize:function(A){this.action="";this.post_name="";this.name="";this.type="";this.size=0;this.id="";this.bytesUploaded=0;this.count=0;this.resize=null;this.uploadResp=null;this.progress=null;this.hasBeenUploaded=false;this.isUploading=false;this.canceled=false;this.groupHash="";this.scrambleCookie="scramble_filename";for(var B in A){this[B]=A[B]}this.addUIComponent();this.uploadSuccess=this.uploadCallSuccess.bind(this);this.uploadFailure=this.uploadCallFailure.bind(this)},onUploadComplete:function(A){this.hasBeenUploaded=true;this.isUploading=false;this.setServerResponse(A);this.completed();this.progress.hide()},onUploadChange:function(A){if(A){this.bytesUploaded=A}this.progress.update(this.getBytesUploaded()/this.getSize());var B=$(this.id)||document;B.fire(PBUpload.MESSAGE.UPLOAD_CHANGE,this)},onUploadCanceled:function(){Effect.Fade(this.id)},updateProgressBarText:function(A){if(this.progress){this.progress.setText(this.name,this.count,A)}},setCount:function(A){this.count=A},getSize:function(){return this.size},getBytesUploaded:function(){return this.bytesUploaded},setResize:function(A){this.resize=A},beforeUpload:function(A){return true},upload:function(A){if(A){var B=location.pathname+"?action="+this.action;for(var C in A){B+="&"+C+"="+A[C]}B+="&cb="+(new Date()).getTime();new Ajax.Request(B,{method:"get",evalJSON:"force",onSuccess:this.uploadSuccess,onFailure:this.uploadFailure});this.isUploading=true}},setProgress:function(A){this.count=A;this.progress=new PBProgressBar({id:this.id+"_pbar",count:this.count})},addUIComponent:function(){},uploadCallSuccess:function(A){this.onUploadComplete(A)},uploadCallFailure:function(A){if(!A.filename){A.filename=this.name}this.onUploadComplete(A)},completed:function(){this.onUploadChange(this.getSize());var A=$(this.id)||document;A.fire(PBUpload.MESSAGE.UPLOAD_COMPLETE,this)},hide:function(){this.progress.hide()},cancel:function(){this.canceled=true;this.completed();this.hide()},setServerResponse:function(response){try{this.uploadResp=eval(response)}catch(e){this.uploadResp={stat:"fail",filename:this.name,errormsg:response}}}});var PBImage=Class.create(PBFile,{initialize:function($super,A){$super(A);this.action="uploadimage";this.post_name="the_image"},getPostParams:function(D,C,E){var B={pbauth:D,action:this.action};if(this.resize){B.image_size=this.resize}if(C){B.group_hash=C}if(E){B.pbguest=E}var A=readCookie(this.scrambleCookie);if(A){B.scramble_filename=A}return B},addUIComponent:function(){this.progress=new PBProgressBar({id:this.id,count:this.count})}});var PBVideo=Class.create(PBFile,{isVideo:true,initialize:function($super,A){$super(A);this.title="";this.action="uploadvideo";this.post_name="the_video";this.processElemId="UPLOAD_METER_ID";this.encodingProgress=0;this.encodingPollingId=null;this.preEncodingPollingId=null;this.isStatusCallPending=false;var B=$(this.processElemId);if(B!=null){this.processId=B.value}},onUploadChange:function($super,A){$super(A);if(A==this.size&&!this.canceled){this.startPreEncodingProgress()}},onUploadComplete:function(data){this.stopPreEncodingProgress();var bSuccess=false;try{data=eval(data);bSuccess=(data.stat!="fail")}catch(e){}if(bSuccess){this.onUploadChange(this.size);this.startPollingEncodingProgress();$(this.id).fire(PBUploadMessages.UPLOAD_CHANGE,this)}else{this.setServerResponse(data);this.cancel()}},onEncodingComplete:function(A){clearInterval(this.encodingPollingId);this.encodingPollingId=null;this.setServerResponse(A);this.completed();this.hide()},onEncodingChange:function(A){this.encodingProgress=A;$(this.id).fire(PBUpload.MESSAGE.ENCODING_CHANGE,this);this.onUploadChange()},getSize:function(){return this.size*2},getBytesUploaded:function(){if(this.encodingProgress==0){return this.bytesUploaded}else{var A=this.size+this.size*this.encodingProgress/100;return A}},getPostParams:function(D,C,E){var B={pbauth:D,action:this.action,video_desc:this.title,UPLOAD_METTER_ID:this.processId,UPLOAD_IDENTIFIER:this.processId};if(C){B.group_hash=C}if(E){B.pbguest=E}var A=readCookie(this.scrambleCookie);if(A){B.scramble_filename=A}return B},setResize:function(A){},addUIComponent:function(){this.progress=new PBProgressBar({id:this.id,count:this.count})},startPreEncodingProgress:function(){this.preEncodingPollingId=setInterval(this.executePreEncodingStatusCall.bind(this),2000)},executePreEncodingStatusCall:function(){if(this.preEncodingPollingId){if(this.encodingProgress<20){this.encodingProgress+=5;this.onEncodingChange(this.encodingProgress)}else{this.stopPreEncodingProgress()}}},stopPreEncodingProgress:function(){clearInterval(this.preEncodingPollingId);this.preEncodingPollingId=null},startPollingEncodingProgress:function(){this.stopPreEncodingProgress();if(!this.encodingPollingId){this.encodingPollingId=setInterval(this.executeEncodingStatusCall.bind(this),2000)}},executeEncodingStatusCall:function(){if(!this.isStatusCallPending){new APIRequest("getvideoprogress",false,{id:this.processId},this.statusCallSuccess.bind(this),this.statusCallFailure.bind(this),false);this.isStatusCallPending=true}},statusCallSuccess:function(A){this.isStatusCallPending=false;if(A.stat=="ok"){var C=A.videoprogress.stage;var B=parseFloat(A.videoprogress.encoding_progress);if(0<B&&B<=100&&B>this.encodingProgress){this.onEncodingChange(B);if(B==100){this.onEncodingComplete(A)}}}},statusCallFailure:function(A){this.isStatusCallPending=false;this.onEncodingComplete(A)},setServerResponse:function(A){var B={stat:(A.stat)?A.stat:"",filename:(A.filename)?A.filename:"",errormsg:(A.errormsg)?A.errormsg:""};this.uploadResp=B},cancel:function($super){this.encodingProgress=100;$super()}});var PBWeb=Class.create(PBFile,{initialize:function($super,A){this.groupHash=null;$super(A);if(this.validExtArray&&this.url){this.utils=new PBFileUtils(this.validExtArray);var B=this.utils.getFilename(this.url);this.name=B;this.type=(B.indexOf(".")>-1)?B.split(".").pop().toLowerCase():null}this.action="uploadweb";this.isValidated=false;this.hasInvalidProtocol=true;this.hasInvalidExtension=true;this.fileTypeErrorMessage="";this.protocolErrorMessage="";this.size=10},validate:function(A){this.hasInvalidProtocol=!this.validateProtocol();this.hasInvalidExtension=!this.validateExtension(A);this.isValidated=(!this.hasInvalidProtocol&&!this.hasInvalidExtension)},upload:function($super){if(this.isValidated){var A={the_web:this.url,image_size:this.resize,group_hash:this.groupHash,json:1};$super(A)}},validateProtocol:function(){var A=!(this.url.search(/^(http|https|ftp):\/\//i)==-1);if(!A){this.setProtocolErrorMessage()}return A},validateExtension:function(C){var B=this.validExtArray.join("|");var A=(B.indexOf(this.type)>-1)&&(C||this.type!="swf");if(!A){this.setFileTypeErrorMsg(C)}return A},beforeUpload:function(C){try{var A=$(C.formId);if(A.image_size&&A.image_size.options){var D=A.image_size.options[A.image_size.selectedIndex].value;this.setResize(D)}}catch(B){return false}return true},setServerResponse:function(A){try{var C=A.responseJSON.response;this.uploadResp=C}catch(B){}},setProtocolErrorMessage:function(){this.protocolErrorMessage='"'+this.url+'" does not look like a valid URL.<br/>Please click on the my computer tab to upload a local file.'},setFileTypeErrorMsg:function(C){var B="";var D=this.validExtArray.join(", ");var A=(this.name!="")?'"'+this.name+'"':this.name;if(!C&&this.type=="swf"){B="The file "+A+" is a SWF: SWF file uploading is no longer available on free accounts. SWF files can be uploaded to PRO accounts only."}else{B="The file "+A+" does not have a valid image  extension.<br>Valid image extensions are: "+D+"."}this.fileTypeErrorMessage=B}});var PBAlbumFile=Class.create(PBFile,{initialize:function($super,A){this.isLoaded=false;this.wasPreloaded=false;this.pollingInterval=2000;this.visibilityPollingId=null;this.container=null;this.elem=null;this.imageElem=null;this.tempElem=null;this.addElem=null;this.removeElem=null;this.groupHash=null;this.media=null;$super(A);this.action="uploadweb";this.progressContainerId="progressContainer";this.size=10;this.bVideo=(this.media=="video");var C="?file=";var B=this.url.indexOf(C);if(this.media&&this.media=="video"&&B>0){this.url=this.url.substring(B+C.length)}this.name=this.id},select:function(){Element.addClassName($(this.id),"selected")},deselect:function(){Element.removeClassName($(this.id),"selected")},load:function(){this.imageElem.src=this.thumb;this.tempElem.style.visibility="hidden";this.imageElem.style.visibility="visible";this.isLoaded=true},pollVisibility:function(A){this.container=$(A);this.visibilityPollingId=setInterval(this.checkVisibility.bind(this),this.pollingInterval)},upload:function($super){var A={the_web:encodeURIComponent(this.url),image_size:this.resize,group_hash:this.groupHash,json:1,album:1};if(this.bVideo){A.video=1}$super(A)},cancel:function($super){$super();this.deselect()},addUIComponent:function(){this.elem=$(this.id);this.imageElem=$(this.id+"_image");this.tempElem=$(this.id+"_temp");this.addElem=$(this.id+"_add");this.removeElem=$(this.id+"_remove");this.elem.show()},checkVisibility:function(){if(this.isLoaded){this.stopPolling()}else{if(this.isVisible()){this.stopPolling();this.load();document.fire(PBUpload.MESSAGE.THUMBNAIL_LOADED,this)}}return },stopPolling:function(){clearInterval(this.visibilityPollingId);this.visibilityPollingId=null;this.container=null},isVisible:function(){if(this.container){var B=this.container.offsetHeight;var E=this.container.offsetTop;var A=this.container.scrollTop;var C=B+E+A;var D=$(this.id).offsetTop;if(D<C){return true}}return false},setServerResponse:function(A){try{var C=A.responseJSON.response;this.uploadResp=C}catch(B){}}});var SWFUpload=function(A){this.initSWFUpload(A)};SWFUpload.prototype.initSWFUpload=function(B){try{this.customSettings={};this.settings=B;this.eventQueue=[];this.movieName="SWFUpload_"+SWFUpload.movieCount++;this.movieElement=null;SWFUpload.instances[this.movieName]=this;this.initSettings();this.loadFlash();this.displayDebugInfo()}catch(A){delete SWFUpload.instances[this.movieName];throw A}};SWFUpload.instances={};SWFUpload.movieCount=0;SWFUpload.version="2.1.0 beta 1";SWFUpload.QUEUE_ERROR={QUEUE_LIMIT_EXCEEDED:-100,FILE_EXCEEDS_SIZE_LIMIT:-110,ZERO_BYTE_FILE:-120,INVALID_FILETYPE:-130};SWFUpload.UPLOAD_ERROR={HTTP_ERROR:-200,MISSING_UPLOAD_URL:-210,IO_ERROR:-220,SECURITY_ERROR:-230,UPLOAD_LIMIT_EXCEEDED:-240,UPLOAD_FAILED:-250,SPECIFIED_FILE_ID_NOT_FOUND:-260,FILE_VALIDATION_FAILED:-270,FILE_CANCELLED:-280,UPLOAD_STOPPED:-290};SWFUpload.FILE_STATUS={QUEUED:-1,IN_PROGRESS:-2,ERROR:-3,COMPLETE:-4,CANCELLED:-5};SWFUpload.prototype.initSettings=function(){this.ensureDefault=function(B,A){this.settings[B]=(this.settings[B]==undefined)?A:this.settings[B]};this.ensureDefault("upload_url","");this.ensureDefault("file_post_name","Filedata");this.ensureDefault("post_params",{});this.ensureDefault("use_query_string",false);this.ensureDefault("file_types","*.*");this.ensureDefault("file_types_description","All Files");this.ensureDefault("file_size_limit",0);this.ensureDefault("file_upload_limit",0);this.ensureDefault("file_queue_limit",0);this.ensureDefault("flash_url","swfupload_f9.swf");this.ensureDefault("flash_color","#FFFFFF");this.ensureDefault("debug",false);this.settings.debug_enabled=this.settings.debug;this.settings.return_upload_start_handler=this.returnUploadStart;this.ensureDefault("swfupload_loaded_handler",null);this.ensureDefault("file_dialog_start_handler",null);this.ensureDefault("file_queued_handler",null);this.ensureDefault("file_queue_error_handler",null);this.ensureDefault("file_dialog_complete_handler",null);this.ensureDefault("upload_start_handler",null);this.ensureDefault("upload_progress_handler",null);this.ensureDefault("upload_error_handler",null);this.ensureDefault("upload_success_handler",null);this.ensureDefault("upload_complete_handler",null);this.ensureDefault("debug_handler",this.debugMessage);this.ensureDefault("custom_settings",{});this.customSettings=this.settings.custom_settings;delete this.ensureDefault};SWFUpload.prototype.loadFlash=function(){var B,A;if(document.getElementById(this.movieName)!==null){throw"ID "+this.movieName+" is already in use. The Flash Object could not be added"}B=document.getElementsByTagName("body")[0];if(B==undefined){alert("no body element yet");throw"Could not find the 'body' element."}A=document.createElement("div");A.style.width="1px";A.style.height="1px";B.appendChild(A);A.innerHTML=this.getFlashHTML()};SWFUpload.prototype.getFlashHTML=function(){return['<object id="',this.movieName,'" type="application/x-shockwave-flash" data="',this.settings.flash_url,'" width="1" height="1" style="-moz-user-focus: ignore;">','<param name="movie" value="',this.settings.flash_url,'" />','<param name="bgcolor" value="',this.settings.flash_color,'" />','<param name="quality" value="high" />','<param name="menu" value="false" />','<param name="allowScriptAccess" value="always" />','<param name="flashvars" value="'+this.getFlashVars()+'" />',"</object>"].join("")};SWFUpload.prototype.getFlashVars=function(){var A=this.buildParamString();return["movieName=",encodeURIComponent(this.movieName),"&amp;uploadURL=",encodeURIComponent(this.settings.upload_url),"&amp;useQueryString=",encodeURIComponent(this.settings.use_query_string),"&amp;params=",encodeURIComponent(A),"&amp;filePostName=",encodeURIComponent(this.settings.file_post_name),"&amp;fileTypes=",encodeURIComponent(this.settings.file_types),"&amp;fileTypesDescription=",encodeURIComponent(this.settings.file_types_description),"&amp;videoFileTypes=",encodeURIComponent(this.settings.video_file_types),"&amp;fileSizeLimit=",encodeURIComponent(this.settings.file_size_limit),"&amp;fileUploadLimit=",encodeURIComponent(this.settings.file_upload_limit),"&amp;fileQueueLimit=",encodeURIComponent(this.settings.file_queue_limit),"&amp;debugEnabled=",encodeURIComponent(this.settings.debug_enabled)].join("")};SWFUpload.prototype.getMovieElement=function(){if(this.movieElement==undefined){this.movieElement=document.getElementById(this.movieName)}if(this.movieElement===null){throw"Could not find Flash element"}return this.movieElement};SWFUpload.prototype.buildParamString=function(){var C=this.settings.post_params;var B=[];if(typeof (C)==="object"){for(var A in C){if(C.hasOwnProperty(A)){B.push(encodeURIComponent(A.toString())+"="+encodeURIComponent(C[A].toString()))}}}return B.join("&")};SWFUpload.prototype.displayDebugInfo=function(){this.debug(["---SWFUpload Instance Info---\n","Version: ",SWFUpload.version,"\n","Movie Name: ",this.movieName,"\n","Settings:\n","\t","upload_url:             ",this.settings.upload_url,"\n","\t","use_query_string:       ",this.settings.use_query_string.toString(),"\n","\t","file_post_name:         ",this.settings.file_post_name,"\n","\t","post_params:            ",this.settings.post_params.toString(),"\n","\t","file_types:             ",this.settings.file_types,"\n","\t","file_types_description: ",this.settings.file_types_description,"\n","\t","file_size_limit:        ",this.settings.file_size_limit,"\n","\t","file_upload_limit:      ",this.settings.file_upload_limit,"\n","\t","file_queue_limit:       ",this.settings.file_queue_limit,"\n","\t","flash_url:              ",this.settings.flash_url,"\n","\t","flash_color:            ",this.settings.flash_color,"\n","\t","debug:                  ",this.settings.debug.toString(),"\n","\t","custom_settings:        ",this.settings.custom_settings.toString(),"\n","Event Handlers:\n","\t","swfupload_loaded_handler assigned:  ",(typeof (this.settings.swfupload_loaded_handler)==="function").toString(),"\n","\t","file_dialog_start_handler assigned: ",(typeof (this.settings.file_dialog_start_handler)==="function").toString(),"\n","\t","file_queued_handler assigned:       ",(typeof (this.settings.file_queued_handler)==="function").toString(),"\n","\t","file_queue_error_handler assigned:  ",(typeof (this.settings.file_queue_error_handler)==="function").toString(),"\n","\t","upload_start_handler assigned:      ",(typeof (this.settings.upload_start_handler)==="function").toString(),"\n","\t","upload_progress_handler assigned:   ",(typeof (this.settings.upload_progress_handler)==="function").toString(),"\n","\t","upload_error_handler assigned:      ",(typeof (this.settings.upload_error_handler)==="function").toString(),"\n","\t","upload_success_handler assigned:    ",(typeof (this.settings.upload_success_handler)==="function").toString(),"\n","\t","upload_complete_handler assigned:   ",(typeof (this.settings.upload_complete_handler)==="function").toString(),"\n","\t","debug_handler assigned:             ",(typeof (this.settings.debug_handler)==="function").toString(),"\n"].join(""))};SWFUpload.prototype.addSetting=function(B,C,A){if(C==undefined){return(this.settings[B]=A)}else{return(this.settings[B]=C)}};SWFUpload.prototype.getSetting=function(A){if(this.settings[A]!=undefined){return this.settings[A]}return""};SWFUpload.prototype.callFlash=function(C,B,E){B=!!B||false;E=E||[];var A=this;var D=function(){var F=A.getMovieElement();if(typeof (F[C])==="function"){if(E.length===0){return F[C]()}else{if(E.length===1){return F[C](E[0])}else{if(E.length===2){return F[C](E[0],E[1])}else{if(E.length===3){return F[C](E[0],E[1],E[2])}else{throw"Too many arguments"}}}}}else{alert("invalid function name:"+C);throw"Invalid function name"}};if(B){setTimeout(D,0)}else{return D()}};SWFUpload.prototype.selectFile=function(){this.callFlash("SelectFile")};SWFUpload.prototype.selectFiles=function(){this.callFlash("SelectFiles")};SWFUpload.prototype.startUpload=function(A){this.callFlash("StartUpload",false,[A])};SWFUpload.prototype.cancelUpload=function(A){this.callFlash("CancelUpload",false,[A])};SWFUpload.prototype.stopUpload=function(){this.callFlash("StopUpload")};SWFUpload.prototype.getStats=function(){return this.callFlash("GetStats")};SWFUpload.prototype.setStats=function(A){this.callFlash("SetStats",false,[A])};SWFUpload.prototype.setCredentials=function(B,A){this.callFlash("SetCrednetials",false,[B,A])};SWFUpload.prototype.getFile=function(A){if(typeof (A)==="number"){return this.callFlash("GetFileByIndex",false,[A])}else{return this.callFlash("GetFile",false,[A])}};SWFUpload.prototype.addFileParam=function(A,B,C){return this.callFlash("AddFileParam",false,[A,B,C])};SWFUpload.prototype.removeFileParam=function(A,B){this.callFlash("RemoveFileParam",false,[A,B])};SWFUpload.prototype.setUploadURL=function(A){this.settings.upload_url=A.toString();this.callFlash("SetUploadURL",false,[A])};SWFUpload.prototype.setPostParams=function(A){this.settings.post_params=A;this.callFlash("SetPostParams",false,[A])};SWFUpload.prototype.setFileTypes=function(A,B){this.settings.file_types=A;this.settings.file_types_description=B;this.callFlash("SetFileTypes",false,[A,B])};SWFUpload.prototype.setFileSizeLimit=function(A){this.settings.file_size_limit=A;this.callFlash("SetFileSizeLimit",false,[A])};SWFUpload.prototype.setFileUploadLimit=function(A){this.settings.file_upload_limit=A;this.callFlash("SetFileUploadLimit",false,[A])};SWFUpload.prototype.setFileQueueLimit=function(A){this.settings.file_queue_limit=A;this.callFlash("SetFileQueueLimit",false,[A])};SWFUpload.prototype.setFilePostName=function(A){this.settings.file_post_name=A;this.callFlash("SetFilePostName",false,[A])};SWFUpload.prototype.setUseQueryString=function(A){this.settings.use_query_string=A;this.callFlash("SetUseQueryString",false,[A])};SWFUpload.prototype.setDebugEnabled=function(A){this.settings.debug_enabled=A;this.callFlash("SetDebugEnabled",false,[A])};SWFUpload.prototype.queueEvent=function(B,C){if(C==undefined){C=[]}else{if(!(C instanceof Array)){C=[C]}}var A=this;if(typeof (this.settings[B])==="function"){this.eventQueue.push(function(){this.settings[B].apply(this,C)});setTimeout(function(){A.executeNextEvent()},0)}else{if(this.settings[B]!==null){throw"Event handler "+B+" is unknown or is not a function"}}};SWFUpload.prototype.executeNextEvent=function(){var A=this.eventQueue.shift();A.apply(this)};SWFUpload.prototype.flashReady=function(){var A=this.getMovieElement();if(typeof (A.StartUpload)!=="function"){throw"ExternalInterface methods failed to initialize."}this.queueEvent("swfupload_loaded_handler")};SWFUpload.prototype.fileDialogStart=function(){this.queueEvent("file_dialog_start_handler")};SWFUpload.prototype.fileQueued=function(A){this.queueEvent("file_queued_handler",A)};SWFUpload.prototype.fileQueueError=function(A,C,B){this.queueEvent("file_queue_error_handler",[A,C,B])};SWFUpload.prototype.fileDialogComplete=function(A,B){this.queueEvent("file_dialog_complete_handler",[A,B])};SWFUpload.prototype.uploadStart=function(A){this.queueEvent("return_upload_start_handler",A)};SWFUpload.prototype.returnUploadStart=function(A){var B;if(typeof (this.settings.upload_start_handler)==="function"){B=this.settings.upload_start_handler.call(this,A)}else{if(this.settings.upload_start_handler!=undefined){throw"upload_start_handler must be a function"}}if(B===undefined){B=true}B=!!B;this.callFlash("ReturnUploadStart",false,[B])};SWFUpload.prototype.uploadProgress=function(A,C,B){this.queueEvent("upload_progress_handler",[A,C,B])};SWFUpload.prototype.uploadError=function(A,C,B){this.queueEvent("upload_error_handler",[A,C,B])};SWFUpload.prototype.uploadSuccess=function(B,A){this.queueEvent("upload_success_handler",[B,A])};SWFUpload.prototype.uploadComplete=function(A){this.queueEvent("upload_complete_handler",A)};SWFUpload.prototype.debug=function(A){this.queueEvent("debug_handler",A)};SWFUpload.prototype.debugMessage=function(C){if(this.settings.debug){var A,D=[];if(typeof (C)==="object"&&typeof (C.name)==="string"&&typeof (C.message)==="string"){for(var B in C){if(C.hasOwnProperty(B)){D.push(B+": "+C[B])}}A=D.join("\n")||"";D=A.split("\n");A="EXCEPTION: "+D.join("\nEXCEPTION: ");SWFUpload.Console.writeLine(A)}else{SWFUpload.Console.writeLine(C)}}};SWFUpload.Console={};SWFUpload.Console.writeLine=function(D){var B,A;try{B=document.getElementById("SWFUpload_Console");if(!B){A=document.createElement("form");document.getElementsByTagName("body")[0].appendChild(A);B=document.createElement("textarea");B.id="SWFUpload_Console";B.style.fontFamily="monospace";B.setAttribute("wrap","off");B.wrap="off";B.style.overflow="auto";B.style.width="700px";B.style.height="350px";B.style.margin="5px";A.appendChild(B)}B.value+=D+"\n";B.scrollTop=B.scrollHeight-B.clientHeight}catch(C){alert("Exception: "+C.name+" Message: "+C.message)}};var SWFUpload;if(typeof (SWFUpload)==="function"){SWFUpload.prototype.queue=new PBUploadQueue();SWFUpload.prototype.flashVersionRequired="9.0.0";SWFUpload.prototype.flashContainer=null;SWFUpload.prototype.componentId="SwfUploadObj";SWFUpload.prototype.uploadVersionCookie="upload_version";SWFUpload.prototype.loadFlash=function(){var A;if(document.getElementById(this.movieName)!==null){throw"ID "+this.movieName+" is already in use. The Flash Object could not be added"}if(this.customSettings.parentId){A=$(this.customSettings.parentId)}else{A=document.getElementsByTagName("body")[0]}if(A==undefined){throw"Could not find the target element."}this.flashContainer=document.createElement("div");this.flashContainer.id=this.componentId;this.flashContainer.style.width="1px";this.flashContainer.style.height="1px";this.flashContainer.style.position="absolute";this.flashContainer.style.top="0";this.flashContainer.style.left="0";A.appendChild(this.flashContainer);this.getFlashHTML()};SWFUpload.prototype.getFlashHTML=function(){var A=new SWFObject(this.settings.flash_url,this.movieName,"1","1",this.flashVersionRequired);A.addParam("quality","high");A.addParam("menu","false");A.addParam("bgcolor",this.settings.flash_color);A.addParam("allowScriptAccess","always");A.addParam("flashvars",this.getFlashVars());if(A.installedVer.major<9||!A.write(this.flashContainer)){createCookie(this.uploadVersionCookie,0,90);location.reload(true)}};SWFUpload.prototype.registerHandlers=function(){this.addSetting("file_queued_handler",this.fileQueuedHandler);this.addSetting("file_queue_error_handler",this.fileQueueErrorHandler);this.addSetting("file_dialog_complete_handler",this.fileDialogCompleteHandler);this.addSetting("upload_start_handler",this.uploadStartHandler);this.addSetting("upload_progress_handler",this.uploadProgressHandler);this.addSetting("upload_error_handler",this.uploadErrorHandler);this.addSetting("upload_success_handler",this.uploadSuccessHandler);this.addSetting("upload_complete_handler",this.uploadCompleteHandler);this.addSetting("queue_complete_handler",this.queueCompleteHandler);Event.observe(this.customSettings.selectButtonId,"click",this.uploadDialogOpenHandler.bindAsEventListener(this),false);Event.observe(document,PBUpload.MESSAGE.UPLOAD_CANCELED,this.cancelQueueHandler.bindAsEventListener(this),false);Event.observe(document,PBUpload.MESSAGE.UPLOAD_COMPLETE,this.uploadCompleteHandler.bindAsEventListener(this),false);this.queue.registerHandlers()};SWFUpload.prototype.uploadDialogOpenHandler=function(){this.selectFiles();this.getComponentElem().fire(PBUpload.MESSAGE.UPLOAD_DIALOG_OPEN)};SWFUpload.prototype.uploadStartHandler=function(B){try{B=this.getFileById(B.id);this.setFilePostName(B.post_name);this.setPostParams(B.getPostParams(this.customSettings.auth,this.customSettings.groupHash,this.customSettings.guest));return true}catch(A){this.debug("upload failed.")}return false};SWFUpload.prototype.fileQueuedHandler=function(D){try{if(!D.type){var A=D.name.split(".");D.type=A[A.length-1]}D.type=D.type.toLowerCase();if(D.type.indexOf(".")>-1){D.type=D.type.substring(1)}var F=false;for(var C=0;C<this.customSettings.validVideoFiles.length;C++){if(D.type==this.customSettings.validVideoFiles[C]){F=true;break}}var E=(F)?new PBVideo(D):new PBImage(D);this.queue.addFile(E)}catch(B){this.debug(B)}};SWFUpload.prototype.fileDialogCompleteHandler=function(C,B){try{if(!this.queue.isComplete()){this.startUpload();this.getComponentElem().fire(PBUpload.MESSAGE.UPLOAD_STARTED,this.queue)}}catch(A){this.debug(A)}};SWFUpload.prototype.uploadProgressHandler=function(B,D,C){try{this.getFileById(B.id).onUploadChange(D)}catch(A){this.debug(A)}};SWFUpload.prototype.uploadSuccessHandler=function(C,B){try{this.getFileById(C.id).onUploadComplete(B)}catch(A){this.debug(A)}};SWFUpload.prototype.uploadCompleteHandler=function(A){if(!this.queue.isComplete()){this.startUpload()}};SWFUpload.prototype.fileQueueErrorHandler=function(D,B,E){try{switch(B){case SWFUpload.QUEUE_ERROR.QUEUE_LIMIT_EXCEEDED:var A="Your first "+this.settings.file_queue_limit+" files are uploading now.  ";if(this.customSettings.groupHash){A="You can upload up to "+this.settings.file_queue_limit+" files at once into a group album.  "+A}else{A+="To upload more than "+this.settings.file_queue_limit+' files at once, use our <a id="linkBulkUpload" href="?action=bulkuploader" title="New Quicker and Easier Uploads. Try Now">bulk uploader</a>.'}this.queue.reportError(0,A);APIRequest.track("UPLOAD_FLASH_LIMIT");break;case SWFUpload.QUEUE_ERROR.FILE_EXCEEDS_SIZE_LIMIT:var A="Video files must be under "+this.settings.file_size_limit+".";document.fire(PBUpload.MESSAGE.ERROR,{message:"Attention",details:A});this.debug("Error Code: File too big, File name: "+D.name+", File size: "+D.size+", Message: "+E);break;case SWFUpload.QUEUE_ERROR.ZERO_BYTE_FILE:this.queue.reportError(D.id,"Cannot upload Zero Byte files.");this.debug("Error Code: Zero byte file, File name: "+D.name+", File size: "+D.size+", Message: "+E);break;case SWFUpload.QUEUE_ERROR.INVALID_FILETYPE:this.queue.reportError(D.id,"Invalid File Type.");this.debug("Error Code: Invalid File Type, File name: "+D.name+", File size: "+D.size+", Message: "+E);break;default:if(D!==null){this.queue.reportError(D.id,"Unhandled Error")}this.debug("Error Code: "+B+", File name: "+D.name+", File size: "+D.size+", Message: "+E);break}}catch(C){this.debug(C)}};SWFUpload.prototype.uploadErrorHandler=function(C,A,D){try{switch(A){case SWFUpload.UPLOAD_ERROR.HTTP_ERROR:this.queue.reportError(C.id,"Upload Error: "+D);this.debug("Error Code: HTTP Error, File name: "+C.name+", Message: "+D);break;case SWFUpload.UPLOAD_ERROR.UPLOAD_FAILED:this.queue.reportError(C.id,"Upload Failed.");this.debug("Error Code: Upload Failed, File name: "+C.name+", File size: "+C.size+", Message: "+D);break;case SWFUpload.UPLOAD_ERROR.IO_ERROR:this.queue.reportError(C.id,"Server (IO) Error");this.debug("Error Code: IO Error, File name: "+C.name+", Message: "+D);break;case SWFUpload.UPLOAD_ERROR.SECURITY_ERROR:this.queue.reportError(C.id,"Security Error");this.debug("Error Code: Security Error, File name: "+C.name+", Message: "+D);break;case SWFUpload.UPLOAD_ERROR.UPLOAD_LIMIT_EXCEEDED:this.queue.reportError(C.id,"Upload limit exceeded.");this.debug("Error Code: Upload Limit Exceeded, File name: "+C.name+", File size: "+C.size+", Message: "+D);break;case SWFUpload.UPLOAD_ERROR.FILE_VALIDATION_FAILED:this.queue.reportError(C.id,"Failed Validation.  Upload skipped.");this.debug("Error Code: File Validation Failed, File name: "+C.name+", File size: "+C.size+", Message: "+D);break;case SWFUpload.UPLOAD_ERROR.FILE_CANCELLED:this.cancelQueueHandler();break;case SWFUpload.UPLOAD_ERROR.UPLOAD_STOPPED:break;default:this.queue.reportError(C.id,"Unhandled Error: "+A);this.debug("Error Code: "+A+", File name: "+C.name+", File size: "+C.size+", Message: "+D);break}}catch(B){this.debug(B)}};SWFUpload.prototype.cancelQueueHandler=function(A){for(var B in this.queue.files){this.cancelUpload(B);this.getFileById(B).cancel()}};SWFUpload.prototype.getFileById=function(A){return this.queue.files[A]};SWFUpload.prototype.getComponentElem=function(){if(!this.componentElem){this.componentElem=$(this.componentId)}return this.componentElem}}var SaveToAlbum=Class.create();var saveObj;SaveToAlbum.prototype={mediaurls:null,oMessage:null,ajaxOptions:null,albumtoview:null,albumUrl:null,formName:null,submitEvtObj:null,initialize:function(A){if(typeof (A)=="object"&&A){if(typeof (A.mediaUrl)=="string"&&A.mediaUrl){this.mediaurls=[A.mediaUrl]}if(typeof (A.mediaurls)=="object"&&A.mediaurls){this.mediaurls=A.mediaurls}if(typeof (A.albumUrl)=="string"&&A.albumUrl){this.albumUrl=A.albumUrl}if(typeof (A.formName)=="string"&&A.formName){this.formName=A.formName}}this.ajaxOptions={method:"post",asynchronous:true};this.submitEvtObj=this.submit.bindAsEventListener(this);Object.extend(this.ajaxOptions,A.ajaxOptions||{});saveObj=this},submit:function(B){Event.stop(B);var D;if((D=$("view_in_album"))!=null){Event.observe(D,"click",this.handleViewInAlbum.bindAsEventListener(this))}controllerMessagePanel.clearMessage();var F=this.getClientSideValidationErrorMessage();if(typeof (F=="string")&&F){controllerMessagePanel.printMessage({details:F})}else{$("panelProcessingSaveToAlbum").show();$("savetoalbumbody").hide();$("saving").show();var A=this.getAlbum();var C=(this.albumUrl==null)?"?action=interstitial&secondary_action=savetoalbum":this.albumUrl+"?action=interstitial&secondary_action=savetoalbum";var G="";if(this.mediaurls.size()==1){C+="&selectedmedia[]="+this.mediaurls.first()}else{this.mediaurls.each(function(H){G+="&selectedmedia[]="+H})}G+="&album="+escape(A.albumname);if(A.isNew){G+="&rootalbum="+escape(A.rootalbum)}var E=this.oMessage.unknownError;new Ajax.Request(C,{method:"post",parameters:G,onSuccess:this.callbackSuccess,onFailure:function(H){controllerMessagePanel.printMessage({details:E});$("panelProcessingSaveToAlbum").hide()}})}},callbackSuccess:function(H){try{var B=H.responseText.evalJSON().response;var G=B.message;var A=B.stat;var D=B.details;if(typeof (A)=="string"){if(A=="ok"){var E=B.albumtoview;saveObj.albumtoview=E;$("panelProcessingSaveToAlbum").hide();$("saveToAlbumContent").hide();$("saveButtonPanel").hide();$("saveToAlbumSuccess").show();var C=$("saveToAlbumSuccess").select("iframe").first();C.src=C.src;controllerMessagePanel.printMessage({message:G,type:MessagePanelController.MSSG_TYPE_MESSAGE})}else{if(A=="fail"){controllerMessagePanel.printMessage({message:G,details:D})}}}}catch(F){controllerMessagePanel.printMessage({details:unknownErrorMessage})}$("panelProcessingSaveToAlbum").hide()},getAlbum:function(){var D=$("sel_album");var E=$("newalbum");var A;if(typeof (D)=="object"&&D){var A={albumname:D.getValue(),isNew:false};if(A.albumname=="new"){var C=D.options;var B=C[0].value;A={albumname:E.getValue().strip(),isNew:true,rootalbum:B}}}return A},setMessageBundle:function(A){this.oMessage=A},getClientSideValidationErrorMessage:function(){var C;if(!typeof (this.msg)=="object"){return }var B=$("sel_album");if(typeof (B)=="object"&&B){var A=B.getValue();if(A=="new"){var E=/^[_a-zA-Z0-9- ]+$/;var F=$("newalbum");var D;if(typeof (F)=="object"&&F){D=F.getValue().strip()}if(!(typeof (D=="string")&&D.length>0)){C=this.oMessage.enterAlbumName}else{if(!(typeof (D=="string")&&D.match(E))){C=this.oMessage.invalidAlbumFormat}else{if(!(typeof (D=="string")&&D.length>=2&&D.length<=50)){C=this.oMessage.invalidAlbumLength}}}if(typeof (C)=="string"){$("newalbum").focus()}}}return C},handleViewInAlbum:function(B){Event.stop(B);var A=this.albumtoview;window.location.href=A},loaded:function(){this.loggedIn=($("loginPrompt")!=null)?false:true;if(this.loggedIn){Form.focusFirstElement("formSaveToAlbum");Event.observe($("formSaveToAlbum"),"submit",this.submitEvtObj)}else{if(this.mediaurls!=null&&this.mediaurls.size()==1){var A=this.mediaurls.first();this.createCookie("savetoalbum",A,1)}}},deactivate:function(){if(this.loggedIn){Event.stopObserving($("formSaveToAlbum"),"submit",this.submitEvtObj)}else{this.createCookie("savetoalbum","",-1)}},createCookie:function(C,D,E){var A;if(E){var B=new Date();B.setTime(B.getTime()+(E*24*60*60*1000));A="; expires="+B.toGMTString()}else{A=""}document.cookie=C+"="+D+A+"; domain=.photobucket.com; path=/"}};function showNewAlbum(C){var B=false;if(C.options[C.selectedIndex].value=="new"){B=true}controllerMessagePanel.clearMessage();var A=$("inputNewalbum");$("newalbum").clear();if(B){A.show();$("newalbum").focus()}else{A.hide()}}var LoginPrompt=Class.create({mediaUrl:null,initialize:function(A){if(typeof (A)=="object"&&A){if(A.mediaUrl!=null){this.createCookie("savetoalbum",A.mediaUrl,1)}}},createCookie:function(C,D,E){var A;if(E){var B=new Date();B.setTime(B.getTime()+(E*24*60*60*1000));A="; expires="+B.toGMTString()}else{A=""}document.cookie=C+"="+D+A+"; domain=.photobucket.com; path=/"},deactivate:function(){this.createCookie("savetoalbum","",-1)}});var VanityUrl=Class.create();VanityUrl.prototype={ajaxOptions:null,container:null,vanity:null,vanityForm:null,vanity_prompt:"your name here",vanityBubble:null,validVanity:null,initialize:function(A){this.ajaxOptions={method:"post",asynchronous:true};Object.extend(this.ajaxOptions,A.ajaxOptions||{});this.submitEvtObj=this.submit.bindAsEventListener(this)},loaded:function(){this.container=$("vanityUrlOuterContent");this.vanityForm=this.container.select("#editVanityUrlForm")[0];if(this.vanityForm){this.vanity=this.vanityForm.select("#vanity")[0];Event.observe(this.vanity,"focus",this.unsetPrompt.bindAsEventListener(this),false);Event.observe(this.vanity,"focus",this.clearInput.bindAsEventListener(this),false);Event.observe(this.vanityForm,"submit",this.submitEvtObj,false);if($("definedVanity")&&$("definedVanity").value.length>0){this.vanity.value=$("definedVanity").value}else{if(this.vanity.value==this.vanity_prompt){this.vanity.addClassName("prompt")}}this.vanityBubble=new Bubble({posOffset:"true",elemId:"vanityHelp",targetId:"vanity",eventOn:"pb:vanitynameunavailable",callbackOn:this.populateVanitySuggestions.bindAsEventListener(this),offsetX:430,offsetY:-12})}},deactivate:function(){Event.stopObserving(this.vanityForm,"submit",this.submitEvtObj)},submit:function(A){$("saveButtonPanel").hide();$("panelProcessingSaveToAlbum").show();$("vanity").writeAttribute("readonly",true);if(this.validateVanity()){if(!this.validVanity){$("panelProcessingSaveToAlbum").hide();$("saveButtonPanel").show();$("vanity").writeAttribute("readonly",false);Event.stop(A)}}else{myLightbox.deactivate()}},validateVanity:function(){var A=this.vanity;if(!(A.value.length==0)){if($("definedVanity")&&$("definedVanity").value.length){if(A.value==$("definedVanity").value){return false}}if(A.value.search(/[^\w-]+/)>=0){controllerMessagePanel.printMessage({message:"Invalid Custom URL",details:"Custom URLs can only contain a-z, A-Z, 0-9, dashes, and underscores."});A.activate()}else{controllerMessagePanel.handleCloseErrorClick();new APIRequest("isvanitynameavailable",true,{vanityname:A.value},function(B){if(B.available==0){A.fire("pb:vanitynameunavailable",{suggestions:B.suggestions})}else{this.validVanity=true;this.vanityBubble.hide()}}.bind(this),null,null,null,false)}}else{A.value=this.vanity_prompt;A.addClassName("prompt")}return true},populateVanitySuggestions:function(F){var E=$("vanitynameSuggestions");var A=E.childElements();for(var B=0;B<A.length;B++){A[B].remove()}var D=F.memo.suggestions;for(var C=0;C<D.length;C++){li=document.createElement("li");a=document.createElement("a");a.href="javascript:void(0);";a.id=D[C]["suggestion"];a.appendChild(document.createTextNode(D[C]["suggestion"]));li.appendChild(a);E.appendChild(li);Event.observe(a,"click",this.handleSuggestionClick.bindAsEventListener(this),false)}return true},handleSuggestionClick:function(A){this.vanity.value=A.target.id;this.vanityBubble.hide()},clearInput:function(B){var A=B.target;if(A.value==this.vanity_prompt){A.value=""}},unsetPrompt:function(A){A.target.removeClassName("prompt")}};var AddFavoriteController=Class.create();AddFavoriteController.prototype={m_handler:null,initialize:function(A){this.m_handler=A.handler;this.loginUrl=A.loginUrl||false;var B=$("addFavoriteLink");if(B){Event.observe(B,"click",this.handleLaunchLightbox.bind(this))}if(A.openLightbox){Event.observe(document,"dom:loaded",this.handleLaunchLightbox.bind(this))}},handleLaunchLightbox:function(){if(this.loginUrl){document.location=this.loginUrl}else{myLightbox=new NotificationLightbox("?action=interstitial&secondary_action=addfavoritetpl",{ajaxOptions:{evalScripts:true,onComplete:function(){myLightbox.callbackLoaded()}},delegate:new Favorite(this.m_handler)})}}};var Favorite=Class.create();Favorite.prototype={m_handler:null,submitEvtObj:null,initialize:function(A){this.m_handler=A;this.ajaxOptions={method:"post",asynchronous:true};this.submitEvtObj=this.submit.bindAsEventListener(this)},loaded:function(){Form.focusFirstElement("addFavoriteForm");Event.observe($("addFavoriteForm"),"submit",this.submitEvtObj)},submit:function(A){Event.stop(A);this.showBusy();var C={};C.action="addtofavorites";C.name=$("addToFavorites_albumName").value;C.url=$("album_url").value;var B=this;new Ajax.Request(this.getDocUrl(),{method:"post",parameters:C,onSuccess:function(H){var E=H.responseText.evalJSON().response;var G=E.message;var D=E.stat;var F=E.details;if(E.stat=="ok"){B.showComplete();B.m_handler.onSuccess()}else{controllerMessagePanel.printMessage({message:E.err_string,type:MessagePanelController.MSSG_TYPE_ERROR})}B.hideBusy()},onFailure:function(D){controllerMessagePanel.printMessage({details:unknownErrorMessage});B.hideBusy()}})},getDocUrl:function(){var A=document.location.href;A=A.split("?")[0];A=A.split("#")[0];return A},showBusy:function(){$("saveButtonPanel").hide();$("panelProcessingAddFavorite").show()},hideBusy:function(){$("saveButtonPanel").show();$("panelProcessingAddFavorite").hide()},showComplete:function(){$("favorite_complete").show();$("favorite_contents").hide()}};var confirmUserInfo=Class.create();confirmUserInfo.prototype={elt:null,eltEmail:null,eltFname:null,eltLname:null,eltBMon:null,eltBDay:null,eltBYear:null,eltSaveButton:null,eltCurrentEmail:null,eltValidateUrl:null,eltValidated:null,eltConfirmUnderAge:null,initialize:function(){this.elt=$("confirmInfoForm");this.eltSaveButton=$("save");if(this.eltSaveButton){this.eltSaveButton.onclick=this.handleFormSubmitValidation.bindAsEventListener(this)}if(this.elt){Event.observe(this.elt,"submit",this.stopFormSubmit.bindAsEventListener(this),false)}},handleFormSubmitValidation:function(){this.eltEmail=$("email");this.eltFname=$("fname");this.eltLname=$("lname");this.eltBMon=$("birthMonth");this.eltBDay=$("birthDay");this.eltBYear=$("birthYear");this.eltCurrentEmail=$("currentemail");this.eltValidateUrl=$("validateurl");var D=$("underage");D.value=0;this.eltValidated=true;var A=new Array("An email address is required.",this.eltEmail,"A first name is required.",this.eltFname,"A last name is required.",this.eltLname,"Please enter a valid birth month.",this.eltBMon,"Please enter a valid birth day.",this.eltBDay,"Please enter a valid birth year.",this.eltBYear);for(var C=1;C<A.length;C+=2){if(C<=5){if(A[C].value==""){controllerMessagePanel.printMessage({message:"Attention",details:A[C-1],type:MessagePanelController.MSSG_TYPE_ERROR});this.eltValidated=false}}else{if(A[C].selectedIndex==0){controllerMessagePanel.printMessage({message:"Attention",details:A[C-1],type:MessagePanelController.MSSG_TYPE_ERROR});this.eltValidated=false}}}if(this.eltValidated){var B=this.eltValidateUrl.value;var E="action=accountoptions&confirmuserinfo=1&email="+escape(this.eltEmail.value)+"&fname="+escape(this.eltFname.value)+"&lname="+escape(this.eltLname.value)+"&bMon="+escape(this.eltBMon.value)+"&bDay="+escape(this.eltBDay.value)+"&bYear="+escape(this.eltBYear.value);new Ajax.Request(B,{method:"get",parameters:E,onSuccess:this.handleAjaxSuccess.bind(this),onFailure:this.handleAjaxFailure.bind(this)})}},handleAjaxSuccess:function(req){var response=req.responseText;response=eval("("+response+")");if(response.response.stat=="ok"&&this.eltValidated==true){this.elt.submit()}else{controllerMessagePanel.printMessage({message:"Attention",details:response.response.message,type:MessagePanelController.MSSG_TYPE_ERROR});if(response.response.underage==true){this.handleUnderAge()}}},handleAjaxFailure:function(A){controllerMessagePanel.printMessage({message:"Attention",details:"There was a problem saving your user information.",type:MessagePanelController.MSSG_TYPE_ERROR})},handleUnderAge:function(){var A=$("underage");A.value=1;this.eltConfirmUnderAge=$("underageconfirm");if(this.eltConfirmUnderAge){this.eltConfirmUnderAge.onclick=this.submitUnderAge.bindAsEventListener(this)}return },submitUnderAge:function(){this.elt.submit()},stopFormSubmit:function(A){Event.stop(A)}};function albumpost(A){document.albumform.action.value=A;document.albumform.submit()}var AlbumThumbnailView=Class.create();AlbumThumbnailView.prototype={strNoDescriptionDefault:"click to add title",objCopyCode:null,objImageEditBubbleCtrl:null,nSelectedMediaCounter:0,bAllChecked:false,descOrigBGColor:null,descBGColor:null,descHoverColor:null,bLinkOptionsOpen:false,urlBase:"",objLightbox:null,albumType:"user",eltForm:null,eltAction:null,strCurrSaveToAlbumIndex:"",initialize:function(G){var C,F,E=0;if(typeof (G)=="string"&&G.length>0){this.albumType=G}this.urlDomain=document.location.host;this.urlBase=this.getDocUrl();this.eltForm=$("thumbForm");this.eltAction=$("thumbAction");this.pendingQueue={};if(typeof (BubblesController)!="undefined"&&BubblesController){new BubblesController({idTarg:"txtTitleEdit_0",idBubble:"optionsHelp",eventOn:"",eventOff:""});new BubblesController({idTarg:"urlcode0",idBubble:"shareTagsHelp",eventOn:"",eventOff:""});if((C=$("bubbleImageEdit"))!=null&&(F=$("editBubbleEltID"))!=null&&F.value){Event.observe("imageEditBubbleCloseBox","click",this.setImageEditBubbleSeen.bindAsEventListener(this),false);this.objImageEditBubbleCtrl=new BubblesController({idBubble:"bubbleImageEdit",idTarg:F.value,eventOff:"click",callbackOff:this.setImageEditBubbleSeen.bind(this)});this.setImageEditBubblePostion(F.value)}}if((C=$("sponsoredMediaCount"))!=null&&typeof (C.value)!="undefined"&&!isNaN(E=parseInt(C.value))){getBrowserInfo();var H=[],D;for(D=0;D<E;D++){if((C=$("sponsoredMediaType_"+D))!=null&&typeof (C.value)!="undefined"&&(C.value=="slideshow"||C.value=="video"||C.value=="adobeexpress")&&$("sponsoredMedia_"+D)!=null){H.push("sponsoredMedia_"+D)}}for(D=0;D<E;D++){if((C=$("linkSponsoredSaveToAlbum_"+D))!=null){Event.observe(C,"click",this.handleSponsoredSaveToAlbum_closure(D).bindAsEventListener(this))}}}var B=this.getCheckboxes();for(var D in B){var A=B[D];if(A.checked){this.nSelectedMediaCounter++;eltLI=Element.up(A,"LI");this.highlightSelectedCell(A,eltLI);this.handlePendingChecked(A)}}this.enableDisableBatchActions(this.nSelectedMediaCounter==0);return true},findByClassName:function(E,D){var B=null,C,A;for(C=0,A=E.length;E&&C<A;C++){if(Element.hasClassName(E[C],D)){B=E[C];break}}return B},findByName:function(E,C){var B=null,D,A;for(D=0,A=E.length;E&&D<A;D++){if(E[D].name==C){B=E[D];break}}return B},handleSelectAllCheck:function(E){var B=Event.element(E),D,A;var C=this.eltForm.elements["selectedmedia[]"];if(B){this.bAllChecked=B.checked;if(typeof (C)=="object"&&typeof (C.length)=="undefined"){C=[C]}for(D=0,A=C.length;C&&D<A;D++){if(typeof (C[D].name)!="undefined"&&C[D].name=="selectedmedia[]"){C[D].checked=this.bAllChecked;this.highlightSelectedCell(C[D],Element.up(C[D],"LI"))}}}return true},handleImageCheck:function(C){var A=Event.element(C);var B=Event.findElement(C,"LI");this.highlightSelectedCell(A,B);return true},handleMultipleSaveToAlbum:function(E){APIRequest.track("save_to_album_"+this.albumType+"_thumbnail_multi");var B=this.eltForm.elements["selectedmedia[]"];if(typeof (B)=="object"&&typeof (B.length)=="undefined"){B=[B]}B=$A(B);var C={urls:new Array(),files:new Array()};B.each(function(I,G){if(I.checked){var H=$("mediaUrl_"+G).value;var F=I.value;C.urls.push(H);C.files.push(F)}});var D="";var A="?action=interstitial&secondary_action=retrievealbums";if(C.urls.size()==1){A+="&mediaUrl="+C.urls.first()}else{C.files.each(function(F){D+="&selectedmedia[]="+F})}myLightbox=new NotificationLightbox(A,{ajaxOptions:{evalScripts:true,onComplete:function(){myLightbox.callbackLoaded()},parameters:D},delegate:new SaveToAlbum({mediaurls:C.urls})})},handleMultipleTag:function(A){if(this.nSelectedMediaCounter>0){if(!this.validateMultiSelection()){return false}this.eltAction.value="tageditmany";this.eltForm.submit()}return true},handleMultipleDelete:function(B){if(this.nSelectedMediaCounter>0){if(!this.validateMultiSelection()){return false}var A=confirm("WARNING: Deleting files will cause your direct links, slideshows and remixes to break.\n\nAre you sure you want to do this?");if(A){this.eltAction.value="delete";this.eltForm.submit()}}return true},handleMultipleMove:function(A){if(this.nSelectedMediaCounter>0){this.eltAction.value="moveoptions";this.eltForm.submit()}return true},handleMultipleCodegen:function(A){if(this.nSelectedMediaCounter>0){this.eltAction.value="codegen";this.eltForm.submit()}return true},handleLinkOptionsClick:function(A){if(this.bLinkOptionsOpen==false){Element.show("containerLinkOptions");this.bLinkOptionsOpen=true}else{Element.hide("containerLinkOptions");this.bLinkOptionsOpen=false}Event.stop(A);return true},handleLinkOptionsSave:function(A){this.eltAction.value="changelinkoptions";this.eltForm.submit();return true},handleApproval:function(D,A,C){var B=location.pathname;B+="?action=";B+=(C)?"approvemedia":"rejectmedia";B+="&mediaUrl="+A;new Ajax.Request(B,{method:"get",onSuccess:function(F){if(C){$("approval_"+D).hide()}else{$("media_"+D).hide()}var E=$("chk_"+D);E.attributes.isPending.value=""}})},handlePendingChecked:function(C){var B=C.attributes.isPending;if(B&&B.value.indexOf("|")>-1){var A=B.value.split("|");if(C.checked){this.pendingQueue[A[0]]={id:A[0],url:A[1]}}else{delete this.pendingQueue[A[0]]}this.enableApprovalBatchAction()}},handleMultipleApproval:function(A){for(var C in this.pendingQueue){var B=this.pendingQueue[C];this.handleApproval(B.id,B.url,true)}this.pendingQueue={};this.enableApprovalBatchAction();return false},enableApprovalBatchAction:function(){var B=false;for(var A in this.pendingQueue){B=true;break}photobucket.ui.setButtonDisabled($("approve_selected"),!B)},handleSingleSaveToAlbum:function(C){APIRequest.track("save_to_album_"+this.albumType+"_thumbnail_single");var D="";var A=$("mediaUrl_"+C).value;var B="?action=interstitial&secondary_action=retrievealbums&mediaUrl="+A;myLightbox=new NotificationLightbox(B,{ajaxOptions:{evalScripts:true,onComplete:function(){myLightbox.callbackLoaded()},parameters:D},delegate:new SaveToAlbum({mediaUrl:A})})},handleSponsoredSaveToAlbum_closure:function(A){return function(){APIRequest.track("save_to_album_"+this.albumType+"_thumbnail_sponsored");var C=false;if($("loggedIn")!=null){C=true}var E="";var B=$("sponsoredMediaURL_"+A).value;var D="?action=interstitial&secondary_action=retrievealbums&mediaUrl="+B;if(C){myLightbox=new NotificationLightbox(D,{ajaxOptions:{evalScripts:true,onComplete:function(){myLightbox.callbackLoaded()},parameters:E},delegate:new SaveToAlbum({mediaUrl:B})})}else{myLightbox=new NotificationLightbox("/promptlogin",{ajaxOptions:{evalScripts:true,onComplete:function(){myLightbox.callbackLoaded()}},delegate:new LoginPrompt({mediaUrl:escape(this.urlMedia)})})}}},enableDisableBatchActions:function(D){var A=["tag_selected","delete_selected","move_selected","codegen","savetoalbum_selected"];for(var C=0;C<A.length;C++){var B=$(A[C]);photobucket.ui.setButtonDisabled(B,D)}this.enableApprovalBatchAction()},highlightSelectedCell:function(A,B){if(A&&B){if(A.checked&&B.className!="selectedCell"){B.className="selectedCell";this.nSelectedMediaCounter++}else{if(!A.checked&&B.className=="selectedCell"){B.className="";this.nSelectedMediaCounter--}}this.handlePendingChecked(A);this.enableDisableBatchActions(this.nSelectedMediaCounter==0)}},getCheckboxes:function(){var A=(new Array()).toArray();if(typeof (A=document.forms.thumbForm.elements["selectedmedia[]"])!="undefined"){if(typeof (A)!="object"||typeof (A.length)=="undefined"){A=([A]).toArray()}}return A},validateMultiSelection:function(){var D=false;var B=this.getCheckboxes();for(var C=0;C<B.length;C++){var E=B[C];if(!E.checked){continue}if(typeof E.attributes.isReadOnly!="undefined"){E.checked=false;var A=Element.up(E,"LI");this.highlightSelectedCell(E,A)}else{D=true}}return D},createCookie:function(C,D,E){var A;if(E){var B=new Date();B.setTime(B.getTime()+(E*24*60*60*1000));A="; expires="+B.toGMTString()}else{A=""}document.cookie=C+"="+D+A+"; domain=.photobucket.com; path=/"},parseVideoUrl:function(B){var A=B;B=B.split("?");if(B.length>1){B=B[1].split("file=");if(B.length>1){A=B[1]}}return A},getStrMediaType:function(B){var C=null,A;if(B&&(A=$("sponsoredMediaType_"+B))!=null&&typeof (A.value)!="undefined"){C=A.value}return C},getUrlMedia:function(C){var D=null,B;if(C&&(B=$("sponsoredMediaURL_"+C))!=null&&typeof (B.value)!="undefined"){D=B.value;var A=this.getStrMediaType(C);if(A=="video"){D=this.parseVideoUrl(D)}}return D},setImageEditBubblePostion:function(C){var B=$(C);var A=$("containerThumbnails");var E;if(B&&(E=$("bubbleImageEdit"))!=null){if(!Element.visible(E)){var D=getEltOffsetPos(B,A);Element.show(E);E.style.left=D.left-E.offsetWidth+28+"px";E.style.top=D.top+B.offsetHeight+10+"px";E.style.zIndex=5000}}return true},setImageEditBubbleSeen:function(){var B={};B.action="newEditorBubbleView";new Ajax.Request(this.urlBase,{method:"post",parameters:B});var A=$("bubbleImageEdit");this.objImageEditBubbleCtrl.hideBubble(A)},getDocUrl:function(){var A=document.location.href;A=A.split("?")[0];A=A.split("#")[0];return A}};function getEltIndex(B){var A=null,C;if(B&&typeof (B.id)!="undefined"&&typeof (C=B.id.split("_")[1])=="string"){A=C}return A}function determineMediaType(B){var A;var C;if((A=getEltIndex(B))!=null){var D=$("mediaUrl_"+A);var E=D.value;if(E.indexOf("/remix/player.swf")!=-1){C="remix"}else{if(E.indexOf("/player.swf")!=-1){C="video"}else{C="photo"}}}else{C="photo"}return C}function singleActionPreparation(A,C){var F=null,B=null,E,D=false;if(typeof (F=document.forms.thumbForm)!="undefined"){B=F.elements["selectedmedia[]"];F.elements.action.value=C}if(B){for(i=0,len=B.length;i<len;i++){if((E=getEltIndex(B[i]))!=null){if(E!=A){B[i].checked=false;D=true}else{B[i].checked=true}}}if(!D){B.checked=true}F.submit()}}function handleSingleMove(B){var A;if((A=getEltIndex(B))!=null){singleActionPreparation(A,"moveoptions")}return false}function handleSingleDelete(C){var B;var A=confirm("WARNING: Deleting files will cause your direct links, slideshows and remixes to break.\n\nAre you sure you want to do this?");if(A&&(B=getEltIndex(C))!=null){singleActionPreparation(B,"delete")}return false}function highlightInputText(A){if(A){A.select()}return true}function handleTitleClick(E){var F;var D=window.location.href.split("?")[0];if(E&&typeof (E.id)!="undefined"){var H=E.id;H=H.split("_");if(H[0]=="title"){var C,G=null,B=null;C=H[1];B=E.innerHTML;if(C&&(F=$("mediaUrl_"+C))!=null){G=F.value;var A=determineMediaType(E);if(A=="remix"){G=G.split("&")[0];G=decodeURIComponent(G)}}G=decodeURIComponent(G);if(G&&B&&C){new InplaceEditor({srcTextId:E.id,strAltTextSrcInputId:"mediaTitle_"+C,strTitleEltId:"pTitle_"+C,nDisplayLength:12,textEditId:"txtTitleEdit_"+C,bttnOkId:"okTitleEdit_"+C,bttnCancelId:"cancelTitleEdit_"+C,errorMssgId:"errorMssgTitleEdit_"+C,bSetFormSubmit:true,strDefaultText:"click to add title",strAttrToUpdate:"title",ajax:new AjaxWrapper(D,{method:"post",parameters:{action:"mediasettitle",media:G,title:B}})})}}}fireMouseEvent(E,"click");return false}function handleGridTitleClick(E){var F;var D=window.location.href.split("?")[0];if(E&&typeof (E.id)!="undefined"){var H=E.id;H=H.split("_");if(H[0]=="title"){var C,G=null,B=null;C=H[1];B=E.innerHTML;if(C&&(F=$("mediaUrl_"+C))!=null){G=F.value;var A=determineMediaType(E);if(A=="remix"){G=G.split("&")[0];G=decodeURIComponent(G)}}G=decodeURIComponent(G);if(G&&B&&C){new InplaceEditor({srcTextId:E.id,strAltTextSrcInputId:"mediaTitle_"+C,strTitleEltId:"containerTitle_"+C,nDisplayLength:12,textEditId:"txtTitleEdit_"+C,bttnOkId:"okTitleEdit_"+C,bttnCancelId:"cancelTitleEdit_"+C,errorMssgId:"errorMssgTitleEdit_"+C,bSetFormSubmit:false,strDefaultText:"click to add title",strAttrToUpdate:"title",ajax:new AjaxWrapper(D,{method:"post",parameters:{action:"mediasettitle",media:G,title:B}})})}}fireMouseEvent(E,"click")}return false}function handleGridDescriptionClick(E){var F;var D=window.location.href.split("?")[0];if(E&&typeof (E.id)!="undefined"){var H=E.id;H=H.split("_");if(H[0]=="description"){var C,G=null,B=null;C=H[1];B=E.innerHTML;if(C&&(F=$("mediaUrl_"+C))!=null){G=F.value;var A=determineMediaType(E);if(A=="remix"){G=G.split("&")[0];G=decodeURIComponent(G)}}G=decodeURIComponent(G);if(G&&B&&C){new InplaceEditor({srcTextId:E.id,strAltTextSrcInputId:"mediaDescription_"+C,strTitleEltId:"containerDescription_"+C,nDisplayLength:55,textEditId:"txtDescriptionEdit_"+C,bttnOkId:"okDescriptionEdit_"+C,bttnCancelId:"cancelDescriptionEdit_"+C,errorMssgId:"errorMssgDescriptionEdit_"+C,bSetFormSubmit:false,strDefaultText:"click to add description",strAttrToUpdate:"desc",ajax:new AjaxWrapper(D,{method:"post",parameters:{action:"mediasetdesc",media:G,desc:B}})})}}fireMouseEvent(E,"click")}return false}function setStaticWidth_IE(C){var B=1002;var A;if(photobucket.browser.isIE&&window.screen.width<=1024){document.body.style.width=B+"px"}return true}Event.observe(window,"load",setStaticWidth_IE,false);var ThumbLoadedHelper=Class.create();ThumbLoadedHelper.prototype={initialize:function(){this.paddingAdjustment=20;this.marginAdjustment=10;this.minWidth=90;this.minHeight=90},handleThumbLoad:function(A,G){var E=Event.element(A);if(!E.tagName){E=A.currentTarget}var F=$(G);if(F&&E){var B=Element.up(E,".image");if(B&&(this.minHeight>B.getHeight())){B.style.marginTop=this.marginAdjustment+"px"}var C=Math.max(E.getWidth()-this.paddingAdjustment,this.minWidth);F.style.width=C+"px";F.style.display="block";var D=E.getHeight()-F.getHeight();F.style.top=D+"px"}}};function handleGroupInvite(A){myLightbox=new NotificationLightbox(A,{ajaxOptions:{evalScripts:true}})}function clearTo(){obj=document.getElementById("to");if(obj.value=="separate email addresses by commas."){obj.className="to";obj.value=""}return }function clearSuccess(){obj=document.getElementById("to");obj.value="";return }var GroupShare=Class.create();GroupShare.prototype={eltContactDiv:null,eltNoContacsDiv:null,eltContactInner:null,eltToField:null,eltSendInvite:null,eltEmailContactInsert:null,eltDoneButton:null,eltNoContactsCancel:null,eltInsertButton:null,eltProgressMeter:null,eltNoContacsDiv:null,eltContactsTable:null,eltSelectAllCheck:null,listCheckBoxes:null,listTRs:null,shareUrl:null,track:null,eltSelectAllCheck:null,initialize:function(){var A;this.eltContactDiv=$("contactSelect");this.eltNoContacsDiv=$("noContacts");this.eltContactInner=$("contactDivInner");this.eltToField=$("to");this.eltEmailContactInsert=$("emailContactInsert");this.eltDoneButton=$("btnContactsDone");this.eltNoContactsCancel=$("btnNoContactsCancel");this.eltSendInvite=$("invite");this.eltInsertButton=$("btnContactsInsert");this.eltProgressMeter=$("progressMeter");this.eltNoContacsDiv=$("noContacts");this.shareUrl=$("shareUrl");this.track=$("track");if(this.eltEmailContactInsert){this.eltEmailContactInsert.onclick=this.handleToButtonClick.bindAsEventListener(this)}if(this.eltInsertButton){this.eltInsertButton.onclick=this.handleInsertButtonClick.bindAsEventListener(this)}if(this.eltDoneButton){this.eltDoneButton.onclick=this.handleDoneButtonClick.bindAsEventListener(this)}if(this.eltNoContactsCancel){this.eltNoContactsCancel.onclick=this.handleNoContactsCancelClick.bindAsEventListener(this)}if(this.eltSendInvite){this.eltSendInvite.onclick=this.handleEmailSendInvite.bindAsEventListener(this)}},clearDefaultToFieldText:function(){clearTo()},handleEmailSendInvite:function(J){var B=true;var A=this.shareUrl.value;var I=$("uname");var H=$("to");var C=$("message");var G=new Array("recipient",H,"message",C);for(var E=1;E<G.length;E+=2){if(G[E].value==""||G[E].value=="separate email addresses by commas."){var F="A "+G[E-1]+" is required.";controllerMessagePanel.printMessage({message:"Attention",details:F,type:MessagePanelController.MSSG_TYPE_ERROR});B=false}}if(B){var D="action=shareGroup&uname="+escape(I.value)+"&recipients="+escape(H.value)+"&msg="+escape(C.value);if(this.track){D+="&first=1"}new Ajax.Request(A,{method:"get",parameters:D,onSuccess:this.handleAjaxSuccess.bind(this),onFailure:this.handleAjaxFailure.bind(this)})}},handleAjaxSuccess:function(req){var response=req.responseText;response=eval("("+response+")");if(response.response.stat=="ok"){clearSuccess();controllerMessagePanel.printMessage({message:"Success!",details:'Your email has been sent.<br />Click <a href="javascript: myLightbox.deactivate();">here</a> to go back to your group album.',type:MessagePanelController.MSSG_TYPE_MESSAGE})}else{controllerMessagePanel.printMessage({message:"Attention",details:"There was a problem sending your email.",type:MessagePanelController.MSSG_TYPE_ERROR})}},handleAjaxFailure:function(A){alert("died");alert("r"+A.toString())},handleToButtonClick:function(C){this.windowCleaner();Element.show(this.eltContactDiv);var A=new APIRequest("getusercontacts",false,null,this.xHandlerSuccess.bind(this),this.xHandlerFailure.bind(this),true);var B=new Ajax.Request("?action=getusercontacts",{asynchronous:true,method:"GET",parameters:null,onSuccess:A.handleSuccess.bind(A),onFailure:A.handleFailure.bind(A)});return true},handleInsertButtonClick:function(F){this.clearDefaultToFieldText();var E=new Array();var C;var B;var A=this.eltToField.value;A=A.replace(/[, ]*$/,"");for(i=0;i<this.listCheckBoxes.length;i++){if(this.listCheckBoxes[i].checked){B=this.listCheckBoxes[i].value;if(B&&A.indexOf(B)<0&&E.indexOf(B)<0){E.push(B)}}}if(E.length>0){var D=E.join(", ");if(A){A+=", "}this.eltToField.value=A+D}this.windowCleaner()},handleCheckContact:function(D){var B=Event.element(D);var A=Event.findElement(D,"TR");if(B&&A){if(B.checked){Element.addClassName(A,"selectedRow")}else{Element.removeClassName(A,"selectedRow")}}var C=this.getAllContactsCheckedState();if(C==this.ALL_CHECKED){if(!this.eltSelectAllCheck.checked){this.eltSelectAllCheck.checked=true}photobucket.ui.setButtonDisabled(this.eltInsertButton,false)}else{if(C==this.ALL_UNCHECKED){if(this.eltSelectAllCheck.checked){this.eltSelectAllCheck.checked=false}photobucket.ui.setButtonDisabled(this.eltInsertButton,true)}else{photobucket.ui.setButtonDisabled(this.eltInsertButton,false)}}return true},handleCheckAllContacts:function(A){if(this.eltSelectAllCheck&&this.listCheckBoxes){if(this.eltSelectAllCheck.checked){this.listCheckBoxes.each(function(B){B.checked=true});this.listTRs.each(function(B){Element.addClassName(B,"selectedRow")});photobucket.ui.setButtonDisabled(this.eltInsertButton,false)}else{this.listCheckBoxes.each(function(B){B.checked=false});this.listTRs.each(function(B){Element.removeClassName(B,"selectedRow")});photobucket.ui.setButtonDisabled(this.eltInsertButton,true)}}return true},getAllContactsCheckedState:function(){var C=0,B,A,D=this.SOME_CHECKED;for(B=0,A=this.listCheckBoxes.length;this.listCheckBoxes[B]&&B<A;B++){if(this.listCheckBoxes[B].checked){C++}}if(this.listCheckBoxes.length==C){D=this.ALL_CHECKED}else{if(C==0){D=this.ALL_UNCHECKED}}return D},handleDoneButtonClick:function(A){this.windowCleaner()},handleNoContactsCancelClick:function(A){this.windowCleaner()},windowCleaner:function(){var A;Element.update(this.eltContactInner,"");this.listTRs=null;this.listCheckBoxes=null;if(this.eltSelectAllCheck){this.eltSelectAllCheck.checked=false}photobucket.ui.setButtonDisabled(this.eltInsertButton,true);Element.hide(this.eltContactDiv);Element.hide(this.eltNoContacsDiv);Element.hide(this.eltContactInner);Element.show(this.eltProgressMeter)},getDisplayName:function(A){var B="";if(A.first&&A.last){B=A.first+" "+A.last}else{if(A.first){B=A.first}else{if(A.last){B=A.last}}}return B},getTHEAD:function(){var A="<thead>\n";A+="<tr>";A+='<th class="cellSelectAll">';A+='<input type="checkbox" name="select_all" id="select_all" value="entry_all" title="select/unselect all">';A+="</th>";A+="<th>Name</th>";A+="<th>Details</th>";A+="</tr>\n";A+="</thead>\n";return A},xHandlerFailure:function(A){var B="<!-- Scrolling content -->";B+='<table id="contactsList">';B+=this.getTHEAD();B+="<tbody>";B+='<tr><td colspan="3">Error retrieving contact list from the server...</td></tr>';B+="</tbody></table><!-- END: scrolling content -->";Element.update(this.eltContactInner,B);Element.show(this.eltContactInner);Element.hide(this.eltProgressMeter)},xHandlerSuccess:function(A){var C="<!-- Scrolling content -->\n";C+='<table id="contactsList">\n';C+=this.getTHEAD();C+="<tbody>\n";if(A.usercontacts&&A.usercontacts.contacts_count>0){var D=A.usercontacts;for(var B=0;B<D.contacts_count;B++){C+="<tr>";C+="<th>";C+='<input type="checkbox" name="selectedcontacts[]" id="entry_'+B+'" value="'+D[B].contact.primary_email+'">';C+="</th>";C+="<td>";C+='<label for="entry_'+B+'">'+this.getDisplayName(D[B].contact)+"</label>";C+="</td>";C+="<td>";C+='<label for="entry_'+B+'">'+D[B].contact.primary_email+"</label>";C+="</td>";C+="</tr>\n"}C+="</tbody></table><!-- END: scrolling content -->";Element.update(this.eltContactInner,C);this.eltContactsTable=$("contactsList");this.eltSelectAllCheck=$("select_all");Element.show(this.eltContactInner);Element.hide(this.eltProgressMeter);if(this.eltSelectAllCheck!=null){this.eltSelectAllCheck.onclick=this.handleCheckAllContacts.bindAsEventListener(this)}this.attachContactList()}else{Element.hide(this.eltContactDiv);Element.show(this.eltNoContacsDiv)}},attachContactList:function(){var B,D,C,A;if(this.eltContactsTable!=null&&(D=this.eltContactsTable.getElementsByTagName("INPUT"))!=null){D=$A(D);this.listCheckBoxes=D.findAll(function(E){return(E.name=="selectedcontacts[]"&&E.type=="checkbox")});for(C=0,A=this.listCheckBoxes.length;this.listCheckBoxes&&C<A;C++){this.listCheckBoxes[C].onclick=this.handleCheckContact.bindAsEventListener(this)}}if(this.eltContactsTable!=null&&(D=this.eltContactsTable.getElementsByTagName("TR"))!=null){D=$A(D);this.listTRs=D.findAll(function(E){return(E.parentNode&&E.parentNode.tagName=="TBODY")})}}};function handleGroupOptions(A){myLightbox=new NotificationLightbox(A,{ajaxOptions:{evalScripts:true}})}function checkPublic(B){var A=document.getElementById("groupAlbumPassword");if(B.value==1&&B.checked==true){A.disabled=true}else{A.disabled=false}return }var GroupOptions=Class.create();GroupOptions.prototype={eltForm:null,eltGroupName:null,eltGroupPublic:null,eltGroupPassword:null,eltGroupViewer:null,eltGroupEmail:null,eltSaveButton:null,eltClose:null,initialize:function(){this.eltGroupName=$("groupname");this.eltGroupPublic=document.options.groupAlbumView;this.eltGroupPassword=$("groupAlbumPassword");this.eltGroupViewer=document.options.viewer;this.eltGroupEmail=$("email");this.eltSaveButton=$("save");this.eltCancelButton=$("cancel");this.eltClose=true;if((this.eltForm=$("options"))!=null){Event.observe(this.eltForm,"submit",this.validateAndSave.bindAsEventListener(this),false)}Event.observe(this.eltCancelButton,"click",this.checkCloseOrRefresh.bindAsEventListener(this),false)},validateAndSave:function(H){var A,F,C,E,B;A=this.eltGroupName.value;F=this.getValue(this.eltGroupPublic);C=this.eltGroupPassword.value;E=this.getValue(this.eltGroupViewer);if(A==""){controllerMessagePanel.printMessage({message:"Attention",details:"A group name is required.",type:MessagePanelController.MSSG_TYPE_ERROR});Event.stop(H)}if(F==0&&C==""){controllerMessagePanel.printMessage({message:"Attention",details:"A guest password is required for a private group album.",type:MessagePanelController.MSSG_TYPE_ERROR});Event.stop(H)}if(F==0&&C!=""){var D=/^[a-zA-Z0-9_-]{5,}$/;var G=D.test(C);if(!G){controllerMessagePanel.printMessage({message:"Attention",details:"Your guest password must be at least 5 characters long.  It can only contain the characters a-z, A-Z, 0-9, -, _, contain no spaces, and cannot start with a zero.",type:MessagePanelController.MSSG_TYPE_ERROR});Event.stop(H)}}},getValue:function(C){var B;for(var A=0;A<C.length;A++){if(C[A].checked==true){B=C[A].value}}return B},checkCloseOrRefresh:function(){if(this.eltClose){myLightbox.deactivate()}}};
